Show unloaded Zygisk modules in UI

This commit is contained in:
topjohnwu 2022-01-21 05:08:15 -08:00
parent fbe17dde03
commit a73acfb9c2
4 changed files with 28 additions and 12 deletions

View File

@ -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()

View File

@ -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<InstallModule>() {
@ -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

View File

@ -25,7 +25,7 @@
<com.google.android.material.card.MaterialCardView
style="@style/WidgetFoundation.Card"
isEnabled="@{!item.removed &amp;&amp; item.enabled &amp;&amp; !item.suspended}"
isEnabled="@{!item.removed &amp;&amp; item.enabled &amp;&amp; !item.showNotice}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:nextFocusRight="@id/module_indicator"
@ -173,14 +173,14 @@
tools:constraint_referenced_ids="module_update,module_remove" />
<TextView
android:id="@+id/module_suspend_text"
goneUnless="@{item.suspended}"
android:id="@+id/module_notice_text"
goneUnless="@{item.showNotice}"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:layout_marginEnd="@dimen/l_50"
android:fontFamily="sans-serif-medium"
android:text="@{item.suspendText}"
android:text="@{item.noticeText}"
android:textAppearance="@style/AppearanceFoundation.Caption.Primary"
android:textColor="?colorError"
app:layout_constraintBottom_toBottomOf="@+id/module_remove"

View File

@ -110,6 +110,7 @@
<string name="update_available">Update Available</string>
<string name="suspend_text_riru">Module suspended because %1$s is enabled</string>
<string name="suspend_text_zygisk">Module suspended because %1$s is not enabled</string>
<string name="zygisk_module_unloaded">Zygisk module not loaded due to incompatibility</string>
<!--Settings-->
<string name="settings_dark_mode_title">Theme Mode</string>