From ddd153c00deb6820e13899bbc11480454a0eb8bb Mon Sep 17 00:00:00 2001 From: topjohnwu Date: Tue, 9 Nov 2021 23:59:37 -0800 Subject: [PATCH] Show module suspend notice Close #4862 --- .../magisk/core/model/module/LocalModule.kt | 4 ++++ .../magisk/ui/module/ModuleRvItem.kt | 9 +++++++++ app/src/main/res/layout/item_module_md2.xml | 20 +++++++++++++++++-- app/src/main/res/values/strings.xml | 2 ++ 4 files changed, 33 insertions(+), 2 deletions(-) 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 f5baa5d54..cd3d5eb12 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 @@ -21,8 +21,12 @@ data class LocalModule( private val disableFile = SuFile(path, "disable") private val updateFile = SuFile(path, "update") private val ruleFile = SuFile(path, "sepolicy.rule") + private val riruFolder = SuFile(path, "riru") + private val zygiskFolder = SuFile(path, "zygisk") val updated: Boolean get() = updateFile.exists() + val isRiru: Boolean get() = (id == "riru-core") || riruFolder.exists() + val isZygisk: Boolean get() = zygiskFolder.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 0166187e6..b874d146c 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 @@ -3,12 +3,14 @@ package com.topjohnwu.magisk.ui.module import androidx.databinding.Bindable import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.R +import com.topjohnwu.magisk.core.Info import com.topjohnwu.magisk.core.model.module.LocalModule import com.topjohnwu.magisk.core.model.module.OnlineModule 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.asText object InstallModule : DiffRvItem() { override val layoutRes = R.layout.item_module_download @@ -70,6 +72,13 @@ class LocalModuleRvItem( item.remove = value } + 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 isModified get() = isRemoved || isUpdated diff --git a/app/src/main/res/layout/item_module_md2.xml b/app/src/main/res/layout/item_module_md2.xml index 661a54ac5..7d27e1901 100644 --- a/app/src/main/res/layout/item_module_md2.xml +++ b/app/src/main/res/layout/item_module_md2.xml @@ -28,7 +28,7 @@ isEnabled="@{!item.removed}" android:layout_width="match_parent" android:layout_height="wrap_content" - android:alpha="@{item.enabled ? 1f : .5f}" + android:alpha="@{(item.enabled && !item.suspended) ? 1f : .5f}" android:nextFocusRight="@id/module_indicator" tools:layout_gravity="center" tools:layout_margin="@dimen/l1"> @@ -94,6 +94,22 @@ app:layout_constraintStart_toEndOf="@+id/module_info" app:layout_constraintTop_toTopOf="@+id/module_title" /> + + diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 0088fa32f..5cae69fc4 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -123,6 +123,8 @@ @string/home_installed_version Online Sorting Order + Module suspended because %1$s is enabled + Module suspended because %1$s is not enabled Theme Mode