Add support card

This commit is contained in:
Nullptr 2022-03-06 23:07:14 +08:00
parent bf7c5ffadc
commit 041e58a038
4 changed files with 69 additions and 12 deletions

View File

@ -22,6 +22,7 @@ import androidx.compose.ui.unit.dp
import kotlinx.coroutines.launch
import org.lsposed.lspatch.BuildConfig
import org.lsposed.lspatch.R
import org.lsposed.lspatch.ui.util.HtmlText
@OptIn(ExperimentalMaterial3Api::class)
@Composable
@ -38,6 +39,8 @@ fun HomePage() {
.verticalScroll(rememberScrollState())
) {
InfoCard(snackbarHostState)
Spacer(Modifier.height(16.dp))
SupportCard()
}
}
}
@ -120,3 +123,34 @@ private fun InfoCard(snackbarHostState: SnackbarHostState) {
}
}
}
@OptIn(ExperimentalMaterial3Api::class)
@Preview
@Composable
private fun SupportCard() {
Card {
Column(
modifier = Modifier
.fillMaxWidth()
.padding(24.dp)
) {
Text(
text = stringResource(R.string.home_support),
fontWeight = FontWeight.SemiBold,
style = MaterialTheme.typography.titleMedium
)
Text(
modifier = Modifier.padding(vertical = 8.dp),
text = stringResource(R.string.home_description),
style = MaterialTheme.typography.bodyMedium
)
HtmlText(
stringResource(
R.string.home_view_source_code,
"<b><a href=\"https://github.com/LSPosed/LSPatch\">GitHub</a></b>",
"<b><a href=\"https://t.me/LSPosed\">Telegram</a></b>"
)
)
}
}
}

View File

@ -17,10 +17,7 @@ import androidx.compose.foundation.rememberScrollState
import androidx.compose.foundation.shape.RoundedCornerShape
import androidx.compose.foundation.verticalScroll
import androidx.compose.material.icons.Icons
import androidx.compose.material.icons.outlined.Api
import androidx.compose.material.icons.outlined.AutoFixHigh
import androidx.compose.material.icons.outlined.BugReport
import androidx.compose.material.icons.outlined.WorkOutline
import androidx.compose.material.icons.outlined.*
import androidx.compose.material3.*
import androidx.compose.runtime.*
import androidx.compose.runtime.saveable.rememberSaveable
@ -165,9 +162,9 @@ private fun ConfiguringFab(onClick: () -> Unit) {
@Composable
private fun sigBypassLvStr(level: Int) = when (level) {
0 -> stringResource(R.string.patch_sigbypasslv_0)
1 -> stringResource(R.string.patch_sigbypasslv_1)
2 -> stringResource(R.string.patch_sigbypasslv_2)
0 -> stringResource(R.string.patch_sigbypasslv0)
1 -> stringResource(R.string.patch_sigbypasslv1)
2 -> stringResource(R.string.patch_sigbypasslv2)
else -> throw IllegalArgumentException("Invalid sigBypassLv: $level")
}
@ -239,6 +236,7 @@ private fun PatchOptionsBody(
SettingsCheckBox(
checked = viewModel.overrideVersionCode,
onClick = { viewModel.overrideVersionCode = !viewModel.overrideVersionCode },
icon = Icons.Outlined.Layers,
title = stringResource(R.string.patch_override_version_code),
desc = stringResource(R.string.patch_override_version_code_desc)
)
@ -246,6 +244,7 @@ private fun PatchOptionsBody(
var expanded by remember { mutableStateOf(false) }
SettingsItem(
onClick = { expanded = true },
icon = Icons.Outlined.Edit,
title = stringResource(R.string.patch_sign),
desc = viewModel.sign.mapIndexedNotNull { index, on -> if (on) "V" + (index + 1) else null }.joinToString(" + ").ifEmpty { "None" }
)
@ -267,7 +266,8 @@ private fun PatchOptionsBody(
var expanded by remember { mutableStateOf(false) }
SettingsItem(
onClick = { expanded = true },
title = stringResource(R.string.patch_sigbypasslv),
icon = Icons.Outlined.RemoveModerator,
title = stringResource(R.string.patch_sigbypass),
desc = sigBypassLvStr(viewModel.sigBypassLevel)
)
DropdownMenu(expanded = expanded, onDismissRequest = { expanded = false }) {

View File

@ -0,0 +1,20 @@
package org.lsposed.lspatch.ui.util
import android.text.method.LinkMovementMethod
import android.widget.TextView
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.viewinterop.AndroidView
import androidx.core.text.HtmlCompat
@Composable
fun HtmlText(html: String, modifier: Modifier = Modifier) {
AndroidView(
modifier = modifier,
factory = { context -> TextView(context) },
update = {
it.movementMethod = LinkMovementMethod.getInstance()
it.text = HtmlCompat.fromHtml(html, HtmlCompat.FROM_HTML_MODE_COMPACT)
}
)
}

View File

@ -14,6 +14,9 @@
<string name="home_device">Device</string>
<string name="home_system_abi">System ABI</string>
<string name="home_info_copied">Copied to clipboard</string>
<string name="home_support">Support</string>
<string name="home_description">LSPatch is a free non-root Xposed framework based on LSPosed core.</string>
<string name="home_view_source_code"><![CDATA[View source code at %1$s<br/>Join our %2$s channel]]></string>
<!-- Manage Page -->
<string name="page_manage">Manage</string>
@ -30,10 +33,10 @@
<string name="patch_embed_modules">Embed modules</string>
<string name="patch_debuggable">Debuggable</string>
<string name="patch_sign">Sign</string>
<string name="patch_sigbypasslv">Signature bypass level</string>
<string name="patch_sigbypasslv_0">lv0: Off</string>
<string name="patch_sigbypasslv_1">lv1: Bypass PM</string>
<string name="patch_sigbypasslv_2">lv2: Bypass PM + openat (libc)</string>
<string name="patch_sigbypass">Signature bypass</string>
<string name="patch_sigbypasslv0">lv0: Off</string>
<string name="patch_sigbypasslv1">lv1: Bypass PM</string>
<string name="patch_sigbypasslv2">lv2: Bypass PM + openat (libc)</string>
<string name="patch_override_version_code">Override version code</string>
<string name="patch_override_version_code_desc">Override the patched app\'s version code to 1\nThis allows downgrade installation</string>
<string name="patch_start">Start Patch</string>