diff --git a/app/src/main/java/me/bmax/apatch/APatchApp.kt b/app/src/main/java/me/bmax/apatch/APatchApp.kt index 8acbfecff..36a6288f2 100644 --- a/app/src/main/java/me/bmax/apatch/APatchApp.kt +++ b/app/src/main/java/me/bmax/apatch/APatchApp.kt @@ -54,6 +54,7 @@ class APApplication : Application() { // todo: should we store super_key in SharedPreferences private const val SUPER_KEY = "super_key" + private const val SHOW_BACKUP_WARN = "show_backup_warning" private lateinit var sharedPreferences: SharedPreferences private val _apStateLiveData = MutableLiveData(State.UNKNOWN_STATE) @@ -216,4 +217,12 @@ class APApplication : Application() { .build() ) } + + fun getBackupWarningState(): Boolean { + return sharedPreferences.getBoolean(SHOW_BACKUP_WARN, true) + } + + fun updateBackupWarningState(state: Boolean) { + sharedPreferences.edit().putBoolean(SHOW_BACKUP_WARN, state).apply() + } } \ No newline at end of file diff --git a/app/src/main/java/me/bmax/apatch/ui/screen/Home.kt b/app/src/main/java/me/bmax/apatch/ui/screen/Home.kt index 3d97afe95..a17b0187d 100644 --- a/app/src/main/java/me/bmax/apatch/ui/screen/Home.kt +++ b/app/src/main/java/me/bmax/apatch/ui/screen/Home.kt @@ -21,6 +21,7 @@ import androidx.compose.material.icons.filled.InstallMobile import androidx.compose.material.icons.filled.Key import androidx.compose.material.icons.filled.Refresh import androidx.compose.material.icons.filled.Settings +import androidx.compose.material.icons.filled.Warning import androidx.compose.material.icons.filled.Visibility import androidx.compose.material.icons.filled.VisibilityOff import androidx.compose.material.icons.outlined.Cached @@ -350,12 +351,12 @@ private fun KStatusCard(state: APApplication.State) { } Row(modifier = Modifier .fillMaxWidth() - .padding(6.dp), verticalAlignment = Alignment.CenterVertically) { + .padding(10.dp), verticalAlignment = Alignment.CenterVertically) { when { !state.equals(APApplication.State.UNKNOWN_STATE) -> { val kernelPatchVersion = Natives.kerenlPatchVersion() Column() { - Text(text = stringResource(R.string.working), + Text(text = stringResource(R.string.home_working), style = MaterialTheme.typography.titleMedium ) Spacer(Modifier.height(6.dp)) @@ -383,11 +384,10 @@ private fun KStatusCard(state: APApplication.State) { } } else -> { - Column(Modifier.padding(start = 12.dp)) { + Column(Modifier.padding(start = 6.dp)) { Text(text = stringResource(R.string.home_install_unknown), style = MaterialTheme.typography.titleMedium ) - Spacer(Modifier.height(8.dp)) } } } @@ -414,24 +414,24 @@ private fun AStatusCard(state: APApplication.State) { Row( modifier = Modifier .fillMaxWidth() - .padding(6.dp), verticalAlignment = Alignment.CenterVertically) { + .padding(10.dp), verticalAlignment = Alignment.CenterVertically) { Column(Modifier .weight(2f) ) { val managerVersion = getManagerVersion() when { state.equals(APApplication.State.KERNELPATCH_READY) -> { - Text(text = stringResource(R.string.not_install), + Text(text = stringResource(R.string.home_not_installed), style = MaterialTheme.typography.titleMedium ) } state.equals(APApplication.State.ANDROIDPATCH_INSTALLING) -> { - Text(text = stringResource(R.string.installing), + Text(text = stringResource(R.string.home_installing), style = MaterialTheme.typography.titleMedium ) } state.equals(APApplication.State.ANDROIDPATCH_INSTALLED) -> { - Text(text = stringResource(R.string.working), + Text(text = stringResource(R.string.home_working), style = MaterialTheme.typography.titleMedium ) Spacer(Modifier.height(6.dp)) @@ -441,7 +441,7 @@ private fun AStatusCard(state: APApplication.State) { ) } state.equals(APApplication.State.ANDROIDPATCH_NEED_UPDATE) -> { - Text(text = stringResource(R.string.need_update), + Text(text = stringResource(R.string.home_need_update), style = MaterialTheme.typography.titleMedium ) Spacer(Modifier.height(6.dp)) @@ -451,9 +451,11 @@ private fun AStatusCard(state: APApplication.State) { ) } else -> { - Text(text = stringResource(R.string.home_install_unknown), - style = MaterialTheme.typography.titleMedium - ) + Column(Modifier.padding(start = 6.dp)) { + Text(text = stringResource(R.string.home_install_unknown), + style = MaterialTheme.typography.titleMedium + ) + } } } Spacer(Modifier.height(6.dp)) @@ -461,7 +463,6 @@ private fun AStatusCard(state: APApplication.State) { if(!state.equals(APApplication.State.UNKNOWN_STATE)) { Column (modifier = Modifier .align(Alignment.CenterVertically) - .weight(1f) ) { Button( onClick = { @@ -506,35 +507,54 @@ private fun AStatusCard(state: APApplication.State) { @Composable fun WarningCard() { - var show by rememberSaveable { mutableStateOf(true) } + var show by rememberSaveable { mutableStateOf(apApp.getBackupWarningState()) } if(show) { ElevatedCard( colors = CardDefaults.elevatedCardColors(containerColor = run { - MaterialTheme.colorScheme.secondaryContainer + MaterialTheme.colorScheme.error }) ) { Row ( modifier = Modifier .fillMaxWidth() - .padding(16.dp) - .align(Alignment.CenterHorizontally), - horizontalArrangement = Arrangement.SpaceBetween - ){ - Text( - modifier = Modifier.weight(1f), - text = stringResource(id = R.string.patch_warnning), - style = MaterialTheme.typography.titleMedium.copy( - color = Color.Red, - fontWeight = FontWeight.Bold - ) - ) + .padding(12.dp) + ) { + Column ( + modifier = Modifier + .padding(12.dp), + verticalArrangement = Arrangement.Center, + horizontalAlignment = Alignment.CenterHorizontally + ) { + Icon(Icons.Filled.Warning, contentDescription = "warning") + } + Column ( + modifier = Modifier + .padding(12.dp), + horizontalAlignment = Alignment.CenterHorizontally + ) { + Row ( + modifier = Modifier + .fillMaxWidth() + .align(Alignment.CenterHorizontally), + horizontalArrangement = Arrangement.SpaceBetween + ){ + Text( + modifier = Modifier.weight(1f), + text = stringResource(id = R.string.patch_warnning), + ) - Spacer(Modifier.width(12.dp)) + Spacer(Modifier.width(12.dp)) - Icon(Icons.Outlined.Clear, - contentDescription = "", - modifier = Modifier.clickable { show = false }, - ) + Icon(Icons.Outlined.Clear, + contentDescription = "", + modifier = Modifier + .clickable { + show = false + apApp.updateBackupWarningState(false) + }, + ) + } + } } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 52d19d84b..e172741d8 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -15,16 +15,15 @@ Not installed Unknown Click to install - Working - Installing - Not install - Can update - version: %d.%d.%d - version: %s - version: %s -> %s + Working + Installing + Update available + Version: %d.%d.%d + Version: %s + Version: %s -> %s su: %s - su: %s->%s - kpatch: %s->%s + su: %s -> %s + kpatch: %s -> %s APatch: %s Superusers: %d Modules: %d diff --git a/build.gradle.kts b/build.gradle.kts index d80634c44..f4183278a 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -32,8 +32,7 @@ cmaker { } } - -project.ext.set("kernelPatchVersion", "0.7.2") +project.ext.set("kernelPatchVersion", "0.8.1") val androidMinSdkVersion = 26 val androidTargetSdkVersion = 33