Skip to content

Add font preview to font preference picker dialog#101

Open
RobinJ1995 wants to merge 1 commit into
masterfrom
claude/font-preview-selection-rwgh4n
Open

Add font preview to font preference picker dialog#101
RobinJ1995 wants to merge 1 commit into
masterfrom
claude/font-preview-selection-rwgh4n

Conversation

@RobinJ1995

Copy link
Copy Markdown
Owner

Summary

Implemented a custom font preference dialog that previews each available font option in its own typeface, allowing users to see what each font looks like before selecting it.

Key Changes

  • New FontListPreferenceDialogFragment class: Custom dialog fragment that extends FrostedListPreferenceDialogFragment and renders each font option in its corresponding typeface

    • Uses a custom ArrayAdapter to apply the appropriate Typeface to each list item
    • Implements single-choice selection with immediate dismiss on selection (matching standard ListPreference behavior)
    • Properly handles preference value persistence through onDialogClosed()
  • New typefaceFor() method in FontPreference: Public utility function that resolves a typeface for any given font preference value, independent of the currently stored preference

    • Enables the picker to render each option in its own font without affecting the active preference
    • Returns null for system/unknown values to use the device default font
  • Updated PreferencesActivity.onDisplayPreferenceDialog(): Routes font preference dialogs to the new FontListPreferenceDialogFragment while keeping other list preferences on the standard FrostedListPreferenceDialogFragment

Implementation Details

  • The custom dialog replicates the framework's ListPreferenceDialogFragmentCompat select-and-persist flow because the base class uses private fields that can't be accessed
  • Each list item is rendered using the font it represents, providing an immediate visual preview
  • The "System default" option preserves the device font by returning null from typefaceFor()

https://claude.ai/code/session_017QpoubQoCriCnSKSB4Avxx

The Appearance font picker is a ListPreference dialog whose rows were all
drawn in the current app font. Render each option in the font it names
(Ubuntu row in Ubuntu, Oxygen in Oxygen, OpenDyslexic in OpenDyslexic;
System default stays the device font) so the user previews a font while
choosing it.

Adds FontListPreferenceDialogFragment, a frosted list-preference dialog
that installs a custom single-choice adapter applying the per-option
typeface, and routes the "font" preference to it. FontPreference gains
typefaceFor(context, value) to resolve any option's typeface.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
Claude-Session: https://claude.ai/code/session_017QpoubQoCriCnSKSB4Avxx
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.

2 participants