Skip to content

Commit

Permalink
Replace count calls with none calls
Browse files Browse the repository at this point in the history
(while processing checked options of QR scanner alert dialog)
  • Loading branch information
MHShetty authored and thestinger committed Nov 26, 2024
1 parent 1c4723d commit 2842077
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions app/src/main/java/app/grapheneos/camera/CamConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -1482,13 +1482,18 @@ class CamConfig(private val mActivity: MainActivity) {
// Add OK and Cancel buttons
builder.setPositiveButton(getString(R.string.ok)) { _, _ ->

val commonFormatsEnabled = commonFormats.count {
val allCommonFormatsDisabled = commonFormats.none {
allowedFormats.contains(it)
}

if (commonFormatsEnabled == 0) {
val otherFormatsEnabled = optionValues.count { it }
if (otherFormatsEnabled == 0) {
// If all formats displayed outside the dialog are disabled (main QR scanner
// UI)
if (allCommonFormatsDisabled) {
val noOptionWasChecked = optionValues.none { it }

// If no option is selected within the check box too (implying no barcode format
// is selected at all) - don't make apply the selction made by the user
if (noOptionWasChecked) {
mActivity.showMessage(
getString(R.string.no_barcode_selected)
)
Expand Down

0 comments on commit 2842077

Please sign in to comment.