Skip to content

Fix low-contrast selected item in dropdown menus#40

Merged
hawkff merged 2 commits into
mainfrom
fix/dropdown-selected-contrast
Jun 20, 2026
Merged

Fix low-contrast selected item in dropdown menus#40
hawkff merged 2 commits into
mainfrom
fix/dropdown-selected-contrast

Conversation

@hawkff

@hawkff hawkff commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes a low-contrast bug in the SimpleMenuPreference dropdown menus (e.g. Night mode, Service mode, Language). The selected item was filled with an opaque colorMaterial100 — a very light per-theme tint (Dracula #E9DDFB, VerdantMint mint-100, etc.) — while the item's CheckedTextView text stays light. Light text on a light fill made the selected option hard to read, across all themes (worst on dark themes).

Fix

Highlight the selected row with a translucent colorPrimary (~20% alpha) instead of the opaque light fill. This reads clearly on any popup background and keeps the existing text color legible. Matches the pattern already used in nav_item_fill.xml (?colorPrimary @ 0.16 alpha) and ConfigurationFragment (ColorUtils.setAlphaComponent(primary, 26)).

Single-file change in SimpleMenuPreference.kt; applies to every theme.

Testing

  • assembleOssDebug builds clean.
  • Installed on device (arm64-v8a, API 33). Note: visual confirmation of the dropdown popup is pending — device was locked at build time, so the rendered popup hasn't been screenshotted yet.

Not for merge yet — pending visual review on device.

Greptile Summary

Fixes a low-contrast bug in SimpleMenuPreference dropdown menus by swapping the selected-item background from an opaque colorMaterial100 tint to a translucent colorPrimary at alpha 41 (~16%), matching the nav_item_fill.xml pattern used in the navigation drawer.

  • The selectedColor value is now computed via ColorUtils.setAlphaComponent(colorPrimary, 41) and the corresponding androidx.core.graphics.ColorUtils import is added.
  • The fix applies uniformly across all four GradientDrawable shapes (topDrawable, bottomDrawable, middleDrawable, singleDrawable), covering every positional highlight case.

Confidence Score: 5/5

Single-file cosmetic change that swaps one color constant; no logic, state, or API surface is touched.

The change is minimal and self-contained: only the selectedColor initializer and one import are modified. The four shared GradientDrawable instances are pre-existing and unaffected structurally. No runtime paths, data flow, or external contracts change.

No files require special attention.

Important Files Changed

Filename Overview
app/src/main/java/moe/matsuri/nb4a/ui/SimpleMenuPreference.kt Replaces opaque colorMaterial100 selected-item fill with a translucent colorPrimary (alpha 41, ~16%) to fix low-contrast text on dark themes; only the block comment's alpha description is slightly stale.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A["getDropDownView(position, ...)"] --> B{position == currentPosition?}
    B -- No --> C[view.background = null]
    B -- Yes --> D{position shape?}
    D -- "count == 1" --> E[singleDrawable\nall corners rounded]
    D -- "position == 0" --> F[topDrawable\ntop corners rounded]
    D -- "position == count-1" --> G[bottomDrawable\nbottom corners rounded]
    D -- else --> H[middleDrawable\nno rounded corners]
    E & F & G & H --> I["GradientDrawable\nfill = ColorUtils.setAlphaComponent(colorPrimary, 41)\n≈ 16% alpha"]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A["getDropDownView(position, ...)"] --> B{position == currentPosition?}
    B -- No --> C[view.background = null]
    B -- Yes --> D{position shape?}
    D -- "count == 1" --> E[singleDrawable\nall corners rounded]
    D -- "position == 0" --> F[topDrawable\ntop corners rounded]
    D -- "position == count-1" --> G[bottomDrawable\nbottom corners rounded]
    D -- else --> H[middleDrawable\nno rounded corners]
    E & F & G & H --> I["GradientDrawable\nfill = ColorUtils.setAlphaComponent(colorPrimary, 41)\n≈ 16% alpha"]
Loading

Reviews (2): Last reviewed commit: "Align dropdown highlight alpha with nav_..." | Re-trigger Greptile

The SimpleMenuPreference dropdown filled the selected row with an opaque
colorMaterial100 (a very light per-theme tint, e.g. Dracula #E9DDFB). The
item's CheckedTextView text stays light, so light-on-light made the selected
option hard to read across themes (worst on dark themes).

Highlight the selected row with a translucent colorPrimary (~20% alpha)
instead, matching the existing nav_item_fill / ConfigurationFragment pattern.
This reads on any background and keeps the text legible. Affects all themes.
@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@hawkff, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 8 minutes and 23 seconds. Learn how PR review limits work.

Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file).

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 3e10f1fa-9487-4c7a-b932-a74d6dbd0ff8

📥 Commits

Reviewing files that changed from the base of the PR and between a7fe7a2 and 0ddab08.

📒 Files selected for processing (1)
  • app/src/main/java/moe/matsuri/nb4a/ui/SimpleMenuPreference.kt

Comment @coderabbitai help to get the list of available commands and usage tips.

Comment thread app/src/main/java/moe/matsuri/nb4a/ui/SimpleMenuPreference.kt
Use alpha 41 (0.16) to match the navigation drawer's checked-item highlight
(nav_item_fill.xml) for a consistent selected-item visual language across the
app. Addresses Greptile P2.
@hawkff hawkff merged commit 901529c into main Jun 20, 2026
5 checks passed
@hawkff hawkff deleted the fix/dropdown-selected-contrast branch June 20, 2026 05:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant