Modify Smartspace UI templates APIs.
1. Add a SmartspaceText class to warp CharSequence with the info of TrunctAtPosition; 2. Add a field shouldTint to SmartspaceIcon. Test: atest CtsSmartspaceServiceTestCases Bug: 213926964 CTS-Coverage-Bug: 214471292 Change-Id: If9352fcced3db4e398d49dae8ff17f86f5765b47
This commit is contained in:
@@ -1940,9 +1940,9 @@ package android.app.smartspace.uitemplatedata {
|
||||
public static final class SmartspaceCarouselUiTemplateData.CarouselItem implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceIcon getImage();
|
||||
method @Nullable public CharSequence getLowerText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getLowerText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceTapAction getTapAction();
|
||||
method @Nullable public CharSequence getUpperText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getUpperText();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.uitemplatedata.SmartspaceCarouselUiTemplateData.CarouselItem> CREATOR;
|
||||
}
|
||||
@@ -1951,9 +1951,9 @@ package android.app.smartspace.uitemplatedata {
|
||||
ctor public SmartspaceCarouselUiTemplateData.CarouselItem.Builder();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceCarouselUiTemplateData.CarouselItem build();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceCarouselUiTemplateData.CarouselItem.Builder setImage(@Nullable android.app.smartspace.uitemplatedata.SmartspaceIcon);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceCarouselUiTemplateData.CarouselItem.Builder setLowerText(@Nullable CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceCarouselUiTemplateData.CarouselItem.Builder setLowerText(@Nullable android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceCarouselUiTemplateData.CarouselItem.Builder setTapAction(@Nullable android.app.smartspace.uitemplatedata.SmartspaceTapAction);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceCarouselUiTemplateData.CarouselItem.Builder setUpperText(@Nullable CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceCarouselUiTemplateData.CarouselItem.Builder setUpperText(@Nullable android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
}
|
||||
|
||||
public final class SmartspaceCombinedCardsUiTemplateData extends android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData {
|
||||
@@ -1969,15 +1969,15 @@ package android.app.smartspace.uitemplatedata {
|
||||
public class SmartspaceDefaultUiTemplateData implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceTapAction getPrimaryTapAction();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceIcon getSubTitleIcon();
|
||||
method @Nullable public CharSequence getSubtitleText();
|
||||
method @Nullable public CharSequence getSupplementalAlarmText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceIcon getSubtitleIcon();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getSubtitleText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getSupplementalAlarmText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceIcon getSupplementalSubtitleIcon();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceTapAction getSupplementalSubtitleTapAction();
|
||||
method @Nullable public CharSequence getSupplementalSubtitleText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getSupplementalSubtitleText();
|
||||
method public int getTemplateType();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceIcon getTitleIcon();
|
||||
method @Nullable public CharSequence getTitleText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getTitleText();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData> CREATOR;
|
||||
}
|
||||
@@ -1986,23 +1986,23 @@ package android.app.smartspace.uitemplatedata {
|
||||
ctor public SmartspaceDefaultUiTemplateData.Builder(int);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData build();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setPrimaryTapAction(@NonNull android.app.smartspace.uitemplatedata.SmartspaceTapAction);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSubTitleIcon(@NonNull android.app.smartspace.uitemplatedata.SmartspaceIcon);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSubtitleText(@NonNull CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSupplementalAlarmText(@NonNull CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSubtitleIcon(@NonNull android.app.smartspace.uitemplatedata.SmartspaceIcon);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSubtitleText(@NonNull android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSupplementalAlarmText(@NonNull android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSupplementalSubtitleIcon(@NonNull android.app.smartspace.uitemplatedata.SmartspaceIcon);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSupplementalSubtitleTapAction(@NonNull android.app.smartspace.uitemplatedata.SmartspaceTapAction);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSupplementalSubtitleText(@NonNull CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setSupplementalSubtitleText(@NonNull android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setTitleIcon(@NonNull android.app.smartspace.uitemplatedata.SmartspaceIcon);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setTitleText(@NonNull CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder setTitleText(@NonNull android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
}
|
||||
|
||||
public final class SmartspaceHeadToHeadUiTemplateData extends android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData {
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceTapAction getHeadToHeadAction();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceIcon getHeadToHeadFirstCompetitorIcon();
|
||||
method @Nullable public CharSequence getHeadToHeadFirstCompetitorText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getHeadToHeadFirstCompetitorText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceIcon getHeadToHeadSecondCompetitorIcon();
|
||||
method @Nullable public CharSequence getHeadToHeadSecondCompetitorText();
|
||||
method @Nullable public CharSequence getHeadToHeadTitle();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getHeadToHeadSecondCompetitorText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getHeadToHeadTitle();
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData> CREATOR;
|
||||
}
|
||||
|
||||
@@ -2011,16 +2011,17 @@ package android.app.smartspace.uitemplatedata {
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData build();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData.Builder setHeadToHeadAction(@Nullable android.app.smartspace.uitemplatedata.SmartspaceTapAction);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData.Builder setHeadToHeadFirstCompetitorIcon(@Nullable android.app.smartspace.uitemplatedata.SmartspaceIcon);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData.Builder setHeadToHeadFirstCompetitorText(@Nullable CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData.Builder setHeadToHeadFirstCompetitorText(@Nullable android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData.Builder setHeadToHeadSecondCompetitorIcon(@Nullable android.app.smartspace.uitemplatedata.SmartspaceIcon);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData.Builder setHeadToHeadSecondCompetitorText(@Nullable CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData.Builder setHeadToHeadTitle(@Nullable CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData.Builder setHeadToHeadSecondCompetitorText(@Nullable android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceHeadToHeadUiTemplateData.Builder setHeadToHeadTitle(@Nullable android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
}
|
||||
|
||||
public final class SmartspaceIcon implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method @Nullable public CharSequence getContentDescription();
|
||||
method @NonNull public android.graphics.drawable.Icon getIcon();
|
||||
method public boolean shouldTint();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.uitemplatedata.SmartspaceIcon> CREATOR;
|
||||
}
|
||||
@@ -2029,46 +2030,47 @@ package android.app.smartspace.uitemplatedata {
|
||||
ctor public SmartspaceIcon.Builder(@NonNull android.graphics.drawable.Icon);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceIcon build();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceIcon.Builder setContentDescription(@NonNull CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceIcon.Builder setShouldTint(boolean);
|
||||
}
|
||||
|
||||
public final class SmartspaceSubCardUiTemplateData extends android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData {
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceTapAction getSubCardAction();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceIcon getSubCardIcon();
|
||||
method @Nullable public CharSequence getSubCardText();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceText getSubCardText();
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.uitemplatedata.SmartspaceSubCardUiTemplateData> CREATOR;
|
||||
}
|
||||
|
||||
public static final class SmartspaceSubCardUiTemplateData.Builder extends android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder {
|
||||
ctor public SmartspaceSubCardUiTemplateData.Builder(@NonNull android.app.smartspace.uitemplatedata.SmartspaceIcon);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubCardUiTemplateData build();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubCardUiTemplateData.Builder setSubCardAction(@NonNull CharSequence);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubCardUiTemplateData.Builder setSubCardAction(@NonNull android.app.smartspace.uitemplatedata.SmartspaceTapAction);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubCardUiTemplateData.Builder setSubCardText(@NonNull android.app.smartspace.uitemplatedata.SmartspaceText);
|
||||
}
|
||||
|
||||
public final class SmartspaceSubImageUiTemplateData extends android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData {
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceTapAction getSubImageAction();
|
||||
method @NonNull public java.util.List<java.lang.CharSequence> getSubImageTexts();
|
||||
method @NonNull public java.util.List<android.app.smartspace.uitemplatedata.SmartspaceText> getSubImageTexts();
|
||||
method @NonNull public java.util.List<android.app.smartspace.uitemplatedata.SmartspaceIcon> getSubImages();
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.uitemplatedata.SmartspaceSubImageUiTemplateData> CREATOR;
|
||||
}
|
||||
|
||||
public static final class SmartspaceSubImageUiTemplateData.Builder extends android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder {
|
||||
ctor public SmartspaceSubImageUiTemplateData.Builder(@NonNull java.util.List<java.lang.CharSequence>, @NonNull java.util.List<android.app.smartspace.uitemplatedata.SmartspaceIcon>);
|
||||
ctor public SmartspaceSubImageUiTemplateData.Builder(@NonNull java.util.List<android.app.smartspace.uitemplatedata.SmartspaceText>, @NonNull java.util.List<android.app.smartspace.uitemplatedata.SmartspaceIcon>);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubImageUiTemplateData build();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubImageUiTemplateData.Builder setCarouselAction(@NonNull android.app.smartspace.uitemplatedata.SmartspaceTapAction);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubImageUiTemplateData.Builder setSubImageAction(@NonNull android.app.smartspace.uitemplatedata.SmartspaceTapAction);
|
||||
}
|
||||
|
||||
public final class SmartspaceSubListUiTemplateData extends android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData {
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceTapAction getSubListAction();
|
||||
method @Nullable public android.app.smartspace.uitemplatedata.SmartspaceIcon getSubListIcon();
|
||||
method @NonNull public java.util.List<java.lang.CharSequence> getSubListTexts();
|
||||
method @NonNull public java.util.List<android.app.smartspace.uitemplatedata.SmartspaceText> getSubListTexts();
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.uitemplatedata.SmartspaceSubListUiTemplateData> CREATOR;
|
||||
}
|
||||
|
||||
public static final class SmartspaceSubListUiTemplateData.Builder extends android.app.smartspace.uitemplatedata.SmartspaceDefaultUiTemplateData.Builder {
|
||||
ctor public SmartspaceSubListUiTemplateData.Builder(@NonNull java.util.List<java.lang.CharSequence>);
|
||||
ctor public SmartspaceSubListUiTemplateData.Builder(@NonNull java.util.List<android.app.smartspace.uitemplatedata.SmartspaceText>);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubListUiTemplateData build();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubListUiTemplateData.Builder setCarouselAction(@NonNull android.app.smartspace.uitemplatedata.SmartspaceTapAction);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubListUiTemplateData.Builder setSubListAction(@NonNull android.app.smartspace.uitemplatedata.SmartspaceTapAction);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceSubListUiTemplateData.Builder setSubListIcon(@NonNull android.app.smartspace.uitemplatedata.SmartspaceIcon);
|
||||
}
|
||||
|
||||
@@ -2092,6 +2094,21 @@ package android.app.smartspace.uitemplatedata {
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceTapAction.Builder setUserHandle(@Nullable android.os.UserHandle);
|
||||
}
|
||||
|
||||
public final class SmartspaceText implements android.os.Parcelable {
|
||||
method public int describeContents();
|
||||
method @NonNull public CharSequence getText();
|
||||
method @NonNull public android.text.TextUtils.TruncateAt getTruncateAtType();
|
||||
method public void writeToParcel(@NonNull android.os.Parcel, int);
|
||||
field @NonNull public static final android.os.Parcelable.Creator<android.app.smartspace.uitemplatedata.SmartspaceText> CREATOR;
|
||||
}
|
||||
|
||||
public static final class SmartspaceText.Builder {
|
||||
ctor public SmartspaceText.Builder(@NonNull CharSequence);
|
||||
ctor public SmartspaceText.Builder(@NonNull CharSequence, @NonNull android.text.TextUtils.TruncateAt);
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceText build();
|
||||
method @NonNull public android.app.smartspace.uitemplatedata.SmartspaceText.Builder setTruncateAtType(@NonNull android.text.TextUtils.TruncateAt);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
package android.app.time {
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
package android.app.smartspace;
|
||||
|
||||
import android.annotation.Nullable;
|
||||
import android.app.smartspace.uitemplatedata.SmartspaceText;
|
||||
import android.text.TextUtils;
|
||||
|
||||
/**
|
||||
* Utilities for Smartspace data.
|
||||
@@ -28,10 +30,22 @@ public final class SmartspaceUtils {
|
||||
private SmartspaceUtils() {
|
||||
}
|
||||
|
||||
/** Returns true if the passed in {@link SmartspaceText} is null or its content is empty. */
|
||||
public static boolean isEmpty(@Nullable SmartspaceText text) {
|
||||
return text == null || TextUtils.isEmpty(text.getText());
|
||||
}
|
||||
|
||||
/** Returns true if the passed-in {@link SmartspaceText}s are equal. */
|
||||
public static boolean isEqual(@Nullable SmartspaceText text1, @Nullable SmartspaceText text2) {
|
||||
if (text1 == null && text2 == null) return true;
|
||||
if (text1 == null || text2 == null) return false;
|
||||
return text1.equals(text2);
|
||||
}
|
||||
|
||||
/** Returns true if the passed-in {@link CharSequence}s are equal. */
|
||||
public static boolean isEqual(@Nullable CharSequence cs1, @Nullable CharSequence cs2) {
|
||||
if ((cs1 == null && cs2 != null) || (cs1 != null && cs2 == null)) return false;
|
||||
if (cs1 == null && cs2 == null) return true;
|
||||
if (cs1 == null || cs2 == null) return false;
|
||||
return cs1.toString().contentEquals(cs2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ import android.app.smartspace.SmartspaceTarget;
|
||||
import android.app.smartspace.SmartspaceUtils;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
@@ -51,15 +50,15 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
}
|
||||
|
||||
private SmartspaceCarouselUiTemplateData(@SmartspaceTarget.UiTemplateType int templateType,
|
||||
@Nullable CharSequence titleText,
|
||||
@Nullable SmartspaceText titleText,
|
||||
@Nullable SmartspaceIcon titleIcon,
|
||||
@Nullable CharSequence subtitleText,
|
||||
@Nullable SmartspaceText subtitleText,
|
||||
@Nullable SmartspaceIcon subTitleIcon,
|
||||
@Nullable SmartspaceTapAction primaryTapAction,
|
||||
@Nullable CharSequence supplementalSubtitleText,
|
||||
@Nullable SmartspaceText supplementalSubtitleText,
|
||||
@Nullable SmartspaceIcon supplementalSubtitleIcon,
|
||||
@Nullable SmartspaceTapAction supplementalSubtitleTapAction,
|
||||
@Nullable CharSequence supplementalAlarmText,
|
||||
@Nullable SmartspaceText supplementalAlarmText,
|
||||
@NonNull List<CarouselItem> carouselItems,
|
||||
@Nullable SmartspaceTapAction carouselAction) {
|
||||
super(templateType, titleText, titleIcon, subtitleText, subTitleIcon, primaryTapAction,
|
||||
@@ -170,11 +169,11 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
if (mCarouselItems.isEmpty()) {
|
||||
throw new IllegalStateException("Carousel data is empty");
|
||||
}
|
||||
|
||||
return new SmartspaceCarouselUiTemplateData(getTemplateType(), getTitleText(),
|
||||
getTitleIcon(), getSubtitleText(), getSubTitleIcon(), getPrimaryTapAction(),
|
||||
getTitleIcon(), getSubtitleText(), getSubtitleIcon(), getPrimaryTapAction(),
|
||||
getSupplementalSubtitleText(), getSupplementalSubtitleIcon(),
|
||||
getSupplementalSubtitleTapAction(), getSupplementalAlarmText(),
|
||||
mCarouselItems,
|
||||
getSupplementalSubtitleTapAction(), getSupplementalAlarmText(), mCarouselItems,
|
||||
mCarouselAction);
|
||||
}
|
||||
}
|
||||
@@ -184,7 +183,7 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
|
||||
/** Text which is above the image item. */
|
||||
@Nullable
|
||||
private final CharSequence mUpperText;
|
||||
private final SmartspaceText mUpperText;
|
||||
|
||||
/** Image item. Can be empty. */
|
||||
@Nullable
|
||||
@@ -192,7 +191,7 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
|
||||
/** Text which is under the image item. */
|
||||
@Nullable
|
||||
private final CharSequence mLowerText;
|
||||
private final SmartspaceText mLowerText;
|
||||
|
||||
/**
|
||||
* Tap action for this {@link CarouselItem} instance. {@code mCarouselAction} is used if not
|
||||
@@ -202,14 +201,14 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
private final SmartspaceTapAction mTapAction;
|
||||
|
||||
CarouselItem(@NonNull Parcel in) {
|
||||
mUpperText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mUpperText = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
mImage = in.readTypedObject(SmartspaceIcon.CREATOR);
|
||||
mLowerText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mLowerText = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
mTapAction = in.readTypedObject(SmartspaceTapAction.CREATOR);
|
||||
}
|
||||
|
||||
private CarouselItem(@Nullable CharSequence upperText, @Nullable SmartspaceIcon image,
|
||||
@Nullable CharSequence lowerText, @Nullable SmartspaceTapAction tapAction) {
|
||||
private CarouselItem(@Nullable SmartspaceText upperText, @Nullable SmartspaceIcon image,
|
||||
@Nullable SmartspaceText lowerText, @Nullable SmartspaceTapAction tapAction) {
|
||||
mUpperText = upperText;
|
||||
mImage = image;
|
||||
mLowerText = lowerText;
|
||||
@@ -217,7 +216,7 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getUpperText() {
|
||||
public SmartspaceText getUpperText() {
|
||||
return mUpperText;
|
||||
}
|
||||
|
||||
@@ -227,7 +226,7 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getLowerText() {
|
||||
public SmartspaceText getLowerText() {
|
||||
return mLowerText;
|
||||
}
|
||||
|
||||
@@ -260,9 +259,9 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
TextUtils.writeToParcel(mUpperText, out, flags);
|
||||
out.writeTypedObject(mUpperText, flags);
|
||||
out.writeTypedObject(mImage, flags);
|
||||
TextUtils.writeToParcel(mLowerText, out, flags);
|
||||
out.writeTypedObject(mLowerText, flags);
|
||||
out.writeTypedObject(mTapAction, flags);
|
||||
}
|
||||
|
||||
@@ -300,16 +299,16 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
@SystemApi
|
||||
public static final class Builder {
|
||||
|
||||
private CharSequence mUpperText;
|
||||
private SmartspaceText mUpperText;
|
||||
private SmartspaceIcon mImage;
|
||||
private CharSequence mLowerText;
|
||||
private SmartspaceText mLowerText;
|
||||
private SmartspaceTapAction mTapAction;
|
||||
|
||||
/**
|
||||
* Sets the upper text.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setUpperText(@Nullable CharSequence upperText) {
|
||||
public Builder setUpperText(@Nullable SmartspaceText upperText) {
|
||||
mUpperText = upperText;
|
||||
return this;
|
||||
}
|
||||
@@ -328,7 +327,7 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
* Sets the lower text.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setLowerText(@Nullable CharSequence lowerText) {
|
||||
public Builder setLowerText(@Nullable SmartspaceText lowerText) {
|
||||
mLowerText = lowerText;
|
||||
return this;
|
||||
}
|
||||
@@ -349,7 +348,8 @@ public final class SmartspaceCarouselUiTemplateData extends SmartspaceDefaultUiT
|
||||
*/
|
||||
@NonNull
|
||||
public CarouselItem build() {
|
||||
if (TextUtils.isEmpty(mUpperText) && mImage == null && TextUtils.isEmpty(
|
||||
if (SmartspaceUtils.isEmpty(mUpperText) && mImage == null
|
||||
&& SmartspaceUtils.isEmpty(
|
||||
mLowerText)) {
|
||||
throw new IllegalStateException("Carousel data is empty");
|
||||
}
|
||||
|
||||
@@ -47,15 +47,15 @@ public final class SmartspaceCombinedCardsUiTemplateData extends SmartspaceDefau
|
||||
}
|
||||
|
||||
private SmartspaceCombinedCardsUiTemplateData(@SmartspaceTarget.UiTemplateType int templateType,
|
||||
@Nullable CharSequence titleText,
|
||||
@Nullable SmartspaceText titleText,
|
||||
@Nullable SmartspaceIcon titleIcon,
|
||||
@Nullable CharSequence subtitleText,
|
||||
@Nullable SmartspaceText subtitleText,
|
||||
@Nullable SmartspaceIcon subTitleIcon,
|
||||
@Nullable SmartspaceTapAction primaryTapAction,
|
||||
@Nullable CharSequence supplementalSubtitleText,
|
||||
@Nullable SmartspaceText supplementalSubtitleText,
|
||||
@Nullable SmartspaceIcon supplementalSubtitleIcon,
|
||||
@Nullable SmartspaceTapAction supplementalSubtitleTapAction,
|
||||
@Nullable CharSequence supplementalAlarmText,
|
||||
@Nullable SmartspaceText supplementalAlarmText,
|
||||
@NonNull List<SmartspaceDefaultUiTemplateData> combinedCardDataList) {
|
||||
super(templateType, titleText, titleIcon, subtitleText, subTitleIcon, primaryTapAction,
|
||||
supplementalSubtitleText, supplementalSubtitleIcon, supplementalSubtitleTapAction,
|
||||
@@ -146,7 +146,7 @@ public final class SmartspaceCombinedCardsUiTemplateData extends SmartspaceDefau
|
||||
throw new IllegalStateException("Please assign a value to all @NonNull args.");
|
||||
}
|
||||
return new SmartspaceCombinedCardsUiTemplateData(getTemplateType(), getTitleText(),
|
||||
getTitleIcon(), getSubtitleText(), getSubTitleIcon(), getPrimaryTapAction(),
|
||||
getTitleIcon(), getSubtitleText(), getSubtitleIcon(), getPrimaryTapAction(),
|
||||
getSupplementalSubtitleText(), getSupplementalSubtitleIcon(),
|
||||
getSupplementalSubtitleTapAction(), getSupplementalAlarmText(),
|
||||
mCombinedCardDataList);
|
||||
|
||||
@@ -24,7 +24,6 @@ import android.app.smartspace.SmartspaceTarget.UiTemplateType;
|
||||
import android.app.smartspace.SmartspaceUtils;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -50,17 +49,17 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
* will be used, which has its own tap action applied to the title area.
|
||||
*/
|
||||
@Nullable
|
||||
private final CharSequence mTitleText;
|
||||
private final SmartspaceText mTitleText;
|
||||
|
||||
@Nullable
|
||||
private final SmartspaceIcon mTitleIcon;
|
||||
|
||||
/** Subtitle text and icon are shown at the second row. */
|
||||
@Nullable
|
||||
private final CharSequence mSubtitleText;
|
||||
private final SmartspaceText mSubtitleText;
|
||||
|
||||
@Nullable
|
||||
private final SmartspaceIcon mSubTitleIcon;
|
||||
private final SmartspaceIcon mSubtitleIcon;
|
||||
|
||||
/**
|
||||
* Primary tap action for the entire card, including the blank spaces, except: 1. When title is
|
||||
@@ -75,7 +74,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
* Mainly used for weather info on non-weather card.
|
||||
*/
|
||||
@Nullable
|
||||
private final CharSequence mSupplementalSubtitleText;
|
||||
private final SmartspaceText mSupplementalSubtitleText;
|
||||
|
||||
@Nullable
|
||||
private final SmartspaceIcon mSupplementalSubtitleIcon;
|
||||
@@ -92,19 +91,19 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
* alarm".
|
||||
*/
|
||||
@Nullable
|
||||
private final CharSequence mSupplementalAlarmText;
|
||||
private final SmartspaceText mSupplementalAlarmText;
|
||||
|
||||
SmartspaceDefaultUiTemplateData(@NonNull Parcel in) {
|
||||
mTemplateType = in.readInt();
|
||||
mTitleText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mTitleText = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
mTitleIcon = in.readTypedObject(SmartspaceIcon.CREATOR);
|
||||
mSubtitleText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mSubTitleIcon = in.readTypedObject(SmartspaceIcon.CREATOR);
|
||||
mSubtitleText = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
mSubtitleIcon = in.readTypedObject(SmartspaceIcon.CREATOR);
|
||||
mPrimaryTapAction = in.readTypedObject(SmartspaceTapAction.CREATOR);
|
||||
mSupplementalSubtitleText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mSupplementalSubtitleText = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
mSupplementalSubtitleIcon = in.readTypedObject(SmartspaceIcon.CREATOR);
|
||||
mSupplementalSubtitleTapAction = in.readTypedObject(SmartspaceTapAction.CREATOR);
|
||||
mSupplementalAlarmText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mSupplementalAlarmText = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -112,20 +111,20 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
* SmartspaceDefaultUiTemplateData.Builder.
|
||||
*/
|
||||
SmartspaceDefaultUiTemplateData(@UiTemplateType int templateType,
|
||||
@Nullable CharSequence titleText,
|
||||
@Nullable SmartspaceText titleText,
|
||||
@Nullable SmartspaceIcon titleIcon,
|
||||
@Nullable CharSequence subtitleText,
|
||||
@Nullable SmartspaceIcon subTitleIcon,
|
||||
@Nullable SmartspaceText subtitleText,
|
||||
@Nullable SmartspaceIcon subtitleIcon,
|
||||
@Nullable SmartspaceTapAction primaryTapAction,
|
||||
@Nullable CharSequence supplementalSubtitleText,
|
||||
@Nullable SmartspaceText supplementalSubtitleText,
|
||||
@Nullable SmartspaceIcon supplementalSubtitleIcon,
|
||||
@Nullable SmartspaceTapAction supplementalSubtitleTapAction,
|
||||
@Nullable CharSequence supplementalAlarmText) {
|
||||
@Nullable SmartspaceText supplementalAlarmText) {
|
||||
mTemplateType = templateType;
|
||||
mTitleText = titleText;
|
||||
mTitleIcon = titleIcon;
|
||||
mSubtitleText = subtitleText;
|
||||
mSubTitleIcon = subTitleIcon;
|
||||
mSubtitleIcon = subtitleIcon;
|
||||
mPrimaryTapAction = primaryTapAction;
|
||||
mSupplementalSubtitleText = supplementalSubtitleText;
|
||||
mSupplementalSubtitleIcon = supplementalSubtitleIcon;
|
||||
@@ -139,7 +138,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getTitleText() {
|
||||
public SmartspaceText getTitleText() {
|
||||
return mTitleText;
|
||||
}
|
||||
|
||||
@@ -149,17 +148,22 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getSubtitleText() {
|
||||
public SmartspaceText getSubtitleText() {
|
||||
return mSubtitleText;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SmartspaceIcon getSubTitleIcon() {
|
||||
return mSubTitleIcon;
|
||||
public SmartspaceIcon getSubtitleIcon() {
|
||||
return mSubtitleIcon;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getSupplementalSubtitleText() {
|
||||
public SmartspaceTapAction getPrimaryTapAction() {
|
||||
return mPrimaryTapAction;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SmartspaceText getSupplementalSubtitleText() {
|
||||
return mSupplementalSubtitleText;
|
||||
}
|
||||
|
||||
@@ -168,18 +172,13 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
return mSupplementalSubtitleIcon;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SmartspaceTapAction getPrimaryTapAction() {
|
||||
return mPrimaryTapAction;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public SmartspaceTapAction getSupplementalSubtitleTapAction() {
|
||||
return mSupplementalSubtitleTapAction;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getSupplementalAlarmText() {
|
||||
public SmartspaceText getSupplementalAlarmText() {
|
||||
return mSupplementalAlarmText;
|
||||
}
|
||||
|
||||
@@ -208,15 +207,15 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
out.writeInt(mTemplateType);
|
||||
TextUtils.writeToParcel(mTitleText, out, flags);
|
||||
out.writeTypedObject(mTitleText, flags);
|
||||
out.writeTypedObject(mTitleIcon, flags);
|
||||
TextUtils.writeToParcel(mSubtitleText, out, flags);
|
||||
out.writeTypedObject(mSubTitleIcon, flags);
|
||||
out.writeTypedObject(mSubtitleText, flags);
|
||||
out.writeTypedObject(mSubtitleIcon, flags);
|
||||
out.writeTypedObject(mPrimaryTapAction, flags);
|
||||
TextUtils.writeToParcel(mSupplementalSubtitleText, out, flags);
|
||||
out.writeTypedObject(mSupplementalSubtitleText, flags);
|
||||
out.writeTypedObject(mSupplementalSubtitleIcon, flags);
|
||||
out.writeTypedObject(mSupplementalSubtitleTapAction, flags);
|
||||
TextUtils.writeToParcel(mSupplementalAlarmText, out, flags);
|
||||
out.writeTypedObject(mSupplementalAlarmText, flags);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -228,7 +227,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
that.mTitleText)
|
||||
&& Objects.equals(mTitleIcon, that.mTitleIcon)
|
||||
&& SmartspaceUtils.isEqual(mSubtitleText, that.mSubtitleText)
|
||||
&& Objects.equals(mSubTitleIcon, that.mSubTitleIcon)
|
||||
&& Objects.equals(mSubtitleIcon, that.mSubtitleIcon)
|
||||
&& Objects.equals(mPrimaryTapAction, that.mPrimaryTapAction)
|
||||
&& SmartspaceUtils.isEqual(mSupplementalSubtitleText,
|
||||
that.mSupplementalSubtitleText)
|
||||
@@ -240,7 +239,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mTemplateType, mTitleText, mTitleIcon, mSubtitleText, mSubTitleIcon,
|
||||
return Objects.hash(mTemplateType, mTitleText, mTitleIcon, mSubtitleText, mSubtitleIcon,
|
||||
mPrimaryTapAction, mSupplementalSubtitleText, mSupplementalSubtitleIcon,
|
||||
mSupplementalSubtitleTapAction, mSupplementalAlarmText);
|
||||
}
|
||||
@@ -252,7 +251,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
+ ", mTitleText=" + mTitleText
|
||||
+ ", mTitleIcon=" + mTitleIcon
|
||||
+ ", mSubtitleText=" + mSubtitleText
|
||||
+ ", mSubTitleIcon=" + mSubTitleIcon
|
||||
+ ", mSubTitleIcon=" + mSubtitleIcon
|
||||
+ ", mPrimaryTapAction=" + mPrimaryTapAction
|
||||
+ ", mSupplementalSubtitleText=" + mSupplementalSubtitleText
|
||||
+ ", mSupplementalSubtitleIcon=" + mSupplementalSubtitleIcon
|
||||
@@ -271,15 +270,15 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
public static class Builder {
|
||||
@UiTemplateType
|
||||
private final int mTemplateType;
|
||||
private CharSequence mTitleText;
|
||||
private SmartspaceText mTitleText;
|
||||
private SmartspaceIcon mTitleIcon;
|
||||
private CharSequence mSubtitleText;
|
||||
private SmartspaceIcon mSubTitleIcon;
|
||||
private SmartspaceText mSubtitleText;
|
||||
private SmartspaceIcon mSubtitleIcon;
|
||||
private SmartspaceTapAction mPrimaryTapAction;
|
||||
private CharSequence mSupplementalSubtitleText;
|
||||
private SmartspaceText mSupplementalSubtitleText;
|
||||
private SmartspaceIcon mSupplementalSubtitleIcon;
|
||||
private SmartspaceTapAction mSupplementalSubtitleTapAction;
|
||||
private CharSequence mSupplementalAlarmText;
|
||||
private SmartspaceText mSupplementalAlarmText;
|
||||
|
||||
/**
|
||||
* A builder for {@link SmartspaceDefaultUiTemplateData}.
|
||||
@@ -300,7 +299,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
/** Should ONLY be used by the subclasses */
|
||||
@Nullable
|
||||
@SuppressLint("GetterOnBuilder")
|
||||
CharSequence getTitleText() {
|
||||
SmartspaceText getTitleText() {
|
||||
return mTitleText;
|
||||
}
|
||||
|
||||
@@ -314,15 +313,15 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
/** Should ONLY be used by the subclasses */
|
||||
@Nullable
|
||||
@SuppressLint("GetterOnBuilder")
|
||||
CharSequence getSubtitleText() {
|
||||
SmartspaceText getSubtitleText() {
|
||||
return mSubtitleText;
|
||||
}
|
||||
|
||||
/** Should ONLY be used by the subclasses */
|
||||
@Nullable
|
||||
@SuppressLint("GetterOnBuilder")
|
||||
SmartspaceIcon getSubTitleIcon() {
|
||||
return mSubTitleIcon;
|
||||
SmartspaceIcon getSubtitleIcon() {
|
||||
return mSubtitleIcon;
|
||||
}
|
||||
|
||||
/** Should ONLY be used by the subclasses */
|
||||
@@ -335,7 +334,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
/** Should ONLY be used by the subclasses */
|
||||
@Nullable
|
||||
@SuppressLint("GetterOnBuilder")
|
||||
CharSequence getSupplementalSubtitleText() {
|
||||
SmartspaceText getSupplementalSubtitleText() {
|
||||
return mSupplementalSubtitleText;
|
||||
}
|
||||
|
||||
@@ -356,7 +355,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
/** Should ONLY be used by the subclasses */
|
||||
@Nullable
|
||||
@SuppressLint("GetterOnBuilder")
|
||||
CharSequence getSupplementalAlarmText() {
|
||||
SmartspaceText getSupplementalAlarmText() {
|
||||
return mSupplementalAlarmText;
|
||||
}
|
||||
|
||||
@@ -364,7 +363,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
* Sets the card title.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setTitleText(@NonNull CharSequence titleText) {
|
||||
public Builder setTitleText(@NonNull SmartspaceText titleText) {
|
||||
mTitleText = titleText;
|
||||
return this;
|
||||
}
|
||||
@@ -382,7 +381,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
* Sets the card subtitle.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setSubtitleText(@NonNull CharSequence subtitleText) {
|
||||
public Builder setSubtitleText(@NonNull SmartspaceText subtitleText) {
|
||||
mSubtitleText = subtitleText;
|
||||
return this;
|
||||
}
|
||||
@@ -391,8 +390,8 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
* Sets the card subtitle icon.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setSubTitleIcon(@NonNull SmartspaceIcon subTitleIcon) {
|
||||
mSubTitleIcon = subTitleIcon;
|
||||
public Builder setSubtitleIcon(@NonNull SmartspaceIcon subtitleIcon) {
|
||||
mSubtitleIcon = subtitleIcon;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -409,7 +408,8 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
* Sets the supplemental subtitle text.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setSupplementalSubtitleText(@NonNull CharSequence supplementalSubtitleText) {
|
||||
public Builder setSupplementalSubtitleText(
|
||||
@NonNull SmartspaceText supplementalSubtitleText) {
|
||||
mSupplementalSubtitleText = supplementalSubtitleText;
|
||||
return this;
|
||||
}
|
||||
@@ -440,7 +440,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
* Sets the supplemental alarm text.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setSupplementalAlarmText(@NonNull CharSequence supplementalAlarmText) {
|
||||
public Builder setSupplementalAlarmText(@NonNull SmartspaceText supplementalAlarmText) {
|
||||
mSupplementalAlarmText = supplementalAlarmText;
|
||||
return this;
|
||||
}
|
||||
@@ -451,7 +451,7 @@ public class SmartspaceDefaultUiTemplateData implements Parcelable {
|
||||
@NonNull
|
||||
public SmartspaceDefaultUiTemplateData build() {
|
||||
return new SmartspaceDefaultUiTemplateData(mTemplateType, mTitleText, mTitleIcon,
|
||||
mSubtitleText, mSubTitleIcon, mPrimaryTapAction, mSupplementalSubtitleText,
|
||||
mSubtitleText, mSubtitleIcon, mPrimaryTapAction, mSupplementalSubtitleText,
|
||||
mSupplementalSubtitleIcon, mSupplementalSubtitleTapAction,
|
||||
mSupplementalAlarmText);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.annotation.SystemApi;
|
||||
import android.app.smartspace.SmartspaceTarget;
|
||||
import android.app.smartspace.SmartspaceUtils;
|
||||
import android.os.Parcel;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -35,15 +34,15 @@ import java.util.Objects;
|
||||
public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultUiTemplateData {
|
||||
|
||||
@Nullable
|
||||
private final CharSequence mHeadToHeadTitle;
|
||||
private final SmartspaceText mHeadToHeadTitle;
|
||||
@Nullable
|
||||
private final SmartspaceIcon mHeadToHeadFirstCompetitorIcon;
|
||||
@Nullable
|
||||
private final SmartspaceIcon mHeadToHeadSecondCompetitorIcon;
|
||||
@Nullable
|
||||
private final CharSequence mHeadToHeadFirstCompetitorText;
|
||||
private final SmartspaceText mHeadToHeadFirstCompetitorText;
|
||||
@Nullable
|
||||
private final CharSequence mHeadToHeadSecondCompetitorText;
|
||||
private final SmartspaceText mHeadToHeadSecondCompetitorText;
|
||||
|
||||
/** Tap action for the head-to-head secondary card. */
|
||||
@Nullable
|
||||
@@ -51,29 +50,29 @@ public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultU
|
||||
|
||||
SmartspaceHeadToHeadUiTemplateData(@NonNull Parcel in) {
|
||||
super(in);
|
||||
mHeadToHeadTitle = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mHeadToHeadTitle = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
mHeadToHeadFirstCompetitorIcon = in.readTypedObject(SmartspaceIcon.CREATOR);
|
||||
mHeadToHeadSecondCompetitorIcon = in.readTypedObject(SmartspaceIcon.CREATOR);
|
||||
mHeadToHeadFirstCompetitorText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mHeadToHeadSecondCompetitorText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mHeadToHeadFirstCompetitorText = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
mHeadToHeadSecondCompetitorText = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
mHeadToHeadAction = in.readTypedObject(SmartspaceTapAction.CREATOR);
|
||||
}
|
||||
|
||||
private SmartspaceHeadToHeadUiTemplateData(@SmartspaceTarget.UiTemplateType int templateType,
|
||||
@Nullable CharSequence titleText,
|
||||
@Nullable SmartspaceText titleText,
|
||||
@Nullable SmartspaceIcon titleIcon,
|
||||
@Nullable CharSequence subtitleText,
|
||||
@Nullable SmartspaceText subtitleText,
|
||||
@Nullable SmartspaceIcon subTitleIcon,
|
||||
@Nullable SmartspaceTapAction primaryTapAction,
|
||||
@Nullable CharSequence supplementalSubtitleText,
|
||||
@Nullable SmartspaceText supplementalSubtitleText,
|
||||
@Nullable SmartspaceIcon supplementalSubtitleIcon,
|
||||
@Nullable SmartspaceTapAction supplementalSubtitleTapAction,
|
||||
@Nullable CharSequence supplementalAlarmText,
|
||||
@Nullable CharSequence headToHeadTitle,
|
||||
@Nullable SmartspaceText supplementalAlarmText,
|
||||
@Nullable SmartspaceText headToHeadTitle,
|
||||
@Nullable SmartspaceIcon headToHeadFirstCompetitorIcon,
|
||||
@Nullable SmartspaceIcon headToHeadSecondCompetitorIcon,
|
||||
@Nullable CharSequence headToHeadFirstCompetitorText,
|
||||
@Nullable CharSequence headToHeadSecondCompetitorText,
|
||||
@Nullable SmartspaceText headToHeadFirstCompetitorText,
|
||||
@Nullable SmartspaceText headToHeadSecondCompetitorText,
|
||||
@Nullable SmartspaceTapAction headToHeadAction) {
|
||||
super(templateType, titleText, titleIcon, subtitleText, subTitleIcon, primaryTapAction,
|
||||
supplementalSubtitleText, supplementalSubtitleIcon, supplementalSubtitleTapAction,
|
||||
@@ -87,7 +86,7 @@ public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultU
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getHeadToHeadTitle() {
|
||||
public SmartspaceText getHeadToHeadTitle() {
|
||||
return mHeadToHeadTitle;
|
||||
}
|
||||
|
||||
@@ -102,12 +101,12 @@ public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultU
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getHeadToHeadFirstCompetitorText() {
|
||||
public SmartspaceText getHeadToHeadFirstCompetitorText() {
|
||||
return mHeadToHeadFirstCompetitorText;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getHeadToHeadSecondCompetitorText() {
|
||||
public SmartspaceText getHeadToHeadSecondCompetitorText() {
|
||||
return mHeadToHeadSecondCompetitorText;
|
||||
}
|
||||
|
||||
@@ -141,11 +140,11 @@ public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultU
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
super.writeToParcel(out, flags);
|
||||
TextUtils.writeToParcel(mHeadToHeadTitle, out, flags);
|
||||
out.writeTypedObject(mHeadToHeadTitle, flags);
|
||||
out.writeTypedObject(mHeadToHeadFirstCompetitorIcon, flags);
|
||||
out.writeTypedObject(mHeadToHeadSecondCompetitorIcon, flags);
|
||||
TextUtils.writeToParcel(mHeadToHeadFirstCompetitorText, out, flags);
|
||||
TextUtils.writeToParcel(mHeadToHeadSecondCompetitorText, out, flags);
|
||||
out.writeTypedObject(mHeadToHeadFirstCompetitorText, flags);
|
||||
out.writeTypedObject(mHeadToHeadSecondCompetitorText, flags);
|
||||
out.writeTypedObject(mHeadToHeadAction, flags);
|
||||
}
|
||||
|
||||
@@ -195,11 +194,11 @@ public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultU
|
||||
@SystemApi
|
||||
public static final class Builder extends SmartspaceDefaultUiTemplateData.Builder {
|
||||
|
||||
private CharSequence mHeadToHeadTitle;
|
||||
private SmartspaceText mHeadToHeadTitle;
|
||||
private SmartspaceIcon mHeadToHeadFirstCompetitorIcon;
|
||||
private SmartspaceIcon mHeadToHeadSecondCompetitorIcon;
|
||||
private CharSequence mHeadToHeadFirstCompetitorText;
|
||||
private CharSequence mHeadToHeadSecondCompetitorText;
|
||||
private SmartspaceText mHeadToHeadFirstCompetitorText;
|
||||
private SmartspaceText mHeadToHeadSecondCompetitorText;
|
||||
private SmartspaceTapAction mHeadToHeadAction;
|
||||
|
||||
/**
|
||||
@@ -213,7 +212,7 @@ public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultU
|
||||
* Sets the head-to-head card's title
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setHeadToHeadTitle(@Nullable CharSequence headToHeadTitle) {
|
||||
public Builder setHeadToHeadTitle(@Nullable SmartspaceText headToHeadTitle) {
|
||||
mHeadToHeadTitle = headToHeadTitle;
|
||||
return this;
|
||||
}
|
||||
@@ -243,7 +242,7 @@ public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultU
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setHeadToHeadFirstCompetitorText(
|
||||
@Nullable CharSequence headToHeadFirstCompetitorText) {
|
||||
@Nullable SmartspaceText headToHeadFirstCompetitorText) {
|
||||
mHeadToHeadFirstCompetitorText = headToHeadFirstCompetitorText;
|
||||
return this;
|
||||
}
|
||||
@@ -253,7 +252,7 @@ public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultU
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setHeadToHeadSecondCompetitorText(
|
||||
@Nullable CharSequence headToHeadSecondCompetitorText) {
|
||||
@Nullable SmartspaceText headToHeadSecondCompetitorText) {
|
||||
mHeadToHeadSecondCompetitorText = headToHeadSecondCompetitorText;
|
||||
return this;
|
||||
}
|
||||
@@ -273,7 +272,7 @@ public final class SmartspaceHeadToHeadUiTemplateData extends SmartspaceDefaultU
|
||||
@NonNull
|
||||
public SmartspaceHeadToHeadUiTemplateData build() {
|
||||
return new SmartspaceHeadToHeadUiTemplateData(getTemplateType(), getTitleText(),
|
||||
getTitleIcon(), getSubtitleText(), getSubTitleIcon(), getPrimaryTapAction(),
|
||||
getTitleIcon(), getSubtitleText(), getSubtitleIcon(), getPrimaryTapAction(),
|
||||
getSupplementalSubtitleText(), getSupplementalSubtitleIcon(),
|
||||
getSupplementalSubtitleTapAction(), getSupplementalAlarmText(),
|
||||
mHeadToHeadTitle,
|
||||
|
||||
@@ -42,14 +42,19 @@ public final class SmartspaceIcon implements Parcelable {
|
||||
@Nullable
|
||||
private final CharSequence mContentDescription;
|
||||
|
||||
private final boolean mShouldTint;
|
||||
|
||||
SmartspaceIcon(@NonNull Parcel in) {
|
||||
mIcon = in.readTypedObject(Icon.CREATOR);
|
||||
mContentDescription = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mShouldTint = in.readBoolean();
|
||||
}
|
||||
|
||||
private SmartspaceIcon(@NonNull Icon icon, @Nullable CharSequence contentDescription) {
|
||||
private SmartspaceIcon(@NonNull Icon icon, @Nullable CharSequence contentDescription,
|
||||
boolean shouldTint) {
|
||||
mIcon = icon;
|
||||
mContentDescription = contentDescription;
|
||||
mShouldTint = shouldTint;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@@ -62,6 +67,11 @@ public final class SmartspaceIcon implements Parcelable {
|
||||
return mContentDescription;
|
||||
}
|
||||
|
||||
/** Return shouldTint value. The default value is true. */
|
||||
public boolean shouldTint() {
|
||||
return mShouldTint;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static final Creator<SmartspaceIcon> CREATOR = new Creator<SmartspaceIcon>() {
|
||||
@Override
|
||||
@@ -80,13 +90,14 @@ public final class SmartspaceIcon implements Parcelable {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof SmartspaceIcon)) return false;
|
||||
SmartspaceIcon that = (SmartspaceIcon) o;
|
||||
return mIcon.equals(that.mIcon) && SmartspaceUtils.isEqual(mContentDescription,
|
||||
that.mContentDescription);
|
||||
return mIcon.toString().equals(that.mIcon.toString()) && SmartspaceUtils.isEqual(
|
||||
mContentDescription,
|
||||
that.mContentDescription) && mShouldTint == that.mShouldTint;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mIcon, mContentDescription);
|
||||
return Objects.hash(mIcon.toString(), mContentDescription, mShouldTint);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -98,13 +109,15 @@ public final class SmartspaceIcon implements Parcelable {
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
out.writeTypedObject(mIcon, flags);
|
||||
TextUtils.writeToParcel(mContentDescription, out, flags);
|
||||
out.writeBoolean(mShouldTint);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "SmartspaceIcon{"
|
||||
+ "mImage=" + mIcon
|
||||
+ ", mContentDescription='" + mContentDescription + '\''
|
||||
+ "mIcon=" + mIcon
|
||||
+ ", mContentDescription=" + mContentDescription
|
||||
+ ", mShouldTint=" + mShouldTint
|
||||
+ '}';
|
||||
}
|
||||
|
||||
@@ -118,14 +131,16 @@ public final class SmartspaceIcon implements Parcelable {
|
||||
|
||||
private Icon mIcon;
|
||||
private CharSequence mContentDescription;
|
||||
private boolean mShouldTint;
|
||||
|
||||
/**
|
||||
* A builder for {@link SmartspaceIcon}.
|
||||
* A builder for {@link SmartspaceIcon}, which sets shouldTint to true by default.
|
||||
*
|
||||
* @param icon the icon image of this smartspace icon.
|
||||
* @param icon the icon image of this {@link SmartspaceIcon} instance.
|
||||
*/
|
||||
public Builder(@NonNull Icon icon) {
|
||||
mIcon = Objects.requireNonNull(icon);
|
||||
mShouldTint = true;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -137,12 +152,21 @@ public final class SmartspaceIcon implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets should tint icon.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setShouldTint(boolean shouldTint) {
|
||||
mShouldTint = shouldTint;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a new SmartspaceIcon instance.
|
||||
*/
|
||||
@NonNull
|
||||
public SmartspaceIcon build() {
|
||||
return new SmartspaceIcon(mIcon, mContentDescription);
|
||||
return new SmartspaceIcon(mIcon, mContentDescription, mShouldTint);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@ import android.annotation.SystemApi;
|
||||
import android.app.smartspace.SmartspaceTarget;
|
||||
import android.app.smartspace.SmartspaceUtils;
|
||||
import android.os.Parcel;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -40,7 +39,7 @@ public final class SmartspaceSubCardUiTemplateData extends SmartspaceDefaultUiTe
|
||||
|
||||
/** Text for the sub-card, which shows below the icon when being set. */
|
||||
@Nullable
|
||||
private final CharSequence mSubCardText;
|
||||
private final SmartspaceText mSubCardText;
|
||||
|
||||
/** Tap action for the sub-card secondary card. */
|
||||
@Nullable
|
||||
@@ -49,22 +48,22 @@ public final class SmartspaceSubCardUiTemplateData extends SmartspaceDefaultUiTe
|
||||
SmartspaceSubCardUiTemplateData(@NonNull Parcel in) {
|
||||
super(in);
|
||||
mSubCardIcon = in.readTypedObject(SmartspaceIcon.CREATOR);
|
||||
mSubCardText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mSubCardText = in.readTypedObject(SmartspaceText.CREATOR);
|
||||
mSubCardAction = in.readTypedObject(SmartspaceTapAction.CREATOR);
|
||||
}
|
||||
|
||||
private SmartspaceSubCardUiTemplateData(int templateType,
|
||||
@Nullable CharSequence titleText,
|
||||
@Nullable SmartspaceText titleText,
|
||||
@Nullable SmartspaceIcon titleIcon,
|
||||
@Nullable CharSequence subtitleText,
|
||||
@Nullable SmartspaceText subtitleText,
|
||||
@Nullable SmartspaceIcon subTitleIcon,
|
||||
@Nullable SmartspaceTapAction primaryTapAction,
|
||||
@Nullable CharSequence supplementalSubtitleText,
|
||||
@Nullable SmartspaceText supplementalSubtitleText,
|
||||
@Nullable SmartspaceIcon supplementalSubtitleIcon,
|
||||
@Nullable SmartspaceTapAction supplementalSubtitleTapAction,
|
||||
@Nullable CharSequence supplementalAlarmText,
|
||||
@Nullable SmartspaceText supplementalAlarmText,
|
||||
@NonNull SmartspaceIcon subCardIcon,
|
||||
@Nullable CharSequence subCardText,
|
||||
@Nullable SmartspaceText subCardText,
|
||||
@Nullable SmartspaceTapAction subCardAction) {
|
||||
super(templateType, titleText, titleIcon, subtitleText, subTitleIcon, primaryTapAction,
|
||||
supplementalSubtitleText, supplementalSubtitleIcon, supplementalSubtitleTapAction,
|
||||
@@ -80,7 +79,7 @@ public final class SmartspaceSubCardUiTemplateData extends SmartspaceDefaultUiTe
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public CharSequence getSubCardText() {
|
||||
public SmartspaceText getSubCardText() {
|
||||
return mSubCardText;
|
||||
}
|
||||
|
||||
@@ -115,7 +114,7 @@ public final class SmartspaceSubCardUiTemplateData extends SmartspaceDefaultUiTe
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
super.writeToParcel(out, flags);
|
||||
out.writeTypedObject(mSubCardIcon, flags);
|
||||
TextUtils.writeToParcel(mSubCardText, out, flags);
|
||||
out.writeTypedObject(mSubCardText, flags);
|
||||
out.writeTypedObject(mSubCardAction, flags);
|
||||
}
|
||||
|
||||
@@ -153,7 +152,7 @@ public final class SmartspaceSubCardUiTemplateData extends SmartspaceDefaultUiTe
|
||||
public static final class Builder extends SmartspaceDefaultUiTemplateData.Builder {
|
||||
|
||||
private final SmartspaceIcon mSubCardIcon;
|
||||
private CharSequence mSubCardText;
|
||||
private SmartspaceText mSubCardText;
|
||||
private SmartspaceTapAction mSubCardAction;
|
||||
|
||||
/**
|
||||
@@ -165,11 +164,11 @@ public final class SmartspaceSubCardUiTemplateData extends SmartspaceDefaultUiTe
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the card title text.
|
||||
* Sets the card text.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setSubCardAction(@NonNull CharSequence subCardTitleText) {
|
||||
mSubCardText = subCardTitleText;
|
||||
public Builder setSubCardText(@NonNull SmartspaceText subCardText) {
|
||||
mSubCardText = subCardText;
|
||||
return this;
|
||||
}
|
||||
|
||||
@@ -188,7 +187,7 @@ public final class SmartspaceSubCardUiTemplateData extends SmartspaceDefaultUiTe
|
||||
@NonNull
|
||||
public SmartspaceSubCardUiTemplateData build() {
|
||||
return new SmartspaceSubCardUiTemplateData(getTemplateType(), getTitleText(),
|
||||
getTitleIcon(), getSubtitleText(), getSubTitleIcon(), getPrimaryTapAction(),
|
||||
getTitleIcon(), getSubtitleText(), getSubtitleIcon(), getPrimaryTapAction(),
|
||||
getSupplementalSubtitleText(), getSupplementalSubtitleIcon(),
|
||||
getSupplementalSubtitleTapAction(), getSupplementalAlarmText(), mSubCardIcon,
|
||||
mSubCardText,
|
||||
|
||||
@@ -22,8 +22,6 @@ import android.annotation.SystemApi;
|
||||
import android.app.smartspace.SmartspaceTarget;
|
||||
import android.os.Parcel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -37,7 +35,7 @@ public final class SmartspaceSubImageUiTemplateData extends SmartspaceDefaultUiT
|
||||
|
||||
/** Texts are shown next to the image as a vertical list */
|
||||
@NonNull
|
||||
private final List<CharSequence> mSubImageTexts;
|
||||
private final List<SmartspaceText> mSubImageTexts;
|
||||
|
||||
/** If multiple images are passed in, they will be rendered as GIF. */
|
||||
@NonNull
|
||||
@@ -49,22 +47,22 @@ public final class SmartspaceSubImageUiTemplateData extends SmartspaceDefaultUiT
|
||||
|
||||
SmartspaceSubImageUiTemplateData(@NonNull Parcel in) {
|
||||
super(in);
|
||||
mSubImageTexts = Arrays.asList(in.readCharSequenceArray());
|
||||
mSubImageTexts = in.createTypedArrayList(SmartspaceText.CREATOR);
|
||||
mSubImages = in.createTypedArrayList(SmartspaceIcon.CREATOR);
|
||||
mSubImageAction = in.readTypedObject(SmartspaceTapAction.CREATOR);
|
||||
}
|
||||
|
||||
private SmartspaceSubImageUiTemplateData(@SmartspaceTarget.UiTemplateType int templateType,
|
||||
@Nullable CharSequence titleText,
|
||||
@Nullable SmartspaceText titleText,
|
||||
@Nullable SmartspaceIcon titleIcon,
|
||||
@Nullable CharSequence subtitleText,
|
||||
@Nullable SmartspaceText subtitleText,
|
||||
@Nullable SmartspaceIcon subTitleIcon,
|
||||
@Nullable SmartspaceTapAction primaryTapAction,
|
||||
@Nullable CharSequence supplementalSubtitleText,
|
||||
@Nullable SmartspaceText supplementalSubtitleText,
|
||||
@Nullable SmartspaceIcon supplementalSubtitleIcon,
|
||||
@Nullable SmartspaceTapAction supplementalSubtitleTapAction,
|
||||
@Nullable CharSequence supplementalAlarmText,
|
||||
@NonNull List<CharSequence> subImageTexts,
|
||||
@Nullable SmartspaceText supplementalAlarmText,
|
||||
@NonNull List<SmartspaceText> subImageTexts,
|
||||
@NonNull List<SmartspaceIcon> subImages,
|
||||
@Nullable SmartspaceTapAction subImageAction) {
|
||||
super(templateType, titleText, titleIcon, subtitleText, subTitleIcon, primaryTapAction,
|
||||
@@ -76,7 +74,7 @@ public final class SmartspaceSubImageUiTemplateData extends SmartspaceDefaultUiT
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public List<CharSequence> getSubImageTexts() {
|
||||
public List<SmartspaceText> getSubImageTexts() {
|
||||
return mSubImageTexts;
|
||||
}
|
||||
|
||||
@@ -115,7 +113,7 @@ public final class SmartspaceSubImageUiTemplateData extends SmartspaceDefaultUiT
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
super.writeToParcel(out, flags);
|
||||
out.writeCharSequenceList(new ArrayList<>(mSubImageTexts));
|
||||
out.writeTypedList(mSubImageTexts);
|
||||
out.writeTypedList(mSubImages);
|
||||
out.writeTypedObject(mSubImageAction, flags);
|
||||
}
|
||||
@@ -153,14 +151,14 @@ public final class SmartspaceSubImageUiTemplateData extends SmartspaceDefaultUiT
|
||||
@SystemApi
|
||||
public static final class Builder extends SmartspaceDefaultUiTemplateData.Builder {
|
||||
|
||||
private final List<CharSequence> mSubImageTexts;
|
||||
private final List<SmartspaceText> mSubImageTexts;
|
||||
private final List<SmartspaceIcon> mSubImages;
|
||||
private SmartspaceTapAction mSubImageAction;
|
||||
|
||||
/**
|
||||
* A builder for {@link SmartspaceSubImageUiTemplateData}.
|
||||
*/
|
||||
public Builder(@NonNull List<CharSequence> subImageTexts,
|
||||
public Builder(@NonNull List<SmartspaceText> subImageTexts,
|
||||
@NonNull List<SmartspaceIcon> subImages) {
|
||||
super(SmartspaceTarget.UI_TEMPLATE_SUB_IMAGE);
|
||||
mSubImageTexts = Objects.requireNonNull(subImageTexts);
|
||||
@@ -171,7 +169,7 @@ public final class SmartspaceSubImageUiTemplateData extends SmartspaceDefaultUiT
|
||||
* Sets the card tap action.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setCarouselAction(@NonNull SmartspaceTapAction subImageAction) {
|
||||
public Builder setSubImageAction(@NonNull SmartspaceTapAction subImageAction) {
|
||||
mSubImageAction = subImageAction;
|
||||
return this;
|
||||
}
|
||||
@@ -182,7 +180,7 @@ public final class SmartspaceSubImageUiTemplateData extends SmartspaceDefaultUiT
|
||||
@NonNull
|
||||
public SmartspaceSubImageUiTemplateData build() {
|
||||
return new SmartspaceSubImageUiTemplateData(getTemplateType(), getTitleText(),
|
||||
getTitleIcon(), getSubtitleText(), getSubTitleIcon(), getPrimaryTapAction(),
|
||||
getTitleIcon(), getSubtitleText(), getSubtitleIcon(), getPrimaryTapAction(),
|
||||
getSupplementalSubtitleText(), getSupplementalSubtitleIcon(),
|
||||
getSupplementalSubtitleTapAction(), getSupplementalAlarmText(), mSubImageTexts,
|
||||
mSubImages,
|
||||
|
||||
@@ -22,11 +22,10 @@ import android.annotation.SystemApi;
|
||||
import android.app.smartspace.SmartspaceTarget;
|
||||
import android.os.Parcel;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
|
||||
/**
|
||||
* Holds all the relevant data needed to render a Smartspace card with the sub-list Ui Template.
|
||||
*
|
||||
@@ -38,7 +37,7 @@ public final class SmartspaceSubListUiTemplateData extends SmartspaceDefaultUiTe
|
||||
@Nullable
|
||||
private final SmartspaceIcon mSubListIcon;
|
||||
@NonNull
|
||||
private final List<CharSequence> mSubListTexts;
|
||||
private final List<SmartspaceText> mSubListTexts;
|
||||
|
||||
/** Tap action for the sub-list secondary card. */
|
||||
@Nullable
|
||||
@@ -47,22 +46,22 @@ public final class SmartspaceSubListUiTemplateData extends SmartspaceDefaultUiTe
|
||||
SmartspaceSubListUiTemplateData(@NonNull Parcel in) {
|
||||
super(in);
|
||||
mSubListIcon = in.readTypedObject(SmartspaceIcon.CREATOR);
|
||||
mSubListTexts = Arrays.asList(in.readCharSequenceArray());
|
||||
mSubListTexts = in.createTypedArrayList(SmartspaceText.CREATOR);
|
||||
mSubListAction = in.readTypedObject(SmartspaceTapAction.CREATOR);
|
||||
}
|
||||
|
||||
private SmartspaceSubListUiTemplateData(@SmartspaceTarget.UiTemplateType int templateType,
|
||||
@Nullable CharSequence titleText,
|
||||
@Nullable SmartspaceText titleText,
|
||||
@Nullable SmartspaceIcon titleIcon,
|
||||
@Nullable CharSequence subtitleText,
|
||||
@Nullable SmartspaceText subtitleText,
|
||||
@Nullable SmartspaceIcon subTitleIcon,
|
||||
@Nullable SmartspaceTapAction primaryTapAction,
|
||||
@Nullable CharSequence supplementalSubtitleText,
|
||||
@Nullable SmartspaceText supplementalSubtitleText,
|
||||
@Nullable SmartspaceIcon supplementalSubtitleIcon,
|
||||
@Nullable SmartspaceTapAction supplementalSubtitleTapAction,
|
||||
@Nullable CharSequence supplementalAlarmText,
|
||||
@Nullable SmartspaceText supplementalAlarmText,
|
||||
@Nullable SmartspaceIcon subListIcon,
|
||||
@NonNull List<CharSequence> subListTexts,
|
||||
@NonNull List<SmartspaceText> subListTexts,
|
||||
@Nullable SmartspaceTapAction subListAction) {
|
||||
super(templateType, titleText, titleIcon, subtitleText, subTitleIcon, primaryTapAction,
|
||||
supplementalSubtitleText, supplementalSubtitleIcon, supplementalSubtitleTapAction,
|
||||
@@ -78,7 +77,7 @@ public final class SmartspaceSubListUiTemplateData extends SmartspaceDefaultUiTe
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public List<CharSequence> getSubListTexts() {
|
||||
public List<SmartspaceText> getSubListTexts() {
|
||||
return mSubListTexts;
|
||||
}
|
||||
|
||||
@@ -113,7 +112,7 @@ public final class SmartspaceSubListUiTemplateData extends SmartspaceDefaultUiTe
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
super.writeToParcel(out, flags);
|
||||
out.writeTypedObject(mSubListIcon, flags);
|
||||
out.writeCharSequenceList(new ArrayList<>(mSubListTexts));
|
||||
out.writeTypedList(mSubListTexts);
|
||||
out.writeTypedObject(mSubListAction, flags);
|
||||
}
|
||||
|
||||
@@ -151,13 +150,13 @@ public final class SmartspaceSubListUiTemplateData extends SmartspaceDefaultUiTe
|
||||
public static final class Builder extends SmartspaceDefaultUiTemplateData.Builder {
|
||||
|
||||
private SmartspaceIcon mSubListIcon;
|
||||
private final List<CharSequence> mSubListTexts;
|
||||
private final List<SmartspaceText> mSubListTexts;
|
||||
private SmartspaceTapAction mSubListAction;
|
||||
|
||||
/**
|
||||
* A builder for {@link SmartspaceSubListUiTemplateData}.
|
||||
*/
|
||||
public Builder(@NonNull List<CharSequence> subListTexts) {
|
||||
public Builder(@NonNull List<SmartspaceText> subListTexts) {
|
||||
super(SmartspaceTarget.UI_TEMPLATE_SUB_LIST);
|
||||
mSubListTexts = Objects.requireNonNull(subListTexts);
|
||||
}
|
||||
@@ -175,7 +174,7 @@ public final class SmartspaceSubListUiTemplateData extends SmartspaceDefaultUiTe
|
||||
* Sets the card tap action.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setCarouselAction(@NonNull SmartspaceTapAction subListAction) {
|
||||
public Builder setSubListAction(@NonNull SmartspaceTapAction subListAction) {
|
||||
mSubListAction = subListAction;
|
||||
return this;
|
||||
}
|
||||
@@ -186,7 +185,7 @@ public final class SmartspaceSubListUiTemplateData extends SmartspaceDefaultUiTe
|
||||
@NonNull
|
||||
public SmartspaceSubListUiTemplateData build() {
|
||||
return new SmartspaceSubListUiTemplateData(getTemplateType(), getTitleText(),
|
||||
getTitleIcon(), getSubtitleText(), getSubTitleIcon(), getPrimaryTapAction(),
|
||||
getTitleIcon(), getSubtitleText(), getSubtitleIcon(), getPrimaryTapAction(),
|
||||
getSupplementalSubtitleText(), getSupplementalSubtitleIcon(),
|
||||
getSupplementalSubtitleTapAction(), getSupplementalAlarmText(), mSubListIcon,
|
||||
mSubListTexts,
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package android.app.smartspace.uitemplatedata;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.SystemApi;
|
||||
import android.app.smartspace.SmartspaceUtils;
|
||||
import android.os.Parcel;
|
||||
import android.os.Parcelable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* Holds the information for a Smartspace-card text: the text content and
|
||||
* the truncate_at information.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public final class SmartspaceText implements Parcelable {
|
||||
|
||||
@NonNull
|
||||
private final CharSequence mText;
|
||||
|
||||
private final TextUtils.TruncateAt mTruncateAtType;
|
||||
|
||||
SmartspaceText(Parcel in) {
|
||||
mText = TextUtils.CHAR_SEQUENCE_CREATOR.createFromParcel(in);
|
||||
mTruncateAtType = TextUtils.TruncateAt.valueOf(in.readString());
|
||||
}
|
||||
|
||||
private SmartspaceText(@NonNull CharSequence text, TextUtils.TruncateAt truncateAtType) {
|
||||
mText = text;
|
||||
mTruncateAtType = truncateAtType;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public CharSequence getText() {
|
||||
return mText;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public TextUtils.TruncateAt getTruncateAtType() {
|
||||
return mTruncateAtType;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public static final Creator<SmartspaceText> CREATOR = new Creator<SmartspaceText>() {
|
||||
@Override
|
||||
public SmartspaceText createFromParcel(Parcel in) {
|
||||
return new SmartspaceText(in);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SmartspaceText[] newArray(int size) {
|
||||
return new SmartspaceText[size];
|
||||
}
|
||||
};
|
||||
|
||||
@Override
|
||||
public int describeContents() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof SmartspaceText)) return false;
|
||||
SmartspaceText that = (SmartspaceText) o;
|
||||
return mTruncateAtType == that.mTruncateAtType && SmartspaceUtils.isEqual(mText,
|
||||
that.mText);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(mText, mTruncateAtType);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeToParcel(@NonNull Parcel out, int flags) {
|
||||
TextUtils.writeToParcel(mText, out, flags);
|
||||
out.writeString(mTruncateAtType.name());
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for {@link SmartspaceText} object.
|
||||
*
|
||||
* @hide
|
||||
*/
|
||||
@SystemApi
|
||||
public static final class Builder {
|
||||
private final CharSequence mText;
|
||||
private TextUtils.TruncateAt mTruncateAtType;
|
||||
|
||||
/**
|
||||
* A builder for {@link SmartspaceText}, which sets TruncateAtType to AT_END by default.
|
||||
*/
|
||||
public Builder(@NonNull CharSequence text) {
|
||||
mText = Objects.requireNonNull(text);
|
||||
mTruncateAtType = TextUtils.TruncateAt.END;
|
||||
}
|
||||
|
||||
/**
|
||||
* A builder for {@link SmartspaceText}.
|
||||
*/
|
||||
public Builder(@NonNull CharSequence text, @NonNull TextUtils.TruncateAt truncateAtType) {
|
||||
mText = Objects.requireNonNull(text);
|
||||
mTruncateAtType = Objects.requireNonNull(truncateAtType);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets truncateAtType.
|
||||
*/
|
||||
@NonNull
|
||||
public Builder setTruncateAtType(@NonNull TextUtils.TruncateAt truncateAtType) {
|
||||
mTruncateAtType = Objects.requireNonNull(truncateAtType);
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a new SmartspaceText instance.
|
||||
*/
|
||||
@NonNull
|
||||
public SmartspaceText build() {
|
||||
return new SmartspaceText(mText, mTruncateAtType);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user