mirror of
https://github.com/topjohnwu/Magisk
synced 2024-11-05 04:51:15 +01:00
Remove dexter dependency
This commit is contained in:
parent
40c64d50d5
commit
465aaeff82
@ -132,5 +132,4 @@ dependencies {
|
||||
implementation 'androidx.multidex:multidex:2.0.1'
|
||||
implementation 'androidx.core:core-ktx:1.1.0'
|
||||
implementation 'com.google.android.material:material:1.2.0-alpha01'
|
||||
implementation 'com.karumi:dexter:6.0.0'
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package com.topjohnwu.magisk.model.events
|
||||
|
||||
import android.content.Context
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
|
||||
interface ContextExecutor {
|
||||
|
||||
@ -12,7 +12,7 @@ interface ContextExecutor {
|
||||
|
||||
interface ActivityExecutor {
|
||||
|
||||
operator fun invoke(activity: AppCompatActivity)
|
||||
operator fun invoke(activity: BaseActivity<*, *>)
|
||||
|
||||
}
|
||||
|
||||
@ -20,4 +20,4 @@ interface FragmentExecutor {
|
||||
|
||||
operator fun invoke(fragment: Fragment)
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,6 @@ package com.topjohnwu.magisk.model.events
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.topjohnwu.magisk.Const
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
import com.topjohnwu.magisk.intent
|
||||
@ -11,7 +10,7 @@ import com.topjohnwu.magisk.ui.flash.FlashActivity
|
||||
|
||||
class InstallExternalModuleEvent : ViewEvent(), ActivityExecutor {
|
||||
|
||||
override fun invoke(activity: AppCompatActivity) {
|
||||
override fun invoke(activity: BaseActivity<*, *>) {
|
||||
activity as BaseActivity<*, *>
|
||||
activity.withExternalRW {
|
||||
onSuccess {
|
||||
@ -35,4 +34,4 @@ class InstallExternalModuleEvent : ViewEvent(), ActivityExecutor {
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package com.topjohnwu.magisk.model.events
|
||||
|
||||
import android.content.Context
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.google.android.material.snackbar.Snackbar
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
import com.topjohnwu.magisk.extensions.snackbar
|
||||
@ -28,7 +27,7 @@ class SnackbarEvent private constructor(
|
||||
|
||||
fun message(context: Context): String = messageString ?: context.getString(messageRes)
|
||||
|
||||
override fun invoke(activity: AppCompatActivity) {
|
||||
override fun invoke(activity: BaseActivity<*, *>) {
|
||||
if (activity is BaseActivity<*, *>) {
|
||||
activity.snackbar(activity.snackbarView, message(activity), length, f)
|
||||
}
|
||||
|
@ -3,12 +3,6 @@ package com.topjohnwu.magisk.model.events
|
||||
import android.app.Activity
|
||||
import android.content.Context
|
||||
import android.content.Intent
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.karumi.dexter.Dexter
|
||||
import com.karumi.dexter.MultiplePermissionsReport
|
||||
import com.karumi.dexter.PermissionToken
|
||||
import com.karumi.dexter.listener.PermissionRequest
|
||||
import com.karumi.dexter.listener.multi.MultiplePermissionsListener
|
||||
import com.topjohnwu.magisk.Const
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
@ -17,7 +11,6 @@ import com.topjohnwu.magisk.extensions.DynamicClassLoader
|
||||
import com.topjohnwu.magisk.extensions.subscribeK
|
||||
import com.topjohnwu.magisk.extensions.writeTo
|
||||
import com.topjohnwu.magisk.model.entity.module.Repo
|
||||
import com.topjohnwu.magisk.model.permissions.PermissionRequestBuilder
|
||||
import com.topjohnwu.magisk.utils.RxBus
|
||||
import com.topjohnwu.magisk.utils.SafetyNetHelper
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
@ -137,7 +130,7 @@ class UpdateSafetyNetEvent : ViewEvent(), ContextExecutor, KoinComponent, Safety
|
||||
}
|
||||
|
||||
class ViewActionEvent(val action: BaseActivity<*, *>.() -> Unit) : ViewEvent(), ActivityExecutor {
|
||||
override fun invoke(activity: AppCompatActivity) = (activity as BaseActivity<*, *>).run(action)
|
||||
override fun invoke(activity: BaseActivity<*, *>) = (activity as BaseActivity<*, *>).run(action)
|
||||
}
|
||||
|
||||
class OpenFilePickerEvent : ViewEvent()
|
||||
@ -157,54 +150,38 @@ class PermissionEvent(
|
||||
val callback: PublishSubject<Boolean>
|
||||
) : ViewEvent(), ActivityExecutor {
|
||||
|
||||
private val permissionRequest = PermissionRequestBuilder().apply {
|
||||
onSuccess {
|
||||
callback.onNext(true)
|
||||
}
|
||||
onFailure {
|
||||
callback.onNext(false)
|
||||
callback.onError(SecurityException("User refused permissions"))
|
||||
}
|
||||
}.build()
|
||||
|
||||
override fun invoke(activity: AppCompatActivity) = Dexter.withActivity(activity)
|
||||
.withPermissions(permissions)
|
||||
.withListener(object : MultiplePermissionsListener {
|
||||
override fun onPermissionRationaleShouldBeShown(
|
||||
permissions: MutableList<PermissionRequest>,
|
||||
token: PermissionToken
|
||||
) = token.continuePermissionRequest()
|
||||
|
||||
override fun onPermissionsChecked(
|
||||
report: MultiplePermissionsReport
|
||||
) = if (report.areAllPermissionsGranted()) {
|
||||
permissionRequest.onSuccess()
|
||||
} else {
|
||||
permissionRequest.onFailure()
|
||||
override fun invoke(activity: BaseActivity<*, *>) =
|
||||
activity.withPermissions(*permissions.toTypedArray()) {
|
||||
onSuccess {
|
||||
callback.onNext(true)
|
||||
}
|
||||
}).check()
|
||||
onFailure {
|
||||
callback.onNext(false)
|
||||
callback.onError(SecurityException("User refused permissions"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class BackPressEvent : ViewEvent(), ActivityExecutor {
|
||||
override fun invoke(activity: AppCompatActivity) {
|
||||
override fun invoke(activity: BaseActivity<*, *>) {
|
||||
activity.onBackPressed()
|
||||
}
|
||||
}
|
||||
|
||||
class DieEvent : ViewEvent(), ActivityExecutor {
|
||||
override fun invoke(activity: AppCompatActivity) {
|
||||
override fun invoke(activity: BaseActivity<*, *>) {
|
||||
activity.finish()
|
||||
}
|
||||
}
|
||||
|
||||
class RecreateEvent : ViewEvent(), ActivityExecutor {
|
||||
override fun invoke(activity: AppCompatActivity) {
|
||||
override fun invoke(activity: BaseActivity<*, *>) {
|
||||
activity.recreate()
|
||||
}
|
||||
}
|
||||
|
||||
class RequestFileEvent : ViewEvent(), ActivityExecutor {
|
||||
override fun invoke(activity: AppCompatActivity) {
|
||||
override fun invoke(activity: BaseActivity<*, *>) {
|
||||
Intent(Intent.ACTION_GET_CONTENT)
|
||||
.setType("*/*")
|
||||
.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
@ -218,4 +195,4 @@ class RequestFileEvent : ViewEvent(), ActivityExecutor {
|
||||
?.takeIf { requestCode == REQUEST_CODE }
|
||||
?.data
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.topjohnwu.magisk.model.events.dialog
|
||||
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
import com.topjohnwu.magisk.model.events.ActivityExecutor
|
||||
import com.topjohnwu.magisk.model.events.ViewEvent
|
||||
import com.topjohnwu.magisk.utils.BiometricHelper
|
||||
@ -16,7 +16,7 @@ class BiometricDialog(
|
||||
builder(Builder())
|
||||
}
|
||||
|
||||
override fun invoke(activity: AppCompatActivity) {
|
||||
override fun invoke(activity: BaseActivity<*, *>) {
|
||||
BiometricHelper.authenticate(
|
||||
activity,
|
||||
onError = listenerOnFailure,
|
||||
@ -35,4 +35,4 @@ class BiometricDialog(
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package com.topjohnwu.magisk.model.events.dialog
|
||||
|
||||
import android.app.Activity
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.appcompat.app.AppCompatDelegate
|
||||
import com.topjohnwu.magisk.Config
|
||||
import com.topjohnwu.magisk.R
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
import com.topjohnwu.magisk.model.events.ActivityExecutor
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
import java.lang.ref.WeakReference
|
||||
@ -13,7 +13,7 @@ class DarkThemeDialog : DialogEvent(), ActivityExecutor {
|
||||
|
||||
private var activity: WeakReference<Activity>? = null
|
||||
|
||||
override fun invoke(activity: AppCompatActivity) {
|
||||
override fun invoke(activity: BaseActivity<*, *>) {
|
||||
this.activity = WeakReference(activity)
|
||||
}
|
||||
|
||||
@ -47,4 +47,4 @@ class DarkThemeDialog : DialogEvent(), ActivityExecutor {
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,8 +3,8 @@ package com.topjohnwu.magisk.model.navigation
|
||||
import android.os.Bundle
|
||||
import androidx.annotation.AnimRes
|
||||
import androidx.annotation.AnimatorRes
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
import com.topjohnwu.magisk.model.events.ActivityExecutor
|
||||
import com.topjohnwu.magisk.model.events.ViewEvent
|
||||
import com.topjohnwu.magisk.redesign.compat.CompatActivity
|
||||
@ -23,7 +23,7 @@ class MagiskNavigationEvent(
|
||||
operator fun invoke(builder: Builder.() -> Unit) = Builder().apply(builder).build()
|
||||
}
|
||||
|
||||
override fun invoke(activity: AppCompatActivity) {
|
||||
override fun invoke(activity: BaseActivity<*, *>) {
|
||||
if (activity !is CompatActivity<*, *>) return
|
||||
activity.navigation?.navigateTo(this)
|
||||
}
|
||||
@ -91,4 +91,4 @@ class MagiskAnimBuilder {
|
||||
var popExit = 0
|
||||
|
||||
val anySet: Boolean get() = enter != 0 || exit != 0 || popEnter != 0 || popExit != 0
|
||||
}
|
||||
}
|
||||
|
@ -2,10 +2,10 @@ package com.topjohnwu.magisk.redesign.compat
|
||||
|
||||
import android.graphics.Insets
|
||||
import android.view.View
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.view.ViewCompat
|
||||
import androidx.core.view.WindowInsetsCompat
|
||||
import androidx.fragment.app.Fragment
|
||||
import com.topjohnwu.magisk.base.BaseActivity
|
||||
import com.topjohnwu.magisk.model.events.ActivityExecutor
|
||||
import com.topjohnwu.magisk.model.events.ContextExecutor
|
||||
import com.topjohnwu.magisk.model.events.FragmentExecutor
|
||||
@ -26,7 +26,7 @@ class CompatDelegate internal constructor(
|
||||
view.viewModel.requestRefresh()
|
||||
}
|
||||
|
||||
fun onEventExecute(event: ViewEvent, activity: AppCompatActivity) {
|
||||
fun onEventExecute(event: ViewEvent, activity: BaseActivity<*, *>) {
|
||||
(event as? ContextExecutor)?.invoke(activity)
|
||||
(event as? ActivityExecutor)?.invoke(activity)
|
||||
(event as? FragmentExecutor)?.let {
|
||||
@ -37,7 +37,7 @@ class CompatDelegate internal constructor(
|
||||
fun onEventExecute(event: ViewEvent, fragment: Fragment) {
|
||||
(event as? ContextExecutor)?.invoke(fragment.requireContext())
|
||||
(event as? FragmentExecutor)?.invoke(fragment)
|
||||
(event as? ActivityExecutor)?.invoke(fragment.requireActivity() as AppCompatActivity)
|
||||
(event as? ActivityExecutor)?.invoke(fragment.requireActivity() as BaseActivity<*, *>)
|
||||
}
|
||||
|
||||
private fun ensureInsets() {
|
||||
@ -74,4 +74,4 @@ class CompatDelegate internal constructor(
|
||||
insets.systemWindowInsetBottom - bottom
|
||||
)
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user