Skip to content

Commit 2842077

Browse files
MHShettythestinger
authored andcommitted
Replace count calls with none calls
(while processing checked options of QR scanner alert dialog)
1 parent 1c4723d commit 2842077

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
@@ -1482,13 +1482,18 @@ class CamConfig(private val mActivity: MainActivity) {
14821482
// Add OK and Cancel buttons
14831483
builder.setPositiveButton(getString(R.string.ok)) { _, _ ->
14841484

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

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

0 commit comments

Comments
 (0)