Skip to content

Commit

Permalink
#1274 add Dagger Hilt dependency injection and split up MainActivity …
Browse files Browse the repository at this point in the history
…into BaseMainActivity
  • Loading branch information
sds100 committed Oct 15, 2024
1 parent 454dd82 commit 917981f
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 6 deletions.
3 changes: 3 additions & 0 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down Expand Up @@ -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"

Expand Down
3 changes: 3 additions & 0 deletions app/src/free/java/io/github/sds100/keymapper/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import io.github.sds100.keymapper.BaseMainActivity

class MainActivity : BaseMainActivity()
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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(
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/io/github/sds100/keymapper/KeyMapperApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -64,6 +65,7 @@ import java.util.Calendar
/**
* Created by sds100 on 19/05/2020.
*/
@HiltAndroidApp
class KeyMapperApp : MultiDexApplication() {
val appCoroutineScope = MainScope()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -250,15 +250,15 @@ 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)
}
}
}

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)
}
}
}
Expand Down
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 917981f

Please sign in to comment.