Skip to content

Commit 2039474

Browse files
committed
Replace count calls with none calls
(while processing checked options of QR scanner alert dialog)
1 parent 2104a06 commit 2039474

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

app/src/main/java/app/grapheneos/camera/CamConfig.kt

+9-4
Original file line numberDiff line numberDiff line change
@@ -1481,13 +1481,18 @@ class CamConfig(private val mActivity: MainActivity) {
14811481
// Add OK and Cancel buttons
14821482
builder.setPositiveButton(getString(R.string.ok)) { _, _ ->
14831483

1484-
val commonFormatsEnabled = commonFormats.count {
1484+
val allCommonFormatsDisabled = commonFormats.none {
14851485
allowedFormats.contains(it)
14861486
}
14871487

1488-
if (commonFormatsEnabled == 0) {
1489-
val otherFormatsEnabled = optionValues.count { it }
1490-
if (otherFormatsEnabled == 0) {
1488+
// If all formats displayed outside the dialog are disabled (main QR scanner
1489+
// UI)
1490+
if (allCommonFormatsDisabled) {
1491+
val noOptionWasChecked = optionValues.none { it }
1492+
1493+
// If no option is selected within the check box too (implying no barcode format
1494+
// is selected at all) - don't make apply the selction made by the user
1495+
if (noOptionWasChecked) {
14911496
mActivity.showMessage(
14921497
getString(R.string.no_barcode_selected)
14931498
)

0 commit comments

Comments
 (0)