App 2.27.0: full-width Overview, a button hides the navigation
A small button in the Overview's top-right corner hides the app's sidebar (or bottom bar) and brings it back; only on the Overview, remembered, swiping still works. Emulator only. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LhzAVaUyqcw5PkGjz4mWW6
This commit is contained in:
@@ -182,7 +182,14 @@ public class MainActivity extends AppCompatActivity {
|
||||
// by the tick even when their page is off screen.
|
||||
pager.setOffscreenPageLimit(panes.length - 1);
|
||||
pager.registerOnPageChangeCallback(new ViewPager2.OnPageChangeCallback() {
|
||||
@Override public void onPageSelected(int position) { markCurrentPage(position); }
|
||||
@Override public void onPageSelected(int position) {
|
||||
markCurrentPage(position);
|
||||
applyOverviewFullScreen(position);
|
||||
}
|
||||
});
|
||||
findViewById(R.id.overview_fullscreen).setOnClickListener(v -> {
|
||||
prefs.edit().putBoolean(PREF_OVERVIEW_FULLSCREEN, !prefs.getBoolean(PREF_OVERVIEW_FULLSCREEN, false)).apply();
|
||||
applyOverviewFullScreen(pager.getCurrentItem());
|
||||
});
|
||||
|
||||
for (int i = 0; i < TAB_IDS.length; i++) {
|
||||
@@ -192,6 +199,25 @@ public class MainActivity extends AppCompatActivity {
|
||||
findViewById(TAB_IDS[i]).setOnClickListener(v -> pager.setCurrentItem(index, false));
|
||||
}
|
||||
markCurrentPage(pager.getCurrentItem());
|
||||
applyOverviewFullScreen(pager.getCurrentItem());
|
||||
}
|
||||
|
||||
/** Whether the Overview hides the navigation (the button in its corner). */
|
||||
static final String PREF_OVERVIEW_FULLSCREEN = "overview_fullscreen";
|
||||
|
||||
/**
|
||||
* The Overview full screen: the navigation hidden while the Overview is the page and the
|
||||
* driver chose it; every other page always has its navigation, and swiping still works.
|
||||
* The button only shows on the Overview, its icon saying what a tap does.
|
||||
*/
|
||||
private void applyOverviewFullScreen(int position) {
|
||||
boolean overview = position == 0;
|
||||
boolean full = overview && prefs.getBoolean(PREF_OVERVIEW_FULLSCREEN, false);
|
||||
findViewById(R.id.nav_bar).setVisibility(full ? View.GONE : View.VISIBLE);
|
||||
android.widget.ImageButton button = findViewById(R.id.overview_fullscreen);
|
||||
button.setVisibility(overview ? View.VISIBLE : View.GONE);
|
||||
button.setImageResource(full ? R.drawable.ic_fullscreen_exit : R.drawable.ic_fullscreen);
|
||||
button.setContentDescription(getString(full ? R.string.overview_fullscreen_exit : R.string.overview_fullscreen_enter));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -67,7 +67,8 @@ final class MinimalView extends ClusterCanvasView {
|
||||
|
||||
// Corners: power and the clock; bottom middle: usage.
|
||||
text(c, fmt(v.powerKw, "%.1f kW", "— kW"), 8f * dp, 30f * dp, 20f * dp, grey, Paint.Align.LEFT);
|
||||
text(c, v.clock.isEmpty() ? "—" : v.clock, w - 8f * dp, 30f * dp, 20f * dp, grey, Paint.Align.RIGHT);
|
||||
// Left of the full-screen button, which sits in the top-right corner.
|
||||
text(c, v.clock.isEmpty() ? "—" : v.clock, w - 72f * dp, 30f * dp, 20f * dp, grey, Paint.Align.RIGHT);
|
||||
text(c, fmt(v.usage5Min, "%.1f kWh/100 km", "— kWh/100 km"), w / 2f, h * 0.86f, 16f * dp, grey, Paint.Align.CENTER);
|
||||
|
||||
// The battery: a hairline along the bottom, filled to the charge.
|
||||
|
||||
@@ -41,9 +41,10 @@ final class TerminalView extends ClusterCanvasView {
|
||||
|
||||
// About 14 rows at 1.32 em each plus margins; monospace is about 0.6 em wide and the
|
||||
// longest row about 58 characters.
|
||||
float size = Math.min(h / 19.5f, w / 38f);
|
||||
float x = 16f * dp;
|
||||
float size = Math.min(h / 19.5f, (w - x) / 38f);
|
||||
text.setTextSize(size);
|
||||
float line = size * 1.32f, x = 16f * dp, y = 12f * dp + line;
|
||||
float line = size * 1.32f, y = 12f * dp + line;
|
||||
String gear = gearRow();
|
||||
|
||||
print(c, "nils@mg4:~$ watch -n 0.2 vehicle-status", x, y, dim);
|
||||
|
||||
Reference in New Issue
Block a user