-
Notifications
You must be signed in to change notification settings - Fork 0
Fix navigation bar color on Sunmi POS devices #129
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Problem: - Navigation bar remained green on Sunmi POS terminals regardless of theme - Issue occurred when switching between themes (Bitcoin orange, obsidian, green, white) - Navigation bar only updated correctly after toggling dark mode on/off Root Cause: - App was using TRANSPARENT for navigationBarColor - Sunmi POS devices don't properly support transparent navigation bars - Device falls back to system default color (green) instead of showing app background Solution: - Changed navigation bar from TRANSPARENT to actual theme background colors - Navigation bar now matches the active theme color dynamically - Updated both programmatic settings and XML theme definitions Files Modified: - ThemeManager.kt: Set navigationBarColor to resolved backgroundColor - ModernPOSActivity.kt: Use theme background color, fix icon appearance logic - MultiInsetEdgeToEdge.kt: Add backgroundColor parameter (defaults to white) - TipSelectionActivity.kt: Use solid white instead of transparent - WithdrawSuccessActivity.kt: Use solid white instead of transparent - PaymentReceivedActivity.kt: Use solid white instead of transparent - PaymentFailureActivity.kt: Use solid white instead of transparent - values/themes.xml: Use solid color instead of transparent - values-night/themes.xml: Use solid color instead of transparent Result: - Navigation bar now correctly matches theme (green, Bitcoin orange, obsidian, white) - Works consistently on Sunmi POS devices without requiring dark mode toggle - All activities now have properly themed navigation bars
Detailed Code Review Comments🔧 Core Fix: ThemeManager.ktBefore: activity.window.navigationBarColor = android.graphics.Color.TRANSPARENTAfter: activity.window.navigationBarColor = backgroundColorWhy this matters: This is the central fix. By using the actual 🎨 ModernPOSActivity.kt - Window SetupKey changes:
Why this matters: The 🛠️ MultiInsetEdgeToEdge.kt - Helper Function EnhancementAdded parameter: fun enableEdgeToEdgeWithPill(
activity: Activity,
lightNavIcons: Boolean = true,
backgroundColor: Int = Color.WHITE // ← New parameter
)Why this matters: This helper is used by many activities throughout the app. By adding a 📱 Activity-Specific FixesAll the activity fixes (TipSelectionActivity, WithdrawSuccessActivity, PaymentReceivedActivity, PaymentFailureActivity) follow the same pattern: Before: window.navigationBarColor = android.graphics.Color.TRANSPARENTAfter: val bgColor = android.graphics.Color.WHITE
window.navigationBarColor = bgColorWhy this matters: These activities all have white backgrounds, so using solid white ensures the navigation bar blends seamlessly. The explicit variable makes the intent clear and allows for easy future changes if needed. 🎨 Theme Resource Updatesvalues/themes.xml and values-night/themes.xml: Before: <item name="android:navigationBarColor">@android:color/transparent</item>After: <item name="android:navigationBarColor">@color/color_bg_white</item>
<!-- or @color/dark_windowBackground for night theme -->Why this matters: These XML theme definitions are the fallback/default values. By setting them to solid colors instead of transparent, we ensure that even if programmatic updates fail, the navigation bar will still have a reasonable color instead of falling back to the device's default green. Device Compatibility NoteThis fix specifically addresses Sunmi POS devices, but it also improves compatibility across all Android devices. Some older or specialized Android devices (POS terminals, kiosks, etc.) may not properly support transparent system bars. Using solid colors ensures consistent behavior across all devices while maintaining the visual design intent. |
Testing & Verification Steps✅ How to Test This Fix
🔍 What to Look For
📸 Before/AfterBefore: Navigation bar always green on Sunmi POS, regardless of theme This fix ensures consistent theming across all Android devices, with special attention to POS terminal compatibility. |
color-example-fix.mp4video of running through a few themes on light and dark mode. note: seperate dark mode issued spotted. on settings view the top and bottom navbars are white when darkmode is turned on. |
|
this has been fixed by @lollerfirst in #130. we can cancel this PR. |
Problem
The navigation bar (system bar with back arrow, home button, and recent apps button) remained green on Sunmi POS terminals regardless of the selected theme. This issue occurred when switching between themes (Bitcoin orange, obsidian, green, white). The navigation bar would only update correctly after toggling dark mode on/off, which was a workaround but not a proper solution.
Root Cause
The app was using
TRANSPARENTfornavigationBarColorthroughout the codebase. While transparent navigation bars work well on most modern Android devices, Sunmi POS devices don't properly support transparent navigation bars. When transparency is requested, these devices fall back to showing a system default color (green in this case) instead of allowing the app's background to show through.Solution
Changed the navigation bar from
TRANSPARENTto the actual theme background colors. The navigation bar now dynamically matches the active theme color, ensuring consistency across all devices including Sunmi POS terminals.Changes Made
Core Theme Management
ThemeManager.kt: ChangednavigationBarColorfromTRANSPARENTto the resolvedbackgroundColorbased on the current themeModernPOSActivity.kt: Updated to use theme background color instead of transparent, and fixed icon appearance logic to properly handle light/dark themesEdge-to-Edge Helper
MultiInsetEdgeToEdge.kt: AddedbackgroundColorparameter (defaults toColor.WHITE) to allow activities to specify their navigation bar colorActivity-Specific Fixes
TipSelectionActivity.kt: Changed fromTRANSPARENTto solid whiteWithdrawSuccessActivity.kt: Changed fromTRANSPARENTto solid whitePaymentReceivedActivity.kt: Changed fromTRANSPARENTto solid whitePaymentFailureActivity.kt: Changed fromTRANSPARENTto solid whiteTheme Resources
values/themes.xml: Changed navigation bar from@android:color/transparentto@color/color_bg_whitevalues-night/themes.xml: Changed navigation bar from@android:color/transparentto@color/dark_windowBackgroundTesting
✅ Navigation bar now correctly matches theme colors:
✅ Works consistently on Sunmi POS devices without requiring dark mode toggle
✅ All activities now have properly themed navigation bars
Technical Notes
Files Changed
app/src/main/java/com/electricdreams/numo/ui/theme/ThemeManager.ktapp/src/main/java/com/electricdreams/numo/ModernPOSActivity.ktapp/src/main/java/com/electricdreams/numo/feature/MultiInsetEdgeToEdge.ktapp/src/main/java/com/electricdreams/numo/feature/tips/TipSelectionActivity.ktapp/src/main/java/com/electricdreams/numo/feature/settings/WithdrawSuccessActivity.ktapp/src/main/java/com/electricdreams/numo/PaymentReceivedActivity.ktapp/src/main/java/com/electricdreams/numo/PaymentFailureActivity.ktapp/src/main/res/values/themes.xmlapp/src/main/res/values-night/themes.xml