Adding the ability to customize the subtitle on an unavailable slice

When a slice is depending on some setting and the setting is off,
it shows "depends on another setting".
Add an new attribute for Preference to customize the subtitle when
a slice is unavailable.

Bug: 118399193
Test: Robo test on com.android.settings.slices, com.android.settings.core
Change-Id: I84a8400295b36abb357e5baf98e9be3a8d6ea897
This commit is contained in:
Console Chen
2018-12-19 18:01:09 +08:00
parent e5e94b95dc
commit ce16d7ad63
17 changed files with 256 additions and 31 deletions

View File

@@ -28,7 +28,6 @@ import java.lang.annotation.RetentionPolicy;
* Note that {@link #mKey} is treated as a primary key for this class and determines equality.
*/
public class SliceData {
/**
* Flags indicating the UI type of the Slice.
*/
@@ -76,6 +75,8 @@ public class SliceData {
private final boolean mIsDynamicSummaryAllowed;
private final String mUnavailableSliceSubtitle;
public String getKey() {
return mKey;
}
@@ -124,6 +125,10 @@ public class SliceData {
return mIsDynamicSummaryAllowed;
}
public String getUnavailableSliceSubtitle() {
return mUnavailableSliceSubtitle;
}
private SliceData(Builder builder) {
mKey = builder.mKey;
mTitle = builder.mTitle;
@@ -137,6 +142,7 @@ public class SliceData {
mSliceType = builder.mSliceType;
mIsPlatformDefined = builder.mIsPlatformDefined;
mIsDynamicSummaryAllowed = builder.mIsDynamicSummaryAllowed;
mUnavailableSliceSubtitle = builder.mUnavailableSliceSubtitle;
}
@Override
@@ -178,6 +184,8 @@ public class SliceData {
private boolean mIsDynamicSummaryAllowed;
private String mUnavailableSliceSubtitle;
public Builder setKey(String key) {
mKey = key;
return this;
@@ -238,6 +246,12 @@ public class SliceData {
return this;
}
public Builder setUnavailableSliceSubtitle(
String unavailableSliceSubtitle) {
mUnavailableSliceSubtitle = unavailableSliceSubtitle;
return this;
}
public SliceData build() {
if (TextUtils.isEmpty(mKey)) {
throw new InvalidSliceDataException("Key cannot be empty");