diff --git a/README.md b/README.md index b4832c7..91dc42f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ Please add your own API key into `local.properties` after cloning this app. You can get Gemini API key [here](https://ai.google.dev/). ``` -API_KEY=[your api key] +apiKey=[your api key] ``` ### Screenshots diff --git a/app/build.gradle.kts b/app/build.gradle.kts index e8c0e6c..056131a 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -14,31 +14,23 @@ android { applicationId = "levi.lin.gemini.android" minSdk = 30 targetSdk = 34 - versionCode = 8 - versionName = "0.1.1" + versionCode = 9 + versionName = "0.2.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" vectorDrawables { useSupportLibrary = true } - - val properties = Properties() - if (project.rootProject.file("local.properties").canRead()) { - properties.load(project.rootProject.file("local.properties").inputStream()) - - } - - buildConfigField("String", "apiKey", "\"${properties.getProperty("API_KEY")}\"") } buildTypes { release { isMinifyEnabled = false proguardFiles( - getDefaultProguardFile("proguard-android-optimize.txt"), + getDefaultProguardFile(name = "proguard-android-optimize.txt"), "proguard-rules.pro" ) - signingConfig = signingConfigs.getByName("debug") + signingConfig = signingConfigs.getByName(name = "debug") } } compileOptions { @@ -53,7 +45,7 @@ android { buildConfig = true } composeOptions { - kotlinCompilerExtensionVersion = "1.5.1" + kotlinCompilerExtensionVersion = "1.5.8" } packaging { resources { diff --git a/app/src/main/java/levi/lin/gemini/android/viewmodel/GeminiViewModel.kt b/app/src/main/java/levi/lin/gemini/android/viewmodel/GeminiViewModel.kt index cb9e8c0..a01b6a9 100644 --- a/app/src/main/java/levi/lin/gemini/android/viewmodel/GeminiViewModel.kt +++ b/app/src/main/java/levi/lin/gemini/android/viewmodel/GeminiViewModel.kt @@ -28,7 +28,7 @@ class GeminiViewModel( private val _selectedImageBitmaps = MutableStateFlow>(emptyList()) val selectedImageBitmaps: StateFlow> = _selectedImageBitmaps.asStateFlow() - private val _selectedImageCount = MutableStateFlow(0) + private val _selectedImageCount = MutableStateFlow(value = 0) val selectedImageCount: StateFlow = _selectedImageCount.asStateFlow() private val _generativeModelFlow = MutableSharedFlow() @@ -38,22 +38,16 @@ class GeminiViewModel( _uiState.value = GeminiUiState.Loading val deviceLanguage = Locale.getDefault().displayLanguage - val textPrompt = - "Content:($inputText) \\n You are a lovely assistant. According to the provided content, " - val imagePrompt = - "Content:($inputText) \\n You are a lovely assistant. According to the provided images and content, " - val generalPrompt = - "if the content is a question, answer the question in $deviceLanguage. If the content is a request, respond with detailed information in $deviceLanguage." + val prompt = + "$inputText (respond in $deviceLanguage)" val imageList = selectedImageBitmaps.value val inputContent = content { if (imageList.isNotEmpty()) { imageList.forEach { image -> image(image = image) } - text(text = imagePrompt + generalPrompt) - } else { - text(text = textPrompt + generalPrompt) } + text(text = prompt) } viewModelScope.launch { @@ -63,7 +57,7 @@ class GeminiViewModel( _uiState.value = GeminiUiState.Success(outputContent) } } catch (e: Exception) { - _uiState.value = GeminiUiState.Error(e.localizedMessage ?: "") + _uiState.value = GeminiUiState.Error(errorMessage = e.localizedMessage ?: "") } } } diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index ebc7b66..4091d76 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,6 +1,6 @@ [versions] -agp = "8.4.0-alpha07" -kotlin = "1.9.0" +agp = "8.2.2" +kotlin = "1.9.22" coreKtx = "1.12.0" junit = "4.13.2" junitVersion = "1.1.5"