diff options
| -rw-r--r-- | android/app/build.gradle | 4 | ||||
| -rw-r--r-- | android/app/src/main/AndroidManifest.xml | 18 | ||||
| -rw-r--r-- | android/app/src/main/java/io/coinos/app/IntentActivity.java | 35 | ||||
| -rw-r--r-- | android/app/src/main/java/io/coinos/app/LauncherActivity.java | 16 | ||||
| -rw-r--r-- | static/coinos.apk | bin | 427903 -> 428099 bytes |
5 files changed, 53 insertions, 20 deletions
diff --git a/android/app/build.gradle b/android/app/build.gradle index 2d9acbd..0378159 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -11,8 +11,8 @@ android { applicationId 'io.coinos.app' minSdk 24 targetSdk 35 - versionCode 1 - versionName '1.0' + versionCode 2 + versionName '1.1' } signingConfigs { release { diff --git a/android/app/src/main/AndroidManifest.xml b/android/app/src/main/AndroidManifest.xml index c6b7a01..4eb96a7 100644 --- a/android/app/src/main/AndroidManifest.xml +++ b/android/app/src/main/AndroidManifest.xml @@ -32,9 +32,18 @@ <category android:name="android.intent.category.BROWSABLE" /> <data android:scheme="https" android:host="v3.coinos.io" /> </intent-filter> - <!-- the payment + nostr schemes: the reason this wrapper exists. - lnurlw/lnurlp ride along — bolt cards and LNURL NFC tags emit - those schemes. --> + </activity> + <!-- Scheme + NFC intents land on this per-intent trampoline, not the + launcher: a TWA already on screen ignores a new intent to its + launcher, so a second lightning: tap used to do nothing. The + trampoline relaunches the TWA with the new URL and finishes. + lnurlw/lnurlp ride along — bolt cards and LNURL NFC tags emit + those schemes; NDEF dispatch needs no NFC permission. --> + <activity + android:name="io.coinos.app.IntentActivity" + android:exported="true" + android:noHistory="true" + android:theme="@android:style/Theme.Translucent.NoTitleBar"> <intent-filter> <action android:name="android.intent.action.VIEW" /> <category android:name="android.intent.category.DEFAULT" /> @@ -46,9 +55,6 @@ <data android:scheme="lnurlw" /> <data android:scheme="lnurlp" /> </intent-filter> - <!-- NFC: an NDEF tag carrying one of our URIs (a bolt card tap, an - address sticker) dispatches here directly — same forwarding path - as a VIEW intent, no NFC permission needed for NDEF dispatch. --> <intent-filter> <action android:name="android.nfc.action.NDEF_DISCOVERED" /> <category android:name="android.intent.category.DEFAULT" /> diff --git a/android/app/src/main/java/io/coinos/app/IntentActivity.java b/android/app/src/main/java/io/coinos/app/IntentActivity.java new file mode 100644 index 0000000..3de1d62 --- /dev/null +++ b/android/app/src/main/java/io/coinos/app/IntentActivity.java @@ -0,0 +1,35 @@ +package io.coinos.app; + +import android.content.Intent; +import android.net.Uri; +import android.os.Bundle; + +/** + * Trampoline for scheme + NFC intents. A TWA already on screen ignores a + * new intent delivered to its (still-alive) launcher, so a second + * lightning: tap used to do nothing. This activity exists per-intent: + * it maps the URI to the web app's ?u= form and relaunches LauncherActivity + * with CLEAR_TOP — the Chrome activity above it is cleared, the launcher is + * recreated with the new data, and the TWA navigates. Then it's gone. + */ +public class IntentActivity extends android.app.Activity { + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Uri url = Uri.parse("https://v3.coinos.io/"); + Uri data = getIntent().getData(); + if (data != null) { + String scheme = data.getScheme(); + if (scheme != null && !scheme.equals("https") && !scheme.equals("http")) { + url = Uri.parse("https://v3.coinos.io/?u=" + Uri.encode(data.toString())); + } else { + url = data; + } + } + Intent i = new Intent(this, LauncherActivity.class); + i.setData(url); + i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(i); + finish(); + } +} diff --git a/android/app/src/main/java/io/coinos/app/LauncherActivity.java b/android/app/src/main/java/io/coinos/app/LauncherActivity.java index d0b56bb..c3950ac 100644 --- a/android/app/src/main/java/io/coinos/app/LauncherActivity.java +++ b/android/app/src/main/java/io/coinos/app/LauncherActivity.java @@ -3,11 +3,9 @@ package io.coinos.app; import android.net.Uri; /** - * Forwards scheme intents into the web app. A lightning:/bitcoin:/nostr:/ - * lnurl: URI arrives as this activity's data; the web app receives it as - * https://v3.coinos.io/?u=<encoded original URI> and routes it (send form - * for payments, profile for nostr npubs). https links to the site pass - * through untouched, everything else opens the default URL. + * The TWA launcher. Scheme/NFC intents arrive via IntentActivity (the + * trampoline that survives the running-TWA case); this activity only needs + * to honor a full URL handed to it, falling back to the site root. */ public class LauncherActivity extends com.google.androidbrowserhelper.trusted.LauncherActivity { @@ -15,13 +13,7 @@ public class LauncherActivity @Override protected Uri getLaunchingUrl() { Uri data = getIntent().getData(); - if (data != null) { - String scheme = data.getScheme(); - if (scheme != null && !scheme.equals("https") && !scheme.equals("http")) { - return Uri.parse("https://v3.coinos.io/?u=" + Uri.encode(data.toString())); - } - if ("v3.coinos.io".equals(data.getHost())) return data; - } + if (data != null && "v3.coinos.io".equals(data.getHost())) return data; return super.getLaunchingUrl(); } } diff --git a/static/coinos.apk b/static/coinos.apk Binary files differindex 1126d53..e660ed8 100644 --- a/static/coinos.apk +++ b/static/coinos.apk |
