diff --git a/app/build.gradle b/app/build.gradle index b6cd8e0c5..dee9651f9 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -95,7 +95,7 @@ dependencies { implementation 'androidx.activity:activity-ktx:1.8.1' implementation 'androidx.fragment:fragment-ktx:1.6.2' implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.6.2' - implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' +// implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.6.2' implementation 'androidx.lifecycle:lifecycle-service:2.6.2' implementation 'androidx.lifecycle:lifecycle-process:2.6.2' implementation 'androidx.constraintlayout:constraintlayout:2.1.4' @@ -107,8 +107,7 @@ dependencies { implementation 'com.google.android.material:material:1.10.0' implementation 'androidx.lifecycle:lifecycle-common-java8:2.6.2' - // TODO https://issuetracker.google.com/issues/254846063 - implementation 'androidx.work:work-runtime-ktx:2.8.1' + implementation 'androidx.work:work-runtime:2.9.0' //noinspection GradleDependency implementation('com.google.guava:guava:32.0.1-android') { exclude group: 'com.google.guava', module: 'failureaccess' @@ -154,7 +153,7 @@ dependencies { androidTestImplementation 'org.jetbrains.kotlinx:kotlinx-coroutines-test:1.7.3' - androidTestImplementation 'androidx.room:room-testing:2.6.0' + androidTestImplementation 'androidx.room:room-testing:2.6.1' androidTestImplementation 'com.squareup.moshi:moshi-kotlin:1.15.0' androidTestImplementation 'com.google.dagger:hilt-android-testing:2.48.1' diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/BaseApp.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/BaseApp.kt index 008038107..4e994274a 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/BaseApp.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/BaseApp.kt @@ -56,6 +56,11 @@ open class BaseApp : Application(), Configuration.Provider { @Inject lateinit var workManagerProvider: Provider + override val workManagerConfiguration: Configuration + get() = Configuration.Builder() + .setWorkerFactory(workerFactory) + .build() + override fun onCreate() { super.onCreate() ACRA.errorReporter.putCustomData("isOriginalApp", appValidator.isOriginalApp.toString()) @@ -110,12 +115,6 @@ open class BaseApp : Application(), Configuration.Provider { } } - override fun getWorkManagerConfiguration(): Configuration { - return Configuration.Builder() - .setWorkerFactory(workerFactory) - .build() - } - @WorkerThread private fun setupDatabaseObservers() { val tracker = database.invalidationTracker diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/WorkServiceStopHelper.kt b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/WorkServiceStopHelper.kt index 6d5b5344c..09e706895 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/core/util/WorkServiceStopHelper.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/core/util/WorkServiceStopHelper.kt @@ -1,7 +1,6 @@ package org.koitharu.kotatsu.core.util import android.annotation.SuppressLint -import androidx.lifecycle.asFlow import androidx.work.WorkInfo import androidx.work.WorkManager import androidx.work.WorkQuery @@ -27,8 +26,7 @@ class WorkServiceStopHelper( fun setup() { processLifecycleScope.launch(Dispatchers.Default) { workManagerProvider.get() - .getWorkInfosLiveData(WorkQuery.fromStates(WorkInfo.State.RUNNING)) - .asFlow() + .getWorkInfosFlow(WorkQuery.fromStates(WorkInfo.State.RUNNING)) .map { it.isEmpty() } .distinctUntilChanged() .collectLatest { diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/worker/DownloadWorker.kt b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/worker/DownloadWorker.kt index 7137d1b11..e236af835 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/worker/DownloadWorker.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/download/ui/worker/DownloadWorker.kt @@ -7,7 +7,6 @@ import android.os.Build import android.webkit.MimeTypeMap import androidx.core.content.ContextCompat import androidx.hilt.work.HiltWorker -import androidx.lifecycle.asFlow import androidx.work.BackoffPolicy import androidx.work.Constraints import androidx.work.CoroutineWorker @@ -385,8 +384,7 @@ class DownloadWorker @AssistedInject constructor( } fun observeWorks(): Flow> = workManager - .getWorkInfosByTagLiveData(TAG) - .asFlow() + .getWorkInfosByTagFlow(TAG) suspend fun cancel(id: UUID) { workManager.cancelWorkById(id).await() diff --git a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/work/TrackWorker.kt b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/work/TrackWorker.kt index 406dbdcb7..8091f57aa 100644 --- a/app/src/main/kotlin/org/koitharu/kotatsu/tracker/work/TrackWorker.kt +++ b/app/src/main/kotlin/org/koitharu/kotatsu/tracker/work/TrackWorker.kt @@ -13,7 +13,6 @@ import androidx.core.app.PendingIntentCompat import androidx.core.content.ContextCompat import androidx.core.content.edit import androidx.hilt.work.HiltWorker -import androidx.lifecycle.asFlow import androidx.work.BackoffPolicy import androidx.work.Constraints import androidx.work.CoroutineWorker @@ -356,8 +355,7 @@ class TrackWorker @AssistedInject constructor( fun observeIsRunning(): Flow { val query = WorkQuery.Builder.fromTags(listOf(TAG, TAG_ONESHOT)).build() - return workManager.getWorkInfosLiveData(query) - .asFlow() + return workManager.getWorkInfosFlow(query) .map { works -> works.any { x -> x.state == WorkInfo.State.RUNNING } }