Add option to pause NFC while viewing a card

This commit is contained in:
il-Luca
2026-02-27 12:37:19 +01:00
parent 9121df192d
commit 0428a87c71
5 changed files with 35 additions and 0 deletions

View File

@@ -10,6 +10,7 @@ import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Color;
import android.graphics.drawable.Drawable;
import android.nfc.NfcAdapter;
import android.os.Build;
import android.os.Bundle;
import android.text.InputType;
@@ -677,6 +678,20 @@ public class LoyaltyCardViewActivity extends CatimaAppCompatActivity implements
window.setAttributes(attributes);
}
// Pause NFC to prevent interference with barcode scanners
if (settings.getDisableNfcWhileViewingCard()) {
NfcAdapter nfcAdapter = NfcAdapter.getDefaultAdapter(this);
if (nfcAdapter != null) {
nfcAdapter.enableReaderMode(this, tag -> {
// Intentionally empty: pause all NFC tag discoveries
}, NfcAdapter.FLAG_READER_NFC_A | NfcAdapter.FLAG_READER_NFC_B
| NfcAdapter.FLAG_READER_NFC_F | NfcAdapter.FLAG_READER_NFC_V
| NfcAdapter.FLAG_READER_NFC_BARCODE
| NfcAdapter.FLAG_READER_SKIP_NDEF_CHECK
| NfcAdapter.FLAG_READER_NO_PLATFORM_SOUNDS, null);
}
}
loyaltyCard = DBHelper.getLoyaltyCard(this, database, loyaltyCardId);
if (loyaltyCard == null) {
Log.w(TAG, "Could not lookup loyalty card " + loyaltyCardId);

View File

@@ -82,6 +82,10 @@ public class Settings {
return getBoolean(R.string.settings_key_disable_lockscreen_while_viewing_card, true);
}
public boolean getDisableNfcWhileViewingCard() {
return getBoolean(R.string.settings_key_disable_nfc_while_viewing_card, false);
}
public boolean getAllowContentProviderRead() {
return getBoolean(R.string.settings_key_allow_content_provider_read, true);
}