|
|
@@ -2,26 +2,20 @@ package com.example.modifier
|
|
|
|
|
|
import android.content.DialogInterface
|
|
|
import android.content.Intent
|
|
|
+import android.net.Uri
|
|
|
import android.os.Bundle
|
|
|
-import android.os.Handler
|
|
|
-import android.os.Looper
|
|
|
import android.provider.Settings
|
|
|
import androidx.activity.enableEdgeToEdge
|
|
|
-import androidx.appcompat.app.AlertDialog
|
|
|
import androidx.appcompat.app.AppCompatActivity
|
|
|
import androidx.navigation.fragment.NavHostFragment
|
|
|
import androidx.navigation.ui.NavigationUI.setupWithNavController
|
|
|
-import com.example.modifier.databinding.ActivityLoginBinding
|
|
|
import com.example.modifier.databinding.ActivityMainBinding
|
|
|
import com.google.android.material.dialog.MaterialAlertDialogBuilder
|
|
|
import kotlinx.coroutines.CoroutineScope
|
|
|
import kotlinx.coroutines.Dispatchers
|
|
|
-import kotlinx.coroutines.GlobalScope
|
|
|
-import kotlinx.coroutines.coroutineScope
|
|
|
import kotlinx.coroutines.delay
|
|
|
import kotlinx.coroutines.launch
|
|
|
-import java.util.concurrent.ExecutorService
|
|
|
-import java.util.concurrent.Executors
|
|
|
+import kotlinx.coroutines.withContext
|
|
|
|
|
|
class MainActivity : AppCompatActivity() {
|
|
|
private lateinit var mBinding: ActivityMainBinding
|
|
|
@@ -36,7 +30,10 @@ class MainActivity : AppCompatActivity() {
|
|
|
supportFragmentManager.findFragmentById(R.id.nav_host_fragment) as NavHostFragment
|
|
|
val controller = navHostFragment.navController
|
|
|
setupWithNavController(mBinding.nav, controller)
|
|
|
- CoroutineScope(Dispatchers.Main).launch {
|
|
|
+ CoroutineScope(Dispatchers.IO).launch {
|
|
|
+ if (!Settings.canDrawOverlays(this@MainActivity)) {
|
|
|
+ Utils.enableOverlay()
|
|
|
+ }
|
|
|
if (Utils.hasRootAccess()) {
|
|
|
if (!Utils.isAccessibilityEnabled()) {
|
|
|
if (!Utils.enableAccessibility()) {
|
|
|
@@ -48,14 +45,16 @@ class MainActivity : AppCompatActivity() {
|
|
|
}
|
|
|
}
|
|
|
} else {
|
|
|
- MaterialAlertDialogBuilder(this@MainActivity)
|
|
|
- .setTitle("No Root Access")
|
|
|
- .setMessage("Root access is required to run this app")
|
|
|
- .setCancelable(false)
|
|
|
- .setPositiveButton("Exit") { _: DialogInterface?, _: Int ->
|
|
|
- finish()
|
|
|
- }
|
|
|
- .show()
|
|
|
+ withContext(Dispatchers.Main) {
|
|
|
+ MaterialAlertDialogBuilder(this@MainActivity)
|
|
|
+ .setTitle("No Root Access")
|
|
|
+ .setMessage("Root access is required to run this app")
|
|
|
+ .setCancelable(false)
|
|
|
+ .setPositiveButton("Exit") { _: DialogInterface?, _: Int ->
|
|
|
+ finish()
|
|
|
+ }
|
|
|
+ .show()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|