You've already forked Magisk
mirror of
https://github.com/topjohnwu/Magisk.git
synced 2025-09-06 06:36:58 +00:00
Fixed updating values with sql
This commit is contained in:
@@ -59,7 +59,7 @@ fun MagiskPolicy.toMap() = mapOf(
|
||||
"until" to until,
|
||||
"logging" to if (logging) 1 else 0,
|
||||
"notification" to if (notification) 1 else 0
|
||||
).mapValues { it.toString() }
|
||||
).mapValues { it.value.toString() }
|
||||
|
||||
@Throws(PackageManager.NameNotFoundException::class)
|
||||
fun Map<String, String>.toPolicy(pm: PackageManager): MagiskPolicy {
|
||||
|
||||
@@ -26,6 +26,13 @@ class PolicyRvItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvIte
|
||||
|
||||
private val rxBus: RxBus by inject()
|
||||
|
||||
private val currentStateItem
|
||||
get() = item.copy(
|
||||
policy = if (isEnabled.value) Policy.ALLOW else Policy.DENY,
|
||||
notification = shouldNotify.value,
|
||||
logging = shouldLog.value
|
||||
)
|
||||
|
||||
init {
|
||||
isEnabled.addOnPropertyChangedCallback {
|
||||
it ?: return@addOnPropertyChangedCallback
|
||||
@@ -33,11 +40,11 @@ class PolicyRvItem(val item: MagiskPolicy, val icon: Drawable) : ComparableRvIte
|
||||
}
|
||||
shouldNotify.addOnPropertyChangedCallback {
|
||||
it ?: return@addOnPropertyChangedCallback
|
||||
rxBus.post(PolicyUpdateEvent.Notification(this@PolicyRvItem, shouldNotify.value))
|
||||
rxBus.post(PolicyUpdateEvent.Notification(currentStateItem))
|
||||
}
|
||||
shouldLog.addOnPropertyChangedCallback {
|
||||
it ?: return@addOnPropertyChangedCallback
|
||||
rxBus.post(PolicyUpdateEvent.Log(this@PolicyRvItem, shouldLog.value))
|
||||
rxBus.post(PolicyUpdateEvent.Log(currentStateItem))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user