diff --git a/AnkiDroid/build.gradle b/AnkiDroid/build.gradle index 41ac3ca9118d..b2b38aae58c1 100644 --- a/AnkiDroid/build.gradle +++ b/AnkiDroid/build.gradle @@ -315,6 +315,8 @@ dependencies { implementation "org.jetbrains.kotlin:kotlin-test:$kotlin_version" implementation 'com.github.ByteHamster:SearchPreference:v2.3.0' implementation 'com.github.AppIntro:AppIntro:6.2.0' + implementation "androidx.work:work-runtime-ktx:2.7.1" + implementation "androidx.datastore:datastore-preferences:1.0.0" // Cannot use debugImplementation since classes need to be imported in AnkiDroidApp // and there's no no-op version for release build. Usage has been disabled for release diff --git a/AnkiDroid/src/main/AndroidManifest.xml b/AnkiDroid/src/main/AndroidManifest.xml index 4b6dd6aa1aa4..d44e5c7cccfa 100644 --- a/AnkiDroid/src/main/AndroidManifest.xml +++ b/AnkiDroid/src/main/AndroidManifest.xml @@ -522,6 +522,18 @@ android:name="android.support.FILE_PROVIDER_PATHS" android:resource="@xml/filepaths" /> + + + + + diff --git a/AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt b/AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt index c62322e67791..0a3f59fd1d6c 100644 --- a/AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt +++ b/AnkiDroid/src/main/java/com/ichi2/anki/AnkiDroidApp.kt @@ -57,7 +57,7 @@ import java.util.regex.Pattern */ @KotlinCleanup("lots to do") @KotlinCleanup("IDE Lint") -open class AnkiDroidApp : Application() { +open class AnkiDroidApp : Application(), androidx.work.Configuration.Provider { /** An exception if the WebView subsystem fails to load */ private var mWebViewError: Throwable? = null private val mNotifications = MutableLiveData() @@ -180,9 +180,11 @@ open class AnkiDroidApp : Application() { } } } + // TODO: Notification CleanUP. Delete the Boot Service after successful implementation of Notification Work Manager. Timber.i("AnkiDroidApp: Starting Services") BootService().onReceive(this, Intent(this, BootService::class.java)) + // TODO: Notification CleanUP. Delete the Notification Service after successful implementation of Notification Work Manager. // Register for notifications mNotifications.observeForever { NotificationService.triggerNotificationFor(this) } Themes.systemIsInNightMode = @@ -210,6 +212,13 @@ open class AnkiDroidApp : Application() { } } + /** + * Our configuration for custom work manager. + * We are using custom work manager because UNIT TESTS are failing. + * TODO: Remove custom implementation after implementing 14 tests using WorkManagerTestInitHelper. SEE: https://developer.android.com/topic/libraries/architecture/workmanager/how-to/integration-testing + */ + override fun getWorkManagerConfiguration() = androidx.work.Configuration.Builder().build() + /** * A tree which logs necessary data for crash reporting. *