From e5fb4e1d2dde66cb5f538924ddbff38b903a6fc5 Mon Sep 17 00:00:00 2001 From: Compot Developer Date: Fri, 20 Nov 2026 18:35:45 +0000 Subject: [PATCH] fix: Cancel and Save as two equal halves in every window (2.27.3) The brass rule for Cancel / Save is now for all windows (#294): Brass.style() lays out any dialog with both buttons as two equal halves, Cancel left, so the camera URL dialog and the Reset confirmation follow Settings (#292); the focused button keeps the focus (Cancel in Reset). focus_ring.xml header to brass 1.4.2 (comment only). Closes #294 --- CHANGELOG.md | 7 +++++++ android/app/build.gradle | 4 ++-- .../main/java/com/openipc/decoder/Brass.java | 14 +++++++++----- .../java/com/openipc/decoder/NetworkPanel.java | 1 - .../app/src/main/res/drawable/focus_ring.xml | 17 +++++++++++------ 5 files changed, 29 insertions(+), 14 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b6dd9c5..0658bc0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -12,6 +12,13 @@ Versions after 2.17 are `MAJOR.MINOR.PATCH` (2.17 is followed by 2.17.1 or 2.18. `docs/testing.md`, "Versions and releases"); the headings below keep the numbers as they were released. +## 2.27.3 — 2026-11-20 + +- Cancel and Save in every window follow the brass rule now (#294), not only in Settings: the + camera URL dialog and the Reset confirmation (Cancel / Clear settings) have Cancel on the left + and the other on the right, two equal halves across the window; on Android TV they were small, + pressed to the left and in the order Save, Cancel. Cancel keeps the first focus in Reset. + ## 2.27.2 — 2026-11-20 - The Settings dialog follows two brass rules it missed (#292): Cancel on the left and Save on diff --git a/android/app/build.gradle b/android/app/build.gradle index 6f3195c..aeefb90 100755 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -26,8 +26,8 @@ android { applicationId "com.openipc.decoder" minSdk 21 targetSdk 36 - versionCode 65 - versionName "2.27.2" + versionCode 66 + versionName "2.27.3" // Keep only these locales of the libraries' resources, as in the other OpenIPC apps resourceConfigurations += ['en', 'ru', 'zh-rCN'] diff --git a/android/app/src/main/java/com/openipc/decoder/Brass.java b/android/app/src/main/java/com/openipc/decoder/Brass.java index 8f7d4ad..47b6d07 100644 --- a/android/app/src/main/java/com/openipc/decoder/Brass.java +++ b/android/app/src/main/java/com/openipc/decoder/Brass.java @@ -165,20 +165,23 @@ static void style(AlertDialog dialog) { Button b = dialog.getButton(which); if (b != null) key(c, b); } + halves(dialog); } /** - * The buttons of a settings window (brass, 2026-11-20, as camex 4.3.1): Cancel on the left, - * Save on the right, two equal halves across the window with 6dp around each. The dialog's - * own button bar is reused; on Android TV it puts the positive button first and packs the - * buttons to the left, so it is reordered here. Call after {@link #style}. + * Cancel and Save of every window (brass, 2026-11-20, as camex 4.3.1): Cancel on the left, + * Save on the right, two equal halves across the window with 6dp around each (#292, #294). + * The dialog's own button bar is reused; on Android TV it puts the positive button first and + * packs the buttons to the left, so it is reordered here. A dialog with only one of the two + * (OK) keeps its bar. The button with the focus keeps it. */ - static void halves(AlertDialog dialog) { + private static void halves(AlertDialog dialog) { Button cancel = dialog.getButton(AlertDialog.BUTTON_NEGATIVE); Button save = dialog.getButton(AlertDialog.BUTTON_POSITIVE); if (cancel == null || save == null || cancel.getParent() != save.getParent() || !(save.getParent() instanceof LinearLayout)) return; LinearLayout bar = (LinearLayout) save.getParent(); + View focused = bar.findFocus(); for (int i = 0; i < bar.getChildCount(); i++) { View v = bar.getChildAt(i); if (v != cancel && v != save) v.setVisibility(View.GONE); @@ -198,6 +201,7 @@ static void halves(AlertDialog dialog) { lp.setMargins(m, m, m, m); bar.addView(b, lp); } + if (focused != null) focused.requestFocus(); } /** A dialog button as a brass key: serif capitals in dark ink, a little apart. */ diff --git a/android/app/src/main/java/com/openipc/decoder/NetworkPanel.java b/android/app/src/main/java/com/openipc/decoder/NetworkPanel.java index eb33367..66064d2 100644 --- a/android/app/src/main/java/com/openipc/decoder/NetworkPanel.java +++ b/android/app/src/main/java/com/openipc/decoder/NetworkPanel.java @@ -463,7 +463,6 @@ protected void onMeasure(int widthSpec, int heightSpec) { Brass.frame(dialog); dialog.show(); Brass.style(dialog); - Brass.halves(dialog); } /** The state line of the Network screen. */ diff --git a/android/app/src/main/res/drawable/focus_ring.xml b/android/app/src/main/res/drawable/focus_ring.xml index 208947e..fec19fb 100644 --- a/android/app/src/main/res/drawable/focus_ring.xml +++ b/android/app/src/main/res/drawable/focus_ring.xml @@ -5,15 +5,20 @@ focus_ring.xml — the D-pad focus of a check box, switch or radio button on a brass screen (res/drawable/focus_ring.xml): the amber frame of a focused brass button, nothing otherwise - Version: 1.3.0 - Date: 2026-11-18 + Version: 1.4.2 + Date: 2026-11-19 - The master copy, after vtesse 2.1.0; rules are in brass/README.md. Wire it through the theme: - @style/Check - - (the same for switchStyle and radioButtonStyle where the screen has them) + (BrassRadio: the same with RadioButton and brass_radio; a switch keeps its own look with + this background through switchStyle) -->