Skip to content

Commit

Permalink
Show confirmation dialog when ignoring/enabling all apps
Browse files Browse the repository at this point in the history
  • Loading branch information
pilot51 committed May 31, 2024
1 parent 908f707 commit e76e404
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 9 deletions.
30 changes: 21 additions & 9 deletions app/src/main/java/com/pilot51/voicenotify/AppListScreen.kt
Original file line number Diff line number Diff line change
Expand Up @@ -88,30 +88,42 @@ fun AppListActions() {
keyboard?.show()
}
} else {
IconButton(onClick = {
showSearchBar = true
}) {
var showConfirmDialog by remember { mutableStateOf<IgnoreType?>(null) }
IconButton(
onClick = { showSearchBar = true }
) {
Icon(
imageVector = Icons.Filled.Search,
contentDescription = stringResource(R.string.filter)
)
}
IconButton(onClick = {
vm.massIgnore(IgnoreType.IGNORE_ALL)
}) {
IconButton(
onClick = { showConfirmDialog = IgnoreType.IGNORE_ALL }
) {
Icon(
imageVector = Icons.Filled.CheckBoxOutlineBlank,
contentDescription = stringResource(R.string.ignore_all)
)
}
IconButton(onClick = {
vm.massIgnore(IgnoreType.IGNORE_NONE)
}) {
IconButton(
onClick = { showConfirmDialog = IgnoreType.IGNORE_NONE }
) {
Icon(
imageVector = Icons.Filled.CheckBox,
contentDescription = stringResource(R.string.ignore_none)
)
}
showConfirmDialog?.let {
val isEnableAll = it == IgnoreType.IGNORE_NONE
ConfirmDialog(
text = stringResource(
R.string.ignore_enable_apps_confirm,
stringResource(if (isEnableAll) R.string.enable else R.string.ignore).lowercase()
),
onConfirm = { vm.massIgnore(it) },
onDismiss = { showConfirmDialog = null }
)
}
}
}

Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,8 @@
<string name="close">Close</string>
<string name="ignore_all">Ignore All</string>
<string name="ignore_none">Ignore None</string>
<string name="ignore_enable_apps_confirm">Are you sure you want to %s all apps?</string>
<string name="ignore">ignore</string>
<string name="filter">Filter</string>
<string name="remove_app_overrides">Remove all app overrides</string>
<string name="remove_app_overrides_confirm">Remove all overrides for %s?</string>
Expand Down

0 comments on commit e76e404

Please sign in to comment.