Skip to content

Commit

Permalink
kp: 0.8.1, improved a lot: 1. fix bti bug 2: some renamed symbol cant…
Browse files Browse the repository at this point in the history
… find bug. 3: merge dev ui imporved
  • Loading branch information
bmax committed Jan 3, 2024
2 parents aa80a2b + 582a2af commit 27260d2
Show file tree
Hide file tree
Showing 4 changed files with 70 additions and 43 deletions.
9 changes: 9 additions & 0 deletions app/src/main/java/me/bmax/apatch/APatchApp.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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>(State.UNKNOWN_STATE)
Expand Down Expand Up @@ -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()
}
}
84 changes: 52 additions & 32 deletions app/src/main/java/me/bmax/apatch/ui/screen/Home.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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))
}
}
}
Expand All @@ -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))
Expand All @@ -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))
Expand All @@ -451,17 +451,18 @@ 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))
}
if(!state.equals(APApplication.State.UNKNOWN_STATE)) {
Column (modifier = Modifier
.align(Alignment.CenterVertically)
.weight(1f)
) {
Button(
onClick = {
Expand Down Expand Up @@ -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)
},
)
}
}
}
}
}
Expand Down
17 changes: 8 additions & 9 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,15 @@
<string name="home_not_installed">Not installed</string>
<string name="home_install_unknown">Unknown</string>
<string name="home_click_to_install">Click to install</string>
<string name="working">Working</string>
<string name="installing">Installing</string>
<string name="not_install">Not install</string>
<string name="need_update">Can update</string>
<string name="kpatch_version">version: %d.%d.%d</string>
<string name="apatch_version">version: %s</string>
<string name="apatch_version_update">version: %s -> %s</string>
<string name="home_working">Working</string>
<string name="home_installing">Installing</string>
<string name="home_need_update">Update available</string>
<string name="kpatch_version">Version: %d.%d.%d</string>
<string name="apatch_version">Version: %s</string>
<string name="apatch_version_update">Version: %s -> %s</string>
<string name="home_su_path">su: %s</string>
<string name="home_su_path_ex">su: %s->%s</string>
<string name="kpatch_shadow_path">kpatch: %s->%s</string>
<string name="home_su_path_ex">su: %s -> %s</string>
<string name="kpatch_shadow_path">kpatch: %s -> %s</string>
<string name="home_apatch_version">APatch: %s</string>
<string name="home_superuser_count">Superusers: %d</string>
<string name="home_module_count">Modules: %d</string>
Expand Down
3 changes: 1 addition & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 27260d2

Please sign in to comment.