[manager]: show status of kernel
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
import android.os.Build
|
||||
import android.system.Os
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Done
|
||||
import androidx.compose.material.icons.filled.Warning
|
||||
import androidx.compose.material3.Card
|
||||
import androidx.compose.material3.Snackbar
|
||||
import androidx.compose.material3.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
@@ -17,6 +18,8 @@ import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import me.weishu.kernelsu.Natives
|
||||
import me.weishu.kernelsu.R
|
||||
import me.weishu.kernelsu.getKernelVersion
|
||||
|
||||
@Composable
|
||||
fun Info(label: String, value: String) {
|
||||
@@ -37,15 +40,46 @@ fun Info(label: String, value: String) {
|
||||
@Composable
|
||||
fun Home() {
|
||||
|
||||
val statusIcon: Int
|
||||
val statusText: String
|
||||
val secondaryText: String
|
||||
|
||||
val kernelVersion = getKernelVersion()
|
||||
val isManager = Natives.becomeManager()
|
||||
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
if (kernelVersion.isGKI()) {
|
||||
// GKI kernel
|
||||
if (isManager) {
|
||||
statusIcon = R.drawable.ic_status_working
|
||||
statusText = "Working"
|
||||
secondaryText = "Version: ${Natives.getVersion()}"
|
||||
} else {
|
||||
statusIcon = R.drawable.ic_status_supported
|
||||
statusText = "Not installed"
|
||||
secondaryText = "Click to install"
|
||||
}
|
||||
} else {
|
||||
statusIcon = R.drawable.ic_status_unsupported
|
||||
statusText = "Unsupported kernel"
|
||||
secondaryText = "KernelSU only supports GKI kernels now"
|
||||
}
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(6.dp)
|
||||
.clickable { },
|
||||
.clickable {
|
||||
if (kernelVersion.isGKI() && !isManager) {
|
||||
Toast.makeText(
|
||||
context,
|
||||
"Unimplemented",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
},
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
@@ -53,7 +87,7 @@ fun Home() {
|
||||
.padding(10.dp)
|
||||
) {
|
||||
Image(
|
||||
if (isManager) Icons.Filled.Done else Icons.Filled.Warning,
|
||||
painter = painterResource(id = statusIcon),
|
||||
null,
|
||||
modifier = Modifier
|
||||
.size(64.dp)
|
||||
@@ -64,13 +98,13 @@ fun Home() {
|
||||
.padding(start = 10.dp),
|
||||
) {
|
||||
Text(
|
||||
text = if (isManager) "Installed" else "Not Installed",
|
||||
text = statusText,
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
|
||||
Text(
|
||||
text = if (isManager) "Version: ${Natives.getVersion()}" else "Click to Install",
|
||||
text = secondaryText,
|
||||
fontSize = 15.sp,
|
||||
fontWeight = FontWeight.Normal
|
||||
)
|
||||
@@ -104,7 +138,6 @@ fun Home() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user