diff --git a/app/build.gradle b/app/build.gradle index e315930ec..07296d8c2 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -17,7 +17,7 @@ apply from: '../gradle/scripts/checkstyle.gradle' apply from: '../gradle/scripts/testLogging.gradle' android { - compileSdk 33 + compileSdk 34 namespace "de.tum.in.tumcampusapp" buildTypes { all { @@ -38,7 +38,7 @@ android { defaultConfig { applicationId "de.tum.in.tumcampus" minSdkVersion 26 - targetSdkVersion 33 + targetSdkVersion 34 versionCode 588 versionName "4.3-dev" @@ -57,11 +57,11 @@ android { } } compileOptions { - sourceCompatibility JavaVersion.VERSION_1_8 - targetCompatibility JavaVersion.VERSION_1_8 + sourceCompatibility JavaVersion.VERSION_17 + targetCompatibility JavaVersion.VERSION_17 } kotlinOptions { - jvmTarget = JavaVersion.VERSION_1_8.toString() + jvmTarget = JavaVersion.VERSION_17.toString() } testOptions { unitTests { @@ -96,25 +96,27 @@ dependencies { // Support Libraries implementation 'androidx.cardview:cardview:1.0.0' - implementation 'com.google.android.material:material:1.5.0' + implementation 'com.google.android.material:material:1.10.0' implementation 'androidx.legacy:legacy-preference-v14:1.0.0' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' // Android arch components implementation "androidx.room:room-rxjava2:$room_version" implementation "androidx.room:room-runtime:$room_version" - implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.5.0' + implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.6.2' implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0' - implementation 'android.arch.lifecycle:reactivestreams:1.1.1' - implementation 'android.arch.work:work-runtime-ktx:1.0.1' - implementation 'androidx.appcompat:appcompat:1.4.2' - implementation 'androidx.lifecycle:lifecycle-common-java8:2.5.0' + implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' + implementation "androidx.lifecycle:lifecycle-reactivestreams-ktx:2.6.2" + implementation 'androidx.work:work-runtime-ktx:2.8.1' + implementation 'androidx.appcompat:appcompat:1.6.1' + implementation 'androidx.lifecycle:lifecycle-common-java8:2.6.2' kapt "androidx.room:room-compiler:$room_version" + implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.1.0" + // Play services - implementation 'com.google.android.gms:play-services-base:18.0.1' - implementation 'com.google.android.gms:play-services-location:19.0.1' + implementation 'com.google.android.gms:play-services-base:18.2.0' + implementation 'com.google.android.gms:play-services-location:21.0.1' // Used for in-app reviews implementation "com.google.android.play:core:$play_core_services" @@ -122,8 +124,8 @@ dependencies { // Firebase implementation 'com.google.firebase:firebase-core:21.1.1' - implementation 'com.google.firebase:firebase-messaging:23.0.6' - implementation 'com.google.firebase:firebase-crashlytics-ktx:18.2.9' + implementation 'com.google.firebase:firebase-messaging:23.2.1' + implementation 'com.google.firebase:firebase-crashlytics-ktx:18.4.3' implementation 'com.google.firebase:firebase-analytics-ktx:21.3.0' // Helpers @@ -137,11 +139,11 @@ dependencies { // Kotlin implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" - implementation 'androidx.core:core-ktx:1.8.0' - implementation 'androidx.fragment:fragment-ktx:1.4.1' + implementation 'androidx.core:core-ktx:1.12.0' + implementation 'androidx.fragment:fragment-ktx:1.6.1' // Note: fix for internal androidx libraries using outdated WorkManager causing a crash - implementation "androidx.work:work-runtime-ktx:2.7.1" - implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.1' + implementation "androidx.work:work-runtime-ktx:2.8.1" + implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4' // RxJava implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' @@ -159,13 +161,10 @@ dependencies { implementation 'com.squareup.picasso:picasso:2.8' implementation "com.tickaroo.tikxml:retrofit-converter:$tikXmlVersion" implementation 'com.github.franmontiel:PersistentCookieJar:1.0.1' - implementation 'com.squareup.okio:okio:2.10.0' // UI implementation 'com.github.mtotschnig:StickyListHeaders:2.8.0' implementation 'com.github.chrisbanes:PhotoView:2.3.0' - implementation 'me.dm7.barcodescanner:zxing:1.9.13' // unused, but removal leads to build errors - implementation 'com.journeyapps:zxing-android-embedded:3.6.0' // unused, but removal leads to build errors implementation 'de.psdev.licensesdialog:licensesdialog:2.1.0' implementation 'com.github.thellmund.Android-Week-View:core:4.1.6' implementation 'de.hdodenhof:circleimageview:3.1.0' @@ -173,17 +172,14 @@ dependencies { implementation 'com.makeramen:roundedimageview:2.3.0' // Dagger - implementation 'com.google.dagger:dagger:2.28.3' - kapt 'com.google.dagger:dagger-compiler:2.28.3' + implementation 'com.google.dagger:dagger:2.38.1' + kapt 'com.google.dagger:dagger-compiler:2.38.1' // LeakCanary debugImplementation 'com.squareup.leakcanary:leakcanary-android:2.9.1' - // DebugDatabase - debugImplementation 'com.amitshekhar.android:debug-db:1.0.6' - // Testing - testImplementation 'androidx.test:core:1.4.0' + testImplementation 'androidx.test:core:1.5.0' testImplementation "commons-io:commons-io:2.11.0" testImplementation 'junit:junit:4.13.2' @@ -198,7 +194,6 @@ dependencies { testImplementation 'org.robolectric:robolectric:4.10.3' // gRPC backend - implementation 'io.grpc:grpc-okhttp:1.58.0' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-protobuf-lite:1.58.0' // CURRENT_GRPC_VERSION implementation 'io.grpc:grpc-stub:1.58.0' // CURRENT_GRPC_VERSION implementation 'org.apache.tomcat:annotations-api:6.0.53' diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/activity/ActivityForDownloadingExternal.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/activity/ActivityForDownloadingExternal.kt index a84da14b6..df5c39199 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/activity/ActivityForDownloadingExternal.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/activity/ActivityForDownloadingExternal.kt @@ -1,7 +1,7 @@ package de.tum.`in`.tumcampusapp.component.other.generic.activity -import androidx.lifecycle.LiveDataReactiveStreams import androidx.lifecycle.Observer +import androidx.lifecycle.toLiveData import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.api.tumonline.CacheControl @@ -33,7 +33,7 @@ abstract class ActivityForDownloadingExternal(layoutId: Int) : ProgressActivity< /** * Gets notifications from the DownloadWorker, if downloading was successful or not */ - private val completionHandler = Observer { + private val completionHandler = Observer { // Calls onStart() to simulate a new start of the activity // without downloading new data, since this receiver // receives data from a new download @@ -59,13 +59,11 @@ abstract class ActivityForDownloadingExternal(layoutId: Int) : ProgressActivity< } showLoadingStart() - LiveDataReactiveStreams - .fromPublisher( - Flowable.fromCallable { method?.execute(forceDownload) } - .doOnError { errorHandler() } - .onErrorReturnItem(Unit) - .subscribeOn(Schedulers.io()) - ) + Flowable.fromCallable { method?.execute(forceDownload) } + .doOnError { errorHandler() } + .onErrorReturnItem(Unit) + .subscribeOn(Schedulers.io()) + .toLiveData() .observe(this, completionHandler) } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/fragment/FragmentForDownloadingExternal.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/fragment/FragmentForDownloadingExternal.kt index 0db424d03..d545a38c2 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/fragment/FragmentForDownloadingExternal.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/other/generic/fragment/FragmentForDownloadingExternal.kt @@ -2,8 +2,8 @@ package de.tum.`in`.tumcampusapp.component.other.generic.fragment import androidx.annotation.LayoutRes import androidx.annotation.StringRes -import androidx.lifecycle.LiveDataReactiveStreams import androidx.lifecycle.Observer +import androidx.lifecycle.toLiveData import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import de.tum.`in`.tumcampusapp.R import de.tum.`in`.tumcampusapp.api.tumonline.CacheControl @@ -36,7 +36,7 @@ abstract class FragmentForDownloadingExternal( /** * Gets notifications from the DownloadWorker, if downloading was successful or not */ - private val completionHandler = Observer { + private val completionHandler = Observer { // Calls onStart() to simulate a new start of the activity // without downloading new data, since this receiver // receives data from a new download @@ -62,13 +62,11 @@ abstract class FragmentForDownloadingExternal( } showLoadingStart() - LiveDataReactiveStreams - .fromPublisher( - Flowable.fromCallable { method?.execute(forceDownload) } - .doOnError { errorHandler() } - .onErrorReturnItem(Unit) - .subscribeOn(Schedulers.io()) - ) + Flowable.fromCallable { method?.execute(forceDownload) } + .doOnError { errorHandler() } + .onErrorReturnItem(Unit) + .subscribeOn(Schedulers.io()) + .toLiveData() .observe(this, completionHandler) } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/onboarding/StartupActivity.kt b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/onboarding/StartupActivity.kt index 4bdcd3280..7f652af08 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/component/ui/onboarding/StartupActivity.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/component/ui/onboarding/StartupActivity.kt @@ -9,8 +9,8 @@ import android.os.Bundle import androidx.core.app.ActivityCompat.checkSelfPermission import androidx.core.app.ActivityCompat.requestPermissions import androidx.core.app.ActivityCompat.shouldShowRequestPermissionRationale -import androidx.lifecycle.LiveDataReactiveStreams import androidx.lifecycle.lifecycleScope +import androidx.lifecycle.toLiveData import com.google.firebase.crashlytics.FirebaseCrashlytics import de.tum.`in`.tumcampusapp.BuildConfig.DEBUG import de.tum.`in`.tumcampusapp.BuildConfig.VERSION_CODE @@ -121,9 +121,10 @@ class StartupActivity : BaseActivity(R.layout.activity_startup) { .subscribeOn(Schedulers.io()) runOnUiThread { - LiveDataReactiveStreams - .fromPublisher(downloadActions) - .observe(this@StartupActivity) { openMainActivityIfInitializationFinished() } + downloadActions.toLiveData() + .observe(this@StartupActivity) { + openMainActivityIfInitializationFinished() + } } // Start background service and ensure cards are set @@ -171,6 +172,7 @@ class StartupActivity : BaseActivity(R.layout.activity_startup) { permissions: Array, grantResults: IntArray ) { + super.onRequestPermissionsResult(requestCode, permissions, grantResults) openMainActivityIfInitializationFinished() } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/di/ViewModelFactory.kt b/app/src/main/java/de/tum/in/tumcampusapp/di/ViewModelFactory.kt index 854b4e1c5..9ffe77c17 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/di/ViewModelFactory.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/di/ViewModelFactory.kt @@ -15,7 +15,7 @@ class ViewModelFactory( ) : ViewModelProvider.Factory { @Suppress("UNCHECKED_CAST") - override fun create(modelClass: Class): T { + override fun create(modelClass: Class): T { return provider.get() as T } } diff --git a/app/src/main/java/de/tum/in/tumcampusapp/service/GeofencingUpdateReceiver.kt b/app/src/main/java/de/tum/in/tumcampusapp/service/GeofencingUpdateReceiver.kt index b6d0e6383..7c4acc0ad 100644 --- a/app/src/main/java/de/tum/in/tumcampusapp/service/GeofencingUpdateReceiver.kt +++ b/app/src/main/java/de/tum/in/tumcampusapp/service/GeofencingUpdateReceiver.kt @@ -19,22 +19,26 @@ class GeofencingUpdateReceiver : BroadcastReceiver() { override fun onReceive(context: Context, intent: Intent) { Utils.logWithTag(TAG, "Received event") val geofencingEvent = GeofencingEvent.fromIntent(intent) - if (geofencingEvent.hasError()) { - Utils.logWithTag(TAG, "Geofencing event contained errors.") - return - } + if (geofencingEvent != null) { + if (geofencingEvent.hasError()) { + Utils.logWithTag(TAG, "Geofencing event contained errors.") + return + } - // Get the transition type. - val geofenceTransition = geofencingEvent.geofenceTransition + // Get the transition type. + val geofenceTransition = geofencingEvent.geofenceTransition - if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) { - Utils.setSetting(context, Const.BACKGROUND_MODE, true) - StartSyncReceiver.startBackground(context) - Utils.logWithTag(TAG, "Geofencing detected user entering munich, enabling Auto updates") - } else if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) { - Utils.setSetting(context, Const.BACKGROUND_MODE, false) - StartSyncReceiver.cancelBackground(context) - Utils.logWithTag(TAG, "Geofencing detected user leaving munich, disabling Auto updates") + if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_ENTER) { + Utils.setSetting(context, Const.BACKGROUND_MODE, true) + StartSyncReceiver.startBackground(context) + Utils.logWithTag(TAG, "Geofencing detected user entering munich, enabling Auto updates") + } else if (geofenceTransition == Geofence.GEOFENCE_TRANSITION_EXIT) { + Utils.setSetting(context, Const.BACKGROUND_MODE, false) + StartSyncReceiver.cancelBackground(context) + Utils.logWithTag(TAG, "Geofencing detected user leaving munich, disabling Auto updates") + } + } else { + Utils.logWithTag(TAG, "Geofencing event was null. Modes are not changed") } } diff --git a/build.gradle b/build.gradle index 4f57ae55f..5c64bec40 100644 --- a/build.gradle +++ b/build.gradle @@ -2,7 +2,7 @@ buildscript { ext { - kotlin_version = '1.7.0' + kotlin_version = '1.8.22' room_version = '2.5.2' } repositories { @@ -12,13 +12,13 @@ buildscript { maven { url "https://jitpack.io"} } dependencies { - classpath 'com.android.tools.build:gradle:7.4.2' + classpath 'com.android.tools.build:gradle:8.1.1' classpath 'com.google.gms:google-services:4.4.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath 'org.jlleitschuh.gradle:ktlint-gradle:11.5.1' classpath "com.github.ben-manes:gradle-versions-plugin:0.43.0" classpath "io.gitlab.arturbosch.detekt:detekt-gradle-plugin:1.13.1" - classpath "com.google.protobuf:protobuf-gradle-plugin:0.8.18" + classpath "com.google.protobuf:protobuf-gradle-plugin:0.9.0" classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.9' } } @@ -36,7 +36,7 @@ allprojects { repositories { google() - jcenter() + mavenCentral() maven { url "https://jitpack.io" } maven { url 'https://maven.google.com/' } } diff --git a/gradle.properties b/gradle.properties index 8fa4fa2b1..6ae05a7e3 100644 --- a/gradle.properties +++ b/gradle.properties @@ -28,3 +28,6 @@ android.enableJetifier=true # see https://kotlinlang.org/docs/whatsnew17.html#build-reports-for-kotlin-compiler-tasks kotlin.incremental.useClasspathSnapshot=true +android.defaults.buildfeatures.buildconfig=true +android.nonTransitiveRClass=false +android.nonFinalResIds=false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 33223d390..a055943c3 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-7.5-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-all.zip