Fix: Enable install activit

This commit is contained in:
NkBe 2025-08-18 13:24:12 +08:00
parent 88561bd2bd
commit b4d1726708
No known key found for this signature in database
GPG Key ID: 75EF144ED8F4D7B8
4 changed files with 38 additions and 42 deletions

View File

@ -30,8 +30,8 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.text.style.TextAlign import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.unit.dp import androidx.compose.ui.unit.dp
import com.ramcosta.composedestinations.annotation.Destination import com.ramcosta.composedestinations.annotation.Destination
import kotlinx.coroutines.launch
import org.lsposed.lspatch.R import org.lsposed.lspatch.R
import kotlinx.coroutines.launch
import org.lsposed.lspatch.config.Configs import org.lsposed.lspatch.config.Configs
import org.lsposed.lspatch.config.MyKeyStore import org.lsposed.lspatch.config.MyKeyStore
import org.lsposed.lspatch.lspApp import org.lsposed.lspatch.lspApp
@ -61,7 +61,7 @@ fun SettingsScreen() {
KeyStore() KeyStore()
DetailPatchLogs() DetailPatchLogs()
StorageDirectory() StorageDirectory()
SwitchInstallPackage() InstallActivity()
} }
} }
} }
@ -251,7 +251,6 @@ private fun DetailPatchLogs() {
icon = Icons.Outlined.BugReport, icon = Icons.Outlined.BugReport,
title = stringResource(R.string.settings_detail_patch_logs) title = stringResource(R.string.settings_detail_patch_logs)
) )
)
} }
@Composable @Composable
@ -273,42 +272,36 @@ private fun StorageDirectory() {
scope.launch { snackbarHost.showSnackbar(errorText) } scope.launch { snackbarHost.showSnackbar(errorText) }
} }
} }
AnywhereDropdown(
expanded = false,
onDismissRequest = { },
onClick = {
launcher.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE))
},
surface = {
SettingsItem( SettingsItem(
title = stringResource(R.string.settings_storage_directory), title = stringResource(R.string.settings_storage_directory),
desc = Configs.storageDirectory ?: "undefined", desc = Configs.storageDirectory ?: "undefined",
icon = Icons.Outlined.Folder icon = Icons.Outlined.Folder,
modifier = Modifier.clickable { launcher.launch(Intent(Intent.ACTION_OPEN_DOCUMENT_TREE)) }
) )
}) {}
} }
@Composable @Composable
private fun SwitchInstallPackage() { private fun InstallActivity() {
val context = LocalContext.current val pm = lspApp.packageManager
val packageName = context.packageName val componentName = ComponentName(lspApp, "org.lsposed.lspatch.ui.activity.InstallActivity")
val componentName = ComponentName(packageName, "$packageName.InstallPackageActivity") var enabled by remember {
val checked = remember { mutableStateOf(Configs.installPackage) } mutableStateOf(pm.getComponentEnabledSetting(componentName) == PackageManager.COMPONENT_ENABLED_STATE_ENABLED)
}
val titleText = stringResource(id = R.string.enable_install_activity_title)
SettingsSwitch( SettingsSwitch(
checked = enabled,
title = titleText,
modifier = Modifier.clickable { modifier = Modifier.clickable {
val isEnabled = !checked.value pm.setComponentEnabledSetting(
context.packageManager.setComponentEnabledSetting(
componentName, componentName,
if (isEnabled) PackageManager.COMPONENT_ENABLED_STATE_ENABLED else PackageManager.COMPONENT_ENABLED_STATE_DISABLED, if (enabled)
PackageManager.COMPONENT_ENABLED_STATE_DISABLED
else
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
PackageManager.DONT_KILL_APP PackageManager.DONT_KILL_APP
) )
Configs.installPackage = isEnabled enabled = !enabled
checked.value = isEnabled }
},
checked = checked.value,
icon = Icons.Outlined.Ballot,
title = stringResource(R.string.settings_switch_install_package),
desc = stringResource(if (checked.value) R.string.settings_switch_install_package_enabled else R.string.settings_switch_install_package_disabled)
) )
} }

View File

@ -87,6 +87,7 @@
<string name="settings_keystore_wrong_alias">别名错误</string> <string name="settings_keystore_wrong_alias">别名错误</string>
<string name="settings_keystore_wrong_alias_password">别名密码错误</string> <string name="settings_keystore_wrong_alias_password">别名密码错误</string>
<string name="settings_detail_patch_logs">详细修补日志</string> <string name="settings_detail_patch_logs">详细修补日志</string>
<string name="enable_install_activity_title">启用 install activity</string>
<string name="patch_inject_dex">注入加载器 Dex</string> <string name="patch_inject_dex">注入加载器 Dex</string>
<string name="patch_inject_dex_desc">对那些需要孤立服务进程的应用程序,譬如说浏览器的渲染引擎,请勾选此选项以确保他们正常运行</string> <string name="patch_inject_dex_desc">对那些需要孤立服务进程的应用程序,譬如说浏览器的渲染引擎,请勾选此选项以确保他们正常运行</string>
</resources> </resources>

View File

@ -87,6 +87,7 @@
<string name="settings_keystore_wrong_alias">別名錯誤</string> <string name="settings_keystore_wrong_alias">別名錯誤</string>
<string name="settings_keystore_wrong_alias_password">別名密碼錯誤</string> <string name="settings_keystore_wrong_alias_password">別名密碼錯誤</string>
<string name="settings_detail_patch_logs">詳細打包日誌</string> <string name="settings_detail_patch_logs">詳細打包日誌</string>
<string name="enable_install_activity_title">啓用 install activity</string>
<string name="patch_inject_dex">注入加載器 Dex</string> <string name="patch_inject_dex">注入加載器 Dex</string>
<string name="patch_inject_dex_desc">對那些需要孤立服務進程的應用程序,譬如說瀏覽器的渲染引擎,請勾選此選項以確保他們正常運行</string> <string name="patch_inject_dex_desc">對那些需要孤立服務進程的應用程序,譬如說瀏覽器的渲染引擎,請勾選此選項以確保他們正常運行</string>
</resources> </resources>

View File

@ -90,6 +90,7 @@
<string name="settings_keystore_wrong_password">Wrong keystore password</string> <string name="settings_keystore_wrong_password">Wrong keystore password</string>
<string name="settings_keystore_wrong_alias">Wrong alias name</string> <string name="settings_keystore_wrong_alias">Wrong alias name</string>
<string name="settings_keystore_wrong_alias_password">Wrong alias password</string> <string name="settings_keystore_wrong_alias_password">Wrong alias password</string>
<string name="enable_install_activity_title">Enable install activity</string>
<string name="settings_detail_patch_logs">Detail patch logs</string> <string name="settings_detail_patch_logs">Detail patch logs</string>
<string name="patch_inject_dex">Inject loader dex</string> <string name="patch_inject_dex">Inject loader dex</string>
<string name="patch_inject_dex_desc">For applications with isolated services, such as the render engines of browsers, please turn on this option to ensure that they work properly.</string> <string name="patch_inject_dex_desc">For applications with isolated services, such as the render engines of browsers, please turn on this option to ensure that they work properly.</string>