Fix talkback speak "double tap to activate" on LabeledSeekBarPreference

- SeekBarPreference should be unselectable
- remove unnecessary handling of Summary
- set currect Title color when preference is enabled and unselectable

Bug: 230553896
Test: robotest
Change-Id: Ie5d819088dc3c435005ddd00e232b2f6992b234a
This commit is contained in:
Edgar Wang
2022-05-19 09:20:30 +08:00
parent 27aa5f9d94
commit 2b0d9cfc5d
5 changed files with 13 additions and 49 deletions

View File

@@ -27,7 +27,6 @@
<com.android.settings.widget.LabeledSeekBarPreference <com.android.settings.widget.LabeledSeekBarPreference
android:key="font_size" android:key="font_size"
android:selectable="true"
android:summary="@string/short_summary_font_size" android:summary="@string/short_summary_font_size"
android:title="@string/title_font_size" android:title="@string/title_font_size"
settings:iconEnd="@drawable/ic_add_24dp" settings:iconEnd="@drawable/ic_add_24dp"
@@ -38,7 +37,6 @@
<com.android.settings.widget.LabeledSeekBarPreference <com.android.settings.widget.LabeledSeekBarPreference
android:key="display_size" android:key="display_size"
android:selectable="true"
android:summary="@string/screen_zoom_short_summary" android:summary="@string/screen_zoom_short_summary"
android:title="@string/screen_zoom_title" android:title="@string/screen_zoom_title"
settings:iconEnd="@drawable/ic_add_24dp" settings:iconEnd="@drawable/ic_add_24dp"

View File

@@ -46,7 +46,6 @@
android:key="gesture_left_back_sensitivity" android:key="gesture_left_back_sensitivity"
android:title="@string/left_edge" android:title="@string/left_edge"
android:max="2" android:max="2"
android:selectable="true"
settings:textStart="@string/low_label" settings:textStart="@string/low_label"
settings:textEnd="@string/high_label"/> settings:textEnd="@string/high_label"/>
@@ -54,7 +53,6 @@
android:key="gesture_right_back_sensitivity" android:key="gesture_right_back_sensitivity"
android:title="@string/right_edge" android:title="@string/right_edge"
android:max="2" android:max="2"
android:selectable="true"
settings:textStart="@string/low_label" settings:textStart="@string/low_label"
settings:textEnd="@string/high_label"/> settings:textEnd="@string/high_label"/>
</PreferenceCategory> </PreferenceCategory>

View File

@@ -36,7 +36,6 @@
android:key="gesture_power_menu_long_press_for_assist_sensitivity" android:key="gesture_power_menu_long_press_for_assist_sensitivity"
android:title="@string/power_menu_long_press_for_assist_sensitivity_title" android:title="@string/power_menu_long_press_for_assist_sensitivity_title"
android:summary="@string/power_menu_long_press_for_assist_sensitivity_summary" android:summary="@string/power_menu_long_press_for_assist_sensitivity_summary"
android:selectable="true"
settings:textStart="@string/power_menu_long_press_for_assist_sensitivity_low_label" settings:textStart="@string/power_menu_long_press_for_assist_sensitivity_low_label"
settings:textEnd="@string/power_menu_long_press_for_assist_sensitivity_high_label" settings:textEnd="@string/power_menu_long_press_for_assist_sensitivity_high_label"
settings:controller="com.android.settings.gestures.LongPressPowerSensitivityPreferenceController" settings:controller="com.android.settings.gestures.LongPressPowerSensitivityPreferenceController"

View File

@@ -26,12 +26,12 @@ import android.widget.ImageView;
import android.widget.SeekBar; import android.widget.SeekBar;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.core.content.res.TypedArrayUtils; import androidx.core.content.res.TypedArrayUtils;
import androidx.preference.PreferenceViewHolder; import androidx.preference.PreferenceViewHolder;
import com.android.internal.util.Preconditions; import com.android.internal.util.Preconditions;
import com.android.settings.R; import com.android.settings.R;
import com.android.settings.Utils;
/** /**
* A labeled {@link SeekBarPreference} with left and right text label, icon label, or both. * A labeled {@link SeekBarPreference} with left and right text label, icon label, or both.
@@ -61,8 +61,6 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
private final int mIconStartContentDescriptionId; private final int mIconStartContentDescriptionId;
private final int mIconEndContentDescriptionId; private final int mIconEndContentDescriptionId;
private OnPreferenceChangeListener mStopListener; private OnPreferenceChangeListener mStopListener;
@Nullable
private CharSequence mSummary;
private SeekBar.OnSeekBarChangeListener mSeekBarChangeListener; private SeekBar.OnSeekBarChangeListener mSeekBarChangeListener;
public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr, public LabeledSeekBarPreference(Context context, AttributeSet attrs, int defStyleAttr,
@@ -97,8 +95,6 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
Preconditions.checkArgument(!(mIconEndContentDescriptionId != 0 && mIconEndId == 0), Preconditions.checkArgument(!(mIconEndContentDescriptionId != 0 && mIconEndId == 0),
"The resource of the iconEnd attribute may be invalid or not set, " "The resource of the iconEnd attribute may be invalid or not set, "
+ "you should set the iconEnd attribute and have the valid resource."); + "you should set the iconEnd attribute and have the valid resource.");
mSummary = styledAttrs.getText(R.styleable.Preference_android_summary);
styledAttrs.recycle(); styledAttrs.recycle();
} }
@@ -112,6 +108,17 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
public void onBindViewHolder(PreferenceViewHolder holder) { public void onBindViewHolder(PreferenceViewHolder holder) {
super.onBindViewHolder(holder); super.onBindViewHolder(holder);
final TextView summaryView = (TextView) holder.findViewById(android.R.id.summary);
boolean isSummaryVisible = false;
if (summaryView != null) {
isSummaryVisible = (summaryView.getVisibility() == View.VISIBLE);
}
final TextView titleView = (TextView) holder.findViewById(android.R.id.title);
if (titleView != null && !isSelectable() && isEnabled() && isSummaryVisible) {
titleView.setTextColor(
Utils.getColorAttr(getContext(), android.R.attr.textColorPrimary));
}
final TextView startText = (TextView) holder.findViewById(android.R.id.text1); final TextView startText = (TextView) holder.findViewById(android.R.id.text1);
if (mTextStartId > 0) { if (mTextStartId > 0) {
startText.setText(mTextStartId); startText.setText(mTextStartId);
@@ -132,15 +139,6 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
seekBar.setTickMark(tickMark); seekBar.setTickMark(tickMark);
} }
final TextView summary = (TextView) holder.findViewById(android.R.id.summary);
if (mSummary != null) {
summary.setText(mSummary);
summary.setVisibility(View.VISIBLE);
} else {
summary.setText(null);
summary.setVisibility(View.GONE);
}
final ViewGroup iconStartFrame = (ViewGroup) holder.findViewById(R.id.icon_start_frame); final ViewGroup iconStartFrame = (ViewGroup) holder.findViewById(R.id.icon_start_frame);
final ImageView iconStartView = (ImageView) holder.findViewById(R.id.icon_start); final ImageView iconStartView = (ImageView) holder.findViewById(R.id.icon_start);
updateIconStartIfNeeded(iconStartFrame, iconStartView, seekBar); updateIconStartIfNeeded(iconStartFrame, iconStartView, seekBar);
@@ -188,25 +186,6 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
notifyChanged(); notifyChanged();
} }
@Override
public void setSummary(CharSequence summary) {
super.setSummary(summary);
mSummary = summary;
notifyChanged();
}
@Override
public void setSummary(int summaryResId) {
super.setSummary(summaryResId);
mSummary = getContext().getText(summaryResId);
notifyChanged();
}
@Override
public CharSequence getSummary() {
return mSummary;
}
public void setOnSeekBarChangeListener(SeekBar.OnSeekBarChangeListener seekBarChangeListener) { public void setOnSeekBarChangeListener(SeekBar.OnSeekBarChangeListener seekBarChangeListener) {
mSeekBarChangeListener = seekBarChangeListener; mSeekBarChangeListener = seekBarChangeListener;
} }

View File

@@ -78,12 +78,7 @@ public class SeekBarPreference extends RestrictedPreference
com.android.internal.R.layout.preference_widget_seekbar); com.android.internal.R.layout.preference_widget_seekbar);
a.recycle(); a.recycle();
a = context.obtainStyledAttributes( setSelectable(false);
attrs, com.android.internal.R.styleable.Preference, defStyleAttr, defStyleRes);
final boolean isSelectable = a.getBoolean(
com.android.settings.R.styleable.Preference_android_selectable, false);
setSelectable(isSelectable);
a.recycle();
setLayoutResource(layoutResId); setLayoutResource(layoutResId);
} }
@@ -170,11 +165,6 @@ public class SeekBarPreference extends RestrictedPreference
}); });
} }
@Override
public CharSequence getSummary() {
return null;
}
@Override @Override
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) { protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
setProgress(restoreValue ? getPersistedInt(mProgress) setProgress(restoreValue ? getPersistedInt(mProgress)