You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Remove RxBus
This commit is contained in:
@@ -9,7 +9,6 @@ import com.topjohnwu.magisk.core.model.MagiskPolicy
|
||||
import com.topjohnwu.magisk.databinding.ComparableRvItem
|
||||
import com.topjohnwu.magisk.extensions.toggle
|
||||
import com.topjohnwu.magisk.extensions.value
|
||||
import com.topjohnwu.magisk.model.events.PolicyUpdateEvent
|
||||
import com.topjohnwu.magisk.ui.superuser.SuperuserViewModel
|
||||
|
||||
class PolicyItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvItem<PolicyItem>() {
|
||||
@@ -42,12 +41,12 @@ class PolicyItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvItem<
|
||||
|
||||
fun toggleNotify(viewModel: SuperuserViewModel) {
|
||||
shouldNotify.toggle()
|
||||
viewModel.updatePolicy(PolicyUpdateEvent.Notification(updatedPolicy))
|
||||
viewModel.updatePolicy(updatedPolicy, isLogging = false)
|
||||
}
|
||||
|
||||
fun toggleLog(viewModel: SuperuserViewModel) {
|
||||
shouldLog.toggle()
|
||||
viewModel.updatePolicy(PolicyUpdateEvent.Log(updatedPolicy))
|
||||
viewModel.updatePolicy(updatedPolicy, isLogging = true)
|
||||
}
|
||||
|
||||
override fun onBindingBound(binding: ViewDataBinding) {
|
||||
|
||||
@@ -1,15 +0,0 @@
|
||||
package com.topjohnwu.magisk.model.events
|
||||
|
||||
import com.topjohnwu.magisk.core.model.MagiskPolicy
|
||||
import com.topjohnwu.magisk.utils.RxBus
|
||||
import org.json.JSONObject
|
||||
|
||||
sealed class PolicyUpdateEvent(val item: MagiskPolicy) : RxBus.Event {
|
||||
class Notification(item: MagiskPolicy) : PolicyUpdateEvent(item)
|
||||
class Log(item: MagiskPolicy) : PolicyUpdateEvent(item)
|
||||
}
|
||||
|
||||
data class SafetyNetResult(
|
||||
val response: JSONObject? = null,
|
||||
val dismiss: Boolean = false
|
||||
) : RxBus.Event
|
||||
@@ -13,7 +13,7 @@ import com.topjohnwu.magisk.extensions.DynamicClassLoader
|
||||
import com.topjohnwu.magisk.extensions.OnErrorListener
|
||||
import com.topjohnwu.magisk.extensions.subscribeK
|
||||
import com.topjohnwu.magisk.extensions.writeTo
|
||||
import com.topjohnwu.magisk.utils.RxBus
|
||||
import com.topjohnwu.magisk.ui.safetynet.SafetyNetResult
|
||||
import com.topjohnwu.magisk.view.MagiskDialog
|
||||
import com.topjohnwu.magisk.view.MarkDownWindow
|
||||
import com.topjohnwu.superuser.Shell
|
||||
@@ -38,10 +38,11 @@ abstract class ViewEvent {
|
||||
var handled = false
|
||||
}
|
||||
|
||||
class UpdateSafetyNetEvent : ViewEvent(), ContextExecutor, KoinComponent, SafetyNetHelper.Callback {
|
||||
class CheckSafetyNetEvent(
|
||||
private val callback: (SafetyNetResult) -> Unit = {}
|
||||
) : ViewEvent(), ContextExecutor, KoinComponent, SafetyNetHelper.Callback {
|
||||
|
||||
private val magiskRepo by inject<MagiskRepository>()
|
||||
private val rxBus by inject<RxBus>()
|
||||
|
||||
private lateinit var apk: File
|
||||
private lateinit var dex: File
|
||||
@@ -93,7 +94,7 @@ class UpdateSafetyNetEvent : ViewEvent(), ContextExecutor, KoinComponent, Safety
|
||||
.map { it.byteStream().writeTo(apk) }
|
||||
.subscribeK { attest(context) {
|
||||
Timber.e(it)
|
||||
rxBus.post(SafetyNetResult())
|
||||
callback(SafetyNetResult())
|
||||
} }
|
||||
|
||||
if (!askUser) {
|
||||
@@ -111,13 +112,13 @@ class UpdateSafetyNetEvent : ViewEvent(), ContextExecutor, KoinComponent, Safety
|
||||
}
|
||||
.applyButton(MagiskDialog.ButtonType.NEGATIVE) {
|
||||
titleRes = android.R.string.cancel
|
||||
onClick { rxBus.post(SafetyNetResult(dismiss = true)) }
|
||||
onClick { callback(SafetyNetResult(dismiss = true)) }
|
||||
}
|
||||
.reveal()
|
||||
}
|
||||
|
||||
override fun onResponse(response: JSONObject?) {
|
||||
rxBus.post(SafetyNetResult(response))
|
||||
callback(SafetyNetResult(response))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user