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

Commit 6123cb9a authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "[Catalyst] Refactor some Text Reading items" into main

parents 224988e2 a02483ad
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
    static final String RESET_KEY = "reset";
    static final String PREVIEW_KEY = "preview";
    private static final String NEED_RESET_SETTINGS = "need_reset_settings";
    private static final String LAST_PREVIEW_INDEX = "last_preview_index";
    private static final int UNKNOWN_INDEX = -1;

    private FontWeightAdjustmentPreferenceController mFontWeightAdjustmentController;
@@ -111,13 +110,6 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
            if (savedInstanceState.getBoolean(NEED_RESET_SETTINGS)) {
                mResetStateListeners.forEach(ResetStateListener::resetState);
            }

            if (savedInstanceState.containsKey(LAST_PREVIEW_INDEX)) {
                final int lastPreviewIndex = savedInstanceState.getInt(LAST_PREVIEW_INDEX);
                if (lastPreviewIndex != UNKNOWN_INDEX) {
                    mPreviewController.setCurrentItem(lastPreviewIndex);
                }
            }
        }
    }

@@ -252,8 +244,6 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
        if (mNeedResetSettings) {
            outState.putBoolean(NEED_RESET_SETTINGS, true);
        }

        outState.putInt(LAST_PREVIEW_INDEX, mPreviewController.getCurrentItem());
    }

    @Override
+19 −0
Original line number Diff line number Diff line
@@ -17,6 +17,8 @@
package com.android.settings.accessibility;

import android.content.Context;
import android.os.Bundle;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.FrameLayout;
@@ -36,6 +38,7 @@ import com.android.settings.widget.DotsPageIndicator;
 * A {@link Preference} that could show the preview related to the text and reading options.
 */
public class TextReadingPreviewPreference extends Preference {
    private static final String KEY_LAST_INDEX = "last_preview_index";
    private int mCurrentItem;
    private int mLastLayerIndex;
    private PreviewPagerAdapter mPreviewAdapter;
@@ -98,6 +101,22 @@ public class TextReadingPreviewPreference extends Preference {
        updatePagerAndIndicator(viewPager, pageIndicator);
    }

    @Override
    protected Parcelable onSaveInstanceState() {
        Bundle state = new Bundle();
        state.putParcelable(null, super.onSaveInstanceState());
        state.putInt(KEY_LAST_INDEX, getCurrentItem());
        return state;
    }

    @Override
    protected void onRestoreInstanceState(Parcelable state) {
        Bundle bundle = (Bundle) state;
        super.onRestoreInstanceState(bundle.getParcelable(null));
        setCurrentItem(bundle.getInt(KEY_LAST_INDEX));
    }


    /**
     * Set the minimum preview layout horizontal inner padding.
     */
+36 −4
Original line number Diff line number Diff line
@@ -56,10 +56,10 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
    private final int mTextStartId;
    private final int mTextEndId;
    private final int mTickMarkId;
    private final int mIconStartId;
    private final int mIconEndId;
    private final int mIconStartContentDescriptionId;
    private final int mIconEndContentDescriptionId;
    private int mIconStartId;
    private int mIconEndId;
    private int mIconStartContentDescriptionId;
    private int mIconEndContentDescriptionId;
    private OnPreferenceChangeListener mStopListener;
    private SeekBar.OnSeekBarChangeListener mSeekBarChangeListener;

@@ -110,6 +110,38 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
        return mSeekBar;
    }

    /** Set the start icon of the Seekbar. */
    public void setIconStart(int iconStartId) {
        if (mIconStartId != iconStartId) {
            mIconStartId = iconStartId;
            notifyChanged();
        }
    }

    /** Set the description resource id of the start icon. */
    public void setIconStartContentDescription(int iconStartContentDescriptionId) {
        if (mIconStartContentDescriptionId != iconStartContentDescriptionId) {
            mIconStartContentDescriptionId = iconStartContentDescriptionId;
            notifyChanged();
        }
    }

    /** Set the end icon of the Seekbar. */
    public void setIconEnd(int iconEndId) {
        if (mIconEndId != iconEndId) {
            mIconEndId = iconEndId;
            notifyChanged();
        }
    }

    /** Set the description resource id of the end icon. */
    public void setIconEndContentDescription(int iconEndContentDescriptionId) {
        if (mIconEndContentDescriptionId != iconEndContentDescriptionId) {
            mIconEndContentDescriptionId = iconEndContentDescriptionId;
            notifyChanged();
        }
    }

    @Override
    public void onBindViewHolder(PreferenceViewHolder holder) {
        super.onBindViewHolder(holder);