UI improvement

This commit is contained in:
BinTianqi
2024-04-02 17:15:56 +08:00
parent d44e5f59ae
commit 3fabd81511
10 changed files with 27 additions and 25 deletions

View File

@@ -144,16 +144,16 @@ private fun HomePage(navCtrl:NavHostController){
.padding(vertical = 16.dp), .padding(vertical = 16.dp),
verticalAlignment = Alignment.CenterVertically verticalAlignment = Alignment.CenterVertically
) { ) {
Spacer(modifier = Modifier.fillMaxWidth(0.06F)) Spacer(modifier = Modifier.padding(start = 22.dp))
Icon( Icon(
painter = painterResource(if(myDpm.isAdminActive(myComponent)){ R.drawable.check_circle_fill1 }else{ R.drawable.block_fill0 }), painter = painterResource(if(myDpm.isAdminActive(myComponent)){ R.drawable.check_circle_fill1 }else{ R.drawable.block_fill0 }),
contentDescription = null, contentDescription = null,
tint = colorScheme.onPrimary tint = colorScheme.onPrimary
) )
Spacer(modifier = Modifier.fillMaxWidth(0.05F)) Spacer(modifier = Modifier.padding(start = 10.dp))
Column { Column {
Text( Text(
text = if(myDpm.isAdminActive(myComponent)){"已激活"}else{"未激活"}, text = stringResource(if(myDpm.isAdminActive(myComponent)){R.string.activated}else{R.string.deactivated}),
style = typography.headlineSmall, style = typography.headlineSmall,
color = colorScheme.onPrimary, color = colorScheme.onPrimary,
modifier = Modifier.padding(bottom = 2.dp) modifier = Modifier.padding(bottom = 2.dp)

View File

@@ -18,6 +18,7 @@ import androidx.compose.runtime.getValue
import androidx.compose.ui.Alignment import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color import androidx.compose.ui.graphics.Color
import androidx.compose.ui.graphics.toArgb
import androidx.compose.ui.platform.LocalContext import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.res.painterResource import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource import androidx.compose.ui.res.stringResource
@@ -80,7 +81,7 @@ private fun Settings(){
R.string.dynamic_color, stringResource(R.string.dynamic_color_desc),null, R.string.dynamic_color, stringResource(R.string.dynamic_color_desc),null,
{sharedPref.getBoolean("dynamicColor",false)},{sharedPref.edit().putBoolean("dynamicColor",it).apply()} {sharedPref.getBoolean("dynamicColor",false)},{sharedPref.edit().putBoolean("dynamicColor",it).apply()}
) )
if(colorScheme.background!=Color(0xFF000000)){ if(colorScheme.background.toArgb()!=Color(0xFF000000).toArgb()){
SwitchItem( SwitchItem(
R.string.blackTheme, stringResource(R.string.blackTheme_desc),null, R.string.blackTheme, stringResource(R.string.blackTheme_desc),null,
{sharedPref.getBoolean("blackTheme",false)},{sharedPref.edit().putBoolean("blackTheme",it).apply()} {sharedPref.getBoolean("blackTheme",false)},{sharedPref.edit().putBoolean("blackTheme",it).apply()}

View File

@@ -69,7 +69,7 @@ fun Network(navCtrl: NavHostController){
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant) colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
)*/ )*/
TopBar(backStackEntry,navCtrl,localNavCtrl){ TopBar(backStackEntry,navCtrl,localNavCtrl){
if(backStackEntry?.destination?.route=="Home"){ if(backStackEntry?.destination?.route=="Home"&&scrollState.maxValue>80){
Text( Text(
text = stringResource(R.string.network), text = stringResource(R.string.network),
modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80) modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80)

View File

@@ -62,7 +62,7 @@ fun Password(navCtrl: NavHostController){
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant) colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
)*/ )*/
TopBar(backStackEntry,navCtrl,localNavCtrl){ TopBar(backStackEntry,navCtrl,localNavCtrl){
if(backStackEntry?.destination?.route=="Home"){ if(backStackEntry?.destination?.route=="Home"&&scrollState.maxValue>80){
Text( Text(
text = stringResource(R.string.password_and_keyguard), text = stringResource(R.string.password_and_keyguard),
modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80) modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80)

View File

@@ -14,11 +14,9 @@ import androidx.compose.foundation.layout.*
import androidx.compose.foundation.text.KeyboardActions import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.foundation.text.selection.SelectionContainer import androidx.compose.foundation.text.selection.SelectionContainer
import androidx.compose.material3.Button import androidx.compose.material3.*
import androidx.compose.material3.MaterialTheme.colorScheme
import androidx.compose.material3.MaterialTheme.typography import androidx.compose.material3.MaterialTheme.typography
import androidx.compose.material3.OutlinedTextField
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.runtime.* import androidx.compose.runtime.*
import androidx.compose.ui.Modifier import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.alpha import androidx.compose.ui.draw.alpha
@@ -68,7 +66,7 @@ fun DpmPermissions(navCtrl:NavHostController){
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant) colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
)*/ )*/
TopBar(backStackEntry,navCtrl,localNavCtrl){ TopBar(backStackEntry,navCtrl,localNavCtrl){
if(backStackEntry?.destination?.route=="Home"){ if(backStackEntry?.destination?.route=="Home"&&scrollState.maxValue>80){
Text( Text(
text = stringResource(R.string.permission), text = stringResource(R.string.permission),
modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80) modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80)
@@ -201,7 +199,7 @@ private fun DeviceAdmin(navCtrl: NavHostController){
myDpm.removeActiveAdmin(myComponent) myDpm.removeActiveAdmin(myComponent)
co.launch{ delay(600); if(!myDpm.isAdminActive(myComponent)){navCtrl.navigateUp()} } co.launch{ delay(600); if(!myDpm.isAdminActive(myComponent)){navCtrl.navigateUp()} }
}, },
modifier = Modifier.fillMaxWidth() colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError)
) { ) {
Text(stringResource(R.string.deactivate)) Text(stringResource(R.string.deactivate))
} }
@@ -232,7 +230,10 @@ private fun ProfileOwner(){
Text(stringResource(if(isProfileOwner(myDpm)){R.string.activated}else{R.string.deactivated}), style = typography.titleLarge) Text(stringResource(if(isProfileOwner(myDpm)){R.string.activated}else{R.string.deactivated}), style = typography.titleLarge)
Spacer(Modifier.padding(vertical = 5.dp)) Spacer(Modifier.padding(vertical = 5.dp))
if(isProfileOwner(myDpm)&&VERSION.SDK_INT>=24){ if(isProfileOwner(myDpm)&&VERSION.SDK_INT>=24){
Button(onClick = {myDpm.clearProfileOwner(myComponent)}, modifier = Modifier.fillMaxWidth()) { Button(
onClick = {myDpm.clearProfileOwner(myComponent)},
colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError)
) {
Text(stringResource(R.string.deactivate)) Text(stringResource(R.string.deactivate))
} }
} }
@@ -261,7 +262,7 @@ private fun DeviceOwner(navCtrl: NavHostController){
myDpm.clearDeviceOwnerApp(myContext.packageName) myDpm.clearDeviceOwnerApp(myContext.packageName)
co.launch{ delay(600); if(!isDeviceOwner(myDpm)){navCtrl.navigateUp()} } co.launch{ delay(600); if(!isDeviceOwner(myDpm)){navCtrl.navigateUp()} }
}, },
modifier = Modifier.fillMaxWidth() colors = ButtonDefaults.buttonColors(containerColor = colorScheme.error, contentColor = colorScheme.onError)
) { ) {
Text(text = stringResource(R.string.deactivate)) Text(text = stringResource(R.string.deactivate))
} }

View File

@@ -111,8 +111,8 @@ fun ShizukuActivate(){
scrollState.animateScrollTo(scrollState.maxValue, scrollAnim()) scrollState.animateScrollTo(scrollState.maxValue, scrollAnim())
outputTextScrollState.animateScrollTo(0, scrollAnim()) outputTextScrollState.animateScrollTo(0, scrollAnim())
} }
}, }
modifier = Modifier.fillMaxWidth()) { ) {
Text(text = stringResource(R.string.activate_device_admin)) Text(text = stringResource(R.string.activate_device_admin))
} }
} }
@@ -124,8 +124,8 @@ fun ShizukuActivate(){
scrollState.animateScrollTo(scrollState.maxValue, scrollAnim()) scrollState.animateScrollTo(scrollState.maxValue, scrollAnim())
outputTextScrollState.animateScrollTo(0, scrollAnim()) outputTextScrollState.animateScrollTo(0, scrollAnim())
} }
}, }
modifier = Modifier.fillMaxWidth()) { ) {
Text(text = stringResource(R.string.activate_profile_owner)) Text(text = stringResource(R.string.activate_profile_owner))
} }
@@ -136,8 +136,8 @@ fun ShizukuActivate(){
scrollState.animateScrollTo(scrollState.maxValue, scrollAnim()) scrollState.animateScrollTo(scrollState.maxValue, scrollAnim())
outputTextScrollState.animateScrollTo(0, scrollAnim()) outputTextScrollState.animateScrollTo(0, scrollAnim())
} }
}, }
modifier = Modifier.fillMaxWidth()) { ) {
Text(text = stringResource(R.string.activate_device_owner)) Text(text = stringResource(R.string.activate_device_owner))
} }

View File

@@ -76,7 +76,7 @@ fun SystemManage(navCtrl:NavHostController){
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant) colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
)*/ )*/
TopBar(backStackEntry,navCtrl,localNavCtrl){ TopBar(backStackEntry,navCtrl,localNavCtrl){
if(backStackEntry?.destination?.route=="Home"){ if(backStackEntry?.destination?.route=="Home"&&scrollState.maxValue>80){
Text( Text(
text = stringResource(R.string.device_ctrl), text = stringResource(R.string.device_ctrl),
modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80) modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80)

View File

@@ -67,7 +67,7 @@ fun UserManage(navCtrl:NavHostController) {
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant) colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
)*/ )*/
TopBar(backStackEntry,navCtrl,localNavCtrl){ TopBar(backStackEntry,navCtrl,localNavCtrl){
if(backStackEntry?.destination?.route=="Home"){ if(backStackEntry?.destination?.route=="Home"&&scrollState.maxValue>80){
Text( Text(
text = stringResource(R.string.user_manage), text = stringResource(R.string.user_manage),
modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80) modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80)

View File

@@ -68,7 +68,7 @@ fun UserRestriction(navCtrl: NavHostController){
colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant) colors = TopAppBarDefaults.topAppBarColors(containerColor = colorScheme.surfaceVariant)
)*/ )*/
TopBar(backStackEntry,navCtrl,localNavCtrl){ TopBar(backStackEntry,navCtrl,localNavCtrl){
if(backStackEntry?.destination?.route=="Home"){ if(backStackEntry?.destination?.route=="Home"&&scrollState.maxValue>80){
Text( Text(
text = stringResource(R.string.user_restrict), text = stringResource(R.string.user_restrict),
modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80) modifier = Modifier.alpha((maxOf(scrollState.value-30,0)).toFloat()/80)

View File

@@ -17,8 +17,8 @@ class Animations{
val animateListSize:FiniteAnimationSpec<IntSize> = spring(stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntSize.VisibilityThreshold) val animateListSize:FiniteAnimationSpec<IntSize> = spring(stiffness = Spring.StiffnessMediumLow, visibilityThreshold = IntSize.VisibilityThreshold)
private val screenWidth = displayMetrics.widthPixels private val screenWidth = displayMetrics.widthPixels
private val initialOffsetValue = screenWidth/8 private val initialOffsetValue = screenWidth/10
private val targetOffsetValue = screenWidth/8 private val targetOffsetValue = screenWidth/10
val navHostEnterTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition = { val navHostEnterTransition: AnimatedContentTransitionScope<NavBackStackEntry>.() -> EnterTransition = {
fadeIn(animationSpec = fade) + fadeIn(animationSpec = fade) +