Skip to content

Commit 2517eb5

Browse files
committed
Merge remote-tracking branch 'upstream/master' into staging-swap
2 parents c52fe0e + 5985ab8 commit 2517eb5

File tree

24 files changed

+21476
-813
lines changed

24 files changed

+21476
-813
lines changed

.github/workflows/ci.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,57 @@ jobs:
7070
path: /github/home/go/src/github.com/BitBoxSwiss/bitbox-wallet-app/frontends/android/BitBoxApp/app/build/outputs/apk/debug/app-debug.apk
7171
name: BitBoxApp-android-${{github.sha}}.apk
7272
if-no-files-found: error
73+
74+
e2e-android:
75+
name: Android E2E Tests
76+
needs: android
77+
runs-on: ubuntu-latest
78+
strategy:
79+
matrix:
80+
api-level: [30, 31, 32, 33, 34, 35]
81+
steps:
82+
- name: Checkout repo
83+
uses: actions/checkout@v4
84+
85+
- name: Set up Node.js
86+
uses: actions/setup-node@v4
87+
with:
88+
node-version: '20.x'
89+
90+
- name: Download APK
91+
uses: actions/download-artifact@v4
92+
with:
93+
name: BitBoxApp-android-${{ github.sha }}.apk
94+
path: frontends/mobiletests/apk
95+
96+
- name: Install dependencies
97+
working-directory: frontends/mobiletests
98+
run: npm ci
99+
100+
- name: Enable KVM group perms
101+
run: |
102+
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
103+
sudo udevadm control --reload-rules
104+
sudo udevadm trigger --name-match=kvm
105+
106+
- name: Install Appium & drivers
107+
run: |
108+
npm install -g appium@3.1.0
109+
appium driver install uiautomator2
110+
111+
- name: Start Android emulator and run tests
112+
uses: reactivecircus/android-emulator-runner@v2
113+
env:
114+
PLATFORM: Android
115+
ANDROID_EMULATOR_WAIT_TIME_BEFORE_KILL: 5
116+
with:
117+
api-level: ${{ matrix.api-level }}
118+
arch: x86_64
119+
force-avd-creation: true
120+
emulator-boot-timeout: 600
121+
working-directory: frontends/mobiletests
122+
emulator-options: "-no-window -no-audio -no-boot-anim -no-snapshot-load -no-snapshot-save"
123+
script: ./run.sh
73124
qt-linux:
74125
runs-on: ubuntu-22.04
75126
needs: setup-env

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
- Android: fix display of external links from Bitrefill
1111
- fix language sometimes not persistent across app restarts
1212
- Android: make the UI work with responsive font sizes and adhere to OS font size settings
13+
- Android: fix layout issues with status and navigation bars.
1314

1415
## v4.49.0
1516
- Bundle BitBox02 Nova firmware version v9.24.0

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
SHELL := /bin/bash
1616
WEBROOT := frontends/web
17+
MOBILETESTROOT := frontends/mobiletests
1718

1819
include version.mk.inc
1920

@@ -64,6 +65,8 @@ webserve:
6465
cd ${WEBROOT} && $(MAKE) serve
6566
webe2etest:
6667
cd ${WEBROOT} && $(MAKE) test-e2e
68+
mobilee2etest:
69+
cd ${MOBILETESTROOT} && ./run.sh
6770
qt-linux: # run inside dockerdev
6871
$(MAKE) buildweb
6972
cd frontends/qt && $(MAKE) linux

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ Tests are located under [`frontends/web/tests`](/frontends/web/tests) and can be
126126
`make webe2etest`
127127

128128
More info can be found [here](/frontends/web/tests/README.md)
129+
Appium is used to perform automatic test on Android emulators.
130+
The test runs automatically on PRs and push to master in the Github CI.
131+
132+
`make mobilee2etest` can be used to launch the tests; however, when ran locally, this requires an Android emulator
133+
to be already running. In CI, the emulator is automatically spawned from a Github Action.
129134

130135
#### Run the HTTP API
131136

frontends/android/BitBoxApp/app/src/main/java/ch/shiftcrypto/bitboxapp/MainActivity.java

Lines changed: 37 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
import android.content.Context;
55
import android.content.Intent;
66
import android.content.ServiceConnection;
7-
import android.content.res.Configuration;
87
import android.net.Uri;
8+
import android.os.Build;
99
import android.os.Bundle;
1010
import android.os.IBinder;
1111
import android.view.View;
12+
import android.view.Window;
1213
import android.view.WindowManager;
1314
import android.webkit.WebView;
1415

@@ -50,37 +51,46 @@ public void onServiceDisconnected(ComponentName arg0) {
5051
}
5152
};
5253

53-
@Override
54-
public void onConfigurationChanged(Configuration newConfig) {
55-
int currentNightMode = newConfig.uiMode & Configuration.UI_MODE_NIGHT_MASK;
56-
switch (currentNightMode) {
57-
case Configuration.UI_MODE_NIGHT_NO:
58-
// Night mode is not active, we're using the light theme
59-
setDarkTheme(false);
60-
break;
61-
case Configuration.UI_MODE_NIGHT_YES:
62-
// Night mode is active, we're using dark theme
63-
setDarkTheme(true);
64-
break;
65-
}
66-
super.onConfigurationChanged(newConfig);
67-
}
68-
6954
public void setDarkTheme(boolean isDark) {
70-
int flags = getWindow().getDecorView().getSystemUiVisibility(); // get current flag
55+
int statusBarColor = ContextCompat.getColor(
56+
getApplicationContext(),
57+
isDark ? R.color.colorPrimaryDark : R.color.colorPrimary
58+
);
59+
// Pre-Oreo devices cannot render light nav bar icons, so fall back to dark bar to keep icons visible.
60+
boolean supportsLightNavIcons = Build.VERSION.SDK_INT >= Build.VERSION_CODES.O;
61+
int navBarColor = supportsLightNavIcons
62+
? statusBarColor
63+
: ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark);
64+
65+
Window window = getWindow();
66+
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
67+
window.setStatusBarColor(statusBarColor);
68+
window.setNavigationBarColor(navBarColor);
69+
70+
View decorView = window.getDecorView();
71+
int flags = decorView.getSystemUiVisibility(); // get current flag
7172
if (isDark) {
7273
Util.log("Dark theme");
73-
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
74-
getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimaryDark));
75-
getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
76-
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; // remove LIGHT_STATUS_BAR to flag
77-
getWindow().getDecorView().setSystemUiVisibility(flags);
74+
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; // remove LIGHT_STATUS_BAR flag
75+
if (supportsLightNavIcons) {
76+
flags &= ~View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
77+
}
7878
} else {
7979
Util.log("Light theme");
80-
getWindow().addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
81-
getWindow().setStatusBarColor(ContextCompat.getColor(getApplicationContext(), R.color.colorPrimary));
82-
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; // add LIGHT_STATUS_BAR to flag
83-
getWindow().getDecorView().setSystemUiVisibility(flags);
80+
flags |= View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR; // add LIGHT_STATUS_BAR flag
81+
if (supportsLightNavIcons) {
82+
flags |= View.SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR;
83+
}
84+
}
85+
decorView.setSystemUiVisibility(flags);
86+
87+
View root = findViewById(R.id.root_layout);
88+
WebView vw = findViewById(R.id.vw);
89+
if (root != null) {
90+
root.setBackgroundColor(statusBarColor);
91+
}
92+
if (vw != null) {
93+
vw.setBackgroundColor(statusBarColor);
8494
}
8595
}
8696

@@ -93,7 +103,6 @@ protected void onCreate(Bundle savedInstanceState) {
93103
if (actionBar != null) {
94104
actionBar.hide(); // hide title bar with app name.
95105
}
96-
onConfigurationChanged(getResources().getConfiguration());
97106
setContentView(R.layout.activity_main);
98107
final WebView vw = findViewById(R.id.vw);
99108

frontends/android/BitBoxApp/app/src/main/res/layout/activity_main.xml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
xmlns:tools="http://schemas.android.com/tools"
55
android:layout_width="match_parent"
66
android:layout_height="match_parent"
7+
android:id="@+id/root_layout"
78
android:keepScreenOn="true"
9+
android:fitsSystemWindows="true"
810
tools:context="ch.shiftcrypto.bitboxapp.MainActivity">
911

1012
<WebView
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<resources>
2+
<style name="AppTheme" parent="BaseAppTheme">
3+
<item name="android:statusBarColor">@color/colorPrimaryDark</item>
4+
<item name="android:navigationBarColor">@color/colorPrimaryDark</item>
5+
<item name="android:windowLightStatusBar">false</item>
6+
<item name="android:windowLightNavigationBar">false</item>
7+
</style>
8+
</resources>

frontends/android/BitBoxApp/app/src/main/res/values-v23/styles.xml

Lines changed: 0 additions & 7 deletions
This file was deleted.

frontends/android/BitBoxApp/app/src/main/res/values/styles.xml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,10 @@
88
</style>
99

1010
<!-- declare the theme name that's actually applied in the manifest file -->
11-
<style name="AppTheme" parent="BaseAppTheme" />
11+
<style name="AppTheme" parent="BaseAppTheme" >
12+
<item name="android:statusBarColor">@color/colorPrimary</item>
13+
<item name="android:navigationBarColor">@color/colorPrimary</item>
14+
<item name="android:windowLightStatusBar">true</item>
15+
<item name="android:windowLightNavigationBar">true</item>
16+
</style>
1217
</resources>

frontends/mobiletests/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/node_modules/

0 commit comments

Comments
 (0)