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

Commit 2af12aca authored by PETER LIANG's avatar PETER LIANG Committed by Android (Google) Code Review
Browse files

Merge "Add the extra style of the reset button to align SuW style."

parents 87b80e32 734e5291
Loading
Loading
Loading
Loading
+37 −0
Original line number Original line 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_vertical|start"
        android:paddingVertical="14dp"
        android:background="?android:attr/selectableItemBackground"
        android:textColor="?android:attr/colorAccent"
        android:textSize="16sp"
        android:text="@string/accessibility_text_reading_reset_button_title"
        android:fontFamily="@*android:string/config_bodyFontFamilyMedium" />
</FrameLayout>
+4 −0
Original line number Original line Diff line number Diff line
@@ -37,6 +37,7 @@ import com.android.settings.search.BaseSearchIndexProvider;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.core.AbstractPreferenceController;
import com.android.settingslib.search.SearchIndexable;
import com.android.settingslib.search.SearchIndexable;


import com.google.android.setupcompat.util.WizardManagerHelper;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.annotations.VisibleForTesting;


import java.lang.annotation.Retention;
import java.lang.annotation.Retention;
@@ -168,6 +169,9 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
                        v -> showDialog(DialogEnums.DIALOG_RESET_SETTINGS));
                        v -> showDialog(DialogEnums.DIALOG_RESET_SETTINGS));
        resetController.setEntryPoint(mEntryPoint);
        resetController.setEntryPoint(mEntryPoint);
        controllers.add(resetController);
        controllers.add(resetController);
        if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
            resetController.setSetupWizardStyle();
        }


        return controllers;
        return controllers;
    }
    }
+9 −0
Original line number Original line Diff line number Diff line
@@ -23,6 +23,7 @@ import androidx.annotation.Nullable;
import androidx.preference.PreferenceScreen;
import androidx.preference.PreferenceScreen;


import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
import com.android.settings.accessibility.TextReadingPreferenceFragment.EntryPoint;
import com.android.settings.accessibility.TextReadingResetPreference.ButtonStyle;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.BasePreferenceController;
import com.android.settings.core.instrumentation.SettingsStatsLog;
import com.android.settings.core.instrumentation.SettingsStatsLog;


@@ -30,6 +31,8 @@ import com.android.settings.core.instrumentation.SettingsStatsLog;
 * The controller of the reset button in the text and reading options page.
 * The controller of the reset button in the text and reading options page.
 */
 */
class TextReadingResetController extends BasePreferenceController {
class TextReadingResetController extends BasePreferenceController {
    @ButtonStyle
    private int mButtonStyle;
    private final View.OnClickListener mOnResetClickListener;
    private final View.OnClickListener mOnResetClickListener;


    @EntryPoint
    @EntryPoint
@@ -63,6 +66,12 @@ class TextReadingResetController extends BasePreferenceController {
                        AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
                        AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
            }
            }
        });
        });

        resetPreference.setSetupWizardStyle(mButtonStyle);
    }

    void setSetupWizardStyle() {
        mButtonStyle = ButtonStyle.SUW;
    }
    }


    /**
    /**
+22 −1
Original line number Original line Diff line number Diff line
@@ -20,11 +20,15 @@ import android.content.Context;
import android.util.AttributeSet;
import android.util.AttributeSet;
import android.view.View;
import android.view.View;


import androidx.annotation.IntDef;
import androidx.preference.Preference;
import androidx.preference.Preference;
import androidx.preference.PreferenceViewHolder;
import androidx.preference.PreferenceViewHolder;


import com.android.settings.R;
import com.android.settings.R;


import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;

/**
/**
 * The preference which is used for resetting the status of all preferences in the display size
 * The preference which is used for resetting the status of all preferences in the display size
 * and text page.
 * and text page.
@@ -32,10 +36,20 @@ import com.android.settings.R;
public class TextReadingResetPreference extends Preference {
public class TextReadingResetPreference extends Preference {
    private View.OnClickListener mOnResetClickListener;
    private View.OnClickListener mOnResetClickListener;


    @Retention(RetentionPolicy.SOURCE)
    @IntDef({
            ButtonStyle.DEFAULT,
            ButtonStyle.SUW,
    })
    @interface ButtonStyle {
        int DEFAULT = 0;
        int SUW = 1;
    }

    public TextReadingResetPreference(Context context, AttributeSet attrs) {
    public TextReadingResetPreference(Context context, AttributeSet attrs) {
        super(context, attrs);
        super(context, attrs);


        setLayoutResource(R.layout.accessibility_text_reading_reset_button);
        setSetupWizardStyle(ButtonStyle.DEFAULT);
    }
    }


    @Override
    @Override
@@ -46,6 +60,13 @@ public class TextReadingResetPreference extends Preference {
        view.setOnClickListener(mOnResetClickListener);
        view.setOnClickListener(mOnResetClickListener);
    }
    }


    void setSetupWizardStyle(@ButtonStyle int style) {
        final int layoutResId = (style == ButtonStyle.SUW)
                ? R.layout.accessibility_text_reading_reset_button_suw
                : R.layout.accessibility_text_reading_reset_button;
        setLayoutResource(layoutResId);
    }

    void setOnResetClickListener(View.OnClickListener resetClickListener) {
    void setOnResetClickListener(View.OnClickListener resetClickListener) {
        mOnResetClickListener = resetClickListener;
        mOnResetClickListener = resetClickListener;
    }
    }