Optimize the interface, add hidden link card function, adjust scrolling behavior, clean up unnecessary code
This commit is contained in:
@@ -102,24 +102,11 @@ class MainActivity : ComponentActivity() {
|
||||
modifier = Modifier.padding(innerPadding),
|
||||
navGraph = NavGraphs.root as NavHostGraphSpec,
|
||||
navController = navController,
|
||||
defaultTransitions = remember {
|
||||
object : NavHostAnimatedDestinationStyle() {
|
||||
override val enterTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition = {
|
||||
fadeIn(animationSpec = tween(300)) +
|
||||
slideIntoContainer(
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.Up,
|
||||
animationSpec = tween(300)
|
||||
)
|
||||
}
|
||||
|
||||
override val exitTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition = {
|
||||
fadeOut(animationSpec = tween(300)) +
|
||||
slideOutOfContainer(
|
||||
towards = AnimatedContentTransitionScope.SlideDirection.Down,
|
||||
animationSpec = tween(300)
|
||||
)
|
||||
}
|
||||
}
|
||||
defaultTransitions = object : NavHostAnimatedDestinationStyle() {
|
||||
override val enterTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition
|
||||
get() = { fadeIn(animationSpec = tween(340)) }
|
||||
override val exitTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> ExitTransition
|
||||
get() = { fadeOut(animationSpec = tween(340)) }
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -372,8 +372,6 @@ private fun AppMenuBox(packageName: String, content: @Composable () -> Unit) {
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Preview
|
||||
|
||||
@@ -132,6 +132,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
||||
var isHideVersion by rememberSaveable { mutableStateOf(false) }
|
||||
var isHideOtherInfo by rememberSaveable { mutableStateOf(false) }
|
||||
var isHideSusfsStatus by rememberSaveable { mutableStateOf(false) }
|
||||
var isHideLinkCard by rememberSaveable { mutableStateOf(false) }
|
||||
|
||||
// 从 SharedPreferences 加载简洁模式状态
|
||||
LaunchedEffect(Unit) {
|
||||
@@ -146,10 +147,13 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
||||
|
||||
isHideSusfsStatus = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||
.getBoolean("is_hide_susfs_status", false)
|
||||
|
||||
isHideLinkCard = context.getSharedPreferences("settings", Context.MODE_PRIVATE)
|
||||
.getBoolean("is_hide_link_card", false)
|
||||
}
|
||||
|
||||
val kernelVersion = getKernelVersion()
|
||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
|
||||
val isManager = Natives.becomeManager(ksuApp.packageName)
|
||||
val deviceModel = getDeviceModel()
|
||||
@@ -279,16 +283,16 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
||||
InfoCard()
|
||||
|
||||
if (!isSimpleMode) {
|
||||
ContributionCard()
|
||||
DonateCard()
|
||||
LearnMoreCard()
|
||||
if (!isHideLinkCard) {
|
||||
ContributionCard()
|
||||
DonateCard()
|
||||
LearnMoreCard()
|
||||
}
|
||||
}
|
||||
|
||||
Spacer(Modifier.height(16.dp))
|
||||
}
|
||||
}
|
||||
|
||||
// 防抖逻辑
|
||||
LaunchedEffect(scrollState) {
|
||||
snapshotFlow { scrollState.isScrollInProgress }
|
||||
.debounce(debounceTime)
|
||||
@@ -297,7 +301,6 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
||||
val currentTime = System.currentTimeMillis()
|
||||
if (currentTime - lastScrollTime > debounceTime) {
|
||||
lastScrollTime = currentTime
|
||||
// 在这里可以添加滚动时的逻辑
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -387,7 +390,7 @@ private fun TopBar(
|
||||
},
|
||||
colors = TopAppBarDefaults.topAppBarColors(
|
||||
containerColor = cardColor.copy(alpha = cardAlpha),
|
||||
scrolledContainerColor = cardColor.copy(alpha = 1f)
|
||||
scrolledContainerColor = cardColor.copy(alpha = cardAlpha)
|
||||
),
|
||||
actions = {
|
||||
if (kernelVersion.isGKI()) {
|
||||
|
||||
@@ -66,7 +66,7 @@ fun KpmScreen(
|
||||
module.id to stringResource(R.string.confirm_uninstall_content, moduleFileName)
|
||||
}
|
||||
|
||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
|
||||
val kpmInstallSuccess = stringResource(R.string.kpm_install_success)
|
||||
val kpmInstallFailed = stringResource(R.string.kpm_install_failed)
|
||||
|
||||
@@ -211,7 +211,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
|
||||
|
||||
val hideInstallButton = isSafeMode || hasMagisk
|
||||
|
||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
|
||||
val webUILauncher = rememberLauncherForActivityResult(
|
||||
contract = ActivityResultContracts.StartActivityForResult()
|
||||
|
||||
@@ -186,6 +186,16 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
||||
isHideSusfsStatus = newValue
|
||||
}
|
||||
|
||||
// 隐藏链接状态开关状态
|
||||
var isHideLinkCard by remember {
|
||||
mutableStateOf(prefs.getBoolean("is_hide_link_card", false))
|
||||
}
|
||||
|
||||
val onHideLinkCardChange = { newValue: Boolean ->
|
||||
prefs.edit { putBoolean("is_hide_link_card", newValue) }
|
||||
isHideLinkCard = newValue
|
||||
}
|
||||
|
||||
// SELinux状态
|
||||
var selinuxEnabled by remember {
|
||||
mutableStateOf(Shell.cmd("getenforce").exec().out.firstOrNull() == "Enforcing")
|
||||
@@ -618,6 +628,21 @@ fun MoreSettingsScreen(navigator: DestinationsNavigator) {
|
||||
) {
|
||||
onHideSusfsStatusChange(it)
|
||||
}
|
||||
|
||||
HorizontalDivider(
|
||||
modifier = Modifier.padding(horizontal = 16.dp),
|
||||
color = MaterialTheme.colorScheme.outlineVariant
|
||||
)
|
||||
|
||||
// 隐藏链接信息
|
||||
SwitchItem(
|
||||
icon = Icons.Filled.VisibilityOff,
|
||||
title = stringResource(R.string.hide_link_card),
|
||||
summary = stringResource(R.string.hide_link_card_summary),
|
||||
checked = isHideLinkCard
|
||||
) {
|
||||
onHideLinkCardChange(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import android.net.Uri
|
||||
import android.widget.Toast
|
||||
import androidx.activity.compose.rememberLauncherForActivityResult
|
||||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.animation.*
|
||||
import androidx.compose.animation.core.*
|
||||
import androidx.compose.foundation.background
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
@@ -64,7 +62,7 @@ import java.time.format.DateTimeFormatter
|
||||
@Destination<RootGraph>
|
||||
@Composable
|
||||
fun SettingScreen(navigator: DestinationsNavigator) {
|
||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
val snackBarHost = LocalSnackbarHost.current
|
||||
val ksuIsValid = Natives.isKsuValid(ksuApp.packageName)
|
||||
|
||||
|
||||
@@ -49,7 +49,7 @@ import com.sukisu.ultra.ui.viewmodel.SuperUserViewModel
|
||||
fun SuperUserScreen(navigator: DestinationsNavigator) {
|
||||
val viewModel = viewModel<SuperUserViewModel>()
|
||||
val scope = rememberCoroutineScope()
|
||||
val scrollBehavior = TopAppBarDefaults.enterAlwaysScrollBehavior(rememberTopAppBarState())
|
||||
val scrollBehavior = TopAppBarDefaults.pinnedScrollBehavior(rememberTopAppBarState())
|
||||
val listState = rememberLazyListState()
|
||||
val context = LocalContext.current
|
||||
val snackBarHostState = remember { SnackbarHostState() }
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
<string name="hide_other_info_summary">ホームページ上のスーパーユーザー、モジュール、KPM モジュールの数に関する情報を非表示にします</string>
|
||||
<string name="hide_susfs_status">SuSFS ステータスを非表示にする</string>
|
||||
<string name="hide_susfs_status_summary">ホームページ上の SuSFS ステータス情報を非表示にします</string>
|
||||
<string name="hide_link_card">リンクカードのステータスを隠す</string>
|
||||
<string name="hide_link_card_summary">ホームページのリンクカード情報を隠す</string>
|
||||
<string name="theme_mode">テーマ</string>
|
||||
<string name="theme_follow_system">システムに従う</string>
|
||||
<string name="theme_light">ライト</string>
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
<string name="hide_other_info_summary">隐藏主页上的超级用户数、模块数和 KPM 模块数信息</string>
|
||||
<string name="hide_susfs_status">隐藏 SuSFS 状态信息</string>
|
||||
<string name="hide_susfs_status_summary">隐藏主页上的 SuSFS 状态信息</string>
|
||||
<string name="hide_link_card">隐藏链接卡片</string>
|
||||
<string name="hide_link_card_summary">隐藏主页上的链接卡片信息</string>
|
||||
<string name="theme_mode">主题模式</string>
|
||||
<string name="theme_follow_system">跟随系统</string>
|
||||
<string name="theme_light">浅色</string>
|
||||
|
||||
@@ -194,6 +194,8 @@
|
||||
<string name="hide_other_info_summary">Hides information about the number of super users, modules and KPM modules on the home page</string>
|
||||
<string name="hide_susfs_status">Hide SuSFS status</string>
|
||||
<string name="hide_susfs_status_summary">Hide SuSFS status information on the home page</string>
|
||||
<string name="hide_link_card">Hide Link Card Status</string>
|
||||
<string name="hide_link_card_summary">Hide link card information on the home page</string>
|
||||
<string name="theme_mode">Theme</string>
|
||||
<string name="theme_follow_system">Follow system</string>
|
||||
<string name="theme_light">Light</string>
|
||||
|
||||
Reference in New Issue
Block a user