add setting to change app name and package name
This commit is contained in:
parent
6607c22aeb
commit
513e820e70
9 changed files with 97 additions and 27 deletions
|
|
@ -16,9 +16,13 @@
|
|||
<uses-permission
|
||||
android:name="android.permission.DELETE_PACKAGES"
|
||||
tools:ignore="ProtectedPermissions" />
|
||||
<uses-permission
|
||||
android:name="android.permission.QUERY_ALL_PACKAGES"
|
||||
tools:ignore="QueryAllPackagesPermission" />
|
||||
|
||||
<queries>
|
||||
<package android:name="com.aliucord" />
|
||||
<package android:name="com.discord" />
|
||||
</queries>
|
||||
|
||||
<application
|
||||
|
|
@ -48,4 +52,4 @@
|
|||
</intent-filter>
|
||||
</activity>
|
||||
</application>
|
||||
</manifest>
|
||||
</manifest>
|
||||
|
|
|
|||
|
|
@ -15,4 +15,6 @@ object Prefs {
|
|||
val debuggable = boolPreference("debuggable")
|
||||
val useDexFromStorage = boolPreference("use_dex_from_storage")
|
||||
val dexLocation = stringPreference("dex_location", "$aliucordDir/Injector.dex")
|
||||
val appName = stringPreference("app_name", "Aliucord")
|
||||
val packageName = stringPreference("package_name", "com.aliucord")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -8,11 +8,8 @@ package com.aliucord.manager.ui.components
|
|||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.lazy.LazyColumn
|
||||
import androidx.compose.foundation.lazy.items
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.OutlinedTextField
|
||||
import androidx.compose.material.TextFieldDefaults
|
||||
import androidx.compose.material.icons.Icons
|
||||
import androidx.compose.material.icons.filled.Delete
|
||||
import androidx.compose.material.icons.filled.Search
|
||||
|
|
@ -39,22 +36,13 @@ fun PluginsList() = Column(
|
|||
var search by remember { mutableStateOf("") }
|
||||
|
||||
if (plugins.isNotEmpty()) {
|
||||
OutlinedTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
TextField(
|
||||
value = search,
|
||||
onValueChange = { search = it },
|
||||
placeholder = { Text(stringResource(R.string.search)) },
|
||||
trailingIcon = { Icon(Icons.Default.Search, stringResource(R.string.search_plugins)) },
|
||||
keyboardOptions = KeyboardOptions(autoCorrect = false, imeAction = ImeAction.Search),
|
||||
keyboardActions = KeyboardActions { focusManager.clearFocus() },
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
colors = TextFieldDefaults.outlinedTextFieldColors(
|
||||
textColor = MaterialTheme.colorScheme.onSecondaryContainer,
|
||||
backgroundColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||
focusedBorderColor = MaterialTheme.colorScheme.outline,
|
||||
cursorColor = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
)
|
||||
|
||||
LazyColumn(
|
||||
|
|
|
|||
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* Copyright (c) 2022 Juby210 & zt
|
||||
* Licensed under the Open Software License version 3.0
|
||||
*/
|
||||
|
||||
package com.aliucord.manager.ui.components
|
||||
|
||||
import androidx.compose.foundation.layout.fillMaxWidth
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.*
|
||||
import androidx.compose.material3.MaterialTheme
|
||||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.ui.Modifier
|
||||
import androidx.compose.ui.unit.dp
|
||||
|
||||
@Composable
|
||||
fun TextField(
|
||||
value: String,
|
||||
onValueChange: (String) -> Unit,
|
||||
placeholder: @Composable (() -> Unit)? = null,
|
||||
label: @Composable (() -> Unit)? = null,
|
||||
trailingIcon: @Composable (() -> Unit)? = null,
|
||||
keyboardOptions: KeyboardOptions = KeyboardOptions(autoCorrect = false),
|
||||
keyboardActions: KeyboardActions = KeyboardActions.Default,
|
||||
) = OutlinedTextField(
|
||||
modifier = Modifier.fillMaxWidth(),
|
||||
singleLine = true,
|
||||
value = value,
|
||||
onValueChange = onValueChange,
|
||||
placeholder = placeholder,
|
||||
label = label,
|
||||
trailingIcon = trailingIcon,
|
||||
keyboardOptions = keyboardOptions,
|
||||
keyboardActions = keyboardActions,
|
||||
shape = RoundedCornerShape(16.dp),
|
||||
colors = TextFieldDefaults.outlinedTextFieldColors(
|
||||
textColor = MaterialTheme.colorScheme.onSecondaryContainer,
|
||||
backgroundColor = MaterialTheme.colorScheme.secondaryContainer,
|
||||
focusedBorderColor = MaterialTheme.colorScheme.outline,
|
||||
cursorColor = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
)
|
||||
|
|
@ -48,7 +48,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
|||
var supportedVersion by remember { mutableStateOf<String?>(null) }
|
||||
val installedVersion = remember {
|
||||
try {
|
||||
packageManager.getPackageInfo("com.aliucord", 0).versionName
|
||||
packageManager.getPackageInfo(Prefs.packageName.get(), 0).versionName
|
||||
} catch (th: Throwable) {
|
||||
"-"
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
|||
) {
|
||||
Column {
|
||||
Text(
|
||||
"Aliucord",
|
||||
"Aliucord${Prefs.packageName.get().let { if (it != "com.aliucord") " ($it)" else ""}}",
|
||||
style = MaterialTheme.typography.titleLarge,
|
||||
color = MaterialTheme.colorScheme.primary
|
||||
)
|
||||
|
|
@ -180,7 +180,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
|||
modifier = Modifier.weight(1f),
|
||||
colors = ButtonDefaults.buttonColors(containerColor = MaterialTheme.colorScheme.secondaryContainer),
|
||||
onClick = {
|
||||
val packageURI = Uri.parse("package:com.aliucord")
|
||||
val packageURI = Uri.parse("package:${Prefs.packageName.get()}")
|
||||
val uninstallIntent = Intent(Intent.ACTION_DELETE, packageURI)
|
||||
|
||||
context.startActivity(uninstallIntent)
|
||||
|
|
@ -197,7 +197,7 @@ fun HomeScreen(navigator: DestinationsNavigator) {
|
|||
Button(
|
||||
modifier = Modifier.weight(1f),
|
||||
onClick = {
|
||||
packageManager.getLaunchIntentForPackage("com.aliucord")?.let {
|
||||
packageManager.getLaunchIntentForPackage(Prefs.packageName.get())?.let {
|
||||
context.startActivity(it)
|
||||
} ?: Toast.makeText(context, "Failed to launch Aliucord", Toast.LENGTH_LONG)
|
||||
.show()
|
||||
|
|
|
|||
|
|
@ -10,7 +10,11 @@ import androidx.activity.compose.rememberLauncherForActivityResult
|
|||
import androidx.activity.result.contract.ActivityResultContracts
|
||||
import androidx.compose.foundation.clickable
|
||||
import androidx.compose.foundation.layout.*
|
||||
import androidx.compose.foundation.shape.RoundedCornerShape
|
||||
import androidx.compose.foundation.text.KeyboardActions
|
||||
import androidx.compose.foundation.text.KeyboardOptions
|
||||
import androidx.compose.material.ContentAlpha
|
||||
import androidx.compose.material.OutlinedTextField
|
||||
import androidx.compose.material3.*
|
||||
import androidx.compose.runtime.*
|
||||
import androidx.compose.ui.Modifier
|
||||
|
|
@ -22,6 +26,7 @@ import androidx.compose.ui.unit.dp
|
|||
import com.aliucord.manager.R
|
||||
import com.aliucord.manager.preferences.Prefs
|
||||
import com.aliucord.manager.ui.components.ListItem
|
||||
import com.aliucord.manager.ui.components.TextField
|
||||
import com.aliucord.manager.ui.components.settings.*
|
||||
import com.ramcosta.composedestinations.annotation.Destination
|
||||
|
||||
|
|
@ -56,6 +61,20 @@ fun SettingsScreen() = Column(
|
|||
preference = Prefs.replaceBg
|
||||
)
|
||||
|
||||
TextField(
|
||||
value = Prefs.appName.get(),
|
||||
onValueChange = { Prefs.appName.set(it) },
|
||||
placeholder = { Text(stringResource(R.string.app_name_setting)) },
|
||||
label = { Text(stringResource(R.string.app_name_setting)) },
|
||||
)
|
||||
|
||||
TextField(
|
||||
value = Prefs.packageName.get(),
|
||||
onValueChange = { Prefs.packageName.set(it) },
|
||||
placeholder = { Text(stringResource(R.string.package_name)) },
|
||||
label = { Text(stringResource(R.string.package_name)) },
|
||||
)
|
||||
|
||||
val devModeOn = Prefs.devMode.get()
|
||||
|
||||
PreferenceItem(
|
||||
|
|
|
|||
|
|
@ -22,3 +22,4 @@ val gson = Gson()
|
|||
const val MANAGE_EXTERNAL_STORAGE = "android.permission.MANAGE_EXTERNAL_STORAGE"
|
||||
const val ANDROID_NAMESPACE = "http://schemas.android.com/apk/res/android"
|
||||
const val REQUEST_LEGACY_STORAGE = "requestLegacyExternalStorage"
|
||||
const val DEBUGGABLE = "debugabble"
|
||||
|
|
|
|||
|
|
@ -3,15 +3,13 @@
|
|||
* Licensed under the Open Software License version 3.0
|
||||
*/
|
||||
|
||||
|
||||
package com.aliucord.manager.utils
|
||||
|
||||
import com.aliucord.manager.preferences.Prefs
|
||||
import pxb.android.axml.*
|
||||
|
||||
fun patchManifest(manifestBytes: ByteArray): ByteArray {
|
||||
val packageName = "com.aliucord"
|
||||
val debuggable = Prefs.debuggable.get()
|
||||
val packageName = Prefs.packageName.get()
|
||||
|
||||
val reader = AxmlReader(manifestBytes)
|
||||
val writer = AxmlWriter()
|
||||
|
|
@ -30,25 +28,37 @@ fun patchManifest(manifestBytes: ByteArray): ByteArray {
|
|||
return when (name) {
|
||||
"uses-sdk" -> ReplaceAttrsVisitor(nv, mapOf("targetSdkVersion" to 29))
|
||||
"permission" -> ReplaceAttrsVisitor(nv, mapOf("name" to "$packageName.permission.CONNECT"))
|
||||
"application" -> object :
|
||||
ReplaceAttrsVisitor(nv, mapOf(REQUEST_LEGACY_STORAGE to 1, "label" to "Aliucord", "debuggable" to debuggable)) {
|
||||
"application" -> object : ReplaceAttrsVisitor(
|
||||
nv,
|
||||
mapOf(REQUEST_LEGACY_STORAGE to 1, "label" to Prefs.appName.get(), DEBUGGABLE to Prefs.debuggable.get())
|
||||
) {
|
||||
private var addLegacyStorage = true
|
||||
private var addDebuggable = debuggable
|
||||
private var addDebuggable = Prefs.debuggable.get()
|
||||
|
||||
override fun attr(ns: String?, name: String, resourceId: Int, type: Int, value: Any?) {
|
||||
super.attr(ns, name, resourceId, type, value)
|
||||
if (name == REQUEST_LEGACY_STORAGE) addLegacyStorage = false
|
||||
else if (name == DEBUGGABLE) addDebuggable = false
|
||||
}
|
||||
|
||||
override fun child(ns: String?, name: String): NodeVisitor {
|
||||
val visitor = super.child(ns, name)
|
||||
return when (name) {
|
||||
"activity" -> ReplaceAttrsVisitor(visitor, mapOf("label" to "Aliucord"))
|
||||
"activity" -> ReplaceAttrsVisitor(visitor, mapOf("label" to Prefs.appName.get()))
|
||||
"service" -> object : NodeVisitor(visitor) {
|
||||
private var disableService = false
|
||||
|
||||
override fun attr(ns: String?, name: String, resourceId: Int, type: Int, value: Any?) {
|
||||
if (name == "name" && (
|
||||
value == "com.google.android.gms.analytics.AnalyticsService" ||
|
||||
value == "com.google.android.gms.analytics.AnalyticsJobService")
|
||||
) disableService = true
|
||||
super.attr(
|
||||
ns, name, resourceId, type,
|
||||
if (value is String && value.endsWith("CONNECT")) "$packageName.permission.CONNECT" else value
|
||||
if (value is String && value.endsWith("CONNECT"))
|
||||
"$packageName.permission.CONNECT"
|
||||
else if (disableService && name == "enabled") 0
|
||||
else value
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -79,7 +89,7 @@ fun patchManifest(manifestBytes: ByteArray): ByteArray {
|
|||
if (addLegacyStorage)
|
||||
super.attr(ANDROID_NAMESPACE, REQUEST_LEGACY_STORAGE, -1, TYPE_INT_BOOLEAN, 1)
|
||||
if (addDebuggable)
|
||||
super.attr(ANDROID_NAMESPACE, "debuggable", -1, TYPE_INT_BOOLEAN, 1)
|
||||
super.attr(ANDROID_NAMESPACE, DEBUGGABLE, -1, TYPE_INT_BOOLEAN, 1)
|
||||
super.end()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,4 +46,6 @@
|
|||
<string name="select_apk">Select APK</string>
|
||||
<string name="download_method">Download Method</string>
|
||||
<string name="changelog_media">Changelog Media</string>
|
||||
<string name="app_name_setting">App Name</string>
|
||||
<string name="package_name">Package Name</string>
|
||||
</resources>
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue