Add the extra style of the reset button to align SuW style.
Bug: 222419452 Test: manual test Change-Id: I3b020129b04b3036a2de8230c759c69e7342e027
This commit is contained in:
37
res/layout/accessibility_text_reading_reset_button_suw.xml
Normal file
37
res/layout/accessibility_text_reading_reset_button_suw.xml
Normal file
@@ -0,0 +1,37 @@
|
||||
<?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>
|
@@ -37,6 +37,7 @@ import com.android.settings.search.BaseSearchIndexProvider;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
import com.android.settingslib.search.SearchIndexable;
|
||||
|
||||
import com.google.android.setupcompat.util.WizardManagerHelper;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
@@ -168,6 +169,9 @@ public class TextReadingPreferenceFragment extends DashboardFragment {
|
||||
v -> showDialog(DialogEnums.DIALOG_RESET_SETTINGS));
|
||||
resetController.setEntryPoint(mEntryPoint);
|
||||
controllers.add(resetController);
|
||||
if (WizardManagerHelper.isAnySetupWizard(getIntent())) {
|
||||
resetController.setSetupWizardStyle();
|
||||
}
|
||||
|
||||
return controllers;
|
||||
}
|
||||
|
@@ -23,6 +23,7 @@ import androidx.annotation.Nullable;
|
||||
import androidx.preference.PreferenceScreen;
|
||||
|
||||
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.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.
|
||||
*/
|
||||
class TextReadingResetController extends BasePreferenceController {
|
||||
@ButtonStyle
|
||||
private int mButtonStyle;
|
||||
private final View.OnClickListener mOnResetClickListener;
|
||||
|
||||
@EntryPoint
|
||||
@@ -63,6 +66,12 @@ class TextReadingResetController extends BasePreferenceController {
|
||||
AccessibilityStatsLogUtils.convertToEntryPoint(mEntryPoint));
|
||||
}
|
||||
});
|
||||
|
||||
resetPreference.setSetupWizardStyle(mButtonStyle);
|
||||
}
|
||||
|
||||
void setSetupWizardStyle() {
|
||||
mButtonStyle = ButtonStyle.SUW;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -20,11 +20,15 @@ import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.annotation.IntDef;
|
||||
import androidx.preference.Preference;
|
||||
import androidx.preference.PreferenceViewHolder;
|
||||
|
||||
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
|
||||
* and text page.
|
||||
@@ -32,10 +36,20 @@ import com.android.settings.R;
|
||||
public class TextReadingResetPreference extends Preference {
|
||||
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) {
|
||||
super(context, attrs);
|
||||
|
||||
setLayoutResource(R.layout.accessibility_text_reading_reset_button);
|
||||
setSetupWizardStyle(ButtonStyle.DEFAULT);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,6 +60,13 @@ public class TextReadingResetPreference extends Preference {
|
||||
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) {
|
||||
mOnResetClickListener = resetClickListener;
|
||||
}
|
||||
|
Reference in New Issue
Block a user