diff options
Diffstat (limited to 'android/app')
| -rw-r--r-- | android/app/build.gradle | 4 | ||||
| -rw-r--r-- | android/app/src/twa/AndroidManifest.xml | 11 | ||||
| -rw-r--r-- | android/app/src/twa/java/io/coinos/app/LauncherActivity.java | 44 |
3 files changed, 49 insertions, 10 deletions
diff --git a/android/app/build.gradle b/android/app/build.gradle index 3556634..cab8b07 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -29,8 +29,8 @@ android { applicationId 'io.coinos.app' minSdk 24 targetSdk 35 - versionCode 12 - versionName '1.11' + versionCode 13 + versionName '1.12' } // Two builds of the same wallet. // diff --git a/android/app/src/twa/AndroidManifest.xml b/android/app/src/twa/AndroidManifest.xml index c430cdf..5e840ef 100644 --- a/android/app/src/twa/AndroidManifest.xml +++ b/android/app/src/twa/AndroidManifest.xml @@ -16,21 +16,16 @@ <meta-data android:name="android.support.customtabs.trusted.DEFAULT_URL" android:value="https://v3.coinos.io/" /> - <!-- System-bar colors: without these the TWA status bar defaults to + <!-- Status-bar colors: without these the TWA status bar defaults to white. Light follows the page background, dark the PWA's - theme_color, so the bar icons keep their contrast either way. --> + theme_color, so the bar icons keep their contrast either way. + The navigation bar is left to the browser (LauncherActivity). --> <meta-data android:name="android.support.customtabs.trusted.STATUS_BAR_COLOR" android:resource="@color/statusBarColor" /> <meta-data android:name="android.support.customtabs.trusted.STATUS_BAR_COLOR_DARK" android:resource="@color/statusBarColorDark" /> - <meta-data - android:name="android.support.customtabs.trusted.NAVIGATION_BAR_COLOR" - android:resource="@color/navigationBarColor" /> - <meta-data - android:name="android.support.customtabs.trusted.NAVIGATION_BAR_COLOR_DARK" - android:resource="@color/navigationBarColorDark" /> <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> diff --git a/android/app/src/twa/java/io/coinos/app/LauncherActivity.java b/android/app/src/twa/java/io/coinos/app/LauncherActivity.java index 654265b..bf960e2 100644 --- a/android/app/src/twa/java/io/coinos/app/LauncherActivity.java +++ b/android/app/src/twa/java/io/coinos/app/LauncherActivity.java @@ -1,10 +1,13 @@ package io.coinos.app; import android.Manifest; +import android.content.Intent; import android.content.pm.PackageManager; import android.net.Uri; import android.os.Build; import android.os.Bundle; +import android.os.Parcelable; +import android.util.SparseArray; import java.net.URLEncoder; @@ -36,6 +39,47 @@ public class LauncherActivity } } + // The navigation bar is left to the browser and the system. The helper + // library always names a colour for it (white when the manifest names + // none), and on Android 17 / Chrome 154 the Custom Tab window paints that + // bar white whatever colour it's given while the buttons follow the colour + // asked for — white buttons on white. So the colour is taken off the + // launch intent on its way to the browser, light and dark scheme alike. + private static final String NAV = "androidx.browser.customtabs.extra.NAVIGATION_BAR_COLOR"; + private static final String NAV_DIVIDER = "androidx.browser.customtabs.extra.NAVIGATION_BAR_DIVIDER_COLOR"; + private static final String SCHEMES = "androidx.browser.customtabs.extra.COLOR_SCHEME_PARAMS"; + + private static void dropNavColors(Intent intent) { + if (intent == null || !intent.hasExtra("android.support.customtabs.extra.SESSION")) return; + try { + intent.removeExtra(NAV); + intent.removeExtra(NAV_DIVIDER); + Bundle extras = intent.getExtras(); + SparseArray<Parcelable> schemes = extras == null ? null : extras.getSparseParcelableArray(SCHEMES); + if (schemes == null) return; + for (int i = 0; i < schemes.size(); i++) { + if (schemes.valueAt(i) instanceof Bundle) { + ((Bundle) schemes.valueAt(i)).remove(NAV); + ((Bundle) schemes.valueAt(i)).remove(NAV_DIVIDER); + } + } + extras.putSparseParcelableArray(SCHEMES, schemes); + intent.replaceExtras(extras); + } catch (Exception ignored) {} + } + + @Override + public void startActivity(Intent intent) { + dropNavColors(intent); + super.startActivity(intent); + } + + @Override + public void startActivity(Intent intent, Bundle options) { + dropNavColors(intent); + super.startActivity(intent, options); + } + @Override protected Uri getLaunchingUrl() { Uri data = getIntent().getData(); |
