Skip to content

Commit

Permalink
fix Get/Put global blocklist, improve menu (indent etc.)
Browse files Browse the repository at this point in the history
  • Loading branch information
hg42 committed Feb 6, 2024
1 parent 15cc3f1 commit 246e193
Showing 1 changed file with 47 additions and 47 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@ import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.text.KeyboardActions
import androidx.compose.foundation.text.KeyboardOptions
import androidx.compose.material3.Divider
import androidx.compose.material3.DropdownMenu
import androidx.compose.material3.DropdownMenuItem
import androidx.compose.material3.HorizontalDivider
import androidx.compose.material3.Icon
import androidx.compose.material3.IconButton
import androidx.compose.material3.ListItem
Expand Down Expand Up @@ -190,12 +190,12 @@ fun Selections(
else {
DropdownMenuItem(
enabled = false, onClick = {},
text = { Text("selections saved:") }
text = { Text("--- selections saved ---") }
)
files.forEach { file ->
file.name?.let { name ->
DropdownMenuItem(
text = { Text(name) },
text = { Text(" $name") },
onClick = {
when (action) {
"get" -> {
Expand Down Expand Up @@ -230,12 +230,12 @@ fun Selections(
else {
DropdownMenuItem(
enabled = false, onClick = {},
text = { Text("schedules include:") }
text = { Text("--- schedules include ---") }
)
schedules.forEach { schedule ->
schedule.name.let { name ->
DropdownMenuItem(
text = { Text(name) },
text = { Text(" $name") },
onClick = {
when (action) {
"get" -> {
Expand All @@ -258,12 +258,12 @@ fun Selections(
}
DropdownMenuItem(
enabled = false, onClick = {},
text = { Text("schedules exclude:") }
text = { Text("--- schedules exclude ---") }
)
schedules.forEach { schedule ->
schedule.name.let { name ->
DropdownMenuItem(
text = { Text(name) },
text = { Text(" $name") },
onClick = {
when (action) {
"get" -> {
Expand All @@ -284,29 +284,29 @@ fun Selections(
)
}
}
DropdownMenuItem(
enabled = false, onClick = {},
text = { Text("global:") }
)
DropdownMenuItem(
text = { Text("blocklist") },
onClick = {
when (action) {
"get" -> {
val newSelection =
OABX.main?.viewModel?.getBlocklist()
?: emptyList()
onAction(newSelection)
}
}
DropdownMenuItem(
enabled = false, onClick = {},
text = { Text("--- global ---") }
)
DropdownMenuItem(
text = { Text(" blocklist") },
onClick = {
when (action) {
"get" -> {
val newSelection =
OABX.main?.viewModel?.getBlocklist()
?: emptyList()
onAction(newSelection)
}

"put" -> {
OABX.main?.viewModel?.setBlocklist(selection.toSet())
onAction(selection)
}
"put" -> {
OABX.main?.viewModel?.setBlocklist(selection.toSet())
onAction(selection)
}
}
)
}
}
)
}
}

Expand Down Expand Up @@ -469,11 +469,11 @@ fun launchRestore(packages: List<Package>) {
)
}

fun launchToBlocklist(packages: List<Package>) {
launchEachPackage(packages, "blocklist <-", parallel = false) {
OABX.main?.viewModel?.addToBlocklist(it.packageName)
}
}
// fun launchToBlocklist(packages: List<Package>) {
// launchEachPackage(packages, "blocklist <-", parallel = false) {
// OABX.main?.viewModel?.addToBlocklist(it.packageName)
// }
// }

fun launchEnable(packages: List<Package>) {
launchEachPackage(packages, "enable", parallel = false) {
Expand Down Expand Up @@ -590,7 +590,7 @@ fun MainPackageContextMenu(
}
)

Divider() //----------------------------------------------------------------------------
HorizontalDivider() //----------------------------------------------------------------------------
}

DropdownMenuItem(
Expand Down Expand Up @@ -673,7 +673,7 @@ fun MainPackageContextMenu(

if (selection.count { it.value } > 0) {

Divider() //----------------------------------------------------------------------------
HorizontalDivider() //----------------------------------------------------------------------------

DropdownMenuItem(
enabled = false, onClick = {},
Expand All @@ -699,20 +699,20 @@ fun MainPackageContextMenu(
}
)

Divider() //----------------------------------------------------------------------------
// Divider() //----------------------------------------------------------------------------

DropdownMenuItem(
text = { Text("Add to Blocklist...") },
onClick = {
openSubMenu(subMenu) {
Confirmation(expanded) {
launchToBlocklist(selectedVisible)
}
}
}
)
// DropdownMenuItem(
// text = { Text("Add to Blocklist...") },
// onClick = {
// openSubMenu(subMenu) {
// Confirmation(expanded) {
// launchToBlocklist(selectedVisible)
// }
// }
// }
// )

Divider() //----------------------------------------------------------------------------
HorizontalDivider() //----------------------------------------------------------------------------

DropdownMenuItem(
text = { Text("Enable") },
Expand Down Expand Up @@ -744,7 +744,7 @@ fun MainPackageContextMenu(
}
)

Divider() //----------------------------------------------------------------------------
HorizontalDivider() //----------------------------------------------------------------------------

DropdownMenuItem(
text = { Text("Delete All Backups...") },
Expand Down

0 comments on commit 246e193

Please sign in to comment.