| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view.selectiontoolbar; |
| 18 |
|
| 19 |
import android.annotation.NonNull; |
| 20 |
import android.annotation.Nullable; |
| 21 |
import android.graphics.drawable.Icon; |
| 22 |
import android.os.Parcelable; |
| 23 |
import android.view.MenuItem; |
| 24 |
|
| 25 |
import com.android.internal.util.DataClass; |
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
|
| 32 |
@DataClass(genBuilder = true, genToString = true, genEqualsHashCode = true) |
| 33 |
public final class ToolbarMenuItem implements Parcelable { |
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
|
| 38 |
public static final int PRIORITY_UNKNOWN = 0; |
| 39 |
|
| 40 |
|
| 41 |
|
| 42 |
|
| 43 |
public static final int PRIORITY_PRIMARY = 1; |
| 44 |
|
| 45 |
|
| 46 |
|
| 47 |
|
| 48 |
public static final int PRIORITY_OVERFLOW = 2; |
| 49 |
|
| 50 |
|
| 51 |
|
| 52 |
|
| 53 |
|
| 54 |
|
| 55 |
private final int mItemId; |
| 56 |
|
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
|
| 61 |
|
| 62 |
@NonNull |
| 63 |
private final CharSequence mTitle; |
| 64 |
|
| 65 |
|
| 66 |
|
| 67 |
|
| 68 |
|
| 69 |
|
| 70 |
@Nullable |
| 71 |
private final CharSequence mContentDescription; |
| 72 |
|
| 73 |
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
|
| 78 |
private final int mGroupId; |
| 79 |
|
| 80 |
|
| 81 |
|
| 82 |
|
| 83 |
|
| 84 |
|
| 85 |
@Nullable |
| 86 |
private final Icon mIcon; |
| 87 |
|
| 88 |
|
| 89 |
|
| 90 |
|
| 91 |
|
| 92 |
|
| 93 |
@Nullable |
| 94 |
private final CharSequence mTooltipText; |
| 95 |
|
| 96 |
|
| 97 |
|
| 98 |
|
| 99 |
private final int mPriority; |
| 100 |
|
| 101 |
|
| 102 |
|
| 103 |
|
| 104 |
public static int getPriorityFromMenuItem(MenuItem menuItem) { |
| 105 |
if (menuItem.requiresActionButton()) { |
| 106 |
return PRIORITY_PRIMARY; |
| 107 |
} else if (menuItem.requiresOverflow()) { |
| 108 |
return PRIORITY_OVERFLOW; |
| 109 |
} |
| 110 |
return PRIORITY_UNKNOWN; |
| 111 |
} |
| 112 |
|
| 113 |
|
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
|
| 118 |
|
| 119 |
|
| 120 |
|
| 121 |
|
| 122 |
|
| 123 |
|
| 124 |
|
| 125 |
|
| 126 |
|
| 127 |
|
| 128 |
|
| 129 |
@android.annotation.IntDef(prefix = "PRIORITY_", value = { |
| 130 |
PRIORITY_UNKNOWN, |
| 131 |
PRIORITY_PRIMARY, |
| 132 |
PRIORITY_OVERFLOW |
| 133 |
}) |
| 134 |
@java.lang.annotation.Retention(java.lang.annotation.RetentionPolicy.SOURCE) |
| 135 |
@DataClass.Generated.Member |
| 136 |
public @interface Priority {} |
| 137 |
|
| 138 |
@DataClass.Generated.Member |
| 139 |
public static String priorityToString(@Priority int value) { |
| 140 |
switch (value) { |
| 141 |
case PRIORITY_UNKNOWN: |
| 142 |
return "PRIORITY_UNKNOWN"; |
| 143 |
case PRIORITY_PRIMARY: |
| 144 |
return "PRIORITY_PRIMARY"; |
| 145 |
case PRIORITY_OVERFLOW: |
| 146 |
return "PRIORITY_OVERFLOW"; |
| 147 |
default: return Integer.toHexString(value); |
| 148 |
} |
| 149 |
} |
| 150 |
|
| 151 |
@DataClass.Generated.Member |
| 152 |
ToolbarMenuItem( |
| 153 |
int itemId, |
| 154 |
@NonNull CharSequence title, |
| 155 |
@Nullable CharSequence contentDescription, |
| 156 |
int groupId, |
| 157 |
@Nullable Icon icon, |
| 158 |
@Nullable CharSequence tooltipText, |
| 159 |
int priority) { |
| 160 |
this.mItemId = itemId; |
| 161 |
this.mTitle = title; |
| 162 |
com.android.internal.util.AnnotationValidations.validate( |
| 163 |
NonNull.class, null, mTitle); |
| 164 |
this.mContentDescription = contentDescription; |
| 165 |
this.mGroupId = groupId; |
| 166 |
this.mIcon = icon; |
| 167 |
this.mTooltipText = tooltipText; |
| 168 |
this.mPriority = priority; |
| 169 |
|
| 170 |
|
| 171 |
} |
| 172 |
|
| 173 |
|
| 174 |
|
| 175 |
|
| 176 |
|
| 177 |
|
| 178 |
@DataClass.Generated.Member |
| 179 |
public int getItemId() { |
| 180 |
return mItemId; |
| 181 |
} |
| 182 |
|
| 183 |
|
| 184 |
|
| 185 |
|
| 186 |
|
| 187 |
|
| 188 |
@DataClass.Generated.Member |
| 189 |
public @NonNull CharSequence getTitle() { |
| 190 |
return mTitle; |
| 191 |
} |
| 192 |
|
| 193 |
|
| 194 |
|
| 195 |
|
| 196 |
|
| 197 |
|
| 198 |
@DataClass.Generated.Member |
| 199 |
public @Nullable CharSequence getContentDescription() { |
| 200 |
return mContentDescription; |
| 201 |
} |
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
@DataClass.Generated.Member |
| 209 |
public int getGroupId() { |
| 210 |
return mGroupId; |
| 211 |
} |
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
@DataClass.Generated.Member |
| 219 |
public @Nullable Icon getIcon() { |
| 220 |
return mIcon; |
| 221 |
} |
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
@DataClass.Generated.Member |
| 229 |
public @Nullable CharSequence getTooltipText() { |
| 230 |
return mTooltipText; |
| 231 |
} |
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
@DataClass.Generated.Member |
| 237 |
public int getPriority() { |
| 238 |
return mPriority; |
| 239 |
} |
| 240 |
|
| 241 |
@Override |
| 242 |
@DataClass.Generated.Member |
| 243 |
public String toString() { |
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
return "ToolbarMenuItem { " + |
| 248 |
"itemId = " + mItemId + ", " + |
| 249 |
"title = " + mTitle + ", " + |
| 250 |
"contentDescription = " + mContentDescription + ", " + |
| 251 |
"groupId = " + mGroupId + ", " + |
| 252 |
"icon = " + mIcon + ", " + |
| 253 |
"tooltipText = " + mTooltipText + ", " + |
| 254 |
"priority = " + mPriority + |
| 255 |
" }"; |
| 256 |
} |
| 257 |
|
| 258 |
@Override |
| 259 |
@DataClass.Generated.Member |
| 260 |
public boolean equals(@Nullable Object o) { |
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
if (this == o) return true; |
| 266 |
if (o == null || getClass() != o.getClass()) return false; |
| 267 |
@SuppressWarnings("unchecked") |
| 268 |
ToolbarMenuItem that = (ToolbarMenuItem) o; |
| 269 |
|
| 270 |
return true |
| 271 |
&& mItemId == that.mItemId |
| 272 |
&& java.util.Objects.equals(mTitle, that.mTitle) |
| 273 |
&& java.util.Objects.equals(mContentDescription, that.mContentDescription) |
| 274 |
&& mGroupId == that.mGroupId |
| 275 |
&& java.util.Objects.equals(mIcon, that.mIcon) |
| 276 |
&& java.util.Objects.equals(mTooltipText, that.mTooltipText) |
| 277 |
&& mPriority == that.mPriority; |
| 278 |
} |
| 279 |
|
| 280 |
@Override |
| 281 |
@DataClass.Generated.Member |
| 282 |
public int hashCode() { |
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
int _hash = 1; |
| 287 |
_hash = 31 * _hash + mItemId; |
| 288 |
_hash = 31 * _hash + java.util.Objects.hashCode(mTitle); |
| 289 |
_hash = 31 * _hash + java.util.Objects.hashCode(mContentDescription); |
| 290 |
_hash = 31 * _hash + mGroupId; |
| 291 |
_hash = 31 * _hash + java.util.Objects.hashCode(mIcon); |
| 292 |
_hash = 31 * _hash + java.util.Objects.hashCode(mTooltipText); |
| 293 |
_hash = 31 * _hash + mPriority; |
| 294 |
return _hash; |
| 295 |
} |
| 296 |
|
| 297 |
@Override |
| 298 |
@DataClass.Generated.Member |
| 299 |
public void writeToParcel(@NonNull android.os.Parcel dest, int flags) { |
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
byte flg = 0; |
| 304 |
if (mContentDescription != null) flg |= 0x4; |
| 305 |
if (mIcon != null) flg |= 0x10; |
| 306 |
if (mTooltipText != null) flg |= 0x20; |
| 307 |
dest.writeByte(flg); |
| 308 |
dest.writeInt(mItemId); |
| 309 |
dest.writeCharSequence(mTitle); |
| 310 |
if (mContentDescription != null) dest.writeCharSequence(mContentDescription); |
| 311 |
dest.writeInt(mGroupId); |
| 312 |
if (mIcon != null) dest.writeTypedObject(mIcon, flags); |
| 313 |
if (mTooltipText != null) dest.writeCharSequence(mTooltipText); |
| 314 |
dest.writeInt(mPriority); |
| 315 |
} |
| 316 |
|
| 317 |
@Override |
| 318 |
@DataClass.Generated.Member |
| 319 |
public int describeContents() { return 0; } |
| 320 |
|
| 321 |
|
| 322 |
@SuppressWarnings({"unchecked", "RedundantCast"}) |
| 323 |
@DataClass.Generated.Member |
| 324 |
ToolbarMenuItem(@NonNull android.os.Parcel in) { |
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
byte flg = in.readByte(); |
| 329 |
int itemId = in.readInt(); |
| 330 |
CharSequence title = (CharSequence) in.readCharSequence(); |
| 331 |
CharSequence contentDescription = (flg & 0x4) == 0 ? null : (CharSequence) in.readCharSequence(); |
| 332 |
int groupId = in.readInt(); |
| 333 |
Icon icon = (flg & 0x10) == 0 ? null : (Icon) in.readTypedObject(Icon.CREATOR); |
| 334 |
CharSequence tooltipText = (flg & 0x20) == 0 ? null : (CharSequence) in.readCharSequence(); |
| 335 |
int priority = in.readInt(); |
| 336 |
|
| 337 |
this.mItemId = itemId; |
| 338 |
this.mTitle = title; |
| 339 |
com.android.internal.util.AnnotationValidations.validate( |
| 340 |
NonNull.class, null, mTitle); |
| 341 |
this.mContentDescription = contentDescription; |
| 342 |
this.mGroupId = groupId; |
| 343 |
this.mIcon = icon; |
| 344 |
this.mTooltipText = tooltipText; |
| 345 |
this.mPriority = priority; |
| 346 |
|
| 347 |
|
| 348 |
} |
| 349 |
|
| 350 |
@DataClass.Generated.Member |
| 351 |
public static final @NonNull Parcelable.Creator<ToolbarMenuItem> CREATOR |
| 352 |
= new Parcelable.Creator<ToolbarMenuItem>() { |
| 353 |
@Override |
| 354 |
public ToolbarMenuItem[] newArray(int size) { |
| 355 |
return new ToolbarMenuItem[size]; |
| 356 |
} |
| 357 |
|
| 358 |
@Override |
| 359 |
public ToolbarMenuItem createFromParcel(@NonNull android.os.Parcel in) { |
| 360 |
return new ToolbarMenuItem(in); |
| 361 |
} |
| 362 |
}; |
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
@SuppressWarnings("WeakerAccess") |
| 368 |
@DataClass.Generated.Member |
| 369 |
public static final class Builder { |
| 370 |
|
| 371 |
private int mItemId; |
| 372 |
private @NonNull CharSequence mTitle; |
| 373 |
private @Nullable CharSequence mContentDescription; |
| 374 |
private int mGroupId; |
| 375 |
private @Nullable Icon mIcon; |
| 376 |
private @Nullable CharSequence mTooltipText; |
| 377 |
private int mPriority; |
| 378 |
|
| 379 |
private long mBuilderFieldsSet = 0L; |
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
public Builder( |
| 400 |
int itemId, |
| 401 |
@NonNull CharSequence title, |
| 402 |
@Nullable CharSequence contentDescription, |
| 403 |
int groupId, |
| 404 |
@Nullable Icon icon, |
| 405 |
@Nullable CharSequence tooltipText, |
| 406 |
int priority) { |
| 407 |
mItemId = itemId; |
| 408 |
mTitle = title; |
| 409 |
com.android.internal.util.AnnotationValidations.validate( |
| 410 |
NonNull.class, null, mTitle); |
| 411 |
mContentDescription = contentDescription; |
| 412 |
mGroupId = groupId; |
| 413 |
mIcon = icon; |
| 414 |
mTooltipText = tooltipText; |
| 415 |
mPriority = priority; |
| 416 |
} |
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
@DataClass.Generated.Member |
| 424 |
public @NonNull Builder setItemId(int value) { |
| 425 |
checkNotUsed(); |
| 426 |
mBuilderFieldsSet |= 0x1; |
| 427 |
mItemId = value; |
| 428 |
return this; |
| 429 |
} |
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
@DataClass.Generated.Member |
| 437 |
public @NonNull Builder setTitle(@NonNull CharSequence value) { |
| 438 |
checkNotUsed(); |
| 439 |
mBuilderFieldsSet |= 0x2; |
| 440 |
mTitle = value; |
| 441 |
return this; |
| 442 |
} |
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
@DataClass.Generated.Member |
| 450 |
public @NonNull Builder setContentDescription(@NonNull CharSequence value) { |
| 451 |
checkNotUsed(); |
| 452 |
mBuilderFieldsSet |= 0x4; |
| 453 |
mContentDescription = value; |
| 454 |
return this; |
| 455 |
} |
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
@DataClass.Generated.Member |
| 463 |
public @NonNull Builder setGroupId(int value) { |
| 464 |
checkNotUsed(); |
| 465 |
mBuilderFieldsSet |= 0x8; |
| 466 |
mGroupId = value; |
| 467 |
return this; |
| 468 |
} |
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
@DataClass.Generated.Member |
| 476 |
public @NonNull Builder setIcon(@NonNull Icon value) { |
| 477 |
checkNotUsed(); |
| 478 |
mBuilderFieldsSet |= 0x10; |
| 479 |
mIcon = value; |
| 480 |
return this; |
| 481 |
} |
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
@DataClass.Generated.Member |
| 489 |
public @NonNull Builder setTooltipText(@NonNull CharSequence value) { |
| 490 |
checkNotUsed(); |
| 491 |
mBuilderFieldsSet |= 0x20; |
| 492 |
mTooltipText = value; |
| 493 |
return this; |
| 494 |
} |
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
@DataClass.Generated.Member |
| 500 |
public @NonNull Builder setPriority(int value) { |
| 501 |
checkNotUsed(); |
| 502 |
mBuilderFieldsSet |= 0x40; |
| 503 |
mPriority = value; |
| 504 |
return this; |
| 505 |
} |
| 506 |
|
| 507 |
|
| 508 |
public @NonNull ToolbarMenuItem build() { |
| 509 |
checkNotUsed(); |
| 510 |
mBuilderFieldsSet |= 0x80; |
| 511 |
|
| 512 |
ToolbarMenuItem o = new ToolbarMenuItem( |
| 513 |
mItemId, |
| 514 |
mTitle, |
| 515 |
mContentDescription, |
| 516 |
mGroupId, |
| 517 |
mIcon, |
| 518 |
mTooltipText, |
| 519 |
mPriority); |
| 520 |
return o; |
| 521 |
} |
| 522 |
|
| 523 |
private void checkNotUsed() { |
| 524 |
if ((mBuilderFieldsSet & 0x80) != 0) { |
| 525 |
throw new IllegalStateException( |
| 526 |
"This Builder should not be reused. Use a new Builder instance instead"); |
| 527 |
} |
| 528 |
} |
| 529 |
} |
| 530 |
|
| 531 |
@DataClass.Generated( |
| 532 |
time = 1643200806234L, |
| 533 |
codegenVersion = "1.0.23", |
| 534 |
sourceFile = "frameworks/base/core/java/android/view/selectiontoolbar/ToolbarMenuItem.java", |
| 535 |
inputSignatures = "public static final int PRIORITY_UNKNOWN\npublic static final int PRIORITY_PRIMARY\npublic static final int PRIORITY_OVERFLOW\nprivate final int mItemId\nprivate final @android.annotation.NonNull java.lang.CharSequence mTitle\nprivate final @android.annotation.Nullable java.lang.CharSequence mContentDescription\nprivate final int mGroupId\nprivate final @android.annotation.Nullable android.graphics.drawable.Icon mIcon\nprivate final @android.annotation.Nullable java.lang.CharSequence mTooltipText\nprivate final int mPriority\npublic static int getPriorityFromMenuItem(android.view.MenuItem)\nclass ToolbarMenuItem extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genBuilder=true, genToString=true, genEqualsHashCode=true)") |
| 536 |
@Deprecated |
| 537 |
private void __metadata() {} |
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
} |