Change on/off values for Force Bold Text

Use On = 300 and Off = 0. Rename setting.

Bug: b/170966021, b/110991537
Test: builds and toggle works, atest
FontWeightAdjustmentPreferenceControllerTest

Change-Id: Icf5d15fc26266578ad78bae5b6f80d193e63c82d
This commit is contained in:
Sally
2020-11-03 18:12:53 +00:00
parent 76eb401911
commit 12f2d67fea
3 changed files with 22 additions and 23 deletions

View File

@@ -17,15 +17,17 @@
package com.android.settings.accessibility;
import android.content.Context;
import android.content.res.Configuration;
import android.graphics.fonts.FontStyle;
import android.provider.Settings;
import com.android.settings.core.TogglePreferenceController;
/** PreferenceController for displaying all text in bold. */
public class ForceBoldTextPreferenceController extends TogglePreferenceController {
public class FontWeightAdjustmentPreferenceController extends TogglePreferenceController {
static final int BOLD_TEXT_ADJUSTMENT =
FontStyle.FONT_WEIGHT_BOLD - FontStyle.FONT_WEIGHT_NORMAL;
public ForceBoldTextPreferenceController(Context context, String preferenceKey) {
public FontWeightAdjustmentPreferenceController(Context context, String preferenceKey) {
super(context, preferenceKey);
}
@@ -37,14 +39,12 @@ public class ForceBoldTextPreferenceController extends TogglePreferenceControlle
@Override
public boolean isChecked() {
return Settings.Secure.getInt(mContext.getContentResolver(),
Settings.Secure.FORCE_BOLD_TEXT, Configuration.FORCE_BOLD_TEXT_NO)
== Configuration.FORCE_BOLD_TEXT_YES;
Settings.Secure.FONT_WEIGHT_ADJUSTMENT, 0) == BOLD_TEXT_ADJUSTMENT;
}
@Override
public boolean setChecked(boolean isChecked) {
return Settings.Secure.putInt(mContext.getContentResolver(),
Settings.Secure.FORCE_BOLD_TEXT,
(isChecked ? Configuration.FORCE_BOLD_TEXT_YES : Configuration.FORCE_BOLD_TEXT_NO));
Settings.Secure.FONT_WEIGHT_ADJUSTMENT, (isChecked ? BOLD_TEXT_ADJUSTMENT : 0));
}
}