diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt index c383dceec..710910c35 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/home/HomeViewModel.kt @@ -1,6 +1,7 @@ package com.topjohnwu.magisk.ui.home import android.content.res.Resources +import com.skoumal.teanity.extensions.addOnPropertyChangedCallback import com.skoumal.teanity.util.KObservableField import com.topjohnwu.magisk.* import com.topjohnwu.magisk.model.events.* @@ -24,11 +25,6 @@ class HomeViewModel( val isForceEncryption = KObservableField(Config.keepEnc) 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 magiskStateText = Observer(magiskState) { when (magiskState.value) { @@ -90,6 +86,14 @@ class HomeViewModel( init { Event.register(this) + + isForceEncryption.addOnPropertyChangedCallback { + Config.keepEnc = it ?: return@addOnPropertyChangedCallback + } + isKeepVerity.addOnPropertyChangedCallback { + Config.keepVerity = it ?: return@addOnPropertyChangedCallback + } + refresh() }