pachli-android/app/build.gradle
Nik Clayton d40b87f0a0
feat: Translate statuses on cached timelines (#220)
Implement some support for server-side status translation. Do this by:

- Implement support for the `api/v1/instance` endpoint to determine if
  the remote server supports translation.

- Create new `ServerCapabilities` to allow the app to query the remote
  capabilities in a server-agnostic way. Use this to query if the
  remote server supports the Mastodon implementation of server-side
  translation

- If translation is supported then show a translate/undo translate
  option on the status "..." menu.

- Fetch translated content from the server if requested, and store it
  locally as a new Room entity.

- Update displaying a status to check if the translated version
  should be displayed; if it should then new code is used to show
  translated content, content warning, poll options, and media
  descriptions.

- Add a `TextView` to show an "in progress" message while translation
  is happening, and to show the translation provider (generally
  required by agreements with them).

Partially fixes #62

---------

Co-authored-by: sanao <naosak1006@gmail.com>
2023-11-12 19:51:46 +01:00

251 lines
7.0 KiB
Groovy

plugins {
alias(libs.plugins.android.application)
alias(libs.plugins.google.ksp)
alias(libs.plugins.kotlin.android)
alias(libs.plugins.kotlin.parcelize)
alias(libs.plugins.aboutlibraries)
alias(libs.plugins.hilt)
alias(libs.plugins.room)
id "app.pachli.plugins.markdown2resource"
}
apply from: 'gitTools.gradle'
final def gitSha = ext.getGitSha()
final def gitRevCount = ext.getGitRevCount()
// The app name
final def APP_NAME = "Pachli"
// The application id. Must be unique, e.g. based on your domain
final def APP_ID = "app.pachli"
// url of a custom app logo. Recommended size at least 600x600. Keep empty to use the default logo.
final def CUSTOM_LOGO_URL = ""
// e.g. mastodon.social. Keep empty to not suggest any instance on the signup screen
final def CUSTOM_INSTANCE = ""
// link to your support account. Will be linked on the about page when not empty.
final def SUPPORT_ACCOUNT_URL = "https://mastodon.social/@Pachli"
android {
compileSdk 34
namespace "app.pachli"
defaultConfig {
applicationId APP_ID
namespace "app.pachli"
minSdk 23
targetSdk 34
versionCode 7
versionName "1.4.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
resValue "string", "app_name", APP_NAME
buildConfigField("String", "CUSTOM_LOGO_URL", "\"$CUSTOM_LOGO_URL\"")
buildConfigField("String", "CUSTOM_INSTANCE", "\"$CUSTOM_INSTANCE\"")
buildConfigField("String", "SUPPORT_ACCOUNT_URL", "\"$SUPPORT_ACCOUNT_URL\"")
}
buildTypes {
debug {
getIsDefault().set(true)
}
release {
minifyEnabled true
shrinkResources true
proguardFiles 'proguard-rules.pro'
}
}
flavorDimensions += "color"
flavorDimensions += "store"
productFlavors {
blue {
dimension "color"
}
orange {
dimension "color"
resValue "string", "app_name", APP_NAME + " Current"
applicationIdSuffix ".current"
versionNameSuffix "+" + gitSha
}
fdroid {
dimension "store"
}
github {
dimension "store"
}
google {
dimension "store"
}
}
lint {
lintConfig file("lint.xml")
// Regenerate by running `./gradlew updateLintBaselineOrangeDebug`
baseline = file("lint-baseline.xml")
}
buildFeatures {
buildConfig true
resValues true
viewBinding true
}
testOptions {
unitTests {
returnDefaultValues = true
includeAndroidResources = true
}
unitTests.all {
systemProperty 'robolectric.logging.enabled', 'true'
systemProperty 'robolectric.lazyload', 'ON'
}
}
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
// Exclude unneeded files added by libraries
packagingOptions.resources.excludes += [
'LICENSE_OFL',
'LICENSE_UNICODE',
]
bundle {
language {
// bundle all languages in every apk so the dynamic language switching works
enableSplit = false
}
}
dependenciesInfo {
includeInApk false
includeInBundle false
}
applicationVariants.configureEach { variant ->
tasks.register("printVersionInfo${variant.name.capitalize()}") {
notCompatibleWithConfigurationCache("Should always print the version info")
println variant.versionCode + " " + variant.versionName
}
variant.outputs.configureEach {
// Set the "orange" release versionCode to the number of commits on the
// branch, to ensure the versionCode updates on every release.
if (variant.buildType.name == "release" && variant.flavorName.startsWith("orange")) {
versionCodeOverride = gitRevCount
}
outputFileName = "Pachli_${variant.versionName}_${variant.versionCode}_${gitSha}_" +
"${variant.flavorName}_${buildType.name}.apk"
}
}
}
room {
schemaDirectory("$projectDir/schemas/")
}
ksp {
arg("room.incremental", "true")
arg("room.generateKotlin", "true")
}
configurations {
// JNI-only libraries don't play nicely with Robolectric
// see https://github.com/tuskyapp/Tusky/pull/3367
testImplementation.exclude group: "org.conscrypt", module: "conscrypt-android"
testRuntime.exclude group: "org.conscrypt", module: "conscrypt-android"
}
aboutLibraries {
configPath = "licenses"
includePlatform = false
duplicationMode = com.mikepenz.aboutlibraries.plugin.DuplicateMode.MERGE
prettyPrint = true
}
markdown2resource {
files = [ layout.projectDirectory.file('../PRIVACY.md') ]
}
// library versions are in PROJECT_ROOT/gradle/libs.versions.toml
dependencies {
implementation libs.kotlinx.coroutines.android
implementation libs.kotlinx.coroutines.rx3
implementation libs.bundles.androidx
implementation libs.bundles.room
ksp libs.androidx.room.compiler
implementation libs.android.material
implementation libs.gson
implementation libs.bundles.retrofit
implementation libs.networkresult.calladapter
implementation libs.bundles.okhttp
implementation libs.conscrypt.android
implementation libs.bundles.glide
ksp libs.glide.compiler
implementation libs.bundles.rxjava3
implementation libs.bundles.autodispose
implementation libs.hilt.android
ksp libs.hilt.compiler
implementation libs.sparkbutton
implementation libs.touchimageview
implementation libs.bundles.material.drawer
implementation libs.material.typeface
implementation libs.image.cropper
implementation libs.bundles.filemojicompat
implementation libs.bouncycastle
implementation libs.unified.push
implementation libs.bundles.xmldiff
implementation libs.bundles.aboutlibraries
implementation libs.timber
googleImplementation libs.app.update
googleImplementation libs.app.update.ktx
implementation libs.kotlin.result
implementation libs.semver
testImplementation libs.androidx.test.junit
testImplementation libs.robolectric
testImplementation libs.bundles.mockito
testImplementation libs.mockwebserver
testImplementation libs.androidx.core.testing
testImplementation libs.kotlinx.coroutines.test
testImplementation libs.androidx.work.testing
testImplementation libs.truth
testImplementation libs.turbine
testImplementation libs.androidx.test.core.ktx
testImplementation libs.hilt.android.testing
kspTest libs.hilt.compiler
androidTestImplementation libs.espresso.core
androidTestImplementation libs.androidx.room.testing
androidTestImplementation libs.androidx.test.junit
androidTestImplementation libs.hilt.android.testing
androidTestImplementation libs.androidx.test.core.ktx
lintChecks project(":checks")
}