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

Commit 2e803bab authored by Sally Yuen's avatar Sally Yuen Committed by Android (Google) Code Review
Browse files

Merge changes from topic "a11y_config_bold"

* changes:
  Change forceBoldText to fontWeightAdjustment in TextView
  Change forceBoldText to fontWeightAdjustment in Settings
  Change forceBoldText to fontWeightAdjustment in ActivityTaskManagerService
parents 67bf1480 ba819fce
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -3580,8 +3580,9 @@ public final class Settings {
            if (outConfig.fontScale < 0) {
                outConfig.fontScale = DEFAULT_FONT_SCALE;
            }
            outConfig.forceBoldText = Settings.Secure.getIntForUser(
                    cr, Settings.Secure.FORCE_BOLD_TEXT, Configuration.FORCE_BOLD_TEXT_NO,
            outConfig.fontWeightAdjustment = Settings.Secure.getIntForUser(
                    cr, Settings.Secure.FONT_WEIGHT_ADJUSTMENT,
                    Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED,
                    userHandle);
            final String localeValue =
@@ -3613,7 +3614,7 @@ public final class Settings {
            if (!inoutConfig.userSetLocale && !inoutConfig.getLocales().isEmpty()) {
                inoutConfig.clearLocales();
            }
            inoutConfig.forceBoldText = Configuration.FORCE_BOLD_TEXT_UNDEFINED;
            inoutConfig.fontWeightAdjustment = Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED;
        }
        /**
@@ -6814,17 +6815,16 @@ public final class Settings {
        public static final String KEYGUARD_SLICE_URI = "keyguard_slice_uri";
        /**
         * Whether to draw text in bold.
         * The adjustment in font weight. This is used to draw text in bold.
         *
         * <p>Values:
         *  1 - Text is not displayed in bold. (Default)
         *  2 - Text is displayed in bold.
         * <p> This value can be negative. To display bolded text, the adjustment used is 300,
         * which is the difference between
         * {@link android.graphics.fonts.FontStyle#FONT_WEIGHT_NORMAL} and
         * {@link android.graphics.fonts.FontStyle#FONT_WEIGHT_BOLD}.
         *
         * @see Configuration#FORCE_BOLD_TEXT_NO
         * @see Configuration#FORCE_BOLD_TEXT_YES
         * @hide
         */
        public static final String FORCE_BOLD_TEXT = "force_bold_text";
        public static final String FONT_WEIGHT_ADJUSTMENT = "font_weight_adjustment";
        /**
         * Whether to speak passwords while in accessibility mode.
+18 −16
Original line number Diff line number Diff line
@@ -742,8 +742,9 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    private boolean mLocalesChanged = false;
    private int mTextSizeUnit = -1;
    // True if force bold text feature is enabled. This feature makes all text bolder.
    private boolean mForceBoldTextEnabled;
    // This is used to reflect the current user preference for changing font weight and making text
    // more bold.
    private int mFontWeightAdjustment;
    private Typeface mOriginalTypeface;
    // True if setKeyListener() has been explicitly called
@@ -1647,8 +1648,7 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
            attributes.mTypefaceIndex = MONOSPACE;
        }
        mForceBoldTextEnabled = getContext().getResources().getConfiguration().forceBoldText
                == Configuration.FORCE_BOLD_TEXT_YES;
        mFontWeightAdjustment = getContext().getResources().getConfiguration().fontWeightAdjustment;
        applyTextAppearance(attributes);
        if (isPassword) {
@@ -4273,12 +4273,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
                invalidate();
            }
        }
        if (newConfig.forceBoldText == Configuration.FORCE_BOLD_TEXT_YES) {
            mForceBoldTextEnabled = true;
            setTypeface(getTypeface());
        } else  if (newConfig.forceBoldText == Configuration.FORCE_BOLD_TEXT_NO
                || newConfig.forceBoldText == Configuration.FORCE_BOLD_TEXT_UNDEFINED) {
            mForceBoldTextEnabled = false;
        if (mFontWeightAdjustment != newConfig.fontWeightAdjustment) {
            mFontWeightAdjustment = newConfig.fontWeightAdjustment;
            setTypeface(getTypeface());
        }
    }
@@ -4433,13 +4429,19 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
     */
    public void setTypeface(@Nullable Typeface tf) {
        mOriginalTypeface = tf;
        if (mForceBoldTextEnabled) {
            int newWeight = tf != null ? tf.getWeight() + 300 : 400;
            newWeight = Math.min(newWeight, 1000);
        if (mFontWeightAdjustment != 0
                && mFontWeightAdjustment != Configuration.FONT_WEIGHT_ADJUSTMENT_UNDEFINED) {
            if (tf == null) {
                tf = Typeface.DEFAULT;
            } else {
                int newWeight = Math.min(
                        Math.max(tf.getWeight() + mFontWeightAdjustment, FontStyle.FONT_WEIGHT_MIN),
                        FontStyle.FONT_WEIGHT_MAX);
                int typefaceStyle = tf != null ? tf.getStyle() : 0;
                boolean italic = (typefaceStyle & Typeface.ITALIC) != 0;
                tf = Typeface.create(tf, newWeight, italic);
            }
        }
        if (mTextPaint.getTypeface() != tf) {
            mTextPaint.setTypeface(tf);
+1 −1
Original line number Diff line number Diff line
@@ -229,7 +229,7 @@ message SecureSettingsProto {

    optional SettingProto enhanced_voice_privacy_enabled = 23 [ (android.privacy).dest = DEST_AUTOMATIC ];

    optional SettingProto force_bold_text = 85 [ (android.privacy).dest = DEST_AUTOMATIC ];
    optional SettingProto font_weight_adjustment = 85 [ (android.privacy).dest = DEST_AUTOMATIC ];

    message Gesture {
        optional SettingProto aware_enabled = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public class SecureSettings {
        Settings.Secure.ACCESSIBILITY_CAPTIONING_TYPEFACE,
        Settings.Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE,
        Settings.Secure.ACCESSIBILITY_CAPTIONING_WINDOW_COLOR,
        Settings.Secure.FORCE_BOLD_TEXT,
        Settings.Secure.FONT_WEIGHT_ADJUSTMENT,
        Settings.Secure.REDUCE_BRIGHT_COLORS_LEVEL,
        Settings.Secure.REDUCE_BRIGHT_COLORS_PERSIST_ACROSS_REBOOTS,
        Settings.Secure.TTS_DEFAULT_RATE,
+1 −1
Original line number Diff line number Diff line
@@ -102,7 +102,7 @@ public class SecureSettingsValidators {
                Secure.ACCESSIBILITY_CAPTIONING_FONT_SCALE,
                new InclusiveFloatRangeValidator(0.5f, 2.0f));
        VALIDATORS.put(Secure.ACCESSIBILITY_CAPTIONING_WINDOW_COLOR, ANY_INTEGER_VALIDATOR);
        VALIDATORS.put(Secure.FORCE_BOLD_TEXT, new DiscreteValueValidator(new String[] {"1", "2"}));
        VALIDATORS.put(Secure.FONT_WEIGHT_ADJUSTMENT, ANY_INTEGER_VALIDATOR);
        VALIDATORS.put(Secure.REDUCE_BRIGHT_COLORS_LEVEL, PERCENTAGE_INTEGER_VALIDATOR);
        VALIDATORS.put(Secure.REDUCE_BRIGHT_COLORS_PERSIST_ACROSS_REBOOTS, BOOLEAN_VALIDATOR);
        VALIDATORS.put(Secure.TTS_DEFAULT_RATE, NON_NEGATIVE_INTEGER_VALIDATOR);
Loading