* feat(#195): add chat attachment support for files and images - Add Attachment data model with computed properties (isImage, formattedSize, fileExtension) - Extend ChatMessage with optional attachments list - Add Coil 2.7.0 for async image loading in Compose - Extend ChatViewModel with pending attachment state, addAttachment/removeAttachment/clearAttachments - Build attachment-prefixed message text (data URIs for images, file refs for others) - Add paperclip button and file picker launcher (ActivityResultContracts.GetContent) to ChatScreen - Add animated attachment preview chips with thumbnails before sending - Render attachments inline in UserBubble (AsyncImage for images, file cards for others) - Add string resources for attachment UI features * fix(#195): rewrite attachment upload protocol to match Hermes backend RPC methods BREAKS: removes old buildAttachmentText() that embedded base64 data URIs in prompt text. Changes: - Replace inline data-URI encoding with proper backend RPC flow: - image.attach_bytes for images (fire-and-forget, auto-queues to session) - file.attach for non-image files (awaited, returns @file: ref text) - Add CompletableDeferred to PendingRequest so sendMessage can await RPC responses - Add readContentUriBytes() to read file content from content:// URIs - Add sendRpcAndAwait() suspend function for sequential RPC calls - Add RpcCallException for awaited RPC error handling - Suppress error UI for awaited RPCs (caller handles them directly) - Keep ChatScreen/ChatBubble UI layer unchanged (file picker, previews, inline images) * feat(#195): add camera capture support via FileProvider + TakePicture contract - Creates temporary photo files in cacheDir via FileProvider - Launches system camera with ActivityResultContracts.TakePicture - Adds camera icon button (📷) next to the paperclip in ChatInputBar - Captured photos added as image/jpeg attachments via same addAttachment flow - FileProvider configured with cache-root path in res/xml/file_paths.xml - Error handling for launch failures and capture failures with snackbar * refactor(#195): group camera/image/file into single attach dropdown - Replaces separate 📷 and 📎 buttons with a single 📎 button - DropdownMenu opens with three options: - 📷 Camera → TakePicture via FileProvider temp URI - 🖼️ Image → GetContent("image/*") - 📄 File → GetContent("*/*") - Removes onAttachClick, adds onImageTap/onFileTap callbacks - Input bar stays clean with one attachment affordance * fix(#195): add missing imports for CI compilation ChatScreen.kt: - android.util.Log - androidx.compose.animation.core.* (infiniteRepeatable, tween, LinearEasing, RepeatMode, rememberInfiniteTransition) - androidx.compose.foundation.layout.widthIn - androidx.compose.material.icons.filled.AttachFile - androidx.compose.material.icons.filled.InsertDriveFile - androidx.compose.ui.layout.ContentScale - coil.compose.AsyncImage ChatBubble.kt: - androidx.compose.material.icons.filled.InsertDriveFile * fix(#195): resolve android-lint LocalContextGetResourceValueCall error Replace context.getString(R.string.chat_camera_error) with a composable-level cameraErrorMsg captured via stringResource() to avoid querying resources via LocalContext.current in a callback. * fix(#195): migrate InsertDriveFile to AutoMirrored, fix chip double-remove - Replace deprecated Icons.Filled.InsertDriveFile with Icons.AutoMirrored.Filled.InsertDriveFile in ChatBubble.kt and ChatScreen.kt - Remove onClick from AttachmentChip Surface so only the dedicated close button triggers removal, not accidental taps on the chip body --------- Co-authored-by: Hermes Agent <hermes@agent.local>
198 lines
6.6 KiB
Kotlin
198 lines
6.6 KiB
Kotlin
import org.gradle.api.tasks.testing.Test
|
|
|
|
plugins {
|
|
alias(libs.plugins.android.application)
|
|
alias(libs.plugins.compose.compiler)
|
|
alias(libs.plugins.kotlin.serialization)
|
|
alias(libs.plugins.room)
|
|
alias(libs.plugins.ksp)
|
|
}
|
|
|
|
android {
|
|
namespace = "com.m57.hermescontrol"
|
|
compileSdk = 36
|
|
defaultConfig {
|
|
applicationId = "com.m57.hermescontrol"
|
|
minSdk = 26
|
|
targetSdk = 36
|
|
// Version overrides passed from CI via -PversionName / -PversionCode
|
|
// Falls back to defaults for local development.
|
|
versionCode = (project.findProperty("versionCode") as? String)?.toIntOrNull() ?: 1
|
|
versionName = (project.findProperty("versionName") as? String) ?: "1.0-dev"
|
|
|
|
// Embed git commit SHA for the About card in Settings
|
|
val gitSha =
|
|
providers.exec {
|
|
commandLine("git", "rev-parse", "--short", "HEAD")
|
|
}.standardOutput.asText.get().trim()
|
|
buildConfigField("String", "GIT_SHA", "\"$gitSha\"")
|
|
}
|
|
|
|
signingConfigs {
|
|
create("release") {
|
|
val isReleaseBuild =
|
|
gradle.startParameter.taskNames.any { name ->
|
|
name.contains("Release", ignoreCase = true) || name == "build"
|
|
}
|
|
|
|
if (isReleaseBuild) {
|
|
val storePath = System.getenv("KEYSTORE_PATH")
|
|
val storePass = System.getenv("KEYSTORE_PASSWORD")
|
|
val alias = System.getenv("KEY_ALIAS")
|
|
val keyPass = System.getenv("KEY_PASSWORD")
|
|
|
|
if (storePath != null && storePass != null && alias != null && keyPass != null) {
|
|
storeFile = file(storePath)
|
|
storePassword = storePass
|
|
keyAlias = alias
|
|
keyPassword = keyPass
|
|
} else {
|
|
// Env vars missing — signing deferred to release workflow.
|
|
// Don't hard-require(): that would break compileReleaseKotlin
|
|
// in CI where keystore secrets aren't set.
|
|
logger.warn("Release signing config missing env vars — signing deferred to release workflow")
|
|
storeFile = file("dummy.keystore")
|
|
storePassword = "dummy"
|
|
keyAlias = "dummy"
|
|
keyPassword = "dummy"
|
|
}
|
|
} else {
|
|
// Dummy values for evaluation configuration during non-release builds
|
|
storeFile = file("dummy.keystore")
|
|
storePassword = "dummy"
|
|
keyAlias = "dummy"
|
|
keyPassword = "dummy"
|
|
}
|
|
}
|
|
}
|
|
|
|
buildTypes {
|
|
release {
|
|
isMinifyEnabled = true
|
|
isShrinkResources = true
|
|
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro")
|
|
signingConfig = signingConfigs["release"]
|
|
}
|
|
}
|
|
compileOptions {
|
|
sourceCompatibility = JavaVersion.VERSION_21
|
|
targetCompatibility = JavaVersion.VERSION_21
|
|
}
|
|
buildFeatures {
|
|
compose = true
|
|
aidl = false
|
|
buildConfig = true
|
|
shaders = false
|
|
}
|
|
|
|
dependenciesInfo {
|
|
includeInApk = false
|
|
}
|
|
|
|
packaging {
|
|
resources {
|
|
pickFirsts += "META-INF/AL2.0"
|
|
pickFirsts += "META-INF/LGPL2.1"
|
|
pickFirsts += "META-INF/LICENSE"
|
|
pickFirsts += "META-INF/LICENSE.md"
|
|
pickFirsts += "META-INF/LICENSE-notice.md"
|
|
pickFirsts += "META-INF/NOTICE"
|
|
pickFirsts += "META-INF/NOTICE.md"
|
|
}
|
|
}
|
|
}
|
|
|
|
kotlin {
|
|
jvmToolchain(21)
|
|
}
|
|
|
|
room {
|
|
schemaDirectory("$projectDir/schemas")
|
|
}
|
|
|
|
dependencies {
|
|
val composeBom = platform(libs.androidx.compose.bom)
|
|
implementation(composeBom)
|
|
androidTestImplementation(composeBom)
|
|
|
|
// Core Android dependencies
|
|
implementation(libs.androidx.core.ktx)
|
|
implementation(libs.androidx.lifecycle.runtime.ktx)
|
|
implementation(libs.androidx.activity.compose)
|
|
|
|
// Arch Components
|
|
implementation(libs.androidx.lifecycle.runtime.compose)
|
|
implementation(libs.androidx.lifecycle.viewmodel.compose)
|
|
|
|
// Compose
|
|
implementation(libs.androidx.compose.ui)
|
|
implementation(libs.androidx.compose.ui.tooling.preview)
|
|
implementation(libs.androidx.compose.material3)
|
|
implementation(libs.androidx.compose.material.icons.extended)
|
|
// Tooling
|
|
debugImplementation(libs.androidx.compose.ui.tooling)
|
|
debugImplementation(libs.leakcanary.android)
|
|
// Instrumented tests
|
|
androidTestImplementation(libs.androidx.compose.ui.test.junit4)
|
|
debugImplementation(libs.androidx.compose.ui.test.manifest)
|
|
|
|
// Networking
|
|
implementation(libs.okhttp)
|
|
implementation(libs.okhttp.logging)
|
|
implementation(libs.retrofit)
|
|
implementation(libs.retrofit.converter.gson)
|
|
implementation(libs.gson)
|
|
|
|
// Image loading
|
|
implementation(libs.coil.compose)
|
|
|
|
// Encrypted storage
|
|
implementation(libs.androidx.security.crypto)
|
|
implementation("androidx.startup:startup-runtime:1.1.1")
|
|
|
|
// Local database (Room) — message persistence
|
|
implementation(libs.androidx.room.runtime)
|
|
implementation(libs.androidx.room.ktx)
|
|
implementation(libs.sqlcipher)
|
|
ksp(libs.androidx.room.compiler)
|
|
|
|
// Local tests: jUnit, coroutines, Android runner
|
|
testImplementation(libs.junit)
|
|
testImplementation(libs.junit.jupiter.api)
|
|
testRuntimeOnly(libs.junit.jupiter.engine)
|
|
testRuntimeOnly(libs.junit.vintage.engine)
|
|
testRuntimeOnly(libs.junit.platform.launcher)
|
|
testImplementation(libs.okhttp.mockwebserver)
|
|
testImplementation(libs.kotlinx.coroutines.test)
|
|
testImplementation(libs.mockk)
|
|
|
|
// Instrumented tests: jUnit rules and runners
|
|
androidTestImplementation(libs.androidx.test.core)
|
|
androidTestImplementation(libs.androidx.test.ext.junit)
|
|
androidTestImplementation(libs.androidx.test.runner)
|
|
androidTestImplementation(libs.androidx.test.espresso.core)
|
|
androidTestImplementation(libs.mockk.android)
|
|
|
|
// Navigation
|
|
implementation(libs.androidx.navigation3.ui)
|
|
implementation(libs.androidx.navigation3.runtime)
|
|
implementation(libs.androidx.lifecycle.viewmodel.navigation3)
|
|
}
|
|
|
|
tasks.register<Exec>("ktlintCheck") {
|
|
group = "verification"
|
|
description = "Runs ktlint check."
|
|
workingDir = rootProject.projectDir
|
|
commandLine("sh", "-c", "ktlint \"app/src/**/*.kt\"")
|
|
}
|
|
tasks.register<Exec>("ktlintFormat") {
|
|
group = "formatting"
|
|
description = "Runs ktlint format."
|
|
workingDir = rootProject.projectDir
|
|
commandLine("sh", "-c", "ktlint -F \"app/src/**/*.kt\"")
|
|
}
|
|
|
|
tasks.withType<Test> {
|
|
useJUnitPlatform()
|
|
}
|