Skip to content

Commit

Permalink
Handle the new Android tag expiration time
Browse files Browse the repository at this point in the history
  • Loading branch information
AbandonedCart committed Sep 7, 2024
1 parent 8da282d commit 922ced0
Showing 1 changed file with 16 additions and 3 deletions.
19 changes: 16 additions & 3 deletions app/src/main/java/com/hiddenramblings/tagmo/nfctech/NfcActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.content.IntentFilter
import android.nfc.NfcAdapter
import android.nfc.Tag
import android.nfc.TagLostException
import android.os.Build
import android.os.Bundle
import android.provider.Settings
import android.view.Menu
Expand Down Expand Up @@ -516,6 +517,9 @@ class NfcActivity : AppCompatActivity() {
Debug.warn(e)
Debug.getExceptionCause(e)?.let { error ->
when {
e is SecurityException -> {

}
getString(R.string.error_tag_rewrite) == error -> {
withContext(Dispatchers.Main) {
getErrorDialog(
Expand Down Expand Up @@ -807,13 +811,22 @@ class NfcActivity : AppCompatActivity() {
NFCIntent.ACTION_UNLOCK_UNIT,
-> startNfcMonitor()
}

if (Version.isTiramisu && (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action
|| NfcAdapter.ACTION_TECH_DISCOVERED == intent.action
|| NfcAdapter.ACTION_TAG_DISCOVERED == intent.action)) {
val tech = tagTech ?: getString(R.string.nfc_tag)
showMessage(R.string.tag_detected, tech)
CoroutineScope(Dispatchers.IO).launch { onTagDiscovered(intent) }
}
}

override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
if (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action
|| NfcAdapter.ACTION_TECH_DISCOVERED == intent.action
|| NfcAdapter.ACTION_TAG_DISCOVERED == intent.action) {
if (Version.isLowerThan(Build.VERSION_CODES.TIRAMISU)
&& (NfcAdapter.ACTION_NDEF_DISCOVERED == intent.action
|| NfcAdapter.ACTION_TECH_DISCOVERED == intent.action
|| NfcAdapter.ACTION_TAG_DISCOVERED == intent.action)) {
val tech = tagTech ?: getString(R.string.nfc_tag)
showMessage(R.string.tag_detected, tech)
CoroutineScope(Dispatchers.IO).launch { onTagDiscovered(intent) }
Expand Down

0 comments on commit 922ced0

Please sign in to comment.