feat: keep patched APKs setting

This commit is contained in:
rushii 2023-02-01 09:25:39 -08:00
parent afac9358ca
commit 2c560faae2
No known key found for this signature in database
GPG key ID: DCBE5952BB3B6420
4 changed files with 27 additions and 11 deletions

View file

@ -15,4 +15,5 @@ class PreferencesManager(preferences: SharedPreferences) : BasePreferenceManager
var packageName by stringPreference("package_name", "com.aliucord")
var version by stringPreference("version", "146108")
var hermesReplaceLibCpp by booleanPreference("hermes_replace_libcpp", false)
var keepPatchedApks by booleanPreference("keep_patched_apks", false)
}

View file

@ -64,6 +64,13 @@ fun SettingsScreen(
SettingsHeader(stringResource(R.string.settings_advanced))
SettingsTextField(
label = stringResource(R.string.setting_app_name),
pref = preferences.appName,
onPrefChange = viewModel::setAppName
)
Spacer(modifier = Modifier.height(4.dp))
SettingsSwitch(
label = stringResource(R.string.setting_replace_icon),
secondaryLabel = stringResource(R.string.setting_replace_icon_desc),
@ -73,14 +80,16 @@ fun SettingsScreen(
preferences.replaceIcon = it
}
Spacer(modifier = Modifier.height(8.dp))
SettingsTextField(
label = stringResource(R.string.setting_app_name),
pref = preferences.appName,
onPrefChange = viewModel::setAppName
SettingsSwitch(
label = stringResource(R.string.setting_keep_patched_apks),
secondaryLabel = stringResource(R.string.setting_keep_patched_apks_desc),
icon = { Icon(Icons.Default.DeleteForever, null) },
pref = preferences.keepPatchedApks,
onPrefChange = { preferences.keepPatchedApks = it },
)
Spacer(modifier = Modifier.height(14.dp))
SettingsSwitch(
label = stringResource(R.string.settings_developer_options),
pref = preferences.devMode,
@ -95,7 +104,7 @@ fun SettingsScreen(
exit = shrinkVertically()
) {
Column(
verticalArrangement = Arrangement.spacedBy(12.dp)
verticalArrangement = Arrangement.spacedBy(6.dp)
) {
SettingsTextField(
label = stringResource(R.string.setting_package_name),

View file

@ -436,9 +436,11 @@ class InstallViewModel(
step(InstallStep.INSTALL_APK) {
application.installApks(silent = !preferences.devMode, *apks)
}
patchedDir.deleteRecursively()
if (!preferences.keepPatchedApks) {
patchedDir.deleteRecursively()
}
}
}
private suspend fun installKotlin() {
@ -636,9 +638,11 @@ class InstallViewModel(
step(InstallStep.INSTALL_APK) {
application.installApks(silent = !preferences.devMode, baseApkFile)
}
patchedDir.deleteRecursively()
if (!preferences.keepPatchedApks) {
patchedDir.deleteRecursively()
}
}
}
@OptIn(ExperimentalTime::class)

View file

@ -54,6 +54,8 @@
<string name="setting_dynamic_color">Dynamic color</string>
<string name="setting_hermes_replace_libcpp">Replace libc++ (RN only)</string>
<string name="setting_hermes_replace_libcpp_desc">Downloads and uses libc++ from patched hermes</string>
<string name="setting_keep_patched_apks">Keep patched APKs</string>
<string name="setting_keep_patched_apks_desc">Don\'t delete patched APKs after installing (for installing manually)</string>
<string name="settings_invalid_package_name">Invalid package name, reset to com.aliucord</string>
<string name="theme_system">System</string>