mirror of
https://github.com/CatimaLoyalty/Android.git
synced 2026-04-28 11:18:09 -04:00
Add option to pause NFC while viewing a card
This commit is contained in:
@@ -12,8 +12,12 @@
|
||||
<uses-sdk tools:overrideLibrary="com.google.zxing.client.android" />
|
||||
|
||||
<uses-permission android:name="android.permission.CAMERA" />
|
||||
<uses-permission android:name="android.permission.NFC" />
|
||||
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" android:maxSdkVersion="23" />
|
||||
|
||||
<uses-feature
|
||||
android:name="android.hardware.nfc"
|
||||
android:required="false" />
|
||||
<uses-feature
|
||||
android:name="android.hardware.camera"
|
||||
android:required="false" />
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -101,6 +101,9 @@
|
||||
<string name="settings_key_keep_screen_on" translatable="false">pref_keep_screen_on</string>
|
||||
<string name="settings_disable_lockscreen_while_viewing_card">Prevent screen lock</string>
|
||||
<string name="settings_disable_lockscreen_while_viewing_card_summary">Disables screen lock while viewing a card</string>
|
||||
<string name="settings_disable_nfc_while_viewing_card">Pause NFC</string>
|
||||
<string name="settings_disable_nfc_while_viewing_card_summary">Pauses NFC to prevent interference with scanners while viewing a card</string>
|
||||
<string name="settings_key_disable_nfc_while_viewing_card" translatable="false">pref_disable_nfc_while_viewing_card</string>
|
||||
<string name="settings_allow_content_provider_read_title">Allow other apps to access my data</string>
|
||||
<string name="settings_allow_content_provider_read_summary">Apps will still have to request permission to be granted access</string>
|
||||
<string name="settings_key_disable_lockscreen_while_viewing_card" translatable="false">pref_disable_lockscreen_while_viewing_card</string>
|
||||
|
||||
@@ -109,6 +109,15 @@
|
||||
android:title="@string/settings_disable_lockscreen_while_viewing_card"
|
||||
app:iconSpaceReserved="false"
|
||||
app:singleLineTitle="false" />
|
||||
|
||||
<SwitchPreferenceCompat
|
||||
android:widgetLayout="@layout/preference_material_switch"
|
||||
android:defaultValue="false"
|
||||
android:key="@string/settings_key_disable_nfc_while_viewing_card"
|
||||
android:summary="@string/settings_disable_nfc_while_viewing_card_summary"
|
||||
android:title="@string/settings_disable_nfc_while_viewing_card"
|
||||
app:iconSpaceReserved="false"
|
||||
app:singleLineTitle="false" />
|
||||
</PreferenceCategory>
|
||||
|
||||
<PreferenceCategory
|
||||
|
||||
Reference in New Issue
Block a user