| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
package android.app.smartspace; |
| 17 |
|
| 18 |
import android.annotation.CurrentTimeMillisLong; |
| 19 |
import android.annotation.IntDef; |
| 20 |
import android.annotation.NonNull; |
| 21 |
import android.annotation.Nullable; |
| 22 |
import android.annotation.SystemApi; |
| 23 |
import android.app.smartspace.uitemplatedata.BaseTemplateData; |
| 24 |
import android.appwidget.AppWidgetProviderInfo; |
| 25 |
import android.content.ComponentName; |
| 26 |
import android.net.Uri; |
| 27 |
import android.os.Parcel; |
| 28 |
import android.os.Parcelable; |
| 29 |
import android.os.UserHandle; |
| 30 |
|
| 31 |
import java.lang.annotation.Retention; |
| 32 |
import java.lang.annotation.RetentionPolicy; |
| 33 |
import java.util.ArrayList; |
| 34 |
import java.util.List; |
| 35 |
import java.util.Objects; |
| 36 |
|
| 37 |
|
| 38 |
|
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
|
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
|
| 49 |
|
| 50 |
@SystemApi |
| 51 |
public final class SmartspaceTarget implements Parcelable { |
| 52 |
|
| 53 |
|
| 54 |
@NonNull |
| 55 |
private final String mSmartspaceTargetId; |
| 56 |
|
| 57 |
|
| 58 |
@Nullable |
| 59 |
private final SmartspaceAction mHeaderAction; |
| 60 |
|
| 61 |
|
| 62 |
@Nullable |
| 63 |
private final SmartspaceAction mBaseAction; |
| 64 |
|
| 65 |
|
| 66 |
@CurrentTimeMillisLong |
| 67 |
private final long mCreationTimeMillis; |
| 68 |
|
| 69 |
|
| 70 |
|
| 71 |
|
| 72 |
|
| 73 |
@CurrentTimeMillisLong |
| 74 |
private final long mExpiryTimeMillis; |
| 75 |
|
| 76 |
|
| 77 |
private final float mScore; |
| 78 |
|
| 79 |
|
| 80 |
@NonNull |
| 81 |
private final List<SmartspaceAction> mActionChips; |
| 82 |
|
| 83 |
|
| 84 |
@NonNull |
| 85 |
private final List<SmartspaceAction> mIconGrid; |
| 86 |
|
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
@FeatureType |
| 93 |
private final int mFeatureType; |
| 94 |
|
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
private final boolean mSensitive; |
| 100 |
|
| 101 |
|
| 102 |
private final boolean mShouldShowExpanded; |
| 103 |
|
| 104 |
|
| 105 |
@Nullable |
| 106 |
private final String mSourceNotificationKey; |
| 107 |
|
| 108 |
|
| 109 |
@NonNull |
| 110 |
private final ComponentName mComponentName; |
| 111 |
|
| 112 |
|
| 113 |
@NonNull |
| 114 |
private final UserHandle mUserHandle; |
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
@Nullable |
| 125 |
private final String mAssociatedSmartspaceTargetId; |
| 126 |
|
| 127 |
|
| 128 |
@Nullable |
| 129 |
private final Uri mSliceUri; |
| 130 |
|
| 131 |
|
| 132 |
@Nullable |
| 133 |
private final AppWidgetProviderInfo mWidget; |
| 134 |
|
| 135 |
@Nullable |
| 136 |
private final BaseTemplateData mTemplateData; |
| 137 |
|
| 138 |
public static final int FEATURE_UNDEFINED = 0; |
| 139 |
public static final int FEATURE_WEATHER = 1; |
| 140 |
public static final int FEATURE_CALENDAR = 2; |
| 141 |
public static final int FEATURE_COMMUTE_TIME = 3; |
| 142 |
public static final int FEATURE_FLIGHT = 4; |
| 143 |
public static final int FEATURE_TIPS = 5; |
| 144 |
public static final int FEATURE_REMINDER = 6; |
| 145 |
public static final int FEATURE_ALARM = 7; |
| 146 |
public static final int FEATURE_ONBOARDING = 8; |
| 147 |
public static final int FEATURE_SPORTS = 9; |
| 148 |
public static final int FEATURE_WEATHER_ALERT = 10; |
| 149 |
public static final int FEATURE_CONSENT = 11; |
| 150 |
public static final int FEATURE_STOCK_PRICE_CHANGE = 12; |
| 151 |
public static final int FEATURE_SHOPPING_LIST = 13; |
| 152 |
public static final int FEATURE_LOYALTY_CARD = 14; |
| 153 |
public static final int FEATURE_MEDIA = 15; |
| 154 |
public static final int FEATURE_BEDTIME_ROUTINE = 16; |
| 155 |
public static final int FEATURE_FITNESS_TRACKING = 17; |
| 156 |
public static final int FEATURE_ETA_MONITORING = 18; |
| 157 |
public static final int FEATURE_MISSED_CALL = 19; |
| 158 |
public static final int FEATURE_PACKAGE_TRACKING = 20; |
| 159 |
public static final int FEATURE_TIMER = 21; |
| 160 |
public static final int FEATURE_STOPWATCH = 22; |
| 161 |
public static final int FEATURE_UPCOMING_ALARM = 23; |
| 162 |
public static final int FEATURE_GAS_STATION_PAYMENT = 24; |
| 163 |
public static final int FEATURE_PAIRED_DEVICE_STATE = 25; |
| 164 |
public static final int FEATURE_DRIVING_MODE = 26; |
| 165 |
public static final int FEATURE_SLEEP_SUMMARY = 27; |
| 166 |
public static final int FEATURE_FLASHLIGHT = 28; |
| 167 |
public static final int FEATURE_TIME_TO_LEAVE = 29; |
| 168 |
public static final int FEATURE_DOORBELL = 30; |
| 169 |
public static final int FEATURE_MEDIA_RESUME = 31; |
| 170 |
public static final int FEATURE_CROSS_DEVICE_TIMER = 32; |
| 171 |
public static final int FEATURE_SEVERE_WEATHER_ALERT = 33; |
| 172 |
public static final int FEATURE_HOLIDAY_ALARM = 34; |
| 173 |
public static final int FEATURE_SAFETY_CHECK = 35; |
| 174 |
public static final int FEATURE_MEDIA_HEADS_UP = 36; |
| 175 |
public static final int FEATURE_STEP_COUNTING = 37; |
| 176 |
public static final int FEATURE_EARTHQUAKE_ALERT = 38; |
| 177 |
public static final int FEATURE_STEP_DATE = 39; |
| 178 |
public static final int FEATURE_BLAZE_BUILD_PROGRESS = 40; |
| 179 |
public static final int FEATURE_EARTHQUAKE_OCCURRED = 41; |
| 180 |
|
| 181 |
|
| 182 |
|
| 183 |
|
| 184 |
@IntDef(prefix = {"FEATURE_"}, value = { |
| 185 |
FEATURE_UNDEFINED, |
| 186 |
FEATURE_WEATHER, |
| 187 |
FEATURE_CALENDAR, |
| 188 |
FEATURE_COMMUTE_TIME, |
| 189 |
FEATURE_FLIGHT, |
| 190 |
FEATURE_TIPS, |
| 191 |
FEATURE_REMINDER, |
| 192 |
FEATURE_ALARM, |
| 193 |
FEATURE_ONBOARDING, |
| 194 |
FEATURE_SPORTS, |
| 195 |
FEATURE_WEATHER_ALERT, |
| 196 |
FEATURE_CONSENT, |
| 197 |
FEATURE_STOCK_PRICE_CHANGE, |
| 198 |
FEATURE_SHOPPING_LIST, |
| 199 |
FEATURE_LOYALTY_CARD, |
| 200 |
FEATURE_MEDIA, |
| 201 |
FEATURE_BEDTIME_ROUTINE, |
| 202 |
FEATURE_FITNESS_TRACKING, |
| 203 |
FEATURE_ETA_MONITORING, |
| 204 |
FEATURE_MISSED_CALL, |
| 205 |
FEATURE_PACKAGE_TRACKING, |
| 206 |
FEATURE_TIMER, |
| 207 |
FEATURE_STOPWATCH, |
| 208 |
FEATURE_UPCOMING_ALARM, |
| 209 |
FEATURE_GAS_STATION_PAYMENT, |
| 210 |
FEATURE_PAIRED_DEVICE_STATE, |
| 211 |
FEATURE_DRIVING_MODE, |
| 212 |
FEATURE_SLEEP_SUMMARY, |
| 213 |
FEATURE_FLASHLIGHT, |
| 214 |
FEATURE_TIME_TO_LEAVE, |
| 215 |
FEATURE_DOORBELL, |
| 216 |
FEATURE_MEDIA_RESUME, |
| 217 |
FEATURE_CROSS_DEVICE_TIMER, |
| 218 |
FEATURE_SEVERE_WEATHER_ALERT, |
| 219 |
FEATURE_HOLIDAY_ALARM, |
| 220 |
FEATURE_SAFETY_CHECK, |
| 221 |
FEATURE_MEDIA_HEADS_UP, |
| 222 |
FEATURE_STEP_COUNTING, |
| 223 |
FEATURE_EARTHQUAKE_ALERT, |
| 224 |
FEATURE_STEP_DATE, |
| 225 |
FEATURE_BLAZE_BUILD_PROGRESS, |
| 226 |
FEATURE_EARTHQUAKE_OCCURRED |
| 227 |
}) |
| 228 |
@Retention(RetentionPolicy.SOURCE) |
| 229 |
public @interface FeatureType { |
| 230 |
} |
| 231 |
|
| 232 |
public static final int UI_TEMPLATE_UNDEFINED = 0; |
| 233 |
|
| 234 |
|
| 235 |
public static final int UI_TEMPLATE_DEFAULT = 1; |
| 236 |
|
| 237 |
public static final int UI_TEMPLATE_SUB_IMAGE = 2; |
| 238 |
|
| 239 |
public static final int UI_TEMPLATE_SUB_LIST = 3; |
| 240 |
|
| 241 |
public static final int UI_TEMPLATE_CAROUSEL = 4; |
| 242 |
|
| 243 |
public static final int UI_TEMPLATE_HEAD_TO_HEAD = 5; |
| 244 |
|
| 245 |
public static final int UI_TEMPLATE_COMBINED_CARDS = 6; |
| 246 |
|
| 247 |
public static final int UI_TEMPLATE_SUB_CARD = 7; |
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
@IntDef(prefix = {"UI_TEMPLATE_"}, value = { |
| 259 |
UI_TEMPLATE_UNDEFINED, |
| 260 |
UI_TEMPLATE_DEFAULT, |
| 261 |
UI_TEMPLATE_SUB_IMAGE, |
| 262 |
UI_TEMPLATE_SUB_LIST, |
| 263 |
UI_TEMPLATE_CAROUSEL, |
| 264 |
UI_TEMPLATE_HEAD_TO_HEAD, |
| 265 |
UI_TEMPLATE_COMBINED_CARDS, |
| 266 |
UI_TEMPLATE_SUB_CARD |
| 267 |
}) |
| 268 |
@Retention(RetentionPolicy.SOURCE) |
| 269 |
public @interface UiTemplateType { |
| 270 |
} |
| 271 |
|
| 272 |
private SmartspaceTarget(Parcel in) { |
| 273 |
this.mSmartspaceTargetId = in.readString(); |
| 274 |
this.mHeaderAction = in.readTypedObject(SmartspaceAction.CREATOR); |
| 275 |
this.mBaseAction = in.readTypedObject(SmartspaceAction.CREATOR); |
| 276 |
this.mCreationTimeMillis = in.readLong(); |
| 277 |
this.mExpiryTimeMillis = in.readLong(); |
| 278 |
this.mScore = in.readFloat(); |
| 279 |
this.mActionChips = in.createTypedArrayList(SmartspaceAction.CREATOR); |
| 280 |
this.mIconGrid = in.createTypedArrayList(SmartspaceAction.CREATOR); |
| 281 |
this.mFeatureType = in.readInt(); |
| 282 |
this.mSensitive = in.readBoolean(); |
| 283 |
this.mShouldShowExpanded = in.readBoolean(); |
| 284 |
this.mSourceNotificationKey = in.readString(); |
| 285 |
this.mComponentName = in.readTypedObject(ComponentName.CREATOR); |
| 286 |
this.mUserHandle = in.readTypedObject(UserHandle.CREATOR); |
| 287 |
this.mAssociatedSmartspaceTargetId = in.readString(); |
| 288 |
this.mSliceUri = in.readTypedObject(Uri.CREATOR); |
| 289 |
this.mWidget = in.readTypedObject(AppWidgetProviderInfo.CREATOR); |
| 290 |
this.mTemplateData = in.readParcelable(null, BaseTemplateData.class); |
| 291 |
} |
| 292 |
|
| 293 |
private SmartspaceTarget(String smartspaceTargetId, |
| 294 |
SmartspaceAction headerAction, SmartspaceAction baseAction, long creationTimeMillis, |
| 295 |
long expiryTimeMillis, float score, |
| 296 |
List<SmartspaceAction> actionChips, |
| 297 |
List<SmartspaceAction> iconGrid, int featureType, boolean sensitive, |
| 298 |
boolean shouldShowExpanded, String sourceNotificationKey, |
| 299 |
ComponentName componentName, UserHandle userHandle, |
| 300 |
String associatedSmartspaceTargetId, Uri sliceUri, |
| 301 |
AppWidgetProviderInfo widget, BaseTemplateData templateData) { |
| 302 |
mSmartspaceTargetId = smartspaceTargetId; |
| 303 |
mHeaderAction = headerAction; |
| 304 |
mBaseAction = baseAction; |
| 305 |
mCreationTimeMillis = creationTimeMillis; |
| 306 |
mExpiryTimeMillis = expiryTimeMillis; |
| 307 |
mScore = score; |
| 308 |
mActionChips = actionChips; |
| 309 |
mIconGrid = iconGrid; |
| 310 |
mFeatureType = featureType; |
| 311 |
mSensitive = sensitive; |
| 312 |
mShouldShowExpanded = shouldShowExpanded; |
| 313 |
mSourceNotificationKey = sourceNotificationKey; |
| 314 |
mComponentName = componentName; |
| 315 |
mUserHandle = userHandle; |
| 316 |
mAssociatedSmartspaceTargetId = associatedSmartspaceTargetId; |
| 317 |
mSliceUri = sliceUri; |
| 318 |
mWidget = widget; |
| 319 |
mTemplateData = templateData; |
| 320 |
} |
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
@NonNull |
| 326 |
public String getSmartspaceTargetId() { |
| 327 |
return mSmartspaceTargetId; |
| 328 |
} |
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
@Nullable |
| 334 |
public SmartspaceAction getHeaderAction() { |
| 335 |
return mHeaderAction; |
| 336 |
} |
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
@Nullable |
| 342 |
public SmartspaceAction getBaseAction() { |
| 343 |
return mBaseAction; |
| 344 |
} |
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
@CurrentTimeMillisLong |
| 350 |
public long getCreationTimeMillis() { |
| 351 |
return mCreationTimeMillis; |
| 352 |
} |
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
@CurrentTimeMillisLong |
| 358 |
public long getExpiryTimeMillis() { |
| 359 |
return mExpiryTimeMillis; |
| 360 |
} |
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
public float getScore() { |
| 366 |
return mScore; |
| 367 |
} |
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
@NonNull |
| 373 |
public List<SmartspaceAction> getActionChips() { |
| 374 |
return mActionChips; |
| 375 |
} |
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
@NonNull |
| 381 |
public List<SmartspaceAction> getIconGrid() { |
| 382 |
return mIconGrid; |
| 383 |
} |
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
@FeatureType |
| 389 |
public int getFeatureType() { |
| 390 |
return mFeatureType; |
| 391 |
} |
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
public boolean isSensitive() { |
| 397 |
return mSensitive; |
| 398 |
} |
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
public boolean shouldShowExpanded() { |
| 404 |
return mShouldShowExpanded; |
| 405 |
} |
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
@Nullable |
| 411 |
public String getSourceNotificationKey() { |
| 412 |
return mSourceNotificationKey; |
| 413 |
} |
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
@NonNull |
| 419 |
public ComponentName getComponentName() { |
| 420 |
return mComponentName; |
| 421 |
} |
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
@NonNull |
| 427 |
public UserHandle getUserHandle() { |
| 428 |
return mUserHandle; |
| 429 |
} |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
@Nullable |
| 435 |
public String getAssociatedSmartspaceTargetId() { |
| 436 |
return mAssociatedSmartspaceTargetId; |
| 437 |
} |
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
@Nullable |
| 443 |
public Uri getSliceUri() { |
| 444 |
return mSliceUri; |
| 445 |
} |
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
@Nullable |
| 451 |
public AppWidgetProviderInfo getWidget() { |
| 452 |
return mWidget; |
| 453 |
} |
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
@Nullable |
| 459 |
public BaseTemplateData getTemplateData() { |
| 460 |
return mTemplateData; |
| 461 |
} |
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
@NonNull |
| 467 |
public static final Creator<SmartspaceTarget> CREATOR = new Creator<SmartspaceTarget>() { |
| 468 |
@Override |
| 469 |
public SmartspaceTarget createFromParcel(Parcel source) { |
| 470 |
return new SmartspaceTarget(source); |
| 471 |
} |
| 472 |
|
| 473 |
@Override |
| 474 |
public SmartspaceTarget[] newArray(int size) { |
| 475 |
return new SmartspaceTarget[size]; |
| 476 |
} |
| 477 |
}; |
| 478 |
|
| 479 |
@Override |
| 480 |
public void writeToParcel(@NonNull Parcel dest, int flags) { |
| 481 |
dest.writeString(this.mSmartspaceTargetId); |
| 482 |
dest.writeTypedObject(this.mHeaderAction, flags); |
| 483 |
dest.writeTypedObject(this.mBaseAction, flags); |
| 484 |
dest.writeLong(this.mCreationTimeMillis); |
| 485 |
dest.writeLong(this.mExpiryTimeMillis); |
| 486 |
dest.writeFloat(this.mScore); |
| 487 |
dest.writeTypedList(this.mActionChips); |
| 488 |
dest.writeTypedList(this.mIconGrid); |
| 489 |
dest.writeInt(this.mFeatureType); |
| 490 |
dest.writeBoolean(this.mSensitive); |
| 491 |
dest.writeBoolean(this.mShouldShowExpanded); |
| 492 |
dest.writeString(this.mSourceNotificationKey); |
| 493 |
dest.writeTypedObject(this.mComponentName, flags); |
| 494 |
dest.writeTypedObject(this.mUserHandle, flags); |
| 495 |
dest.writeString(this.mAssociatedSmartspaceTargetId); |
| 496 |
dest.writeTypedObject(this.mSliceUri, flags); |
| 497 |
dest.writeTypedObject(this.mWidget, flags); |
| 498 |
dest.writeParcelable(this.mTemplateData, flags); |
| 499 |
} |
| 500 |
|
| 501 |
@Override |
| 502 |
public int describeContents() { |
| 503 |
return 0; |
| 504 |
} |
| 505 |
|
| 506 |
@Override |
| 507 |
public String toString() { |
| 508 |
return "SmartspaceTarget{" |
| 509 |
+ "mSmartspaceTargetId='" + mSmartspaceTargetId + '\'' |
| 510 |
+ ", mHeaderAction=" + mHeaderAction |
| 511 |
+ ", mBaseAction=" + mBaseAction |
| 512 |
+ ", mCreationTimeMillis=" + mCreationTimeMillis |
| 513 |
+ ", mExpiryTimeMillis=" + mExpiryTimeMillis |
| 514 |
+ ", mScore=" + mScore |
| 515 |
+ ", mActionChips=" + mActionChips |
| 516 |
+ ", mIconGrid=" + mIconGrid |
| 517 |
+ ", mFeatureType=" + mFeatureType |
| 518 |
+ ", mSensitive=" + mSensitive |
| 519 |
+ ", mShouldShowExpanded=" + mShouldShowExpanded |
| 520 |
+ ", mSourceNotificationKey='" + mSourceNotificationKey + '\'' |
| 521 |
+ ", mComponentName=" + mComponentName |
| 522 |
+ ", mUserHandle=" + mUserHandle |
| 523 |
+ ", mAssociatedSmartspaceTargetId='" + mAssociatedSmartspaceTargetId + '\'' |
| 524 |
+ ", mSliceUri=" + mSliceUri |
| 525 |
+ ", mWidget=" + mWidget |
| 526 |
+ ", mTemplateData=" + mTemplateData |
| 527 |
+ '}'; |
| 528 |
} |
| 529 |
|
| 530 |
@Override |
| 531 |
public boolean equals(Object o) { |
| 532 |
if (this == o) return true; |
| 533 |
if (o == null || getClass() != o.getClass()) return false; |
| 534 |
SmartspaceTarget that = (SmartspaceTarget) o; |
| 535 |
return mCreationTimeMillis == that.mCreationTimeMillis |
| 536 |
&& mExpiryTimeMillis == that.mExpiryTimeMillis |
| 537 |
&& Float.compare(that.mScore, mScore) == 0 |
| 538 |
&& mFeatureType == that.mFeatureType |
| 539 |
&& mSensitive == that.mSensitive |
| 540 |
&& mShouldShowExpanded == that.mShouldShowExpanded |
| 541 |
&& mSmartspaceTargetId.equals(that.mSmartspaceTargetId) |
| 542 |
&& Objects.equals(mHeaderAction, that.mHeaderAction) |
| 543 |
&& Objects.equals(mBaseAction, that.mBaseAction) |
| 544 |
&& Objects.equals(mActionChips, that.mActionChips) |
| 545 |
&& Objects.equals(mIconGrid, that.mIconGrid) |
| 546 |
&& Objects.equals(mSourceNotificationKey, that.mSourceNotificationKey) |
| 547 |
&& mComponentName.equals(that.mComponentName) |
| 548 |
&& mUserHandle.equals(that.mUserHandle) |
| 549 |
&& Objects.equals(mAssociatedSmartspaceTargetId, |
| 550 |
that.mAssociatedSmartspaceTargetId) |
| 551 |
&& Objects.equals(mSliceUri, that.mSliceUri) |
| 552 |
&& Objects.equals(mWidget, that.mWidget) |
| 553 |
&& Objects.equals(mTemplateData, that.mTemplateData); |
| 554 |
} |
| 555 |
|
| 556 |
@Override |
| 557 |
public int hashCode() { |
| 558 |
return Objects.hash(mSmartspaceTargetId, mHeaderAction, mBaseAction, mCreationTimeMillis, |
| 559 |
mExpiryTimeMillis, mScore, mActionChips, mIconGrid, mFeatureType, mSensitive, |
| 560 |
mShouldShowExpanded, mSourceNotificationKey, mComponentName, mUserHandle, |
| 561 |
mAssociatedSmartspaceTargetId, mSliceUri, mWidget, mTemplateData); |
| 562 |
} |
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
@SystemApi |
| 570 |
public static final class Builder { |
| 571 |
private final String mSmartspaceTargetId; |
| 572 |
private final ComponentName mComponentName; |
| 573 |
private final UserHandle mUserHandle; |
| 574 |
|
| 575 |
private SmartspaceAction mHeaderAction; |
| 576 |
private SmartspaceAction mBaseAction; |
| 577 |
private long mCreationTimeMillis; |
| 578 |
private long mExpiryTimeMillis; |
| 579 |
private float mScore; |
| 580 |
private List<SmartspaceAction> mActionChips = new ArrayList<>(); |
| 581 |
private List<SmartspaceAction> mIconGrid = new ArrayList<>(); |
| 582 |
private int mFeatureType; |
| 583 |
private boolean mSensitive; |
| 584 |
private boolean mShouldShowExpanded; |
| 585 |
private String mSourceNotificationKey; |
| 586 |
private String mAssociatedSmartspaceTargetId; |
| 587 |
private Uri mSliceUri; |
| 588 |
private AppWidgetProviderInfo mWidget; |
| 589 |
private BaseTemplateData mTemplateData; |
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
public Builder(@NonNull String smartspaceTargetId, |
| 599 |
@NonNull ComponentName componentName, @NonNull UserHandle userHandle) { |
| 600 |
this.mSmartspaceTargetId = smartspaceTargetId; |
| 601 |
this.mComponentName = componentName; |
| 602 |
this.mUserHandle = userHandle; |
| 603 |
} |
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
@NonNull |
| 609 |
public Builder setHeaderAction(@NonNull SmartspaceAction headerAction) { |
| 610 |
this.mHeaderAction = headerAction; |
| 611 |
return this; |
| 612 |
} |
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
@NonNull |
| 618 |
public Builder setBaseAction(@NonNull SmartspaceAction baseAction) { |
| 619 |
this.mBaseAction = baseAction; |
| 620 |
return this; |
| 621 |
} |
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
@NonNull |
| 627 |
public Builder setCreationTimeMillis(@CurrentTimeMillisLong long creationTimeMillis) { |
| 628 |
this.mCreationTimeMillis = creationTimeMillis; |
| 629 |
return this; |
| 630 |
} |
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
@NonNull |
| 636 |
public Builder setExpiryTimeMillis(@CurrentTimeMillisLong long expiryTimeMillis) { |
| 637 |
this.mExpiryTimeMillis = expiryTimeMillis; |
| 638 |
return this; |
| 639 |
} |
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
@NonNull |
| 645 |
public Builder setScore(float score) { |
| 646 |
this.mScore = score; |
| 647 |
return this; |
| 648 |
} |
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
@NonNull |
| 654 |
public Builder setActionChips(@NonNull List<SmartspaceAction> actionChips) { |
| 655 |
this.mActionChips = actionChips; |
| 656 |
return this; |
| 657 |
} |
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
@NonNull |
| 663 |
public Builder setIconGrid(@NonNull List<SmartspaceAction> iconGrid) { |
| 664 |
this.mIconGrid = iconGrid; |
| 665 |
return this; |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
@NonNull |
| 672 |
public Builder setFeatureType(int featureType) { |
| 673 |
this.mFeatureType = featureType; |
| 674 |
return this; |
| 675 |
} |
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
@NonNull |
| 681 |
public Builder setSensitive(boolean sensitive) { |
| 682 |
this.mSensitive = sensitive; |
| 683 |
return this; |
| 684 |
} |
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
@NonNull |
| 690 |
public Builder setShouldShowExpanded(boolean shouldShowExpanded) { |
| 691 |
this.mShouldShowExpanded = shouldShowExpanded; |
| 692 |
return this; |
| 693 |
} |
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
@NonNull |
| 699 |
public Builder setSourceNotificationKey(@NonNull String sourceNotificationKey) { |
| 700 |
this.mSourceNotificationKey = sourceNotificationKey; |
| 701 |
return this; |
| 702 |
} |
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
@NonNull |
| 708 |
public Builder setAssociatedSmartspaceTargetId( |
| 709 |
@NonNull String associatedSmartspaceTargetId) { |
| 710 |
this.mAssociatedSmartspaceTargetId = associatedSmartspaceTargetId; |
| 711 |
return this; |
| 712 |
} |
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
@NonNull |
| 720 |
public Builder setSliceUri(@NonNull Uri sliceUri) { |
| 721 |
this.mSliceUri = sliceUri; |
| 722 |
return this; |
| 723 |
} |
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
@NonNull |
| 732 |
public Builder setWidget(@NonNull AppWidgetProviderInfo widget) { |
| 733 |
this.mWidget = widget; |
| 734 |
return this; |
| 735 |
} |
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
@NonNull |
| 741 |
public Builder setTemplateData( |
| 742 |
@Nullable BaseTemplateData templateData) { |
| 743 |
mTemplateData = templateData; |
| 744 |
return this; |
| 745 |
} |
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
@NonNull |
| 753 |
public SmartspaceTarget build() { |
| 754 |
if (mSmartspaceTargetId == null |
| 755 |
|| mComponentName == null |
| 756 |
|| mUserHandle == null) { |
| 757 |
throw new IllegalStateException("Please assign a value to all @NonNull args."); |
| 758 |
} |
| 759 |
return new SmartspaceTarget(mSmartspaceTargetId, |
| 760 |
mHeaderAction, mBaseAction, mCreationTimeMillis, mExpiryTimeMillis, mScore, |
| 761 |
mActionChips, mIconGrid, mFeatureType, mSensitive, mShouldShowExpanded, |
| 762 |
mSourceNotificationKey, mComponentName, mUserHandle, |
| 763 |
mAssociatedSmartspaceTargetId, mSliceUri, mWidget, mTemplateData); |
| 764 |
} |
| 765 |
} |
| 766 |
} |