Skip to content

Commit 47d438b

Browse files
Merge pull request #270 from appdevforall/feat/ADFA-4886-webview-navbar
ADFA-4886: Material 3 nav bar for the WebView chrome (icons, theme, a11y, i18n)
2 parents c16937e + ba6f82e commit 47d438b

12 files changed

Lines changed: 161 additions & 66 deletions

File tree

‎controller/app/src/main/AndroidManifest.xml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
android:exported="false"
7272
android:configChanges="orientation|screenSize"
7373
android:hardwareAccelerated="true"
74-
android:theme="@style/Theme.AppCompat.DayNight.NoActionBar"/>
74+
android:theme="@style/Theme.K2Go"/> <!-- ADFA-4886: Material 3 DayNight + app typography for the WebView chrome -->
7575

7676
<activity
7777
android:name="com.journeyapps.barcodescanner.CaptureActivity"

‎controller/app/src/main/java/org/iiab/controller/PortalActivity.java‎

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121

2222
import android.graphics.Bitmap;
2323
import android.view.View;
24-
import android.widget.Button;
24+
import android.widget.ImageButton;
2525
import android.widget.LinearLayout;
2626
import android.content.Intent;
2727
import android.os.Handler;
@@ -95,14 +95,14 @@ protected void onCreate(Bundle savedInstanceState) {
9595
webView.setGestureLogging(BuildConfig.DEBUG);
9696

9797
LinearLayout bottomNav = findViewById(R.id.bottomNav);
98-
Button btnHandle = findViewById(R.id.btnHandle); // The new handle
99-
Button btnHideNav = findViewById(R.id.btnHideNav); // Button to close
98+
ImageButton btnHandle = findViewById(R.id.btnHandle); // The new handle
99+
ImageButton btnHideNav = findViewById(R.id.btnHideNav); // Button to close
100100

101-
Button btnBack = findViewById(R.id.btnBack);
102-
Button btnHome = findViewById(R.id.btnHome);
103-
Button btnReload = findViewById(R.id.btnReload);
104-
Button btnExit = findViewById(R.id.btnExit);
105-
Button btnForward = findViewById(R.id.btnForward);
101+
ImageButton btnBack = findViewById(R.id.btnBack);
102+
ImageButton btnHome = findViewById(R.id.btnHome);
103+
ImageButton btnReload = findViewById(R.id.btnReload);
104+
ImageButton btnExit = findViewById(R.id.btnExit);
105+
ImageButton btnForward = findViewById(R.id.btnForward);
106106

107107
// --- NAV BAR (auto-hide after inactivity) ---
108108
// Visible on entry; hides after AUTO_HIDE_MS with no interaction, measured from the LAST
@@ -206,14 +206,16 @@ public boolean shouldOverrideUrlLoading(WebView view, android.webkit.WebResource
206206
public void onPageStarted(WebView view, String url, Bitmap favicon) {
207207
super.onPageStarted(view, url, favicon);
208208
vm.setLoading(true);
209-
btnReload.setText("✕"); // Change to Stop
209+
btnReload.setImageResource(R.drawable.ic_stop); // Change to Stop
210+
btnReload.setContentDescription(getString(R.string.k2go_nav_stop));
210211
}
211212

212213
@Override
213214
public void onPageFinished(WebView view, String url) {
214215
super.onPageFinished(view, url);
215216
vm.setLoading(false);
216-
btnReload.setText("↻"); // Back to Reload
217+
btnReload.setImageResource(R.drawable.ic_refresh); // Back to Reload
218+
btnReload.setContentDescription(getString(R.string.k2go_nav_reload));
217219
view.getSettings().setCacheMode(android.webkit.WebSettings.LOAD_DEFAULT);
218220

219221
// Touch diagnostics + best-effort MapLibre pitch enablement.
@@ -228,13 +230,15 @@ public void onReceivedError(WebView view, android.webkit.WebResourceRequest requ
228230
super.onReceivedError(view, request, error);
229231
if (request.isForMainFrame()) {
230232
String customErrorHtml = "<html><body style='background-color:#1A1A1A;color:#FFFFFF;text-align:center;padding-top:50px;font-family:sans-serif;'>"
231-
+ "<h2>⚠️ Connection Failed</h2>"
232-
+ "<p>Unable to reach the secure environment.</p>"
233-
+ "<p style='color:#888;font-size:12px;'>Error: " + error.getDescription() + "</p>"
233+
+ "<h2>⚠️ " + getString(R.string.k2go_portal_error_title) + "</h2>"
234+
+ "<p>" + getString(R.string.k2go_portal_error_body) + "</p>"
235+
+ "<p style='color:#888;font-size:12px;'>"
236+
+ getString(R.string.k2go_portal_error_detail, error.getDescription()) + "</p>"
234237
+ "</body></html>";
235238
view.loadData(customErrorHtml, "text/html", "UTF-8");
236239
vm.setLoading(false);
237-
btnReload.setText("↻");
240+
btnReload.setImageResource(R.drawable.ic_refresh);
241+
btnReload.setContentDescription(getString(R.string.k2go_nav_reload));
238242
}
239243
}
240244
});
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!-- ADFA-4886: collapsed-bar handle. The visible tab (the bar's own colorSurfaceContainer surface
3+
with rounded top corners) is drawn only in the bottom strip via a top inset, so the button can
4+
be a full 48dp-tall touch target (a11y minimum) while still looking like a slim peeking tab. -->
5+
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
6+
<item android:top="20dp">
7+
<shape android:shape="rectangle">
8+
<solid android:color="?attr/colorSurfaceContainer" />
9+
<corners
10+
android:topLeftRadius="14dp"
11+
android:topRightRadius="14dp"
12+
android:bottomLeftRadius="0dp"
13+
android:bottomRightRadius="0dp" />
14+
</shape>
15+
</item>
16+
</layer-list>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp" android:height="24dp"
3+
android:viewportWidth="24" android:viewportHeight="24"
4+
android:tint="?attr/colorControlNormal">
5+
<path android:fillColor="#FF000000"
6+
android:pathData="M12,4l-1.41,1.41L16.17,11H4v2h12.17l-5.58,5.59L12,20l8,-8z"/>
7+
</vector>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp" android:height="24dp"
3+
android:viewportWidth="24" android:viewportHeight="24"
4+
android:tint="?attr/colorControlNormal">
5+
<path android:fillColor="#FF000000"
6+
android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
7+
</vector>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp" android:height="24dp"
3+
android:viewportWidth="24" android:viewportHeight="24"
4+
android:tint="?attr/colorControlNormal">
5+
<path android:fillColor="#FF000000"
6+
android:pathData="M7,14H5v5h5v-2H7v-3zM5,10h2V7h3V5H5v5zM17,17h-3v2h5v-5h-2v3zM14,5v2h3v3h2V5h-5z"/>
7+
</vector>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="32dp" android:height="24dp"
3+
android:viewportWidth="32" android:viewportHeight="24"
4+
android:tint="?attr/colorControlNormal">
5+
<path android:fillColor="#FF000000"
6+
android:pathData="M8,10h16a2,2 0 0 1 0,4h-16a2,2 0 0 1 0,-4z"/>
7+
</vector>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp" android:height="24dp"
3+
android:viewportWidth="24" android:viewportHeight="24"
4+
android:tint="?attr/colorControlNormal">
5+
<path android:fillColor="#FF000000"
6+
android:pathData="M17.65,6.35C16.2,4.9 14.21,4 12,4c-4.42,0 -7.99,3.58 -7.99,8s3.57,8 7.99,8c3.73,0 6.84,-2.55 7.73,-6h-2.08c-0.82,2.33 -3.04,4 -5.65,4 -3.31,0 -6,-2.69 -6,-6s2.69,-6 6,-6c1.66,0 3.14,0.69 4.22,1.78L13,11h7V4l-2.35,2.35z"/>
7+
</vector>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<vector xmlns:android="http://schemas.android.com/apk/res/android"
2+
android:width="24dp" android:height="24dp"
3+
android:viewportWidth="24" android:viewportHeight="24"
4+
android:tint="?attr/colorControlNormal">
5+
<path android:fillColor="#FF000000"
6+
android:pathData="M6,6h12v12H6z"/>
7+
</vector>
Lines changed: 66 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
3+
xmlns:app="http://schemas.android.com/apk/res-auto"
34
android:layout_width="match_parent"
45
android:layout_height="match_parent"
5-
android:background="?android:attr/colorBackground">
6+
android:background="?attr/colorSurface">
67

78
<!-- WebView (Web page content handles its own background,
89
but you can force a dark theme in Java using WebSettings.setForceDark) -->
@@ -11,98 +12,112 @@
1112
android:layout_width="match_parent"
1213
android:layout_height="match_parent" />
1314

14-
<Button
15+
<!-- ADFA-4886: nav chrome uses Material 3 vector icons + theme attributes (system day/night)
16+
instead of emoji/glyph text buttons. Icon-only buttons carry a contentDescription. -->
17+
<!-- Collapsed-bar handle: a Material 3 tab of the bar's own surface with a drag grabber,
18+
so it reads as the nav bar peeking from the bottom edge rather than a separate button. -->
19+
<ImageButton
1520
android:id="@+id/btnHandle"
16-
android:layout_width="60dp"
17-
android:layout_height="32dp"
21+
android:layout_width="56dp"
22+
android:layout_height="48dp"
1823
android:layout_alignParentBottom="true"
1924
android:layout_centerHorizontal="true"
20-
android:alpha="0.8"
21-
android:background="?android:attr/colorButtonNormal"
22-
android:padding="0dp"
23-
android:stateListAnimator="@null"
24-
android:text="⌃"
25-
android:textColor="?android:attr/textColorPrimary"
26-
android:textSize="18sp" />
25+
android:background="@drawable/bg_nav_handle"
26+
android:contentDescription="@string/k2go_nav_show_bar"
27+
android:elevation="8dp"
28+
android:paddingTop="20dp"
29+
android:scaleType="center"
30+
app:tint="?attr/colorOnSurfaceVariant"
31+
app:srcCompat="@drawable/ic_nav_grabber" />
2732

2833
<LinearLayout
2934
android:id="@+id/bottomNav"
3035
android:layout_width="match_parent"
3136
android:layout_height="wrap_content"
3237
android:layout_alignParentBottom="true"
33-
android:background="?android:attr/colorBackgroundFloating"
38+
android:background="?attr/colorSurfaceContainer"
3439
android:orientation="vertical"
3540
android:visibility="invisible"
3641
android:elevation="8dp">
3742

38-
<Button
43+
<ImageButton
3944
android:id="@+id/btnHideNav"
4045
android:layout_width="match_parent"
4146
android:layout_height="30dp"
42-
android:background="?android:attr/selectableItemBackground"
43-
android:text="⌄"
44-
android:textSize="20sp"
45-
android:textColor="?android:attr/textColorSecondary"
46-
android:stateListAnimator="@null" />
47+
android:background="?attr/selectableItemBackground"
48+
android:contentDescription="@string/k2go_nav_hide_bar"
49+
android:padding="4dp"
50+
android:scaleType="fitCenter"
51+
app:tint="?attr/colorOnSurfaceVariant"
52+
app:srcCompat="@drawable/ic_expand_more" />
4753

4854
<LinearLayout
4955
android:layout_width="match_parent"
5056
android:layout_height="wrap_content"
5157
android:orientation="horizontal"
5258
android:paddingBottom="8dp">
5359

54-
<Button
60+
<ImageButton
5561
android:id="@+id/btnBack"
5662
android:layout_width="0dp"
57-
android:layout_height="wrap_content"
63+
android:layout_height="48dp"
5864
android:layout_weight="1"
59-
android:text="◀"
60-
android:textSize="20sp"
61-
style="?android:attr/buttonBarButtonStyle"
62-
android:textColor="?android:attr/textColorPrimary" />
65+
android:background="?attr/selectableItemBackgroundBorderless"
66+
android:contentDescription="@string/k2go_nav_back"
67+
android:padding="12dp"
68+
android:scaleType="fitCenter"
69+
app:tint="?attr/colorOnSurface"
70+
app:srcCompat="@drawable/ic_arrow_left" />
6371

64-
<!-- ADFA-4887: repurposed as a Fullscreen toggle (no in-WebView home page anymore).
65-
Material 3 icon + contentDescription land in ADFA-4886. -->
66-
<Button
72+
<!-- ADFA-4887: repurposed as a Fullscreen toggle (no in-WebView home page anymore). -->
73+
<ImageButton
6774
android:id="@+id/btnHome"
6875
android:layout_width="0dp"
69-
android:layout_height="wrap_content"
76+
android:layout_height="48dp"
7077
android:layout_weight="1"
71-
android:text="⛶"
72-
android:textSize="20sp"
73-
style="?android:attr/buttonBarButtonStyle"
74-
android:textColor="?android:attr/textColorPrimary" />
78+
android:background="?attr/selectableItemBackgroundBorderless"
79+
android:contentDescription="@string/k2go_nav_fullscreen"
80+
android:padding="12dp"
81+
android:scaleType="fitCenter"
82+
app:tint="?attr/colorOnSurface"
83+
app:srcCompat="@drawable/ic_fullscreen" />
7584

76-
<Button
85+
<ImageButton
7786
android:id="@+id/btnReload"
7887
android:layout_width="0dp"
79-
android:layout_height="wrap_content"
88+
android:layout_height="48dp"
8089
android:layout_weight="1"
81-
android:text="↻"
82-
android:textSize="20sp"
83-
style="?android:attr/buttonBarButtonStyle"
84-
android:textColor="?android:attr/textColorPrimary" />
90+
android:background="?attr/selectableItemBackgroundBorderless"
91+
android:contentDescription="@string/k2go_nav_reload"
92+
android:padding="12dp"
93+
android:scaleType="fitCenter"
94+
app:tint="?attr/colorOnSurface"
95+
app:srcCompat="@drawable/ic_refresh" />
8596

86-
<Button
97+
<ImageButton
8798
android:id="@+id/btnExit"
8899
android:layout_width="0dp"
89-
android:layout_height="wrap_content"
100+
android:layout_height="48dp"
90101
android:layout_weight="1"
91-
android:text="✖"
92-
android:textSize="20sp"
93-
style="?android:attr/buttonBarButtonStyle"
94-
android:textColor="#D32F2F" /> <!-- Red is universal alert color -->
102+
android:background="?attr/selectableItemBackgroundBorderless"
103+
android:contentDescription="@string/k2go_nav_exit"
104+
android:padding="12dp"
105+
android:scaleType="fitCenter"
106+
app:tint="@color/k2go_nav_exit"
107+
app:srcCompat="@drawable/ic_close_24" /> <!-- Red is the universal alert color -->
95108

96-
<Button
109+
<ImageButton
97110
android:id="@+id/btnForward"
98111
android:layout_width="0dp"
99-
android:layout_height="wrap_content"
112+
android:layout_height="48dp"
100113
android:layout_weight="1"
101-
android:text="▶"
102-
android:textSize="20sp"
103-
style="?android:attr/buttonBarButtonStyle"
104-
android:textColor="?android:attr/textColorPrimary" />
114+
android:background="?attr/selectableItemBackgroundBorderless"
115+
android:contentDescription="@string/k2go_nav_forward"
116+
android:padding="12dp"
117+
android:scaleType="fitCenter"
118+
app:tint="?attr/colorOnSurface"
119+
app:srcCompat="@drawable/ic_arrow_right" />
105120
</LinearLayout>
106121

107122
</LinearLayout>
108-
</RelativeLayout>
123+
</RelativeLayout>

0 commit comments

Comments
 (0)