diff options
| author | Adam Soltys <[email protected]> | 2026-10-09 09:46:29 -0700 |
|---|---|---|
| committer | Adam Soltys <[email protected]> | 2026-10-09 09:46:29 -0700 |
| commit | 479959cdd77fdd18ca03f63af9b94eae291d0e2a (patch) | |
| tree | 6c72d32378c1a7b859d3ee86cf60a8d44e44b26b /android/app/src/twa | |
| parent | 09834ebe3d22d1ed877a1e3620747d59c9c14aef (diff) | |
| download | coinosv3-479959cdd77fdd18ca03f63af9b94eae291d0e2a.tar.gz coinosv3-479959cdd77fdd18ca03f63af9b94eae291d0e2a.zip | |
Dark mode: your own chat bubbles are a gray (#343a44, light text) instead of the white accent, which glared among the dark bubbles. Android 1.12 (code 13): the TWA no longer names a navigation-bar colour — the helper library always passed one (white when the manifest named none), and Chrome 154's Custom Tab window paints that bar white anyway while the buttons follow the colour asked for, so the colour extras are stripped from the launch intent (both schemes) and the bar is left to the browser and the system. Untested on a device yet; not published.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01Vps2H27rhbG9ZqseGfMrc3
Diffstat (limited to 'android/app/src/twa')
| -rw-r--r-- | android/app/src/twa/AndroidManifest.xml | 11 | ||||
| -rw-r--r-- | android/app/src/twa/java/io/coinos/app/LauncherActivity.java | 44 |
2 files changed, 47 insertions, 8 deletions
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(); |
