Fix font scaling and update bookmark dialog layout #152
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Overview
This PR implements configuration overrides to prevent the GATB Reference Guide Android app from scaling with the device's font size and display size settings. The changes ensure a consistent UI experience across all devices regardless of user accessibility settings.
Problem
The app's UI was being affected by system-level font size and display size settings, causing:
Text elements expanding beyond their intended containers
Layout inconsistencies across different device configurations
UI elements being clipped or overlapping when users increase system font/display sizes
Inconsistent user experience as the app appearance varied based on device accessibility settings
Specifically, the bookmark success dialog's TextView was experiencing text overflow issues when system font sizes were increased, even with fixed dimensions and autoSizeTextType="none" set.
Solution
Implemented attachBaseContext() method overrides at both the Application and Activity levels to force a fixed font scale of 1.0, preventing the app from respecting system font and display size changes that way only the webview font size changes. This approach:
Application-level override: Ensures all activities and components use the fixed configuration
Activity-level override: Provides a secondary enforcement point for the main activity
Layout preservation: Maintains autoSizeTextType="none" in XML layouts as an additional safeguard
Code Changes
Added attachBaseContext() override to enforce fixed font scaling app-wide:
Key changes:
Added Context and Configuration imports
Implemented attachBaseContext() override
Created new Configuration object with fontScale = 1.0f
Applied configuration using createConfigurationContext()
2. Main Activity (MainActivity.kt)
Added attachBaseContext() override to MainActivity for consistent enforcement:
Key changes:
Added Context and Configuration imports
Implemented attachBaseContext() override before onCreate()
Same configuration override pattern as Application class
3. Bookmark Dialog Layout (dialog_bookmark_success.xml)
Maintained existing autoSizeTextType="none" attribute as an additional safeguard:
Note: The autoSizeTextType="none" attribute remains as a defense-in-depth measure, though the configuration overrides are the primary solution.
Testing
Default Device Settings:
Launch the app with default font and display size
Navigate through all screens (Home, Search, Settings, Chapters, Bookmarks)
Verify UI appears as expected
Bookmark an item and verify dialog displays correctly
Maximum Font Size:
Go to device Settings → Display → Font size
Set to maximum (largest)
Launch/restart the app
Expected: Text sizes remain unchanged from default
Navigate to bookmark dialog and verify text doesn't overflow
Check action bar titles, bottom navigation, and all text elements
Maximum Display Size:
Go to device Settings → Display → Display size
Set to maximum (largest)
Launch/restart the app
Expected: UI scaling remains consistent with default
Verify layouts maintain proper spacing and dimensions
Combined Maximum Settings:
Set both Font size and Display size to maximum
Launch/restart the app
Expected: App maintains default appearance
Test all major screens and dialogs
Verify no text clipping or layout issues
Minimum Settings:
Set Font size and Display size to minimum (smallest)
Launch/restart the app
Expected: App maintains default appearance
Verify readability is consistent
Configuration Changes: