From c0deb5050ccebfd7e0921628ed69ad592cb62f6c Mon Sep 17 00:00:00 2001 From: benma's agent Date: Wed, 19 Nov 2025 17:21:19 +0100 Subject: [PATCH 1/2] android: fix system navigation bar overlap Android 15 (API 35) enforces edge-to-edge display by default, causing the app to draw behind the system navigation bar. This commit adds to the root layout to prevent the app content from overlapping with the system navigation bar. --- .../android/BitBoxApp/app/src/main/res/layout/activity_main.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/frontends/android/BitBoxApp/app/src/main/res/layout/activity_main.xml b/frontends/android/BitBoxApp/app/src/main/res/layout/activity_main.xml index fe3bbcdfd6..7b798c6cc7 100644 --- a/frontends/android/BitBoxApp/app/src/main/res/layout/activity_main.xml +++ b/frontends/android/BitBoxApp/app/src/main/res/layout/activity_main.xml @@ -5,6 +5,7 @@ android:layout_width="match_parent" android:layout_height="match_parent" android:keepScreenOn="true" + android:fitsSystemWindows="true" tools:context="ch.shiftcrypto.bitboxapp.MainActivity"> Date: Mon, 24 Nov 2025 06:01:27 -0500 Subject: [PATCH 2/2] android: align system bars with app theme The colors of both the status and the navigation bars and their icons were not always matching the app background. Also, forcing the app theme in the settings and then switching the OS theme was sometime causing the bar icons to change and blend with the bars. This commit does the following: - Drives the colors of both bars and icons in the setDarkTheme method to avoid misalignemnts with the app theme - Removes the onConfigurationChanged overriding, which was conficting with the implemented theme handling, which is delegated to the frontend DarkmodeProvider. Listening of OS theme changes in the activity must be avoided as it could fire unwanted changes in the app theme. - Improve the app static styles, to reduce the color flickering before setDarkTheme() is called for the first time. - Apply matching backgrounds to the root layout and WebView so the bars blend with the app in both light and dark modes. --- CHANGELOG.md | 1 + .../shiftcrypto/bitboxapp/MainActivity.java | 65 +++++++++++-------- .../app/src/main/res/layout/activity_main.xml | 1 + .../app/src/main/res/values-night/styles.xml | 8 +++ .../app/src/main/res/values-v23/styles.xml | 7 -- .../app/src/main/res/values/styles.xml | 7 +- 6 files changed, 53 insertions(+), 36 deletions(-) create mode 100644 frontends/android/BitBoxApp/app/src/main/res/values-night/styles.xml delete mode 100644 frontends/android/BitBoxApp/app/src/main/res/values-v23/styles.xml diff --git a/CHANGELOG.md b/CHANGELOG.md index d5c5b94a46..35d7a62276 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ - Android: fix display of external links from Bitrefill - fix language sometimes not persistent across app restarts - Android: make the UI work with responsive font sizes and adhere to OS font size settings +- Android: fix layout issues with status and navigation bars. ## v4.49.0 - Bundle BitBox02 Nova firmware version v9.24.0 diff --git a/frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/MainActivity.java b/frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/MainActivity.java index 7e96fa4e73..abc1da40e6 100644 --- a/frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/MainActivity.java +++ b/frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/MainActivity.java @@ -4,11 +4,12 @@ import android.content.Context; import android.content.Intent; import android.content.ServiceConnection; -import android.content.res.Configuration; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.os.IBinder; import android.view.View; +import android.view.Window; import android.view.WindowManager; import android.webkit.WebView; @@ -50,37 +51,46 @@ public void onServiceDisconnected(ComponentName arg0) { } }; - @Override - public void onConfigurationChanged(Configuration newConfig) { - int currentNightMode = newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK; - switch (currentNightMode) { - case Configuration.UI_MODE_NIGHT_NO: - // Night mode is not active, we're using the light theme - setDarkTheme(false); - break; - case Configuration.UI_MODE_NIGHT_YES: - // Night mode is active, we're using dark theme - setDarkTheme(true); - break; - } - super.onConfigurationChanged(newConfig); - } - public void setDarkTheme(boolean isDark) { - int flags = getWindow().getDecorView().getSystemUiVisibility(); // get current flag + int statusBarColor = ContextCompat.getColor( + getApplicationContext(), + isDark ? R.color.colorPrimaryDark : R.color.colorPrimary + ); + // Pre-Oreo devices cannot render light nav bar icons, so fall back to dark bar to keep icons visible. + boolean supportsLightNavIcons = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O; + int navBarColor = supportsLightNavIcons + ? statusBarColor + : ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark); + + Window window = getWindow(); + window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); + window.setStatusBarColor(statusBarColor); + window.setNavigationBarColor(navBarColor); + + View decorView = window.getDecorView(); + int flags = decorView.getSystemUiVisibility(); // get current flag if (isDark) { Util.log("Dark theme"); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark)); - getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR); - flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; // remove LIGHT_STATUS_BAR to flag - getWindow().getDecorView().setSystemUiVisibility(flags); + flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; // remove LIGHT_STATUS_BAR flag + if (supportsLightNavIcons) { + flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + } } else { Util.log("Light theme"); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS); - getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary)); - flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; // add LIGHT_STATUS_BAR to flag - getWindow().getDecorView().setSystemUiVisibility(flags); + flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; // add LIGHT_STATUS_BAR flag + if (supportsLightNavIcons) { + flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR; + } + } + decorView.setSystemUiVisibility(flags); + + View root = findViewById(R.id.root_layout); + WebView vw = findViewById(R.id.vw); + if (root != null) { + root.setBackgroundColor(statusBarColor); + } + if (vw != null) { + vw.setBackgroundColor(statusBarColor); } } @@ -93,7 +103,6 @@ protected void onCreate(Bundle savedInstanceState) { if (actionBar != null) { actionBar.hide(); // hide title bar with app name. } - onConfigurationChanged(getResources().getConfiguration()); setContentView(R.layout.activity_main); final WebView vw = findViewById(R.id.vw); diff --git a/frontends/android/BitBoxApp/app/src/main/res/layout/activity_main.xml b/frontends/android/BitBoxApp/app/src/main/res/layout/activity_main.xml index 7b798c6cc7..138b229219 100644 --- a/frontends/android/BitBoxApp/app/src/main/res/layout/activity_main.xml +++ b/frontends/android/BitBoxApp/app/src/main/res/layout/activity_main.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" + android:id="@+id/root_layout" android:keepScreenOn="true" android:fitsSystemWindows="true" tools:context="ch.shiftcrypto.bitboxapp.MainActivity"> diff --git a/frontends/android/BitBoxApp/app/src/main/res/values-night/styles.xml b/frontends/android/BitBoxApp/app/src/main/res/values-night/styles.xml new file mode 100644 index 0000000000..fb085c181f --- /dev/null +++ b/frontends/android/BitBoxApp/app/src/main/res/values-night/styles.xml @@ -0,0 +1,8 @@ + + + diff --git a/frontends/android/BitBoxApp/app/src/main/res/values-v23/styles.xml b/frontends/android/BitBoxApp/app/src/main/res/values-v23/styles.xml deleted file mode 100644 index 5fb62d8180..0000000000 --- a/frontends/android/BitBoxApp/app/src/main/res/values-v23/styles.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - diff --git a/frontends/android/BitBoxApp/app/src/main/res/values/styles.xml b/frontends/android/BitBoxApp/app/src/main/res/values/styles.xml index 36ee924949..97ba6cdb7b 100644 --- a/frontends/android/BitBoxApp/app/src/main/res/values/styles.xml +++ b/frontends/android/BitBoxApp/app/src/main/res/values/styles.xml @@ -8,5 +8,10 @@ -