Skip to content

Commit

Permalink
manager: Update Home page
Browse files Browse the repository at this point in the history
- Add SUSFS card
- Remove Donate card
- Remove Learn More card
  • Loading branch information
changhuapeng committed Dec 23, 2024
1 parent 2402e65 commit 0e5d3a5
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ private fun BottomBar(navController: NavHostController) {
}
},
label = { Text(stringResource(destination.label)) },
alwaysShowLabel = false
alwaysShowLabel = true
)
}
}
Expand Down
91 changes: 45 additions & 46 deletions manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ import androidx.compose.runtime.*
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.vector.ImageVector
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.platform.LocalUriHandler
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.res.vectorResource
import androidx.compose.ui.tooling.preview.Preview
import androidx.compose.ui.unit.dp
import androidx.core.content.pm.PackageInfoCompat
Expand Down Expand Up @@ -93,15 +95,14 @@ fun HomeScreen(navigator: DestinationsNavigator) {
stringResource(id = R.string.grant_root_failed)
)
}
SusfsCard()
val checkUpdate =
LocalContext.current.getSharedPreferences("settings", Context.MODE_PRIVATE)
.getBoolean("check_update", true)
if (checkUpdate) {
UpdateCard()
}
InfoCard()
DonateCard()
LearnMoreCard()
Spacer(Modifier)
}
}
Expand Down Expand Up @@ -337,55 +338,53 @@ fun WarningCard(
}

@Composable
fun LearnMoreCard() {
val uriHandler = LocalUriHandler.current
val url = stringResource(R.string.home_learn_kernelsu_url)

ElevatedCard {

Row(modifier = Modifier
.fillMaxWidth()
.clickable {
uriHandler.openUri(url)
}
.padding(24.dp), verticalAlignment = Alignment.CenterVertically) {
Column {
Text(
text = stringResource(R.string.home_learn_kernelsu),
style = MaterialTheme.typography.titleSmall
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_click_to_learn_kernelsu),
style = MaterialTheme.typography.bodyMedium
)
}
}
}
}

@Composable
fun DonateCard() {
val uriHandler = LocalUriHandler.current
private fun SusfsCard(
) {
val susfsVersion = getSusfsVersion()

ElevatedCard {

Row(modifier = Modifier
.fillMaxWidth()
.clickable {
uriHandler.openUri("https://patreon.com/weishu")
}
.padding(24.dp), verticalAlignment = Alignment.CenterVertically) {
Column {
Text(
text = stringResource(R.string.home_support_title),
style = MaterialTheme.typography.titleSmall
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_support_content),
style = MaterialTheme.typography.bodyMedium
)
Icon(
ImageVector.vectorResource(R.drawable.ic_susfs),
stringResource(R.string.susfs),
modifier = Modifier.size(24.dp)
)
Column(Modifier.padding(start = 20.dp)) {
when {
susfsVersion.isNotBlank() -> {
Text(
text =
"${stringResource(R.string.susfs)} " +
"$susfsVersion " +
"(${getSusfsVariant()})",
style = MaterialTheme.typography.bodyMedium
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(
R.string.susfs_sus_su_mode,
if (getSusfsSSMode().length == 1) getSusfsSSMode() else "Unsupported"
),
style = MaterialTheme.typography.bodyMedium
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(
R.string.susfs_auto_hide,
if (getSusfsAutoHide()) "Yes" else "No"
),
style = MaterialTheme.typography.bodyMedium
)
}
else -> {
Text(
text = "${stringResource(R.string.susfs)} ${stringResource(R.string.susfs_unsupported)}",
style = MaterialTheme.typography.titleMedium
)
}
}
}
}
}
Expand Down
24 changes: 24 additions & 0 deletions manager/app/src/main/java/me/weishu/kernelsu/ui/util/KsuCli.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ private fun getKsuDaemonPath(): String {
return ksuApp.applicationInfo.nativeLibraryDir + File.separator + "libksud.so"
}

private fun getSusfsPath(): String {
return ksuApp.applicationInfo.nativeLibraryDir + File.separator + "libsusfs.so"
}

object KsuCli {
val SHELL: Shell = createRootShell()
val GLOBAL_MNT_SHELL: Shell = createRootShell(true)
Expand Down Expand Up @@ -432,3 +436,23 @@ fun restartApp(packageName: String) {
forceStopApp(packageName)
launchApp(packageName)
}

fun getSusfsVersion(): String {
val shell = getRootShell()
return ShellUtils.fastCmd(shell, "${getSusfsPath()} show version")
}

fun getSusfsVariant(): String {
val shell = getRootShell()
return ShellUtils.fastCmd(shell, "${getSusfsPath()} show variant")
}

fun getSusfsAutoHide(): Boolean {
val shell = getRootShell()
return ShellUtils.fastCmdResult(shell, "${getSusfsPath()} show enabled_features | grep AUTO")
}

fun getSusfsSSMode(): String {
val shell = getRootShell()
return ShellUtils.fastCmd(shell, "${getSusfsPath()} sus_su show_working_mode")
}
14 changes: 14 additions & 0 deletions manager/app/src/main/res/drawable/ic_susfs.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:pathData="M265,22.6c-1.4,0.2 -6.6,1.1 -11.7,1.9 -26.7,4.4 -53.1,17 -74.4,35.8 -27.5,24.1 -45.1,59 -48.9,96.7 -1.3,13 -1.4,289.4 -0.1,299.3 2.1,15.8 16.4,29.4 34.6,32.8 3.6,0.6 16.4,0.9 33.4,0.7l27.6,-0.3 6.3,-3.4c10.6,-5.8 19.5,-17.5 22.1,-29.4 0.6,-2.3 1.3,-14.9 1.7,-28l0.7,-23.7 21.6,0.2 21.6,0.3 0.5,27 0.5,27 2.8,5.7c4.3,8.7 10.7,15.2 19,19.3 10.5,5.1 15.4,5.7 46.1,5.3l27.1,-0.3 5.8,-2.7c8.6,-4.1 16.6,-12.6 20.8,-22.4l3.4,-7.9 0.5,-87.6 0.5,-87.6 7.7,-6.2c13.6,-10.7 24.1,-25.9 29.7,-42.6 5.1,-15.5 6.3,-29.6 3.6,-45.1 -5,-28.6 -21.4,-52.2 -45.8,-65.8 -5.8,-3.3 -6.4,-4 -9.2,-10.3 -13.7,-31.7 -40.8,-59.8 -72,-74.8 -18.9,-9.1 -36.8,-13.4 -58.5,-14 -8,-0.2 -15.6,-0.2 -17,0.1zM385.2,150.1c19.2,4 34.8,18.5 40.4,37.4 2.7,9 2.5,24.1 -0.5,32.7 -6.1,18.2 -22.2,32.5 -40.2,35.8 -3.7,0.7 -26.2,1 -62.6,0.8l-56.9,-0.3 -7.6,-3.8c-11.8,-5.8 -20,-15.9 -22.8,-27.9 -0.5,-2.4 -1,-12.5 -1,-22.5 0,-15 0.3,-19.2 1.9,-24.2 4.3,-13.8 13.8,-23.3 27.6,-27.7 5.4,-1.7 113.8,-2 121.7,-0.3z"
android:fillColor="#000000"
android:strokeColor="#00000000"/>
<path
android:pathData="M74,173.9c-14.6,4.7 -23,13 -28,27.6 -1.9,5.6 -2,8.4 -2,87.3 0,80 0,81.6 2.1,88.6 3.1,10.3 10.5,19.9 18.6,23.9 3.8,1.9 18.5,4 25.1,3.5l5.2,-0.3 0.3,-116.3 0.2,-116.2 -8,0.1c-4.8,-0 -10.2,0.7 -13.5,1.8z"
android:fillColor="#000000"
android:strokeColor="#00000000"/>
</vector>
4 changes: 4 additions & 0 deletions manager/app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,10 @@
<string name="selinux_status_enforcing">Enforcing</string>
<string name="selinux_status_permissive">Permissive</string>
<string name="selinux_status_unknown">Unknown</string>
<string name="susfs">SuSFS</string>
<string name="susfs_auto_hide">Auto-hide: %s</string>
<string name="susfs_sus_su_mode">SUS_SU mode: %s</string>
<string name="susfs_unsupported">Unsupported</string>
<string name="superuser">Superuser</string>
<string name="module_failed_to_enable">Failed to enable module: %s</string>
<string name="module_failed_to_disable">Failed to disable module: %s</string>
Expand Down

0 comments on commit 0e5d3a5

Please sign in to comment.