New feature “Text and reading options” for SetupWizard, Wallpaper, and Settings (12/n).

- Link-up between the preview, font size, and display size preferences.
- Add the preview preference and entry.

Bug: 211503117
Test: make RunSettingsRoboTests ROBOTEST_FILTER=TextReadingPreviewControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=TextReadingPreviewPreferenceTest
Change-Id: Ic6c48861a0051670fd78b13dca5488711de30cb8
This commit is contained in:
Peter_Liang
2022-01-27 15:37:36 +08:00
parent 0eee699438
commit edb52508d3
7 changed files with 386 additions and 11 deletions

View File

@@ -32,8 +32,9 @@ import com.android.settings.widget.DotsPageIndicator;
/**
* A {@link Preference} that could show the preview related to the text and reading options.
*/
final class TextReadingPreviewPreference extends Preference {
public class TextReadingPreviewPreference extends Preference {
private int mCurrentItem;
private int mLastLayerIndex;
private PreviewPagerAdapter mPreviewAdapter;
TextReadingPreviewPreference(Context context) {
@@ -41,7 +42,7 @@ final class TextReadingPreviewPreference extends Preference {
init();
}
TextReadingPreviewPreference(Context context, AttributeSet attrs) {
public TextReadingPreviewPreference(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
@@ -120,4 +121,16 @@ final class TextReadingPreviewPreference extends Preference {
private void init() {
setLayoutResource(R.layout.accessibility_text_reading_preview);
}
void notifyPreviewPagerChanged(int pagerIndex) {
Preconditions.checkNotNull(mPreviewAdapter,
"Preview adapter is null, you should init the preview adapter first");
if (pagerIndex != mLastLayerIndex) {
mPreviewAdapter.setPreviewLayer(pagerIndex, mLastLayerIndex, getCurrentItem(),
/* animate= */ false);
}
mLastLayerIndex = pagerIndex;
}
}