diff --git a/app/src/main/java/moe/lyniko/hiderecent/ui/SettingsView.kt b/app/src/main/java/moe/lyniko/hiderecent/ui/SettingsView.kt index 2188ec1..d0b4fe7 100644 --- a/app/src/main/java/moe/lyniko/hiderecent/ui/SettingsView.kt +++ b/app/src/main/java/moe/lyniko/hiderecent/ui/SettingsView.kt @@ -66,7 +66,6 @@ fun SettingsView() { Preference( title = { Text(context.getString(R.string.export_config)) }, onClick = { - // clipboard val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clip = ClipData.newPlainText("config", PreferenceUtils.getInstance(context).packagesToString()) try { @@ -85,7 +84,6 @@ fun SettingsView() { Preference( title = { Text(context.getString(R.string.import_config)) }, onClick = { - // clipboard val clipboard = context.getSystemService(Context.CLIPBOARD_SERVICE) as ClipboardManager val clipboardData: CharSequence? @@ -112,6 +110,28 @@ fun SettingsView() { } ) } + item { + val appHomeComponent = ComponentName(BuildConfig.APPLICATION_ID, BuildConfig.APPLICATION_ID + ".LauncherActivity") + var switchMutableState by remember { + mutableStateOf( + context.packageManager?.getComponentEnabledSetting( + appHomeComponent + ) != PackageManager.COMPONENT_ENABLED_STATE_DISABLED + ) + } + SwitchPreference( + value = switchMutableState, + onValueChange = { + switchMutableState = it + context.packageManager?.setComponentEnabledSetting( + appHomeComponent, + if (it) PackageManager.COMPONENT_ENABLED_STATE_DISABLED else PackageManager.COMPONENT_ENABLED_STATE_ENABLED, + PackageManager.DONT_KILL_APP + ) + }, + title = { Text(context.getString(R.string.hide_icon_in_launcher)) }, + ) + } } } } \ No newline at end of file