Skip to content

Commit

Permalink
feat: hide launcher icon
Browse files Browse the repository at this point in the history
  • Loading branch information
Young-Lord committed Apr 21, 2024
1 parent a406e17 commit a97c727
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions app/src/main/java/moe/lyniko/hiderecent/ui/SettingsView.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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?
Expand All @@ -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)) },
)
}
}
}
}

0 comments on commit a97c727

Please sign in to comment.