Skip to content

Conversation

@sande11
Copy link

@sande11 sande11 commented Nov 17, 2025

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

  1. Application Class (App.kt)
    Added attachBaseContext() override to enforce fixed font scaling app-wide:
    override fun attachBaseContext(base: Context) {
        val configuration = Configuration(base.resources.configuration)
        configuration.fontScale = 1.0f
        super.attachBaseContext(base.createConfigurationContext(configuration))
    }

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:

  override fun attachBaseContext(newBase: Context) {
        val configuration = Configuration(newBase.resources.configuration)
        configuration.fontScale = 1.0f
        super.attachBaseContext(newBase.createConfigurationContext(configuration))
    }

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:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="281dp"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@drawable/bookmark_popup_background">

    <TextView
        android:id="@+id/bookmarked_text"
        android:layout_width="219dp"
        android:layout_height="82dp"
        android:layout_centerHorizontal="true"
        android:layout_alignParentTop="true"
        android:layout_marginTop="35dp"
        android:text="@string/bookmarked_message"
        android:textAppearance="@style/BookmarkedTextStyle"
        android:textColor="?attr/colorTextBlackWhite"
        android:autoSizeTextType="none" />

    <!-- ...buttons... -->
</RelativeLayout>

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:

Override attachBaseContext in App and MainActivity to enforce a fontScale of 1.0, preventing system font size changes from affecting the app. Simplify dialog_bookmark_success.xml by replacing the ScrollView with a single TextView and disabling auto-sizing for consistent appearance.
@sande11 sande11 requested a review from MaxwellKJr November 17, 2025 08:45
@sande11 sande11 self-assigned this Nov 17, 2025
@sande11 sande11 linked an issue Nov 17, 2025 that may be closed by this pull request
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.

Bookmark container doesn’t expand with content

2 participants