Skip to content

Commit

Permalink
Merge pull request #11 from gy6543721/develop
Browse files Browse the repository at this point in the history
[Release] 0.2.0
  • Loading branch information
gy6543721 authored Jan 30, 2024
2 parents c358853 + 26f4886 commit 6b69cdc
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 27 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 5 additions & 13 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -53,7 +45,7 @@ android {
buildConfig = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.5.1"
kotlinCompilerExtensionVersion = "1.5.8"
}
packaging {
resources {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class GeminiViewModel(
private val _selectedImageBitmaps = MutableStateFlow<List<Bitmap>>(emptyList())
val selectedImageBitmaps: StateFlow<List<Bitmap>> = _selectedImageBitmaps.asStateFlow()

private val _selectedImageCount = MutableStateFlow(0)
private val _selectedImageCount = MutableStateFlow(value = 0)
val selectedImageCount: StateFlow<Int> = _selectedImageCount.asStateFlow()

private val _generativeModelFlow = MutableSharedFlow<GenerativeModel>()
Expand All @@ -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 {
Expand All @@ -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 ?: "")
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit 6b69cdc

Please sign in to comment.