Adds a small `:translate` Gradle module that translates received SMS / MMS bubbles and conversation-list snippets on the fly by binding to the offline-translator app on F-Droid (`dev.davidv.translator`). The actual translation runs there — Mozilla Bergamot/Marian on-device — so this patch ships no model, no inference, and no permissions beyond an Android 11+ <queries> block for package visibility. Behavior: - User-defined source-language allowlist + target language in Settings → Translation (right after Language). Off by default. - Auto-translate fires on RecyclerView bind for received bubbles and conversation snippets. Detection uses ML Kit Language Identification (CLD3, on-device). Once dev.davidv.translator exposes a detectLanguage() AIDL method we'll route through that and drop ML Kit. - AIDL latency is sub-second, so the bubble just quietly swaps from the original to the translation — no loading spinner. - Tap the translate icon next to a bubble to flip it back to the original; tap again to flip to the translation. Cached in process memory. - Long-press → ⋮ → Translate forces a one-off translation regardless of the allowlist (useful for messages in non-allowlisted languages), with a toast surfacing AIDL errors like 'language pack not installed'. - Copy / Share / Select on a translated bubble captures what the user sees, not the underlying source body. - Silently no-ops when offline-translator isn't installed; settings screen shows an F-Droid install banner. - Translation Settings is a regular Fossify sub-screen with MyAppBarLayout + MaterialToolbar + NestedScrollView, matching Manage Blocked Numbers / Keywords / SettingsActivity. No new database, no service, no boot receiver, no foreground service. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
37 lines
1 KiB
Kotlin
37 lines
1 KiB
Kotlin
plugins {
|
|
id("com.android.library")
|
|
}
|
|
|
|
android {
|
|
namespace = "org.fossify.messages.translate"
|
|
compileSdk = project.libs.versions.app.build.compileSDKVersion.get().toInt()
|
|
|
|
defaultConfig {
|
|
minSdk = project.libs.versions.app.build.minimumSDK.get().toInt()
|
|
}
|
|
|
|
buildFeatures {
|
|
aidl = true
|
|
viewBinding = true
|
|
}
|
|
|
|
compileOptions {
|
|
val javaVersion = JavaVersion.valueOf(libs.versions.app.build.javaVersion.get())
|
|
sourceCompatibility = javaVersion
|
|
targetCompatibility = javaVersion
|
|
}
|
|
|
|
sourceSets {
|
|
getByName("main").java.srcDirs("src/main/kotlin")
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
// Fossify base for SimpleActivity / MyTextView / theming so this
|
|
// settings screen looks and behaves like the rest of the app.
|
|
implementation(libs.fossify.commons)
|
|
|
|
// Bundled CLD3 language identification — transitional; will be replaced
|
|
// by an AIDL detectLanguage() call once dev.davidv.translator exposes it.
|
|
implementation(libs.mlkit.language.id)
|
|
}
|