Fixed checkboxes on homescreen not writing values to static fields

This commit is contained in:
Viktor De Pasquale 2019-04-27 11:43:55 +02:00
parent cbe64fd559
commit e426090a18

View File

@ -1,6 +1,7 @@
package com.topjohnwu.magisk.ui.home package com.topjohnwu.magisk.ui.home
import android.content.res.Resources import android.content.res.Resources
import com.skoumal.teanity.extensions.addOnPropertyChangedCallback
import com.skoumal.teanity.util.KObservableField import com.skoumal.teanity.util.KObservableField
import com.topjohnwu.magisk.* import com.topjohnwu.magisk.*
import com.topjohnwu.magisk.model.events.* import com.topjohnwu.magisk.model.events.*
@ -24,11 +25,6 @@ class HomeViewModel(
val isForceEncryption = KObservableField(Config.keepEnc) val isForceEncryption = KObservableField(Config.keepEnc)
val isKeepVerity = KObservableField(Config.keepVerity) val isKeepVerity = KObservableField(Config.keepVerity)
private val prefsObserver = Observer(isForceEncryption, isKeepVerity) {
Config.keepEnc = isForceEncryption.value
Config.keepVerity = isKeepVerity.value
}
val magiskState = KObservableField(MagiskState.LOADING) val magiskState = KObservableField(MagiskState.LOADING)
val magiskStateText = Observer(magiskState) { val magiskStateText = Observer(magiskState) {
when (magiskState.value) { when (magiskState.value) {
@ -90,6 +86,14 @@ class HomeViewModel(
init { init {
Event.register(this) Event.register(this)
isForceEncryption.addOnPropertyChangedCallback {
Config.keepEnc = it ?: return@addOnPropertyChangedCallback
}
isKeepVerity.addOnPropertyChangedCallback {
Config.keepVerity = it ?: return@addOnPropertyChangedCallback
}
refresh() refresh()
} }