Skip to content

Add option to pause NFC while viewing a card#3047

Open
il-Luca wants to merge 1 commit intoCatimaLoyalty:mainfrom
il-Luca:feature/pause-nfc-while-viewing-card
Open

Add option to pause NFC while viewing a card#3047
il-Luca wants to merge 1 commit intoCatimaLoyalty:mainfrom
il-Luca:feature/pause-nfc-while-viewing-card

Conversation

@il-Luca
Copy link
Contributor

@il-Luca il-Luca commented Mar 4, 2026

⚠️ This solution has been coded with the help of LLM and NOT tested on a real device. Exactly what is discouraged in https://github.com/CatimaLoyalty/Android/blob/main/CONTRIBUTING.md

❌ Therefore, the pull request can simply be declined without further discussion or put on hold until someone is capable of thoroughly testing it – no one will complain 🙂

😇 I couldn't resist experimenting with vibecoding to try fixing an issue that’s been bugging me, and that has been raised by others in the past (see #2158)

Problem

When displaying a loyalty card barcode, nearby NFC readers can interfere with barcode readers resulting in failed read – or accidental payments as described in #2158

Solution

Added an optional "Pause NFC" setting that temporarily suppresses NFC tag dispatch while viewing a card.
It uses NfcAdapter.enableReaderMode() with a no-op callback to intercept all NFC technologies (A, B, F, V, Barcode) without processing them. NFC behavior automatically restores when the card view is exited.
The code added to LoyaltyCardViewActivity.onResume() was "stolen" from https://stackoverflow.com/questions/78570610/disable-programmatically-nfc-while-my-app-is-open

Implementation

  • Added android.permission.NFC permission and feature declaration
  • Added "Pause NFC" toggle in Settings > Card view (default: off)
  • Modified LoyaltyCardViewActivity.onResume() to enable reader mode when setting is active

@TheLastProject
Copy link
Member

What's stopping you from testing it yourself? :)

@il-Luca
Copy link
Contributor Author

il-Luca commented Mar 5, 2026

@TheLastProject the fact that I have close to zero knowledge of software development and testing 😹
Given that, I wouldn't trust myself to test the app. But if "clueless beginner on one phone" is sufficient as a test, I can try. I just need a few weeks to learn the basics and find the time to do it

ihniwiad

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants