manager: Improved UI

This commit is contained in:
Rifat Azad
2024-12-14 21:19:28 +06:00
parent 9eb97a8afa
commit c52d128968
4 changed files with 55 additions and 25 deletions

View File

@@ -8,6 +8,7 @@ import androidx.compose.ui.graphics.vector.ImageVector
import com.ramcosta.composedestinations.generated.destinations.HomeScreenDestination
import com.ramcosta.composedestinations.generated.destinations.ModuleScreenDestination
import com.ramcosta.composedestinations.generated.destinations.SuperUserScreenDestination
import com.ramcosta.composedestinations.generated.destinations.SettingScreenDestination
import com.ramcosta.composedestinations.spec.DirectionDestinationSpec
import me.weishu.kernelsu.R
@@ -20,5 +21,6 @@ enum class BottomBarDestination(
) {
Home(HomeScreenDestination, R.string.home, Icons.Filled.Home, Icons.Outlined.Home, false),
SuperUser(SuperUserScreenDestination, R.string.superuser, Icons.Filled.Security, Icons.Outlined.Security, true),
Module(ModuleScreenDestination, R.string.module, Icons.Filled.Apps, Icons.Outlined.Apps, true)
Module(ModuleScreenDestination, R.string.module, Icons.Filled.Layers, Icons.Outlined.Layers, true),
Settings(SettingScreenDestination, R.string.module, Icons.Filled.Settings, Icons.Outlined.Settings, true)
}

View File

@@ -32,7 +32,6 @@ import androidx.core.content.pm.PackageInfoCompat
import com.ramcosta.composedestinations.annotation.Destination
import com.ramcosta.composedestinations.annotation.RootGraph
import com.ramcosta.composedestinations.generated.destinations.InstallScreenDestination
import com.ramcosta.composedestinations.generated.destinations.SettingScreenDestination
import com.ramcosta.composedestinations.navigation.DestinationsNavigator
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@@ -53,9 +52,6 @@ fun HomeScreen(navigator: DestinationsNavigator) {
topBar = {
TopBar(
kernelVersion,
onSettingsClick = {
navigator.navigate(SettingScreenDestination)
},
onInstallClick = {
navigator.navigate(InstallScreenDestination)
},
@@ -104,6 +100,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
}
NextCard()
InfoCard()
EXperimentalCard()
Spacer(Modifier)
}
}
@@ -166,7 +163,6 @@ fun RebootDropdownItem(@StringRes id: Int, reason: String = "") {
private fun TopBar(
kernelVersion: KernelVersion,
onInstallClick: () -> Unit,
onSettingsClick: () -> Unit,
scrollBehavior: TopAppBarScrollBehavior? = null
) {
TopAppBar(
@@ -207,13 +203,6 @@ private fun TopBar(
RebootDropdownItem(id = R.string.reboot_edl, reason = "edl")
}
}
IconButton(onClick = onSettingsClick) {
Icon(
imageVector = Icons.Filled.Settings,
contentDescription = stringResource(id = R.string.settings)
)
}
},
windowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
scrollBehavior = scrollBehavior
@@ -407,6 +396,51 @@ fun NextCard() {
}
}
@Composable
fun EXperimentalCard() {
/*val uriHandler = LocalUriHandler.current
val url = stringResource(R.string.home_experimental_kernelsu_repo)
*/
ElevatedCard {
Row(modifier = Modifier
.fillMaxWidth()
/*.clickable {
uriHandler.openUri(url)
}
*/
.padding(24.dp), verticalAlignment = Alignment.CenterVertically) {
Column {
Text(
text = stringResource(R.string.home_experimental_kernelsu),
style = MaterialTheme.typography.titleSmall
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_experimental_kernelsu_body),
style = MaterialTheme.typography.bodyMedium
)
Spacer(Modifier.height(4.dp))
Text(
text = stringResource(R.string.home_experimental_kernelsu_body_point_1),
style = MaterialTheme.typography.bodyMedium
)
Spacer(Modifier.height(2.dp))
Text(
text = stringResource(R.string.home_experimental_kernelsu_body_point_2),
style = MaterialTheme.typography.bodyMedium
)
Spacer(Modifier.height(2.dp))
Text(
text = stringResource(R.string.home_experimental_kernelsu_body_point_3),
style = MaterialTheme.typography.bodyMedium
)
}
}
}
}
fun getManagerVersion(context: Context): Pair<String, Long> {
val packageInfo = context.packageManager.getPackageInfo(context.packageName, 0)!!
val versionCode = PackageInfoCompat.getLongVersionCode(packageInfo)

View File

@@ -18,7 +18,6 @@ import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.automirrored.filled.ArrowBack
import androidx.compose.material.icons.automirrored.filled.Undo
import androidx.compose.material.icons.filled.BugReport
import androidx.compose.material.icons.filled.Compress
@@ -105,9 +104,6 @@ fun SettingScreen(navigator: DestinationsNavigator) {
Scaffold(
topBar = {
TopBar(
onBack = {
navigator.popBackStack()
},
scrollBehavior = scrollBehavior
)
},
@@ -438,18 +434,10 @@ fun rememberUninstallDialog(onSelected: (UninstallType) -> Unit): DialogHandle {
@OptIn(ExperimentalMaterial3Api::class)
@Composable
private fun TopBar(
onBack: () -> Unit = {},
scrollBehavior: TopAppBarScrollBehavior? = null
) {
TopAppBar(
title = { Text(stringResource(R.string.settings)) },
navigationIcon = {
IconButton(
onClick = onBack
) {
Icon(Icons.AutoMirrored.Filled.ArrowBack, contentDescription = null)
}
},
windowInsets = WindowInsets.safeDrawing.only(WindowInsetsSides.Top + WindowInsetsSides.Horizontal),
scrollBehavior = scrollBehavior
)

View File

@@ -49,6 +49,12 @@
<string name="home_next_kernelsu">🔥 Next Build</string>
<string name="home_next_kernelsu_repo">https://github.com/rifsxd/KernelSU</string>
<string name="home_next_kernelsu_body">Next modifications branch. Check it out on GitHub!</string>
<string name="home_experimental_kernelsu">⚠️ Experimental Development Warning!</string>
<string name="home_experimental_kernelsu_repo">127.0.0.1</string>
<string name="home_experimental_kernelsu_body">Next is a non-official build which is always under active experimental development. It is provided as-is, with no guarantees of stability, performance, or reliability.</string>
<string name="home_experimental_kernelsu_body_point_1"> • Use at Your Own Risk: It may experience crashes, unexpected behavior, or cause system issues.</string>
<string name="home_experimental_kernelsu_body_point_2"> • No Warranty: The developers are not responsible for any data loss, system damage, or other consequences arising from its use.</string>
<string name="home_experimental_kernelsu_body_point_3"> • For Testing Purposes Only: It is intended for users who understand the risks and are comfortable troubleshooting issues.</string>
<string name="about_source_code"><![CDATA[View source code at %1$s]]></string>
<string name="profile" translatable="false">App Profile</string>
<string name="profile_default">Default</string>