mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-05-14 11:36:21 -04:00
Add option to pause NFC while viewing a card
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user