Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f19f710b authored by Candice Lo's avatar Candice Lo
Browse files

Set the settings key when the font size is changed

The key ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED will be always ON
after users modify the font size for the first time.

Bug: 269679768
Test: make RunSettingsRoboTests ROBOTEST_FILTER=FontSizeDataTest
Change-Id: I5967227ce05d5b8bf37dfec9aafa015c5cacbd30
Merged-In: I382e4ecd3c335d7b046f157cedc093fc40c3a77a
parent 1fc651ae
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.settings.accessibility;

import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;
import static com.android.settings.display.ToggleFontSizePreferenceFragment.fontSizeValueToIndex;

import android.content.ContentResolver;
@@ -52,6 +54,12 @@ final class FontSizeData extends PreviewSizeData<Float> {
    @Override
    void commit(int currentProgress) {
        final ContentResolver resolver = getContext().getContentResolver();
        if (Settings.Secure.getInt(resolver,
                Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED,
                /* def= */ OFF) != ON) {
            Settings.Secure.putInt(resolver,
                    Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, ON);
        }
        Settings.System.putFloat(resolver, Settings.System.FONT_SCALE,
                getValues().get(currentProgress));
    }
+18 −0
Original line number Diff line number Diff line
@@ -16,6 +16,9 @@

package com.android.settings.accessibility;

import static com.android.settings.accessibility.AccessibilityUtil.State.OFF;
import static com.android.settings.accessibility.AccessibilityUtil.State.ON;

import static com.google.common.truth.Truth.assertThat;

import android.content.Context;
@@ -52,4 +55,19 @@ public class FontSizeDataTest {

        assertThat(currentScale).isEqualTo(mFontSizeData.getValues().get(progress));
    }

    @Test
    public void commit_fontScalingHasBeenChangedIsOn() {
        final int progress = 3;
        Settings.Secure.putInt(mContext.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED, OFF);

        mFontSizeData.commit(progress);
        final int currentSettings = Settings.Secure.getInt(
                mContext.getContentResolver(),
                Settings.Secure.ACCESSIBILITY_FONT_SCALING_HAS_BEEN_CHANGED,
                /* def= */ OFF);

        assertThat(currentSettings).isEqualTo(ON);
    }
}