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:
Peter Liang
2022-12-05 00:39:36 +08:00
parent 47c0ee6b38
commit 734e5291bb
4 changed files with 72 additions and 1 deletions

View File

@@ -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;
}