From 0242d143dc5a0a66ed335cb949b9e7a1cb43c60f Mon Sep 17 00:00:00 2001 From: Compot Developer Date: Tue, 13 Oct 2026 10:25:16 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20menu=20=E2=80=94=20active=20items=20(D?= =?UTF-8?q?=20on,=20Q,=20U,=20active=20slot)=20in=20orange,=20focus=20stay?= =?UTF-8?q?s=20blue=20(#114)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/openipc/decoder/MenuManager.java | 43 +++++++++++++------ 1 file changed, 29 insertions(+), 14 deletions(-) diff --git a/android/app/src/main/java/com/openipc/decoder/MenuManager.java b/android/app/src/main/java/com/openipc/decoder/MenuManager.java index 39cccad7..2b5df23e 100644 --- a/android/app/src/main/java/com/openipc/decoder/MenuManager.java +++ b/android/app/src/main/java/com/openipc/decoder/MenuManager.java @@ -36,6 +36,9 @@ import android.widget.RadioGroup; import android.widget.TextView; +import java.util.HashSet; +import java.util.Set; + class MenuManager { private static final String TAG = "OpenIPCDecoder"; private static final int CAM_COUNT = Decoder.CAM_COUNT; @@ -374,16 +377,35 @@ private TextView createItem(String title) { return text; } + /** On / active (D on, Q, U, the active slot): orange, unlike the blue focus (#114). */ + private static final int ACTIVE_BORDER = 0xFFFF9800; + private static final int ACTIVE_FILL = 0xFF4A2C00; + private static final int FOCUS_BORDER = Color.BLUE; + private final Set activeItems = new HashSet<>(); + private void highlightItem(TextView item) { - GradientDrawable bg = new GradientDrawable(); - bg.setColor(Color.BLACK); - bg.setStroke(2, Color.BLUE); - item.setBackground(bg); + activeItems.add(item); + paintItem(item, item.hasFocus()); } private void resetItem(TextView item) { item.setTextColor(Color.WHITE); - focusChange(item); + activeItems.remove(item); + paintItem(item, item.hasFocus()); + } + + /** + * Active items have an orange fill and border, the focused item a thick blue border; an + * item that is both keeps the orange fill under the blue border, so neither state hides. + */ + private void paintItem(View item, boolean focused) { + boolean active = activeItems.contains(item); + GradientDrawable bg = new GradientDrawable(); + bg.setColor(active ? ACTIVE_FILL : Color.BLACK); + if (focused) bg.setStroke(dp(2), FOCUS_BORDER); + else if (active) bg.setStroke(dp(2), ACTIVE_BORDER); + else bg.setStroke(1, Color.GRAY); + item.setBackground(bg); } private void applyQualityColor(TextView btn, int slot, boolean quadEnabled, @@ -459,15 +481,8 @@ void showUrlEditor(int mActive, String[] mHosts, Transport.Mode[] mTransports) { } private void focusChange(View item) { - GradientDrawable border = new GradientDrawable(); - border.setColor(Color.BLACK); - border.setStroke(1, Color.GRAY); - item.setBackground(border); - item.setOnFocusChangeListener((v, hasFocus) -> { - if (hasFocus) border.setStroke(1, Color.BLUE); - else border.setStroke(1, Color.GRAY); - v.setBackground(border); - }); + paintItem(item, false); + item.setOnFocusChangeListener((v, hasFocus) -> paintItem(v, hasFocus)); } @SuppressLint("SetJavaScriptEnabled")