New feature “Text and reading options” for SetupWizard, Wallpaper, and Settings (9/n).

- Fine-tune the legacy interface of the LabeledSeekBarPreference
1) If not set any label, the layout should be gone instead of visible. If not gone, the preference will have redundant space.

Bug: 211503117
Test: make -j64 RunSettingsRoboTests ROBOTEST_FILTER=LabeledSeekBarPreferenceTest
Change-Id: Ideea8589e35083eb89495c0eceba38c62b4807a7
This commit is contained in:
Peter_Liang
2022-01-20 01:32:58 +08:00
parent cc5808cbd7
commit 88d63ea3af
3 changed files with 44 additions and 7 deletions

View File

@@ -74,11 +74,9 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
final TypedArray styledAttrs = context.obtainStyledAttributes(attrs,
R.styleable.LabeledSeekBarPreference);
mTextStartId = styledAttrs.getResourceId(
R.styleable.LabeledSeekBarPreference_textStart,
R.string.summary_placeholder);
R.styleable.LabeledSeekBarPreference_textStart, /* defValue= */ 0);
mTextEndId = styledAttrs.getResourceId(
R.styleable.LabeledSeekBarPreference_textEnd,
R.string.summary_placeholder);
R.styleable.LabeledSeekBarPreference_textEnd, /* defValue= */ 0);
mTickMarkId = styledAttrs.getResourceId(
R.styleable.LabeledSeekBarPreference_tickMark, /* defValue= */ 0);
mIconStartId = styledAttrs.getResourceId(
@@ -115,9 +113,18 @@ public class LabeledSeekBarPreference extends SeekBarPreference {
super.onBindViewHolder(holder);
final TextView startText = (TextView) holder.findViewById(android.R.id.text1);
if (mTextStartId > 0) {
startText.setText(mTextStartId);
}
final TextView endText = (TextView) holder.findViewById(android.R.id.text2);
startText.setText(mTextStartId);
endText.setText(mTextEndId);
if (mTextEndId > 0) {
endText.setText(mTextEndId);
}
final View labelFrame = holder.findViewById(R.id.label_frame);
final boolean isValidTextResIdExist = mTextStartId > 0 || mTextEndId > 0;
labelFrame.setVisibility(isValidTextResIdExist ? View.VISIBLE : View.GONE);
final SeekBar seekBar = (SeekBar) holder.findViewById(com.android.internal.R.id.seekbar);
if (mTickMarkId != 0) {