Skip to content

Commit 7401978

Browse files
committed
ui: polish rootless home/settings behavior
Address several rootless-mode UX inconsistencies and control semantics. - Home: fix InfoCard spacing when su path is hidden in rootless mode. - Home: show mode label as literal 'Rootless' (not localized). - Home: show reboot menu only when root is actually available (internal KP root or external root source). - Settings: hide 'Reset su path' when running in rootless mode. - Settings > More: invert the card transparency slider axis so the control matches transparency semantics while preserving stored alpha.
1 parent 18b5487 commit 7401978

3 files changed

Lines changed: 33 additions & 12 deletions

File tree

app/src/main/java/com/anatdx/icepatch/ui/screen/Home.kt

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ import com.anatdx.icepatch.util.Version.getManagerVersion
119119
import com.anatdx.icepatch.util.checkNewVersion
120120
import com.anatdx.icepatch.util.getSELinuxStatus
121121
import com.anatdx.icepatch.util.reboot
122+
import com.anatdx.icepatch.util.rootAvailable
122123
import com.anatdx.icepatch.util.ui.APDialogBlurBehindUtils
123124

124125
private val managerVersion = getManagerVersion()
@@ -139,11 +140,19 @@ fun HomeScreen(navigator: DestinationsNavigator) {
139140
if (kpState != APApplication.State.UNKNOWN_STATE) {
140141
showPatchFloatAction = false
141142
}
143+
val canReboot by produceState(
144+
initialValue = false,
145+
key1 = kpState,
146+
key2 = rootlessMode,
147+
key3 = APApplication.superKey
148+
) {
149+
value = rootAvailable()
150+
}
142151

143152
Scaffold(
144153
containerColor = Color.Transparent,
145154
topBar = {
146-
TopBar(navigator = navigator, kpState = kpState)
155+
TopBar(canReboot = canReboot)
147156
}
148157
) { innerPadding ->
149158
Column(
@@ -435,15 +444,15 @@ fun RebootDropdownItem(@StringRes id: Int, reason: String = "") {
435444
@OptIn(ExperimentalMaterial3Api::class)
436445
@Composable
437446
private fun TopBar(
438-
navigator: DestinationsNavigator, kpState: APApplication.State
447+
canReboot: Boolean
439448
) {
440449
var showDropdownReboot by remember { mutableStateOf(false) }
441450

442451
TopAppBar(
443452
title = { Text(stringResource(R.string.app_name)) },
444453
colors = TopBarStyle.topAppBarColors(),
445454
actions = {
446-
if (kpState != APApplication.State.UNKNOWN_STATE) {
455+
if (canReboot) {
447456
IconButton(onClick = {
448457
showDropdownReboot = true
449458
}) {
@@ -594,7 +603,7 @@ private fun KStatusCard(
594603
Spacer(Modifier.height(4.dp))
595604
Text(
596605
text = "${Version.installedKPVString()} (${managerVersion.second}) - " + when {
597-
rootlessMode -> stringResource(R.string.home_mode_rootless)
606+
rootlessMode -> "Rootless"
598607
apState != APApplication.State.ANDROIDPATCH_NOT_INSTALLED -> stringResource(R.string.home_mode_full)
599608
else -> stringResource(R.string.home_mode_kernelpatch)
600609
},
@@ -965,23 +974,33 @@ private fun InfoCard(
965974
}
966975

967976
if (kpState != APApplication.State.UNKNOWN_STATE) {
977+
val showKpVersion = allow("kp_version")
968978
val showSuPath = !rootlessMode && allow("su_path")
979+
val showApVersion =
980+
apState != APApplication.State.UNKNOWN_STATE &&
981+
apState != APApplication.State.ANDROIDPATCH_NOT_INSTALLED &&
982+
allow("ap_version")
983+
val showDevice = allow("device")
984+
val showKernel = allow("kernel")
985+
val showSystem = allow("system")
986+
val showFingerprint = allow("fingerprint")
987+
val showSelinux = allow("selinux")
969988
InfoCardItem(
970989
stringResource(R.string.home_kpatch_version),
971990
Version.installedKPVString(),
972991
Icons.Filled.Healing,
973-
allow("kp_version")
992+
showKpVersion
974993
)
975-
if (allow("kp_version") && showSuPath) {
994+
if (showKpVersion && (showSuPath || showApVersion || showDevice || showKernel || showSystem || showFingerprint || showSelinux)) {
976995
Spacer(Modifier.height(16.dp))
977996
}
978997
InfoCardItem(
979998
stringResource(R.string.home_su_path),
980-
Natives.suPath(),
999+
if (showSuPath) Natives.suPath() else "",
9811000
Icons.Filled.Security,
9821001
showSuPath
9831002
)
984-
if (showSuPath) {
1003+
if (showSuPath && (showApVersion || showDevice || showKernel || showSystem || showFingerprint || showSelinux)) {
9851004
Spacer(Modifier.height(16.dp))
9861005
}
9871006
}

app/src/main/java/com/anatdx/icepatch/ui/screen/Settings.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ import java.util.Locale
110110
@OptIn(ExperimentalMaterial3Api::class)
111111
fun SettingScreen(navigator: DestinationsNavigator) {
112112
val state by APApplication.apStateLiveData.observeAsState(APApplication.State.UNKNOWN_STATE)
113+
val rootlessMode by APApplication.rootlessModeLiveData.observeAsState(false)
113114
val kPatchReady = state != APApplication.State.UNKNOWN_STATE
114115
val aPatchReady =
115116
(state == APApplication.State.ANDROIDPATCH_INSTALLING || state == APApplication.State.ANDROIDPATCH_INSTALLED || state == APApplication.State.ANDROIDPATCH_NEED_UPDATE)
@@ -267,7 +268,7 @@ fun SettingScreen(navigator: DestinationsNavigator) {
267268
)
268269

269270
// su path
270-
if (kPatchReady) {
271+
if (kPatchReady && !rootlessMode) {
271272
ListItem(
272273
leadingContent = {
273274
Icon(

app/src/main/java/com/anatdx/icepatch/ui/screen/SettingsMoreScreen.kt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -307,10 +307,11 @@ fun SettingsMoreScreen(navigator: DestinationsNavigator) {
307307
}
308308

309309
Text(text = stringResource(id = R.string.settings_card_alpha))
310+
val cardTransparency = 1f - cardAlpha
310311
Slider(
311-
value = cardAlpha,
312-
valueRange = 0.4f..1f,
313-
onValueChange = { cardAlpha = it },
312+
value = cardTransparency,
313+
valueRange = 0f..0.6f,
314+
onValueChange = { cardAlpha = (1f - it).coerceIn(0.4f, 1f) },
314315
onValueChangeFinished = {
315316
prefs.edit { putFloat(StylePrefs.KEY_CARD_ALPHA, cardAlpha) }
316317
refreshTheme.value = true

0 commit comments

Comments
 (0)