Skip to content

Commit e6c0c24

Browse files
ADFA-4887: WebView nav — touch-based auto-hide + Home becomes Fullscreen
- Restore auto-hide from the LAST touch: resetTimer now reschedules the hide after AUTO_HIDE_MS (4s) instead of only cancelling it; GestureWebView notifies the host on each touch (setOnUserInteraction) so content touches count, and the countdown starts on load. The handle brings the bar back; btnHideNav still hides manually. - Repurpose Home as a Fullscreen toggle (no in-WebView home page anymore): enter full immersive (system bars hidden via WindowInsetsControllerCompat) and hide our bar too, but keep it recoverable via the handle; press again to exit. Glyph swapped to a fullscreen mark (Material 3 icon + contentDescription land in ADFA-4886).
1 parent 1a0a56a commit e6c0c24

3 files changed

Lines changed: 37 additions & 8 deletions

File tree

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

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public class PortalActivity extends AppCompatActivity {
6969

7070
private GestureWebView webView;
7171
private org.iiab.controller.redesign.FqrController fqr; // ADFA-4879: FQR maps (only on /maps/)
72+
private static final long AUTO_HIDE_MS = 4000L; // ADFA-4887: nav-bar auto-hide after inactivity
73+
private boolean fullscreenOn = false; // ADFA-4887: Home button toggles fullscreen
7274
// pdf.js builds advertised by /pdfjs/manifest.json (loaded off the main thread).
7375
// Empty until loaded / when the box serves none -> PDFs fall back to download.
7476
private volatile List<PdfViewerBuild> pdfViewerBuilds = Collections.emptyList();
@@ -100,16 +102,15 @@ protected void onCreate(Bundle savedInstanceState) {
100102
Button btnExit = findViewById(R.id.btnExit);
101103
Button btnForward = findViewById(R.id.btnForward);
102104

103-
// --- PERSISTENT BAR ---
104-
// Keep the nav bar (with Exit) visible so a non-technical user always has an
105-
// obvious way out. The handle is only used after a manual hide (btnHideNav).
105+
// --- NAV BAR (auto-hide after inactivity) ---
106+
// Visible on entry; hides after AUTO_HIDE_MS with no interaction, measured from the LAST
107+
// touch. The handle (⌃) brings it back; btnHideNav hides it manually.
106108
bottomNav.post(() -> {
107109
bottomNav.setTranslationY(0);
108110
bottomNav.setVisibility(View.VISIBLE);
109111
});
110112
btnHandle.setVisibility(View.GONE);
111113

112-
// --- AUTO-HIDE TIMER ---
113114
Handler hideHandler = new Handler(Looper.getMainLooper());
114115

115116
Runnable hideRunnable = () -> {
@@ -118,8 +119,13 @@ protected void onCreate(Bundle savedInstanceState) {
118119
btnHandle.animate().alpha(1f).setDuration(150);
119120
};
120121

121-
// Persistent bar: never auto-hide. Cancel any pending hide; only btnHideNav hides.
122-
Runnable resetTimer = () -> hideHandler.removeCallbacks(hideRunnable);
122+
// Reschedule the hide on every interaction -> auto-hide from the LAST touch, not the first.
123+
Runnable resetTimer = () -> {
124+
hideHandler.removeCallbacks(hideRunnable);
125+
hideHandler.postDelayed(hideRunnable, AUTO_HIDE_MS);
126+
};
127+
webView.setOnUserInteraction(resetTimer); // content touches count as interaction too
128+
resetTimer.run(); // start the initial countdown
123129

124130
// --- HANDLE LOGIC (Show Bar) ---
125131
btnHandle.setOnClickListener(v -> {
@@ -141,8 +147,23 @@ protected void onCreate(Bundle savedInstanceState) {
141147
// Resolve the target URL once (domain), surviving rotation via the ViewModel.
142148
final String finalTargetUrl = vm.targetUrl(getIntent().getStringExtra("TARGET_URL"));
143149

150+
// ADFA-4887: there is no in-WebView home page anymore, so Home is a Fullscreen toggle.
151+
// Enters full immersive (system bars hidden) and hides our bar too — but the bar stays
152+
// recoverable via the handle. Press again to exit.
144153
btnHome.setOnClickListener(v -> {
145-
webView.loadUrl(finalTargetUrl);
154+
fullscreenOn = !fullscreenOn;
155+
androidx.core.view.WindowInsetsControllerCompat wic =
156+
androidx.core.view.WindowCompat.getInsetsController(getWindow(), getWindow().getDecorView());
157+
if (fullscreenOn) {
158+
wic.setSystemBarsBehavior(
159+
androidx.core.view.WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE);
160+
wic.hide(androidx.core.view.WindowInsetsCompat.Type.systemBars());
161+
hideRunnable.run(); // hide our bar too (still recoverable via the handle)
162+
} else {
163+
wic.show(androidx.core.view.WindowInsetsCompat.Type.systemBars());
164+
btnHandle.animate().alpha(0f).setDuration(150).withEndAction(() -> btnHandle.setVisibility(View.GONE));
165+
bottomNav.animate().translationY(0).setDuration(250);
166+
}
146167
resetTimer.run();
147168
});
148169

‎controller/app/src/main/java/org/iiab/controller/portal/presentation/GestureWebView.java‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public class GestureWebView extends WebView {
2828
public static final String TAG = "IIAB-GestureWV";
2929

3030
private boolean gestureLogging = false;
31+
private Runnable onUserInteraction; // ADFA-4887: notified on each touch (nav-bar auto-hide)
3132

3233
public GestureWebView(Context context) { super(context); }
3334
public GestureWebView(Context context, AttributeSet attrs) { super(context, attrs); }
@@ -36,10 +37,15 @@ public class GestureWebView extends WebView {
3637
/** Enable verbose touch logging (debug builds only). */
3738
public void setGestureLogging(boolean enabled) { this.gestureLogging = enabled; }
3839

40+
/** Called on every touch so the host can reset UI timers (e.g. nav-bar auto-hide from last touch). */
41+
public void setOnUserInteraction(Runnable r) { this.onUserInteraction = r; }
42+
3943
@Override
4044
public boolean onTouchEvent(MotionEvent event) {
4145
final int pointers = event.getPointerCount();
4246

47+
if (onUserInteraction != null) onUserInteraction.run();
48+
4349
// Two or more fingers: keep the gesture for the web content (the map),
4450
// so an ancestor (pager/scroll) can't hijack a tilt/rotate/pinch.
4551
if (pointers >= 2) {

‎controller/app/src/main/res/layout/activity_portal.xml‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,14 @@
6161
style="?android:attr/buttonBarButtonStyle"
6262
android:textColor="?android:attr/textColorPrimary" />
6363

64+
<!-- ADFA-4887: repurposed as a Fullscreen toggle (no in-WebView home page anymore).
65+
Material 3 icon + contentDescription land in ADFA-4886. -->
6466
<Button
6567
android:id="@+id/btnHome"
6668
android:layout_width="0dp"
6769
android:layout_height="wrap_content"
6870
android:layout_weight="1"
69-
android:text="🏠"
71+
android:text="⛶"
7072
android:textSize="20sp"
7173
style="?android:attr/buttonBarButtonStyle"
7274
android:textColor="?android:attr/textColorPrimary" />

0 commit comments

Comments
 (0)