New feature “Text and reading options” for SetupWizard, Wallpaper, and Settings (14/n).
- Link-up between the ResetPreference and the FontWeightAdjustmentPreference. Bug: 211503117 Test: atest FontWeightAdjustmentPreferenceControllerTest Change-Id: Iabf585660ff2c67f063198391bd68724190ba54d
This commit is contained in:
@@ -49,8 +49,7 @@
|
|||||||
android:key="toggle_force_bold_text"
|
android:key="toggle_force_bold_text"
|
||||||
android:persistent="false"
|
android:persistent="false"
|
||||||
android:title="@string/force_bold_text"
|
android:title="@string/force_bold_text"
|
||||||
settings:keywords="@string/keywords_bold_text"
|
settings:keywords="@string/keywords_bold_text" />
|
||||||
settings:controller="com.android.settings.accessibility.FontWeightAdjustmentPreferenceController"/>
|
|
||||||
|
|
||||||
<SwitchPreference
|
<SwitchPreference
|
||||||
android:key="toggle_high_text_contrast_preference"
|
android:key="toggle_high_text_contrast_preference"
|
||||||
|
@@ -24,7 +24,8 @@ import com.android.settings.R;
|
|||||||
import com.android.settings.core.TogglePreferenceController;
|
import com.android.settings.core.TogglePreferenceController;
|
||||||
|
|
||||||
/** PreferenceController for displaying all text in bold. */
|
/** PreferenceController for displaying all text in bold. */
|
||||||
public class FontWeightAdjustmentPreferenceController extends TogglePreferenceController {
|
public class FontWeightAdjustmentPreferenceController extends TogglePreferenceController implements
|
||||||
|
TextReadingResetController.ResetStateListener {
|
||||||
static final int BOLD_TEXT_ADJUSTMENT =
|
static final int BOLD_TEXT_ADJUSTMENT =
|
||||||
FontStyle.FONT_WEIGHT_BOLD - FontStyle.FONT_WEIGHT_NORMAL;
|
FontStyle.FONT_WEIGHT_BOLD - FontStyle.FONT_WEIGHT_NORMAL;
|
||||||
|
|
||||||
@@ -53,4 +54,9 @@ public class FontWeightAdjustmentPreferenceController extends TogglePreferenceCo
|
|||||||
public int getSliceHighlightMenuRes() {
|
public int getSliceHighlightMenuRes() {
|
||||||
return R.string.menu_key_accessibility;
|
return R.string.menu_key_accessibility;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void resetState() {
|
||||||
|
setChecked(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -42,6 +42,7 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
|||||||
private static final String DISPLAY_SIZE_KEY = "display_size";
|
private static final String DISPLAY_SIZE_KEY = "display_size";
|
||||||
private static final String PREVIEW_KEY = "preview";
|
private static final String PREVIEW_KEY = "preview";
|
||||||
private static final String RESET_KEY = "reset";
|
private static final String RESET_KEY = "reset";
|
||||||
|
private static final String BOLD_TEXT_KEY = "toggle_force_bold_text";
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected int getPreferenceScreenResId() {
|
protected int getPreferenceScreenResId() {
|
||||||
@@ -78,6 +79,10 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
|||||||
displaySizeController.setInteractionListener(previewController);
|
displaySizeController.setInteractionListener(previewController);
|
||||||
controllers.add(displaySizeController);
|
controllers.add(displaySizeController);
|
||||||
|
|
||||||
|
final FontWeightAdjustmentPreferenceController fontWeightController =
|
||||||
|
new FontWeightAdjustmentPreferenceController(context, BOLD_TEXT_KEY);
|
||||||
|
controllers.add(fontWeightController);
|
||||||
|
|
||||||
final List<ResetStateListener> resetStateListeners =
|
final List<ResetStateListener> resetStateListeners =
|
||||||
controllers.stream().filter(c -> c instanceof ResetStateListener).map(
|
controllers.stream().filter(c -> c instanceof ResetStateListener).map(
|
||||||
c -> (ResetStateListener) c).collect(Collectors.toList());
|
c -> (ResetStateListener) c).collect(Collectors.toList());
|
||||||
|
@@ -31,6 +31,9 @@ import org.junit.Before;
|
|||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tests for {@link FontWeightAdjustmentPreferenceController}.
|
||||||
|
*/
|
||||||
@RunWith(AndroidJUnit4.class)
|
@RunWith(AndroidJUnit4.class)
|
||||||
public class FontWeightAdjustmentPreferenceControllerTest {
|
public class FontWeightAdjustmentPreferenceControllerTest {
|
||||||
private static final int ON = FontWeightAdjustmentPreferenceController.BOLD_TEXT_ADJUSTMENT;
|
private static final int ON = FontWeightAdjustmentPreferenceController.BOLD_TEXT_ADJUSTMENT;
|
||||||
@@ -91,4 +94,14 @@ public class FontWeightAdjustmentPreferenceControllerTest {
|
|||||||
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
Settings.Secure.FONT_WEIGHT_ADJUSTMENT, OFF)).isEqualTo(OFF);
|
Settings.Secure.FONT_WEIGHT_ADJUSTMENT, OFF)).isEqualTo(OFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void resetState_shouldDisableBoldText() {
|
||||||
|
mController.setChecked(true);
|
||||||
|
|
||||||
|
mController.resetState();
|
||||||
|
|
||||||
|
assertThat(Settings.Secure.getInt(mContext.getContentResolver(),
|
||||||
|
Settings.Secure.FONT_WEIGHT_ADJUSTMENT, OFF)).isEqualTo(OFF);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user