Skip to content

fix: make icon/folder rename dialog follow system light/dark theme#413

Open
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/issue-198
Open

fix: make icon/folder rename dialog follow system light/dark theme#413
MiMoHo wants to merge 1 commit into
FossifyOrg:mainfrom
MiMoHo:fix/issue-198

Conversation

@MiMoHo

@MiMoHo MiMoHo commented Jul 3, 2026

Copy link
Copy Markdown

Type of change(s)

  • Bug fix

What changed and why

The folder/icon rename dialog showed dark text on a dark background in light system mode (dark mode was fine), making it unreadable.

Root cause is a dialog surface/text-color mismatch, not a hardcoded text color:

  • MainActivity (which opens the rename dialog) is declared with android:theme="@style/LauncherTheme", whose parent is Theme.Material3.Dark.NoActionBar — a forced-dark theme so the launcher can draw a transparent window over the wallpaper. MainActivity.onCreate also sets useDynamicTheme = false, so BaseSimpleActivity never calls setTheme(getThemeId(...)) to switch to a light theme. The activity theme is therefore dark regardless of system mode.
  • On Android 12+ isDynamicTheme() defaults to true, so commons' getAlertDialogBuilder() returns MaterialAlertDialogBuilder(activity), inheriting that forced-dark context. LauncherTheme does not define materialAlertDialogTheme/colorSurface, so the dialog surface stays the default Material3 dark surface even in light mode.
  • The dialog text uses getProperTextColor() (you_neutral_text_color), which is dark in day / light in night. Light mode therefore renders dark text on a dark surface = unreadable; dark mode renders light text on dark = fine.

Fix: in the dynamic-theme path, build the dialog from a ContextThemeWrapper carrying the proper day/night theme (activity.getThemeId()), so the Material dialog surface follows the system light/dark mode. This mirrors the precedent MainActivity already uses for its popup menu (ContextThemeWrapper(this, getPopupMenuTheme())). getThemeId() resolves to AppTheme.Base.System.Light in light mode / AppTheme.Base.System in dark mode, both of which set materialAlertDialogTheme and colorSurface=you_dialog_background_color (day/night). The non-dynamic path is left byte-for-byte identical (it already sets an explicit window background and renders correctly). MaterialAlertDialogBuilder subclasses androidx.appcompat.app.AlertDialog.Builder, so setupDialogStuff(view, this, ...) still type-checks.

Tests performed

Built the fossDebug variant and verified on an Android 15 (API 35) emulator:

Set Fossify as home app; forced light mode; long-pressed Phone icon -> Rename. Dialog shows light surface with dark readable 'Phone' text (fixed). Forced dark mode, reopened Rename -> dark surface with light readable text (not regressed).

Also confirmed detekt, lint, unit tests and the build all pass locally (CI-equivalent).

Closes the following issue(s)

Checklist

  • I read the contribution guidelines.
  • I manually tested my changes on device/emulator.
  • I updated the "Unreleased" section in CHANGELOG.md (if applicable).
  • I have self-reviewed my pull request (no typos, formatting errors, etc.).
  • I understand every change in this pull request.

Coded with Opus 4.8 ultracode.

MainActivity uses the forced-dark LauncherTheme so it can draw over the wallpaper. The rename dialog inherited that context, so under dynamic theming the Material dialog surface stayed dark even in light mode, rendering the dark getProperTextColor() text unreadable on a dark background.

Build the dialog from a ContextThemeWrapper carrying the proper day/night theme (getThemeId()) in the dynamic-theme path, mirroring the existing getPopupMenuTheme() precedent, so the dialog surface tracks the system mode. The non-dynamic path is left unchanged.

Closes FossifyOrg#198
@MiMoHo
MiMoHo requested a review from naveensingh as a code owner July 3, 2026 21:29
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.

Folder rename dialog: Dark text on dark background

1 participant