40fde54e0b
This pull request removes the remaining RxJava code and replaces it with coroutine-equivalent implementations. - Remove all duplicate methods in `MastodonApi`: - Methods returning a RxJava `Single` have been replaced by suspending methods returning a `NetworkResult` in order to be consistent with the new code. - _sync_/_async_ method variants are replaced with the _async_ version only (suspending method), and `runBlocking{}` is used to make the async variant synchronous. - Create a custom coroutine-based implementation of `Single` for usage in Java code where launching a coroutine is not possible. This class can be deleted after remaining Java code has been converted to Kotlin. - `NotificationsFragment.java` can subscribe to `EventHub` events by calling the new lifecycle-aware `EventHub.subscribe()` method. This allows using the `SharedFlow` as single source of truth for all events. - Rx Autodispose is replaced by `lifecycleScope.launch()` which will automatically cancel the coroutine when the Fragment view/Activity is destroyed. - Background work is launched in the existing injectable `externalScope`, since using `GlobalScope` is discouraged. `externalScope` has been changed to be a `@Singleton` and to use the main dispatcher by default. - Transform `ShareShortcutHelper` to an injectable utility class so it can use the application `Context` and `externalScope` as provided dependencies to launch a background coroutine. - Implement a custom Glide extension method `RequestBuilder.submitAsync()` to do the same thing as `RequestBuilder.submit().get()` in a non-blocking way. This way there is no need to switch to a background dispatcher and block a background thread, and cancellation is supported out-of-the-box. - An utility method `Fragment.updateRelativeTimePeriodically()` has been added to remove duplicate logic in `TimelineFragment` and `NotificationsFragment`, and the logic is now implemented using a simple coroutine instead of `Observable.interval()`. Note that the periodic update now happens between onStart and onStop instead of between onResume and onPause, since the Fragment is not interactive but is still visible in the started state. - Rewrite `BottomSheetActivityTest` using coroutines tests. - Remove all RxJava library dependencies.
198 lines
6.6 KiB
Groovy
198 lines
6.6 KiB
Groovy
plugins {
|
|
alias(libs.plugins.android.application)
|
|
alias(libs.plugins.google.ksp)
|
|
alias(libs.plugins.kotlin.android)
|
|
alias(libs.plugins.kotlin.kapt)
|
|
alias(libs.plugins.kotlin.parcelize)
|
|
}
|
|
|
|
apply from: 'getGitSha.gradle'
|
|
|
|
final def gitSha = ext.getGitSha()
|
|
|
|
// The app name
|
|
final def APP_NAME = "Tusky"
|
|
// The application id. Must be unique, e.g. based on your domain
|
|
final def APP_ID = "com.keylesspalace.tusky"
|
|
// url of a custom app logo. Recommended size at least 600x600. Keep empty to use the Tusky elephant friend.
|
|
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/@Tusky"
|
|
|
|
android {
|
|
compileSdk 34
|
|
namespace "com.keylesspalace.tusky"
|
|
defaultConfig {
|
|
applicationId APP_ID
|
|
namespace "com.keylesspalace.tusky"
|
|
minSdk 24
|
|
targetSdk 34
|
|
versionCode 117
|
|
versionName "24.1"
|
|
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 {
|
|
isDefault true
|
|
}
|
|
release {
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
proguardFiles 'proguard-rules.pro'
|
|
}
|
|
}
|
|
|
|
flavorDimensions += "color"
|
|
productFlavors {
|
|
blue {}
|
|
green {
|
|
resValue "string", "app_name", APP_NAME + " Test"
|
|
applicationIdSuffix ".test"
|
|
versionNameSuffix "-" + gitSha
|
|
isDefault true
|
|
}
|
|
}
|
|
|
|
lint {
|
|
lintConfig file("lint.xml")
|
|
// Regenerate by running `./gradlew app:newLintBaseline`
|
|
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 ->
|
|
variant.outputs.configureEach {
|
|
outputFileName = "Tusky_${variant.versionName}_${variant.versionCode}_${gitSha}_" +
|
|
"${variant.flavorName}_${buildType.name}.apk"
|
|
}
|
|
}
|
|
}
|
|
|
|
ksp {
|
|
arg("room.schemaLocation", "$projectDir/schemas")
|
|
arg("room.generateKotlin", "true")
|
|
arg("room.incremental", "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"
|
|
}
|
|
|
|
// library versions are in PROJECT_ROOT/gradle/libs.versions.toml
|
|
dependencies {
|
|
implementation libs.kotlinx.coroutines.android
|
|
|
|
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.dagger
|
|
kapt libs.bundles.dagger.processors
|
|
|
|
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
|
|
|
|
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
|
|
|
|
androidTestImplementation libs.espresso.core
|
|
androidTestImplementation libs.androidx.room.testing
|
|
androidTestImplementation libs.androidx.test.junit
|
|
}
|
|
|
|
// Work around warnings of:
|
|
// WARNING: Illegal reflective access by org.jetbrains.kotlin.kapt3.util.ModuleManipulationUtilsKt (file:/C:/Users/Andi/.gradle/caches/modules-2/files-2.1/org.jetbrains.kotlin/kotlin-annotation-processing-gradle/1.8.22/28dab7e0ee9ce62c03bf97de3543c911dc653700/kotlin-annotation-processing-gradle-1.8.22.jar) to constructor com.sun.tools.javac.util.Context()
|
|
// See https://youtrack.jetbrains.com/issue/KT-30589/Kapt-An-illegal-reflective-access-operation-has-occurred
|
|
tasks.withType(org.jetbrains.kotlin.gradle.internal.KaptWithoutKotlincTask).configureEach {
|
|
kaptProcessJvmArgs.addAll([
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED",
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED",
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED",
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED",
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.processing=ALL-UNNAMED",
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.comp=ALL-UNNAMED",
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED",
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED",
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED",
|
|
"--add-opens", "jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"])
|
|
}
|