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

Commit 37704520 authored by Massimo Carli's avatar Massimo Carli
Browse files

Use custom default font_scale behing flag

When the flag is enabled, we read the default
font scale value from the device_font_scale
property in Settings.

Flag: ACONFIG com.android.window.flags.configurable_font_scale_default DEVELOPMENT
Bug: 316160749
Test: atest SettingsRoboTests:FontSizeDataTest

Change-Id: I03a5ee9a2bd364dca9c75b131832e5f9e868167a
parent 495ab9d0
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -25,6 +25,7 @@ import android.content.res.Resources;
import android.provider.Settings;

import com.android.settingslib.R;
import com.android.window.flags.Flags;

import java.util.Arrays;
import java.util.List;
@@ -38,12 +39,11 @@ final class FontSizeData extends PreviewSizeData<Float> {

    FontSizeData(Context context) {
        super(context);

        final Resources resources = getContext().getResources();
        final ContentResolver resolver = getContext().getContentResolver();
        final List<String> strEntryValues =
                Arrays.asList(resources.getStringArray(R.array.entryvalues_font_size));
        setDefaultValue(FONT_SCALE_DEF_VALUE);
        setDefaultValue(getFontScaleDefValue(resolver));
        final float currentScale =
                Settings.System.getFloat(resolver, Settings.System.FONT_SCALE, getDefaultValue());
        setInitialIndex(fontSizeValueToIndex(currentScale, strEntryValues.toArray(new String[0])));
@@ -78,4 +78,10 @@ final class FontSizeData extends PreviewSizeData<Float> {
        }
        return indices.length - 1;
    }

    private float getFontScaleDefValue(ContentResolver resolver) {
        return Flags.configurableFontScaleDefault() ? Settings.System.getFloat(resolver,
                Settings.System.DEFAULT_DEVICE_FONT_SCALE, FONT_SCALE_DEF_VALUE)
                : FONT_SCALE_DEF_VALUE;
    }
}