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

Commit f71050b5 authored by Peter_Liang's avatar Peter_Liang
Browse files

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

- Add the ResetPreference for controlling all preferences state in the text and reading options page.
1) Create a new interface ResetStateListener for the other preferences.

- Link-up between the reset, font size, and display size preferences.

Bug: 211503117
Test: make RunSettingsRoboTests ROBOTEST_FILTER=PreviewSizeSeekBarControllerTest
Test: make RunSettingsRoboTests ROBOTEST_FILTER=TextReadingResetControllerTest
Change-Id: Ida773967834e32737b1daac885a2dd71189d32c8
parent edb52508
Loading
Loading
Loading
Loading
+25 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2022 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<shape
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:androidprv="http://schemas.android.com/apk/prv/res/android"
    android:shape="rectangle">

    <corners android:radius="100dp" />
    <solid android:color="?androidprv:attr/colorAccentPrimary" />
</shape>
+36 −0
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<!--
    Copyright (C) 2022 The Android Open Source Project

    Licensed under the Apache License, Version 2.0 (the "License");
    you may not use this file except in compliance with the License.
    You may obtain a copy of the License at

         http://www.apache.org/licenses/LICENSE-2.0

    Unless required by applicable law or agreed to in writing, software
    distributed under the License is distributed on an "AS IS" BASIS,
    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    See the License for the specific language governing permissions and
    limitations under the License.
-->

<FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:minHeight="?android:attr/listPreferredItemHeight"
    android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
    android:paddingStart="?android:attr/listPreferredItemPaddingStart">

    <Button
        android:id="@+id/reset_button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:background="@drawable/accessibility_text_reading_reset_button_background"
        android:paddingHorizontal="24dp"
        android:paddingVertical="14dp"
        android:text="@string/accessibility_text_reading_reset_button_title"
        android:textAppearance="?android:attr/textAppearanceMedium" />
</FrameLayout>
+2 −0
Original line number Diff line number Diff line
@@ -5233,6 +5233,8 @@
    <string name="accessibility_text_reading_preview_mail_from">From: bill@email.com</string>
    <!-- Content for the mail content of the accessibility text reading preview. [CHAR LIMIT=NONE] -->
    <string name="accessibility_text_reading_preview_mail_content">Good morning! Following up on our last conversation, I’d like to check in on the progress of your time machine development plan. Will you be able to have a prototype ready to demo at E3 this year?</string>
    <!-- Title for the reset button of the accessibility text reading page to reset all preferences state. [CHAR LIMIT=NONE] -->
    <string name="accessibility_text_reading_reset_button_title">Reset</string>
    <!-- Title for the footer text to explain what option accessibility service does. [CHAR LIMIT=35] -->
    <string name="accessibility_screen_option">Options</string>
    <!-- Summary for the accessibility preference to enable screen magnification. [CHAR LIMIT=25] -->
+6 −0
Original line number Diff line number Diff line
@@ -57,4 +57,10 @@
        android:persistent="false"
        android:title="@string/accessibility_toggle_high_text_contrast_preference_title"
        settings:controller="com.android.settings.accessibility.HighTextContrastPreferenceController"/>

    <com.android.settingslib.widget.LayoutPreference
        android:key="reset"
        android:layout="@layout/accessibility_text_reading_reset_button"
        android:persistent="false"
        android:selectable="false" />
</PreferenceScreen>
+13 −7
Original line number Diff line number Diff line
@@ -29,10 +29,12 @@ import com.android.settings.widget.LabeledSeekBarPreference;
 * The controller of {@link LabeledSeekBarPreference} that listens to display size and font size
 * settings changes and updates preview size threshold smoothly.
 */
class PreviewSizeSeekBarController extends BasePreferenceController {
class PreviewSizeSeekBarController extends BasePreferenceController implements
        TextReadingResetController.ResetStateListener {
    private final PreviewSizeData<? extends Number> mSizeData;
    private boolean mSeekByTouch;
    private ProgressInteractionListener mInteractionListener;
    private LabeledSeekBarPreference mSeekBarPreference;

    private final SeekBar.OnSeekBarChangeListener mSeekBarChangeListener =
            new SeekBar.OnSeekBarChangeListener() {
@@ -81,13 +83,17 @@ class PreviewSizeSeekBarController extends BasePreferenceController {

        final int dataSize = mSizeData.getValues().size();
        final int initialIndex = mSizeData.getInitialIndex();
        final LabeledSeekBarPreference seekBarPreference =
                screen.findPreference(getPreferenceKey());
        mSeekBarPreference = screen.findPreference(getPreferenceKey());
        mSeekBarPreference.setMax(dataSize - 1);
        mSeekBarPreference.setProgress(initialIndex);
        mSeekBarPreference.setContinuousUpdates(true);
        mSeekBarPreference.setOnSeekBarChangeListener(mSeekBarChangeListener);
    }

        seekBarPreference.setMax(dataSize - 1);
        seekBarPreference.setProgress(initialIndex);
        seekBarPreference.setContinuousUpdates(true);
        seekBarPreference.setOnSeekBarChangeListener(mSeekBarChangeListener);
    @Override
    public void resetState() {
        final int defaultProgress = mSizeData.getValues().indexOf(mSizeData.getDefaultValue());
        mSeekBarPreference.setProgress(defaultProgress);
    }

    /**
Loading