Init
This commit is contained in:
@@ -0,0 +1,73 @@
|
||||
package me.weishu.kernelsu
|
||||
|
||||
import androidx.compose.foundation.text.ClickableText
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalUriHandler
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.style.TextDecoration
|
||||
import androidx.compose.ui.unit.TextUnit
|
||||
|
||||
@Composable
|
||||
fun HyperlinkText(
|
||||
modifier: Modifier = Modifier,
|
||||
fullText: String,
|
||||
hyperLinks: Map<String, String>,
|
||||
textStyle: TextStyle = TextStyle.Default,
|
||||
linkTextColor: Color = Color.Blue,
|
||||
linkTextFontWeight: FontWeight = FontWeight.Normal,
|
||||
linkTextDecoration: TextDecoration = TextDecoration.None,
|
||||
fontSize: TextUnit = TextUnit.Unspecified
|
||||
) {
|
||||
val annotatedString = buildAnnotatedString {
|
||||
append(fullText)
|
||||
|
||||
for((key, value) in hyperLinks){
|
||||
|
||||
val startIndex = fullText.indexOf(key)
|
||||
val endIndex = startIndex + key.length
|
||||
addStyle(
|
||||
style = SpanStyle(
|
||||
color = linkTextColor,
|
||||
fontSize = fontSize,
|
||||
fontWeight = linkTextFontWeight,
|
||||
textDecoration = linkTextDecoration
|
||||
),
|
||||
start = startIndex,
|
||||
end = endIndex
|
||||
)
|
||||
addStringAnnotation(
|
||||
tag = "URL",
|
||||
annotation = value,
|
||||
start = startIndex,
|
||||
end = endIndex
|
||||
)
|
||||
}
|
||||
addStyle(
|
||||
style = SpanStyle(
|
||||
fontSize = fontSize
|
||||
),
|
||||
start = 0,
|
||||
end = fullText.length
|
||||
)
|
||||
}
|
||||
|
||||
val uriHandler = LocalUriHandler.current
|
||||
|
||||
ClickableText(
|
||||
modifier = modifier,
|
||||
text = annotatedString,
|
||||
style = textStyle,
|
||||
onClick = {
|
||||
annotatedString
|
||||
.getStringAnnotations("URL", it, it)
|
||||
.firstOrNull()?.let { stringAnnotation ->
|
||||
uriHandler.openUri(stringAnnotation.item)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
149
manager/app/src/main/java/me/weishu/kernelsu/MainActivity.kt
Normal file
149
manager/app/src/main/java/me/weishu/kernelsu/MainActivity.kt
Normal file
@@ -0,0 +1,149 @@
|
||||
package me.weishu.kernelsu
|
||||
|
||||
import AboutDialog
|
||||
import Home
|
||||
import Module
|
||||
import SuperUser
|
||||
import SuperUserData
|
||||
import android.os.Bundle
|
||||
import androidx.activity.ComponentActivity
|
||||
import androidx.activity.compose.setContent
|
||||
import androidx.annotation.StringRes
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.graphics.Color.Companion.Gray
|
||||
import androidx.compose.ui.graphics.vector.ImageVector
|
||||
import androidx.compose.ui.res.painterResource
|
||||
import androidx.compose.ui.res.stringResource
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import androidx.compose.ui.tooling.preview.Preview
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.navigation.NavDestination.Companion.hierarchy
|
||||
import androidx.navigation.NavGraph.Companion.findStartDestination
|
||||
import androidx.navigation.compose.NavHost
|
||||
import androidx.navigation.compose.composable
|
||||
import androidx.navigation.compose.currentBackStackEntryAsState
|
||||
import androidx.navigation.compose.rememberNavController
|
||||
import me.weishu.kernelsu.ui.theme.KernelSUTheme
|
||||
|
||||
class MainActivity : ComponentActivity() {
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
setContent {
|
||||
KernelSUTheme {
|
||||
// A surface container using the 'background' color from the theme
|
||||
Surface(
|
||||
modifier = Modifier.fillMaxSize(),
|
||||
color = MaterialTheme.colors.background
|
||||
) {
|
||||
Greeting()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Greeting() {
|
||||
|
||||
val items = listOf(
|
||||
Screen.Home,
|
||||
Screen.SuperUser,
|
||||
Screen.Module
|
||||
)
|
||||
|
||||
val navController = rememberNavController()
|
||||
|
||||
var showAboutDialog by remember { mutableStateOf(false) }
|
||||
|
||||
AboutDialog(openDialog = showAboutDialog, onDismiss = {
|
||||
showAboutDialog = false
|
||||
})
|
||||
|
||||
Scaffold(
|
||||
topBar = {
|
||||
TopAppBar(
|
||||
title = {
|
||||
Text(text = "KernelSU")
|
||||
},
|
||||
backgroundColor = MaterialTheme.colors.primary,
|
||||
contentColor = Color.White,
|
||||
elevation = 12.dp,
|
||||
actions = {
|
||||
IconButton(onClick = { /*TODO*/ }) {
|
||||
Icon(Icons.Filled.Search, contentDescription = "Search")
|
||||
}
|
||||
IconButton(onClick = {
|
||||
showAboutDialog = true
|
||||
}) {
|
||||
Icon(Icons.Filled.MoreVert, contentDescription = "More")
|
||||
}
|
||||
}
|
||||
)
|
||||
},
|
||||
bottomBar = {
|
||||
BottomNavigation(
|
||||
backgroundColor = MaterialTheme.colors.background,
|
||||
) {
|
||||
val navBackStackEntry by navController.currentBackStackEntryAsState()
|
||||
val currentDestination = navBackStackEntry?.destination
|
||||
items.forEach { screen ->
|
||||
BottomNavigationItem(
|
||||
icon = { Icon(painterResource(id = screen.icon), null) },
|
||||
label = { Text(stringResource(screen.resourceId)) },
|
||||
selected = currentDestination?.hierarchy?.any { it.route == screen.route } == true,
|
||||
selectedContentColor = MaterialTheme.colors.primary,
|
||||
unselectedContentColor = MaterialTheme.colors.onSurface.copy(alpha = ContentAlpha.medium),
|
||||
onClick = {
|
||||
navController.navigate(screen.route) {
|
||||
// Pop up to the start destination of the graph to
|
||||
// avoid building up a large stack of destinations
|
||||
// on the back stack as users select items
|
||||
popUpTo(navController.graph.findStartDestination().id) {
|
||||
saveState = true
|
||||
}
|
||||
// Avoid multiple copies of the same destination when
|
||||
// reselecting the same item
|
||||
launchSingleTop = true
|
||||
// Restore state when reselecting a previously selected item
|
||||
restoreState = true
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
) { innerPadding ->
|
||||
NavHost(
|
||||
navController,
|
||||
startDestination = Screen.Home.route,
|
||||
Modifier.padding(innerPadding)
|
||||
) {
|
||||
composable(Screen.Home.route) { Home() }
|
||||
composable(Screen.SuperUser.route) { SuperUser() }
|
||||
composable(Screen.Module.route) { Module() }
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Preview(showBackground = true)
|
||||
@Composable
|
||||
fun DefaultPreview() {
|
||||
KernelSUTheme {
|
||||
Greeting()
|
||||
}
|
||||
}
|
||||
|
||||
sealed class Screen(val route: String, @StringRes val resourceId: Int, val icon: Int) {
|
||||
object Home : Screen("home", R.string.home, R.drawable.ic_home)
|
||||
object SuperUser : Screen("superuser", R.string.superuser, R.drawable.ic_superuser)
|
||||
object Module: Screen("module", R.string.module, R.drawable.ic_module)
|
||||
}
|
||||
|
||||
24
manager/app/src/main/java/me/weishu/kernelsu/Natives.java
Normal file
24
manager/app/src/main/java/me/weishu/kernelsu/Natives.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package me.weishu.kernelsu;
|
||||
|
||||
/**
|
||||
* @author weishu
|
||||
* @date 2022/12/8.
|
||||
*/
|
||||
public final class Natives {
|
||||
|
||||
static {
|
||||
System.loadLibrary("kernelsu");
|
||||
}
|
||||
|
||||
// become root manager, return true if success.
|
||||
public static native boolean becomeManager();
|
||||
|
||||
public static native int getVersion();
|
||||
|
||||
// get the uid list of allowed su processes.
|
||||
public static native int[] getAllowList();
|
||||
|
||||
public static native int[] getDenyList();
|
||||
|
||||
public static native boolean allowRoot(int uid, boolean allow);
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.material.AlertDialog
|
||||
import androidx.compose.material.Button
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.style.TextAlign
|
||||
import me.weishu.kernelsu.HyperlinkText
|
||||
|
||||
@Composable
|
||||
fun AboutDialog(openDialog: Boolean, onDismiss: () -> Unit) {
|
||||
|
||||
if (openDialog) {
|
||||
AlertDialog(
|
||||
onDismissRequest = {
|
||||
onDismiss()
|
||||
},
|
||||
title = {
|
||||
Text(text = "About")
|
||||
},
|
||||
text = {
|
||||
Column {
|
||||
|
||||
HyperlinkText(
|
||||
fullText = "Author: weishu",
|
||||
hyperLinks = mutableMapOf(
|
||||
"weishu" to "https://github.com/tiann",
|
||||
),
|
||||
textStyle = TextStyle(
|
||||
textAlign = TextAlign.Center,
|
||||
color = Color.Gray
|
||||
),
|
||||
linkTextColor = MaterialTheme.colors.secondary,
|
||||
)
|
||||
|
||||
HyperlinkText(
|
||||
fullText = "Github: https://github.com/tiann/KernelSU",
|
||||
hyperLinks = mutableMapOf(
|
||||
"https://github.com/tiann/KernelSU" to "https://github.com/tiann/KernelSU",
|
||||
),
|
||||
textStyle = TextStyle(
|
||||
textAlign = TextAlign.Center,
|
||||
color = Color.Gray
|
||||
),
|
||||
linkTextColor = MaterialTheme.colors.secondary,
|
||||
)
|
||||
|
||||
HyperlinkText(
|
||||
fullText = "Telegram: https://t.me/KernelSU",
|
||||
hyperLinks = mutableMapOf(
|
||||
"https://t.me/KernelSU" to "https://t.me/KernelSU",
|
||||
),
|
||||
textStyle = TextStyle(
|
||||
textAlign = TextAlign.Center,
|
||||
color = Color.Gray
|
||||
),
|
||||
linkTextColor = MaterialTheme.colors.secondary,
|
||||
)
|
||||
|
||||
HyperlinkText(
|
||||
fullText = "QQ: https://pd.qq.com/s/8lipl1brp",
|
||||
hyperLinks = mutableMapOf(
|
||||
"https://pd.qq.com/s/8lipl1brp" to "https://pd.qq.com/s/8lipl1brp",
|
||||
),
|
||||
textStyle = TextStyle(
|
||||
textAlign = TextAlign.Center,
|
||||
color = Color.Gray
|
||||
),
|
||||
linkTextColor = MaterialTheme.colors.secondary,
|
||||
)
|
||||
|
||||
}
|
||||
},
|
||||
confirmButton = {
|
||||
Button(
|
||||
onClick = {
|
||||
onDismiss()
|
||||
}) {
|
||||
Text("OK")
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
}
|
||||
118
manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
Normal file
118
manager/app/src/main/java/me/weishu/kernelsu/ui/screen/Home.kt
Normal file
@@ -0,0 +1,118 @@
|
||||
import android.os.Build
|
||||
import android.system.Os
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Done
|
||||
import androidx.compose.material.icons.filled.Warning
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.platform.ClipboardManager
|
||||
import androidx.compose.ui.text.SpanStyle
|
||||
import androidx.compose.ui.text.buildAnnotatedString
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.text.withStyle
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import me.weishu.kernelsu.Natives
|
||||
import java.util.*
|
||||
|
||||
@Composable
|
||||
fun Info(label: String, value: String) {
|
||||
Text(
|
||||
buildAnnotatedString {
|
||||
append("$label: ")
|
||||
withStyle(
|
||||
style = SpanStyle(
|
||||
fontWeight = FontWeight.W900,
|
||||
color = MaterialTheme.colors.secondary
|
||||
)
|
||||
) {
|
||||
append(value)
|
||||
}
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun Home() {
|
||||
|
||||
val isManager = Natives.becomeManager()
|
||||
|
||||
Column(modifier = Modifier.fillMaxWidth()) {
|
||||
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(6.dp)
|
||||
.clickable { },
|
||||
elevation = 10.dp,
|
||||
backgroundColor = MaterialTheme.colors.secondary
|
||||
) {
|
||||
Row(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(10.dp)
|
||||
) {
|
||||
Image(
|
||||
if (isManager) Icons.Filled.Done else Icons.Filled.Warning,
|
||||
null,
|
||||
modifier = Modifier
|
||||
.size(64.dp)
|
||||
)
|
||||
Column(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(start = 10.dp),
|
||||
) {
|
||||
Text(
|
||||
text = if (isManager) "Installed" else "Not Installed",
|
||||
fontSize = 20.sp,
|
||||
fontWeight = FontWeight.Bold
|
||||
)
|
||||
|
||||
Text(
|
||||
text = if (isManager) "Version: ${Natives.getVersion()}" else "Click to Install",
|
||||
fontSize = 15.sp,
|
||||
fontWeight = FontWeight.Normal
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(6.dp)
|
||||
.clickable { },
|
||||
elevation = 10.dp
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(10.dp)
|
||||
) {
|
||||
|
||||
Os.uname().let { uname ->
|
||||
Info("Kernel", uname.release)
|
||||
Info("Arch", uname.machine)
|
||||
Info("Version", uname.version)
|
||||
}
|
||||
|
||||
Info("API Level", Build.VERSION.SDK_INT.toString())
|
||||
|
||||
Info("ABI", Build.SUPPORTED_ABIS.joinToString(", "))
|
||||
|
||||
Info("Fingerprint", Build.FINGERPRINT)
|
||||
|
||||
Info("Security Patch", Build.VERSION.SECURITY_PATCH)
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.Column
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.layout.padding
|
||||
import androidx.compose.material.Card
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun Module() {
|
||||
Card(
|
||||
modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.padding(6.dp)
|
||||
.clickable { },
|
||||
elevation = 10.dp
|
||||
) {
|
||||
Column(
|
||||
modifier = Modifier.padding(10.dp)
|
||||
) {
|
||||
|
||||
|
||||
Text("Coming Soon..")
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,174 @@
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.content.pm.ApplicationInfo
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.util.Log
|
||||
import android.widget.Toast
|
||||
import androidx.compose.foundation.Image
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.material.Checkbox
|
||||
import androidx.compose.material.Switch
|
||||
import androidx.compose.material.Text
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.graphics.Color
|
||||
import androidx.compose.ui.platform.LocalContext
|
||||
import androidx.compose.ui.unit.dp
|
||||
import androidx.compose.ui.unit.sp
|
||||
import com.google.accompanist.drawablepainter.rememberDrawablePainter
|
||||
import me.weishu.kernelsu.Natives
|
||||
import java.util.*
|
||||
|
||||
class SuperUserData(
|
||||
val name: CharSequence,
|
||||
val description: String,
|
||||
val icon: Drawable,
|
||||
val uid: Int,
|
||||
initialChecked: Boolean = false
|
||||
) {
|
||||
var checked: Boolean by mutableStateOf(initialChecked)
|
||||
}
|
||||
|
||||
@Composable
|
||||
fun SuperUserItem(
|
||||
superUserData: SuperUserData,
|
||||
checked: Boolean,
|
||||
onCheckedChange: (Boolean) -> Unit,
|
||||
onItemClick: () -> Unit
|
||||
) {
|
||||
Row(modifier = Modifier
|
||||
.fillMaxWidth()
|
||||
.clickable {
|
||||
onItemClick()
|
||||
}) {
|
||||
|
||||
Image(
|
||||
painter = rememberDrawablePainter(drawable = superUserData.icon),
|
||||
contentDescription = superUserData.name.toString(),
|
||||
modifier = Modifier
|
||||
.padding(4.dp)
|
||||
.width(48.dp)
|
||||
.height(48.dp)
|
||||
)
|
||||
|
||||
Column {
|
||||
Text(
|
||||
superUserData.name.toString(),
|
||||
modifier = Modifier.padding(4.dp),
|
||||
color = Color.Black,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
Text(
|
||||
superUserData.description,
|
||||
modifier = Modifier.padding(4.dp),
|
||||
color = Color.Gray,
|
||||
fontSize = 12.sp
|
||||
)
|
||||
}
|
||||
|
||||
Spacer(modifier = Modifier.weight(1f))
|
||||
|
||||
Switch(
|
||||
checked = checked,
|
||||
onCheckedChange = onCheckedChange,
|
||||
modifier = Modifier.padding(4.dp)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
private fun getAppList(context: Context): List<SuperUserData> {
|
||||
val pm = context.packageManager
|
||||
val allowList = Natives.getAllowList()
|
||||
val denyList = Natives.getDenyList();
|
||||
|
||||
Log.i("mylog", "allowList: ${Arrays.toString(allowList)}")
|
||||
Log.i("mylog", "denyList: ${Arrays.toString(denyList)}")
|
||||
|
||||
val result = mutableListOf<SuperUserData>()
|
||||
|
||||
// add allow list
|
||||
for (uid in allowList) {
|
||||
val packagesForUid = pm.getPackagesForUid(uid)
|
||||
if (packagesForUid == null || packagesForUid.isEmpty()) {
|
||||
continue
|
||||
}
|
||||
|
||||
packagesForUid.forEach { packageName ->
|
||||
val applicationInfo = pm.getApplicationInfo(packageName, 0)
|
||||
result.add(
|
||||
SuperUserData(
|
||||
name = applicationInfo.loadLabel(pm),
|
||||
description = applicationInfo.packageName,
|
||||
icon = applicationInfo.loadIcon(pm),
|
||||
uid = uid,
|
||||
initialChecked = true
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
// add deny list
|
||||
for (uid in denyList) {
|
||||
val packagesForUid = pm.getPackagesForUid(uid)
|
||||
if (packagesForUid == null || packagesForUid.isEmpty()) {
|
||||
continue
|
||||
}
|
||||
|
||||
packagesForUid.forEach { packageName ->
|
||||
val applicationInfo = pm.getApplicationInfo(packageName, 0)
|
||||
result.add(
|
||||
SuperUserData(
|
||||
name = applicationInfo.loadLabel(pm),
|
||||
description = applicationInfo.packageName,
|
||||
icon = applicationInfo.loadIcon(pm),
|
||||
uid = uid,
|
||||
initialChecked = false
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
@SuppressLint("QueryPermissionsNeeded")
|
||||
@Composable
|
||||
fun SuperUser() {
|
||||
|
||||
val context = LocalContext.current
|
||||
|
||||
val list = getAppList(context)
|
||||
val apps = remember { list.toMutableStateList() }
|
||||
|
||||
if (apps.isEmpty()) {
|
||||
Text("No apps found")
|
||||
return
|
||||
}
|
||||
|
||||
LazyColumn() {
|
||||
items(apps, key = { it.description }) { app ->
|
||||
SuperUserItem(
|
||||
superUserData = app,
|
||||
checked = app.checked,
|
||||
onCheckedChange = { checked ->
|
||||
val success = Natives.allowRoot(app.uid, checked)
|
||||
if (success) {
|
||||
app.checked = checked
|
||||
} else {
|
||||
Toast.makeText(
|
||||
context,
|
||||
"Failed to allow root: ${app.uid}",
|
||||
Toast.LENGTH_SHORT
|
||||
).show()
|
||||
}
|
||||
},
|
||||
onItemClick = {
|
||||
// TODO
|
||||
}
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package me.weishu.kernelsu.ui.theme
|
||||
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
val YELLOW = Color(0xFFeed502)
|
||||
val YELLOW_LIGHT = Color(0xFFffff52)
|
||||
val SECONDARY_LIGHT = Color(0xffa9817f)
|
||||
|
||||
val YELLOW_DARK = Color(0xFFb7a400)
|
||||
val SECONDARY_DARK = Color(0xFF4c2b2b)
|
||||
@@ -0,0 +1,11 @@
|
||||
package me.weishu.kernelsu.ui.theme
|
||||
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.material.Shapes
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
val Shapes = Shapes(
|
||||
small = RoundedCornerShape(4.dp),
|
||||
medium = RoundedCornerShape(4.dp),
|
||||
large = RoundedCornerShape(0.dp)
|
||||
)
|
||||
@@ -0,0 +1,36 @@
|
||||
package me.weishu.kernelsu.ui.theme
|
||||
|
||||
import androidx.compose.foundation.isSystemInDarkTheme
|
||||
import androidx.compose.material.MaterialTheme
|
||||
import androidx.compose.material.darkColors
|
||||
import androidx.compose.material.lightColors
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.graphics.Color
|
||||
|
||||
private val DarkColorPalette = darkColors(
|
||||
primary = YELLOW,
|
||||
primaryVariant = YELLOW_DARK,
|
||||
secondary = SECONDARY_DARK
|
||||
)
|
||||
|
||||
private val LightColorPalette = lightColors(
|
||||
primary = YELLOW,
|
||||
primaryVariant = YELLOW_LIGHT,
|
||||
secondary = SECONDARY_LIGHT
|
||||
)
|
||||
|
||||
@Composable
|
||||
fun KernelSUTheme(darkTheme: Boolean = isSystemInDarkTheme(), content: @Composable () -> Unit) {
|
||||
val colors = if (darkTheme) {
|
||||
DarkColorPalette
|
||||
} else {
|
||||
LightColorPalette
|
||||
}
|
||||
|
||||
MaterialTheme(
|
||||
colors = colors,
|
||||
typography = Typography,
|
||||
shapes = Shapes,
|
||||
content = content
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
package me.weishu.kernelsu.ui.theme
|
||||
|
||||
import androidx.compose.material.Typography
|
||||
import androidx.compose.ui.text.TextStyle
|
||||
import androidx.compose.ui.text.font.FontFamily
|
||||
import androidx.compose.ui.text.font.FontWeight
|
||||
import androidx.compose.ui.unit.sp
|
||||
|
||||
// Set of Material typography styles to start with
|
||||
val Typography = Typography(
|
||||
body1 = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 16.sp
|
||||
)
|
||||
/* Other default text styles to override
|
||||
button = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.W500,
|
||||
fontSize = 14.sp
|
||||
),
|
||||
caption = TextStyle(
|
||||
fontFamily = FontFamily.Default,
|
||||
fontWeight = FontWeight.Normal,
|
||||
fontSize = 12.sp
|
||||
)
|
||||
*/
|
||||
)
|
||||
Reference in New Issue
Block a user