9ec5d6e3b0
Fixes #793. This is an implementation for push notifications based on UnifiedPush for Tusky. No push gateway (other than UP itself) is needed, since UnifiedPush is simple enough such that it can act as a catch-all endpoint for WebPush messages. When a UnifiedPush distributor is present on-device, we will by default register Tusky as a receiver; if no UnifiedPush distributor is available, then pull notifications are used as a fallback mechanism. Because WebPush messages are encrypted, and Mastodon does not send the keys and IV needed for decryption in the request body, for now the push handler simply acts as a trigger for the pre-existing NotificationWorker which is also used for pull notifications. Nevertheless, I have implemented proper key generation and storage, just in case we would like to implement full decryption support in the future when Mastodon upgrades to the latest WebPush encryption scheme that includes all information in the request body. For users with existing accounts, push notifications will not be enabled until all of the accounts have been re-logged in to grant the new push OAuth scope. A small prompt will be shown (until dismissed) as a Snackbar to explain to the user about this, and an option is added in Account Preferences to facilitate re-login without deleting local drafts and cache.
198 lines
7.3 KiB
Groovy
198 lines
7.3 KiB
Groovy
apply plugin: 'com.android.application'
|
|
apply plugin: 'kotlin-android'
|
|
apply plugin: 'kotlin-kapt'
|
|
apply plugin: 'kotlin-parcelize'
|
|
|
|
apply from: "../instance-build.gradle"
|
|
|
|
def getGitSha = {
|
|
def stdout = new ByteArrayOutputStream()
|
|
try {
|
|
exec {
|
|
commandLine 'git', 'rev-parse', '--short', 'HEAD'
|
|
standardOutput = stdout
|
|
}
|
|
} catch (Exception e) {
|
|
return "unknown"
|
|
}
|
|
return stdout.toString().trim()
|
|
}
|
|
|
|
android {
|
|
compileSdkVersion 31
|
|
defaultConfig {
|
|
applicationId APP_ID
|
|
minSdkVersion 21
|
|
targetSdkVersion 31
|
|
versionCode 91
|
|
versionName "18.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\"")
|
|
|
|
kapt {
|
|
arguments {
|
|
arg("room.schemaLocation", "$projectDir/schemas")
|
|
}
|
|
}
|
|
}
|
|
buildTypes {
|
|
release {
|
|
minifyEnabled true
|
|
shrinkResources true
|
|
proguardFiles 'proguard-rules.pro'
|
|
}
|
|
debug {}
|
|
}
|
|
|
|
flavorDimensions "color"
|
|
productFlavors {
|
|
blue {}
|
|
green {
|
|
resValue "string", "app_name", APP_NAME + " Test"
|
|
applicationIdSuffix ".test"
|
|
versionNameSuffix "-" + getGitSha()
|
|
}
|
|
}
|
|
|
|
lintOptions {
|
|
disable 'MissingTranslation'
|
|
}
|
|
buildFeatures {
|
|
viewBinding true
|
|
}
|
|
testOptions {
|
|
unitTests {
|
|
returnDefaultValues = true
|
|
includeAndroidResources = true
|
|
}
|
|
}
|
|
sourceSets {
|
|
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
|
|
}
|
|
|
|
packagingOptions {
|
|
// Exclude unneeded files added by libraries
|
|
exclude 'LICENSE_OFL'
|
|
exclude 'LICENSE_UNICODE'
|
|
}
|
|
bundle {
|
|
language {
|
|
// bundle all languages in every apk so the dynamic language switching works
|
|
enableSplit = false
|
|
}
|
|
}
|
|
kotlinOptions {
|
|
freeCompilerArgs += "-opt-in=kotlin.RequiresOptIn"
|
|
}
|
|
}
|
|
|
|
ext.coroutinesVersion = "1.6.1"
|
|
ext.lifecycleVersion = "2.4.1"
|
|
ext.roomVersion = '2.4.2'
|
|
ext.retrofitVersion = '2.9.0'
|
|
ext.okhttpVersion = '4.9.3'
|
|
ext.glideVersion = '4.13.1'
|
|
ext.daggerVersion = '2.41'
|
|
ext.materialdrawerVersion = '8.4.5'
|
|
ext.emoji2_version = '1.1.0'
|
|
ext.filemojicompat_version = '3.2.1'
|
|
|
|
// if libraries are changed here, they should also be changed in LicenseActivity
|
|
dependencies {
|
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$coroutinesVersion"
|
|
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-rx3:$coroutinesVersion"
|
|
|
|
implementation "androidx.core:core-ktx:1.7.0"
|
|
implementation "androidx.appcompat:appcompat:1.4.1"
|
|
implementation "androidx.fragment:fragment-ktx:1.4.1"
|
|
implementation "androidx.browser:browser:1.4.0"
|
|
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0"
|
|
implementation "androidx.recyclerview:recyclerview:1.2.1"
|
|
implementation "androidx.exifinterface:exifinterface:1.3.3"
|
|
implementation "androidx.cardview:cardview:1.0.0"
|
|
implementation "androidx.preference:preference-ktx:1.2.0"
|
|
implementation "androidx.sharetarget:sharetarget:1.2.0-rc01"
|
|
implementation "androidx.emoji2:emoji2:$emoji2_version"
|
|
implementation "androidx.emoji2:emoji2-views:$emoji2_version"
|
|
implementation "androidx.emoji2:emoji2-views-helper:$emoji2_version"
|
|
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
|
|
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
|
|
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
|
|
implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:$lifecycleVersion"
|
|
implementation "androidx.constraintlayout:constraintlayout:2.1.3"
|
|
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
|
|
implementation "androidx.viewpager2:viewpager2:1.0.0"
|
|
implementation "androidx.work:work-runtime:2.7.1"
|
|
implementation "androidx.room:room-ktx:$roomVersion"
|
|
implementation "androidx.room:room-paging:$roomVersion"
|
|
kapt "androidx.room:room-compiler:$roomVersion"
|
|
implementation 'androidx.core:core-splashscreen:1.0.0-beta02'
|
|
|
|
implementation "com.google.android.material:material:1.5.0"
|
|
|
|
implementation "com.google.code.gson:gson:2.9.0"
|
|
|
|
implementation "com.squareup.retrofit2:retrofit:$retrofitVersion"
|
|
implementation "com.squareup.retrofit2:converter-gson:$retrofitVersion"
|
|
implementation "com.squareup.retrofit2:adapter-rxjava3:$retrofitVersion"
|
|
implementation "at.connyduck:kotlin-result-calladapter:1.0.1"
|
|
|
|
implementation "com.squareup.okhttp3:okhttp:$okhttpVersion"
|
|
implementation "com.squareup.okhttp3:logging-interceptor:$okhttpVersion"
|
|
|
|
implementation "org.conscrypt:conscrypt-android:2.5.2"
|
|
|
|
implementation "com.github.bumptech.glide:glide:$glideVersion"
|
|
implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion"
|
|
kapt "com.github.bumptech.glide:compiler:$glideVersion"
|
|
|
|
implementation "com.github.penfeizhou.android.animation:glide-plugin:2.20.0"
|
|
|
|
implementation "io.reactivex.rxjava3:rxjava:3.1.3"
|
|
implementation "io.reactivex.rxjava3:rxandroid:3.0.0"
|
|
implementation "io.reactivex.rxjava3:rxkotlin:3.0.1"
|
|
|
|
implementation "com.uber.autodispose2:autodispose-androidx-lifecycle:2.1.1"
|
|
implementation "com.uber.autodispose2:autodispose:2.1.1"
|
|
|
|
implementation "com.google.dagger:dagger:$daggerVersion"
|
|
kapt "com.google.dagger:dagger-compiler:$daggerVersion"
|
|
implementation "com.google.dagger:dagger-android:$daggerVersion"
|
|
implementation "com.google.dagger:dagger-android-support:$daggerVersion"
|
|
kapt "com.google.dagger:dagger-android-processor:$daggerVersion"
|
|
|
|
implementation "com.github.connyduck:sparkbutton:4.1.0"
|
|
|
|
implementation "com.github.chrisbanes:PhotoView:2.3.0"
|
|
|
|
implementation "com.mikepenz:materialdrawer:$materialdrawerVersion"
|
|
implementation "com.mikepenz:materialdrawer-iconics:$materialdrawerVersion"
|
|
implementation 'com.mikepenz:google-material-typeface:4.0.0.2-kotlin@aar'
|
|
|
|
implementation "com.github.CanHub:Android-Image-Cropper:4.1.0"
|
|
|
|
implementation "de.c1710:filemojicompat-ui:$filemojicompat_version"
|
|
implementation "de.c1710:filemojicompat:$filemojicompat_version"
|
|
implementation "de.c1710:filemojicompat-defaults:$filemojicompat_version"
|
|
|
|
implementation "org.bouncycastle:bcprov-jdk15on:1.70"
|
|
implementation "com.github.UnifiedPush:android-connector:2.0.0"
|
|
|
|
testImplementation "androidx.test.ext:junit:1.1.3"
|
|
testImplementation "org.robolectric:robolectric:4.4"
|
|
testImplementation "org.mockito:mockito-inline:4.4.0"
|
|
testImplementation "org.mockito.kotlin:mockito-kotlin:4.0.0"
|
|
|
|
androidTestImplementation "androidx.test.espresso:espresso-core:3.4.0"
|
|
androidTestImplementation "androidx.room:room-testing:$roomVersion"
|
|
androidTestImplementation "androidx.test.ext:junit:1.1.3"
|
|
testImplementation "androidx.arch.core:core-testing:2.1.0"
|
|
|
|
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$coroutinesVersion"
|
|
}
|