diff --git a/app/build.gradle b/app/build.gradle index bc76e3f059..6eb86e9740 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -5,6 +5,7 @@ apply plugin: "androidx.navigation.safeargs.kotlin" apply plugin: "kotlinx-serialization" apply plugin: "org.jetbrains.kotlin.plugin.parcelize" apply plugin: "org.jlleitschuh.gradle.ktlint" +apply plugin: "com.google.dagger.hilt.android" android { @@ -164,6 +165,8 @@ dependencies { implementation "dev.rikka.shizuku:api:$shizuku_version" implementation "dev.rikka.shizuku:provider:$shizuku_version" implementation "org.lsposed.hiddenapibypass:hiddenapibypass:4.3" + implementation("com.google.dagger:hilt-android:2.51") + kapt("com.google.dagger:hilt-android-compiler:2.51") proImplementation "com.android.billingclient:billing:7.1.1" proImplementation "com.android.billingclient:billing-ktx:7.1.1" diff --git a/app/src/free/java/io/github/sds100/keymapper/MainActivity.kt b/app/src/free/java/io/github/sds100/keymapper/MainActivity.kt new file mode 100644 index 0000000000..8c248798d4 --- /dev/null +++ b/app/src/free/java/io/github/sds100/keymapper/MainActivity.kt @@ -0,0 +1,3 @@ +import io.github.sds100.keymapper.BaseMainActivity + +class MainActivity : BaseMainActivity() diff --git a/app/src/main/java/io/github/sds100/keymapper/MainActivity.kt b/app/src/main/java/io/github/sds100/keymapper/BaseMainActivity.kt similarity index 95% rename from app/src/main/java/io/github/sds100/keymapper/MainActivity.kt rename to app/src/main/java/io/github/sds100/keymapper/BaseMainActivity.kt index 4e3580d10a..2b309bd304 100644 --- a/app/src/main/java/io/github/sds100/keymapper/MainActivity.kt +++ b/app/src/main/java/io/github/sds100/keymapper/BaseMainActivity.kt @@ -21,7 +21,7 @@ import timber.log.Timber * Created by sds100 on 19/02/2020. */ -class MainActivity : AppCompatActivity() { +abstract class BaseMainActivity : AppCompatActivity() { companion object { const val ACTION_SHOW_ACCESSIBILITY_SETTINGS_NOT_FOUND_DIALOG = @@ -51,7 +51,7 @@ class MainActivity : AppCompatActivity() { requestPermissionDelegate = RequestPermissionDelegate(this, showDialogs = true) - ServiceLocator.permissionAdapter(this@MainActivity).request + ServiceLocator.permissionAdapter(this@BaseMainActivity).request .flowWithLifecycle(lifecycle, Lifecycle.State.STARTED) .onEach { permission -> requestPermissionDelegate.requestPermission( diff --git a/app/src/main/java/io/github/sds100/keymapper/KeyMapperApp.kt b/app/src/main/java/io/github/sds100/keymapper/KeyMapperApp.kt index 170339f2f2..8f0c251013 100644 --- a/app/src/main/java/io/github/sds100/keymapper/KeyMapperApp.kt +++ b/app/src/main/java/io/github/sds100/keymapper/KeyMapperApp.kt @@ -9,6 +9,7 @@ import androidx.lifecycle.OnLifecycleEvent import androidx.lifecycle.ProcessLifecycleOwner import androidx.multidex.MultiDexApplication import com.google.android.material.color.DynamicColors +import dagger.hilt.android.HiltAndroidApp import io.github.sds100.keymapper.data.Keys import io.github.sds100.keymapper.data.entities.LogEntryEntity import io.github.sds100.keymapper.logging.KeyMapperLoggingTree @@ -64,6 +65,7 @@ import java.util.Calendar /** * Created by sds100 on 19/05/2020. */ +@HiltAndroidApp class KeyMapperApp : MultiDexApplication() { val appCoroutineScope = MainScope() diff --git a/app/src/main/java/io/github/sds100/keymapper/system/notifications/NotificationController.kt b/app/src/main/java/io/github/sds100/keymapper/system/notifications/NotificationController.kt index 815b868bb8..e66573c0d6 100644 --- a/app/src/main/java/io/github/sds100/keymapper/system/notifications/NotificationController.kt +++ b/app/src/main/java/io/github/sds100/keymapper/system/notifications/NotificationController.kt @@ -3,8 +3,8 @@ package io.github.sds100.keymapper.system.notifications import androidx.annotation.VisibleForTesting import androidx.core.app.NotificationCompat import androidx.core.app.NotificationManagerCompat +import io.github.sds100.keymapper.BaseMainActivity import io.github.sds100.keymapper.Constants -import io.github.sds100.keymapper.MainActivity import io.github.sds100.keymapper.R import io.github.sds100.keymapper.mappings.PauseMappingsUseCase import io.github.sds100.keymapper.mappings.fingerprintmaps.AreFingerprintGesturesSupportedUseCase @@ -250,7 +250,7 @@ class NotificationController( private fun attemptStartAccessibilityService() { if (!controlAccessibilityService.startService()) { coroutineScope.launch { - _openApp.emit(MainActivity.ACTION_SHOW_ACCESSIBILITY_SETTINGS_NOT_FOUND_DIALOG) + _openApp.emit(BaseMainActivity.ACTION_SHOW_ACCESSIBILITY_SETTINGS_NOT_FOUND_DIALOG) } } } @@ -258,7 +258,7 @@ class NotificationController( private fun attemptRestartAccessibilityService() { if (!controlAccessibilityService.restartService()) { coroutineScope.launch { - _openApp.emit(MainActivity.ACTION_SHOW_ACCESSIBILITY_SETTINGS_NOT_FOUND_DIALOG) + _openApp.emit(BaseMainActivity.ACTION_SHOW_ACCESSIBILITY_SETTINGS_NOT_FOUND_DIALOG) } } } diff --git a/build.gradle b/build.gradle index a891f2f9bb..cbb9f0b487 100644 --- a/build.gradle +++ b/build.gradle @@ -14,10 +14,11 @@ buildscript { def nav_version = '2.6.0' classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version" - classpath 'com.android.tools.build:gradle:8.4.2' + classpath "com.android.tools.build:gradle:8.4.2" classpath "org.jlleitschuh.gradle:ktlint-gradle:12.1.0" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_version" + classpath "com.google.dagger:hilt-android-gradle-plugin:2.52" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files