From 6e14a727b10926b72d67f8c2aba40c0ed5753202 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Sun, 29 Mar 2020 11:55:37 +0200 Subject: [PATCH] Fixed modules screen not offering reboot when local modules change --- .../topjohnwu/magisk/core/model/module/Module.kt | 14 ++++++++------ .../magisk/model/entity/recycler/ModuleRvItem.kt | 11 ++++++----- .../topjohnwu/magisk/ui/module/ModuleViewModel.kt | 1 + 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/core/model/module/Module.kt b/app/src/main/java/com/topjohnwu/magisk/core/model/module/Module.kt index 40ddecdd7..a73df7f92 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/model/module/Module.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/model/module/Module.kt @@ -18,12 +18,13 @@ class Module(path: String) : BaseModule() { private val updateFile = SuFile(path, "update") private val ruleFile = SuFile(path, "sepolicy.rule") - val updated: Boolean = updateFile.exists() + val updated: Boolean get() = updateFile.exists() - var enable: Boolean = !disableFile.exists() + var enable: Boolean + get() = !disableFile.exists() set(enable) { val dir = "$PERSIST/$id" - field = if (enable) { + if (enable) { Shell.su("mkdir -p $dir", "cp -af $ruleFile $dir").submit() disableFile.delete() } else { @@ -32,9 +33,10 @@ class Module(path: String) : BaseModule() { } } - var remove: Boolean = removeFile.exists() + var remove: Boolean + get() = removeFile.exists() set(remove) { - field = if (remove) { + if (remove) { Shell.su("rm -rf $PERSIST/$id").submit() removeFile.createNewFile() } else { @@ -67,7 +69,7 @@ class Module(path: String) : BaseModule() { val moduleList = mutableListOf() val path = SuFile(Const.MAGISK_PATH) val modules = - path.listFiles { _, name -> name != "lost+found" && name != ".core" }.orEmpty() + path.listFiles { _, name -> name != "lost+found" && name != ".core" }.orEmpty() for (file in modules) { if (file.isFile) continue val module = Module(Const.MAGISK_PATH + "/" + file.name) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt b/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt index c47dc3ae0..111154846 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt +++ b/app/src/main/java/com/topjohnwu/magisk/model/entity/recycler/ModuleRvItem.kt @@ -110,22 +110,23 @@ class ModuleItem(val item: Module) : ObservableItem(), Observable { } @get:Bindable - var isEnabled = item.enable + var isEnabled + get() = item.enable set(value) { - field = value item.enable = value notifyChange(BR.enabled) } + @get:Bindable - var isRemoved = item.remove + var isRemoved + get() = item.remove set(value) { - field = value item.remove = value notifyChange(BR.removed) } val isUpdated get() = item.updated - val isModified get() = isRemoved || item.updated + val isModified get() = isRemoved || isUpdated fun toggle() { isEnabled = !isEnabled diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt index 64224380f..d952cf994 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleViewModel.kt @@ -193,6 +193,7 @@ class ModuleViewModel( .doOnSuccess { addInstalledEmptyMessage() addUpdatableEmptyMessage() + updateActiveState() } .ignoreElement()!!