Show module suspend notice

Close #4862
This commit is contained in:
topjohnwu 2021-11-09 23:59:37 -08:00
parent b8c1588284
commit ddd153c00d
4 changed files with 33 additions and 2 deletions

View File

@ -21,8 +21,12 @@ data class LocalModule(
private val disableFile = SuFile(path, "disable") private val disableFile = SuFile(path, "disable")
private val updateFile = SuFile(path, "update") private val updateFile = SuFile(path, "update")
private val ruleFile = SuFile(path, "sepolicy.rule") 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 updated: Boolean get() = updateFile.exists()
val isRiru: Boolean get() = (id == "riru-core") || riruFolder.exists()
val isZygisk: Boolean get() = zygiskFolder.exists()
var enable: Boolean var enable: Boolean
get() = !disableFile.exists() get() = !disableFile.exists()

View File

@ -3,12 +3,14 @@ package com.topjohnwu.magisk.ui.module
import androidx.databinding.Bindable import androidx.databinding.Bindable
import com.topjohnwu.magisk.BR import com.topjohnwu.magisk.BR
import com.topjohnwu.magisk.R 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.LocalModule
import com.topjohnwu.magisk.core.model.module.OnlineModule import com.topjohnwu.magisk.core.model.module.OnlineModule
import com.topjohnwu.magisk.databinding.DiffRvItem import com.topjohnwu.magisk.databinding.DiffRvItem
import com.topjohnwu.magisk.databinding.ObservableDiffRvItem import com.topjohnwu.magisk.databinding.ObservableDiffRvItem
import com.topjohnwu.magisk.databinding.RvContainer import com.topjohnwu.magisk.databinding.RvContainer
import com.topjohnwu.magisk.databinding.set import com.topjohnwu.magisk.databinding.set
import com.topjohnwu.magisk.utils.asText
object InstallModule : DiffRvItem<InstallModule>() { object InstallModule : DiffRvItem<InstallModule>() {
override val layoutRes = R.layout.item_module_download override val layoutRes = R.layout.item_module_download
@ -70,6 +72,13 @@ class LocalModuleRvItem(
item.remove = value 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 isUpdated get() = item.updated
val isModified get() = isRemoved || isUpdated val isModified get() = isRemoved || isUpdated

View File

@ -28,7 +28,7 @@
isEnabled="@{!item.removed}" isEnabled="@{!item.removed}"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:alpha="@{item.enabled ? 1f : .5f}" android:alpha="@{(item.enabled &amp;&amp; !item.suspended) ? 1f : .5f}"
android:nextFocusRight="@id/module_indicator" android:nextFocusRight="@id/module_indicator"
tools:layout_gravity="center" tools:layout_gravity="center"
tools:layout_margin="@dimen/l1"> tools:layout_margin="@dimen/l1">
@ -94,6 +94,22 @@
app:layout_constraintStart_toEndOf="@+id/module_info" app:layout_constraintStart_toEndOf="@+id/module_info"
app:layout_constraintTop_toTopOf="@+id/module_title" /> app:layout_constraintTop_toTopOf="@+id/module_title" />
<TextView
android:id="@+id/module_suspend_text"
goneUnless="@{item.suspended}"
strikeThrough="@{item.removed}"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/l1"
android:layout_marginTop="@dimen/l_50"
android:layout_marginEnd="@dimen/l1"
android:text="@{item.suspendText}"
android:textAppearance="@style/AppearanceFoundation.Tiny.Bold"
android:textColor="?colorError"
app:layout_constraintTop_toBottomOf="@+id/module_version_author"
tools:lines="1"
tools:text="@tools:sample/lorem/random" />
<TextView <TextView
android:id="@+id/module_description" android:id="@+id/module_description"
gone="@{item.item.description.empty}" gone="@{item.item.description.empty}"
@ -105,7 +121,7 @@
android:layout_marginEnd="@dimen/l1" android:layout_marginEnd="@dimen/l1"
android:text="@{item.item.description}" android:text="@{item.item.description}"
android:textAppearance="@style/AppearanceFoundation.Caption.Variant" android:textAppearance="@style/AppearanceFoundation.Caption.Variant"
app:layout_constraintTop_toBottomOf="@+id/module_version_author" app:layout_constraintTop_toBottomOf="@+id/module_suspend_text"
tools:lines="4" tools:lines="4"
tools:text="@tools:sample/lorem/random" /> tools:text="@tools:sample/lorem/random" />

View File

@ -123,6 +123,8 @@
<string name="module_installed">@string/home_installed_version</string> <string name="module_installed">@string/home_installed_version</string>
<string name="module_section_online">Online</string> <string name="module_section_online">Online</string>
<string name="sorting_order">Sorting Order</string> <string name="sorting_order">Sorting Order</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>
<!--Settings--> <!--Settings-->
<string name="settings_dark_mode_title">Theme Mode</string> <string name="settings_dark_mode_title">Theme Mode</string>