Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions app/src/main/kotlin/com/google/ai/sample/ApiKeyDialog.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
package com.google.ai.sample

import android.content.Intent
import android.net.Uri
import androidx.compose.foundation.layout.*
import androidx.compose.foundation.lazy.LazyColumn
import androidx.compose.foundation.lazy.itemsIndexed
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp
import androidx.compose.ui.window.Dialog
Expand All @@ -24,6 +27,7 @@ fun ApiKeyDialog(
var errorMessage by remember { mutableStateOf("") }
val apiKeys = remember { mutableStateListOf<String>() }
var selectedKeyIndex by remember { mutableStateOf(apiKeyManager.getCurrentKeyIndex()) }
val context = LocalContext.current

// Load existing keys
LaunchedEffect(Unit) {
Expand Down Expand Up @@ -63,6 +67,19 @@ fun ApiKeyDialog(
)
}

// Get API Key button
Button(
onClick = {
val intent = Intent(Intent.ACTION_VIEW, Uri.parse("https://aistudio.google.com/u/0/apikey"))
context.startActivity(intent)
},
modifier = Modifier
.fillMaxWidth()
.padding(bottom = 16.dp)
) {
Text("Get API Key")
}

// Input field for new API key
OutlinedTextField(
value = apiKeyInput,
Expand Down