diff --git a/app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt b/app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt index d1c7df947..9cedb57a5 100644 --- a/app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt +++ b/app/src/main/java/com/topjohnwu/magisk/core/model/module/LocalModule.kt @@ -29,10 +29,12 @@ data class LocalModule( private val ruleFile = SuFile(path, "sepolicy.rule") private val riruFolder = SuFile(path, "riru") private val zygiskFolder = SuFile(path, "zygisk") + private val unloaded = SuFile(zygiskFolder, "unloaded") val updated: Boolean get() = updateFile.exists() val isRiru: Boolean get() = (id == "riru-core") || riruFolder.exists() val isZygisk: Boolean get() = zygiskFolder.exists() + val zygiskUnloaded: Boolean get() = unloaded.exists() var enable: Boolean get() = !disableFile.exists() diff --git a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt index 98433e5c1..d7d9e6842 100644 --- a/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt +++ b/app/src/main/java/com/topjohnwu/magisk/ui/module/ModuleRvItem.kt @@ -9,6 +9,7 @@ import com.topjohnwu.magisk.databinding.DiffRvItem import com.topjohnwu.magisk.databinding.ObservableDiffRvItem import com.topjohnwu.magisk.databinding.RvContainer import com.topjohnwu.magisk.databinding.set +import com.topjohnwu.magisk.utils.TextHolder import com.topjohnwu.magisk.utils.asText object InstallModule : DiffRvItem() { @@ -21,6 +22,25 @@ class LocalModuleRvItem( override val layoutRes = R.layout.item_module_md2 + val showNotice: Boolean + val noticeText: TextHolder + + init { + val isZygisk = item.isZygisk + val isRiru = item.isRiru + val zygiskUnloaded = isZygisk && item.zygiskUnloaded + + showNotice = zygiskUnloaded || + (Info.isZygiskEnabled && isRiru) || + (!Info.isZygiskEnabled && isZygisk) + noticeText = + when { + zygiskUnloaded -> R.string.zygisk_module_unloaded.asText() + isRiru -> R.string.suspend_text_riru.asText(R.string.zygisk.asText()) + else -> R.string.suspend_text_zygisk.asText(R.string.zygisk.asText()) + } + } + @get:Bindable var isEnabled = item.enable set(value) = set(value, field, { field = it }, BR.enabled, BR.updateReady) { @@ -38,14 +58,7 @@ class LocalModuleRvItem( get() = item.updateInfo != null && !isRemoved && isEnabled set(_) = notifyPropertyChanged(BR.updateReady) - val isSuspended = - (Info.isZygiskEnabled && item.isRiru) || (!Info.isZygiskEnabled && item.isZygisk) - - val suspendText = - if (item.isRiru) R.string.suspend_text_riru.asText(R.string.zygisk.asText()) - else R.string.suspend_text_zygisk.asText(R.string.zygisk.asText()) - - val isUpdated get() = item.updated + val isUpdated = item.updated fun delete() { isRemoved = !isRemoved diff --git a/app/src/main/res/layout/item_module_md2.xml b/app/src/main/res/layout/item_module_md2.xml index 602ffabcf..d20b8902e 100644 --- a/app/src/main/res/layout/item_module_md2.xml +++ b/app/src/main/res/layout/item_module_md2.xml @@ -25,7 +25,7 @@ Update Available Module suspended because %1$s is enabled Module suspended because %1$s is not enabled + Zygisk module not loaded due to incompatibility Theme Mode