manager: Clean code & bump AGP version

This commit is contained in:
ShirkNeko
2025-08-25 17:28:51 +08:00
parent 1af8a87876
commit 8c8f344161
56 changed files with 27 additions and 279 deletions

View File

@@ -24,7 +24,6 @@ import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.remember
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalSoftwareKeyboardController
import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.input.ImeAction
@@ -48,8 +47,6 @@ import com.sukisu.ultra.R
import com.sukisu.ultra.profile.Capabilities
import com.sukisu.ultra.profile.Groups
import com.sukisu.ultra.ui.component.rememberCustomDialog
import com.sukisu.ultra.ui.theme.CardConfig
import com.sukisu.ultra.ui.theme.CardConfig.cardAlpha
import com.sukisu.ultra.ui.util.isSepolicyValid
@OptIn(ExperimentalMaterial3Api::class)
@@ -501,5 +498,5 @@ private fun RootProfileConfigPreview() {
}
private fun isTextValidUid(text: String): Boolean {
return text.isNotEmpty() && text.isDigitsOnly() && text.toInt() >= 0 && text.toInt() <= Int.MAX_VALUE
return text.isNotEmpty() && text.isDigitsOnly() && text.toInt() >= 0
}

View File

@@ -84,7 +84,6 @@ import com.sukisu.ultra.ui.component.profile.AppProfileConfig
import com.sukisu.ultra.ui.component.profile.RootProfileConfig
import com.sukisu.ultra.ui.component.profile.TemplateConfig
import com.sukisu.ultra.ui.theme.CardConfig
import com.sukisu.ultra.ui.theme.CardConfig.cardAlpha
import com.sukisu.ultra.ui.theme.getCardColors
import com.sukisu.ultra.ui.theme.getCardElevation
import com.sukisu.ultra.ui.util.LocalSnackbarHost

View File

@@ -8,10 +8,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.verticalScroll
import androidx.compose.foundation.layout.WindowInsets
import androidx.compose.foundation.layout.WindowInsetsSides
import androidx.compose.foundation.layout.defaultMinSize
import androidx.compose.foundation.layout.safeDrawing
import androidx.compose.foundation.layout.only
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.filled.Close
import androidx.compose.material.icons.filled.Save

View File

@@ -338,7 +338,7 @@ private fun RebootDialog(
sealed class InstallMethod {
data class SelectFile(
val uri: Uri? = null,
@StringRes override val label: Int = R.string.select_file,
@param:StringRes override val label: Int = R.string.select_file,
override val summary: String?
) : InstallMethod()
@@ -355,7 +355,7 @@ sealed class InstallMethod {
data class HorizonKernel(
val uri: Uri? = null,
val slot: String? = null,
@StringRes override val label: Int = R.string.horizon_kernel,
@param:StringRes override val label: Int = R.string.horizon_kernel,
override val summary: String? = null
) : InstallMethod()
@@ -413,7 +413,7 @@ private fun SelectInstallMethod(
else -> null
}
option?.let {
option?.let { it ->
selectedOption = it
onSelected(it)
}
@@ -682,7 +682,7 @@ private fun SelectInstallMethod(
@Composable
fun rememberSelectKmiDialog(onSelected: (String?) -> Unit): DialogHandle {
return rememberCustomDialog { dismiss ->
val supportedKmi by produceState(initialValue = emptyList<String>()) {
val supportedKmi by produceState(initialValue = emptyList()) {
value = getSupportedKmis()
}
val options = supportedKmi.map { value ->

View File

@@ -221,7 +221,7 @@ fun ModuleScreen(navigator: DestinationsNavigator) {
}
// 所有模块签名验证通过,直接安装
if (verificationResults.all { it.value }) {
if (verificationResults.all { it -> it.value }) {
try {
navigator.navigate(FlashScreenDestination(FlashIt.FlashModules(selectedModules)))
viewModel.markNeedRefresh()

View File

@@ -33,7 +33,6 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Scaffold
import androidx.compose.material3.Text
import androidx.compose.material3.TopAppBar
import androidx.compose.material3.TopAppBarColors
import androidx.compose.material3.TopAppBarDefaults
import androidx.compose.material3.TopAppBarScrollBehavior
import androidx.compose.material3.pulltorefresh.PullToRefreshBox
@@ -94,9 +93,6 @@ fun AppProfileTemplateScreen(
}
}
val cardColorUse = MaterialTheme.colorScheme.surfaceVariant
val cardAlpha = CardConfig.cardAlpha
Scaffold(
topBar = {
val context = LocalContext.current
@@ -108,10 +104,6 @@ fun AppProfileTemplateScreen(
}
TopBar(
onBack = dropUnlessResumed { navigator.popBackStack() },
colors = TopAppBarDefaults.topAppBarColors(
containerColor = cardColorUse.copy(alpha = cardAlpha),
scrolledContainerColor = cardColorUse.copy(alpha = cardAlpha)
),
onSync = {
scope.launch { viewModel.fetchTemplates(true) }
},
@@ -209,7 +201,7 @@ private fun TemplateItem(
FlowRow {
LabelText(label = "UID: ${template.uid}")
LabelText(label = "GID: ${template.gid}")
LabelText(label = template.context,)
LabelText(label = template.context)
if (template.local) {
LabelText(label = "local")
} else {
@@ -228,7 +220,6 @@ private fun TopBar(
onSync: () -> Unit = {},
onImport: () -> Unit = {},
onExport: () -> Unit = {},
colors: TopAppBarColors,
scrollBehavior: TopAppBarScrollBehavior? = null
) {
val colorScheme = MaterialTheme.colorScheme

View File

@@ -64,9 +64,9 @@ fun LinkifyText(
}
private val urlPattern: Pattern = Pattern.compile(
"(?:^|[\\W])((ht|f)tp(s?):\\/\\/|www\\.)"
+ "(([\\w\\-]+\\.){1,}?([\\w\\-.~]+\\/?)*"
+ "[\\p{Alnum}.,%_=?&#\\-+()\\[\\]\\*$~@!:/{};']*)",
"(?:^|\\W)((ht|f)tp(s?)://|www\\.)"
+ "(([\\w\\-]+\\.)+([\\w\\-.~]+/?)*"
+ "[\\p{Alnum}.,%_=?&#\\-+()\\[\\]*$~@!:/{};']*)",
Pattern.CASE_INSENSITIVE or Pattern.MULTILINE or Pattern.DOTALL
)

View File

@@ -314,7 +314,6 @@ object ModuleModify {
): androidx.activity.result.ActivityResultLauncher<Intent> {
var showRestoreDialog by remember { mutableStateOf(false) }
var restoreConfirmResult by remember { mutableStateOf<CompletableDeferred<Boolean>?>(null) }
var pendingUri by remember { mutableStateOf<Uri?>(null) }
// 显示恢复确认对话框
RestoreConfirmationDialog(
@@ -334,7 +333,6 @@ object ModuleModify {
) { result ->
if (result.resultCode == android.app.Activity.RESULT_OK) {
result.data?.data?.let { uri ->
pendingUri = uri
scope.launch {
val confirmResult = CompletableDeferred<Boolean>()
restoreConfirmResult = confirmResult
@@ -377,7 +375,6 @@ object ModuleModify {
): androidx.activity.result.ActivityResultLauncher<Intent> {
var showAllowlistRestoreDialog by remember { mutableStateOf(false) }
var allowlistRestoreConfirmResult by remember { mutableStateOf<CompletableDeferred<Boolean>?>(null) }
var pendingUri by remember { mutableStateOf<Uri?>(null) }
// 显示允许列表恢复确认对话框
AllowlistRestoreConfirmationDialog(
@@ -397,7 +394,6 @@ object ModuleModify {
) { result ->
if (result.resultCode == android.app.Activity.RESULT_OK) {
result.data?.data?.let { uri ->
pendingUri = uri
scope.launch {
val confirmResult = CompletableDeferred<Boolean>()
allowlistRestoreConfirmResult = confirmResult

View File

@@ -49,7 +49,7 @@ suspend fun initPlatform() = withContext(Dispatchers.IO) {
delay(1000)
}
return@withContext active
return@withContext true
} catch (e: Exception) {
Log.e("KsuLibSu", "Failed to initialize platform", e)
return@withContext false

View File

@@ -76,15 +76,14 @@ public final class SuFilePathHandler implements WebViewAssetLoader.PathHandler {
* The application should typically use a dedicated subdirectory for the files it intends to
* expose and keep them separate from other files.
*
* @param context {@link Context} that is used to access app's internal storage.
* @param directory the absolute path of the exposed app internal storage directory from
* which files can be loaded.
* @throws IllegalArgumentException if the directory is not allowed.
*/
public SuFilePathHandler(@NonNull Context context, @NonNull File directory, Shell rootShell) {
public SuFilePathHandler(@NonNull File directory, Shell rootShell) {
try {
mDirectory = new File(getCanonicalDirPath(directory));
if (!isAllowedInternalStorageDir(context)) {
if (!isAllowedInternalStorageDir()) {
throw new IllegalArgumentException("The given directory \"" + directory
+ "\" doesn't exist under an allowed app internal storage directory");
}
@@ -96,7 +95,7 @@ public final class SuFilePathHandler implements WebViewAssetLoader.PathHandler {
}
}
private boolean isAllowedInternalStorageDir(@NonNull Context context) throws IOException {
private boolean isAllowedInternalStorageDir() throws IOException {
String dir = getCanonicalDirPath(mDirectory);
for (String forbiddenPath : FORBIDDEN_DATA_DIRS) {

View File

@@ -58,7 +58,7 @@ class WebUIActivity : ComponentActivity() {
.setDomain("mui.kernelsu.org")
.addPathHandler(
"/",
SuFilePathHandler(this, webRoot, rootShell)
SuFilePathHandler(webRoot, rootShell)
)
.build()