| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
package android.view; |
| 18 |
|
| 19 |
import static android.content.res.Resources.ID_NULL; |
| 20 |
import static android.view.ContentInfo.SOURCE_DRAG_AND_DROP; |
| 21 |
import static android.view.accessibility.AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED; |
| 22 |
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_INVALID_BOUNDS; |
| 23 |
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_MISSING_WINDOW; |
| 24 |
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN; |
| 25 |
import static android.view.displayhash.DisplayHashResultCallback.DISPLAY_HASH_ERROR_UNKNOWN; |
| 26 |
import static android.view.displayhash.DisplayHashResultCallback.EXTRA_DISPLAY_HASH; |
| 27 |
import static android.view.displayhash.DisplayHashResultCallback.EXTRA_DISPLAY_HASH_ERROR_CODE; |
| 28 |
|
| 29 |
import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS; |
| 30 |
import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS; |
| 31 |
import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP; |
| 32 |
import static com.android.internal.util.FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION; |
| 33 |
|
| 34 |
import static java.lang.Math.max; |
| 35 |
|
| 36 |
import android.animation.AnimatorInflater; |
| 37 |
import android.animation.StateListAnimator; |
| 38 |
import android.annotation.AttrRes; |
| 39 |
import android.annotation.CallSuper; |
| 40 |
import android.annotation.ColorInt; |
| 41 |
import android.annotation.DrawableRes; |
| 42 |
import android.annotation.FloatRange; |
| 43 |
import android.annotation.IdRes; |
| 44 |
import android.annotation.IntDef; |
| 45 |
import android.annotation.IntRange; |
| 46 |
import android.annotation.LayoutRes; |
| 47 |
import android.annotation.NonNull; |
| 48 |
import android.annotation.Nullable; |
| 49 |
import android.annotation.RequiresPermission; |
| 50 |
import android.annotation.Size; |
| 51 |
import android.annotation.StyleRes; |
| 52 |
import android.annotation.SuppressLint; |
| 53 |
import android.annotation.SystemApi; |
| 54 |
import android.annotation.TestApi; |
| 55 |
import android.annotation.UiContext; |
| 56 |
import android.annotation.UiThread; |
| 57 |
import android.compat.annotation.UnsupportedAppUsage; |
| 58 |
import android.content.AutofillOptions; |
| 59 |
import android.content.ClipData; |
| 60 |
import android.content.ClipDescription; |
| 61 |
import android.content.Context; |
| 62 |
import android.content.ContextWrapper; |
| 63 |
import android.content.Intent; |
| 64 |
import android.content.res.ColorStateList; |
| 65 |
import android.content.res.Configuration; |
| 66 |
import android.content.res.Resources; |
| 67 |
import android.content.res.TypedArray; |
| 68 |
import android.graphics.Bitmap; |
| 69 |
import android.graphics.BlendMode; |
| 70 |
import android.graphics.Canvas; |
| 71 |
import android.graphics.Color; |
| 72 |
import android.graphics.Insets; |
| 73 |
import android.graphics.Interpolator; |
| 74 |
import android.graphics.LinearGradient; |
| 75 |
import android.graphics.Matrix; |
| 76 |
import android.graphics.Outline; |
| 77 |
import android.graphics.Paint; |
| 78 |
import android.graphics.PixelFormat; |
| 79 |
import android.graphics.Point; |
| 80 |
import android.graphics.PorterDuff; |
| 81 |
import android.graphics.PorterDuffXfermode; |
| 82 |
import android.graphics.RecordingCanvas; |
| 83 |
import android.graphics.Rect; |
| 84 |
import android.graphics.RectF; |
| 85 |
import android.graphics.Region; |
| 86 |
import android.graphics.RenderEffect; |
| 87 |
import android.graphics.RenderNode; |
| 88 |
import android.graphics.Shader; |
| 89 |
import android.graphics.drawable.ColorDrawable; |
| 90 |
import android.graphics.drawable.Drawable; |
| 91 |
import android.graphics.drawable.GradientDrawable; |
| 92 |
import android.hardware.display.DisplayManagerGlobal; |
| 93 |
import android.net.Uri; |
| 94 |
import android.os.Build; |
| 95 |
import android.os.Bundle; |
| 96 |
import android.os.Handler; |
| 97 |
import android.os.IBinder; |
| 98 |
import android.os.Message; |
| 99 |
import android.os.Parcel; |
| 100 |
import android.os.Parcelable; |
| 101 |
import android.os.RemoteCallback; |
| 102 |
import android.os.RemoteException; |
| 103 |
import android.os.SystemClock; |
| 104 |
import android.os.Trace; |
| 105 |
import android.sysprop.DisplayProperties; |
| 106 |
import android.text.InputType; |
| 107 |
import android.text.TextUtils; |
| 108 |
import android.util.AttributeSet; |
| 109 |
import android.util.FloatProperty; |
| 110 |
import android.util.LayoutDirection; |
| 111 |
import android.util.Log; |
| 112 |
import android.util.LongSparseArray; |
| 113 |
import android.util.LongSparseLongArray; |
| 114 |
import android.util.Pair; |
| 115 |
import android.util.Pools.SynchronizedPool; |
| 116 |
import android.util.Property; |
| 117 |
import android.util.SparseArray; |
| 118 |
import android.util.SparseIntArray; |
| 119 |
import android.util.StateSet; |
| 120 |
import android.util.SuperNotCalledException; |
| 121 |
import android.util.TypedValue; |
| 122 |
import android.view.AccessibilityIterators.CharacterTextSegmentIterator; |
| 123 |
import android.view.AccessibilityIterators.ParagraphTextSegmentIterator; |
| 124 |
import android.view.AccessibilityIterators.TextSegmentIterator; |
| 125 |
import android.view.AccessibilityIterators.WordTextSegmentIterator; |
| 126 |
import android.view.ContextMenu.ContextMenuInfo; |
| 127 |
import android.view.InputDevice.InputSourceClass; |
| 128 |
import android.view.Window.OnContentApplyWindowInsetsListener; |
| 129 |
import android.view.WindowInsets.Type; |
| 130 |
import android.view.WindowInsetsAnimation.Bounds; |
| 131 |
import android.view.WindowManager.LayoutParams; |
| 132 |
import android.view.accessibility.AccessibilityEvent; |
| 133 |
import android.view.accessibility.AccessibilityEventSource; |
| 134 |
import android.view.accessibility.AccessibilityManager; |
| 135 |
import android.view.accessibility.AccessibilityNodeIdManager; |
| 136 |
import android.view.accessibility.AccessibilityNodeInfo; |
| 137 |
import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction; |
| 138 |
import android.view.accessibility.AccessibilityNodeProvider; |
| 139 |
import android.view.accessibility.AccessibilityWindowInfo; |
| 140 |
import android.view.animation.Animation; |
| 141 |
import android.view.animation.AnimationUtils; |
| 142 |
import android.view.animation.Transformation; |
| 143 |
import android.view.autofill.AutofillId; |
| 144 |
import android.view.autofill.AutofillManager; |
| 145 |
import android.view.autofill.AutofillValue; |
| 146 |
import android.view.contentcapture.ContentCaptureContext; |
| 147 |
import android.view.contentcapture.ContentCaptureManager; |
| 148 |
import android.view.contentcapture.ContentCaptureSession; |
| 149 |
import android.view.displayhash.DisplayHash; |
| 150 |
import android.view.displayhash.DisplayHashManager; |
| 151 |
import android.view.displayhash.DisplayHashResultCallback; |
| 152 |
import android.view.inputmethod.EditorInfo; |
| 153 |
import android.view.inputmethod.InputConnection; |
| 154 |
import android.view.inspector.InspectableProperty; |
| 155 |
import android.view.inspector.InspectableProperty.EnumEntry; |
| 156 |
import android.view.inspector.InspectableProperty.FlagEntry; |
| 157 |
import android.view.translation.TranslationCapability; |
| 158 |
import android.view.translation.TranslationSpec.DataFormat; |
| 159 |
import android.view.translation.ViewTranslationCallback; |
| 160 |
import android.view.translation.ViewTranslationRequest; |
| 161 |
import android.view.translation.ViewTranslationResponse; |
| 162 |
import android.widget.Checkable; |
| 163 |
import android.widget.FrameLayout; |
| 164 |
import android.widget.ScrollBarDrawable; |
| 165 |
import android.window.OnBackInvokedDispatcher; |
| 166 |
|
| 167 |
import com.android.internal.R; |
| 168 |
import com.android.internal.util.ArrayUtils; |
| 169 |
import com.android.internal.util.FrameworkStatsLog; |
| 170 |
import com.android.internal.util.Preconditions; |
| 171 |
import com.android.internal.view.ScrollCaptureInternal; |
| 172 |
import com.android.internal.view.TooltipPopup; |
| 173 |
import com.android.internal.view.menu.MenuBuilder; |
| 174 |
import com.android.internal.widget.ScrollBarUtils; |
| 175 |
|
| 176 |
import com.google.android.collect.Lists; |
| 177 |
import com.google.android.collect.Maps; |
| 178 |
|
| 179 |
import java.io.PrintWriter; |
| 180 |
import java.lang.annotation.Retention; |
| 181 |
import java.lang.annotation.RetentionPolicy; |
| 182 |
import java.lang.ref.WeakReference; |
| 183 |
import java.lang.reflect.Field; |
| 184 |
import java.lang.reflect.InvocationTargetException; |
| 185 |
import java.lang.reflect.Method; |
| 186 |
import java.lang.reflect.Modifier; |
| 187 |
import java.util.ArrayList; |
| 188 |
import java.util.Arrays; |
| 189 |
import java.util.Calendar; |
| 190 |
import java.util.Collection; |
| 191 |
import java.util.Collections; |
| 192 |
import java.util.HashMap; |
| 193 |
import java.util.List; |
| 194 |
import java.util.Locale; |
| 195 |
import java.util.Map; |
| 196 |
import java.util.concurrent.CopyOnWriteArrayList; |
| 197 |
import java.util.concurrent.Executor; |
| 198 |
import java.util.concurrent.atomic.AtomicInteger; |
| 199 |
import java.util.function.Consumer; |
| 200 |
import java.util.function.Predicate; |
| 201 |
|
| 202 |
|
| 203 |
|
| 204 |
|
| 205 |
|
| 206 |
|
| 207 |
|
| 208 |
|
| 209 |
|
| 210 |
|
| 211 |
|
| 212 |
|
| 213 |
|
| 214 |
|
| 215 |
|
| 216 |
|
| 217 |
|
| 218 |
|
| 219 |
|
| 220 |
|
| 221 |
|
| 222 |
|
| 223 |
|
| 224 |
|
| 225 |
|
| 226 |
|
| 227 |
|
| 228 |
|
| 229 |
|
| 230 |
|
| 231 |
|
| 232 |
|
| 233 |
|
| 234 |
|
| 235 |
|
| 236 |
|
| 237 |
|
| 238 |
|
| 239 |
|
| 240 |
|
| 241 |
|
| 242 |
|
| 243 |
|
| 244 |
|
| 245 |
|
| 246 |
|
| 247 |
|
| 248 |
|
| 249 |
|
| 250 |
|
| 251 |
|
| 252 |
|
| 253 |
|
| 254 |
|
| 255 |
|
| 256 |
|
| 257 |
|
| 258 |
|
| 259 |
|
| 260 |
|
| 261 |
|
| 262 |
|
| 263 |
|
| 264 |
|
| 265 |
|
| 266 |
|
| 267 |
|
| 268 |
|
| 269 |
|
| 270 |
|
| 271 |
|
| 272 |
|
| 273 |
|
| 274 |
|
| 275 |
|
| 276 |
|
| 277 |
|
| 278 |
|
| 279 |
|
| 280 |
|
| 281 |
|
| 282 |
|
| 283 |
|
| 284 |
|
| 285 |
|
| 286 |
|
| 287 |
|
| 288 |
|
| 289 |
|
| 290 |
|
| 291 |
|
| 292 |
|
| 293 |
|
| 294 |
|
| 295 |
|
| 296 |
|
| 297 |
|
| 298 |
|
| 299 |
|
| 300 |
|
| 301 |
|
| 302 |
|
| 303 |
|
| 304 |
|
| 305 |
|
| 306 |
|
| 307 |
|
| 308 |
|
| 309 |
|
| 310 |
|
| 311 |
|
| 312 |
|
| 313 |
|
| 314 |
|
| 315 |
|
| 316 |
|
| 317 |
|
| 318 |
|
| 319 |
|
| 320 |
|
| 321 |
|
| 322 |
|
| 323 |
|
| 324 |
|
| 325 |
|
| 326 |
|
| 327 |
|
| 328 |
|
| 329 |
|
| 330 |
|
| 331 |
|
| 332 |
|
| 333 |
|
| 334 |
|
| 335 |
|
| 336 |
|
| 337 |
|
| 338 |
|
| 339 |
|
| 340 |
|
| 341 |
|
| 342 |
|
| 343 |
|
| 344 |
|
| 345 |
|
| 346 |
|
| 347 |
|
| 348 |
|
| 349 |
|
| 350 |
|
| 351 |
|
| 352 |
|
| 353 |
|
| 354 |
|
| 355 |
|
| 356 |
|
| 357 |
|
| 358 |
|
| 359 |
|
| 360 |
|
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
|
| 365 |
|
| 366 |
|
| 367 |
|
| 368 |
|
| 369 |
|
| 370 |
|
| 371 |
|
| 372 |
|
| 373 |
|
| 374 |
|
| 375 |
|
| 376 |
|
| 377 |
|
| 378 |
|
| 379 |
|
| 380 |
|
| 381 |
|
| 382 |
|
| 383 |
|
| 384 |
|
| 385 |
|
| 386 |
|
| 387 |
|
| 388 |
|
| 389 |
|
| 390 |
|
| 391 |
|
| 392 |
|
| 393 |
|
| 394 |
|
| 395 |
|
| 396 |
|
| 397 |
|
| 398 |
|
| 399 |
|
| 400 |
|
| 401 |
|
| 402 |
|
| 403 |
|
| 404 |
|
| 405 |
|
| 406 |
|
| 407 |
|
| 408 |
|
| 409 |
|
| 410 |
|
| 411 |
|
| 412 |
|
| 413 |
|
| 414 |
|
| 415 |
|
| 416 |
|
| 417 |
|
| 418 |
|
| 419 |
|
| 420 |
|
| 421 |
|
| 422 |
|
| 423 |
|
| 424 |
|
| 425 |
|
| 426 |
|
| 427 |
|
| 428 |
|
| 429 |
|
| 430 |
|
| 431 |
|
| 432 |
|
| 433 |
|
| 434 |
|
| 435 |
|
| 436 |
|
| 437 |
|
| 438 |
|
| 439 |
|
| 440 |
|
| 441 |
|
| 442 |
|
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
|
| 449 |
|
| 450 |
|
| 451 |
|
| 452 |
|
| 453 |
|
| 454 |
|
| 455 |
|
| 456 |
|
| 457 |
|
| 458 |
|
| 459 |
|
| 460 |
|
| 461 |
|
| 462 |
|
| 463 |
|
| 464 |
|
| 465 |
|
| 466 |
|
| 467 |
|
| 468 |
|
| 469 |
|
| 470 |
|
| 471 |
|
| 472 |
|
| 473 |
|
| 474 |
|
| 475 |
|
| 476 |
|
| 477 |
|
| 478 |
|
| 479 |
|
| 480 |
|
| 481 |
|
| 482 |
|
| 483 |
|
| 484 |
|
| 485 |
|
| 486 |
|
| 487 |
|
| 488 |
|
| 489 |
|
| 490 |
|
| 491 |
|
| 492 |
|
| 493 |
|
| 494 |
|
| 495 |
|
| 496 |
|
| 497 |
|
| 498 |
|
| 499 |
|
| 500 |
|
| 501 |
|
| 502 |
|
| 503 |
|
| 504 |
|
| 505 |
|
| 506 |
|
| 507 |
|
| 508 |
|
| 509 |
|
| 510 |
|
| 511 |
|
| 512 |
|
| 513 |
|
| 514 |
|
| 515 |
|
| 516 |
|
| 517 |
|
| 518 |
|
| 519 |
|
| 520 |
|
| 521 |
|
| 522 |
|
| 523 |
|
| 524 |
|
| 525 |
|
| 526 |
|
| 527 |
|
| 528 |
|
| 529 |
|
| 530 |
|
| 531 |
|
| 532 |
|
| 533 |
|
| 534 |
|
| 535 |
|
| 536 |
|
| 537 |
|
| 538 |
|
| 539 |
|
| 540 |
|
| 541 |
|
| 542 |
|
| 543 |
|
| 544 |
|
| 545 |
|
| 546 |
|
| 547 |
|
| 548 |
|
| 549 |
|
| 550 |
|
| 551 |
|
| 552 |
|
| 553 |
|
| 554 |
|
| 555 |
|
| 556 |
|
| 557 |
|
| 558 |
|
| 559 |
|
| 560 |
|
| 561 |
|
| 562 |
|
| 563 |
|
| 564 |
|
| 565 |
|
| 566 |
|
| 567 |
|
| 568 |
|
| 569 |
|
| 570 |
|
| 571 |
|
| 572 |
|
| 573 |
|
| 574 |
|
| 575 |
|
| 576 |
|
| 577 |
|
| 578 |
|
| 579 |
|
| 580 |
|
| 581 |
|
| 582 |
|
| 583 |
|
| 584 |
|
| 585 |
|
| 586 |
|
| 587 |
|
| 588 |
|
| 589 |
|
| 590 |
|
| 591 |
|
| 592 |
|
| 593 |
|
| 594 |
|
| 595 |
|
| 596 |
|
| 597 |
|
| 598 |
|
| 599 |
|
| 600 |
|
| 601 |
|
| 602 |
|
| 603 |
|
| 604 |
|
| 605 |
|
| 606 |
|
| 607 |
|
| 608 |
|
| 609 |
|
| 610 |
|
| 611 |
|
| 612 |
|
| 613 |
|
| 614 |
|
| 615 |
|
| 616 |
|
| 617 |
|
| 618 |
|
| 619 |
|
| 620 |
|
| 621 |
|
| 622 |
|
| 623 |
|
| 624 |
|
| 625 |
|
| 626 |
|
| 627 |
|
| 628 |
|
| 629 |
|
| 630 |
|
| 631 |
|
| 632 |
|
| 633 |
|
| 634 |
|
| 635 |
|
| 636 |
|
| 637 |
|
| 638 |
|
| 639 |
|
| 640 |
|
| 641 |
|
| 642 |
|
| 643 |
|
| 644 |
|
| 645 |
|
| 646 |
|
| 647 |
|
| 648 |
|
| 649 |
|
| 650 |
|
| 651 |
|
| 652 |
|
| 653 |
|
| 654 |
|
| 655 |
|
| 656 |
|
| 657 |
|
| 658 |
|
| 659 |
|
| 660 |
|
| 661 |
|
| 662 |
|
| 663 |
|
| 664 |
|
| 665 |
|
| 666 |
|
| 667 |
|
| 668 |
|
| 669 |
|
| 670 |
|
| 671 |
|
| 672 |
|
| 673 |
|
| 674 |
|
| 675 |
|
| 676 |
|
| 677 |
|
| 678 |
|
| 679 |
|
| 680 |
|
| 681 |
|
| 682 |
|
| 683 |
|
| 684 |
|
| 685 |
|
| 686 |
|
| 687 |
|
| 688 |
|
| 689 |
|
| 690 |
|
| 691 |
|
| 692 |
|
| 693 |
|
| 694 |
|
| 695 |
|
| 696 |
|
| 697 |
|
| 698 |
|
| 699 |
|
| 700 |
|
| 701 |
|
| 702 |
|
| 703 |
|
| 704 |
|
| 705 |
|
| 706 |
|
| 707 |
|
| 708 |
|
| 709 |
|
| 710 |
|
| 711 |
|
| 712 |
|
| 713 |
|
| 714 |
|
| 715 |
|
| 716 |
|
| 717 |
|
| 718 |
|
| 719 |
|
| 720 |
|
| 721 |
|
| 722 |
|
| 723 |
|
| 724 |
|
| 725 |
|
| 726 |
|
| 727 |
|
| 728 |
|
| 729 |
|
| 730 |
|
| 731 |
|
| 732 |
|
| 733 |
|
| 734 |
|
| 735 |
|
| 736 |
|
| 737 |
|
| 738 |
|
| 739 |
|
| 740 |
|
| 741 |
|
| 742 |
|
| 743 |
|
| 744 |
|
| 745 |
|
| 746 |
|
| 747 |
|
| 748 |
|
| 749 |
|
| 750 |
|
| 751 |
|
| 752 |
|
| 753 |
|
| 754 |
|
| 755 |
|
| 756 |
|
| 757 |
|
| 758 |
|
| 759 |
|
| 760 |
|
| 761 |
|
| 762 |
|
| 763 |
|
| 764 |
|
| 765 |
|
| 766 |
|
| 767 |
|
| 768 |
|
| 769 |
|
| 770 |
|
| 771 |
|
| 772 |
|
| 773 |
|
| 774 |
|
| 775 |
|
| 776 |
|
| 777 |
|
| 778 |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 |
|
| 785 |
|
| 786 |
|
| 787 |
|
| 788 |
|
| 789 |
|
| 790 |
|
| 791 |
|
| 792 |
|
| 793 |
|
| 794 |
|
| 795 |
|
| 796 |
|
| 797 |
|
| 798 |
|
| 799 |
|
| 800 |
|
| 801 |
|
| 802 |
|
| 803 |
|
| 804 |
|
| 805 |
|
| 806 |
|
| 807 |
|
| 808 |
|
| 809 |
|
| 810 |
|
| 811 |
|
| 812 |
|
| 813 |
|
| 814 |
|
| 815 |
|
| 816 |
|
| 817 |
|
| 818 |
|
| 819 |
|
| 820 |
|
| 821 |
|
| 822 |
|
| 823 |
|
| 824 |
|
| 825 |
|
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
|
| 831 |
|
| 832 |
|
| 833 |
|
| 834 |
|
| 835 |
|
| 836 |
|
| 837 |
|
| 838 |
@UiThread |
| 839 |
public class View implements Drawable.Callback, KeyEvent.Callback, |
| 840 |
AccessibilityEventSource { |
| 841 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 842 |
private static final boolean DBG = false; |
| 843 |
|
| 844 |
|
| 845 |
public static boolean DEBUG_DRAW = false; |
| 846 |
|
| 847 |
|
| 848 |
|
| 849 |
|
| 850 |
protected static final String VIEW_LOG_TAG = "View"; |
| 851 |
|
| 852 |
|
| 853 |
|
| 854 |
|
| 855 |
|
| 856 |
|
| 857 |
private static final String AUTOFILL_LOG_TAG = "View.Autofill"; |
| 858 |
|
| 859 |
|
| 860 |
|
| 861 |
|
| 862 |
private static final String CONTENT_CAPTURE_LOG_TAG = "View.ContentCapture"; |
| 863 |
|
| 864 |
private static final boolean DEBUG_CONTENT_CAPTURE = false; |
| 865 |
|
| 866 |
|
| 867 |
|
| 868 |
|
| 869 |
|
| 870 |
|
| 871 |
public static boolean sDebugViewAttributes = false; |
| 872 |
|
| 873 |
|
| 874 |
|
| 875 |
|
| 876 |
|
| 877 |
|
| 878 |
public static String sDebugViewAttributesApplicationPackage; |
| 879 |
|
| 880 |
|
| 881 |
|
| 882 |
|
| 883 |
public static final int NO_ID = -1; |
| 884 |
|
| 885 |
|
| 886 |
|
| 887 |
|
| 888 |
|
| 889 |
|
| 890 |
public static final int LAST_APP_AUTOFILL_ID = Integer.MAX_VALUE / 2; |
| 891 |
|
| 892 |
|
| 893 |
|
| 894 |
|
| 895 |
|
| 896 |
|
| 897 |
private static final int[] AUTOFILL_HIGHLIGHT_ATTR = |
| 898 |
new int[]{android.R.attr.autofilledHighlight}; |
| 899 |
|
| 900 |
|
| 901 |
|
| 902 |
|
| 903 |
|
| 904 |
private static boolean sCompatibilityDone = false; |
| 905 |
|
| 906 |
|
| 907 |
|
| 908 |
|
| 909 |
private static boolean sUseBrokenMakeMeasureSpec = false; |
| 910 |
|
| 911 |
|
| 912 |
|
| 913 |
|
| 914 |
static boolean sUseZeroUnspecifiedMeasureSpec = false; |
| 915 |
|
| 916 |
|
| 917 |
|
| 918 |
|
| 919 |
private static boolean sIgnoreMeasureCache = false; |
| 920 |
|
| 921 |
|
| 922 |
|
| 923 |
|
| 924 |
private static boolean sAlwaysRemeasureExactly = false; |
| 925 |
|
| 926 |
|
| 927 |
|
| 928 |
|
| 929 |
|
| 930 |
static boolean sTextureViewIgnoresDrawableSetters = false; |
| 931 |
|
| 932 |
|
| 933 |
|
| 934 |
|
| 935 |
|
| 936 |
|
| 937 |
|
| 938 |
|
| 939 |
|
| 940 |
protected static boolean sPreserveMarginParamsInLayoutParamConversion; |
| 941 |
|
| 942 |
|
| 943 |
|
| 944 |
|
| 945 |
|
| 946 |
|
| 947 |
|
| 948 |
|
| 949 |
|
| 950 |
|
| 951 |
static boolean sCascadedDragDrop; |
| 952 |
|
| 953 |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 |
|
| 958 |
|
| 959 |
static boolean sHasFocusableExcludeAutoFocusable; |
| 960 |
|
| 961 |
|
| 962 |
|
| 963 |
|
| 964 |
|
| 965 |
|
| 966 |
|
| 967 |
|
| 968 |
|
| 969 |
|
| 970 |
private static boolean sAutoFocusableOffUIThreadWontNotifyParents; |
| 971 |
|
| 972 |
|
| 973 |
|
| 974 |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 |
private static boolean sThrowOnInvalidFloatProperties; |
| 980 |
|
| 981 |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 |
private static boolean sAcceptZeroSizeDragShadow; |
| 986 |
|
| 987 |
|
| 988 |
|
| 989 |
|
| 990 |
|
| 991 |
|
| 992 |
|
| 993 |
|
| 994 |
|
| 995 |
|
| 996 |
|
| 997 |
static boolean sBrokenInsetsDispatch; |
| 998 |
|
| 999 |
|
| 1000 |
|
| 1001 |
|
| 1002 |
|
| 1003 |
|
| 1004 |
|
| 1005 |
|
| 1006 |
|
| 1007 |
|
| 1008 |
|
| 1009 |
|
| 1010 |
protected static boolean sBrokenWindowBackground; |
| 1011 |
|
| 1012 |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 |
static boolean sForceLayoutWhenInsetsChanged; |
| 1018 |
|
| 1019 |
|
| 1020 |
@IntDef({NOT_FOCUSABLE, FOCUSABLE, FOCUSABLE_AUTO}) |
| 1021 |
@Retention(RetentionPolicy.SOURCE) |
| 1022 |
public @interface Focusable {} |
| 1023 |
|
| 1024 |
|
| 1025 |
|
| 1026 |
|
| 1027 |
|
| 1028 |
|
| 1029 |
|
| 1030 |
public static final int NOT_FOCUSABLE = 0x00000000; |
| 1031 |
|
| 1032 |
|
| 1033 |
|
| 1034 |
|
| 1035 |
|
| 1036 |
|
| 1037 |
|
| 1038 |
public static final int FOCUSABLE = 0x00000001; |
| 1039 |
|
| 1040 |
|
| 1041 |
|
| 1042 |
|
| 1043 |
|
| 1044 |
|
| 1045 |
|
| 1046 |
public static final int FOCUSABLE_AUTO = 0x00000010; |
| 1047 |
|
| 1048 |
|
| 1049 |
|
| 1050 |
|
| 1051 |
private static final int FOCUSABLE_MASK = 0x00000011; |
| 1052 |
|
| 1053 |
|
| 1054 |
|
| 1055 |
|
| 1056 |
private static final int FITS_SYSTEM_WINDOWS = 0x00000002; |
| 1057 |
|
| 1058 |
|
| 1059 |
@IntDef({VISIBLE, INVISIBLE, GONE}) |
| 1060 |
@Retention(RetentionPolicy.SOURCE) |
| 1061 |
public @interface Visibility {} |
| 1062 |
|
| 1063 |
|
| 1064 |
|
| 1065 |
|
| 1066 |
|
| 1067 |
|
| 1068 |
public static final int VISIBLE = 0x00000000; |
| 1069 |
|
| 1070 |
|
| 1071 |
|
| 1072 |
|
| 1073 |
|
| 1074 |
|
| 1075 |
public static final int INVISIBLE = 0x00000004; |
| 1076 |
|
| 1077 |
|
| 1078 |
|
| 1079 |
|
| 1080 |
|
| 1081 |
|
| 1082 |
public static final int GONE = 0x00000008; |
| 1083 |
|
| 1084 |
|
| 1085 |
|
| 1086 |
|
| 1087 |
|
| 1088 |
static final int VISIBILITY_MASK = 0x0000000C; |
| 1089 |
|
| 1090 |
private static final int[] VISIBILITY_FLAGS = {VISIBLE, INVISIBLE, GONE}; |
| 1091 |
|
| 1092 |
|
| 1093 |
|
| 1094 |
|
| 1095 |
|
| 1096 |
|
| 1097 |
|
| 1098 |
|
| 1099 |
|
| 1100 |
|
| 1101 |
public static final String AUTOFILL_HINT_EMAIL_ADDRESS = "emailAddress"; |
| 1102 |
|
| 1103 |
|
| 1104 |
|
| 1105 |
|
| 1106 |
|
| 1107 |
|
| 1108 |
|
| 1109 |
|
| 1110 |
|
| 1111 |
|
| 1112 |
public static final String AUTOFILL_HINT_NAME = "name"; |
| 1113 |
|
| 1114 |
|
| 1115 |
|
| 1116 |
|
| 1117 |
|
| 1118 |
|
| 1119 |
|
| 1120 |
|
| 1121 |
|
| 1122 |
|
| 1123 |
public static final String AUTOFILL_HINT_USERNAME = "username"; |
| 1124 |
|
| 1125 |
|
| 1126 |
|
| 1127 |
|
| 1128 |
|
| 1129 |
|
| 1130 |
|
| 1131 |
|
| 1132 |
|
| 1133 |
|
| 1134 |
public static final String AUTOFILL_HINT_PASSWORD = "password"; |
| 1135 |
|
| 1136 |
|
| 1137 |
|
| 1138 |
|
| 1139 |
|
| 1140 |
|
| 1141 |
|
| 1142 |
|
| 1143 |
|
| 1144 |
|
| 1145 |
public static final String AUTOFILL_HINT_PHONE = "phone"; |
| 1146 |
|
| 1147 |
|
| 1148 |
|
| 1149 |
|
| 1150 |
|
| 1151 |
|
| 1152 |
|
| 1153 |
|
| 1154 |
|
| 1155 |
|
| 1156 |
public static final String AUTOFILL_HINT_POSTAL_ADDRESS = "postalAddress"; |
| 1157 |
|
| 1158 |
|
| 1159 |
|
| 1160 |
|
| 1161 |
|
| 1162 |
|
| 1163 |
|
| 1164 |
|
| 1165 |
|
| 1166 |
|
| 1167 |
public static final String AUTOFILL_HINT_POSTAL_CODE = "postalCode"; |
| 1168 |
|
| 1169 |
|
| 1170 |
|
| 1171 |
|
| 1172 |
|
| 1173 |
|
| 1174 |
|
| 1175 |
|
| 1176 |
|
| 1177 |
|
| 1178 |
public static final String AUTOFILL_HINT_CREDIT_CARD_NUMBER = "creditCardNumber"; |
| 1179 |
|
| 1180 |
|
| 1181 |
|
| 1182 |
|
| 1183 |
|
| 1184 |
|
| 1185 |
|
| 1186 |
|
| 1187 |
|
| 1188 |
|
| 1189 |
public static final String AUTOFILL_HINT_CREDIT_CARD_SECURITY_CODE = "creditCardSecurityCode"; |
| 1190 |
|
| 1191 |
|
| 1192 |
|
| 1193 |
|
| 1194 |
|
| 1195 |
|
| 1196 |
|
| 1197 |
|
| 1198 |
|
| 1199 |
|
| 1200 |
|
| 1201 |
|
| 1202 |
|
| 1203 |
|
| 1204 |
|
| 1205 |
|
| 1206 |
|
| 1207 |
|
| 1208 |
|
| 1209 |
|
| 1210 |
|
| 1211 |
|
| 1212 |
|
| 1213 |
|
| 1214 |
|
| 1215 |
|
| 1216 |
|
| 1217 |
|
| 1218 |
|
| 1219 |
|
| 1220 |
|
| 1221 |
|
| 1222 |
|
| 1223 |
|
| 1224 |
|
| 1225 |
|
| 1226 |
|
| 1227 |
|
| 1228 |
|
| 1229 |
|
| 1230 |
public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE = |
| 1231 |
"creditCardExpirationDate"; |
| 1232 |
|
| 1233 |
|
| 1234 |
|
| 1235 |
|
| 1236 |
|
| 1237 |
|
| 1238 |
|
| 1239 |
|
| 1240 |
|
| 1241 |
|
| 1242 |
|
| 1243 |
|
| 1244 |
|
| 1245 |
|
| 1246 |
|
| 1247 |
|
| 1248 |
|
| 1249 |
|
| 1250 |
|
| 1251 |
|
| 1252 |
|
| 1253 |
|
| 1254 |
|
| 1255 |
|
| 1256 |
|
| 1257 |
|
| 1258 |
public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_MONTH = |
| 1259 |
"creditCardExpirationMonth"; |
| 1260 |
|
| 1261 |
|
| 1262 |
|
| 1263 |
|
| 1264 |
|
| 1265 |
|
| 1266 |
|
| 1267 |
|
| 1268 |
|
| 1269 |
|
| 1270 |
public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_YEAR = |
| 1271 |
"creditCardExpirationYear"; |
| 1272 |
|
| 1273 |
|
| 1274 |
|
| 1275 |
|
| 1276 |
|
| 1277 |
|
| 1278 |
|
| 1279 |
|
| 1280 |
|
| 1281 |
|
| 1282 |
public static final String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY = "creditCardExpirationDay"; |
| 1283 |
|
| 1284 |
|
| 1285 |
|
| 1286 |
|
| 1287 |
|
| 1288 |
|
| 1289 |
|
| 1290 |
|
| 1291 |
|
| 1292 |
|
| 1293 |
public static final String AUTOFILL_HINT_PASSWORD_AUTO = "passwordAuto"; |
| 1294 |
|
| 1295 |
|
| 1296 |
|
| 1297 |
|
| 1298 |
private @Nullable String[] mAutofillHints; |
| 1299 |
|
| 1300 |
|
| 1301 |
|
| 1302 |
|
| 1303 |
private AutofillId mAutofillId; |
| 1304 |
|
| 1305 |
|
| 1306 |
@IntDef(prefix = { "AUTOFILL_TYPE_" }, value = { |
| 1307 |
AUTOFILL_TYPE_NONE, |
| 1308 |
AUTOFILL_TYPE_TEXT, |
| 1309 |
AUTOFILL_TYPE_TOGGLE, |
| 1310 |
AUTOFILL_TYPE_LIST, |
| 1311 |
AUTOFILL_TYPE_DATE, |
| 1312 |
}) |
| 1313 |
@Retention(RetentionPolicy.SOURCE) |
| 1314 |
public @interface AutofillType {} |
| 1315 |
|
| 1316 |
|
| 1317 |
|
| 1318 |
|
| 1319 |
|
| 1320 |
|
| 1321 |
|
| 1322 |
|
| 1323 |
public static final int AUTOFILL_TYPE_NONE = 0; |
| 1324 |
|
| 1325 |
|
| 1326 |
|
| 1327 |
|
| 1328 |
|
| 1329 |
|
| 1330 |
|
| 1331 |
|
| 1332 |
|
| 1333 |
|
| 1334 |
public static final int AUTOFILL_TYPE_TEXT = 1; |
| 1335 |
|
| 1336 |
|
| 1337 |
|
| 1338 |
|
| 1339 |
|
| 1340 |
|
| 1341 |
|
| 1342 |
|
| 1343 |
|
| 1344 |
|
| 1345 |
public static final int AUTOFILL_TYPE_TOGGLE = 2; |
| 1346 |
|
| 1347 |
|
| 1348 |
|
| 1349 |
|
| 1350 |
|
| 1351 |
|
| 1352 |
|
| 1353 |
|
| 1354 |
|
| 1355 |
|
| 1356 |
|
| 1357 |
|
| 1358 |
|
| 1359 |
|
| 1360 |
public static final int AUTOFILL_TYPE_LIST = 3; |
| 1361 |
|
| 1362 |
|
| 1363 |
|
| 1364 |
|
| 1365 |
|
| 1366 |
|
| 1367 |
|
| 1368 |
|
| 1369 |
|
| 1370 |
|
| 1371 |
|
| 1372 |
|
| 1373 |
public static final int AUTOFILL_TYPE_DATE = 4; |
| 1374 |
|
| 1375 |
|
| 1376 |
|
| 1377 |
@IntDef(prefix = { "IMPORTANT_FOR_AUTOFILL_" }, value = { |
| 1378 |
IMPORTANT_FOR_AUTOFILL_AUTO, |
| 1379 |
IMPORTANT_FOR_AUTOFILL_YES, |
| 1380 |
IMPORTANT_FOR_AUTOFILL_NO, |
| 1381 |
IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, |
| 1382 |
IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS |
| 1383 |
}) |
| 1384 |
@Retention(RetentionPolicy.SOURCE) |
| 1385 |
public @interface AutofillImportance {} |
| 1386 |
|
| 1387 |
|
| 1388 |
|
| 1389 |
|
| 1390 |
|
| 1391 |
|
| 1392 |
|
| 1393 |
public static final int IMPORTANT_FOR_AUTOFILL_AUTO = 0x0; |
| 1394 |
|
| 1395 |
|
| 1396 |
|
| 1397 |
|
| 1398 |
|
| 1399 |
|
| 1400 |
|
| 1401 |
public static final int IMPORTANT_FOR_AUTOFILL_YES = 0x1; |
| 1402 |
|
| 1403 |
|
| 1404 |
|
| 1405 |
|
| 1406 |
|
| 1407 |
|
| 1408 |
|
| 1409 |
public static final int IMPORTANT_FOR_AUTOFILL_NO = 0x2; |
| 1410 |
|
| 1411 |
|
| 1412 |
|
| 1413 |
|
| 1414 |
|
| 1415 |
|
| 1416 |
|
| 1417 |
public static final int IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS = 0x4; |
| 1418 |
|
| 1419 |
|
| 1420 |
|
| 1421 |
|
| 1422 |
|
| 1423 |
|
| 1424 |
|
| 1425 |
public static final int IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS = 0x8; |
| 1426 |
|
| 1427 |
|
| 1428 |
@IntDef(flag = true, prefix = { "AUTOFILL_FLAG_" }, value = { |
| 1429 |
AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS |
| 1430 |
}) |
| 1431 |
@Retention(RetentionPolicy.SOURCE) |
| 1432 |
public @interface AutofillFlags {} |
| 1433 |
|
| 1434 |
|
| 1435 |
|
| 1436 |
|
| 1437 |
|
| 1438 |
public static final int AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS = 0x1; |
| 1439 |
|
| 1440 |
|
| 1441 |
@IntDef(prefix = { "IMPORTANT_FOR_CONTENT_CAPTURE_" }, value = { |
| 1442 |
IMPORTANT_FOR_CONTENT_CAPTURE_AUTO, |
| 1443 |
IMPORTANT_FOR_CONTENT_CAPTURE_YES, |
| 1444 |
IMPORTANT_FOR_CONTENT_CAPTURE_NO, |
| 1445 |
IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS, |
| 1446 |
IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS |
| 1447 |
}) |
| 1448 |
@Retention(RetentionPolicy.SOURCE) |
| 1449 |
public @interface ContentCaptureImportance {} |
| 1450 |
|
| 1451 |
|
| 1452 |
|
| 1453 |
|
| 1454 |
|
| 1455 |
|
| 1456 |
|
| 1457 |
public static final int IMPORTANT_FOR_CONTENT_CAPTURE_AUTO = 0x0; |
| 1458 |
|
| 1459 |
|
| 1460 |
|
| 1461 |
|
| 1462 |
|
| 1463 |
|
| 1464 |
|
| 1465 |
public static final int IMPORTANT_FOR_CONTENT_CAPTURE_YES = 0x1; |
| 1466 |
|
| 1467 |
|
| 1468 |
|
| 1469 |
|
| 1470 |
|
| 1471 |
|
| 1472 |
|
| 1473 |
public static final int IMPORTANT_FOR_CONTENT_CAPTURE_NO = 0x2; |
| 1474 |
|
| 1475 |
|
| 1476 |
|
| 1477 |
|
| 1478 |
|
| 1479 |
|
| 1480 |
|
| 1481 |
public static final int IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS = 0x4; |
| 1482 |
|
| 1483 |
|
| 1484 |
|
| 1485 |
|
| 1486 |
|
| 1487 |
|
| 1488 |
|
| 1489 |
|
| 1490 |
public static final int IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS = 0x8; |
| 1491 |
|
| 1492 |
|
| 1493 |
@IntDef(flag = true, prefix = {"SCROLL_CAPTURE_HINT_"}, |
| 1494 |
value = { |
| 1495 |
SCROLL_CAPTURE_HINT_AUTO, |
| 1496 |
SCROLL_CAPTURE_HINT_EXCLUDE, |
| 1497 |
SCROLL_CAPTURE_HINT_INCLUDE, |
| 1498 |
SCROLL_CAPTURE_HINT_EXCLUDE_DESCENDANTS |
| 1499 |
}) |
| 1500 |
@Retention(RetentionPolicy.SOURCE) |
| 1501 |
public @interface ScrollCaptureHint {} |
| 1502 |
|
| 1503 |
|
| 1504 |
|
| 1505 |
|
| 1506 |
|
| 1507 |
|
| 1508 |
|
| 1509 |
public static final int SCROLL_CAPTURE_HINT_AUTO = 0; |
| 1510 |
|
| 1511 |
|
| 1512 |
|
| 1513 |
|
| 1514 |
|
| 1515 |
|
| 1516 |
|
| 1517 |
|
| 1518 |
|
| 1519 |
public static final int SCROLL_CAPTURE_HINT_EXCLUDE = 0x1; |
| 1520 |
|
| 1521 |
|
| 1522 |
|
| 1523 |
|
| 1524 |
|
| 1525 |
|
| 1526 |
|
| 1527 |
|
| 1528 |
|
| 1529 |
public static final int SCROLL_CAPTURE_HINT_INCLUDE = 0x2; |
| 1530 |
|
| 1531 |
|
| 1532 |
|
| 1533 |
|
| 1534 |
|
| 1535 |
|
| 1536 |
|
| 1537 |
|
| 1538 |
|
| 1539 |
public static final int SCROLL_CAPTURE_HINT_EXCLUDE_DESCENDANTS = 0x4; |
| 1540 |
|
| 1541 |
|
| 1542 |
|
| 1543 |
|
| 1544 |
|
| 1545 |
|
| 1546 |
static final int ENABLED = 0x00000000; |
| 1547 |
|
| 1548 |
|
| 1549 |
|
| 1550 |
|
| 1551 |
|
| 1552 |
|
| 1553 |
static final int DISABLED = 0x00000020; |
| 1554 |
|
| 1555 |
|
| 1556 |
|
| 1557 |
|
| 1558 |
|
| 1559 |
|
| 1560 |
static final int ENABLED_MASK = 0x00000020; |
| 1561 |
|
| 1562 |
|
| 1563 |
|
| 1564 |
|
| 1565 |
|
| 1566 |
|
| 1567 |
|
| 1568 |
static final int WILL_NOT_DRAW = 0x00000080; |
| 1569 |
|
| 1570 |
|
| 1571 |
|
| 1572 |
|
| 1573 |
|
| 1574 |
|
| 1575 |
static final int DRAW_MASK = 0x00000080; |
| 1576 |
|
| 1577 |
|
| 1578 |
|
| 1579 |
|
| 1580 |
|
| 1581 |
static final int SCROLLBARS_NONE = 0x00000000; |
| 1582 |
|
| 1583 |
|
| 1584 |
|
| 1585 |
|
| 1586 |
|
| 1587 |
static final int SCROLLBARS_HORIZONTAL = 0x00000100; |
| 1588 |
|
| 1589 |
|
| 1590 |
|
| 1591 |
|
| 1592 |
|
| 1593 |
static final int SCROLLBARS_VERTICAL = 0x00000200; |
| 1594 |
|
| 1595 |
|
| 1596 |
|
| 1597 |
|
| 1598 |
|
| 1599 |
|
| 1600 |
static final int SCROLLBARS_MASK = 0x00000300; |
| 1601 |
|
| 1602 |
|
| 1603 |
|
| 1604 |
|
| 1605 |
|
| 1606 |
|
| 1607 |
static final int FILTER_TOUCHES_WHEN_OBSCURED = 0x00000400; |
| 1608 |
|
| 1609 |
|
| 1610 |
|
| 1611 |
|
| 1612 |
|
| 1613 |
|
| 1614 |
|
| 1615 |
|
| 1616 |
|
| 1617 |
|
| 1618 |
static final int OPTIONAL_FITS_SYSTEM_WINDOWS = 0x00000800; |
| 1619 |
|
| 1620 |
|
| 1621 |
|
| 1622 |
|
| 1623 |
|
| 1624 |
static final int FADING_EDGE_NONE = 0x00000000; |
| 1625 |
|
| 1626 |
|
| 1627 |
|
| 1628 |
|
| 1629 |
|
| 1630 |
static final int FADING_EDGE_HORIZONTAL = 0x00001000; |
| 1631 |
|
| 1632 |
|
| 1633 |
|
| 1634 |
|
| 1635 |
|
| 1636 |
static final int FADING_EDGE_VERTICAL = 0x00002000; |
| 1637 |
|
| 1638 |
|
| 1639 |
|
| 1640 |
|
| 1641 |
|
| 1642 |
|
| 1643 |
static final int FADING_EDGE_MASK = 0x00003000; |
| 1644 |
|
| 1645 |
|
| 1646 |
|
| 1647 |
|
| 1648 |
|
| 1649 |
|
| 1650 |
static final int CLICKABLE = 0x00004000; |
| 1651 |
|
| 1652 |
|
| 1653 |
|
| 1654 |
|
| 1655 |
|
| 1656 |
static final int DRAWING_CACHE_ENABLED = 0x00008000; |
| 1657 |
|
| 1658 |
|
| 1659 |
|
| 1660 |
|
| 1661 |
|
| 1662 |
static final int SAVE_DISABLED = 0x000010000; |
| 1663 |
|
| 1664 |
|
| 1665 |
|
| 1666 |
|
| 1667 |
|
| 1668 |
|
| 1669 |
static final int SAVE_DISABLED_MASK = 0x000010000; |
| 1670 |
|
| 1671 |
|
| 1672 |
|
| 1673 |
|
| 1674 |
|
| 1675 |
static final int WILL_NOT_CACHE_DRAWING = 0x000020000; |
| 1676 |
|
| 1677 |
|
| 1678 |
|
| 1679 |
|
| 1680 |
|
| 1681 |
static final int FOCUSABLE_IN_TOUCH_MODE = 0x00040000; |
| 1682 |
|
| 1683 |
|
| 1684 |
@Retention(RetentionPolicy.SOURCE) |
| 1685 |
@IntDef(prefix = { "DRAWING_CACHE_QUALITY_" }, value = { |
| 1686 |
DRAWING_CACHE_QUALITY_LOW, |
| 1687 |
DRAWING_CACHE_QUALITY_HIGH, |
| 1688 |
DRAWING_CACHE_QUALITY_AUTO |
| 1689 |
}) |
| 1690 |
public @interface DrawingCacheQuality {} |
| 1691 |
|
| 1692 |
|
| 1693 |
|
| 1694 |
|
| 1695 |
|
| 1696 |
|
| 1697 |
|
| 1698 |
|
| 1699 |
|
| 1700 |
|
| 1701 |
|
| 1702 |
|
| 1703 |
|
| 1704 |
|
| 1705 |
|
| 1706 |
|
| 1707 |
|
| 1708 |
@Deprecated |
| 1709 |
public static final int DRAWING_CACHE_QUALITY_LOW = 0x00080000; |
| 1710 |
|
| 1711 |
|
| 1712 |
|
| 1713 |
|
| 1714 |
|
| 1715 |
|
| 1716 |
|
| 1717 |
|
| 1718 |
|
| 1719 |
|
| 1720 |
|
| 1721 |
|
| 1722 |
|
| 1723 |
|
| 1724 |
|
| 1725 |
|
| 1726 |
|
| 1727 |
@Deprecated |
| 1728 |
public static final int DRAWING_CACHE_QUALITY_HIGH = 0x00100000; |
| 1729 |
|
| 1730 |
|
| 1731 |
|
| 1732 |
|
| 1733 |
|
| 1734 |
|
| 1735 |
|
| 1736 |
|
| 1737 |
|
| 1738 |
|
| 1739 |
|
| 1740 |
|
| 1741 |
|
| 1742 |
|
| 1743 |
|
| 1744 |
|
| 1745 |
|
| 1746 |
@Deprecated |
| 1747 |
public static final int DRAWING_CACHE_QUALITY_AUTO = 0x00000000; |
| 1748 |
|
| 1749 |
private static final int[] DRAWING_CACHE_QUALITY_FLAGS = { |
| 1750 |
DRAWING_CACHE_QUALITY_AUTO, DRAWING_CACHE_QUALITY_LOW, DRAWING_CACHE_QUALITY_HIGH |
| 1751 |
}; |
| 1752 |
|
| 1753 |
|
| 1754 |
|
| 1755 |
|
| 1756 |
|
| 1757 |
|
| 1758 |
static final int DRAWING_CACHE_QUALITY_MASK = 0x00180000; |
| 1759 |
|
| 1760 |
|
| 1761 |
|
| 1762 |
|
| 1763 |
|
| 1764 |
|
| 1765 |
|
| 1766 |
|
| 1767 |
|
| 1768 |
static final int LONG_CLICKABLE = 0x00200000; |
| 1769 |
|
| 1770 |
|
| 1771 |
|
| 1772 |
|
| 1773 |
|
| 1774 |
|
| 1775 |
|
| 1776 |
static final int DUPLICATE_PARENT_STATE = 0x00400000; |
| 1777 |
|
| 1778 |
|
| 1779 |
|
| 1780 |
|
| 1781 |
|
| 1782 |
|
| 1783 |
|
| 1784 |
|
| 1785 |
|
| 1786 |
static final int CONTEXT_CLICKABLE = 0x00800000; |
| 1787 |
|
| 1788 |
|
| 1789 |
@IntDef(prefix = { "SCROLLBARS_" }, value = { |
| 1790 |
SCROLLBARS_INSIDE_OVERLAY, |
| 1791 |
SCROLLBARS_INSIDE_INSET, |
| 1792 |
SCROLLBARS_OUTSIDE_OVERLAY, |
| 1793 |
SCROLLBARS_OUTSIDE_INSET |
| 1794 |
}) |
| 1795 |
@Retention(RetentionPolicy.SOURCE) |
| 1796 |
public @interface ScrollBarStyle {} |
| 1797 |
|
| 1798 |
|
| 1799 |
|
| 1800 |
|
| 1801 |
|
| 1802 |
|
| 1803 |
public static final int SCROLLBARS_INSIDE_OVERLAY = 0; |
| 1804 |
|
| 1805 |
|
| 1806 |
|
| 1807 |
|
| 1808 |
|
| 1809 |
|
| 1810 |
public static final int SCROLLBARS_INSIDE_INSET = 0x01000000; |
| 1811 |
|
| 1812 |
|
| 1813 |
|
| 1814 |
|
| 1815 |
|
| 1816 |
|
| 1817 |
public static final int SCROLLBARS_OUTSIDE_OVERLAY = 0x02000000; |
| 1818 |
|
| 1819 |
|
| 1820 |
|
| 1821 |
|
| 1822 |
|
| 1823 |
|
| 1824 |
public static final int SCROLLBARS_OUTSIDE_INSET = 0x03000000; |
| 1825 |
|
| 1826 |
|
| 1827 |
|
| 1828 |
|
| 1829 |
|
| 1830 |
static final int SCROLLBARS_INSET_MASK = 0x01000000; |
| 1831 |
|
| 1832 |
|
| 1833 |
|
| 1834 |
|
| 1835 |
|
| 1836 |
static final int SCROLLBARS_OUTSIDE_MASK = 0x02000000; |
| 1837 |
|
| 1838 |
|
| 1839 |
|
| 1840 |
|
| 1841 |
|
| 1842 |
static final int SCROLLBARS_STYLE_MASK = 0x03000000; |
| 1843 |
|
| 1844 |
|
| 1845 |
|
| 1846 |
|
| 1847 |
|
| 1848 |
|
| 1849 |
|
| 1850 |
public static final int KEEP_SCREEN_ON = 0x04000000; |
| 1851 |
|
| 1852 |
|
| 1853 |
|
| 1854 |
|
| 1855 |
|
| 1856 |
public static final int SOUND_EFFECTS_ENABLED = 0x08000000; |
| 1857 |
|
| 1858 |
|
| 1859 |
|
| 1860 |
|
| 1861 |
|
| 1862 |
public static final int HAPTIC_FEEDBACK_ENABLED = 0x10000000; |
| 1863 |
|
| 1864 |
|
| 1865 |
|
| 1866 |
|
| 1867 |
|
| 1868 |
|
| 1869 |
|
| 1870 |
static final int PARENT_SAVE_DISABLED = 0x20000000; |
| 1871 |
|
| 1872 |
|
| 1873 |
|
| 1874 |
|
| 1875 |
|
| 1876 |
static final int PARENT_SAVE_DISABLED_MASK = 0x20000000; |
| 1877 |
|
| 1878 |
private static Paint sDebugPaint; |
| 1879 |
|
| 1880 |
|
| 1881 |
|
| 1882 |
|
| 1883 |
|
| 1884 |
static final int TOOLTIP = 0x40000000; |
| 1885 |
|
| 1886 |
|
| 1887 |
@IntDef(flag = true, prefix = { "FOCUSABLES_" }, value = { |
| 1888 |
FOCUSABLES_ALL, |
| 1889 |
FOCUSABLES_TOUCH_MODE |
| 1890 |
}) |
| 1891 |
@Retention(RetentionPolicy.SOURCE) |
| 1892 |
public @interface FocusableMode {} |
| 1893 |
|
| 1894 |
|
| 1895 |
|
| 1896 |
|
| 1897 |
|
| 1898 |
public static final int FOCUSABLES_ALL = 0x00000000; |
| 1899 |
|
| 1900 |
|
| 1901 |
|
| 1902 |
|
| 1903 |
|
| 1904 |
public static final int FOCUSABLES_TOUCH_MODE = 0x00000001; |
| 1905 |
|
| 1906 |
|
| 1907 |
@IntDef(prefix = { "FOCUS_" }, value = { |
| 1908 |
FOCUS_BACKWARD, |
| 1909 |
FOCUS_FORWARD, |
| 1910 |
FOCUS_LEFT, |
| 1911 |
FOCUS_UP, |
| 1912 |
FOCUS_RIGHT, |
| 1913 |
FOCUS_DOWN |
| 1914 |
}) |
| 1915 |
@Retention(RetentionPolicy.SOURCE) |
| 1916 |
public @interface FocusDirection {} |
| 1917 |
|
| 1918 |
|
| 1919 |
@IntDef(prefix = { "FOCUS_" }, value = { |
| 1920 |
FOCUS_LEFT, |
| 1921 |
FOCUS_UP, |
| 1922 |
FOCUS_RIGHT, |
| 1923 |
FOCUS_DOWN |
| 1924 |
}) |
| 1925 |
@Retention(RetentionPolicy.SOURCE) |
| 1926 |
public @interface FocusRealDirection {} |
| 1927 |
|
| 1928 |
|
| 1929 |
|
| 1930 |
|
| 1931 |
|
| 1932 |
public static final int FOCUS_BACKWARD = 0x00000001; |
| 1933 |
|
| 1934 |
|
| 1935 |
|
| 1936 |
|
| 1937 |
|
| 1938 |
public static final int FOCUS_FORWARD = 0x00000002; |
| 1939 |
|
| 1940 |
|
| 1941 |
|
| 1942 |
|
| 1943 |
public static final int FOCUS_LEFT = 0x00000011; |
| 1944 |
|
| 1945 |
|
| 1946 |
|
| 1947 |
|
| 1948 |
public static final int FOCUS_UP = 0x00000021; |
| 1949 |
|
| 1950 |
|
| 1951 |
|
| 1952 |
|
| 1953 |
public static final int FOCUS_RIGHT = 0x00000042; |
| 1954 |
|
| 1955 |
|
| 1956 |
|
| 1957 |
|
| 1958 |
public static final int FOCUS_DOWN = 0x00000082; |
| 1959 |
|
| 1960 |
|
| 1961 |
|
| 1962 |
|
| 1963 |
|
| 1964 |
public static final int MEASURED_SIZE_MASK = 0x00ffffff; |
| 1965 |
|
| 1966 |
|
| 1967 |
|
| 1968 |
|
| 1969 |
|
| 1970 |
public static final int MEASURED_STATE_MASK = 0xff000000; |
| 1971 |
|
| 1972 |
|
| 1973 |
|
| 1974 |
|
| 1975 |
|
| 1976 |
|
| 1977 |
|
| 1978 |
public static final int MEASURED_HEIGHT_STATE_SHIFT = 16; |
| 1979 |
|
| 1980 |
|
| 1981 |
|
| 1982 |
|
| 1983 |
|
| 1984 |
|
| 1985 |
public static final int MEASURED_STATE_TOO_SMALL = 0x01000000; |
| 1986 |
|
| 1987 |
|
| 1988 |
|
| 1989 |
|
| 1990 |
|
| 1991 |
|
| 1992 |
|
| 1993 |
|
| 1994 |
|
| 1995 |
|
| 1996 |
|
| 1997 |
|
| 1998 |
|
| 1999 |
protected static final int[] EMPTY_STATE_SET; |
| 2000 |
|
| 2001 |
|
| 2002 |
|
| 2003 |
|
| 2004 |
|
| 2005 |
|
| 2006 |
|
| 2007 |
|
| 2008 |
protected static final int[] ENABLED_STATE_SET; |
| 2009 |
|
| 2010 |
|
| 2011 |
|
| 2012 |
|
| 2013 |
|
| 2014 |
|
| 2015 |
|
| 2016 |
|
| 2017 |
protected static final int[] FOCUSED_STATE_SET; |
| 2018 |
|
| 2019 |
|
| 2020 |
|
| 2021 |
|
| 2022 |
|
| 2023 |
|
| 2024 |
|
| 2025 |
|
| 2026 |
protected static final int[] SELECTED_STATE_SET; |
| 2027 |
|
| 2028 |
|
| 2029 |
|
| 2030 |
|
| 2031 |
|
| 2032 |
|
| 2033 |
|
| 2034 |
|
| 2035 |
protected static final int[] PRESSED_STATE_SET; |
| 2036 |
|
| 2037 |
|
| 2038 |
|
| 2039 |
|
| 2040 |
|
| 2041 |
|
| 2042 |
|
| 2043 |
|
| 2044 |
protected static final int[] WINDOW_FOCUSED_STATE_SET; |
| 2045 |
|
| 2046 |
|
| 2047 |
|
| 2048 |
|
| 2049 |
|
| 2050 |
|
| 2051 |
|
| 2052 |
protected static final int[] ENABLED_FOCUSED_STATE_SET; |
| 2053 |
|
| 2054 |
|
| 2055 |
|
| 2056 |
|
| 2057 |
|
| 2058 |
|
| 2059 |
protected static final int[] ENABLED_SELECTED_STATE_SET; |
| 2060 |
|
| 2061 |
|
| 2062 |
|
| 2063 |
|
| 2064 |
|
| 2065 |
|
| 2066 |
protected static final int[] ENABLED_WINDOW_FOCUSED_STATE_SET; |
| 2067 |
|
| 2068 |
|
| 2069 |
|
| 2070 |
|
| 2071 |
|
| 2072 |
|
| 2073 |
protected static final int[] FOCUSED_SELECTED_STATE_SET; |
| 2074 |
|
| 2075 |
|
| 2076 |
|
| 2077 |
|
| 2078 |
|
| 2079 |
|
| 2080 |
protected static final int[] FOCUSED_WINDOW_FOCUSED_STATE_SET; |
| 2081 |
|
| 2082 |
|
| 2083 |
|
| 2084 |
|
| 2085 |
|
| 2086 |
|
| 2087 |
protected static final int[] SELECTED_WINDOW_FOCUSED_STATE_SET; |
| 2088 |
|
| 2089 |
|
| 2090 |
|
| 2091 |
|
| 2092 |
|
| 2093 |
|
| 2094 |
|
| 2095 |
|
| 2096 |
protected static final int[] ENABLED_FOCUSED_SELECTED_STATE_SET; |
| 2097 |
|
| 2098 |
|
| 2099 |
|
| 2100 |
|
| 2101 |
|
| 2102 |
|
| 2103 |
|
| 2104 |
protected static final int[] ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET; |
| 2105 |
|
| 2106 |
|
| 2107 |
|
| 2108 |
|
| 2109 |
|
| 2110 |
|
| 2111 |
|
| 2112 |
protected static final int[] ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET; |
| 2113 |
|
| 2114 |
|
| 2115 |
|
| 2116 |
|
| 2117 |
|
| 2118 |
|
| 2119 |
|
| 2120 |
protected static final int[] FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET; |
| 2121 |
|
| 2122 |
|
| 2123 |
|
| 2124 |
|
| 2125 |
|
| 2126 |
|
| 2127 |
|
| 2128 |
|
| 2129 |
|
| 2130 |
protected static final int[] ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET; |
| 2131 |
|
| 2132 |
|
| 2133 |
|
| 2134 |
|
| 2135 |
|
| 2136 |
|
| 2137 |
protected static final int[] PRESSED_WINDOW_FOCUSED_STATE_SET; |
| 2138 |
|
| 2139 |
|
| 2140 |
|
| 2141 |
|
| 2142 |
|
| 2143 |
|
| 2144 |
protected static final int[] PRESSED_SELECTED_STATE_SET; |
| 2145 |
|
| 2146 |
|
| 2147 |
|
| 2148 |
|
| 2149 |
|
| 2150 |
|
| 2151 |
|
| 2152 |
protected static final int[] PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET; |
| 2153 |
|
| 2154 |
|
| 2155 |
|
| 2156 |
|
| 2157 |
|
| 2158 |
|
| 2159 |
protected static final int[] PRESSED_FOCUSED_STATE_SET; |
| 2160 |
|
| 2161 |
|
| 2162 |
|
| 2163 |
|
| 2164 |
|
| 2165 |
|
| 2166 |
|
| 2167 |
protected static final int[] PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET; |
| 2168 |
|
| 2169 |
|
| 2170 |
|
| 2171 |
|
| 2172 |
|
| 2173 |
|
| 2174 |
|
| 2175 |
protected static final int[] PRESSED_FOCUSED_SELECTED_STATE_SET; |
| 2176 |
|
| 2177 |
|
| 2178 |
|
| 2179 |
|
| 2180 |
|
| 2181 |
|
| 2182 |
|
| 2183 |
|
| 2184 |
protected static final int[] PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET; |
| 2185 |
|
| 2186 |
|
| 2187 |
|
| 2188 |
|
| 2189 |
|
| 2190 |
|
| 2191 |
protected static final int[] PRESSED_ENABLED_STATE_SET; |
| 2192 |
|
| 2193 |
|
| 2194 |
|
| 2195 |
|
| 2196 |
|
| 2197 |
|
| 2198 |
|
| 2199 |
protected static final int[] PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET; |
| 2200 |
|
| 2201 |
|
| 2202 |
|
| 2203 |
|
| 2204 |
|
| 2205 |
|
| 2206 |
|
| 2207 |
protected static final int[] PRESSED_ENABLED_SELECTED_STATE_SET; |
| 2208 |
|
| 2209 |
|
| 2210 |
|
| 2211 |
|
| 2212 |
|
| 2213 |
|
| 2214 |
|
| 2215 |
|
| 2216 |
|
| 2217 |
protected static final int[] PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET; |
| 2218 |
|
| 2219 |
|
| 2220 |
|
| 2221 |
|
| 2222 |
|
| 2223 |
|
| 2224 |
|
| 2225 |
protected static final int[] PRESSED_ENABLED_FOCUSED_STATE_SET; |
| 2226 |
|
| 2227 |
|
| 2228 |
|
| 2229 |
|
| 2230 |
|
| 2231 |
|
| 2232 |
|
| 2233 |
|
| 2234 |
|
| 2235 |
protected static final int[] PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET; |
| 2236 |
|
| 2237 |
|
| 2238 |
|
| 2239 |
|
| 2240 |
|
| 2241 |
|
| 2242 |
|
| 2243 |
|
| 2244 |
protected static final int[] PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET; |
| 2245 |
|
| 2246 |
|
| 2247 |
|
| 2248 |
|
| 2249 |
|
| 2250 |
|
| 2251 |
|
| 2252 |
|
| 2253 |
|
| 2254 |
|
| 2255 |
protected static final int[] PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET; |
| 2256 |
|
| 2257 |
static { |
| 2258 |
EMPTY_STATE_SET = StateSet.get(0); |
| 2259 |
|
| 2260 |
WINDOW_FOCUSED_STATE_SET = StateSet.get(StateSet.VIEW_STATE_WINDOW_FOCUSED); |
| 2261 |
|
| 2262 |
SELECTED_STATE_SET = StateSet.get(StateSet.VIEW_STATE_SELECTED); |
| 2263 |
SELECTED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2264 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_SELECTED); |
| 2265 |
|
| 2266 |
FOCUSED_STATE_SET = StateSet.get(StateSet.VIEW_STATE_FOCUSED); |
| 2267 |
FOCUSED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2268 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_FOCUSED); |
| 2269 |
FOCUSED_SELECTED_STATE_SET = StateSet.get( |
| 2270 |
StateSet.VIEW_STATE_SELECTED | StateSet.VIEW_STATE_FOCUSED); |
| 2271 |
FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2272 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_SELECTED |
| 2273 |
| StateSet.VIEW_STATE_FOCUSED); |
| 2274 |
|
| 2275 |
ENABLED_STATE_SET = StateSet.get(StateSet.VIEW_STATE_ENABLED); |
| 2276 |
ENABLED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2277 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_ENABLED); |
| 2278 |
ENABLED_SELECTED_STATE_SET = StateSet.get( |
| 2279 |
StateSet.VIEW_STATE_SELECTED | StateSet.VIEW_STATE_ENABLED); |
| 2280 |
ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2281 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_SELECTED |
| 2282 |
| StateSet.VIEW_STATE_ENABLED); |
| 2283 |
ENABLED_FOCUSED_STATE_SET = StateSet.get( |
| 2284 |
StateSet.VIEW_STATE_FOCUSED | StateSet.VIEW_STATE_ENABLED); |
| 2285 |
ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2286 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_FOCUSED |
| 2287 |
| StateSet.VIEW_STATE_ENABLED); |
| 2288 |
ENABLED_FOCUSED_SELECTED_STATE_SET = StateSet.get( |
| 2289 |
StateSet.VIEW_STATE_SELECTED | StateSet.VIEW_STATE_FOCUSED |
| 2290 |
| StateSet.VIEW_STATE_ENABLED); |
| 2291 |
ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2292 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_SELECTED |
| 2293 |
| StateSet.VIEW_STATE_FOCUSED| StateSet.VIEW_STATE_ENABLED); |
| 2294 |
|
| 2295 |
PRESSED_STATE_SET = StateSet.get(StateSet.VIEW_STATE_PRESSED); |
| 2296 |
PRESSED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2297 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_PRESSED); |
| 2298 |
PRESSED_SELECTED_STATE_SET = StateSet.get( |
| 2299 |
StateSet.VIEW_STATE_SELECTED | StateSet.VIEW_STATE_PRESSED); |
| 2300 |
PRESSED_SELECTED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2301 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_SELECTED |
| 2302 |
| StateSet.VIEW_STATE_PRESSED); |
| 2303 |
PRESSED_FOCUSED_STATE_SET = StateSet.get( |
| 2304 |
StateSet.VIEW_STATE_FOCUSED | StateSet.VIEW_STATE_PRESSED); |
| 2305 |
PRESSED_FOCUSED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2306 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_FOCUSED |
| 2307 |
| StateSet.VIEW_STATE_PRESSED); |
| 2308 |
PRESSED_FOCUSED_SELECTED_STATE_SET = StateSet.get( |
| 2309 |
StateSet.VIEW_STATE_SELECTED | StateSet.VIEW_STATE_FOCUSED |
| 2310 |
| StateSet.VIEW_STATE_PRESSED); |
| 2311 |
PRESSED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2312 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_SELECTED |
| 2313 |
| StateSet.VIEW_STATE_FOCUSED | StateSet.VIEW_STATE_PRESSED); |
| 2314 |
PRESSED_ENABLED_STATE_SET = StateSet.get( |
| 2315 |
StateSet.VIEW_STATE_ENABLED | StateSet.VIEW_STATE_PRESSED); |
| 2316 |
PRESSED_ENABLED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2317 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_ENABLED |
| 2318 |
| StateSet.VIEW_STATE_PRESSED); |
| 2319 |
PRESSED_ENABLED_SELECTED_STATE_SET = StateSet.get( |
| 2320 |
StateSet.VIEW_STATE_SELECTED | StateSet.VIEW_STATE_ENABLED |
| 2321 |
| StateSet.VIEW_STATE_PRESSED); |
| 2322 |
PRESSED_ENABLED_SELECTED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2323 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_SELECTED |
| 2324 |
| StateSet.VIEW_STATE_ENABLED | StateSet.VIEW_STATE_PRESSED); |
| 2325 |
PRESSED_ENABLED_FOCUSED_STATE_SET = StateSet.get( |
| 2326 |
StateSet.VIEW_STATE_FOCUSED | StateSet.VIEW_STATE_ENABLED |
| 2327 |
| StateSet.VIEW_STATE_PRESSED); |
| 2328 |
PRESSED_ENABLED_FOCUSED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2329 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_FOCUSED |
| 2330 |
| StateSet.VIEW_STATE_ENABLED | StateSet.VIEW_STATE_PRESSED); |
| 2331 |
PRESSED_ENABLED_FOCUSED_SELECTED_STATE_SET = StateSet.get( |
| 2332 |
StateSet.VIEW_STATE_SELECTED | StateSet.VIEW_STATE_FOCUSED |
| 2333 |
| StateSet.VIEW_STATE_ENABLED | StateSet.VIEW_STATE_PRESSED); |
| 2334 |
PRESSED_ENABLED_FOCUSED_SELECTED_WINDOW_FOCUSED_STATE_SET = StateSet.get( |
| 2335 |
StateSet.VIEW_STATE_WINDOW_FOCUSED | StateSet.VIEW_STATE_SELECTED |
| 2336 |
| StateSet.VIEW_STATE_FOCUSED| StateSet.VIEW_STATE_ENABLED |
| 2337 |
| StateSet.VIEW_STATE_PRESSED); |
| 2338 |
} |
| 2339 |
|
| 2340 |
|
| 2341 |
|
| 2342 |
|
| 2343 |
private static final int POPULATING_ACCESSIBILITY_EVENT_TYPES = |
| 2344 |
AccessibilityEvent.TYPE_VIEW_CLICKED |
| 2345 |
| AccessibilityEvent.TYPE_VIEW_LONG_CLICKED |
| 2346 |
| AccessibilityEvent.TYPE_VIEW_SELECTED |
| 2347 |
| AccessibilityEvent.TYPE_VIEW_FOCUSED |
| 2348 |
| AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED |
| 2349 |
| AccessibilityEvent.TYPE_VIEW_HOVER_ENTER |
| 2350 |
| AccessibilityEvent.TYPE_VIEW_HOVER_EXIT |
| 2351 |
| AccessibilityEvent.TYPE_VIEW_TEXT_CHANGED |
| 2352 |
| AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED |
| 2353 |
| AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED |
| 2354 |
| AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY; |
| 2355 |
|
| 2356 |
static final int DEBUG_CORNERS_COLOR = Color.rgb(63, 127, 255); |
| 2357 |
|
| 2358 |
static final int DEBUG_CORNERS_SIZE_DIP = 8; |
| 2359 |
|
| 2360 |
|
| 2361 |
|
| 2362 |
|
| 2363 |
|
| 2364 |
|
| 2365 |
static final ThreadLocal<Rect> sThreadLocal = ThreadLocal.withInitial(Rect::new); |
| 2366 |
|
| 2367 |
|
| 2368 |
|
| 2369 |
|
| 2370 |
@UnsupportedAppUsage |
| 2371 |
private SparseArray<Object> mKeyedTags; |
| 2372 |
|
| 2373 |
|
| 2374 |
|
| 2375 |
|
| 2376 |
private static int sNextAccessibilityViewId; |
| 2377 |
|
| 2378 |
|
| 2379 |
|
| 2380 |
|
| 2381 |
|
| 2382 |
protected Animation mCurrentAnimation = null; |
| 2383 |
|
| 2384 |
|
| 2385 |
|
| 2386 |
|
| 2387 |
|
| 2388 |
@ViewDebug.ExportedProperty(category = "measurement") |
| 2389 |
@UnsupportedAppUsage |
| 2390 |
int mMeasuredWidth; |
| 2391 |
|
| 2392 |
|
| 2393 |
|
| 2394 |
|
| 2395 |
|
| 2396 |
@ViewDebug.ExportedProperty(category = "measurement") |
| 2397 |
@UnsupportedAppUsage |
| 2398 |
int mMeasuredHeight; |
| 2399 |
|
| 2400 |
|
| 2401 |
|
| 2402 |
|
| 2403 |
|
| 2404 |
|
| 2405 |
|
| 2406 |
|
| 2407 |
|
| 2408 |
|
| 2409 |
@UnsupportedAppUsage |
| 2410 |
boolean mRecreateDisplayList = false; |
| 2411 |
|
| 2412 |
|
| 2413 |
|
| 2414 |
|
| 2415 |
|
| 2416 |
|
| 2417 |
|
| 2418 |
|
| 2419 |
@IdRes |
| 2420 |
@ViewDebug.ExportedProperty(resolveId = true) |
| 2421 |
int mID = NO_ID; |
| 2422 |
|
| 2423 |
|
| 2424 |
|
| 2425 |
|
| 2426 |
|
| 2427 |
|
| 2428 |
|
| 2429 |
|
| 2430 |
|
| 2431 |
|
| 2432 |
|
| 2433 |
private int mAutofillViewId = NO_ID; |
| 2434 |
|
| 2435 |
|
| 2436 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 2437 |
private int mAccessibilityViewId = NO_ID; |
| 2438 |
|
| 2439 |
private int mAccessibilityCursorPosition = ACCESSIBILITY_CURSOR_POSITION_UNDEFINED; |
| 2440 |
|
| 2441 |
|
| 2442 |
|
| 2443 |
|
| 2444 |
|
| 2445 |
|
| 2446 |
|
| 2447 |
|
| 2448 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 2449 |
protected Object mTag = null; |
| 2450 |
|
| 2451 |
|
| 2452 |
|
| 2453 |
|
| 2454 |
|
| 2455 |
|
| 2456 |
|
| 2457 |
|
| 2458 |
|
| 2459 |
|
| 2460 |
|
| 2461 |
|
| 2462 |
|
| 2463 |
|
| 2464 |
|
| 2465 |
|
| 2466 |
|
| 2467 |
|
| 2468 |
|
| 2469 |
|
| 2470 |
|
| 2471 |
|
| 2472 |
|
| 2473 |
|
| 2474 |
|
| 2475 |
|
| 2476 |
|
| 2477 |
|
| 2478 |
|
| 2479 |
|
| 2480 |
|
| 2481 |
|
| 2482 |
|
| 2483 |
|
| 2484 |
|
| 2485 |
|
| 2486 |
|
| 2487 |
|
| 2488 |
|
| 2489 |
|
| 2490 |
static final int PFLAG_WANTS_FOCUS = 0x00000001; |
| 2491 |
|
| 2492 |
static final int PFLAG_FOCUSED = 0x00000002; |
| 2493 |
|
| 2494 |
static final int PFLAG_SELECTED = 0x00000004; |
| 2495 |
|
| 2496 |
static final int PFLAG_IS_ROOT_NAMESPACE = 0x00000008; |
| 2497 |
|
| 2498 |
static final int PFLAG_HAS_BOUNDS = 0x00000010; |
| 2499 |
|
| 2500 |
static final int PFLAG_DRAWN = 0x00000020; |
| 2501 |
|
| 2502 |
|
| 2503 |
|
| 2504 |
|
| 2505 |
|
| 2506 |
|
| 2507 |
|
| 2508 |
static final int PFLAG_DRAW_ANIMATION = 0x00000040; |
| 2509 |
|
| 2510 |
static final int PFLAG_SKIP_DRAW = 0x00000080; |
| 2511 |
|
| 2512 |
static final int PFLAG_REQUEST_TRANSPARENT_REGIONS = 0x00000200; |
| 2513 |
|
| 2514 |
static final int PFLAG_DRAWABLE_STATE_DIRTY = 0x00000400; |
| 2515 |
|
| 2516 |
static final int PFLAG_MEASURED_DIMENSION_SET = 0x00000800; |
| 2517 |
|
| 2518 |
static final int PFLAG_FORCE_LAYOUT = 0x00001000; |
| 2519 |
|
| 2520 |
static final int PFLAG_LAYOUT_REQUIRED = 0x00002000; |
| 2521 |
|
| 2522 |
private static final int PFLAG_PRESSED = 0x00004000; |
| 2523 |
|
| 2524 |
|
| 2525 |
static final int PFLAG_DRAWING_CACHE_VALID = 0x00008000; |
| 2526 |
|
| 2527 |
|
| 2528 |
|
| 2529 |
|
| 2530 |
|
| 2531 |
static final int PFLAG_ANIMATION_STARTED = 0x00010000; |
| 2532 |
|
| 2533 |
private static final int PFLAG_SAVE_STATE_CALLED = 0x00020000; |
| 2534 |
|
| 2535 |
|
| 2536 |
|
| 2537 |
|
| 2538 |
|
| 2539 |
|
| 2540 |
static final int PFLAG_ALPHA_SET = 0x00040000; |
| 2541 |
|
| 2542 |
|
| 2543 |
|
| 2544 |
|
| 2545 |
static final int PFLAG_SCROLL_CONTAINER = 0x00080000; |
| 2546 |
|
| 2547 |
|
| 2548 |
|
| 2549 |
|
| 2550 |
static final int PFLAG_SCROLL_CONTAINER_ADDED = 0x00100000; |
| 2551 |
|
| 2552 |
|
| 2553 |
|
| 2554 |
|
| 2555 |
|
| 2556 |
|
| 2557 |
static final int PFLAG_DIRTY = 0x00200000; |
| 2558 |
|
| 2559 |
|
| 2560 |
|
| 2561 |
|
| 2562 |
|
| 2563 |
|
| 2564 |
static final int PFLAG_DIRTY_MASK = 0x00200000; |
| 2565 |
|
| 2566 |
|
| 2567 |
|
| 2568 |
|
| 2569 |
|
| 2570 |
|
| 2571 |
static final int PFLAG_OPAQUE_BACKGROUND = 0x00800000; |
| 2572 |
|
| 2573 |
|
| 2574 |
|
| 2575 |
|
| 2576 |
|
| 2577 |
|
| 2578 |
static final int PFLAG_OPAQUE_SCROLLBARS = 0x01000000; |
| 2579 |
|
| 2580 |
|
| 2581 |
|
| 2582 |
|
| 2583 |
|
| 2584 |
|
| 2585 |
static final int PFLAG_OPAQUE_MASK = 0x01800000; |
| 2586 |
|
| 2587 |
|
| 2588 |
|
| 2589 |
|
| 2590 |
|
| 2591 |
|
| 2592 |
|
| 2593 |
|
| 2594 |
|
| 2595 |
private static final int PFLAG_PREPRESSED = 0x02000000; |
| 2596 |
|
| 2597 |
|
| 2598 |
|
| 2599 |
|
| 2600 |
|
| 2601 |
|
| 2602 |
static final int PFLAG_CANCEL_NEXT_UP_EVENT = 0x04000000; |
| 2603 |
|
| 2604 |
|
| 2605 |
|
| 2606 |
|
| 2607 |
|
| 2608 |
|
| 2609 |
|
| 2610 |
|
| 2611 |
|
| 2612 |
private static final int PFLAG_AWAKEN_SCROLL_BARS_ON_ATTACH = 0x08000000; |
| 2613 |
|
| 2614 |
|
| 2615 |
|
| 2616 |
|
| 2617 |
|
| 2618 |
private static final int PFLAG_HOVERED = 0x10000000; |
| 2619 |
|
| 2620 |
|
| 2621 |
|
| 2622 |
|
| 2623 |
private static final int PFLAG_NOTIFY_AUTOFILL_MANAGER_ON_CLICK = 0x20000000; |
| 2624 |
|
| 2625 |
|
| 2626 |
static final int PFLAG_ACTIVATED = 0x40000000; |
| 2627 |
|
| 2628 |
|
| 2629 |
|
| 2630 |
|
| 2631 |
|
| 2632 |
|
| 2633 |
|
| 2634 |
|
| 2635 |
|
| 2636 |
static final int PFLAG_INVALIDATED = 0x80000000; |
| 2637 |
|
| 2638 |
|
| 2639 |
|
| 2640 |
|
| 2641 |
|
| 2642 |
|
| 2643 |
|
| 2644 |
|
| 2645 |
|
| 2646 |
|
| 2647 |
|
| 2648 |
|
| 2649 |
|
| 2650 |
|
| 2651 |
|
| 2652 |
|
| 2653 |
|
| 2654 |
|
| 2655 |
|
| 2656 |
|
| 2657 |
|
| 2658 |
|
| 2659 |
|
| 2660 |
|
| 2661 |
|
| 2662 |
|
| 2663 |
|
| 2664 |
|
| 2665 |
|
| 2666 |
|
| 2667 |
|
| 2668 |
|
| 2669 |
|
| 2670 |
|
| 2671 |
|
| 2672 |
|
| 2673 |
|
| 2674 |
|
| 2675 |
|
| 2676 |
|
| 2677 |
|
| 2678 |
|
| 2679 |
|
| 2680 |
|
| 2681 |
|
| 2682 |
|
| 2683 |
|
| 2684 |
|
| 2685 |
|
| 2686 |
|
| 2687 |
static final int PFLAG2_DRAG_CAN_ACCEPT = 0x00000001; |
| 2688 |
|
| 2689 |
|
| 2690 |
|
| 2691 |
|
| 2692 |
|
| 2693 |
|
| 2694 |
|
| 2695 |
static final int PFLAG2_DRAG_HOVERED = 0x00000002; |
| 2696 |
|
| 2697 |
|
| 2698 |
@IntDef(prefix = { "LAYOUT_DIRECTION_" }, value = { |
| 2699 |
LAYOUT_DIRECTION_LTR, |
| 2700 |
LAYOUT_DIRECTION_RTL, |
| 2701 |
LAYOUT_DIRECTION_INHERIT, |
| 2702 |
LAYOUT_DIRECTION_LOCALE |
| 2703 |
}) |
| 2704 |
@Retention(RetentionPolicy.SOURCE) |
| 2705 |
|
| 2706 |
public @interface LayoutDir {} |
| 2707 |
|
| 2708 |
|
| 2709 |
@IntDef(prefix = { "LAYOUT_DIRECTION_" }, value = { |
| 2710 |
LAYOUT_DIRECTION_LTR, |
| 2711 |
LAYOUT_DIRECTION_RTL |
| 2712 |
}) |
| 2713 |
@Retention(RetentionPolicy.SOURCE) |
| 2714 |
public @interface ResolvedLayoutDir {} |
| 2715 |
|
| 2716 |
|
| 2717 |
|
| 2718 |
|
| 2719 |
|
| 2720 |
public static final int LAYOUT_DIRECTION_UNDEFINED = LayoutDirection.UNDEFINED; |
| 2721 |
|
| 2722 |
|
| 2723 |
|
| 2724 |
|
| 2725 |
|
| 2726 |
public static final int LAYOUT_DIRECTION_LTR = LayoutDirection.LTR; |
| 2727 |
|
| 2728 |
|
| 2729 |
|
| 2730 |
|
| 2731 |
|
| 2732 |
public static final int LAYOUT_DIRECTION_RTL = LayoutDirection.RTL; |
| 2733 |
|
| 2734 |
|
| 2735 |
|
| 2736 |
|
| 2737 |
|
| 2738 |
public static final int LAYOUT_DIRECTION_INHERIT = LayoutDirection.INHERIT; |
| 2739 |
|
| 2740 |
|
| 2741 |
|
| 2742 |
|
| 2743 |
|
| 2744 |
public static final int LAYOUT_DIRECTION_LOCALE = LayoutDirection.LOCALE; |
| 2745 |
|
| 2746 |
|
| 2747 |
|
| 2748 |
|
| 2749 |
|
| 2750 |
static final int PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT = 2; |
| 2751 |
|
| 2752 |
|
| 2753 |
|
| 2754 |
|
| 2755 |
|
| 2756 |
static final int PFLAG2_LAYOUT_DIRECTION_MASK = 0x00000003 << PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT; |
| 2757 |
|
| 2758 |
|
| 2759 |
|
| 2760 |
|
| 2761 |
|
| 2762 |
|
| 2763 |
static final int PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL = 4 << PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT; |
| 2764 |
|
| 2765 |
|
| 2766 |
|
| 2767 |
|
| 2768 |
|
| 2769 |
static final int PFLAG2_LAYOUT_DIRECTION_RESOLVED = 8 << PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT; |
| 2770 |
|
| 2771 |
|
| 2772 |
|
| 2773 |
|
| 2774 |
|
| 2775 |
static final int PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK = 0x0000000C |
| 2776 |
<< PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT; |
| 2777 |
|
| 2778 |
|
| 2779 |
|
| 2780 |
|
| 2781 |
|
| 2782 |
|
| 2783 |
private static final int[] LAYOUT_DIRECTION_FLAGS = { |
| 2784 |
LAYOUT_DIRECTION_LTR, |
| 2785 |
LAYOUT_DIRECTION_RTL, |
| 2786 |
LAYOUT_DIRECTION_INHERIT, |
| 2787 |
LAYOUT_DIRECTION_LOCALE |
| 2788 |
}; |
| 2789 |
|
| 2790 |
|
| 2791 |
|
| 2792 |
|
| 2793 |
private static final int LAYOUT_DIRECTION_DEFAULT = LAYOUT_DIRECTION_INHERIT; |
| 2794 |
|
| 2795 |
|
| 2796 |
|
| 2797 |
|
| 2798 |
|
| 2799 |
static final int LAYOUT_DIRECTION_RESOLVED_DEFAULT = LAYOUT_DIRECTION_LTR; |
| 2800 |
|
| 2801 |
|
| 2802 |
|
| 2803 |
|
| 2804 |
public static final int TEXT_DIRECTION_INHERIT = 0; |
| 2805 |
|
| 2806 |
|
| 2807 |
|
| 2808 |
|
| 2809 |
|
| 2810 |
|
| 2811 |
public static final int TEXT_DIRECTION_FIRST_STRONG = 1; |
| 2812 |
|
| 2813 |
|
| 2814 |
|
| 2815 |
|
| 2816 |
|
| 2817 |
|
| 2818 |
public static final int TEXT_DIRECTION_ANY_RTL = 2; |
| 2819 |
|
| 2820 |
|
| 2821 |
|
| 2822 |
|
| 2823 |
public static final int TEXT_DIRECTION_LTR = 3; |
| 2824 |
|
| 2825 |
|
| 2826 |
|
| 2827 |
|
| 2828 |
public static final int TEXT_DIRECTION_RTL = 4; |
| 2829 |
|
| 2830 |
|
| 2831 |
|
| 2832 |
|
| 2833 |
public static final int TEXT_DIRECTION_LOCALE = 5; |
| 2834 |
|
| 2835 |
|
| 2836 |
|
| 2837 |
|
| 2838 |
|
| 2839 |
|
| 2840 |
public static final int TEXT_DIRECTION_FIRST_STRONG_LTR = 6; |
| 2841 |
|
| 2842 |
|
| 2843 |
|
| 2844 |
|
| 2845 |
|
| 2846 |
|
| 2847 |
public static final int TEXT_DIRECTION_FIRST_STRONG_RTL = 7; |
| 2848 |
|
| 2849 |
|
| 2850 |
|
| 2851 |
|
| 2852 |
private static final int TEXT_DIRECTION_DEFAULT = TEXT_DIRECTION_INHERIT; |
| 2853 |
|
| 2854 |
|
| 2855 |
|
| 2856 |
|
| 2857 |
|
| 2858 |
static final int TEXT_DIRECTION_RESOLVED_DEFAULT = TEXT_DIRECTION_FIRST_STRONG; |
| 2859 |
|
| 2860 |
|
| 2861 |
|
| 2862 |
|
| 2863 |
|
| 2864 |
static final int PFLAG2_TEXT_DIRECTION_MASK_SHIFT = 6; |
| 2865 |
|
| 2866 |
|
| 2867 |
|
| 2868 |
|
| 2869 |
|
| 2870 |
static final int PFLAG2_TEXT_DIRECTION_MASK = 0x00000007 |
| 2871 |
<< PFLAG2_TEXT_DIRECTION_MASK_SHIFT; |
| 2872 |
|
| 2873 |
|
| 2874 |
|
| 2875 |
|
| 2876 |
|
| 2877 |
|
| 2878 |
private static final int[] PFLAG2_TEXT_DIRECTION_FLAGS = { |
| 2879 |
TEXT_DIRECTION_INHERIT << PFLAG2_TEXT_DIRECTION_MASK_SHIFT, |
| 2880 |
TEXT_DIRECTION_FIRST_STRONG << PFLAG2_TEXT_DIRECTION_MASK_SHIFT, |
| 2881 |
TEXT_DIRECTION_ANY_RTL << PFLAG2_TEXT_DIRECTION_MASK_SHIFT, |
| 2882 |
TEXT_DIRECTION_LTR << PFLAG2_TEXT_DIRECTION_MASK_SHIFT, |
| 2883 |
TEXT_DIRECTION_RTL << PFLAG2_TEXT_DIRECTION_MASK_SHIFT, |
| 2884 |
TEXT_DIRECTION_LOCALE << PFLAG2_TEXT_DIRECTION_MASK_SHIFT, |
| 2885 |
TEXT_DIRECTION_FIRST_STRONG_LTR << PFLAG2_TEXT_DIRECTION_MASK_SHIFT, |
| 2886 |
TEXT_DIRECTION_FIRST_STRONG_RTL << PFLAG2_TEXT_DIRECTION_MASK_SHIFT |
| 2887 |
}; |
| 2888 |
|
| 2889 |
|
| 2890 |
|
| 2891 |
|
| 2892 |
|
| 2893 |
static final int PFLAG2_TEXT_DIRECTION_RESOLVED = 0x00000008 |
| 2894 |
<< PFLAG2_TEXT_DIRECTION_MASK_SHIFT; |
| 2895 |
|
| 2896 |
|
| 2897 |
|
| 2898 |
|
| 2899 |
|
| 2900 |
static final int PFLAG2_TEXT_DIRECTION_RESOLVED_MASK_SHIFT = 10; |
| 2901 |
|
| 2902 |
|
| 2903 |
|
| 2904 |
|
| 2905 |
|
| 2906 |
static final int PFLAG2_TEXT_DIRECTION_RESOLVED_MASK = 0x00000007 |
| 2907 |
<< PFLAG2_TEXT_DIRECTION_RESOLVED_MASK_SHIFT; |
| 2908 |
|
| 2909 |
|
| 2910 |
|
| 2911 |
|
| 2912 |
|
| 2913 |
static final int PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT = |
| 2914 |
TEXT_DIRECTION_RESOLVED_DEFAULT << PFLAG2_TEXT_DIRECTION_RESOLVED_MASK_SHIFT; |
| 2915 |
|
| 2916 |
|
| 2917 |
@IntDef(prefix = { "TEXT_ALIGNMENT_" }, value = { |
| 2918 |
TEXT_ALIGNMENT_INHERIT, |
| 2919 |
TEXT_ALIGNMENT_GRAVITY, |
| 2920 |
TEXT_ALIGNMENT_CENTER, |
| 2921 |
TEXT_ALIGNMENT_TEXT_START, |
| 2922 |
TEXT_ALIGNMENT_TEXT_END, |
| 2923 |
TEXT_ALIGNMENT_VIEW_START, |
| 2924 |
TEXT_ALIGNMENT_VIEW_END |
| 2925 |
}) |
| 2926 |
@Retention(RetentionPolicy.SOURCE) |
| 2927 |
public @interface TextAlignment {} |
| 2928 |
|
| 2929 |
|
| 2930 |
|
| 2931 |
|
| 2932 |
|
| 2933 |
public static final int TEXT_ALIGNMENT_INHERIT = 0; |
| 2934 |
|
| 2935 |
|
| 2936 |
|
| 2937 |
|
| 2938 |
|
| 2939 |
|
| 2940 |
|
| 2941 |
public static final int TEXT_ALIGNMENT_GRAVITY = 1; |
| 2942 |
|
| 2943 |
|
| 2944 |
|
| 2945 |
|
| 2946 |
|
| 2947 |
|
| 2948 |
public static final int TEXT_ALIGNMENT_TEXT_START = 2; |
| 2949 |
|
| 2950 |
|
| 2951 |
|
| 2952 |
|
| 2953 |
|
| 2954 |
|
| 2955 |
public static final int TEXT_ALIGNMENT_TEXT_END = 3; |
| 2956 |
|
| 2957 |
|
| 2958 |
|
| 2959 |
|
| 2960 |
|
| 2961 |
|
| 2962 |
public static final int TEXT_ALIGNMENT_CENTER = 4; |
| 2963 |
|
| 2964 |
|
| 2965 |
|
| 2966 |
|
| 2967 |
|
| 2968 |
|
| 2969 |
|
| 2970 |
public static final int TEXT_ALIGNMENT_VIEW_START = 5; |
| 2971 |
|
| 2972 |
|
| 2973 |
|
| 2974 |
|
| 2975 |
|
| 2976 |
|
| 2977 |
|
| 2978 |
public static final int TEXT_ALIGNMENT_VIEW_END = 6; |
| 2979 |
|
| 2980 |
|
| 2981 |
|
| 2982 |
|
| 2983 |
private static final int TEXT_ALIGNMENT_DEFAULT = TEXT_ALIGNMENT_GRAVITY; |
| 2984 |
|
| 2985 |
|
| 2986 |
|
| 2987 |
|
| 2988 |
|
| 2989 |
static final int TEXT_ALIGNMENT_RESOLVED_DEFAULT = TEXT_ALIGNMENT_GRAVITY; |
| 2990 |
|
| 2991 |
|
| 2992 |
|
| 2993 |
|
| 2994 |
|
| 2995 |
static final int PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT = 13; |
| 2996 |
|
| 2997 |
|
| 2998 |
|
| 2999 |
|
| 3000 |
|
| 3001 |
static final int PFLAG2_TEXT_ALIGNMENT_MASK = 0x00000007 << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT; |
| 3002 |
|
| 3003 |
|
| 3004 |
|
| 3005 |
|
| 3006 |
|
| 3007 |
|
| 3008 |
private static final int[] PFLAG2_TEXT_ALIGNMENT_FLAGS = { |
| 3009 |
TEXT_ALIGNMENT_INHERIT << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT, |
| 3010 |
TEXT_ALIGNMENT_GRAVITY << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT, |
| 3011 |
TEXT_ALIGNMENT_TEXT_START << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT, |
| 3012 |
TEXT_ALIGNMENT_TEXT_END << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT, |
| 3013 |
TEXT_ALIGNMENT_CENTER << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT, |
| 3014 |
TEXT_ALIGNMENT_VIEW_START << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT, |
| 3015 |
TEXT_ALIGNMENT_VIEW_END << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT |
| 3016 |
}; |
| 3017 |
|
| 3018 |
|
| 3019 |
|
| 3020 |
|
| 3021 |
|
| 3022 |
static final int PFLAG2_TEXT_ALIGNMENT_RESOLVED = 0x00000008 << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT; |
| 3023 |
|
| 3024 |
|
| 3025 |
|
| 3026 |
|
| 3027 |
|
| 3028 |
static final int PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT = 17; |
| 3029 |
|
| 3030 |
|
| 3031 |
|
| 3032 |
|
| 3033 |
|
| 3034 |
static final int PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK = 0x00000007 |
| 3035 |
<< PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT; |
| 3036 |
|
| 3037 |
|
| 3038 |
|
| 3039 |
|
| 3040 |
private static final int PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT = |
| 3041 |
TEXT_ALIGNMENT_RESOLVED_DEFAULT << PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT; |
| 3042 |
|
| 3043 |
|
| 3044 |
|
| 3045 |
|
| 3046 |
|
| 3047 |
|
| 3048 |
|
| 3049 |
static final int PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT = 20; |
| 3050 |
|
| 3051 |
|
| 3052 |
|
| 3053 |
|
| 3054 |
public static final int IMPORTANT_FOR_ACCESSIBILITY_AUTO = 0x00000000; |
| 3055 |
|
| 3056 |
|
| 3057 |
|
| 3058 |
|
| 3059 |
public static final int IMPORTANT_FOR_ACCESSIBILITY_YES = 0x00000001; |
| 3060 |
|
| 3061 |
|
| 3062 |
|
| 3063 |
|
| 3064 |
public static final int IMPORTANT_FOR_ACCESSIBILITY_NO = 0x00000002; |
| 3065 |
|
| 3066 |
|
| 3067 |
|
| 3068 |
|
| 3069 |
|
| 3070 |
public static final int IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS = 0x00000004; |
| 3071 |
|
| 3072 |
|
| 3073 |
|
| 3074 |
|
| 3075 |
static final int IMPORTANT_FOR_ACCESSIBILITY_DEFAULT = IMPORTANT_FOR_ACCESSIBILITY_AUTO; |
| 3076 |
|
| 3077 |
|
| 3078 |
|
| 3079 |
|
| 3080 |
|
| 3081 |
static final int PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK = (IMPORTANT_FOR_ACCESSIBILITY_AUTO |
| 3082 |
| IMPORTANT_FOR_ACCESSIBILITY_YES | IMPORTANT_FOR_ACCESSIBILITY_NO |
| 3083 |
| IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) |
| 3084 |
<< PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT; |
| 3085 |
|
| 3086 |
|
| 3087 |
|
| 3088 |
|
| 3089 |
|
| 3090 |
static final int PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT = 23; |
| 3091 |
|
| 3092 |
|
| 3093 |
|
| 3094 |
|
| 3095 |
|
| 3096 |
|
| 3097 |
|
| 3098 |
|
| 3099 |
public static final int ACCESSIBILITY_LIVE_REGION_NONE = 0x00000000; |
| 3100 |
|
| 3101 |
|
| 3102 |
|
| 3103 |
|
| 3104 |
|
| 3105 |
|
| 3106 |
|
| 3107 |
public static final int ACCESSIBILITY_LIVE_REGION_POLITE = 0x00000001; |
| 3108 |
|
| 3109 |
|
| 3110 |
|
| 3111 |
|
| 3112 |
|
| 3113 |
|
| 3114 |
|
| 3115 |
public static final int ACCESSIBILITY_LIVE_REGION_ASSERTIVE = 0x00000002; |
| 3116 |
|
| 3117 |
|
| 3118 |
|
| 3119 |
|
| 3120 |
static final int ACCESSIBILITY_LIVE_REGION_DEFAULT = ACCESSIBILITY_LIVE_REGION_NONE; |
| 3121 |
|
| 3122 |
|
| 3123 |
|
| 3124 |
|
| 3125 |
|
| 3126 |
static final int PFLAG2_ACCESSIBILITY_LIVE_REGION_MASK = (ACCESSIBILITY_LIVE_REGION_NONE |
| 3127 |
| ACCESSIBILITY_LIVE_REGION_POLITE | ACCESSIBILITY_LIVE_REGION_ASSERTIVE) |
| 3128 |
<< PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT; |
| 3129 |
|
| 3130 |
|
| 3131 |
|
| 3132 |
|
| 3133 |
static final int PFLAG2_ACCESSIBILITY_FOCUSED = 0x04000000; |
| 3134 |
|
| 3135 |
|
| 3136 |
|
| 3137 |
|
| 3138 |
static final int PFLAG2_SUBTREE_ACCESSIBILITY_STATE_CHANGED = 0x08000000; |
| 3139 |
|
| 3140 |
|
| 3141 |
|
| 3142 |
|
| 3143 |
|
| 3144 |
|
| 3145 |
static final int PFLAG2_VIEW_QUICK_REJECTED = 0x10000000; |
| 3146 |
|
| 3147 |
|
| 3148 |
|
| 3149 |
|
| 3150 |
|
| 3151 |
|
| 3152 |
|
| 3153 |
|
| 3154 |
static final int PFLAG2_PADDING_RESOLVED = 0x20000000; |
| 3155 |
|
| 3156 |
|
| 3157 |
|
| 3158 |
|
| 3159 |
static final int PFLAG2_DRAWABLE_RESOLVED = 0x40000000; |
| 3160 |
|
| 3161 |
|
| 3162 |
|
| 3163 |
|
| 3164 |
|
| 3165 |
|
| 3166 |
static final int PFLAG2_HAS_TRANSIENT_STATE = 0x80000000; |
| 3167 |
|
| 3168 |
|
| 3169 |
|
| 3170 |
|
| 3171 |
static final int ALL_RTL_PROPERTIES_RESOLVED = PFLAG2_LAYOUT_DIRECTION_RESOLVED | |
| 3172 |
PFLAG2_TEXT_DIRECTION_RESOLVED | |
| 3173 |
PFLAG2_TEXT_ALIGNMENT_RESOLVED | |
| 3174 |
PFLAG2_PADDING_RESOLVED | |
| 3175 |
PFLAG2_DRAWABLE_RESOLVED; |
| 3176 |
|
| 3177 |
|
| 3178 |
|
| 3179 |
|
| 3180 |
|
| 3181 |
|
| 3182 |
|
| 3183 |
|
| 3184 |
|
| 3185 |
|
| 3186 |
|
| 3187 |
|
| 3188 |
|
| 3189 |
|
| 3190 |
|
| 3191 |
|
| 3192 |
|
| 3193 |
|
| 3194 |
|
| 3195 |
|
| 3196 |
|
| 3197 |
|
| 3198 |
|
| 3199 |
|
| 3200 |
|
| 3201 |
|
| 3202 |
|
| 3203 |
|
| 3204 |
|
| 3205 |
|
| 3206 |
|
| 3207 |
|
| 3208 |
|
| 3209 |
|
| 3210 |
|
| 3211 |
|
| 3212 |
|
| 3213 |
|
| 3214 |
|
| 3215 |
|
| 3216 |
|
| 3217 |
|
| 3218 |
|
| 3219 |
|
| 3220 |
|
| 3221 |
|
| 3222 |
static final int PFLAG3_VIEW_IS_ANIMATING_TRANSFORM = 0x1; |
| 3223 |
|
| 3224 |
|
| 3225 |
|
| 3226 |
|
| 3227 |
|
| 3228 |
|
| 3229 |
static final int PFLAG3_VIEW_IS_ANIMATING_ALPHA = 0x2; |
| 3230 |
|
| 3231 |
|
| 3232 |
|
| 3233 |
|
| 3234 |
|
| 3235 |
static final int PFLAG3_IS_LAID_OUT = 0x4; |
| 3236 |
|
| 3237 |
|
| 3238 |
|
| 3239 |
|
| 3240 |
|
| 3241 |
static final int PFLAG3_MEASURE_NEEDED_BEFORE_LAYOUT = 0x8; |
| 3242 |
|
| 3243 |
|
| 3244 |
|
| 3245 |
|
| 3246 |
|
| 3247 |
static final int PFLAG3_CALLED_SUPER = 0x10; |
| 3248 |
|
| 3249 |
|
| 3250 |
|
| 3251 |
|
| 3252 |
static final int PFLAG3_APPLYING_INSETS = 0x20; |
| 3253 |
|
| 3254 |
|
| 3255 |
|
| 3256 |
|
| 3257 |
static final int PFLAG3_FITTING_SYSTEM_WINDOWS = 0x40; |
| 3258 |
|
| 3259 |
|
| 3260 |
|
| 3261 |
|
| 3262 |
|
| 3263 |
|
| 3264 |
static final int PFLAG3_NESTED_SCROLLING_ENABLED = 0x80; |
| 3265 |
|
| 3266 |
|
| 3267 |
|
| 3268 |
|
| 3269 |
|
| 3270 |
static final int PFLAG3_SCROLL_INDICATOR_TOP = 0x0100; |
| 3271 |
|
| 3272 |
|
| 3273 |
|
| 3274 |
|
| 3275 |
|
| 3276 |
static final int PFLAG3_SCROLL_INDICATOR_BOTTOM = 0x0200; |
| 3277 |
|
| 3278 |
|
| 3279 |
|
| 3280 |
|
| 3281 |
|
| 3282 |
static final int PFLAG3_SCROLL_INDICATOR_LEFT = 0x0400; |
| 3283 |
|
| 3284 |
|
| 3285 |
|
| 3286 |
|
| 3287 |
|
| 3288 |
static final int PFLAG3_SCROLL_INDICATOR_RIGHT = 0x0800; |
| 3289 |
|
| 3290 |
|
| 3291 |
|
| 3292 |
|
| 3293 |
|
| 3294 |
static final int PFLAG3_SCROLL_INDICATOR_START = 0x1000; |
| 3295 |
|
| 3296 |
|
| 3297 |
|
| 3298 |
|
| 3299 |
|
| 3300 |
static final int PFLAG3_SCROLL_INDICATOR_END = 0x2000; |
| 3301 |
|
| 3302 |
static final int DRAG_MASK = PFLAG2_DRAG_CAN_ACCEPT | PFLAG2_DRAG_HOVERED; |
| 3303 |
|
| 3304 |
static final int SCROLL_INDICATORS_NONE = 0x0000; |
| 3305 |
|
| 3306 |
|
| 3307 |
|
| 3308 |
|
| 3309 |
|
| 3310 |
static final int SCROLL_INDICATORS_PFLAG3_MASK = PFLAG3_SCROLL_INDICATOR_TOP |
| 3311 |
| PFLAG3_SCROLL_INDICATOR_BOTTOM | PFLAG3_SCROLL_INDICATOR_LEFT |
| 3312 |
| PFLAG3_SCROLL_INDICATOR_RIGHT | PFLAG3_SCROLL_INDICATOR_START |
| 3313 |
| PFLAG3_SCROLL_INDICATOR_END; |
| 3314 |
|
| 3315 |
|
| 3316 |
|
| 3317 |
|
| 3318 |
|
| 3319 |
|
| 3320 |
static final int SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT = 8; |
| 3321 |
|
| 3322 |
|
| 3323 |
@Retention(RetentionPolicy.SOURCE) |
| 3324 |
@IntDef(flag = true, prefix = { "SCROLL_INDICATOR_" }, value = { |
| 3325 |
SCROLL_INDICATOR_TOP, |
| 3326 |
SCROLL_INDICATOR_BOTTOM, |
| 3327 |
SCROLL_INDICATOR_LEFT, |
| 3328 |
SCROLL_INDICATOR_RIGHT, |
| 3329 |
SCROLL_INDICATOR_START, |
| 3330 |
SCROLL_INDICATOR_END, |
| 3331 |
}) |
| 3332 |
public @interface ScrollIndicators {} |
| 3333 |
|
| 3334 |
|
| 3335 |
|
| 3336 |
|
| 3337 |
|
| 3338 |
|
| 3339 |
|
| 3340 |
|
| 3341 |
public static final int SCROLL_INDICATOR_TOP = |
| 3342 |
PFLAG3_SCROLL_INDICATOR_TOP >> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; |
| 3343 |
|
| 3344 |
|
| 3345 |
|
| 3346 |
|
| 3347 |
|
| 3348 |
|
| 3349 |
|
| 3350 |
|
| 3351 |
public static final int SCROLL_INDICATOR_BOTTOM = |
| 3352 |
PFLAG3_SCROLL_INDICATOR_BOTTOM >> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; |
| 3353 |
|
| 3354 |
|
| 3355 |
|
| 3356 |
|
| 3357 |
|
| 3358 |
|
| 3359 |
|
| 3360 |
|
| 3361 |
public static final int SCROLL_INDICATOR_LEFT = |
| 3362 |
PFLAG3_SCROLL_INDICATOR_LEFT >> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; |
| 3363 |
|
| 3364 |
|
| 3365 |
|
| 3366 |
|
| 3367 |
|
| 3368 |
|
| 3369 |
|
| 3370 |
|
| 3371 |
public static final int SCROLL_INDICATOR_RIGHT = |
| 3372 |
PFLAG3_SCROLL_INDICATOR_RIGHT >> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; |
| 3373 |
|
| 3374 |
|
| 3375 |
|
| 3376 |
|
| 3377 |
|
| 3378 |
|
| 3379 |
|
| 3380 |
|
| 3381 |
|
| 3382 |
|
| 3383 |
|
| 3384 |
public static final int SCROLL_INDICATOR_START = |
| 3385 |
PFLAG3_SCROLL_INDICATOR_START >> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; |
| 3386 |
|
| 3387 |
|
| 3388 |
|
| 3389 |
|
| 3390 |
|
| 3391 |
|
| 3392 |
|
| 3393 |
|
| 3394 |
|
| 3395 |
|
| 3396 |
|
| 3397 |
public static final int SCROLL_INDICATOR_END = |
| 3398 |
PFLAG3_SCROLL_INDICATOR_END >> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; |
| 3399 |
|
| 3400 |
|
| 3401 |
|
| 3402 |
|
| 3403 |
|
| 3404 |
static final int PFLAG3_ASSIST_BLOCKED = 0x4000; |
| 3405 |
|
| 3406 |
|
| 3407 |
|
| 3408 |
|
| 3409 |
|
| 3410 |
|
| 3411 |
|
| 3412 |
private static final int PFLAG3_CLUSTER = 0x8000; |
| 3413 |
|
| 3414 |
|
| 3415 |
|
| 3416 |
|
| 3417 |
|
| 3418 |
|
| 3419 |
|
| 3420 |
private static final int PFLAG3_IS_AUTOFILLED = 0x10000; |
| 3421 |
|
| 3422 |
|
| 3423 |
|
| 3424 |
|
| 3425 |
|
| 3426 |
private static final int PFLAG3_FINGER_DOWN = 0x20000; |
| 3427 |
|
| 3428 |
|
| 3429 |
|
| 3430 |
|
| 3431 |
|
| 3432 |
|
| 3433 |
|
| 3434 |
private static final int PFLAG3_FOCUSED_BY_DEFAULT = 0x40000; |
| 3435 |
|
| 3436 |
|
| 3437 |
|
| 3438 |
|
| 3439 |
|
| 3440 |
static final int PFLAG3_IMPORTANT_FOR_AUTOFILL_SHIFT = 19; |
| 3441 |
|
| 3442 |
|
| 3443 |
|
| 3444 |
|
| 3445 |
|
| 3446 |
static final int PFLAG3_IMPORTANT_FOR_AUTOFILL_MASK = (IMPORTANT_FOR_AUTOFILL_AUTO |
| 3447 |
| IMPORTANT_FOR_AUTOFILL_YES | IMPORTANT_FOR_AUTOFILL_NO |
| 3448 |
| IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS |
| 3449 |
| IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS) |
| 3450 |
<< PFLAG3_IMPORTANT_FOR_AUTOFILL_SHIFT; |
| 3451 |
|
| 3452 |
|
| 3453 |
|
| 3454 |
|
| 3455 |
|
| 3456 |
|
| 3457 |
|
| 3458 |
|
| 3459 |
private static final int PFLAG3_OVERLAPPING_RENDERING_FORCED_VALUE = 0x800000; |
| 3460 |
|
| 3461 |
|
| 3462 |
|
| 3463 |
|
| 3464 |
|
| 3465 |
private static final int PFLAG3_HAS_OVERLAPPING_RENDERING_FORCED = 0x1000000; |
| 3466 |
|
| 3467 |
|
| 3468 |
|
| 3469 |
|
| 3470 |
|
| 3471 |
|
| 3472 |
|
| 3473 |
static final int PFLAG3_TEMPORARY_DETACH = 0x2000000; |
| 3474 |
|
| 3475 |
|
| 3476 |
|
| 3477 |
|
| 3478 |
|
| 3479 |
|
| 3480 |
|
| 3481 |
|
| 3482 |
|
| 3483 |
private static final int PFLAG3_NO_REVEAL_ON_FOCUS = 0x4000000; |
| 3484 |
|
| 3485 |
|
| 3486 |
|
| 3487 |
|
| 3488 |
|
| 3489 |
|
| 3490 |
|
| 3491 |
static final int PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT = 0x8000000; |
| 3492 |
|
| 3493 |
|
| 3494 |
|
| 3495 |
|
| 3496 |
|
| 3497 |
private static final int PFLAG3_SCREEN_READER_FOCUSABLE = 0x10000000; |
| 3498 |
|
| 3499 |
|
| 3500 |
|
| 3501 |
|
| 3502 |
private static final int PFLAG3_AGGREGATED_VISIBLE = 0x20000000; |
| 3503 |
|
| 3504 |
|
| 3505 |
|
| 3506 |
|
| 3507 |
|
| 3508 |
private static final int PFLAG3_AUTOFILLID_EXPLICITLY_SET = 0x40000000; |
| 3509 |
|
| 3510 |
|
| 3511 |
|
| 3512 |
|
| 3513 |
private static final int PFLAG3_ACCESSIBILITY_HEADING = 0x80000000; |
| 3514 |
|
| 3515 |
|
| 3516 |
|
| 3517 |
|
| 3518 |
|
| 3519 |
|
| 3520 |
|
| 3521 |
|
| 3522 |
|
| 3523 |
|
| 3524 |
|
| 3525 |
|
| 3526 |
|
| 3527 |
|
| 3528 |
|
| 3529 |
|
| 3530 |
|
| 3531 |
|
| 3532 |
|
| 3533 |
|
| 3534 |
|
| 3535 |
|
| 3536 |
|
| 3537 |
|
| 3538 |
|
| 3539 |
|
| 3540 |
|
| 3541 |
|
| 3542 |
|
| 3543 |
|
| 3544 |
|
| 3545 |
private static final int PFLAG4_IMPORTANT_FOR_CONTENT_CAPTURE_MASK = |
| 3546 |
IMPORTANT_FOR_CONTENT_CAPTURE_AUTO | IMPORTANT_FOR_CONTENT_CAPTURE_YES |
| 3547 |
| IMPORTANT_FOR_CONTENT_CAPTURE_NO |
| 3548 |
| IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS |
| 3549 |
| IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS; |
| 3550 |
|
| 3551 |
|
| 3552 |
|
| 3553 |
|
| 3554 |
|
| 3555 |
|
| 3556 |
|
| 3557 |
|
| 3558 |
private static final int PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED = 0x10; |
| 3559 |
private static final int PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED = 0x20; |
| 3560 |
|
| 3561 |
|
| 3562 |
|
| 3563 |
|
| 3564 |
|
| 3565 |
private static final int PFLAG4_CONTENT_CAPTURE_IMPORTANCE_IS_CACHED = 0x40; |
| 3566 |
private static final int PFLAG4_CONTENT_CAPTURE_IMPORTANCE_CACHED_VALUE = 0x80; |
| 3567 |
|
| 3568 |
private static final int PFLAG4_CONTENT_CAPTURE_IMPORTANCE_MASK = |
| 3569 |
PFLAG4_CONTENT_CAPTURE_IMPORTANCE_IS_CACHED |
| 3570 |
| PFLAG4_CONTENT_CAPTURE_IMPORTANCE_CACHED_VALUE; |
| 3571 |
|
| 3572 |
|
| 3573 |
|
| 3574 |
|
| 3575 |
static final int PFLAG4_FRAMEWORK_OPTIONAL_FITS_SYSTEM_WINDOWS = 0x000000100; |
| 3576 |
|
| 3577 |
|
| 3578 |
|
| 3579 |
|
| 3580 |
private static final int PFLAG4_AUTOFILL_HIDE_HIGHLIGHT = 0x200; |
| 3581 |
|
| 3582 |
|
| 3583 |
|
| 3584 |
|
| 3585 |
static final int PFLAG4_SCROLL_CAPTURE_HINT_SHIFT = 10; |
| 3586 |
|
| 3587 |
static final int PFLAG4_SCROLL_CAPTURE_HINT_MASK = (SCROLL_CAPTURE_HINT_INCLUDE |
| 3588 |
| SCROLL_CAPTURE_HINT_EXCLUDE | SCROLL_CAPTURE_HINT_EXCLUDE_DESCENDANTS) |
| 3589 |
<< PFLAG4_SCROLL_CAPTURE_HINT_SHIFT; |
| 3590 |
|
| 3591 |
|
| 3592 |
|
| 3593 |
|
| 3594 |
private static final int PFLAG4_ALLOW_CLICK_WHEN_DISABLED = 0x000001000; |
| 3595 |
|
| 3596 |
|
| 3597 |
|
| 3598 |
|
| 3599 |
private static final int PFLAG4_DETACHED = 0x000002000; |
| 3600 |
|
| 3601 |
|
| 3602 |
|
| 3603 |
|
| 3604 |
private static final int PFLAG4_HAS_TRANSLATION_TRANSIENT_STATE = 0x000004000; |
| 3605 |
|
| 3606 |
|
| 3607 |
|
| 3608 |
|
| 3609 |
private static final int PFLAG4_DRAG_A11Y_STARTED = 0x000008000; |
| 3610 |
|
| 3611 |
|
| 3612 |
|
| 3613 |
|
| 3614 |
private static final int PFLAG4_AUTO_HANDWRITING_ENABLED = 0x000010000; |
| 3615 |
|
| 3616 |
|
| 3617 |
|
| 3618 |
protected static final int VIEW_STRUCTURE_FOR_ASSIST = 0; |
| 3619 |
|
| 3620 |
protected static final int VIEW_STRUCTURE_FOR_AUTOFILL = 1; |
| 3621 |
|
| 3622 |
protected static final int VIEW_STRUCTURE_FOR_CONTENT_CAPTURE = 2; |
| 3623 |
|
| 3624 |
|
| 3625 |
@IntDef(flag = true, prefix = { "VIEW_STRUCTURE_FOR" }, value = { |
| 3626 |
VIEW_STRUCTURE_FOR_ASSIST, |
| 3627 |
VIEW_STRUCTURE_FOR_AUTOFILL, |
| 3628 |
VIEW_STRUCTURE_FOR_CONTENT_CAPTURE |
| 3629 |
}) |
| 3630 |
@Retention(RetentionPolicy.SOURCE) |
| 3631 |
public @interface ViewStructureType {} |
| 3632 |
|
| 3633 |
|
| 3634 |
|
| 3635 |
|
| 3636 |
|
| 3637 |
|
| 3638 |
|
| 3639 |
|
| 3640 |
public static final int OVER_SCROLL_ALWAYS = 0; |
| 3641 |
|
| 3642 |
|
| 3643 |
|
| 3644 |
|
| 3645 |
|
| 3646 |
|
| 3647 |
|
| 3648 |
|
| 3649 |
public static final int OVER_SCROLL_IF_CONTENT_SCROLLS = 1; |
| 3650 |
|
| 3651 |
|
| 3652 |
|
| 3653 |
|
| 3654 |
|
| 3655 |
|
| 3656 |
|
| 3657 |
public static final int OVER_SCROLL_NEVER = 2; |
| 3658 |
|
| 3659 |
|
| 3660 |
|
| 3661 |
|
| 3662 |
|
| 3663 |
|
| 3664 |
|
| 3665 |
|
| 3666 |
|
| 3667 |
@Deprecated |
| 3668 |
public static final int SYSTEM_UI_FLAG_VISIBLE = 0; |
| 3669 |
|
| 3670 |
|
| 3671 |
|
| 3672 |
|
| 3673 |
|
| 3674 |
|
| 3675 |
|
| 3676 |
|
| 3677 |
|
| 3678 |
|
| 3679 |
|
| 3680 |
|
| 3681 |
|
| 3682 |
|
| 3683 |
|
| 3684 |
@Deprecated |
| 3685 |
public static final int SYSTEM_UI_FLAG_LOW_PROFILE = 0x00000001; |
| 3686 |
|
| 3687 |
|
| 3688 |
|
| 3689 |
|
| 3690 |
|
| 3691 |
|
| 3692 |
|
| 3693 |
|
| 3694 |
|
| 3695 |
|
| 3696 |
|
| 3697 |
|
| 3698 |
|
| 3699 |
|
| 3700 |
|
| 3701 |
|
| 3702 |
|
| 3703 |
|
| 3704 |
|
| 3705 |
|
| 3706 |
|
| 3707 |
|
| 3708 |
@Deprecated |
| 3709 |
public static final int SYSTEM_UI_FLAG_HIDE_NAVIGATION = 0x00000002; |
| 3710 |
|
| 3711 |
|
| 3712 |
|
| 3713 |
|
| 3714 |
|
| 3715 |
|
| 3716 |
|
| 3717 |
|
| 3718 |
|
| 3719 |
|
| 3720 |
|
| 3721 |
|
| 3722 |
|
| 3723 |
|
| 3724 |
|
| 3725 |
|
| 3726 |
|
| 3727 |
|
| 3728 |
|
| 3729 |
|
| 3730 |
|
| 3731 |
|
| 3732 |
|
| 3733 |
|
| 3734 |
|
| 3735 |
|
| 3736 |
|
| 3737 |
|
| 3738 |
|
| 3739 |
|
| 3740 |
|
| 3741 |
|
| 3742 |
|
| 3743 |
|
| 3744 |
|
| 3745 |
|
| 3746 |
|
| 3747 |
@Deprecated |
| 3748 |
public static final int SYSTEM_UI_FLAG_FULLSCREEN = 0x00000004; |
| 3749 |
|
| 3750 |
|
| 3751 |
|
| 3752 |
|
| 3753 |
|
| 3754 |
|
| 3755 |
|
| 3756 |
|
| 3757 |
|
| 3758 |
|
| 3759 |
|
| 3760 |
|
| 3761 |
|
| 3762 |
|
| 3763 |
|
| 3764 |
|
| 3765 |
|
| 3766 |
|
| 3767 |
|
| 3768 |
|
| 3769 |
|
| 3770 |
|
| 3771 |
|
| 3772 |
|
| 3773 |
|
| 3774 |
|
| 3775 |
|
| 3776 |
|
| 3777 |
|
| 3778 |
|
| 3779 |
|
| 3780 |
|
| 3781 |
|
| 3782 |
|
| 3783 |
|
| 3784 |
|
| 3785 |
@Deprecated |
| 3786 |
public static final int SYSTEM_UI_FLAG_LAYOUT_STABLE = 0x00000100; |
| 3787 |
|
| 3788 |
|
| 3789 |
|
| 3790 |
|
| 3791 |
|
| 3792 |
|
| 3793 |
|
| 3794 |
|
| 3795 |
|
| 3796 |
|
| 3797 |
|
| 3798 |
|
| 3799 |
|
| 3800 |
|
| 3801 |
|
| 3802 |
public static final int SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION = 0x00000200; |
| 3803 |
|
| 3804 |
|
| 3805 |
|
| 3806 |
|
| 3807 |
|
| 3808 |
|
| 3809 |
|
| 3810 |
|
| 3811 |
|
| 3812 |
|
| 3813 |
|
| 3814 |
|
| 3815 |
|
| 3816 |
|
| 3817 |
|
| 3818 |
|
| 3819 |
|
| 3820 |
|
| 3821 |
|
| 3822 |
|
| 3823 |
|
| 3824 |
|
| 3825 |
|
| 3826 |
|
| 3827 |
|
| 3828 |
|
| 3829 |
|
| 3830 |
@Deprecated |
| 3831 |
public static final int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 0x00000400; |
| 3832 |
|
| 3833 |
|
| 3834 |
|
| 3835 |
|
| 3836 |
|
| 3837 |
|
| 3838 |
|
| 3839 |
|
| 3840 |
|
| 3841 |
|
| 3842 |
|
| 3843 |
@Deprecated |
| 3844 |
public static final int SYSTEM_UI_FLAG_IMMERSIVE = 0x00000800; |
| 3845 |
|
| 3846 |
|
| 3847 |
|
| 3848 |
|
| 3849 |
|
| 3850 |
|
| 3851 |
|
| 3852 |
|
| 3853 |
|
| 3854 |
|
| 3855 |
|
| 3856 |
|
| 3857 |
|
| 3858 |
|
| 3859 |
|
| 3860 |
|
| 3861 |
|
| 3862 |
|
| 3863 |
|
| 3864 |
@Deprecated |
| 3865 |
public static final int SYSTEM_UI_FLAG_IMMERSIVE_STICKY = 0x00001000; |
| 3866 |
|
| 3867 |
|
| 3868 |
|
| 3869 |
|
| 3870 |
|
| 3871 |
|
| 3872 |
|
| 3873 |
|
| 3874 |
|
| 3875 |
|
| 3876 |
|
| 3877 |
|
| 3878 |
|
| 3879 |
|
| 3880 |
@Deprecated |
| 3881 |
public static final int SYSTEM_UI_FLAG_LIGHT_STATUS_BAR = 0x00002000; |
| 3882 |
|
| 3883 |
|
| 3884 |
|
| 3885 |
|
| 3886 |
|
| 3887 |
private static final int SYSTEM_UI_RESERVED_LEGACY1 = 0x00004000; |
| 3888 |
|
| 3889 |
|
| 3890 |
|
| 3891 |
|
| 3892 |
|
| 3893 |
private static final int SYSTEM_UI_RESERVED_LEGACY2 = 0x00010000; |
| 3894 |
|
| 3895 |
|
| 3896 |
|
| 3897 |
|
| 3898 |
|
| 3899 |
|
| 3900 |
|
| 3901 |
|
| 3902 |
|
| 3903 |
|
| 3904 |
|
| 3905 |
|
| 3906 |
|
| 3907 |
|
| 3908 |
@Deprecated |
| 3909 |
public static final int SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR = 0x00000010; |
| 3910 |
|
| 3911 |
|
| 3912 |
|
| 3913 |
|
| 3914 |
@Deprecated |
| 3915 |
public static final int STATUS_BAR_HIDDEN = SYSTEM_UI_FLAG_LOW_PROFILE; |
| 3916 |
|
| 3917 |
|
| 3918 |
|
| 3919 |
|
| 3920 |
@Deprecated |
| 3921 |
public static final int STATUS_BAR_VISIBLE = SYSTEM_UI_FLAG_VISIBLE; |
| 3922 |
|
| 3923 |
|
| 3924 |
|
| 3925 |
|
| 3926 |
|
| 3927 |
|
| 3928 |
|
| 3929 |
|
| 3930 |
|
| 3931 |
|
| 3932 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 3933 |
public static final int STATUS_BAR_DISABLE_EXPAND = 0x00010000; |
| 3934 |
|
| 3935 |
|
| 3936 |
|
| 3937 |
|
| 3938 |
|
| 3939 |
|
| 3940 |
|
| 3941 |
|
| 3942 |
|
| 3943 |
public static final int STATUS_BAR_DISABLE_NOTIFICATION_ICONS = 0x00020000; |
| 3944 |
|
| 3945 |
|
| 3946 |
|
| 3947 |
|
| 3948 |
|
| 3949 |
|
| 3950 |
|
| 3951 |
|
| 3952 |
|
| 3953 |
|
| 3954 |
public static final int STATUS_BAR_DISABLE_NOTIFICATION_ALERTS = 0x00040000; |
| 3955 |
|
| 3956 |
|
| 3957 |
|
| 3958 |
|
| 3959 |
|
| 3960 |
|
| 3961 |
|
| 3962 |
|
| 3963 |
|
| 3964 |
|
| 3965 |
|
| 3966 |
public static final int STATUS_BAR_DISABLE_NOTIFICATION_TICKER = 0x00080000; |
| 3967 |
|
| 3968 |
|
| 3969 |
|
| 3970 |
|
| 3971 |
|
| 3972 |
|
| 3973 |
|
| 3974 |
|
| 3975 |
|
| 3976 |
public static final int STATUS_BAR_DISABLE_SYSTEM_INFO = 0x00100000; |
| 3977 |
|
| 3978 |
|
| 3979 |
|
| 3980 |
|
| 3981 |
|
| 3982 |
|
| 3983 |
|
| 3984 |
|
| 3985 |
|
| 3986 |
|
| 3987 |
@UnsupportedAppUsage |
| 3988 |
public static final int STATUS_BAR_DISABLE_HOME = 0x00200000; |
| 3989 |
|
| 3990 |
|
| 3991 |
|
| 3992 |
|
| 3993 |
|
| 3994 |
|
| 3995 |
|
| 3996 |
|
| 3997 |
|
| 3998 |
|
| 3999 |
@UnsupportedAppUsage |
| 4000 |
public static final int STATUS_BAR_DISABLE_BACK = 0x00400000; |
| 4001 |
|
| 4002 |
|
| 4003 |
|
| 4004 |
|
| 4005 |
|
| 4006 |
|
| 4007 |
|
| 4008 |
|
| 4009 |
|
| 4010 |
|
| 4011 |
public static final int STATUS_BAR_DISABLE_CLOCK = 0x00800000; |
| 4012 |
|
| 4013 |
|
| 4014 |
|
| 4015 |
|
| 4016 |
|
| 4017 |
|
| 4018 |
|
| 4019 |
|
| 4020 |
|
| 4021 |
|
| 4022 |
@UnsupportedAppUsage |
| 4023 |
public static final int STATUS_BAR_DISABLE_RECENT = 0x01000000; |
| 4024 |
|
| 4025 |
|
| 4026 |
|
| 4027 |
|
| 4028 |
|
| 4029 |
|
| 4030 |
|
| 4031 |
|
| 4032 |
|
| 4033 |
|
| 4034 |
public static final int STATUS_BAR_DISABLE_SEARCH = 0x02000000; |
| 4035 |
|
| 4036 |
|
| 4037 |
|
| 4038 |
|
| 4039 |
|
| 4040 |
|
| 4041 |
|
| 4042 |
|
| 4043 |
|
| 4044 |
public static final int STATUS_BAR_DISABLE_ONGOING_CALL_CHIP = 0x04000000; |
| 4045 |
|
| 4046 |
|
| 4047 |
|
| 4048 |
|
| 4049 |
public static final int PUBLIC_STATUS_BAR_VISIBILITY_MASK = 0x00003FF7; |
| 4050 |
|
| 4051 |
|
| 4052 |
|
| 4053 |
|
| 4054 |
|
| 4055 |
|
| 4056 |
|
| 4057 |
public static final int SYSTEM_UI_CLEARABLE_FLAGS = |
| 4058 |
SYSTEM_UI_FLAG_LOW_PROFILE | SYSTEM_UI_FLAG_HIDE_NAVIGATION |
| 4059 |
| SYSTEM_UI_FLAG_FULLSCREEN; |
| 4060 |
|
| 4061 |
|
| 4062 |
|
| 4063 |
|
| 4064 |
|
| 4065 |
|
| 4066 |
@Deprecated |
| 4067 |
public static final int SYSTEM_UI_LAYOUT_FLAGS = |
| 4068 |
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION |
| 4069 |
| SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN; |
| 4070 |
|
| 4071 |
|
| 4072 |
@IntDef(flag = true, prefix = { "FIND_VIEWS_" }, value = { |
| 4073 |
FIND_VIEWS_WITH_TEXT, |
| 4074 |
FIND_VIEWS_WITH_CONTENT_DESCRIPTION |
| 4075 |
}) |
| 4076 |
@Retention(RetentionPolicy.SOURCE) |
| 4077 |
public @interface FindViewFlags {} |
| 4078 |
|
| 4079 |
|
| 4080 |
|
| 4081 |
|
| 4082 |
|
| 4083 |
|
| 4084 |
public static final int FIND_VIEWS_WITH_TEXT = 0x00000001; |
| 4085 |
|
| 4086 |
|
| 4087 |
|
| 4088 |
|
| 4089 |
|
| 4090 |
|
| 4091 |
public static final int FIND_VIEWS_WITH_CONTENT_DESCRIPTION = 0x00000002; |
| 4092 |
|
| 4093 |
|
| 4094 |
|
| 4095 |
|
| 4096 |
|
| 4097 |
|
| 4098 |
|
| 4099 |
|
| 4100 |
|
| 4101 |
|
| 4102 |
|
| 4103 |
|
| 4104 |
|
| 4105 |
|
| 4106 |
public static final int FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS = 0x00000004; |
| 4107 |
|
| 4108 |
|
| 4109 |
|
| 4110 |
|
| 4111 |
|
| 4112 |
|
| 4113 |
public static final int ACCESSIBILITY_CURSOR_POSITION_UNDEFINED = -1; |
| 4114 |
|
| 4115 |
|
| 4116 |
|
| 4117 |
|
| 4118 |
|
| 4119 |
|
| 4120 |
public static final int SCREEN_STATE_OFF = 0x0; |
| 4121 |
|
| 4122 |
|
| 4123 |
|
| 4124 |
|
| 4125 |
|
| 4126 |
|
| 4127 |
public static final int SCREEN_STATE_ON = 0x1; |
| 4128 |
|
| 4129 |
|
| 4130 |
|
| 4131 |
|
| 4132 |
public static final int SCROLL_AXIS_NONE = 0; |
| 4133 |
|
| 4134 |
|
| 4135 |
|
| 4136 |
|
| 4137 |
public static final int SCROLL_AXIS_HORIZONTAL = 1 << 0; |
| 4138 |
|
| 4139 |
|
| 4140 |
|
| 4141 |
|
| 4142 |
public static final int SCROLL_AXIS_VERTICAL = 1 << 1; |
| 4143 |
|
| 4144 |
|
| 4145 |
|
| 4146 |
|
| 4147 |
|
| 4148 |
|
| 4149 |
|
| 4150 |
private int mOverScrollMode; |
| 4151 |
|
| 4152 |
|
| 4153 |
|
| 4154 |
|
| 4155 |
|
| 4156 |
|
| 4157 |
|
| 4158 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4159 |
protected ViewParent mParent; |
| 4160 |
|
| 4161 |
|
| 4162 |
|
| 4163 |
|
| 4164 |
|
| 4165 |
|
| 4166 |
|
| 4167 |
|
| 4168 |
|
| 4169 |
|
| 4170 |
|
| 4171 |
|
| 4172 |
|
| 4173 |
|
| 4174 |
|
| 4175 |
|
| 4176 |
|
| 4177 |
|
| 4178 |
|
| 4179 |
|
| 4180 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4181 |
AttachInfo mAttachInfo; |
| 4182 |
|
| 4183 |
|
| 4184 |
|
| 4185 |
|
| 4186 |
@ViewDebug.ExportedProperty(flagMapping = { |
| 4187 |
@ViewDebug.FlagToString(mask = PFLAG_FORCE_LAYOUT, equals = PFLAG_FORCE_LAYOUT, |
| 4188 |
name = "FORCE_LAYOUT"), |
| 4189 |
@ViewDebug.FlagToString(mask = PFLAG_LAYOUT_REQUIRED, equals = PFLAG_LAYOUT_REQUIRED, |
| 4190 |
name = "LAYOUT_REQUIRED"), |
| 4191 |
@ViewDebug.FlagToString(mask = PFLAG_DRAWING_CACHE_VALID, equals = PFLAG_DRAWING_CACHE_VALID, |
| 4192 |
name = "DRAWING_CACHE_INVALID", outputIf = false), |
| 4193 |
@ViewDebug.FlagToString(mask = PFLAG_DRAWN, equals = PFLAG_DRAWN, name = "DRAWN", outputIf = true), |
| 4194 |
@ViewDebug.FlagToString(mask = PFLAG_DRAWN, equals = PFLAG_DRAWN, name = "NOT_DRAWN", outputIf = false), |
| 4195 |
@ViewDebug.FlagToString(mask = PFLAG_DIRTY_MASK, equals = PFLAG_DIRTY, name = "DIRTY") |
| 4196 |
}, formatToHexString = true) |
| 4197 |
|
| 4198 |
|
| 4199 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123769414) |
| 4200 |
public int mPrivateFlags; |
| 4201 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768943) |
| 4202 |
int mPrivateFlags2; |
| 4203 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 129147060) |
| 4204 |
int mPrivateFlags3; |
| 4205 |
|
| 4206 |
private int mPrivateFlags4; |
| 4207 |
|
| 4208 |
|
| 4209 |
|
| 4210 |
|
| 4211 |
|
| 4212 |
@ViewDebug.ExportedProperty(flagMapping = { |
| 4213 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_LOW_PROFILE, |
| 4214 |
equals = SYSTEM_UI_FLAG_LOW_PROFILE, |
| 4215 |
name = "LOW_PROFILE"), |
| 4216 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_HIDE_NAVIGATION, |
| 4217 |
equals = SYSTEM_UI_FLAG_HIDE_NAVIGATION, |
| 4218 |
name = "HIDE_NAVIGATION"), |
| 4219 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_FULLSCREEN, |
| 4220 |
equals = SYSTEM_UI_FLAG_FULLSCREEN, |
| 4221 |
name = "FULLSCREEN"), |
| 4222 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_LAYOUT_STABLE, |
| 4223 |
equals = SYSTEM_UI_FLAG_LAYOUT_STABLE, |
| 4224 |
name = "LAYOUT_STABLE"), |
| 4225 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, |
| 4226 |
equals = SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, |
| 4227 |
name = "LAYOUT_HIDE_NAVIGATION"), |
| 4228 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, |
| 4229 |
equals = SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, |
| 4230 |
name = "LAYOUT_FULLSCREEN"), |
| 4231 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_IMMERSIVE, |
| 4232 |
equals = SYSTEM_UI_FLAG_IMMERSIVE, |
| 4233 |
name = "IMMERSIVE"), |
| 4234 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_IMMERSIVE_STICKY, |
| 4235 |
equals = SYSTEM_UI_FLAG_IMMERSIVE_STICKY, |
| 4236 |
name = "IMMERSIVE_STICKY"), |
| 4237 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, |
| 4238 |
equals = SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, |
| 4239 |
name = "LIGHT_STATUS_BAR"), |
| 4240 |
@ViewDebug.FlagToString(mask = SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, |
| 4241 |
equals = SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, |
| 4242 |
name = "LIGHT_NAVIGATION_BAR"), |
| 4243 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_EXPAND, |
| 4244 |
equals = STATUS_BAR_DISABLE_EXPAND, |
| 4245 |
name = "STATUS_BAR_DISABLE_EXPAND"), |
| 4246 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_NOTIFICATION_ICONS, |
| 4247 |
equals = STATUS_BAR_DISABLE_NOTIFICATION_ICONS, |
| 4248 |
name = "STATUS_BAR_DISABLE_NOTIFICATION_ICONS"), |
| 4249 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, |
| 4250 |
equals = STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, |
| 4251 |
name = "STATUS_BAR_DISABLE_NOTIFICATION_ALERTS"), |
| 4252 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_NOTIFICATION_TICKER, |
| 4253 |
equals = STATUS_BAR_DISABLE_NOTIFICATION_TICKER, |
| 4254 |
name = "STATUS_BAR_DISABLE_NOTIFICATION_TICKER"), |
| 4255 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_SYSTEM_INFO, |
| 4256 |
equals = STATUS_BAR_DISABLE_SYSTEM_INFO, |
| 4257 |
name = "STATUS_BAR_DISABLE_SYSTEM_INFO"), |
| 4258 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_HOME, |
| 4259 |
equals = STATUS_BAR_DISABLE_HOME, |
| 4260 |
name = "STATUS_BAR_DISABLE_HOME"), |
| 4261 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_BACK, |
| 4262 |
equals = STATUS_BAR_DISABLE_BACK, |
| 4263 |
name = "STATUS_BAR_DISABLE_BACK"), |
| 4264 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_CLOCK, |
| 4265 |
equals = STATUS_BAR_DISABLE_CLOCK, |
| 4266 |
name = "STATUS_BAR_DISABLE_CLOCK"), |
| 4267 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_RECENT, |
| 4268 |
equals = STATUS_BAR_DISABLE_RECENT, |
| 4269 |
name = "STATUS_BAR_DISABLE_RECENT"), |
| 4270 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_SEARCH, |
| 4271 |
equals = STATUS_BAR_DISABLE_SEARCH, |
| 4272 |
name = "STATUS_BAR_DISABLE_SEARCH"), |
| 4273 |
@ViewDebug.FlagToString(mask = STATUS_BAR_DISABLE_ONGOING_CALL_CHIP, |
| 4274 |
equals = STATUS_BAR_DISABLE_ONGOING_CALL_CHIP, |
| 4275 |
name = "STATUS_BAR_DISABLE_ONGOING_CALL_CHIP") |
| 4276 |
}, formatToHexString = true) |
| 4277 |
@SystemUiVisibility |
| 4278 |
int mSystemUiVisibility; |
| 4279 |
|
| 4280 |
|
| 4281 |
|
| 4282 |
|
| 4283 |
@IntDef(flag = true, prefix = "", value = { |
| 4284 |
SYSTEM_UI_FLAG_LOW_PROFILE, |
| 4285 |
SYSTEM_UI_FLAG_HIDE_NAVIGATION, |
| 4286 |
SYSTEM_UI_FLAG_FULLSCREEN, |
| 4287 |
SYSTEM_UI_FLAG_LAYOUT_STABLE, |
| 4288 |
SYSTEM_UI_FLAG_LAYOUT_HIDE_NAVIGATION, |
| 4289 |
SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN, |
| 4290 |
SYSTEM_UI_FLAG_IMMERSIVE, |
| 4291 |
SYSTEM_UI_FLAG_IMMERSIVE_STICKY, |
| 4292 |
SYSTEM_UI_FLAG_LIGHT_STATUS_BAR, |
| 4293 |
SYSTEM_UI_FLAG_LIGHT_NAVIGATION_BAR, |
| 4294 |
STATUS_BAR_DISABLE_EXPAND, |
| 4295 |
STATUS_BAR_DISABLE_NOTIFICATION_ICONS, |
| 4296 |
STATUS_BAR_DISABLE_NOTIFICATION_ALERTS, |
| 4297 |
STATUS_BAR_DISABLE_NOTIFICATION_TICKER, |
| 4298 |
STATUS_BAR_DISABLE_SYSTEM_INFO, |
| 4299 |
STATUS_BAR_DISABLE_HOME, |
| 4300 |
STATUS_BAR_DISABLE_BACK, |
| 4301 |
STATUS_BAR_DISABLE_CLOCK, |
| 4302 |
STATUS_BAR_DISABLE_RECENT, |
| 4303 |
STATUS_BAR_DISABLE_SEARCH, |
| 4304 |
STATUS_BAR_DISABLE_ONGOING_CALL_CHIP, |
| 4305 |
}) |
| 4306 |
@Retention(RetentionPolicy.SOURCE) |
| 4307 |
public @interface SystemUiVisibility {} |
| 4308 |
|
| 4309 |
|
| 4310 |
|
| 4311 |
|
| 4312 |
|
| 4313 |
int mTransientStateCount = 0; |
| 4314 |
|
| 4315 |
|
| 4316 |
|
| 4317 |
|
| 4318 |
int mWindowAttachCount; |
| 4319 |
|
| 4320 |
|
| 4321 |
|
| 4322 |
|
| 4323 |
|
| 4324 |
|
| 4325 |
|
| 4326 |
|
| 4327 |
|
| 4328 |
|
| 4329 |
|
| 4330 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4331 |
protected ViewGroup.LayoutParams mLayoutParams; |
| 4332 |
|
| 4333 |
|
| 4334 |
|
| 4335 |
|
| 4336 |
|
| 4337 |
|
| 4338 |
|
| 4339 |
|
| 4340 |
@ViewDebug.ExportedProperty(formatToHexString = true) |
| 4341 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4342 |
int mViewFlags; |
| 4343 |
|
| 4344 |
static class TransformationInfo { |
| 4345 |
|
| 4346 |
|
| 4347 |
|
| 4348 |
|
| 4349 |
|
| 4350 |
|
| 4351 |
|
| 4352 |
private final Matrix mMatrix = new Matrix(); |
| 4353 |
|
| 4354 |
|
| 4355 |
|
| 4356 |
|
| 4357 |
|
| 4358 |
|
| 4359 |
|
| 4360 |
|
| 4361 |
private Matrix mInverseMatrix; |
| 4362 |
|
| 4363 |
|
| 4364 |
|
| 4365 |
|
| 4366 |
|
| 4367 |
@ViewDebug.ExportedProperty |
| 4368 |
private float mAlpha = 1f; |
| 4369 |
|
| 4370 |
|
| 4371 |
|
| 4372 |
|
| 4373 |
|
| 4374 |
|
| 4375 |
float mTransitionAlpha = 1f; |
| 4376 |
} |
| 4377 |
|
| 4378 |
|
| 4379 |
@UnsupportedAppUsage |
| 4380 |
public TransformationInfo mTransformationInfo; |
| 4381 |
|
| 4382 |
|
| 4383 |
|
| 4384 |
|
| 4385 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 4386 |
Rect mClipBounds = null; |
| 4387 |
|
| 4388 |
private boolean mLastIsOpaque; |
| 4389 |
|
| 4390 |
|
| 4391 |
|
| 4392 |
|
| 4393 |
|
| 4394 |
|
| 4395 |
@ViewDebug.ExportedProperty(category = "layout") |
| 4396 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4397 |
protected int mLeft; |
| 4398 |
|
| 4399 |
|
| 4400 |
|
| 4401 |
|
| 4402 |
|
| 4403 |
@ViewDebug.ExportedProperty(category = "layout") |
| 4404 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4405 |
protected int mRight; |
| 4406 |
|
| 4407 |
|
| 4408 |
|
| 4409 |
|
| 4410 |
|
| 4411 |
@ViewDebug.ExportedProperty(category = "layout") |
| 4412 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4413 |
protected int mTop; |
| 4414 |
|
| 4415 |
|
| 4416 |
|
| 4417 |
|
| 4418 |
|
| 4419 |
@ViewDebug.ExportedProperty(category = "layout") |
| 4420 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4421 |
protected int mBottom; |
| 4422 |
|
| 4423 |
|
| 4424 |
|
| 4425 |
|
| 4426 |
|
| 4427 |
|
| 4428 |
|
| 4429 |
|
| 4430 |
@ViewDebug.ExportedProperty(category = "scrolling") |
| 4431 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4432 |
protected int mScrollX; |
| 4433 |
|
| 4434 |
|
| 4435 |
|
| 4436 |
|
| 4437 |
|
| 4438 |
|
| 4439 |
|
| 4440 |
@ViewDebug.ExportedProperty(category = "scrolling") |
| 4441 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4442 |
protected int mScrollY; |
| 4443 |
|
| 4444 |
|
| 4445 |
|
| 4446 |
|
| 4447 |
|
| 4448 |
|
| 4449 |
@ViewDebug.ExportedProperty(category = "padding") |
| 4450 |
@UnsupportedAppUsage |
| 4451 |
protected int mPaddingLeft = 0; |
| 4452 |
|
| 4453 |
|
| 4454 |
|
| 4455 |
|
| 4456 |
|
| 4457 |
@ViewDebug.ExportedProperty(category = "padding") |
| 4458 |
@UnsupportedAppUsage |
| 4459 |
protected int mPaddingRight = 0; |
| 4460 |
|
| 4461 |
|
| 4462 |
|
| 4463 |
|
| 4464 |
|
| 4465 |
@ViewDebug.ExportedProperty(category = "padding") |
| 4466 |
@UnsupportedAppUsage |
| 4467 |
protected int mPaddingTop; |
| 4468 |
|
| 4469 |
|
| 4470 |
|
| 4471 |
|
| 4472 |
|
| 4473 |
@ViewDebug.ExportedProperty(category = "padding") |
| 4474 |
@UnsupportedAppUsage |
| 4475 |
protected int mPaddingBottom; |
| 4476 |
|
| 4477 |
|
| 4478 |
|
| 4479 |
|
| 4480 |
|
| 4481 |
private Insets mLayoutInsets; |
| 4482 |
|
| 4483 |
|
| 4484 |
|
| 4485 |
|
| 4486 |
private CharSequence mStateDescription; |
| 4487 |
|
| 4488 |
|
| 4489 |
|
| 4490 |
|
| 4491 |
private CharSequence mContentDescription; |
| 4492 |
|
| 4493 |
|
| 4494 |
|
| 4495 |
|
| 4496 |
|
| 4497 |
private CharSequence mAccessibilityPaneTitle; |
| 4498 |
|
| 4499 |
|
| 4500 |
|
| 4501 |
|
| 4502 |
|
| 4503 |
private int mLabelForId = View.NO_ID; |
| 4504 |
|
| 4505 |
|
| 4506 |
|
| 4507 |
|
| 4508 |
|
| 4509 |
private MatchLabelForPredicate mMatchLabelForPredicate; |
| 4510 |
|
| 4511 |
|
| 4512 |
|
| 4513 |
|
| 4514 |
private int mAccessibilityTraversalBeforeId = NO_ID; |
| 4515 |
|
| 4516 |
|
| 4517 |
|
| 4518 |
|
| 4519 |
private int mAccessibilityTraversalAfterId = NO_ID; |
| 4520 |
|
| 4521 |
|
| 4522 |
|
| 4523 |
|
| 4524 |
private MatchIdPredicate mMatchIdPredicate; |
| 4525 |
|
| 4526 |
|
| 4527 |
|
| 4528 |
|
| 4529 |
|
| 4530 |
|
| 4531 |
@ViewDebug.ExportedProperty(category = "padding") |
| 4532 |
protected int mUserPaddingRight; |
| 4533 |
|
| 4534 |
|
| 4535 |
|
| 4536 |
|
| 4537 |
|
| 4538 |
|
| 4539 |
@ViewDebug.ExportedProperty(category = "padding") |
| 4540 |
protected int mUserPaddingBottom; |
| 4541 |
|
| 4542 |
|
| 4543 |
|
| 4544 |
|
| 4545 |
|
| 4546 |
|
| 4547 |
@ViewDebug.ExportedProperty(category = "padding") |
| 4548 |
protected int mUserPaddingLeft; |
| 4549 |
|
| 4550 |
|
| 4551 |
|
| 4552 |
|
| 4553 |
|
| 4554 |
@ViewDebug.ExportedProperty(category = "padding") |
| 4555 |
int mUserPaddingStart; |
| 4556 |
|
| 4557 |
|
| 4558 |
|
| 4559 |
|
| 4560 |
|
| 4561 |
@ViewDebug.ExportedProperty(category = "padding") |
| 4562 |
int mUserPaddingEnd; |
| 4563 |
|
| 4564 |
|
| 4565 |
|
| 4566 |
|
| 4567 |
|
| 4568 |
|
| 4569 |
|
| 4570 |
int mUserPaddingLeftInitial; |
| 4571 |
|
| 4572 |
|
| 4573 |
|
| 4574 |
|
| 4575 |
|
| 4576 |
|
| 4577 |
|
| 4578 |
int mUserPaddingRightInitial; |
| 4579 |
|
| 4580 |
|
| 4581 |
|
| 4582 |
|
| 4583 |
private static final int UNDEFINED_PADDING = Integer.MIN_VALUE; |
| 4584 |
|
| 4585 |
|
| 4586 |
|
| 4587 |
|
| 4588 |
|
| 4589 |
private boolean mLeftPaddingDefined = false; |
| 4590 |
|
| 4591 |
|
| 4592 |
|
| 4593 |
|
| 4594 |
|
| 4595 |
private boolean mRightPaddingDefined = false; |
| 4596 |
|
| 4597 |
|
| 4598 |
|
| 4599 |
|
| 4600 |
int mOldWidthMeasureSpec = Integer.MIN_VALUE; |
| 4601 |
|
| 4602 |
|
| 4603 |
|
| 4604 |
int mOldHeightMeasureSpec = Integer.MIN_VALUE; |
| 4605 |
|
| 4606 |
private LongSparseLongArray mMeasureCache; |
| 4607 |
|
| 4608 |
@ViewDebug.ExportedProperty(deepExport = true, prefix = "bg_") |
| 4609 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 4610 |
private Drawable mBackground; |
| 4611 |
private TintInfo mBackgroundTint; |
| 4612 |
|
| 4613 |
@ViewDebug.ExportedProperty(deepExport = true, prefix = "fg_") |
| 4614 |
private ForegroundInfo mForegroundInfo; |
| 4615 |
|
| 4616 |
private Drawable mScrollIndicatorDrawable; |
| 4617 |
|
| 4618 |
|
| 4619 |
|
| 4620 |
|
| 4621 |
|
| 4622 |
|
| 4623 |
|
| 4624 |
|
| 4625 |
|
| 4626 |
RenderNode mBackgroundRenderNode; |
| 4627 |
|
| 4628 |
@UnsupportedAppUsage |
| 4629 |
private int mBackgroundResource; |
| 4630 |
private boolean mBackgroundSizeChanged; |
| 4631 |
|
| 4632 |
|
| 4633 |
|
| 4634 |
|
| 4635 |
|
| 4636 |
private Drawable mDefaultFocusHighlight; |
| 4637 |
private Drawable mDefaultFocusHighlightCache; |
| 4638 |
private boolean mDefaultFocusHighlightSizeChanged; |
| 4639 |
|
| 4640 |
|
| 4641 |
|
| 4642 |
private static boolean sUseDefaultFocusHighlight; |
| 4643 |
|
| 4644 |
|
| 4645 |
|
| 4646 |
|
| 4647 |
private static boolean sCanFocusZeroSized; |
| 4648 |
|
| 4649 |
|
| 4650 |
|
| 4651 |
|
| 4652 |
private static boolean sAlwaysAssignFocus; |
| 4653 |
|
| 4654 |
private String mTransitionName; |
| 4655 |
|
| 4656 |
static class TintInfo { |
| 4657 |
ColorStateList mTintList; |
| 4658 |
BlendMode mBlendMode; |
| 4659 |
boolean mHasTintMode; |
| 4660 |
boolean mHasTintList; |
| 4661 |
} |
| 4662 |
|
| 4663 |
private static class ForegroundInfo { |
| 4664 |
private Drawable mDrawable; |
| 4665 |
private TintInfo mTintInfo; |
| 4666 |
private int mGravity = Gravity.FILL; |
| 4667 |
private boolean mInsidePadding = true; |
| 4668 |
private boolean mBoundsChanged = true; |
| 4669 |
private final Rect mSelfBounds = new Rect(); |
| 4670 |
private final Rect mOverlayBounds = new Rect(); |
| 4671 |
} |
| 4672 |
|
| 4673 |
static class ListenerInfo { |
| 4674 |
|
| 4675 |
@UnsupportedAppUsage |
| 4676 |
ListenerInfo() { |
| 4677 |
} |
| 4678 |
|
| 4679 |
|
| 4680 |
|
| 4681 |
|
| 4682 |
|
| 4683 |
|
| 4684 |
@UnsupportedAppUsage |
| 4685 |
protected OnFocusChangeListener mOnFocusChangeListener; |
| 4686 |
|
| 4687 |
|
| 4688 |
|
| 4689 |
|
| 4690 |
private ArrayList<OnLayoutChangeListener> mOnLayoutChangeListeners; |
| 4691 |
|
| 4692 |
protected OnScrollChangeListener mOnScrollChangeListener; |
| 4693 |
|
| 4694 |
|
| 4695 |
|
| 4696 |
|
| 4697 |
private CopyOnWriteArrayList<OnAttachStateChangeListener> mOnAttachStateChangeListeners; |
| 4698 |
|
| 4699 |
|
| 4700 |
|
| 4701 |
|
| 4702 |
|
| 4703 |
|
| 4704 |
@UnsupportedAppUsage |
| 4705 |
public OnClickListener mOnClickListener; |
| 4706 |
|
| 4707 |
|
| 4708 |
|
| 4709 |
|
| 4710 |
|
| 4711 |
|
| 4712 |
@UnsupportedAppUsage |
| 4713 |
protected OnLongClickListener mOnLongClickListener; |
| 4714 |
|
| 4715 |
|
| 4716 |
|
| 4717 |
|
| 4718 |
|
| 4719 |
|
| 4720 |
protected OnContextClickListener mOnContextClickListener; |
| 4721 |
|
| 4722 |
|
| 4723 |
|
| 4724 |
|
| 4725 |
|
| 4726 |
|
| 4727 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 4728 |
protected OnCreateContextMenuListener mOnCreateContextMenuListener; |
| 4729 |
|
| 4730 |
@UnsupportedAppUsage |
| 4731 |
private OnKeyListener mOnKeyListener; |
| 4732 |
|
| 4733 |
@UnsupportedAppUsage |
| 4734 |
private OnTouchListener mOnTouchListener; |
| 4735 |
|
| 4736 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 4737 |
private OnHoverListener mOnHoverListener; |
| 4738 |
|
| 4739 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 4740 |
private OnGenericMotionListener mOnGenericMotionListener; |
| 4741 |
|
| 4742 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 4743 |
private OnDragListener mOnDragListener; |
| 4744 |
|
| 4745 |
private OnSystemUiVisibilityChangeListener mOnSystemUiVisibilityChangeListener; |
| 4746 |
|
| 4747 |
OnApplyWindowInsetsListener mOnApplyWindowInsetsListener; |
| 4748 |
|
| 4749 |
OnCapturedPointerListener mOnCapturedPointerListener; |
| 4750 |
|
| 4751 |
private ArrayList<OnUnhandledKeyEventListener> mUnhandledKeyListeners; |
| 4752 |
|
| 4753 |
WindowInsetsAnimation.Callback mWindowInsetsAnimationCallback; |
| 4754 |
|
| 4755 |
|
| 4756 |
|
| 4757 |
|
| 4758 |
|
| 4759 |
private List<Rect> mSystemGestureExclusionRects = null; |
| 4760 |
private List<Rect> mKeepClearRects = null; |
| 4761 |
private List<Rect> mUnrestrictedKeepClearRects = null; |
| 4762 |
private boolean mPreferKeepClear = false; |
| 4763 |
private Rect mHandwritingArea = null; |
| 4764 |
|
| 4765 |
|
| 4766 |
|
| 4767 |
|
| 4768 |
|
| 4769 |
public RenderNode.PositionUpdateListener mPositionUpdateListener; |
| 4770 |
private Runnable mPositionChangedUpdate; |
| 4771 |
|
| 4772 |
|
| 4773 |
|
| 4774 |
|
| 4775 |
ScrollCaptureCallback mScrollCaptureCallback; |
| 4776 |
|
| 4777 |
@Nullable |
| 4778 |
private OnReceiveContentListener mOnReceiveContentListener; |
| 4779 |
} |
| 4780 |
|
| 4781 |
@UnsupportedAppUsage |
| 4782 |
ListenerInfo mListenerInfo; |
| 4783 |
|
| 4784 |
private static class TooltipInfo { |
| 4785 |
|
| 4786 |
|
| 4787 |
|
| 4788 |
@Nullable |
| 4789 |
CharSequence mTooltipText; |
| 4790 |
|
| 4791 |
|
| 4792 |
|
| 4793 |
|
| 4794 |
int mAnchorX; |
| 4795 |
int mAnchorY; |
| 4796 |
|
| 4797 |
|
| 4798 |
|
| 4799 |
|
| 4800 |
@Nullable |
| 4801 |
TooltipPopup mTooltipPopup; |
| 4802 |
|
| 4803 |
|
| 4804 |
|
| 4805 |
|
| 4806 |
boolean mTooltipFromLongClick; |
| 4807 |
|
| 4808 |
|
| 4809 |
|
| 4810 |
|
| 4811 |
Runnable mShowTooltipRunnable; |
| 4812 |
Runnable mHideTooltipRunnable; |
| 4813 |
|
| 4814 |
|
| 4815 |
|
| 4816 |
|
| 4817 |
int mHoverSlop; |
| 4818 |
|
| 4819 |
|
| 4820 |
|
| 4821 |
|
| 4822 |
|
| 4823 |
|
| 4824 |
|
| 4825 |
|
| 4826 |
private boolean updateAnchorPos(MotionEvent event) { |
| 4827 |
final int newAnchorX = (int) event.getX(); |
| 4828 |
final int newAnchorY = (int) event.getY(); |
| 4829 |
if (Math.abs(newAnchorX - mAnchorX) <= mHoverSlop |
| 4830 |
&& Math.abs(newAnchorY - mAnchorY) <= mHoverSlop) { |
| 4831 |
return false; |
| 4832 |
} |
| 4833 |
mAnchorX = newAnchorX; |
| 4834 |
mAnchorY = newAnchorY; |
| 4835 |
return true; |
| 4836 |
} |
| 4837 |
|
| 4838 |
|
| 4839 |
|
| 4840 |
|
| 4841 |
private void clearAnchorPos() { |
| 4842 |
mAnchorX = Integer.MAX_VALUE; |
| 4843 |
mAnchorY = Integer.MAX_VALUE; |
| 4844 |
} |
| 4845 |
} |
| 4846 |
|
| 4847 |
TooltipInfo mTooltipInfo; |
| 4848 |
|
| 4849 |
|
| 4850 |
|
| 4851 |
private float mLongClickX = Float.NaN; |
| 4852 |
private float mLongClickY = Float.NaN; |
| 4853 |
|
| 4854 |
|
| 4855 |
|
| 4856 |
|
| 4857 |
|
| 4858 |
|
| 4859 |
@ViewDebug.ExportedProperty(deepExport = true) |
| 4860 |
@UnsupportedAppUsage |
| 4861 |
@UiContext |
| 4862 |
protected Context mContext; |
| 4863 |
|
| 4864 |
@UnsupportedAppUsage |
| 4865 |
private final Resources mResources; |
| 4866 |
|
| 4867 |
@UnsupportedAppUsage |
| 4868 |
private ScrollabilityCache mScrollCache; |
| 4869 |
|
| 4870 |
private int[] mDrawableState = null; |
| 4871 |
|
| 4872 |
ViewOutlineProvider mOutlineProvider = ViewOutlineProvider.BACKGROUND; |
| 4873 |
|
| 4874 |
|
| 4875 |
|
| 4876 |
|
| 4877 |
private StateListAnimator mStateListAnimator; |
| 4878 |
|
| 4879 |
|
| 4880 |
|
| 4881 |
|
| 4882 |
|
| 4883 |
private int mNextFocusLeftId = View.NO_ID; |
| 4884 |
|
| 4885 |
|
| 4886 |
|
| 4887 |
|
| 4888 |
|
| 4889 |
private int mNextFocusRightId = View.NO_ID; |
| 4890 |
|
| 4891 |
|
| 4892 |
|
| 4893 |
|
| 4894 |
|
| 4895 |
private int mNextFocusUpId = View.NO_ID; |
| 4896 |
|
| 4897 |
|
| 4898 |
|
| 4899 |
|
| 4900 |
|
| 4901 |
private int mNextFocusDownId = View.NO_ID; |
| 4902 |
|
| 4903 |
|
| 4904 |
|
| 4905 |
|
| 4906 |
|
| 4907 |
int mNextFocusForwardId = View.NO_ID; |
| 4908 |
|
| 4909 |
|
| 4910 |
|
| 4911 |
|
| 4912 |
|
| 4913 |
|
| 4914 |
int mNextClusterForwardId = View.NO_ID; |
| 4915 |
|
| 4916 |
|
| 4917 |
|
| 4918 |
|
| 4919 |
|
| 4920 |
boolean mDefaultFocusHighlightEnabled = true; |
| 4921 |
|
| 4922 |
private CheckForLongPress mPendingCheckForLongPress; |
| 4923 |
@UnsupportedAppUsage |
| 4924 |
private CheckForTap mPendingCheckForTap = null; |
| 4925 |
private PerformClick mPerformClick; |
| 4926 |
private SendViewScrolledAccessibilityEvent mSendViewScrolledAccessibilityEvent; |
| 4927 |
private SendAccessibilityEventThrottle mSendStateChangedAccessibilityEvent; |
| 4928 |
private UnsetPressedState mUnsetPressedState; |
| 4929 |
|
| 4930 |
|
| 4931 |
|
| 4932 |
|
| 4933 |
|
| 4934 |
|
| 4935 |
|
| 4936 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
| 4937 |
private boolean mHasPerformedLongPress; |
| 4938 |
|
| 4939 |
|
| 4940 |
|
| 4941 |
|
| 4942 |
|
| 4943 |
|
| 4944 |
private boolean mInContextButtonPress; |
| 4945 |
|
| 4946 |
|
| 4947 |
|
| 4948 |
|
| 4949 |
|
| 4950 |
|
| 4951 |
private boolean mIgnoreNextUpEvent; |
| 4952 |
|
| 4953 |
|
| 4954 |
|
| 4955 |
|
| 4956 |
|
| 4957 |
@ViewDebug.ExportedProperty(category = "measurement") |
| 4958 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4959 |
private int mMinHeight; |
| 4960 |
|
| 4961 |
|
| 4962 |
|
| 4963 |
|
| 4964 |
|
| 4965 |
@ViewDebug.ExportedProperty(category = "measurement") |
| 4966 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 4967 |
private int mMinWidth; |
| 4968 |
|
| 4969 |
|
| 4970 |
|
| 4971 |
|
| 4972 |
|
| 4973 |
private TouchDelegate mTouchDelegate = null; |
| 4974 |
|
| 4975 |
|
| 4976 |
|
| 4977 |
|
| 4978 |
|
| 4979 |
|
| 4980 |
|
| 4981 |
|
| 4982 |
|
| 4983 |
private boolean mHoveringTouchDelegate = false; |
| 4984 |
|
| 4985 |
|
| 4986 |
|
| 4987 |
|
| 4988 |
|
| 4989 |
private int mDrawingCacheBackgroundColor = 0; |
| 4990 |
|
| 4991 |
|
| 4992 |
|
| 4993 |
|
| 4994 |
private ViewTreeObserver mFloatingTreeObserver; |
| 4995 |
|
| 4996 |
|
| 4997 |
|
| 4998 |
|
| 4999 |
private int mTouchSlop; |
| 5000 |
|
| 5001 |
|
| 5002 |
|
| 5003 |
|
| 5004 |
private float mAmbiguousGestureMultiplier; |
| 5005 |
|
| 5006 |
|
| 5007 |
|
| 5008 |
|
| 5009 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
| 5010 |
private ViewPropertyAnimator mAnimator = null; |
| 5011 |
|
| 5012 |
|
| 5013 |
|
| 5014 |
|
| 5015 |
private ArrayList<FrameMetricsObserver> mFrameMetricsObservers; |
| 5016 |
|
| 5017 |
|
| 5018 |
|
| 5019 |
|
| 5020 |
|
| 5021 |
|
| 5022 |
|
| 5023 |
|
| 5024 |
|
| 5025 |
|
| 5026 |
|
| 5027 |
|
| 5028 |
public static final int DRAG_FLAG_GLOBAL = 1 << 8; |
| 5029 |
|
| 5030 |
|
| 5031 |
|
| 5032 |
|
| 5033 |
|
| 5034 |
|
| 5035 |
public static final int DRAG_FLAG_GLOBAL_URI_READ = Intent.FLAG_GRANT_READ_URI_PERMISSION; |
| 5036 |
|
| 5037 |
|
| 5038 |
|
| 5039 |
|
| 5040 |
|
| 5041 |
|
| 5042 |
public static final int DRAG_FLAG_GLOBAL_URI_WRITE = Intent.FLAG_GRANT_WRITE_URI_PERMISSION; |
| 5043 |
|
| 5044 |
|
| 5045 |
|
| 5046 |
|
| 5047 |
|
| 5048 |
|
| 5049 |
|
| 5050 |
|
| 5051 |
public static final int DRAG_FLAG_GLOBAL_PERSISTABLE_URI_PERMISSION = |
| 5052 |
Intent.FLAG_GRANT_PERSISTABLE_URI_PERMISSION; |
| 5053 |
|
| 5054 |
|
| 5055 |
|
| 5056 |
|
| 5057 |
|
| 5058 |
|
| 5059 |
|
| 5060 |
public static final int DRAG_FLAG_GLOBAL_PREFIX_URI_PERMISSION = |
| 5061 |
Intent.FLAG_GRANT_PREFIX_URI_PERMISSION; |
| 5062 |
|
| 5063 |
|
| 5064 |
|
| 5065 |
|
| 5066 |
|
| 5067 |
|
| 5068 |
public static final int DRAG_FLAG_OPAQUE = 1 << 9; |
| 5069 |
|
| 5070 |
|
| 5071 |
|
| 5072 |
|
| 5073 |
|
| 5074 |
|
| 5075 |
|
| 5076 |
public static final int DRAG_FLAG_ACCESSIBILITY_ACTION = 1 << 10; |
| 5077 |
|
| 5078 |
|
| 5079 |
|
| 5080 |
|
| 5081 |
|
| 5082 |
|
| 5083 |
|
| 5084 |
|
| 5085 |
|
| 5086 |
|
| 5087 |
|
| 5088 |
|
| 5089 |
|
| 5090 |
|
| 5091 |
|
| 5092 |
|
| 5093 |
|
| 5094 |
public static final int DRAG_FLAG_REQUEST_SURFACE_FOR_RETURN_ANIMATION = 1 << 11; |
| 5095 |
|
| 5096 |
|
| 5097 |
|
| 5098 |
|
| 5099 |
private float mVerticalScrollFactor; |
| 5100 |
|
| 5101 |
|
| 5102 |
|
| 5103 |
|
| 5104 |
@UnsupportedAppUsage |
| 5105 |
private int mVerticalScrollbarPosition; |
| 5106 |
|
| 5107 |
|
| 5108 |
|
| 5109 |
|
| 5110 |
public static final int SCROLLBAR_POSITION_DEFAULT = 0; |
| 5111 |
|
| 5112 |
|
| 5113 |
|
| 5114 |
|
| 5115 |
public static final int SCROLLBAR_POSITION_LEFT = 1; |
| 5116 |
|
| 5117 |
|
| 5118 |
|
| 5119 |
|
| 5120 |
public static final int SCROLLBAR_POSITION_RIGHT = 2; |
| 5121 |
|
| 5122 |
|
| 5123 |
|
| 5124 |
|
| 5125 |
|
| 5126 |
|
| 5127 |
|
| 5128 |
|
| 5129 |
|
| 5130 |
public static final int LAYER_TYPE_NONE = 0; |
| 5131 |
|
| 5132 |
|
| 5133 |
|
| 5134 |
|
| 5135 |
|
| 5136 |
|
| 5137 |
|
| 5138 |
|
| 5139 |
|
| 5140 |
|
| 5141 |
|
| 5142 |
|
| 5143 |
|
| 5144 |
|
| 5145 |
|
| 5146 |
|
| 5147 |
|
| 5148 |
|
| 5149 |
|
| 5150 |
|
| 5151 |
|
| 5152 |
|
| 5153 |
|
| 5154 |
|
| 5155 |
|
| 5156 |
|
| 5157 |
|
| 5158 |
public static final int LAYER_TYPE_SOFTWARE = 1; |
| 5159 |
|
| 5160 |
|
| 5161 |
|
| 5162 |
|
| 5163 |
|
| 5164 |
|
| 5165 |
|
| 5166 |
|
| 5167 |
|
| 5168 |
|
| 5169 |
|
| 5170 |
|
| 5171 |
|
| 5172 |
|
| 5173 |
|
| 5174 |
|
| 5175 |
|
| 5176 |
|
| 5177 |
|
| 5178 |
|
| 5179 |
|
| 5180 |
|
| 5181 |
|
| 5182 |
|
| 5183 |
public static final int LAYER_TYPE_HARDWARE = 2; |
| 5184 |
|
| 5185 |
|
| 5186 |
@IntDef(prefix = { "LAYER_TYPE_" }, value = { |
| 5187 |
LAYER_TYPE_NONE, |
| 5188 |
LAYER_TYPE_SOFTWARE, |
| 5189 |
LAYER_TYPE_HARDWARE |
| 5190 |
}) |
| 5191 |
@Retention(RetentionPolicy.SOURCE) |
| 5192 |
public @interface LayerType {} |
| 5193 |
|
| 5194 |
@ViewDebug.ExportedProperty(category = "drawing", mapping = { |
| 5195 |
@ViewDebug.IntToString(from = LAYER_TYPE_NONE, to = "NONE"), |
| 5196 |
@ViewDebug.IntToString(from = LAYER_TYPE_SOFTWARE, to = "SOFTWARE"), |
| 5197 |
@ViewDebug.IntToString(from = LAYER_TYPE_HARDWARE, to = "HARDWARE") |
| 5198 |
}) |
| 5199 |
int mLayerType = LAYER_TYPE_NONE; |
| 5200 |
Paint mLayerPaint; |
| 5201 |
|
| 5202 |
|
| 5203 |
|
| 5204 |
|
| 5205 |
|
| 5206 |
|
| 5207 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 5208 |
public boolean mCachingFailed; |
| 5209 |
@UnsupportedAppUsage |
| 5210 |
private Bitmap mDrawingCache; |
| 5211 |
@UnsupportedAppUsage |
| 5212 |
private Bitmap mUnscaledDrawingCache; |
| 5213 |
|
| 5214 |
|
| 5215 |
|
| 5216 |
|
| 5217 |
|
| 5218 |
|
| 5219 |
|
| 5220 |
|
| 5221 |
@UnsupportedAppUsage |
| 5222 |
final RenderNode mRenderNode; |
| 5223 |
|
| 5224 |
|
| 5225 |
|
| 5226 |
|
| 5227 |
|
| 5228 |
private boolean mSendingHoverAccessibilityEvents; |
| 5229 |
|
| 5230 |
|
| 5231 |
|
| 5232 |
|
| 5233 |
@UnsupportedAppUsage |
| 5234 |
AccessibilityDelegate mAccessibilityDelegate; |
| 5235 |
|
| 5236 |
|
| 5237 |
|
| 5238 |
|
| 5239 |
|
| 5240 |
ViewOverlay mOverlay; |
| 5241 |
|
| 5242 |
|
| 5243 |
|
| 5244 |
|
| 5245 |
|
| 5246 |
|
| 5247 |
|
| 5248 |
private ViewParent mNestedScrollingParent; |
| 5249 |
|
| 5250 |
|
| 5251 |
|
| 5252 |
|
| 5253 |
|
| 5254 |
protected final InputEventConsistencyVerifier mInputEventConsistencyVerifier = |
| 5255 |
InputEventConsistencyVerifier.isInstrumentationEnabled() ? |
| 5256 |
new InputEventConsistencyVerifier(this, 0) : null; |
| 5257 |
|
| 5258 |
private static final AtomicInteger sNextGeneratedId = new AtomicInteger(1); |
| 5259 |
|
| 5260 |
private int[] mTempNestedScrollConsumed; |
| 5261 |
|
| 5262 |
|
| 5263 |
|
| 5264 |
|
| 5265 |
|
| 5266 |
|
| 5267 |
GhostView mGhostView; |
| 5268 |
|
| 5269 |
|
| 5270 |
|
| 5271 |
|
| 5272 |
|
| 5273 |
@ViewDebug.ExportedProperty(category = "attributes", hasAdjacentMapping = true) |
| 5274 |
public String[] mAttributes; |
| 5275 |
|
| 5276 |
|
| 5277 |
|
| 5278 |
|
| 5279 |
private static SparseArray<String> mAttributeMap; |
| 5280 |
|
| 5281 |
|
| 5282 |
|
| 5283 |
|
| 5284 |
|
| 5285 |
private HandlerActionQueue mRunQueue; |
| 5286 |
|
| 5287 |
|
| 5288 |
|
| 5289 |
|
| 5290 |
private PointerIcon mPointerIcon; |
| 5291 |
|
| 5292 |
|
| 5293 |
|
| 5294 |
|
| 5295 |
@UnsupportedAppUsage |
| 5296 |
String mStartActivityRequestWho; |
| 5297 |
|
| 5298 |
@Nullable |
| 5299 |
private RoundScrollbarRenderer mRoundScrollbarRenderer; |
| 5300 |
|
| 5301 |
|
| 5302 |
private Handler mVisibilityChangeForAutofillHandler; |
| 5303 |
|
| 5304 |
|
| 5305 |
|
| 5306 |
|
| 5307 |
|
| 5308 |
@Nullable |
| 5309 |
private ContentCaptureSession mContentCaptureSession; |
| 5310 |
|
| 5311 |
|
| 5312 |
|
| 5313 |
|
| 5314 |
private boolean mContentCaptureSessionCached; |
| 5315 |
|
| 5316 |
@LayoutRes |
| 5317 |
private int mSourceLayoutId = ID_NULL; |
| 5318 |
|
| 5319 |
@Nullable |
| 5320 |
private SparseIntArray mAttributeSourceResId; |
| 5321 |
|
| 5322 |
@Nullable |
| 5323 |
private SparseArray<int[]> mAttributeResolutionStacks; |
| 5324 |
|
| 5325 |
@StyleRes |
| 5326 |
private int mExplicitStyle; |
| 5327 |
|
| 5328 |
|
| 5329 |
|
| 5330 |
|
| 5331 |
|
| 5332 |
|
| 5333 |
@InputSourceClass |
| 5334 |
int mUnbufferedInputSource = InputDevice.SOURCE_CLASS_NONE; |
| 5335 |
|
| 5336 |
@Nullable |
| 5337 |
private String[] mReceiveContentMimeTypes; |
| 5338 |
|
| 5339 |
@Nullable |
| 5340 |
private ViewTranslationCallback mViewTranslationCallback; |
| 5341 |
|
| 5342 |
@Nullable |
| 5343 |
|
| 5344 |
private ViewTranslationResponse mViewTranslationResponse; |
| 5345 |
|
| 5346 |
|
| 5347 |
|
| 5348 |
|
| 5349 |
|
| 5350 |
|
| 5351 |
|
| 5352 |
public View(Context context) { |
| 5353 |
mContext = context; |
| 5354 |
mResources = context != null ? context.getResources() : null; |
| 5355 |
mViewFlags = SOUND_EFFECTS_ENABLED | HAPTIC_FEEDBACK_ENABLED | FOCUSABLE_AUTO; |
| 5356 |
|
| 5357 |
mPrivateFlags2 = |
| 5358 |
(LAYOUT_DIRECTION_DEFAULT << PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) | |
| 5359 |
(TEXT_DIRECTION_DEFAULT << PFLAG2_TEXT_DIRECTION_MASK_SHIFT) | |
| 5360 |
(PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT) | |
| 5361 |
(TEXT_ALIGNMENT_DEFAULT << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT) | |
| 5362 |
(PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT) | |
| 5363 |
(IMPORTANT_FOR_ACCESSIBILITY_DEFAULT << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT); |
| 5364 |
mPrivateFlags4 = PFLAG4_AUTO_HANDWRITING_ENABLED; |
| 5365 |
|
| 5366 |
final ViewConfiguration configuration = ViewConfiguration.get(context); |
| 5367 |
mTouchSlop = configuration.getScaledTouchSlop(); |
| 5368 |
mAmbiguousGestureMultiplier = configuration.getScaledAmbiguousGestureMultiplier(); |
| 5369 |
|
| 5370 |
setOverScrollMode(OVER_SCROLL_IF_CONTENT_SCROLLS); |
| 5371 |
mUserPaddingStart = UNDEFINED_PADDING; |
| 5372 |
mUserPaddingEnd = UNDEFINED_PADDING; |
| 5373 |
mRenderNode = RenderNode.create(getClass().getName(), new ViewAnimationHostBridge(this)); |
| 5374 |
|
| 5375 |
if (!sCompatibilityDone && context != null) { |
| 5376 |
final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion; |
| 5377 |
|
| 5378 |
|
| 5379 |
sUseBrokenMakeMeasureSpec = targetSdkVersion <= Build.VERSION_CODES.JELLY_BEAN_MR1; |
| 5380 |
|
| 5381 |
|
| 5382 |
|
| 5383 |
sIgnoreMeasureCache = targetSdkVersion < Build.VERSION_CODES.KITKAT; |
| 5384 |
|
| 5385 |
|
| 5386 |
|
| 5387 |
|
| 5388 |
|
| 5389 |
|
| 5390 |
sUseZeroUnspecifiedMeasureSpec = targetSdkVersion < Build.VERSION_CODES.M; |
| 5391 |
|
| 5392 |
|
| 5393 |
|
| 5394 |
|
| 5395 |
sAlwaysRemeasureExactly = targetSdkVersion <= Build.VERSION_CODES.M; |
| 5396 |
|
| 5397 |
|
| 5398 |
|
| 5399 |
sTextureViewIgnoresDrawableSetters = targetSdkVersion <= Build.VERSION_CODES.M; |
| 5400 |
|
| 5401 |
|
| 5402 |
|
| 5403 |
sPreserveMarginParamsInLayoutParamConversion = |
| 5404 |
targetSdkVersion >= Build.VERSION_CODES.N; |
| 5405 |
|
| 5406 |
sCascadedDragDrop = targetSdkVersion < Build.VERSION_CODES.N; |
| 5407 |
|
| 5408 |
sHasFocusableExcludeAutoFocusable = targetSdkVersion < Build.VERSION_CODES.O; |
| 5409 |
|
| 5410 |
sAutoFocusableOffUIThreadWontNotifyParents = targetSdkVersion < Build.VERSION_CODES.O; |
| 5411 |
|
| 5412 |
sUseDefaultFocusHighlight = context.getResources().getBoolean( |
| 5413 |
com.android.internal.R.bool.config_useDefaultFocusHighlight); |
| 5414 |
|
| 5415 |
sThrowOnInvalidFloatProperties = targetSdkVersion >= Build.VERSION_CODES.P; |
| 5416 |
|
| 5417 |
sCanFocusZeroSized = targetSdkVersion < Build.VERSION_CODES.P; |
| 5418 |
|
| 5419 |
sAlwaysAssignFocus = targetSdkVersion < Build.VERSION_CODES.P; |
| 5420 |
|
| 5421 |
sAcceptZeroSizeDragShadow = targetSdkVersion < Build.VERSION_CODES.P; |
| 5422 |
|
| 5423 |
sBrokenInsetsDispatch = targetSdkVersion < Build.VERSION_CODES.R; |
| 5424 |
|
| 5425 |
sBrokenWindowBackground = targetSdkVersion < Build.VERSION_CODES.Q; |
| 5426 |
|
| 5427 |
GradientDrawable.sWrapNegativeAngleMeasurements = |
| 5428 |
targetSdkVersion >= Build.VERSION_CODES.Q; |
| 5429 |
|
| 5430 |
sForceLayoutWhenInsetsChanged = targetSdkVersion < Build.VERSION_CODES.R; |
| 5431 |
|
| 5432 |
sCompatibilityDone = true; |
| 5433 |
} |
| 5434 |
} |
| 5435 |
|
| 5436 |
|
| 5437 |
|
| 5438 |
|
| 5439 |
|
| 5440 |
|
| 5441 |
|
| 5442 |
|
| 5443 |
|
| 5444 |
|
| 5445 |
|
| 5446 |
|
| 5447 |
|
| 5448 |
|
| 5449 |
|
| 5450 |
|
| 5451 |
|
| 5452 |
public View(Context context, @Nullable AttributeSet attrs) { |
| 5453 |
this(context, attrs, 0); |
| 5454 |
} |
| 5455 |
|
| 5456 |
|
| 5457 |
|
| 5458 |
|
| 5459 |
|
| 5460 |
|
| 5461 |
|
| 5462 |
|
| 5463 |
|
| 5464 |
|
| 5465 |
|
| 5466 |
|
| 5467 |
|
| 5468 |
|
| 5469 |
|
| 5470 |
|
| 5471 |
|
| 5472 |
|
| 5473 |
public View(Context context, @Nullable AttributeSet attrs, int defStyleAttr) { |
| 5474 |
this(context, attrs, defStyleAttr, 0); |
| 5475 |
} |
| 5476 |
|
| 5477 |
|
| 5478 |
|
| 5479 |
|
| 5480 |
|
| 5481 |
|
| 5482 |
|
| 5483 |
|
| 5484 |
|
| 5485 |
|
| 5486 |
|
| 5487 |
|
| 5488 |
|
| 5489 |
|
| 5490 |
|
| 5491 |
|
| 5492 |
|
| 5493 |
|
| 5494 |
|
| 5495 |
|
| 5496 |
|
| 5497 |
|
| 5498 |
|
| 5499 |
|
| 5500 |
|
| 5501 |
|
| 5502 |
|
| 5503 |
|
| 5504 |
|
| 5505 |
|
| 5506 |
|
| 5507 |
|
| 5508 |
|
| 5509 |
|
| 5510 |
public View(Context context, @Nullable AttributeSet attrs, int defStyleAttr, int defStyleRes) { |
| 5511 |
this(context); |
| 5512 |
|
| 5513 |
mSourceLayoutId = Resources.getAttributeSetSourceResId(attrs); |
| 5514 |
|
| 5515 |
final TypedArray a = context.obtainStyledAttributes( |
| 5516 |
attrs, com.android.internal.R.styleable.View, defStyleAttr, defStyleRes); |
| 5517 |
|
| 5518 |
retrieveExplicitStyle(context.getTheme(), attrs); |
| 5519 |
saveAttributeDataForStyleable(context, com.android.internal.R.styleable.View, attrs, a, |
| 5520 |
defStyleAttr, defStyleRes); |
| 5521 |
|
| 5522 |
if (sDebugViewAttributes) { |
| 5523 |
saveAttributeData(attrs, a); |
| 5524 |
} |
| 5525 |
|
| 5526 |
Drawable background = null; |
| 5527 |
|
| 5528 |
int leftPadding = -1; |
| 5529 |
int topPadding = -1; |
| 5530 |
int rightPadding = -1; |
| 5531 |
int bottomPadding = -1; |
| 5532 |
int startPadding = UNDEFINED_PADDING; |
| 5533 |
int endPadding = UNDEFINED_PADDING; |
| 5534 |
|
| 5535 |
int padding = -1; |
| 5536 |
int paddingHorizontal = -1; |
| 5537 |
int paddingVertical = -1; |
| 5538 |
|
| 5539 |
int viewFlagValues = 0; |
| 5540 |
int viewFlagMasks = 0; |
| 5541 |
|
| 5542 |
boolean setScrollContainer = false; |
| 5543 |
|
| 5544 |
int x = 0; |
| 5545 |
int y = 0; |
| 5546 |
|
| 5547 |
float tx = 0; |
| 5548 |
float ty = 0; |
| 5549 |
float tz = 0; |
| 5550 |
float elevation = 0; |
| 5551 |
float rotation = 0; |
| 5552 |
float rotationX = 0; |
| 5553 |
float rotationY = 0; |
| 5554 |
float sx = 1f; |
| 5555 |
float sy = 1f; |
| 5556 |
boolean transformSet = false; |
| 5557 |
|
| 5558 |
int scrollbarStyle = SCROLLBARS_INSIDE_OVERLAY; |
| 5559 |
int overScrollMode = mOverScrollMode; |
| 5560 |
boolean initializeScrollbars = false; |
| 5561 |
boolean initializeScrollIndicators = false; |
| 5562 |
|
| 5563 |
boolean startPaddingDefined = false; |
| 5564 |
boolean endPaddingDefined = false; |
| 5565 |
boolean leftPaddingDefined = false; |
| 5566 |
boolean rightPaddingDefined = false; |
| 5567 |
|
| 5568 |
final int targetSdkVersion = context.getApplicationInfo().targetSdkVersion; |
| 5569 |
|
| 5570 |
|
| 5571 |
viewFlagValues |= FOCUSABLE_AUTO; |
| 5572 |
viewFlagMasks |= FOCUSABLE_AUTO; |
| 5573 |
|
| 5574 |
final int N = a.getIndexCount(); |
| 5575 |
for (int i = 0; i < N; i++) { |
| 5576 |
int attr = a.getIndex(i); |
| 5577 |
switch (attr) { |
| 5578 |
case com.android.internal.R.styleable.View_background: |
| 5579 |
background = a.getDrawable(attr); |
| 5580 |
break; |
| 5581 |
case com.android.internal.R.styleable.View_padding: |
| 5582 |
padding = a.getDimensionPixelSize(attr, -1); |
| 5583 |
mUserPaddingLeftInitial = padding; |
| 5584 |
mUserPaddingRightInitial = padding; |
| 5585 |
leftPaddingDefined = true; |
| 5586 |
rightPaddingDefined = true; |
| 5587 |
break; |
| 5588 |
case com.android.internal.R.styleable.View_paddingHorizontal: |
| 5589 |
paddingHorizontal = a.getDimensionPixelSize(attr, -1); |
| 5590 |
mUserPaddingLeftInitial = paddingHorizontal; |
| 5591 |
mUserPaddingRightInitial = paddingHorizontal; |
| 5592 |
leftPaddingDefined = true; |
| 5593 |
rightPaddingDefined = true; |
| 5594 |
break; |
| 5595 |
case com.android.internal.R.styleable.View_paddingVertical: |
| 5596 |
paddingVertical = a.getDimensionPixelSize(attr, -1); |
| 5597 |
break; |
| 5598 |
case com.android.internal.R.styleable.View_paddingLeft: |
| 5599 |
leftPadding = a.getDimensionPixelSize(attr, -1); |
| 5600 |
mUserPaddingLeftInitial = leftPadding; |
| 5601 |
leftPaddingDefined = true; |
| 5602 |
break; |
| 5603 |
case com.android.internal.R.styleable.View_paddingTop: |
| 5604 |
topPadding = a.getDimensionPixelSize(attr, -1); |
| 5605 |
break; |
| 5606 |
case com.android.internal.R.styleable.View_paddingRight: |
| 5607 |
rightPadding = a.getDimensionPixelSize(attr, -1); |
| 5608 |
mUserPaddingRightInitial = rightPadding; |
| 5609 |
rightPaddingDefined = true; |
| 5610 |
break; |
| 5611 |
case com.android.internal.R.styleable.View_paddingBottom: |
| 5612 |
bottomPadding = a.getDimensionPixelSize(attr, -1); |
| 5613 |
break; |
| 5614 |
case com.android.internal.R.styleable.View_paddingStart: |
| 5615 |
startPadding = a.getDimensionPixelSize(attr, UNDEFINED_PADDING); |
| 5616 |
startPaddingDefined = (startPadding != UNDEFINED_PADDING); |
| 5617 |
break; |
| 5618 |
case com.android.internal.R.styleable.View_paddingEnd: |
| 5619 |
endPadding = a.getDimensionPixelSize(attr, UNDEFINED_PADDING); |
| 5620 |
endPaddingDefined = (endPadding != UNDEFINED_PADDING); |
| 5621 |
break; |
| 5622 |
case com.android.internal.R.styleable.View_scrollX: |
| 5623 |
x = a.getDimensionPixelOffset(attr, 0); |
| 5624 |
break; |
| 5625 |
case com.android.internal.R.styleable.View_scrollY: |
| 5626 |
y = a.getDimensionPixelOffset(attr, 0); |
| 5627 |
break; |
| 5628 |
case com.android.internal.R.styleable.View_alpha: |
| 5629 |
setAlpha(a.getFloat(attr, 1f)); |
| 5630 |
break; |
| 5631 |
case com.android.internal.R.styleable.View_transformPivotX: |
| 5632 |
setPivotX(a.getDimension(attr, 0)); |
| 5633 |
break; |
| 5634 |
case com.android.internal.R.styleable.View_transformPivotY: |
| 5635 |
setPivotY(a.getDimension(attr, 0)); |
| 5636 |
break; |
| 5637 |
case com.android.internal.R.styleable.View_translationX: |
| 5638 |
tx = a.getDimension(attr, 0); |
| 5639 |
transformSet = true; |
| 5640 |
break; |
| 5641 |
case com.android.internal.R.styleable.View_translationY: |
| 5642 |
ty = a.getDimension(attr, 0); |
| 5643 |
transformSet = true; |
| 5644 |
break; |
| 5645 |
case com.android.internal.R.styleable.View_translationZ: |
| 5646 |
tz = a.getDimension(attr, 0); |
| 5647 |
transformSet = true; |
| 5648 |
break; |
| 5649 |
case com.android.internal.R.styleable.View_elevation: |
| 5650 |
elevation = a.getDimension(attr, 0); |
| 5651 |
transformSet = true; |
| 5652 |
break; |
| 5653 |
case com.android.internal.R.styleable.View_rotation: |
| 5654 |
rotation = a.getFloat(attr, 0); |
| 5655 |
transformSet = true; |
| 5656 |
break; |
| 5657 |
case com.android.internal.R.styleable.View_rotationX: |
| 5658 |
rotationX = a.getFloat(attr, 0); |
| 5659 |
transformSet = true; |
| 5660 |
break; |
| 5661 |
case com.android.internal.R.styleable.View_rotationY: |
| 5662 |
rotationY = a.getFloat(attr, 0); |
| 5663 |
transformSet = true; |
| 5664 |
break; |
| 5665 |
case com.android.internal.R.styleable.View_scaleX: |
| 5666 |
sx = a.getFloat(attr, 1f); |
| 5667 |
transformSet = true; |
| 5668 |
break; |
| 5669 |
case com.android.internal.R.styleable.View_scaleY: |
| 5670 |
sy = a.getFloat(attr, 1f); |
| 5671 |
transformSet = true; |
| 5672 |
break; |
| 5673 |
case com.android.internal.R.styleable.View_id: |
| 5674 |
mID = a.getResourceId(attr, NO_ID); |
| 5675 |
break; |
| 5676 |
case com.android.internal.R.styleable.View_tag: |
| 5677 |
mTag = a.getText(attr); |
| 5678 |
break; |
| 5679 |
case com.android.internal.R.styleable.View_fitsSystemWindows: |
| 5680 |
if (a.getBoolean(attr, false)) { |
| 5681 |
viewFlagValues |= FITS_SYSTEM_WINDOWS; |
| 5682 |
viewFlagMasks |= FITS_SYSTEM_WINDOWS; |
| 5683 |
} |
| 5684 |
break; |
| 5685 |
case com.android.internal.R.styleable.View_focusable: |
| 5686 |
viewFlagValues = (viewFlagValues & ~FOCUSABLE_MASK) | getFocusableAttribute(a); |
| 5687 |
if ((viewFlagValues & FOCUSABLE_AUTO) == 0) { |
| 5688 |
viewFlagMasks |= FOCUSABLE_MASK; |
| 5689 |
} |
| 5690 |
break; |
| 5691 |
case com.android.internal.R.styleable.View_focusableInTouchMode: |
| 5692 |
if (a.getBoolean(attr, false)) { |
| 5693 |
|
| 5694 |
viewFlagValues &= ~FOCUSABLE_AUTO; |
| 5695 |
viewFlagValues |= FOCUSABLE_IN_TOUCH_MODE | FOCUSABLE; |
| 5696 |
viewFlagMasks |= FOCUSABLE_IN_TOUCH_MODE | FOCUSABLE_MASK; |
| 5697 |
} |
| 5698 |
break; |
| 5699 |
case com.android.internal.R.styleable.View_clickable: |
| 5700 |
if (a.getBoolean(attr, false)) { |
| 5701 |
viewFlagValues |= CLICKABLE; |
| 5702 |
viewFlagMasks |= CLICKABLE; |
| 5703 |
} |
| 5704 |
break; |
| 5705 |
case com.android.internal.R.styleable.View_allowClickWhenDisabled: |
| 5706 |
setAllowClickWhenDisabled(a.getBoolean(attr, false)); |
| 5707 |
break; |
| 5708 |
case com.android.internal.R.styleable.View_longClickable: |
| 5709 |
if (a.getBoolean(attr, false)) { |
| 5710 |
viewFlagValues |= LONG_CLICKABLE; |
| 5711 |
viewFlagMasks |= LONG_CLICKABLE; |
| 5712 |
} |
| 5713 |
break; |
| 5714 |
case com.android.internal.R.styleable.View_contextClickable: |
| 5715 |
if (a.getBoolean(attr, false)) { |
| 5716 |
viewFlagValues |= CONTEXT_CLICKABLE; |
| 5717 |
viewFlagMasks |= CONTEXT_CLICKABLE; |
| 5718 |
} |
| 5719 |
break; |
| 5720 |
case com.android.internal.R.styleable.View_saveEnabled: |
| 5721 |
if (!a.getBoolean(attr, true)) { |
| 5722 |
viewFlagValues |= SAVE_DISABLED; |
| 5723 |
viewFlagMasks |= SAVE_DISABLED_MASK; |
| 5724 |
} |
| 5725 |
break; |
| 5726 |
case com.android.internal.R.styleable.View_duplicateParentState: |
| 5727 |
if (a.getBoolean(attr, false)) { |
| 5728 |
viewFlagValues |= DUPLICATE_PARENT_STATE; |
| 5729 |
viewFlagMasks |= DUPLICATE_PARENT_STATE; |
| 5730 |
} |
| 5731 |
break; |
| 5732 |
case com.android.internal.R.styleable.View_visibility: |
| 5733 |
final int visibility = a.getInt(attr, 0); |
| 5734 |
if (visibility != 0) { |
| 5735 |
viewFlagValues |= VISIBILITY_FLAGS[visibility]; |
| 5736 |
viewFlagMasks |= VISIBILITY_MASK; |
| 5737 |
} |
| 5738 |
break; |
| 5739 |
case com.android.internal.R.styleable.View_layoutDirection: |
| 5740 |
|
| 5741 |
mPrivateFlags2 &= |
| 5742 |
~(PFLAG2_LAYOUT_DIRECTION_MASK | PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK); |
| 5743 |
|
| 5744 |
final int layoutDirection = a.getInt(attr, -1); |
| 5745 |
final int value = (layoutDirection != -1) ? |
| 5746 |
LAYOUT_DIRECTION_FLAGS[layoutDirection] : LAYOUT_DIRECTION_DEFAULT; |
| 5747 |
mPrivateFlags2 |= (value << PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT); |
| 5748 |
break; |
| 5749 |
case com.android.internal.R.styleable.View_drawingCacheQuality: |
| 5750 |
final int cacheQuality = a.getInt(attr, 0); |
| 5751 |
if (cacheQuality != 0) { |
| 5752 |
viewFlagValues |= DRAWING_CACHE_QUALITY_FLAGS[cacheQuality]; |
| 5753 |
viewFlagMasks |= DRAWING_CACHE_QUALITY_MASK; |
| 5754 |
} |
| 5755 |
break; |
| 5756 |
case com.android.internal.R.styleable.View_contentDescription: |
| 5757 |
setContentDescription(a.getString(attr)); |
| 5758 |
break; |
| 5759 |
case com.android.internal.R.styleable.View_accessibilityTraversalBefore: |
| 5760 |
setAccessibilityTraversalBefore(a.getResourceId(attr, NO_ID)); |
| 5761 |
break; |
| 5762 |
case com.android.internal.R.styleable.View_accessibilityTraversalAfter: |
| 5763 |
setAccessibilityTraversalAfter(a.getResourceId(attr, NO_ID)); |
| 5764 |
break; |
| 5765 |
case com.android.internal.R.styleable.View_labelFor: |
| 5766 |
setLabelFor(a.getResourceId(attr, NO_ID)); |
| 5767 |
break; |
| 5768 |
case com.android.internal.R.styleable.View_soundEffectsEnabled: |
| 5769 |
if (!a.getBoolean(attr, true)) { |
| 5770 |
viewFlagValues &= ~SOUND_EFFECTS_ENABLED; |
| 5771 |
viewFlagMasks |= SOUND_EFFECTS_ENABLED; |
| 5772 |
} |
| 5773 |
break; |
| 5774 |
case com.android.internal.R.styleable.View_hapticFeedbackEnabled: |
| 5775 |
if (!a.getBoolean(attr, true)) { |
| 5776 |
viewFlagValues &= ~HAPTIC_FEEDBACK_ENABLED; |
| 5777 |
viewFlagMasks |= HAPTIC_FEEDBACK_ENABLED; |
| 5778 |
} |
| 5779 |
break; |
| 5780 |
case R.styleable.View_scrollbars: |
| 5781 |
final int scrollbars = a.getInt(attr, SCROLLBARS_NONE); |
| 5782 |
if (scrollbars != SCROLLBARS_NONE) { |
| 5783 |
viewFlagValues |= scrollbars; |
| 5784 |
viewFlagMasks |= SCROLLBARS_MASK; |
| 5785 |
initializeScrollbars = true; |
| 5786 |
} |
| 5787 |
break; |
| 5788 |
|
| 5789 |
case R.styleable.View_fadingEdge: |
| 5790 |
if (targetSdkVersion >= Build.VERSION_CODES.ICE_CREAM_SANDWICH) { |
| 5791 |
|
| 5792 |
break; |
| 5793 |
} |
| 5794 |
|
| 5795 |
case R.styleable.View_requiresFadingEdge: |
| 5796 |
final int fadingEdge = a.getInt(attr, FADING_EDGE_NONE); |
| 5797 |
if (fadingEdge != FADING_EDGE_NONE) { |
| 5798 |
viewFlagValues |= fadingEdge; |
| 5799 |
viewFlagMasks |= FADING_EDGE_MASK; |
| 5800 |
initializeFadingEdgeInternal(a); |
| 5801 |
} |
| 5802 |
break; |
| 5803 |
case R.styleable.View_scrollbarStyle: |
| 5804 |
scrollbarStyle = a.getInt(attr, SCROLLBARS_INSIDE_OVERLAY); |
| 5805 |
if (scrollbarStyle != SCROLLBARS_INSIDE_OVERLAY) { |
| 5806 |
viewFlagValues |= scrollbarStyle & SCROLLBARS_STYLE_MASK; |
| 5807 |
viewFlagMasks |= SCROLLBARS_STYLE_MASK; |
| 5808 |
} |
| 5809 |
break; |
| 5810 |
case R.styleable.View_isScrollContainer: |
| 5811 |
setScrollContainer = true; |
| 5812 |
if (a.getBoolean(attr, false)) { |
| 5813 |
setScrollContainer(true); |
| 5814 |
} |
| 5815 |
break; |
| 5816 |
case com.android.internal.R.styleable.View_keepScreenOn: |
| 5817 |
if (a.getBoolean(attr, false)) { |
| 5818 |
viewFlagValues |= KEEP_SCREEN_ON; |
| 5819 |
viewFlagMasks |= KEEP_SCREEN_ON; |
| 5820 |
} |
| 5821 |
break; |
| 5822 |
case R.styleable.View_filterTouchesWhenObscured: |
| 5823 |
if (a.getBoolean(attr, false)) { |
| 5824 |
viewFlagValues |= FILTER_TOUCHES_WHEN_OBSCURED; |
| 5825 |
viewFlagMasks |= FILTER_TOUCHES_WHEN_OBSCURED; |
| 5826 |
} |
| 5827 |
break; |
| 5828 |
case R.styleable.View_nextFocusLeft: |
| 5829 |
mNextFocusLeftId = a.getResourceId(attr, View.NO_ID); |
| 5830 |
break; |
| 5831 |
case R.styleable.View_nextFocusRight: |
| 5832 |
mNextFocusRightId = a.getResourceId(attr, View.NO_ID); |
| 5833 |
break; |
| 5834 |
case R.styleable.View_nextFocusUp: |
| 5835 |
mNextFocusUpId = a.getResourceId(attr, View.NO_ID); |
| 5836 |
break; |
| 5837 |
case R.styleable.View_nextFocusDown: |
| 5838 |
mNextFocusDownId = a.getResourceId(attr, View.NO_ID); |
| 5839 |
break; |
| 5840 |
case R.styleable.View_nextFocusForward: |
| 5841 |
mNextFocusForwardId = a.getResourceId(attr, View.NO_ID); |
| 5842 |
break; |
| 5843 |
case R.styleable.View_nextClusterForward: |
| 5844 |
mNextClusterForwardId = a.getResourceId(attr, View.NO_ID); |
| 5845 |
break; |
| 5846 |
case R.styleable.View_minWidth: |
| 5847 |
mMinWidth = a.getDimensionPixelSize(attr, 0); |
| 5848 |
break; |
| 5849 |
case R.styleable.View_minHeight: |
| 5850 |
mMinHeight = a.getDimensionPixelSize(attr, 0); |
| 5851 |
break; |
| 5852 |
case R.styleable.View_onClick: |
| 5853 |
if (context.isRestricted()) { |
| 5854 |
throw new IllegalStateException("The android:onClick attribute cannot " |
| 5855 |
+ "be used within a restricted context"); |
| 5856 |
} |
| 5857 |
|
| 5858 |
final String handlerName = a.getString(attr); |
| 5859 |
if (handlerName != null) { |
| 5860 |
setOnClickListener(new DeclaredOnClickListener(this, handlerName)); |
| 5861 |
} |
| 5862 |
break; |
| 5863 |
case R.styleable.View_overScrollMode: |
| 5864 |
overScrollMode = a.getInt(attr, OVER_SCROLL_IF_CONTENT_SCROLLS); |
| 5865 |
break; |
| 5866 |
case R.styleable.View_verticalScrollbarPosition: |
| 5867 |
mVerticalScrollbarPosition = a.getInt(attr, SCROLLBAR_POSITION_DEFAULT); |
| 5868 |
break; |
| 5869 |
case R.styleable.View_layerType: |
| 5870 |
setLayerType(a.getInt(attr, LAYER_TYPE_NONE), null); |
| 5871 |
break; |
| 5872 |
case R.styleable.View_textDirection: |
| 5873 |
|
| 5874 |
mPrivateFlags2 &= ~PFLAG2_TEXT_DIRECTION_MASK; |
| 5875 |
|
| 5876 |
final int textDirection = a.getInt(attr, -1); |
| 5877 |
if (textDirection != -1) { |
| 5878 |
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_FLAGS[textDirection]; |
| 5879 |
} |
| 5880 |
break; |
| 5881 |
case R.styleable.View_textAlignment: |
| 5882 |
|
| 5883 |
mPrivateFlags2 &= ~PFLAG2_TEXT_ALIGNMENT_MASK; |
| 5884 |
|
| 5885 |
final int textAlignment = a.getInt(attr, TEXT_ALIGNMENT_DEFAULT); |
| 5886 |
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_FLAGS[textAlignment]; |
| 5887 |
break; |
| 5888 |
case R.styleable.View_importantForAccessibility: |
| 5889 |
setImportantForAccessibility(a.getInt(attr, |
| 5890 |
IMPORTANT_FOR_ACCESSIBILITY_DEFAULT)); |
| 5891 |
break; |
| 5892 |
case R.styleable.View_accessibilityLiveRegion: |
| 5893 |
setAccessibilityLiveRegion(a.getInt(attr, ACCESSIBILITY_LIVE_REGION_DEFAULT)); |
| 5894 |
break; |
| 5895 |
case R.styleable.View_transitionName: |
| 5896 |
setTransitionName(a.getString(attr)); |
| 5897 |
break; |
| 5898 |
case R.styleable.View_nestedScrollingEnabled: |
| 5899 |
setNestedScrollingEnabled(a.getBoolean(attr, false)); |
| 5900 |
break; |
| 5901 |
case R.styleable.View_stateListAnimator: |
| 5902 |
setStateListAnimator(AnimatorInflater.loadStateListAnimator(context, |
| 5903 |
a.getResourceId(attr, 0))); |
| 5904 |
break; |
| 5905 |
case R.styleable.View_backgroundTint: |
| 5906 |
|
| 5907 |
if (mBackgroundTint == null) { |
| 5908 |
mBackgroundTint = new TintInfo(); |
| 5909 |
} |
| 5910 |
mBackgroundTint.mTintList = a.getColorStateList( |
| 5911 |
R.styleable.View_backgroundTint); |
| 5912 |
mBackgroundTint.mHasTintList = true; |
| 5913 |
break; |
| 5914 |
case R.styleable.View_backgroundTintMode: |
| 5915 |
|
| 5916 |
if (mBackgroundTint == null) { |
| 5917 |
mBackgroundTint = new TintInfo(); |
| 5918 |
} |
| 5919 |
mBackgroundTint.mBlendMode = Drawable.parseBlendMode(a.getInt( |
| 5920 |
R.styleable.View_backgroundTintMode, -1), null); |
| 5921 |
mBackgroundTint.mHasTintMode = true; |
| 5922 |
break; |
| 5923 |
case R.styleable.View_outlineProvider: |
| 5924 |
setOutlineProviderFromAttribute(a.getInt(R.styleable.View_outlineProvider, |
| 5925 |
PROVIDER_BACKGROUND)); |
| 5926 |
break; |
| 5927 |
case R.styleable.View_foreground: |
| 5928 |
if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { |
| 5929 |
setForeground(a.getDrawable(attr)); |
| 5930 |
} |
| 5931 |
break; |
| 5932 |
case R.styleable.View_foregroundGravity: |
| 5933 |
if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { |
| 5934 |
setForegroundGravity(a.getInt(attr, Gravity.NO_GRAVITY)); |
| 5935 |
} |
| 5936 |
break; |
| 5937 |
case R.styleable.View_foregroundTintMode: |
| 5938 |
if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { |
| 5939 |
setForegroundTintBlendMode( |
| 5940 |
Drawable.parseBlendMode(a.getInt(attr, -1), |
| 5941 |
null)); |
| 5942 |
} |
| 5943 |
break; |
| 5944 |
case R.styleable.View_foregroundTint: |
| 5945 |
if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { |
| 5946 |
setForegroundTintList(a.getColorStateList(attr)); |
| 5947 |
} |
| 5948 |
break; |
| 5949 |
case R.styleable.View_foregroundInsidePadding: |
| 5950 |
if (targetSdkVersion >= Build.VERSION_CODES.M || this instanceof FrameLayout) { |
| 5951 |
if (mForegroundInfo == null) { |
| 5952 |
mForegroundInfo = new ForegroundInfo(); |
| 5953 |
} |
| 5954 |
mForegroundInfo.mInsidePadding = a.getBoolean(attr, |
| 5955 |
mForegroundInfo.mInsidePadding); |
| 5956 |
} |
| 5957 |
break; |
| 5958 |
case R.styleable.View_scrollIndicators: |
| 5959 |
final int scrollIndicators = |
| 5960 |
(a.getInt(attr, 0) << SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT) |
| 5961 |
& SCROLL_INDICATORS_PFLAG3_MASK; |
| 5962 |
if (scrollIndicators != 0) { |
| 5963 |
mPrivateFlags3 |= scrollIndicators; |
| 5964 |
initializeScrollIndicators = true; |
| 5965 |
} |
| 5966 |
break; |
| 5967 |
case R.styleable.View_pointerIcon: |
| 5968 |
final int resourceId = a.getResourceId(attr, 0); |
| 5969 |
if (resourceId != 0) { |
| 5970 |
setPointerIcon(PointerIcon.load( |
| 5971 |
context.getResources(), resourceId)); |
| 5972 |
} else { |
| 5973 |
final int pointerType = a.getInt(attr, PointerIcon.TYPE_NOT_SPECIFIED); |
| 5974 |
if (pointerType != PointerIcon.TYPE_NOT_SPECIFIED) { |
| 5975 |
setPointerIcon(PointerIcon.getSystemIcon(context, pointerType)); |
| 5976 |
} |
| 5977 |
} |
| 5978 |
break; |
| 5979 |
case R.styleable.View_forceHasOverlappingRendering: |
| 5980 |
if (a.peekValue(attr) != null) { |
| 5981 |
forceHasOverlappingRendering(a.getBoolean(attr, true)); |
| 5982 |
} |
| 5983 |
break; |
| 5984 |
case R.styleable.View_tooltipText: |
| 5985 |
setTooltipText(a.getText(attr)); |
| 5986 |
break; |
| 5987 |
case R.styleable.View_keyboardNavigationCluster: |
| 5988 |
if (a.peekValue(attr) != null) { |
| 5989 |
setKeyboardNavigationCluster(a.getBoolean(attr, true)); |
| 5990 |
} |
| 5991 |
break; |
| 5992 |
case R.styleable.View_focusedByDefault: |
| 5993 |
if (a.peekValue(attr) != null) { |
| 5994 |
setFocusedByDefault(a.getBoolean(attr, true)); |
| 5995 |
} |
| 5996 |
break; |
| 5997 |
case R.styleable.View_autofillHints: |
| 5998 |
if (a.peekValue(attr) != null) { |
| 5999 |
CharSequence[] rawHints = null; |
| 6000 |
String rawString = null; |
| 6001 |
|
| 6002 |
if (a.getType(attr) == TypedValue.TYPE_REFERENCE) { |
| 6003 |
int resId = a.getResourceId(attr, 0); |
| 6004 |
|
| 6005 |
try { |
| 6006 |
rawHints = a.getTextArray(attr); |
| 6007 |
} catch (Resources.NotFoundException e) { |
| 6008 |
rawString = getResources().getString(resId); |
| 6009 |
} |
| 6010 |
} else { |
| 6011 |
rawString = a.getString(attr); |
| 6012 |
} |
| 6013 |
|
| 6014 |
if (rawHints == null) { |
| 6015 |
if (rawString == null) { |
| 6016 |
throw new IllegalArgumentException( |
| 6017 |
"Could not resolve autofillHints"); |
| 6018 |
} else { |
| 6019 |
rawHints = rawString.split(","); |
| 6020 |
} |
| 6021 |
} |
| 6022 |
|
| 6023 |
String[] hints = new String[rawHints.length]; |
| 6024 |
|
| 6025 |
int numHints = rawHints.length; |
| 6026 |
for (int rawHintNum = 0; rawHintNum < numHints; rawHintNum++) { |
| 6027 |
hints[rawHintNum] = rawHints[rawHintNum].toString().trim(); |
| 6028 |
} |
| 6029 |
setAutofillHints(hints); |
| 6030 |
} |
| 6031 |
break; |
| 6032 |
case R.styleable.View_importantForAutofill: |
| 6033 |
if (a.peekValue(attr) != null) { |
| 6034 |
setImportantForAutofill(a.getInt(attr, IMPORTANT_FOR_AUTOFILL_AUTO)); |
| 6035 |
} |
| 6036 |
break; |
| 6037 |
case R.styleable.View_importantForContentCapture: |
| 6038 |
if (a.peekValue(attr) != null) { |
| 6039 |
setImportantForContentCapture(a.getInt(attr, |
| 6040 |
IMPORTANT_FOR_CONTENT_CAPTURE_AUTO)); |
| 6041 |
} |
| 6042 |
case R.styleable.View_defaultFocusHighlightEnabled: |
| 6043 |
if (a.peekValue(attr) != null) { |
| 6044 |
setDefaultFocusHighlightEnabled(a.getBoolean(attr, true)); |
| 6045 |
} |
| 6046 |
break; |
| 6047 |
case R.styleable.View_screenReaderFocusable: |
| 6048 |
if (a.peekValue(attr) != null) { |
| 6049 |
setScreenReaderFocusable(a.getBoolean(attr, false)); |
| 6050 |
} |
| 6051 |
break; |
| 6052 |
case R.styleable.View_accessibilityPaneTitle: |
| 6053 |
if (a.peekValue(attr) != null) { |
| 6054 |
setAccessibilityPaneTitle(a.getString(attr)); |
| 6055 |
} |
| 6056 |
break; |
| 6057 |
case R.styleable.View_outlineSpotShadowColor: |
| 6058 |
setOutlineSpotShadowColor(a.getColor(attr, Color.BLACK)); |
| 6059 |
break; |
| 6060 |
case R.styleable.View_outlineAmbientShadowColor: |
| 6061 |
setOutlineAmbientShadowColor(a.getColor(attr, Color.BLACK)); |
| 6062 |
break; |
| 6063 |
case com.android.internal.R.styleable.View_accessibilityHeading: |
| 6064 |
setAccessibilityHeading(a.getBoolean(attr, false)); |
| 6065 |
break; |
| 6066 |
case R.styleable.View_forceDarkAllowed: |
| 6067 |
mRenderNode.setForceDarkAllowed(a.getBoolean(attr, true)); |
| 6068 |
break; |
| 6069 |
case R.styleable.View_scrollCaptureHint: |
| 6070 |
setScrollCaptureHint((a.getInt(attr, SCROLL_CAPTURE_HINT_AUTO))); |
| 6071 |
break; |
| 6072 |
case R.styleable.View_clipToOutline: |
| 6073 |
setClipToOutline(a.getBoolean(attr, false)); |
| 6074 |
break; |
| 6075 |
case R.styleable.View_preferKeepClear: |
| 6076 |
setPreferKeepClear(a.getBoolean(attr, false)); |
| 6077 |
break; |
| 6078 |
case R.styleable.View_autoHandwritingEnabled: |
| 6079 |
setAutoHandwritingEnabled(a.getBoolean(attr, true)); |
| 6080 |
break; |
| 6081 |
} |
| 6082 |
} |
| 6083 |
|
| 6084 |
setOverScrollMode(overScrollMode); |
| 6085 |
|
| 6086 |
|
| 6087 |
|
| 6088 |
|
| 6089 |
mUserPaddingStart = startPadding; |
| 6090 |
mUserPaddingEnd = endPadding; |
| 6091 |
|
| 6092 |
if (background != null) { |
| 6093 |
setBackground(background); |
| 6094 |
} |
| 6095 |
|
| 6096 |
|
| 6097 |
|
| 6098 |
mLeftPaddingDefined = leftPaddingDefined; |
| 6099 |
mRightPaddingDefined = rightPaddingDefined; |
| 6100 |
|
| 6101 |
|
| 6102 |
|
| 6103 |
if (padding >= 0) { |
| 6104 |
leftPadding = padding; |
| 6105 |
topPadding = padding; |
| 6106 |
rightPadding = padding; |
| 6107 |
bottomPadding = padding; |
| 6108 |
mUserPaddingLeftInitial = padding; |
| 6109 |
mUserPaddingRightInitial = padding; |
| 6110 |
} else { |
| 6111 |
if (paddingHorizontal >= 0) { |
| 6112 |
leftPadding = paddingHorizontal; |
| 6113 |
rightPadding = paddingHorizontal; |
| 6114 |
mUserPaddingLeftInitial = paddingHorizontal; |
| 6115 |
mUserPaddingRightInitial = paddingHorizontal; |
| 6116 |
} |
| 6117 |
if (paddingVertical >= 0) { |
| 6118 |
topPadding = paddingVertical; |
| 6119 |
bottomPadding = paddingVertical; |
| 6120 |
} |
| 6121 |
} |
| 6122 |
|
| 6123 |
if (isRtlCompatibilityMode()) { |
| 6124 |
|
| 6125 |
|
| 6126 |
|
| 6127 |
|
| 6128 |
|
| 6129 |
|
| 6130 |
|
| 6131 |
if (!mLeftPaddingDefined && startPaddingDefined) { |
| 6132 |
leftPadding = startPadding; |
| 6133 |
} |
| 6134 |
mUserPaddingLeftInitial = (leftPadding >= 0) ? leftPadding : mUserPaddingLeftInitial; |
| 6135 |
if (!mRightPaddingDefined && endPaddingDefined) { |
| 6136 |
rightPadding = endPadding; |
| 6137 |
} |
| 6138 |
mUserPaddingRightInitial = (rightPadding >= 0) ? rightPadding : mUserPaddingRightInitial; |
| 6139 |
} else { |
| 6140 |
|
| 6141 |
|
| 6142 |
|
| 6143 |
|
| 6144 |
|
| 6145 |
final boolean hasRelativePadding = startPaddingDefined || endPaddingDefined; |
| 6146 |
|
| 6147 |
if (mLeftPaddingDefined && !hasRelativePadding) { |
| 6148 |
mUserPaddingLeftInitial = leftPadding; |
| 6149 |
} |
| 6150 |
if (mRightPaddingDefined && !hasRelativePadding) { |
| 6151 |
mUserPaddingRightInitial = rightPadding; |
| 6152 |
} |
| 6153 |
} |
| 6154 |
|
| 6155 |
|
| 6156 |
|
| 6157 |
internalSetPadding( |
| 6158 |
mUserPaddingLeftInitial, |
| 6159 |
topPadding >= 0 ? topPadding : mPaddingTop, |
| 6160 |
mUserPaddingRightInitial, |
| 6161 |
bottomPadding >= 0 ? bottomPadding : mPaddingBottom); |
| 6162 |
|
| 6163 |
if (viewFlagMasks != 0) { |
| 6164 |
setFlags(viewFlagValues, viewFlagMasks); |
| 6165 |
} |
| 6166 |
|
| 6167 |
if (initializeScrollbars) { |
| 6168 |
initializeScrollbarsInternal(a); |
| 6169 |
} |
| 6170 |
|
| 6171 |
if (initializeScrollIndicators) { |
| 6172 |
initializeScrollIndicatorsInternal(); |
| 6173 |
} |
| 6174 |
|
| 6175 |
a.recycle(); |
| 6176 |
|
| 6177 |
|
| 6178 |
if (scrollbarStyle != SCROLLBARS_INSIDE_OVERLAY) { |
| 6179 |
recomputePadding(); |
| 6180 |
} |
| 6181 |
|
| 6182 |
if (x != 0 || y != 0) { |
| 6183 |
scrollTo(x, y); |
| 6184 |
} |
| 6185 |
|
| 6186 |
if (transformSet) { |
| 6187 |
setTranslationX(tx); |
| 6188 |
setTranslationY(ty); |
| 6189 |
setTranslationZ(tz); |
| 6190 |
setElevation(elevation); |
| 6191 |
setRotation(rotation); |
| 6192 |
setRotationX(rotationX); |
| 6193 |
setRotationY(rotationY); |
| 6194 |
setScaleX(sx); |
| 6195 |
setScaleY(sy); |
| 6196 |
} |
| 6197 |
|
| 6198 |
if (!setScrollContainer && (viewFlagValues&SCROLLBARS_VERTICAL) != 0) { |
| 6199 |
setScrollContainer(true); |
| 6200 |
} |
| 6201 |
|
| 6202 |
computeOpaqueFlags(); |
| 6203 |
} |
| 6204 |
|
| 6205 |
|
| 6206 |
|
| 6207 |
|
| 6208 |
|
| 6209 |
|
| 6210 |
|
| 6211 |
|
| 6212 |
|
| 6213 |
|
| 6214 |
|
| 6215 |
|
| 6216 |
|
| 6217 |
|
| 6218 |
|
| 6219 |
@NonNull |
| 6220 |
public int[] getAttributeResolutionStack(@AttrRes int attribute) { |
| 6221 |
if (!sDebugViewAttributes |
| 6222 |
|| mAttributeResolutionStacks == null |
| 6223 |
|| mAttributeResolutionStacks.get(attribute) == null) { |
| 6224 |
return new int[0]; |
| 6225 |
} |
| 6226 |
int[] attributeResolutionStack = mAttributeResolutionStacks.get(attribute); |
| 6227 |
int stackSize = attributeResolutionStack.length; |
| 6228 |
if (mSourceLayoutId != ID_NULL) { |
| 6229 |
stackSize++; |
| 6230 |
} |
| 6231 |
|
| 6232 |
int currentIndex = 0; |
| 6233 |
int[] stack = new int[stackSize]; |
| 6234 |
|
| 6235 |
if (mSourceLayoutId != ID_NULL) { |
| 6236 |
stack[currentIndex] = mSourceLayoutId; |
| 6237 |
currentIndex++; |
| 6238 |
} |
| 6239 |
for (int i = 0; i < attributeResolutionStack.length; i++) { |
| 6240 |
stack[currentIndex] = attributeResolutionStack[i]; |
| 6241 |
currentIndex++; |
| 6242 |
} |
| 6243 |
return stack; |
| 6244 |
} |
| 6245 |
|
| 6246 |
|
| 6247 |
|
| 6248 |
|
| 6249 |
|
| 6250 |
|
| 6251 |
|
| 6252 |
|
| 6253 |
|
| 6254 |
|
| 6255 |
|
| 6256 |
|
| 6257 |
|
| 6258 |
|
| 6259 |
@NonNull |
| 6260 |
@SuppressWarnings("AndroidFrameworkEfficientCollections") |
| 6261 |
public Map<Integer, Integer> getAttributeSourceResourceMap() { |
| 6262 |
HashMap<Integer, Integer> map = new HashMap<>(); |
| 6263 |
if (!sDebugViewAttributes || mAttributeSourceResId == null) { |
| 6264 |
return map; |
| 6265 |
} |
| 6266 |
for (int i = 0; i < mAttributeSourceResId.size(); i++) { |
| 6267 |
map.put(mAttributeSourceResId.keyAt(i), mAttributeSourceResId.valueAt(i)); |
| 6268 |
} |
| 6269 |
return map; |
| 6270 |
} |
| 6271 |
|
| 6272 |
|
| 6273 |
|
| 6274 |
|
| 6275 |
|
| 6276 |
|
| 6277 |
|
| 6278 |
|
| 6279 |
|
| 6280 |
|
| 6281 |
|
| 6282 |
|
| 6283 |
|
| 6284 |
|
| 6285 |
|
| 6286 |
|
| 6287 |
|
| 6288 |
|
| 6289 |
@StyleRes |
| 6290 |
public int getExplicitStyle() { |
| 6291 |
if (!sDebugViewAttributes) { |
| 6292 |
return ID_NULL; |
| 6293 |
} |
| 6294 |
return mExplicitStyle; |
| 6295 |
} |
| 6296 |
|
| 6297 |
|
| 6298 |
|
| 6299 |
|
| 6300 |
|
| 6301 |
private static class DeclaredOnClickListener implements OnClickListener { |
| 6302 |
private final View mHostView; |
| 6303 |
private final String mMethodName; |
| 6304 |
|
| 6305 |
private Method mResolvedMethod; |
| 6306 |
private Context mResolvedContext; |
| 6307 |
|
| 6308 |
public DeclaredOnClickListener(@NonNull View hostView, @NonNull String methodName) { |
| 6309 |
mHostView = hostView; |
| 6310 |
mMethodName = methodName; |
| 6311 |
} |
| 6312 |
|
| 6313 |
@Override |
| 6314 |
public void onClick(@NonNull View v) { |
| 6315 |
if (mResolvedMethod == null) { |
| 6316 |
resolveMethod(mHostView.getContext(), mMethodName); |
| 6317 |
} |
| 6318 |
|
| 6319 |
try { |
| 6320 |
mResolvedMethod.invoke(mResolvedContext, v); |
| 6321 |
} catch (IllegalAccessException e) { |
| 6322 |
throw new IllegalStateException( |
| 6323 |
"Could not execute non-public method for android:onClick", e); |
| 6324 |
} catch (InvocationTargetException e) { |
| 6325 |
throw new IllegalStateException( |
| 6326 |
"Could not execute method for android:onClick", e); |
| 6327 |
} |
| 6328 |
} |
| 6329 |
|
| 6330 |
@NonNull |
| 6331 |
private void resolveMethod(@Nullable Context context, @NonNull String name) { |
| 6332 |
while (context != null) { |
| 6333 |
try { |
| 6334 |
if (!context.isRestricted()) { |
| 6335 |
final Method method = context.getClass().getMethod(mMethodName, View.class); |
| 6336 |
if (method != null) { |
| 6337 |
mResolvedMethod = method; |
| 6338 |
mResolvedContext = context; |
| 6339 |
return; |
| 6340 |
} |
| 6341 |
} |
| 6342 |
} catch (NoSuchMethodException e) { |
| 6343 |
|
| 6344 |
} |
| 6345 |
|
| 6346 |
if (context instanceof ContextWrapper) { |
| 6347 |
context = ((ContextWrapper) context).getBaseContext(); |
| 6348 |
} else { |
| 6349 |
|
| 6350 |
context = null; |
| 6351 |
} |
| 6352 |
} |
| 6353 |
|
| 6354 |
final int id = mHostView.getId(); |
| 6355 |
final String idText = id == NO_ID ? "" : " with id '" |
| 6356 |
+ mHostView.getContext().getResources().getResourceEntryName(id) + "'"; |
| 6357 |
throw new IllegalStateException("Could not find method " + mMethodName |
| 6358 |
+ "(View) in a parent or ancestor Context for android:onClick " |
| 6359 |
+ "attribute defined on view " + mHostView.getClass() + idText); |
| 6360 |
} |
| 6361 |
} |
| 6362 |
|
| 6363 |
|
| 6364 |
|
| 6365 |
|
| 6366 |
@UnsupportedAppUsage |
| 6367 |
View() { |
| 6368 |
mResources = null; |
| 6369 |
mRenderNode = RenderNode.create(getClass().getName(), new ViewAnimationHostBridge(this)); |
| 6370 |
} |
| 6371 |
|
| 6372 |
|
| 6373 |
|
| 6374 |
|
| 6375 |
|
| 6376 |
public final boolean isShowingLayoutBounds() { |
| 6377 |
return DEBUG_DRAW || mAttachInfo != null && mAttachInfo.mDebugLayout; |
| 6378 |
} |
| 6379 |
|
| 6380 |
|
| 6381 |
|
| 6382 |
|
| 6383 |
|
| 6384 |
|
| 6385 |
|
| 6386 |
@TestApi |
| 6387 |
public final void setShowingLayoutBounds(boolean debugLayout) { |
| 6388 |
if (mAttachInfo != null) { |
| 6389 |
mAttachInfo.mDebugLayout = debugLayout; |
| 6390 |
} |
| 6391 |
} |
| 6392 |
|
| 6393 |
private static SparseArray<String> getAttributeMap() { |
| 6394 |
if (mAttributeMap == null) { |
| 6395 |
mAttributeMap = new SparseArray<>(); |
| 6396 |
} |
| 6397 |
return mAttributeMap; |
| 6398 |
} |
| 6399 |
|
| 6400 |
private void retrieveExplicitStyle(@NonNull Resources.Theme theme, |
| 6401 |
@Nullable AttributeSet attrs) { |
| 6402 |
if (!sDebugViewAttributes) { |
| 6403 |
return; |
| 6404 |
} |
| 6405 |
mExplicitStyle = theme.getExplicitStyle(attrs); |
| 6406 |
} |
| 6407 |
|
| 6408 |
|
| 6409 |
|
| 6410 |
|
| 6411 |
|
| 6412 |
|
| 6413 |
|
| 6414 |
|
| 6415 |
|
| 6416 |
|
| 6417 |
|
| 6418 |
|
| 6419 |
|
| 6420 |
|
| 6421 |
public final void saveAttributeDataForStyleable(@NonNull Context context, |
| 6422 |
@NonNull int[] styleable, @Nullable AttributeSet attrs, @NonNull TypedArray t, |
| 6423 |
int defStyleAttr, int defStyleRes) { |
| 6424 |
if (!sDebugViewAttributes) { |
| 6425 |
return; |
| 6426 |
} |
| 6427 |
|
| 6428 |
int[] attributeResolutionStack = context.getTheme().getAttributeResolutionStack( |
| 6429 |
defStyleAttr, defStyleRes, mExplicitStyle); |
| 6430 |
|
| 6431 |
if (mAttributeResolutionStacks == null) { |
| 6432 |
mAttributeResolutionStacks = new SparseArray<>(); |
| 6433 |
} |
| 6434 |
|
| 6435 |
if (mAttributeSourceResId == null) { |
| 6436 |
mAttributeSourceResId = new SparseIntArray(); |
| 6437 |
} |
| 6438 |
|
| 6439 |
final int indexCount = t.getIndexCount(); |
| 6440 |
for (int j = 0; j < indexCount; ++j) { |
| 6441 |
final int index = t.getIndex(j); |
| 6442 |
mAttributeSourceResId.append(styleable[index], t.getSourceResourceId(index, 0)); |
| 6443 |
mAttributeResolutionStacks.append(styleable[index], attributeResolutionStack); |
| 6444 |
} |
| 6445 |
} |
| 6446 |
|
| 6447 |
private void saveAttributeData(@Nullable AttributeSet attrs, @NonNull TypedArray t) { |
| 6448 |
final int attrsCount = attrs == null ? 0 : attrs.getAttributeCount(); |
| 6449 |
final int indexCount = t.getIndexCount(); |
| 6450 |
final String[] attributes = new String[(attrsCount + indexCount) * 2]; |
| 6451 |
|
| 6452 |
int i = 0; |
| 6453 |
|
| 6454 |
|
| 6455 |
for (int j = 0; j < attrsCount; ++j) { |
| 6456 |
attributes[i] = attrs.getAttributeName(j); |
| 6457 |
attributes[i + 1] = attrs.getAttributeValue(j); |
| 6458 |
i += 2; |
| 6459 |
} |
| 6460 |
|
| 6461 |
|
| 6462 |
final Resources res = t.getResources(); |
| 6463 |
final SparseArray<String> attributeMap = getAttributeMap(); |
| 6464 |
for (int j = 0; j < indexCount; ++j) { |
| 6465 |
final int index = t.getIndex(j); |
| 6466 |
if (!t.hasValueOrEmpty(index)) { |
| 6467 |
|
| 6468 |
continue; |
| 6469 |
} |
| 6470 |
|
| 6471 |
final int resourceId = t.getResourceId(index, 0); |
| 6472 |
if (resourceId == 0) { |
| 6473 |
|
| 6474 |
continue; |
| 6475 |
} |
| 6476 |
|
| 6477 |
String resourceName = attributeMap.get(resourceId); |
| 6478 |
if (resourceName == null) { |
| 6479 |
try { |
| 6480 |
resourceName = res.getResourceName(resourceId); |
| 6481 |
} catch (Resources.NotFoundException e) { |
| 6482 |
resourceName = "0x" + Integer.toHexString(resourceId); |
| 6483 |
} |
| 6484 |
attributeMap.put(resourceId, resourceName); |
| 6485 |
} |
| 6486 |
|
| 6487 |
attributes[i] = resourceName; |
| 6488 |
attributes[i + 1] = t.getString(index); |
| 6489 |
i += 2; |
| 6490 |
} |
| 6491 |
|
| 6492 |
|
| 6493 |
final String[] trimmed = new String[i]; |
| 6494 |
System.arraycopy(attributes, 0, trimmed, 0, i); |
| 6495 |
mAttributes = trimmed; |
| 6496 |
} |
| 6497 |
|
| 6498 |
@Override |
| 6499 |
public String toString() { |
| 6500 |
StringBuilder out = new StringBuilder(256); |
| 6501 |
out.append(getClass().getName()); |
| 6502 |
out.append('{'); |
| 6503 |
out.append(Integer.toHexString(System.identityHashCode(this))); |
| 6504 |
out.append(' '); |
| 6505 |
switch (mViewFlags&VISIBILITY_MASK) { |
| 6506 |
case VISIBLE: out.append('V'); break; |
| 6507 |
case INVISIBLE: out.append('I'); break; |
| 6508 |
case GONE: out.append('G'); break; |
| 6509 |
default: out.append('.'); break; |
| 6510 |
} |
| 6511 |
out.append((mViewFlags & FOCUSABLE) == FOCUSABLE ? 'F' : '.'); |
| 6512 |
out.append((mViewFlags&ENABLED_MASK) == ENABLED ? 'E' : '.'); |
| 6513 |
out.append((mViewFlags&DRAW_MASK) == WILL_NOT_DRAW ? '.' : 'D'); |
| 6514 |
out.append((mViewFlags&SCROLLBARS_HORIZONTAL) != 0 ? 'H' : '.'); |
| 6515 |
out.append((mViewFlags&SCROLLBARS_VERTICAL) != 0 ? 'V' : '.'); |
| 6516 |
out.append((mViewFlags&CLICKABLE) != 0 ? 'C' : '.'); |
| 6517 |
out.append((mViewFlags&LONG_CLICKABLE) != 0 ? 'L' : '.'); |
| 6518 |
out.append((mViewFlags&CONTEXT_CLICKABLE) != 0 ? 'X' : '.'); |
| 6519 |
out.append(' '); |
| 6520 |
out.append((mPrivateFlags&PFLAG_IS_ROOT_NAMESPACE) != 0 ? 'R' : '.'); |
| 6521 |
out.append((mPrivateFlags&PFLAG_FOCUSED) != 0 ? 'F' : '.'); |
| 6522 |
out.append((mPrivateFlags&PFLAG_SELECTED) != 0 ? 'S' : '.'); |
| 6523 |
if ((mPrivateFlags&PFLAG_PREPRESSED) != 0) { |
| 6524 |
out.append('p'); |
| 6525 |
} else { |
| 6526 |
out.append((mPrivateFlags&PFLAG_PRESSED) != 0 ? 'P' : '.'); |
| 6527 |
} |
| 6528 |
out.append((mPrivateFlags&PFLAG_HOVERED) != 0 ? 'H' : '.'); |
| 6529 |
out.append((mPrivateFlags&PFLAG_ACTIVATED) != 0 ? 'A' : '.'); |
| 6530 |
out.append((mPrivateFlags&PFLAG_INVALIDATED) != 0 ? 'I' : '.'); |
| 6531 |
out.append((mPrivateFlags&PFLAG_DIRTY_MASK) != 0 ? 'D' : '.'); |
| 6532 |
out.append(' '); |
| 6533 |
out.append(mLeft); |
| 6534 |
out.append(','); |
| 6535 |
out.append(mTop); |
| 6536 |
out.append('-'); |
| 6537 |
out.append(mRight); |
| 6538 |
out.append(','); |
| 6539 |
out.append(mBottom); |
| 6540 |
final int id = getId(); |
| 6541 |
if (id != NO_ID) { |
| 6542 |
out.append(" #"); |
| 6543 |
out.append(Integer.toHexString(id)); |
| 6544 |
final Resources r = mResources; |
| 6545 |
if (id > 0 && Resources.resourceHasPackage(id) && r != null) { |
| 6546 |
try { |
| 6547 |
String pkgname; |
| 6548 |
switch (id&0xff000000) { |
| 6549 |
case 0x7f000000: |
| 6550 |
pkgname="app"; |
| 6551 |
break; |
| 6552 |
case 0x01000000: |
| 6553 |
pkgname="android"; |
| 6554 |
break; |
| 6555 |
default: |
| 6556 |
pkgname = r.getResourcePackageName(id); |
| 6557 |
break; |
| 6558 |
} |
| 6559 |
String typename = r.getResourceTypeName(id); |
| 6560 |
String entryname = r.getResourceEntryName(id); |
| 6561 |
out.append(" "); |
| 6562 |
out.append(pkgname); |
| 6563 |
out.append(":"); |
| 6564 |
out.append(typename); |
| 6565 |
out.append("/"); |
| 6566 |
out.append(entryname); |
| 6567 |
} catch (Resources.NotFoundException e) { |
| 6568 |
} |
| 6569 |
} |
| 6570 |
} |
| 6571 |
if (mAutofillId != null) { |
| 6572 |
out.append(" aid="); out.append(mAutofillId); |
| 6573 |
} |
| 6574 |
out.append("}"); |
| 6575 |
return out.toString(); |
| 6576 |
} |
| 6577 |
|
| 6578 |
|
| 6579 |
|
| 6580 |
|
| 6581 |
|
| 6582 |
|
| 6583 |
|
| 6584 |
|
| 6585 |
|
| 6586 |
|
| 6587 |
|
| 6588 |
|
| 6589 |
|
| 6590 |
|
| 6591 |
protected void initializeFadingEdge(TypedArray a) { |
| 6592 |
|
| 6593 |
|
| 6594 |
|
| 6595 |
|
| 6596 |
|
| 6597 |
|
| 6598 |
TypedArray arr = mContext.obtainStyledAttributes(com.android.internal.R.styleable.View); |
| 6599 |
|
| 6600 |
initializeFadingEdgeInternal(arr); |
| 6601 |
|
| 6602 |
arr.recycle(); |
| 6603 |
} |
| 6604 |
|
| 6605 |
|
| 6606 |
|
| 6607 |
|
| 6608 |
|
| 6609 |
|
| 6610 |
|
| 6611 |
|
| 6612 |
|
| 6613 |
|
| 6614 |
|
| 6615 |
|
| 6616 |
|
| 6617 |
protected void initializeFadingEdgeInternal(TypedArray a) { |
| 6618 |
initScrollCache(); |
| 6619 |
|
| 6620 |
mScrollCache.fadingEdgeLength = a.getDimensionPixelSize( |
| 6621 |
R.styleable.View_fadingEdgeLength, |
| 6622 |
ViewConfiguration.get(mContext).getScaledFadingEdgeLength()); |
| 6623 |
} |
| 6624 |
|
| 6625 |
|
| 6626 |
|
| 6627 |
|
| 6628 |
|
| 6629 |
|
| 6630 |
|
| 6631 |
|
| 6632 |
|
| 6633 |
public int getVerticalFadingEdgeLength() { |
| 6634 |
if (isVerticalFadingEdgeEnabled()) { |
| 6635 |
ScrollabilityCache cache = mScrollCache; |
| 6636 |
if (cache != null) { |
| 6637 |
return cache.fadingEdgeLength; |
| 6638 |
} |
| 6639 |
} |
| 6640 |
return 0; |
| 6641 |
} |
| 6642 |
|
| 6643 |
|
| 6644 |
|
| 6645 |
|
| 6646 |
|
| 6647 |
|
| 6648 |
|
| 6649 |
|
| 6650 |
|
| 6651 |
|
| 6652 |
|
| 6653 |
public void setFadingEdgeLength(int length) { |
| 6654 |
initScrollCache(); |
| 6655 |
mScrollCache.fadingEdgeLength = length; |
| 6656 |
} |
| 6657 |
|
| 6658 |
|
| 6659 |
|
| 6660 |
|
| 6661 |
|
| 6662 |
|
| 6663 |
|
| 6664 |
|
| 6665 |
|
| 6666 |
public int getHorizontalFadingEdgeLength() { |
| 6667 |
if (isHorizontalFadingEdgeEnabled()) { |
| 6668 |
ScrollabilityCache cache = mScrollCache; |
| 6669 |
if (cache != null) { |
| 6670 |
return cache.fadingEdgeLength; |
| 6671 |
} |
| 6672 |
} |
| 6673 |
return 0; |
| 6674 |
} |
| 6675 |
|
| 6676 |
|
| 6677 |
|
| 6678 |
|
| 6679 |
|
| 6680 |
|
| 6681 |
|
| 6682 |
public int getVerticalScrollbarWidth() { |
| 6683 |
ScrollabilityCache cache = mScrollCache; |
| 6684 |
if (cache != null) { |
| 6685 |
ScrollBarDrawable scrollBar = cache.scrollBar; |
| 6686 |
if (scrollBar != null) { |
| 6687 |
int size = scrollBar.getSize(true); |
| 6688 |
if (size <= 0) { |
| 6689 |
size = cache.scrollBarSize; |
| 6690 |
} |
| 6691 |
return size; |
| 6692 |
} |
| 6693 |
return 0; |
| 6694 |
} |
| 6695 |
return 0; |
| 6696 |
} |
| 6697 |
|
| 6698 |
|
| 6699 |
|
| 6700 |
|
| 6701 |
|
| 6702 |
|
| 6703 |
|
| 6704 |
protected int getHorizontalScrollbarHeight() { |
| 6705 |
ScrollabilityCache cache = mScrollCache; |
| 6706 |
if (cache != null) { |
| 6707 |
ScrollBarDrawable scrollBar = cache.scrollBar; |
| 6708 |
if (scrollBar != null) { |
| 6709 |
int size = scrollBar.getSize(false); |
| 6710 |
if (size <= 0) { |
| 6711 |
size = cache.scrollBarSize; |
| 6712 |
} |
| 6713 |
return size; |
| 6714 |
} |
| 6715 |
return 0; |
| 6716 |
} |
| 6717 |
return 0; |
| 6718 |
} |
| 6719 |
|
| 6720 |
|
| 6721 |
|
| 6722 |
|
| 6723 |
|
| 6724 |
|
| 6725 |
|
| 6726 |
|
| 6727 |
|
| 6728 |
|
| 6729 |
|
| 6730 |
|
| 6731 |
|
| 6732 |
|
| 6733 |
protected void initializeScrollbars(TypedArray a) { |
| 6734 |
|
| 6735 |
|
| 6736 |
|
| 6737 |
|
| 6738 |
TypedArray arr = mContext.obtainStyledAttributes(com.android.internal.R.styleable.View); |
| 6739 |
|
| 6740 |
initializeScrollbarsInternal(arr); |
| 6741 |
|
| 6742 |
|
| 6743 |
arr.recycle(); |
| 6744 |
} |
| 6745 |
|
| 6746 |
private void initializeScrollBarDrawable() { |
| 6747 |
initScrollCache(); |
| 6748 |
|
| 6749 |
if (mScrollCache.scrollBar == null) { |
| 6750 |
mScrollCache.scrollBar = new ScrollBarDrawable(); |
| 6751 |
mScrollCache.scrollBar.setState(getDrawableState()); |
| 6752 |
mScrollCache.scrollBar.setCallback(this); |
| 6753 |
} |
| 6754 |
} |
| 6755 |
|
| 6756 |
|
| 6757 |
|
| 6758 |
|
| 6759 |
|
| 6760 |
|
| 6761 |
|
| 6762 |
|
| 6763 |
|
| 6764 |
|
| 6765 |
|
| 6766 |
|
| 6767 |
|
| 6768 |
@UnsupportedAppUsage |
| 6769 |
protected void initializeScrollbarsInternal(TypedArray a) { |
| 6770 |
initScrollCache(); |
| 6771 |
|
| 6772 |
final ScrollabilityCache scrollabilityCache = mScrollCache; |
| 6773 |
|
| 6774 |
if (scrollabilityCache.scrollBar == null) { |
| 6775 |
scrollabilityCache.scrollBar = new ScrollBarDrawable(); |
| 6776 |
scrollabilityCache.scrollBar.setState(getDrawableState()); |
| 6777 |
scrollabilityCache.scrollBar.setCallback(this); |
| 6778 |
} |
| 6779 |
|
| 6780 |
final boolean fadeScrollbars = a.getBoolean(R.styleable.View_fadeScrollbars, true); |
| 6781 |
|
| 6782 |
if (!fadeScrollbars) { |
| 6783 |
scrollabilityCache.state = ScrollabilityCache.ON; |
| 6784 |
} |
| 6785 |
scrollabilityCache.fadeScrollBars = fadeScrollbars; |
| 6786 |
|
| 6787 |
|
| 6788 |
scrollabilityCache.scrollBarFadeDuration = a.getInt( |
| 6789 |
R.styleable.View_scrollbarFadeDuration, ViewConfiguration |
| 6790 |
.getScrollBarFadeDuration()); |
| 6791 |
scrollabilityCache.scrollBarDefaultDelayBeforeFade = a.getInt( |
| 6792 |
R.styleable.View_scrollbarDefaultDelayBeforeFade, |
| 6793 |
ViewConfiguration.getScrollDefaultDelay()); |
| 6794 |
|
| 6795 |
|
| 6796 |
scrollabilityCache.scrollBarSize = a.getDimensionPixelSize( |
| 6797 |
com.android.internal.R.styleable.View_scrollbarSize, |
| 6798 |
ViewConfiguration.get(mContext).getScaledScrollBarSize()); |
| 6799 |
|
| 6800 |
Drawable track = a.getDrawable(R.styleable.View_scrollbarTrackHorizontal); |
| 6801 |
scrollabilityCache.scrollBar.setHorizontalTrackDrawable(track); |
| 6802 |
|
| 6803 |
Drawable thumb = a.getDrawable(R.styleable.View_scrollbarThumbHorizontal); |
| 6804 |
if (thumb != null) { |
| 6805 |
scrollabilityCache.scrollBar.setHorizontalThumbDrawable(thumb); |
| 6806 |
} |
| 6807 |
|
| 6808 |
boolean alwaysDraw = a.getBoolean(R.styleable.View_scrollbarAlwaysDrawHorizontalTrack, |
| 6809 |
false); |
| 6810 |
if (alwaysDraw) { |
| 6811 |
scrollabilityCache.scrollBar.setAlwaysDrawHorizontalTrack(true); |
| 6812 |
} |
| 6813 |
|
| 6814 |
track = a.getDrawable(R.styleable.View_scrollbarTrackVertical); |
| 6815 |
scrollabilityCache.scrollBar.setVerticalTrackDrawable(track); |
| 6816 |
|
| 6817 |
thumb = a.getDrawable(R.styleable.View_scrollbarThumbVertical); |
| 6818 |
if (thumb != null) { |
| 6819 |
scrollabilityCache.scrollBar.setVerticalThumbDrawable(thumb); |
| 6820 |
} |
| 6821 |
|
| 6822 |
alwaysDraw = a.getBoolean(R.styleable.View_scrollbarAlwaysDrawVerticalTrack, |
| 6823 |
false); |
| 6824 |
if (alwaysDraw) { |
| 6825 |
scrollabilityCache.scrollBar.setAlwaysDrawVerticalTrack(true); |
| 6826 |
} |
| 6827 |
|
| 6828 |
|
| 6829 |
final int layoutDirection = getLayoutDirection(); |
| 6830 |
if (track != null) { |
| 6831 |
track.setLayoutDirection(layoutDirection); |
| 6832 |
} |
| 6833 |
if (thumb != null) { |
| 6834 |
thumb.setLayoutDirection(layoutDirection); |
| 6835 |
} |
| 6836 |
|
| 6837 |
|
| 6838 |
resolvePadding(); |
| 6839 |
} |
| 6840 |
|
| 6841 |
|
| 6842 |
|
| 6843 |
|
| 6844 |
|
| 6845 |
|
| 6846 |
|
| 6847 |
|
| 6848 |
|
| 6849 |
public void setVerticalScrollbarThumbDrawable(@Nullable Drawable drawable) { |
| 6850 |
initializeScrollBarDrawable(); |
| 6851 |
mScrollCache.scrollBar.setVerticalThumbDrawable(drawable); |
| 6852 |
} |
| 6853 |
|
| 6854 |
|
| 6855 |
|
| 6856 |
|
| 6857 |
|
| 6858 |
|
| 6859 |
|
| 6860 |
|
| 6861 |
|
| 6862 |
public void setVerticalScrollbarTrackDrawable(@Nullable Drawable drawable) { |
| 6863 |
initializeScrollBarDrawable(); |
| 6864 |
mScrollCache.scrollBar.setVerticalTrackDrawable(drawable); |
| 6865 |
} |
| 6866 |
|
| 6867 |
|
| 6868 |
|
| 6869 |
|
| 6870 |
|
| 6871 |
|
| 6872 |
|
| 6873 |
|
| 6874 |
|
| 6875 |
public void setHorizontalScrollbarThumbDrawable(@Nullable Drawable drawable) { |
| 6876 |
initializeScrollBarDrawable(); |
| 6877 |
mScrollCache.scrollBar.setHorizontalThumbDrawable(drawable); |
| 6878 |
} |
| 6879 |
|
| 6880 |
|
| 6881 |
|
| 6882 |
|
| 6883 |
|
| 6884 |
|
| 6885 |
|
| 6886 |
|
| 6887 |
|
| 6888 |
public void setHorizontalScrollbarTrackDrawable(@Nullable Drawable drawable) { |
| 6889 |
initializeScrollBarDrawable(); |
| 6890 |
mScrollCache.scrollBar.setHorizontalTrackDrawable(drawable); |
| 6891 |
} |
| 6892 |
|
| 6893 |
|
| 6894 |
|
| 6895 |
|
| 6896 |
|
| 6897 |
|
| 6898 |
|
| 6899 |
|
| 6900 |
|
| 6901 |
public @Nullable Drawable getVerticalScrollbarThumbDrawable() { |
| 6902 |
return mScrollCache != null ? mScrollCache.scrollBar.getVerticalThumbDrawable() : null; |
| 6903 |
} |
| 6904 |
|
| 6905 |
|
| 6906 |
|
| 6907 |
|
| 6908 |
|
| 6909 |
|
| 6910 |
|
| 6911 |
|
| 6912 |
|
| 6913 |
public @Nullable Drawable getVerticalScrollbarTrackDrawable() { |
| 6914 |
return mScrollCache != null ? mScrollCache.scrollBar.getVerticalTrackDrawable() : null; |
| 6915 |
} |
| 6916 |
|
| 6917 |
|
| 6918 |
|
| 6919 |
|
| 6920 |
|
| 6921 |
|
| 6922 |
|
| 6923 |
|
| 6924 |
|
| 6925 |
public @Nullable Drawable getHorizontalScrollbarThumbDrawable() { |
| 6926 |
return mScrollCache != null ? mScrollCache.scrollBar.getHorizontalThumbDrawable() : null; |
| 6927 |
} |
| 6928 |
|
| 6929 |
|
| 6930 |
|
| 6931 |
|
| 6932 |
|
| 6933 |
|
| 6934 |
|
| 6935 |
|
| 6936 |
|
| 6937 |
public @Nullable Drawable getHorizontalScrollbarTrackDrawable() { |
| 6938 |
return mScrollCache != null ? mScrollCache.scrollBar.getHorizontalTrackDrawable() : null; |
| 6939 |
} |
| 6940 |
|
| 6941 |
private void initializeScrollIndicatorsInternal() { |
| 6942 |
|
| 6943 |
|
| 6944 |
|
| 6945 |
if (mScrollIndicatorDrawable == null) { |
| 6946 |
mScrollIndicatorDrawable = mContext.getDrawable(R.drawable.scroll_indicator_material); |
| 6947 |
} |
| 6948 |
} |
| 6949 |
|
| 6950 |
|
| 6951 |
|
| 6952 |
|
| 6953 |
|
| 6954 |
|
| 6955 |
private void initScrollCache() { |
| 6956 |
if (mScrollCache == null) { |
| 6957 |
mScrollCache = new ScrollabilityCache(ViewConfiguration.get(mContext), this); |
| 6958 |
} |
| 6959 |
} |
| 6960 |
|
| 6961 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 6962 |
private ScrollabilityCache getScrollCache() { |
| 6963 |
initScrollCache(); |
| 6964 |
return mScrollCache; |
| 6965 |
} |
| 6966 |
|
| 6967 |
|
| 6968 |
|
| 6969 |
|
| 6970 |
|
| 6971 |
|
| 6972 |
|
| 6973 |
|
| 6974 |
public void setVerticalScrollbarPosition(int position) { |
| 6975 |
if (mVerticalScrollbarPosition != position) { |
| 6976 |
mVerticalScrollbarPosition = position; |
| 6977 |
computeOpaqueFlags(); |
| 6978 |
resolvePadding(); |
| 6979 |
} |
| 6980 |
} |
| 6981 |
|
| 6982 |
|
| 6983 |
|
| 6984 |
|
| 6985 |
|
| 6986 |
public int getVerticalScrollbarPosition() { |
| 6987 |
return mVerticalScrollbarPosition; |
| 6988 |
} |
| 6989 |
|
| 6990 |
boolean isOnScrollbar(float x, float y) { |
| 6991 |
if (mScrollCache == null) { |
| 6992 |
return false; |
| 6993 |
} |
| 6994 |
x += getScrollX(); |
| 6995 |
y += getScrollY(); |
| 6996 |
final boolean canScrollVertically = |
| 6997 |
computeVerticalScrollRange() > computeVerticalScrollExtent(); |
| 6998 |
if (isVerticalScrollBarEnabled() && !isVerticalScrollBarHidden() && canScrollVertically) { |
| 6999 |
final Rect touchBounds = mScrollCache.mScrollBarTouchBounds; |
| 7000 |
getVerticalScrollBarBounds(null, touchBounds); |
| 7001 |
if (touchBounds.contains((int) x, (int) y)) { |
| 7002 |
return true; |
| 7003 |
} |
| 7004 |
} |
| 7005 |
final boolean canScrollHorizontally = |
| 7006 |
computeHorizontalScrollRange() > computeHorizontalScrollExtent(); |
| 7007 |
if (isHorizontalScrollBarEnabled() && canScrollHorizontally) { |
| 7008 |
final Rect touchBounds = mScrollCache.mScrollBarTouchBounds; |
| 7009 |
getHorizontalScrollBarBounds(null, touchBounds); |
| 7010 |
if (touchBounds.contains((int) x, (int) y)) { |
| 7011 |
return true; |
| 7012 |
} |
| 7013 |
} |
| 7014 |
return false; |
| 7015 |
} |
| 7016 |
|
| 7017 |
@UnsupportedAppUsage |
| 7018 |
boolean isOnScrollbarThumb(float x, float y) { |
| 7019 |
return isOnVerticalScrollbarThumb(x, y) || isOnHorizontalScrollbarThumb(x, y); |
| 7020 |
} |
| 7021 |
|
| 7022 |
private boolean isOnVerticalScrollbarThumb(float x, float y) { |
| 7023 |
if (mScrollCache == null || !isVerticalScrollBarEnabled() || isVerticalScrollBarHidden()) { |
| 7024 |
return false; |
| 7025 |
} |
| 7026 |
final int range = computeVerticalScrollRange(); |
| 7027 |
final int extent = computeVerticalScrollExtent(); |
| 7028 |
if (range > extent) { |
| 7029 |
x += getScrollX(); |
| 7030 |
y += getScrollY(); |
| 7031 |
final Rect bounds = mScrollCache.mScrollBarBounds; |
| 7032 |
final Rect touchBounds = mScrollCache.mScrollBarTouchBounds; |
| 7033 |
getVerticalScrollBarBounds(bounds, touchBounds); |
| 7034 |
final int offset = computeVerticalScrollOffset(); |
| 7035 |
final int thumbLength = ScrollBarUtils.getThumbLength(bounds.height(), bounds.width(), |
| 7036 |
extent, range); |
| 7037 |
final int thumbOffset = ScrollBarUtils.getThumbOffset(bounds.height(), thumbLength, |
| 7038 |
extent, range, offset); |
| 7039 |
final int thumbTop = bounds.top + thumbOffset; |
| 7040 |
final int adjust = Math.max(mScrollCache.scrollBarMinTouchTarget - thumbLength, 0) / 2; |
| 7041 |
if (x >= touchBounds.left && x <= touchBounds.right |
| 7042 |
&& y >= thumbTop - adjust && y <= thumbTop + thumbLength + adjust) { |
| 7043 |
return true; |
| 7044 |
} |
| 7045 |
} |
| 7046 |
return false; |
| 7047 |
} |
| 7048 |
|
| 7049 |
private boolean isOnHorizontalScrollbarThumb(float x, float y) { |
| 7050 |
if (mScrollCache == null || !isHorizontalScrollBarEnabled()) { |
| 7051 |
return false; |
| 7052 |
} |
| 7053 |
final int range = computeHorizontalScrollRange(); |
| 7054 |
final int extent = computeHorizontalScrollExtent(); |
| 7055 |
if (range > extent) { |
| 7056 |
x += getScrollX(); |
| 7057 |
y += getScrollY(); |
| 7058 |
final Rect bounds = mScrollCache.mScrollBarBounds; |
| 7059 |
final Rect touchBounds = mScrollCache.mScrollBarTouchBounds; |
| 7060 |
getHorizontalScrollBarBounds(bounds, touchBounds); |
| 7061 |
final int offset = computeHorizontalScrollOffset(); |
| 7062 |
|
| 7063 |
final int thumbLength = ScrollBarUtils.getThumbLength(bounds.width(), bounds.height(), |
| 7064 |
extent, range); |
| 7065 |
final int thumbOffset = ScrollBarUtils.getThumbOffset(bounds.width(), thumbLength, |
| 7066 |
extent, range, offset); |
| 7067 |
final int thumbLeft = bounds.left + thumbOffset; |
| 7068 |
final int adjust = Math.max(mScrollCache.scrollBarMinTouchTarget - thumbLength, 0) / 2; |
| 7069 |
if (x >= thumbLeft - adjust && x <= thumbLeft + thumbLength + adjust |
| 7070 |
&& y >= touchBounds.top && y <= touchBounds.bottom) { |
| 7071 |
return true; |
| 7072 |
} |
| 7073 |
} |
| 7074 |
return false; |
| 7075 |
} |
| 7076 |
|
| 7077 |
@UnsupportedAppUsage |
| 7078 |
boolean isDraggingScrollBar() { |
| 7079 |
return mScrollCache != null |
| 7080 |
&& mScrollCache.mScrollBarDraggingState != ScrollabilityCache.NOT_DRAGGING; |
| 7081 |
} |
| 7082 |
|
| 7083 |
|
| 7084 |
|
| 7085 |
|
| 7086 |
|
| 7087 |
|
| 7088 |
|
| 7089 |
|
| 7090 |
|
| 7091 |
|
| 7092 |
|
| 7093 |
|
| 7094 |
@RemotableViewMethod |
| 7095 |
public void setScrollIndicators(@ScrollIndicators int indicators) { |
| 7096 |
setScrollIndicators(indicators, |
| 7097 |
SCROLL_INDICATORS_PFLAG3_MASK >>> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT); |
| 7098 |
} |
| 7099 |
|
| 7100 |
|
| 7101 |
|
| 7102 |
|
| 7103 |
|
| 7104 |
|
| 7105 |
|
| 7106 |
|
| 7107 |
|
| 7108 |
|
| 7109 |
|
| 7110 |
|
| 7111 |
|
| 7112 |
|
| 7113 |
|
| 7114 |
|
| 7115 |
|
| 7116 |
|
| 7117 |
|
| 7118 |
|
| 7119 |
|
| 7120 |
|
| 7121 |
|
| 7122 |
|
| 7123 |
|
| 7124 |
|
| 7125 |
|
| 7126 |
|
| 7127 |
public void setScrollIndicators(@ScrollIndicators int indicators, @ScrollIndicators int mask) { |
| 7128 |
|
| 7129 |
mask <<= SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; |
| 7130 |
mask &= SCROLL_INDICATORS_PFLAG3_MASK; |
| 7131 |
|
| 7132 |
|
| 7133 |
indicators <<= SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; |
| 7134 |
indicators &= mask; |
| 7135 |
|
| 7136 |
|
| 7137 |
final int updatedFlags = indicators | (mPrivateFlags3 & ~mask); |
| 7138 |
|
| 7139 |
if (mPrivateFlags3 != updatedFlags) { |
| 7140 |
mPrivateFlags3 = updatedFlags; |
| 7141 |
|
| 7142 |
if (indicators != 0) { |
| 7143 |
initializeScrollIndicatorsInternal(); |
| 7144 |
} |
| 7145 |
invalidate(); |
| 7146 |
} |
| 7147 |
} |
| 7148 |
|
| 7149 |
|
| 7150 |
|
| 7151 |
|
| 7152 |
|
| 7153 |
|
| 7154 |
|
| 7155 |
|
| 7156 |
|
| 7157 |
|
| 7158 |
|
| 7159 |
|
| 7160 |
|
| 7161 |
@InspectableProperty(flagMapping = { |
| 7162 |
@FlagEntry(target = SCROLL_INDICATORS_NONE, mask = 0xffff_ffff, name = "none"), |
| 7163 |
@FlagEntry(target = SCROLL_INDICATOR_TOP, name = "top"), |
| 7164 |
@FlagEntry(target = SCROLL_INDICATOR_BOTTOM, name = "bottom"), |
| 7165 |
@FlagEntry(target = SCROLL_INDICATOR_LEFT, name = "left"), |
| 7166 |
@FlagEntry(target = SCROLL_INDICATOR_RIGHT, name = "right"), |
| 7167 |
@FlagEntry(target = SCROLL_INDICATOR_START, name = "start"), |
| 7168 |
@FlagEntry(target = SCROLL_INDICATOR_END, name = "end") |
| 7169 |
}) |
| 7170 |
@ScrollIndicators |
| 7171 |
public int getScrollIndicators() { |
| 7172 |
return (mPrivateFlags3 & SCROLL_INDICATORS_PFLAG3_MASK) |
| 7173 |
>>> SCROLL_INDICATORS_TO_PFLAGS3_LSHIFT; |
| 7174 |
} |
| 7175 |
|
| 7176 |
@UnsupportedAppUsage |
| 7177 |
ListenerInfo getListenerInfo() { |
| 7178 |
if (mListenerInfo != null) { |
| 7179 |
return mListenerInfo; |
| 7180 |
} |
| 7181 |
mListenerInfo = new ListenerInfo(); |
| 7182 |
return mListenerInfo; |
| 7183 |
} |
| 7184 |
|
| 7185 |
|
| 7186 |
|
| 7187 |
|
| 7188 |
|
| 7189 |
|
| 7190 |
|
| 7191 |
|
| 7192 |
|
| 7193 |
|
| 7194 |
|
| 7195 |
|
| 7196 |
|
| 7197 |
|
| 7198 |
|
| 7199 |
public void setOnScrollChangeListener(OnScrollChangeListener l) { |
| 7200 |
getListenerInfo().mOnScrollChangeListener = l; |
| 7201 |
} |
| 7202 |
|
| 7203 |
|
| 7204 |
|
| 7205 |
|
| 7206 |
|
| 7207 |
|
| 7208 |
public void setOnFocusChangeListener(OnFocusChangeListener l) { |
| 7209 |
getListenerInfo().mOnFocusChangeListener = l; |
| 7210 |
} |
| 7211 |
|
| 7212 |
|
| 7213 |
|
| 7214 |
|
| 7215 |
|
| 7216 |
|
| 7217 |
|
| 7218 |
public void addOnLayoutChangeListener(OnLayoutChangeListener listener) { |
| 7219 |
ListenerInfo li = getListenerInfo(); |
| 7220 |
if (li.mOnLayoutChangeListeners == null) { |
| 7221 |
li.mOnLayoutChangeListeners = new ArrayList<OnLayoutChangeListener>(); |
| 7222 |
} |
| 7223 |
if (!li.mOnLayoutChangeListeners.contains(listener)) { |
| 7224 |
li.mOnLayoutChangeListeners.add(listener); |
| 7225 |
} |
| 7226 |
} |
| 7227 |
|
| 7228 |
|
| 7229 |
|
| 7230 |
|
| 7231 |
|
| 7232 |
|
| 7233 |
public void removeOnLayoutChangeListener(OnLayoutChangeListener listener) { |
| 7234 |
ListenerInfo li = mListenerInfo; |
| 7235 |
if (li == null || li.mOnLayoutChangeListeners == null) { |
| 7236 |
return; |
| 7237 |
} |
| 7238 |
li.mOnLayoutChangeListeners.remove(listener); |
| 7239 |
} |
| 7240 |
|
| 7241 |
|
| 7242 |
|
| 7243 |
|
| 7244 |
|
| 7245 |
|
| 7246 |
|
| 7247 |
|
| 7248 |
|
| 7249 |
|
| 7250 |
|
| 7251 |
public void addOnAttachStateChangeListener(OnAttachStateChangeListener listener) { |
| 7252 |
ListenerInfo li = getListenerInfo(); |
| 7253 |
if (li.mOnAttachStateChangeListeners == null) { |
| 7254 |
li.mOnAttachStateChangeListeners |
| 7255 |
= new CopyOnWriteArrayList<OnAttachStateChangeListener>(); |
| 7256 |
} |
| 7257 |
li.mOnAttachStateChangeListeners.add(listener); |
| 7258 |
} |
| 7259 |
|
| 7260 |
|
| 7261 |
|
| 7262 |
|
| 7263 |
|
| 7264 |
|
| 7265 |
|
| 7266 |
|
| 7267 |
public void removeOnAttachStateChangeListener(OnAttachStateChangeListener listener) { |
| 7268 |
ListenerInfo li = mListenerInfo; |
| 7269 |
if (li == null || li.mOnAttachStateChangeListeners == null) { |
| 7270 |
return; |
| 7271 |
} |
| 7272 |
li.mOnAttachStateChangeListeners.remove(listener); |
| 7273 |
} |
| 7274 |
|
| 7275 |
|
| 7276 |
|
| 7277 |
|
| 7278 |
|
| 7279 |
|
| 7280 |
public OnFocusChangeListener getOnFocusChangeListener() { |
| 7281 |
ListenerInfo li = mListenerInfo; |
| 7282 |
return li != null ? li.mOnFocusChangeListener : null; |
| 7283 |
} |
| 7284 |
|
| 7285 |
|
| 7286 |
|
| 7287 |
|
| 7288 |
|
| 7289 |
|
| 7290 |
|
| 7291 |
|
| 7292 |
|
| 7293 |
public void setOnClickListener(@Nullable OnClickListener l) { |
| 7294 |
if (!isClickable()) { |
| 7295 |
setClickable(true); |
| 7296 |
} |
| 7297 |
getListenerInfo().mOnClickListener = l; |
| 7298 |
} |
| 7299 |
|
| 7300 |
|
| 7301 |
|
| 7302 |
|
| 7303 |
|
| 7304 |
public boolean hasOnClickListeners() { |
| 7305 |
ListenerInfo li = mListenerInfo; |
| 7306 |
return (li != null && li.mOnClickListener != null); |
| 7307 |
} |
| 7308 |
|
| 7309 |
|
| 7310 |
|
| 7311 |
|
| 7312 |
|
| 7313 |
|
| 7314 |
|
| 7315 |
|
| 7316 |
|
| 7317 |
public void setOnLongClickListener(@Nullable OnLongClickListener l) { |
| 7318 |
if (!isLongClickable()) { |
| 7319 |
setLongClickable(true); |
| 7320 |
} |
| 7321 |
getListenerInfo().mOnLongClickListener = l; |
| 7322 |
} |
| 7323 |
|
| 7324 |
|
| 7325 |
|
| 7326 |
|
| 7327 |
|
| 7328 |
public boolean hasOnLongClickListeners() { |
| 7329 |
ListenerInfo li = mListenerInfo; |
| 7330 |
return (li != null && li.mOnLongClickListener != null); |
| 7331 |
} |
| 7332 |
|
| 7333 |
|
| 7334 |
|
| 7335 |
|
| 7336 |
|
| 7337 |
@Nullable |
| 7338 |
public OnLongClickListener getOnLongClickListener() { |
| 7339 |
ListenerInfo li = mListenerInfo; |
| 7340 |
return (li != null) ? li.mOnLongClickListener : null; |
| 7341 |
} |
| 7342 |
|
| 7343 |
|
| 7344 |
|
| 7345 |
|
| 7346 |
|
| 7347 |
|
| 7348 |
|
| 7349 |
|
| 7350 |
public void setOnContextClickListener(@Nullable OnContextClickListener l) { |
| 7351 |
if (!isContextClickable()) { |
| 7352 |
setContextClickable(true); |
| 7353 |
} |
| 7354 |
getListenerInfo().mOnContextClickListener = l; |
| 7355 |
} |
| 7356 |
|
| 7357 |
|
| 7358 |
|
| 7359 |
|
| 7360 |
|
| 7361 |
|
| 7362 |
|
| 7363 |
|
| 7364 |
public void setOnCreateContextMenuListener(OnCreateContextMenuListener l) { |
| 7365 |
if (!isLongClickable()) { |
| 7366 |
setLongClickable(true); |
| 7367 |
} |
| 7368 |
getListenerInfo().mOnCreateContextMenuListener = l; |
| 7369 |
} |
| 7370 |
|
| 7371 |
|
| 7372 |
|
| 7373 |
|
| 7374 |
|
| 7375 |
|
| 7376 |
public void addFrameMetricsListener(Window window, |
| 7377 |
Window.OnFrameMetricsAvailableListener listener, |
| 7378 |
Handler handler) { |
| 7379 |
if (mAttachInfo != null) { |
| 7380 |
if (mAttachInfo.mThreadedRenderer != null) { |
| 7381 |
if (mFrameMetricsObservers == null) { |
| 7382 |
mFrameMetricsObservers = new ArrayList<>(); |
| 7383 |
} |
| 7384 |
|
| 7385 |
FrameMetricsObserver fmo = new FrameMetricsObserver(window, handler, listener); |
| 7386 |
mFrameMetricsObservers.add(fmo); |
| 7387 |
mAttachInfo.mThreadedRenderer.addObserver(fmo.getRendererObserver()); |
| 7388 |
} else { |
| 7389 |
Log.w(VIEW_LOG_TAG, "View not hardware-accelerated. Unable to observe frame stats"); |
| 7390 |
} |
| 7391 |
} else { |
| 7392 |
if (mFrameMetricsObservers == null) { |
| 7393 |
mFrameMetricsObservers = new ArrayList<>(); |
| 7394 |
} |
| 7395 |
|
| 7396 |
FrameMetricsObserver fmo = new FrameMetricsObserver(window, handler, listener); |
| 7397 |
mFrameMetricsObservers.add(fmo); |
| 7398 |
} |
| 7399 |
} |
| 7400 |
|
| 7401 |
|
| 7402 |
|
| 7403 |
|
| 7404 |
|
| 7405 |
|
| 7406 |
public void removeFrameMetricsListener( |
| 7407 |
Window.OnFrameMetricsAvailableListener listener) { |
| 7408 |
ThreadedRenderer renderer = getThreadedRenderer(); |
| 7409 |
FrameMetricsObserver fmo = findFrameMetricsObserver(listener); |
| 7410 |
if (fmo == null) { |
| 7411 |
throw new IllegalArgumentException( |
| 7412 |
"attempt to remove OnFrameMetricsAvailableListener that was never added"); |
| 7413 |
} |
| 7414 |
|
| 7415 |
if (mFrameMetricsObservers != null) { |
| 7416 |
mFrameMetricsObservers.remove(fmo); |
| 7417 |
if (renderer != null) { |
| 7418 |
renderer.removeObserver(fmo.getRendererObserver()); |
| 7419 |
} |
| 7420 |
} |
| 7421 |
} |
| 7422 |
|
| 7423 |
private void registerPendingFrameMetricsObservers() { |
| 7424 |
if (mFrameMetricsObservers != null) { |
| 7425 |
ThreadedRenderer renderer = getThreadedRenderer(); |
| 7426 |
if (renderer != null) { |
| 7427 |
for (FrameMetricsObserver fmo : mFrameMetricsObservers) { |
| 7428 |
renderer.addObserver(fmo.getRendererObserver()); |
| 7429 |
} |
| 7430 |
} else { |
| 7431 |
Log.w(VIEW_LOG_TAG, "View not hardware-accelerated. Unable to observe frame stats"); |
| 7432 |
} |
| 7433 |
} |
| 7434 |
} |
| 7435 |
|
| 7436 |
private FrameMetricsObserver findFrameMetricsObserver( |
| 7437 |
Window.OnFrameMetricsAvailableListener listener) { |
| 7438 |
if (mFrameMetricsObservers != null) { |
| 7439 |
for (int i = 0; i < mFrameMetricsObservers.size(); i++) { |
| 7440 |
FrameMetricsObserver observer = mFrameMetricsObservers.get(i); |
| 7441 |
if (observer.mListener == listener) { |
| 7442 |
return observer; |
| 7443 |
} |
| 7444 |
} |
| 7445 |
} |
| 7446 |
|
| 7447 |
return null; |
| 7448 |
} |
| 7449 |
|
| 7450 |
|
| 7451 |
public void setNotifyAutofillManagerOnClick(boolean notify) { |
| 7452 |
if (notify) { |
| 7453 |
mPrivateFlags |= PFLAG_NOTIFY_AUTOFILL_MANAGER_ON_CLICK; |
| 7454 |
} else { |
| 7455 |
mPrivateFlags &= ~PFLAG_NOTIFY_AUTOFILL_MANAGER_ON_CLICK; |
| 7456 |
} |
| 7457 |
} |
| 7458 |
|
| 7459 |
private void notifyAutofillManagerOnClick() { |
| 7460 |
if ((mPrivateFlags & PFLAG_NOTIFY_AUTOFILL_MANAGER_ON_CLICK) != 0) { |
| 7461 |
try { |
| 7462 |
getAutofillManager().notifyViewClicked(this); |
| 7463 |
} finally { |
| 7464 |
|
| 7465 |
|
| 7466 |
mPrivateFlags &= ~PFLAG_NOTIFY_AUTOFILL_MANAGER_ON_CLICK; |
| 7467 |
} |
| 7468 |
} |
| 7469 |
} |
| 7470 |
|
| 7471 |
|
| 7472 |
|
| 7473 |
|
| 7474 |
|
| 7475 |
|
| 7476 |
|
| 7477 |
private boolean performClickInternal() { |
| 7478 |
|
| 7479 |
|
| 7480 |
|
| 7481 |
notifyAutofillManagerOnClick(); |
| 7482 |
|
| 7483 |
return performClick(); |
| 7484 |
} |
| 7485 |
|
| 7486 |
|
| 7487 |
|
| 7488 |
|
| 7489 |
|
| 7490 |
|
| 7491 |
|
| 7492 |
|
| 7493 |
|
| 7494 |
|
| 7495 |
|
| 7496 |
|
| 7497 |
public boolean performClick() { |
| 7498 |
|
| 7499 |
|
| 7500 |
notifyAutofillManagerOnClick(); |
| 7501 |
|
| 7502 |
final boolean result; |
| 7503 |
final ListenerInfo li = mListenerInfo; |
| 7504 |
if (li != null && li.mOnClickListener != null) { |
| 7505 |
playSoundEffect(SoundEffectConstants.CLICK); |
| 7506 |
li.mOnClickListener.onClick(this); |
| 7507 |
result = true; |
| 7508 |
} else { |
| 7509 |
result = false; |
| 7510 |
} |
| 7511 |
|
| 7512 |
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CLICKED); |
| 7513 |
|
| 7514 |
notifyEnterOrExitForAutoFillIfNeeded(true); |
| 7515 |
|
| 7516 |
return result; |
| 7517 |
} |
| 7518 |
|
| 7519 |
|
| 7520 |
|
| 7521 |
|
| 7522 |
|
| 7523 |
|
| 7524 |
|
| 7525 |
|
| 7526 |
|
| 7527 |
public boolean callOnClick() { |
| 7528 |
ListenerInfo li = mListenerInfo; |
| 7529 |
if (li != null && li.mOnClickListener != null) { |
| 7530 |
li.mOnClickListener.onClick(this); |
| 7531 |
return true; |
| 7532 |
} |
| 7533 |
return false; |
| 7534 |
} |
| 7535 |
|
| 7536 |
|
| 7537 |
|
| 7538 |
|
| 7539 |
|
| 7540 |
|
| 7541 |
|
| 7542 |
|
| 7543 |
public boolean performLongClick() { |
| 7544 |
return performLongClickInternal(mLongClickX, mLongClickY); |
| 7545 |
} |
| 7546 |
|
| 7547 |
|
| 7548 |
|
| 7549 |
|
| 7550 |
|
| 7551 |
|
| 7552 |
|
| 7553 |
|
| 7554 |
|
| 7555 |
|
| 7556 |
|
| 7557 |
|
| 7558 |
|
| 7559 |
public boolean performLongClick(float x, float y) { |
| 7560 |
mLongClickX = x; |
| 7561 |
mLongClickY = y; |
| 7562 |
final boolean handled = performLongClick(); |
| 7563 |
mLongClickX = Float.NaN; |
| 7564 |
mLongClickY = Float.NaN; |
| 7565 |
return handled; |
| 7566 |
} |
| 7567 |
|
| 7568 |
|
| 7569 |
|
| 7570 |
|
| 7571 |
|
| 7572 |
|
| 7573 |
|
| 7574 |
|
| 7575 |
|
| 7576 |
|
| 7577 |
|
| 7578 |
|
| 7579 |
|
| 7580 |
private boolean performLongClickInternal(float x, float y) { |
| 7581 |
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED); |
| 7582 |
|
| 7583 |
boolean handled = false; |
| 7584 |
final ListenerInfo li = mListenerInfo; |
| 7585 |
if (li != null && li.mOnLongClickListener != null) { |
| 7586 |
handled = li.mOnLongClickListener.onLongClick(View.this); |
| 7587 |
} |
| 7588 |
if (!handled) { |
| 7589 |
final boolean isAnchored = !Float.isNaN(x) && !Float.isNaN(y); |
| 7590 |
handled = isAnchored ? showContextMenu(x, y) : showContextMenu(); |
| 7591 |
} |
| 7592 |
if ((mViewFlags & TOOLTIP) == TOOLTIP) { |
| 7593 |
if (!handled) { |
| 7594 |
handled = showLongClickTooltip((int) x, (int) y); |
| 7595 |
} |
| 7596 |
} |
| 7597 |
if (handled) { |
| 7598 |
performHapticFeedback(HapticFeedbackConstants.LONG_PRESS); |
| 7599 |
} |
| 7600 |
return handled; |
| 7601 |
} |
| 7602 |
|
| 7603 |
|
| 7604 |
|
| 7605 |
|
| 7606 |
|
| 7607 |
|
| 7608 |
|
| 7609 |
|
| 7610 |
|
| 7611 |
public boolean performContextClick(float x, float y) { |
| 7612 |
return performContextClick(); |
| 7613 |
} |
| 7614 |
|
| 7615 |
|
| 7616 |
|
| 7617 |
|
| 7618 |
|
| 7619 |
|
| 7620 |
|
| 7621 |
public boolean performContextClick() { |
| 7622 |
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_CONTEXT_CLICKED); |
| 7623 |
|
| 7624 |
boolean handled = false; |
| 7625 |
ListenerInfo li = mListenerInfo; |
| 7626 |
if (li != null && li.mOnContextClickListener != null) { |
| 7627 |
handled = li.mOnContextClickListener.onContextClick(View.this); |
| 7628 |
} |
| 7629 |
if (handled) { |
| 7630 |
performHapticFeedback(HapticFeedbackConstants.CONTEXT_CLICK); |
| 7631 |
} |
| 7632 |
return handled; |
| 7633 |
} |
| 7634 |
|
| 7635 |
|
| 7636 |
|
| 7637 |
|
| 7638 |
|
| 7639 |
|
| 7640 |
|
| 7641 |
|
| 7642 |
|
| 7643 |
protected boolean performButtonActionOnTouchDown(MotionEvent event) { |
| 7644 |
if (event.isFromSource(InputDevice.SOURCE_MOUSE) && |
| 7645 |
(event.getButtonState() & MotionEvent.BUTTON_SECONDARY) != 0) { |
| 7646 |
showContextMenu(event.getX(), event.getY()); |
| 7647 |
mPrivateFlags |= PFLAG_CANCEL_NEXT_UP_EVENT; |
| 7648 |
return true; |
| 7649 |
} |
| 7650 |
return false; |
| 7651 |
} |
| 7652 |
|
| 7653 |
|
| 7654 |
|
| 7655 |
|
| 7656 |
|
| 7657 |
|
| 7658 |
|
| 7659 |
|
| 7660 |
public boolean showContextMenu() { |
| 7661 |
return getParent().showContextMenuForChild(this); |
| 7662 |
} |
| 7663 |
|
| 7664 |
|
| 7665 |
|
| 7666 |
|
| 7667 |
|
| 7668 |
|
| 7669 |
|
| 7670 |
|
| 7671 |
|
| 7672 |
|
| 7673 |
|
| 7674 |
|
| 7675 |
public boolean showContextMenu(float x, float y) { |
| 7676 |
return getParent().showContextMenuForChild(this, x, y); |
| 7677 |
} |
| 7678 |
|
| 7679 |
|
| 7680 |
|
| 7681 |
|
| 7682 |
|
| 7683 |
|
| 7684 |
|
| 7685 |
|
| 7686 |
|
| 7687 |
|
| 7688 |
public ActionMode startActionMode(ActionMode.Callback callback) { |
| 7689 |
return startActionMode(callback, ActionMode.TYPE_PRIMARY); |
| 7690 |
} |
| 7691 |
|
| 7692 |
|
| 7693 |
|
| 7694 |
|
| 7695 |
|
| 7696 |
|
| 7697 |
|
| 7698 |
|
| 7699 |
|
| 7700 |
|
| 7701 |
public ActionMode startActionMode(ActionMode.Callback callback, int type) { |
| 7702 |
ViewParent parent = getParent(); |
| 7703 |
if (parent == null) return null; |
| 7704 |
try { |
| 7705 |
return parent.startActionModeForChild(this, callback, type); |
| 7706 |
} catch (AbstractMethodError ame) { |
| 7707 |
|
| 7708 |
return parent.startActionModeForChild(this, callback); |
| 7709 |
} |
| 7710 |
} |
| 7711 |
|
| 7712 |
|
| 7713 |
|
| 7714 |
|
| 7715 |
|
| 7716 |
|
| 7717 |
|
| 7718 |
|
| 7719 |
|
| 7720 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
| 7721 |
public void startActivityForResult(Intent intent, int requestCode) { |
| 7722 |
mStartActivityRequestWho = "@android:view:" + System.identityHashCode(this); |
| 7723 |
getContext().startActivityForResult(mStartActivityRequestWho, intent, requestCode, null); |
| 7724 |
} |
| 7725 |
|
| 7726 |
|
| 7727 |
|
| 7728 |
|
| 7729 |
|
| 7730 |
|
| 7731 |
|
| 7732 |
|
| 7733 |
|
| 7734 |
|
| 7735 |
|
| 7736 |
|
| 7737 |
|
| 7738 |
|
| 7739 |
public boolean dispatchActivityResult( |
| 7740 |
String who, int requestCode, int resultCode, Intent data) { |
| 7741 |
if (mStartActivityRequestWho != null && mStartActivityRequestWho.equals(who)) { |
| 7742 |
onActivityResult(requestCode, resultCode, data); |
| 7743 |
mStartActivityRequestWho = null; |
| 7744 |
return true; |
| 7745 |
} |
| 7746 |
return false; |
| 7747 |
} |
| 7748 |
|
| 7749 |
|
| 7750 |
|
| 7751 |
|
| 7752 |
|
| 7753 |
|
| 7754 |
|
| 7755 |
|
| 7756 |
|
| 7757 |
|
| 7758 |
|
| 7759 |
|
| 7760 |
|
| 7761 |
public void onActivityResult(int requestCode, int resultCode, Intent data) { |
| 7762 |
|
| 7763 |
} |
| 7764 |
|
| 7765 |
|
| 7766 |
|
| 7767 |
|
| 7768 |
|
| 7769 |
|
| 7770 |
|
| 7771 |
public void setOnKeyListener(OnKeyListener l) { |
| 7772 |
getListenerInfo().mOnKeyListener = l; |
| 7773 |
} |
| 7774 |
|
| 7775 |
|
| 7776 |
|
| 7777 |
|
| 7778 |
|
| 7779 |
public void setOnTouchListener(OnTouchListener l) { |
| 7780 |
getListenerInfo().mOnTouchListener = l; |
| 7781 |
} |
| 7782 |
|
| 7783 |
|
| 7784 |
|
| 7785 |
|
| 7786 |
|
| 7787 |
public void setOnGenericMotionListener(OnGenericMotionListener l) { |
| 7788 |
getListenerInfo().mOnGenericMotionListener = l; |
| 7789 |
} |
| 7790 |
|
| 7791 |
|
| 7792 |
|
| 7793 |
|
| 7794 |
|
| 7795 |
public void setOnHoverListener(OnHoverListener l) { |
| 7796 |
getListenerInfo().mOnHoverListener = l; |
| 7797 |
} |
| 7798 |
|
| 7799 |
|
| 7800 |
|
| 7801 |
|
| 7802 |
|
| 7803 |
|
| 7804 |
|
| 7805 |
|
| 7806 |
public void setOnDragListener(OnDragListener l) { |
| 7807 |
getListenerInfo().mOnDragListener = l; |
| 7808 |
} |
| 7809 |
|
| 7810 |
|
| 7811 |
|
| 7812 |
|
| 7813 |
|
| 7814 |
|
| 7815 |
|
| 7816 |
|
| 7817 |
|
| 7818 |
|
| 7819 |
|
| 7820 |
|
| 7821 |
|
| 7822 |
|
| 7823 |
|
| 7824 |
|
| 7825 |
void handleFocusGainInternal(@FocusRealDirection int direction, Rect previouslyFocusedRect) { |
| 7826 |
if (DBG) { |
| 7827 |
System.out.println(this + " requestFocus()"); |
| 7828 |
} |
| 7829 |
|
| 7830 |
if ((mPrivateFlags & PFLAG_FOCUSED) == 0) { |
| 7831 |
mPrivateFlags |= PFLAG_FOCUSED; |
| 7832 |
|
| 7833 |
View oldFocus = (mAttachInfo != null) ? getRootView().findFocus() : null; |
| 7834 |
|
| 7835 |
if (mParent != null) { |
| 7836 |
mParent.requestChildFocus(this, this); |
| 7837 |
updateFocusedInCluster(oldFocus, direction); |
| 7838 |
} |
| 7839 |
|
| 7840 |
if (mAttachInfo != null) { |
| 7841 |
mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(oldFocus, this); |
| 7842 |
} |
| 7843 |
|
| 7844 |
onFocusChanged(true, direction, previouslyFocusedRect); |
| 7845 |
refreshDrawableState(); |
| 7846 |
} |
| 7847 |
} |
| 7848 |
|
| 7849 |
|
| 7850 |
|
| 7851 |
|
| 7852 |
|
| 7853 |
|
| 7854 |
|
| 7855 |
|
| 7856 |
|
| 7857 |
|
| 7858 |
|
| 7859 |
|
| 7860 |
|
| 7861 |
|
| 7862 |
|
| 7863 |
|
| 7864 |
public final void setRevealOnFocusHint(boolean revealOnFocus) { |
| 7865 |
if (revealOnFocus) { |
| 7866 |
mPrivateFlags3 &= ~PFLAG3_NO_REVEAL_ON_FOCUS; |
| 7867 |
} else { |
| 7868 |
mPrivateFlags3 |= PFLAG3_NO_REVEAL_ON_FOCUS; |
| 7869 |
} |
| 7870 |
} |
| 7871 |
|
| 7872 |
|
| 7873 |
|
| 7874 |
|
| 7875 |
|
| 7876 |
|
| 7877 |
|
| 7878 |
|
| 7879 |
|
| 7880 |
|
| 7881 |
|
| 7882 |
|
| 7883 |
|
| 7884 |
|
| 7885 |
|
| 7886 |
public final boolean getRevealOnFocusHint() { |
| 7887 |
return (mPrivateFlags3 & PFLAG3_NO_REVEAL_ON_FOCUS) == 0; |
| 7888 |
} |
| 7889 |
|
| 7890 |
|
| 7891 |
|
| 7892 |
|
| 7893 |
|
| 7894 |
|
| 7895 |
|
| 7896 |
|
| 7897 |
public void getHotspotBounds(Rect outRect) { |
| 7898 |
final Drawable background = getBackground(); |
| 7899 |
if (background != null) { |
| 7900 |
background.getHotspotBounds(outRect); |
| 7901 |
} else { |
| 7902 |
getBoundsOnScreen(outRect); |
| 7903 |
} |
| 7904 |
} |
| 7905 |
|
| 7906 |
|
| 7907 |
|
| 7908 |
|
| 7909 |
|
| 7910 |
|
| 7911 |
|
| 7912 |
|
| 7913 |
|
| 7914 |
|
| 7915 |
|
| 7916 |
|
| 7917 |
|
| 7918 |
|
| 7919 |
|
| 7920 |
public boolean requestRectangleOnScreen(Rect rectangle) { |
| 7921 |
return requestRectangleOnScreen(rectangle, false); |
| 7922 |
} |
| 7923 |
|
| 7924 |
|
| 7925 |
|
| 7926 |
|
| 7927 |
|
| 7928 |
|
| 7929 |
|
| 7930 |
|
| 7931 |
|
| 7932 |
|
| 7933 |
|
| 7934 |
|
| 7935 |
|
| 7936 |
|
| 7937 |
|
| 7938 |
|
| 7939 |
|
| 7940 |
|
| 7941 |
public boolean requestRectangleOnScreen(Rect rectangle, boolean immediate) { |
| 7942 |
if (mParent == null) { |
| 7943 |
return false; |
| 7944 |
} |
| 7945 |
|
| 7946 |
View child = this; |
| 7947 |
|
| 7948 |
RectF position = (mAttachInfo != null) ? mAttachInfo.mTmpTransformRect : new RectF(); |
| 7949 |
position.set(rectangle); |
| 7950 |
|
| 7951 |
ViewParent parent = mParent; |
| 7952 |
boolean scrolled = false; |
| 7953 |
while (parent != null) { |
| 7954 |
rectangle.set((int) position.left, (int) position.top, |
| 7955 |
(int) position.right, (int) position.bottom); |
| 7956 |
|
| 7957 |
scrolled |= parent.requestChildRectangleOnScreen(child, rectangle, immediate); |
| 7958 |
|
| 7959 |
if (!(parent instanceof View)) { |
| 7960 |
break; |
| 7961 |
} |
| 7962 |
|
| 7963 |
|
| 7964 |
position.offset(child.mLeft - child.getScrollX(), child.mTop -child.getScrollY()); |
| 7965 |
|
| 7966 |
child = (View) parent; |
| 7967 |
parent = child.getParent(); |
| 7968 |
} |
| 7969 |
|
| 7970 |
return scrolled; |
| 7971 |
} |
| 7972 |
|
| 7973 |
|
| 7974 |
|
| 7975 |
|
| 7976 |
|
| 7977 |
|
| 7978 |
|
| 7979 |
|
| 7980 |
|
| 7981 |
|
| 7982 |
|
| 7983 |
|
| 7984 |
public void clearFocus() { |
| 7985 |
if (DBG) { |
| 7986 |
System.out.println(this + " clearFocus()"); |
| 7987 |
} |
| 7988 |
|
| 7989 |
final boolean refocus = sAlwaysAssignFocus || !isInTouchMode(); |
| 7990 |
clearFocusInternal(null, true, refocus); |
| 7991 |
} |
| 7992 |
|
| 7993 |
|
| 7994 |
|
| 7995 |
|
| 7996 |
|
| 7997 |
|
| 7998 |
|
| 7999 |
|
| 8000 |
|
| 8001 |
|
| 8002 |
void clearFocusInternal(View focused, boolean propagate, boolean refocus) { |
| 8003 |
if ((mPrivateFlags & PFLAG_FOCUSED) != 0) { |
| 8004 |
mPrivateFlags &= ~PFLAG_FOCUSED; |
| 8005 |
clearParentsWantFocus(); |
| 8006 |
|
| 8007 |
if (propagate && mParent != null) { |
| 8008 |
mParent.clearChildFocus(this); |
| 8009 |
} |
| 8010 |
|
| 8011 |
onFocusChanged(false, 0, null); |
| 8012 |
refreshDrawableState(); |
| 8013 |
|
| 8014 |
if (propagate && (!refocus || !rootViewRequestFocus())) { |
| 8015 |
notifyGlobalFocusCleared(this); |
| 8016 |
} |
| 8017 |
} |
| 8018 |
} |
| 8019 |
|
| 8020 |
void notifyGlobalFocusCleared(View oldFocus) { |
| 8021 |
if (oldFocus != null && mAttachInfo != null) { |
| 8022 |
mAttachInfo.mTreeObserver.dispatchOnGlobalFocusChange(oldFocus, null); |
| 8023 |
} |
| 8024 |
} |
| 8025 |
|
| 8026 |
boolean rootViewRequestFocus() { |
| 8027 |
final View root = getRootView(); |
| 8028 |
return root != null && root.requestFocus(); |
| 8029 |
} |
| 8030 |
|
| 8031 |
|
| 8032 |
|
| 8033 |
|
| 8034 |
|
| 8035 |
|
| 8036 |
|
| 8037 |
|
| 8038 |
|
| 8039 |
void unFocus(View focused) { |
| 8040 |
if (DBG) { |
| 8041 |
System.out.println(this + " unFocus()"); |
| 8042 |
} |
| 8043 |
|
| 8044 |
clearFocusInternal(focused, false, false); |
| 8045 |
} |
| 8046 |
|
| 8047 |
|
| 8048 |
|
| 8049 |
|
| 8050 |
|
| 8051 |
|
| 8052 |
|
| 8053 |
@ViewDebug.ExportedProperty(category = "focus") |
| 8054 |
public boolean hasFocus() { |
| 8055 |
return (mPrivateFlags & PFLAG_FOCUSED) != 0; |
| 8056 |
} |
| 8057 |
|
| 8058 |
|
| 8059 |
|
| 8060 |
|
| 8061 |
|
| 8062 |
|
| 8063 |
|
| 8064 |
|
| 8065 |
|
| 8066 |
|
| 8067 |
|
| 8068 |
|
| 8069 |
|
| 8070 |
|
| 8071 |
|
| 8072 |
|
| 8073 |
|
| 8074 |
|
| 8075 |
|
| 8076 |
|
| 8077 |
|
| 8078 |
|
| 8079 |
public boolean hasFocusable() { |
| 8080 |
return hasFocusable(!sHasFocusableExcludeAutoFocusable, false); |
| 8081 |
} |
| 8082 |
|
| 8083 |
|
| 8084 |
|
| 8085 |
|
| 8086 |
|
| 8087 |
|
| 8088 |
|
| 8089 |
|
| 8090 |
|
| 8091 |
|
| 8092 |
|
| 8093 |
|
| 8094 |
|
| 8095 |
|
| 8096 |
|
| 8097 |
|
| 8098 |
|
| 8099 |
|
| 8100 |
public boolean hasExplicitFocusable() { |
| 8101 |
return hasFocusable(false, true); |
| 8102 |
} |
| 8103 |
|
| 8104 |
boolean hasFocusable(boolean allowAutoFocus, boolean dispatchExplicit) { |
| 8105 |
if (!isFocusableInTouchMode()) { |
| 8106 |
for (ViewParent p = mParent; p instanceof ViewGroup; p = p.getParent()) { |
| 8107 |
final ViewGroup g = (ViewGroup) p; |
| 8108 |
if (g.shouldBlockFocusForTouchscreen()) { |
| 8109 |
return false; |
| 8110 |
} |
| 8111 |
} |
| 8112 |
} |
| 8113 |
|
| 8114 |
|
| 8115 |
if ((mViewFlags & VISIBILITY_MASK) != VISIBLE |
| 8116 |
|| (mViewFlags & ENABLED_MASK) != ENABLED) { |
| 8117 |
return false; |
| 8118 |
} |
| 8119 |
|
| 8120 |
|
| 8121 |
if ((allowAutoFocus || getFocusable() != FOCUSABLE_AUTO) && isFocusable()) { |
| 8122 |
return true; |
| 8123 |
} |
| 8124 |
|
| 8125 |
return false; |
| 8126 |
} |
| 8127 |
|
| 8128 |
|
| 8129 |
|
| 8130 |
|
| 8131 |
|
| 8132 |
|
| 8133 |
|
| 8134 |
|
| 8135 |
|
| 8136 |
|
| 8137 |
|
| 8138 |
|
| 8139 |
|
| 8140 |
|
| 8141 |
|
| 8142 |
|
| 8143 |
|
| 8144 |
|
| 8145 |
|
| 8146 |
@CallSuper |
| 8147 |
protected void onFocusChanged(boolean gainFocus, @FocusDirection int direction, |
| 8148 |
@Nullable Rect previouslyFocusedRect) { |
| 8149 |
if (gainFocus) { |
| 8150 |
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED); |
| 8151 |
} else { |
| 8152 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 8153 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 8154 |
} |
| 8155 |
|
| 8156 |
|
| 8157 |
switchDefaultFocusHighlight(); |
| 8158 |
|
| 8159 |
if (!gainFocus) { |
| 8160 |
if (isPressed()) { |
| 8161 |
setPressed(false); |
| 8162 |
} |
| 8163 |
if (hasWindowFocus()) { |
| 8164 |
notifyFocusChangeToImeFocusController(false ); |
| 8165 |
} |
| 8166 |
onFocusLost(); |
| 8167 |
} else if (hasWindowFocus()) { |
| 8168 |
notifyFocusChangeToImeFocusController(true ); |
| 8169 |
} |
| 8170 |
|
| 8171 |
invalidate(true); |
| 8172 |
ListenerInfo li = mListenerInfo; |
| 8173 |
if (li != null && li.mOnFocusChangeListener != null) { |
| 8174 |
li.mOnFocusChangeListener.onFocusChange(this, gainFocus); |
| 8175 |
} |
| 8176 |
|
| 8177 |
if (mAttachInfo != null) { |
| 8178 |
mAttachInfo.mKeyDispatchState.reset(this); |
| 8179 |
} |
| 8180 |
|
| 8181 |
if (mParent != null) { |
| 8182 |
mParent.onDescendantUnbufferedRequested(); |
| 8183 |
} |
| 8184 |
|
| 8185 |
notifyEnterOrExitForAutoFillIfNeeded(gainFocus); |
| 8186 |
updatePreferKeepClearForFocus(); |
| 8187 |
} |
| 8188 |
|
| 8189 |
|
| 8190 |
|
| 8191 |
|
| 8192 |
|
| 8193 |
|
| 8194 |
private void notifyFocusChangeToImeFocusController(boolean hasFocus) { |
| 8195 |
if (mAttachInfo == null) { |
| 8196 |
return; |
| 8197 |
} |
| 8198 |
mAttachInfo.mViewRootImpl.getImeFocusController().onViewFocusChanged(this, hasFocus); |
| 8199 |
} |
| 8200 |
|
| 8201 |
|
| 8202 |
public void notifyEnterOrExitForAutoFillIfNeeded(boolean enter) { |
| 8203 |
if (canNotifyAutofillEnterExitEvent()) { |
| 8204 |
AutofillManager afm = getAutofillManager(); |
| 8205 |
if (afm != null) { |
| 8206 |
if (enter) { |
| 8207 |
|
| 8208 |
|
| 8209 |
|
| 8210 |
|
| 8211 |
|
| 8212 |
|
| 8213 |
|
| 8214 |
|
| 8215 |
|
| 8216 |
|
| 8217 |
if (!isLaidOut() || !isVisibleToUser()) { |
| 8218 |
mPrivateFlags3 |= PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT; |
| 8219 |
} else if (isVisibleToUser()) { |
| 8220 |
if (isFocused()) { |
| 8221 |
|
| 8222 |
|
| 8223 |
|
| 8224 |
|
| 8225 |
afm.notifyViewEntered(this); |
| 8226 |
} else { |
| 8227 |
afm.notifyViewEnteredForFillDialog(this); |
| 8228 |
} |
| 8229 |
} |
| 8230 |
} else if (!isFocused()) { |
| 8231 |
afm.notifyViewExited(this); |
| 8232 |
} |
| 8233 |
} |
| 8234 |
} |
| 8235 |
} |
| 8236 |
|
| 8237 |
|
| 8238 |
|
| 8239 |
|
| 8240 |
|
| 8241 |
|
| 8242 |
|
| 8243 |
|
| 8244 |
|
| 8245 |
|
| 8246 |
|
| 8247 |
|
| 8248 |
|
| 8249 |
|
| 8250 |
|
| 8251 |
public void setAccessibilityPaneTitle(@Nullable CharSequence accessibilityPaneTitle) { |
| 8252 |
if (!TextUtils.equals(accessibilityPaneTitle, mAccessibilityPaneTitle)) { |
| 8253 |
boolean currentPaneTitleEmpty = mAccessibilityPaneTitle == null; |
| 8254 |
boolean newPaneTitleEmpty = accessibilityPaneTitle == null; |
| 8255 |
mAccessibilityPaneTitle = accessibilityPaneTitle; |
| 8256 |
|
| 8257 |
|
| 8258 |
if (mAccessibilityPaneTitle != null |
| 8259 |
&& getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) { |
| 8260 |
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); |
| 8261 |
} |
| 8262 |
if (currentPaneTitleEmpty) { |
| 8263 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 8264 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_APPEARED); |
| 8265 |
} else if (newPaneTitleEmpty) { |
| 8266 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 8267 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED); |
| 8268 |
} else { |
| 8269 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 8270 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_TITLE); |
| 8271 |
} |
| 8272 |
} |
| 8273 |
} |
| 8274 |
|
| 8275 |
|
| 8276 |
|
| 8277 |
|
| 8278 |
|
| 8279 |
|
| 8280 |
|
| 8281 |
|
| 8282 |
|
| 8283 |
|
| 8284 |
@InspectableProperty |
| 8285 |
@Nullable |
| 8286 |
public CharSequence getAccessibilityPaneTitle() { |
| 8287 |
return mAccessibilityPaneTitle; |
| 8288 |
} |
| 8289 |
|
| 8290 |
private boolean isAccessibilityPane() { |
| 8291 |
return mAccessibilityPaneTitle != null; |
| 8292 |
} |
| 8293 |
|
| 8294 |
|
| 8295 |
|
| 8296 |
|
| 8297 |
|
| 8298 |
|
| 8299 |
|
| 8300 |
|
| 8301 |
|
| 8302 |
|
| 8303 |
|
| 8304 |
|
| 8305 |
|
| 8306 |
|
| 8307 |
|
| 8308 |
|
| 8309 |
|
| 8310 |
|
| 8311 |
|
| 8312 |
|
| 8313 |
|
| 8314 |
|
| 8315 |
|
| 8316 |
|
| 8317 |
|
| 8318 |
|
| 8319 |
|
| 8320 |
|
| 8321 |
|
| 8322 |
|
| 8323 |
|
| 8324 |
|
| 8325 |
|
| 8326 |
|
| 8327 |
|
| 8328 |
|
| 8329 |
|
| 8330 |
|
| 8331 |
|
| 8332 |
public void sendAccessibilityEvent(int eventType) { |
| 8333 |
if (mAccessibilityDelegate != null) { |
| 8334 |
mAccessibilityDelegate.sendAccessibilityEvent(this, eventType); |
| 8335 |
} else { |
| 8336 |
sendAccessibilityEventInternal(eventType); |
| 8337 |
} |
| 8338 |
} |
| 8339 |
|
| 8340 |
|
| 8341 |
|
| 8342 |
|
| 8343 |
|
| 8344 |
|
| 8345 |
|
| 8346 |
|
| 8347 |
|
| 8348 |
|
| 8349 |
|
| 8350 |
|
| 8351 |
|
| 8352 |
public void announceForAccessibility(CharSequence text) { |
| 8353 |
if (AccessibilityManager.getInstance(mContext).isEnabled() && mParent != null) { |
| 8354 |
AccessibilityEvent event = AccessibilityEvent.obtain( |
| 8355 |
AccessibilityEvent.TYPE_ANNOUNCEMENT); |
| 8356 |
onInitializeAccessibilityEvent(event); |
| 8357 |
event.getText().add(text); |
| 8358 |
event.setContentDescription(null); |
| 8359 |
mParent.requestSendAccessibilityEvent(this, event); |
| 8360 |
} |
| 8361 |
} |
| 8362 |
|
| 8363 |
|
| 8364 |
|
| 8365 |
|
| 8366 |
|
| 8367 |
|
| 8368 |
|
| 8369 |
|
| 8370 |
public void sendAccessibilityEventInternal(int eventType) { |
| 8371 |
if (AccessibilityManager.getInstance(mContext).isEnabled()) { |
| 8372 |
sendAccessibilityEventUnchecked(AccessibilityEvent.obtain(eventType)); |
| 8373 |
} |
| 8374 |
} |
| 8375 |
|
| 8376 |
|
| 8377 |
|
| 8378 |
|
| 8379 |
|
| 8380 |
|
| 8381 |
|
| 8382 |
|
| 8383 |
|
| 8384 |
|
| 8385 |
|
| 8386 |
|
| 8387 |
|
| 8388 |
|
| 8389 |
|
| 8390 |
|
| 8391 |
public void sendAccessibilityEventUnchecked(AccessibilityEvent event) { |
| 8392 |
if (mAccessibilityDelegate != null) { |
| 8393 |
mAccessibilityDelegate.sendAccessibilityEventUnchecked(this, event); |
| 8394 |
} else { |
| 8395 |
sendAccessibilityEventUncheckedInternal(event); |
| 8396 |
} |
| 8397 |
} |
| 8398 |
|
| 8399 |
|
| 8400 |
|
| 8401 |
|
| 8402 |
|
| 8403 |
|
| 8404 |
|
| 8405 |
|
| 8406 |
public void sendAccessibilityEventUncheckedInternal(AccessibilityEvent event) { |
| 8407 |
|
| 8408 |
boolean isWindowStateChanged = |
| 8409 |
(event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); |
| 8410 |
boolean isWindowDisappearedEvent = isWindowStateChanged && ((event.getContentChangeTypes() |
| 8411 |
& AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED) != 0); |
| 8412 |
boolean detached = detached(); |
| 8413 |
if (!isShown() && !isWindowDisappearedEvent && !detached) { |
| 8414 |
return; |
| 8415 |
} |
| 8416 |
onInitializeAccessibilityEvent(event); |
| 8417 |
|
| 8418 |
if ((event.getEventType() & POPULATING_ACCESSIBILITY_EVENT_TYPES) != 0) { |
| 8419 |
dispatchPopulateAccessibilityEvent(event); |
| 8420 |
} |
| 8421 |
SendAccessibilityEventThrottle throttle = getThrottleForAccessibilityEvent(event); |
| 8422 |
if (throttle != null) { |
| 8423 |
throttle.post(event); |
| 8424 |
} else if (!isWindowDisappearedEvent && detached) { |
| 8425 |
|
| 8426 |
|
| 8427 |
postDelayed(() -> { |
| 8428 |
if (AccessibilityManager.getInstance(mContext).isEnabled() && isShown()) { |
| 8429 |
requestParentSendAccessibilityEvent(event); |
| 8430 |
} |
| 8431 |
}, ViewConfiguration.getSendRecurringAccessibilityEventsInterval()); |
| 8432 |
} else { |
| 8433 |
requestParentSendAccessibilityEvent(event); |
| 8434 |
} |
| 8435 |
} |
| 8436 |
|
| 8437 |
private void requestParentSendAccessibilityEvent(AccessibilityEvent event) { |
| 8438 |
ViewParent parent = getParent(); |
| 8439 |
if (parent != null) { |
| 8440 |
getParent().requestSendAccessibilityEvent(this, event); |
| 8441 |
} |
| 8442 |
} |
| 8443 |
|
| 8444 |
private SendAccessibilityEventThrottle getThrottleForAccessibilityEvent( |
| 8445 |
AccessibilityEvent event) { |
| 8446 |
if (event.getEventType() == AccessibilityEvent.TYPE_VIEW_SCROLLED) { |
| 8447 |
if (mSendViewScrolledAccessibilityEvent == null) { |
| 8448 |
mSendViewScrolledAccessibilityEvent = new SendViewScrolledAccessibilityEvent(); |
| 8449 |
} |
| 8450 |
return mSendViewScrolledAccessibilityEvent; |
| 8451 |
} |
| 8452 |
boolean isStateContentChanged = (event.getContentChangeTypes() |
| 8453 |
& AccessibilityEvent.CONTENT_CHANGE_TYPE_STATE_DESCRIPTION) != 0; |
| 8454 |
if (event.getEventType() == AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED |
| 8455 |
&& isStateContentChanged) { |
| 8456 |
if (mSendStateChangedAccessibilityEvent == null) { |
| 8457 |
mSendStateChangedAccessibilityEvent = new SendAccessibilityEventThrottle(); |
| 8458 |
} |
| 8459 |
return mSendStateChangedAccessibilityEvent; |
| 8460 |
} |
| 8461 |
return null; |
| 8462 |
} |
| 8463 |
|
| 8464 |
private void clearAccessibilityThrottles() { |
| 8465 |
cancel(mSendViewScrolledAccessibilityEvent); |
| 8466 |
cancel(mSendStateChangedAccessibilityEvent); |
| 8467 |
} |
| 8468 |
|
| 8469 |
|
| 8470 |
|
| 8471 |
|
| 8472 |
|
| 8473 |
|
| 8474 |
|
| 8475 |
|
| 8476 |
|
| 8477 |
|
| 8478 |
|
| 8479 |
|
| 8480 |
|
| 8481 |
|
| 8482 |
|
| 8483 |
|
| 8484 |
|
| 8485 |
|
| 8486 |
|
| 8487 |
|
| 8488 |
|
| 8489 |
|
| 8490 |
|
| 8491 |
|
| 8492 |
|
| 8493 |
|
| 8494 |
public boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event) { |
| 8495 |
if (mAccessibilityDelegate != null) { |
| 8496 |
return mAccessibilityDelegate.dispatchPopulateAccessibilityEvent(this, event); |
| 8497 |
} else { |
| 8498 |
return dispatchPopulateAccessibilityEventInternal(event); |
| 8499 |
} |
| 8500 |
} |
| 8501 |
|
| 8502 |
|
| 8503 |
|
| 8504 |
|
| 8505 |
|
| 8506 |
|
| 8507 |
|
| 8508 |
|
| 8509 |
public boolean dispatchPopulateAccessibilityEventInternal(AccessibilityEvent event) { |
| 8510 |
onPopulateAccessibilityEvent(event); |
| 8511 |
return false; |
| 8512 |
} |
| 8513 |
|
| 8514 |
|
| 8515 |
|
| 8516 |
|
| 8517 |
|
| 8518 |
|
| 8519 |
|
| 8520 |
|
| 8521 |
|
| 8522 |
|
| 8523 |
|
| 8524 |
|
| 8525 |
|
| 8526 |
|
| 8527 |
|
| 8528 |
|
| 8529 |
|
| 8530 |
|
| 8531 |
|
| 8532 |
|
| 8533 |
|
| 8534 |
|
| 8535 |
|
| 8536 |
|
| 8537 |
|
| 8538 |
|
| 8539 |
|
| 8540 |
|
| 8541 |
|
| 8542 |
|
| 8543 |
|
| 8544 |
|
| 8545 |
@CallSuper |
| 8546 |
public void onPopulateAccessibilityEvent(AccessibilityEvent event) { |
| 8547 |
if (mAccessibilityDelegate != null) { |
| 8548 |
mAccessibilityDelegate.onPopulateAccessibilityEvent(this, event); |
| 8549 |
} else { |
| 8550 |
onPopulateAccessibilityEventInternal(event); |
| 8551 |
} |
| 8552 |
} |
| 8553 |
|
| 8554 |
|
| 8555 |
|
| 8556 |
|
| 8557 |
|
| 8558 |
|
| 8559 |
|
| 8560 |
|
| 8561 |
public void onPopulateAccessibilityEventInternal(AccessibilityEvent event) { |
| 8562 |
if ((event.getEventType() == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) |
| 8563 |
&& isAccessibilityPane()) { |
| 8564 |
event.getText().add(getAccessibilityPaneTitle()); |
| 8565 |
} |
| 8566 |
} |
| 8567 |
|
| 8568 |
|
| 8569 |
|
| 8570 |
|
| 8571 |
|
| 8572 |
|
| 8573 |
|
| 8574 |
|
| 8575 |
|
| 8576 |
|
| 8577 |
|
| 8578 |
|
| 8579 |
|
| 8580 |
|
| 8581 |
|
| 8582 |
|
| 8583 |
|
| 8584 |
|
| 8585 |
|
| 8586 |
|
| 8587 |
|
| 8588 |
|
| 8589 |
|
| 8590 |
|
| 8591 |
|
| 8592 |
|
| 8593 |
|
| 8594 |
@CallSuper |
| 8595 |
public void onInitializeAccessibilityEvent(AccessibilityEvent event) { |
| 8596 |
if (mAccessibilityDelegate != null) { |
| 8597 |
mAccessibilityDelegate.onInitializeAccessibilityEvent(this, event); |
| 8598 |
} else { |
| 8599 |
onInitializeAccessibilityEventInternal(event); |
| 8600 |
} |
| 8601 |
} |
| 8602 |
|
| 8603 |
|
| 8604 |
|
| 8605 |
|
| 8606 |
|
| 8607 |
|
| 8608 |
|
| 8609 |
|
| 8610 |
@UnsupportedAppUsage |
| 8611 |
public void onInitializeAccessibilityEventInternal(AccessibilityEvent event) { |
| 8612 |
event.setSource(this); |
| 8613 |
event.setClassName(getAccessibilityClassName()); |
| 8614 |
event.setPackageName(getContext().getPackageName()); |
| 8615 |
event.setEnabled(isEnabled()); |
| 8616 |
event.setContentDescription(mContentDescription); |
| 8617 |
event.setScrollX(getScrollX()); |
| 8618 |
event.setScrollY(getScrollY()); |
| 8619 |
|
| 8620 |
switch (event.getEventType()) { |
| 8621 |
case AccessibilityEvent.TYPE_VIEW_FOCUSED: { |
| 8622 |
ArrayList<View> focusablesTempList = (mAttachInfo != null) |
| 8623 |
? mAttachInfo.mTempArrayList : new ArrayList<View>(); |
| 8624 |
getRootView().addFocusables(focusablesTempList, View.FOCUS_FORWARD, FOCUSABLES_ALL); |
| 8625 |
event.setItemCount(focusablesTempList.size()); |
| 8626 |
event.setCurrentItemIndex(focusablesTempList.indexOf(this)); |
| 8627 |
if (mAttachInfo != null) { |
| 8628 |
focusablesTempList.clear(); |
| 8629 |
} |
| 8630 |
} break; |
| 8631 |
case AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED: { |
| 8632 |
CharSequence text = getIterableTextForAccessibility(); |
| 8633 |
if (text != null && text.length() > 0) { |
| 8634 |
event.setFromIndex(getAccessibilitySelectionStart()); |
| 8635 |
event.setToIndex(getAccessibilitySelectionEnd()); |
| 8636 |
event.setItemCount(text.length()); |
| 8637 |
} |
| 8638 |
} break; |
| 8639 |
} |
| 8640 |
} |
| 8641 |
|
| 8642 |
|
| 8643 |
|
| 8644 |
|
| 8645 |
|
| 8646 |
|
| 8647 |
|
| 8648 |
|
| 8649 |
|
| 8650 |
|
| 8651 |
|
| 8652 |
|
| 8653 |
|
| 8654 |
|
| 8655 |
|
| 8656 |
|
| 8657 |
|
| 8658 |
public AccessibilityNodeInfo createAccessibilityNodeInfo() { |
| 8659 |
if (mAccessibilityDelegate != null) { |
| 8660 |
return mAccessibilityDelegate.createAccessibilityNodeInfo(this); |
| 8661 |
} else { |
| 8662 |
return createAccessibilityNodeInfoInternal(); |
| 8663 |
} |
| 8664 |
} |
| 8665 |
|
| 8666 |
|
| 8667 |
|
| 8668 |
|
| 8669 |
|
| 8670 |
|
| 8671 |
public @Nullable AccessibilityNodeInfo createAccessibilityNodeInfoInternal() { |
| 8672 |
AccessibilityNodeProvider provider = getAccessibilityNodeProvider(); |
| 8673 |
if (provider != null) { |
| 8674 |
return provider.createAccessibilityNodeInfo(AccessibilityNodeProvider.HOST_VIEW_ID); |
| 8675 |
} else { |
| 8676 |
AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(this); |
| 8677 |
onInitializeAccessibilityNodeInfo(info); |
| 8678 |
return info; |
| 8679 |
} |
| 8680 |
} |
| 8681 |
|
| 8682 |
|
| 8683 |
|
| 8684 |
|
| 8685 |
|
| 8686 |
|
| 8687 |
|
| 8688 |
|
| 8689 |
|
| 8690 |
|
| 8691 |
|
| 8692 |
|
| 8693 |
|
| 8694 |
|
| 8695 |
|
| 8696 |
|
| 8697 |
|
| 8698 |
|
| 8699 |
|
| 8700 |
|
| 8701 |
|
| 8702 |
|
| 8703 |
|
| 8704 |
|
| 8705 |
|
| 8706 |
|
| 8707 |
|
| 8708 |
|
| 8709 |
|
| 8710 |
|
| 8711 |
|
| 8712 |
|
| 8713 |
@CallSuper |
| 8714 |
public void onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo info) { |
| 8715 |
if (mAccessibilityDelegate != null) { |
| 8716 |
mAccessibilityDelegate.onInitializeAccessibilityNodeInfo(this, info); |
| 8717 |
} else { |
| 8718 |
onInitializeAccessibilityNodeInfoInternal(info); |
| 8719 |
} |
| 8720 |
} |
| 8721 |
|
| 8722 |
|
| 8723 |
|
| 8724 |
|
| 8725 |
|
| 8726 |
|
| 8727 |
|
| 8728 |
@UnsupportedAppUsage |
| 8729 |
public void getBoundsOnScreen(Rect outRect) { |
| 8730 |
getBoundsOnScreen(outRect, false); |
| 8731 |
} |
| 8732 |
|
| 8733 |
|
| 8734 |
|
| 8735 |
|
| 8736 |
|
| 8737 |
|
| 8738 |
|
| 8739 |
|
| 8740 |
@UnsupportedAppUsage |
| 8741 |
public void getBoundsOnScreen(Rect outRect, boolean clipToParent) { |
| 8742 |
if (mAttachInfo == null) { |
| 8743 |
return; |
| 8744 |
} |
| 8745 |
RectF position = mAttachInfo.mTmpTransformRect; |
| 8746 |
getBoundsToScreenInternal(position, clipToParent); |
| 8747 |
outRect.set(Math.round(position.left), Math.round(position.top), |
| 8748 |
Math.round(position.right), Math.round(position.bottom)); |
| 8749 |
} |
| 8750 |
|
| 8751 |
|
| 8752 |
|
| 8753 |
|
| 8754 |
|
| 8755 |
|
| 8756 |
|
| 8757 |
|
| 8758 |
public void getBoundsOnScreen(RectF outRect, boolean clipToParent) { |
| 8759 |
if (mAttachInfo == null) { |
| 8760 |
return; |
| 8761 |
} |
| 8762 |
RectF position = mAttachInfo.mTmpTransformRect; |
| 8763 |
getBoundsToScreenInternal(position, clipToParent); |
| 8764 |
outRect.set(position.left, position.top, position.right, position.bottom); |
| 8765 |
} |
| 8766 |
|
| 8767 |
private void getBoundsToScreenInternal(RectF position, boolean clipToParent) { |
| 8768 |
position.set(0, 0, mRight - mLeft, mBottom - mTop); |
| 8769 |
mapRectFromViewToScreenCoords(position, clipToParent); |
| 8770 |
} |
| 8771 |
|
| 8772 |
|
| 8773 |
|
| 8774 |
|
| 8775 |
|
| 8776 |
|
| 8777 |
|
| 8778 |
|
| 8779 |
public void mapRectFromViewToScreenCoords(RectF rect, boolean clipToParent) { |
| 8780 |
if (!hasIdentityMatrix()) { |
| 8781 |
getMatrix().mapRect(rect); |
| 8782 |
} |
| 8783 |
|
| 8784 |
rect.offset(mLeft, mTop); |
| 8785 |
|
| 8786 |
ViewParent parent = mParent; |
| 8787 |
while (parent instanceof View) { |
| 8788 |
View parentView = (View) parent; |
| 8789 |
|
| 8790 |
rect.offset(-parentView.mScrollX, -parentView.mScrollY); |
| 8791 |
|
| 8792 |
if (clipToParent) { |
| 8793 |
rect.left = Math.max(rect.left, 0); |
| 8794 |
rect.top = Math.max(rect.top, 0); |
| 8795 |
rect.right = Math.min(rect.right, parentView.getWidth()); |
| 8796 |
rect.bottom = Math.min(rect.bottom, parentView.getHeight()); |
| 8797 |
} |
| 8798 |
|
| 8799 |
if (!parentView.hasIdentityMatrix()) { |
| 8800 |
parentView.getMatrix().mapRect(rect); |
| 8801 |
} |
| 8802 |
|
| 8803 |
rect.offset(parentView.mLeft, parentView.mTop); |
| 8804 |
|
| 8805 |
parent = parentView.mParent; |
| 8806 |
} |
| 8807 |
|
| 8808 |
if (parent instanceof ViewRootImpl) { |
| 8809 |
ViewRootImpl viewRootImpl = (ViewRootImpl) parent; |
| 8810 |
rect.offset(0, -viewRootImpl.mCurScrollY); |
| 8811 |
} |
| 8812 |
|
| 8813 |
rect.offset(mAttachInfo.mWindowLeft, mAttachInfo.mWindowTop); |
| 8814 |
} |
| 8815 |
|
| 8816 |
|
| 8817 |
|
| 8818 |
|
| 8819 |
|
| 8820 |
|
| 8821 |
|
| 8822 |
|
| 8823 |
public CharSequence getAccessibilityClassName() { |
| 8824 |
return View.class.getName(); |
| 8825 |
} |
| 8826 |
|
| 8827 |
|
| 8828 |
|
| 8829 |
|
| 8830 |
|
| 8831 |
|
| 8832 |
|
| 8833 |
public void onProvideStructure(ViewStructure structure) { |
| 8834 |
onProvideStructure(structure, VIEW_STRUCTURE_FOR_ASSIST, 0); |
| 8835 |
} |
| 8836 |
|
| 8837 |
|
| 8838 |
|
| 8839 |
|
| 8840 |
|
| 8841 |
|
| 8842 |
|
| 8843 |
|
| 8844 |
|
| 8845 |
|
| 8846 |
|
| 8847 |
|
| 8848 |
|
| 8849 |
|
| 8850 |
|
| 8851 |
|
| 8852 |
|
| 8853 |
|
| 8854 |
|
| 8855 |
|
| 8856 |
|
| 8857 |
|
| 8858 |
|
| 8859 |
|
| 8860 |
|
| 8861 |
|
| 8862 |
|
| 8863 |
|
| 8864 |
|
| 8865 |
|
| 8866 |
|
| 8867 |
|
| 8868 |
|
| 8869 |
|
| 8870 |
|
| 8871 |
|
| 8872 |
|
| 8873 |
|
| 8874 |
|
| 8875 |
|
| 8876 |
|
| 8877 |
|
| 8878 |
|
| 8879 |
|
| 8880 |
|
| 8881 |
|
| 8882 |
|
| 8883 |
|
| 8884 |
|
| 8885 |
|
| 8886 |
|
| 8887 |
|
| 8888 |
|
| 8889 |
|
| 8890 |
|
| 8891 |
|
| 8892 |
|
| 8893 |
|
| 8894 |
|
| 8895 |
|
| 8896 |
|
| 8897 |
|
| 8898 |
|
| 8899 |
|
| 8900 |
|
| 8901 |
|
| 8902 |
|
| 8903 |
|
| 8904 |
|
| 8905 |
|
| 8906 |
public void onProvideAutofillStructure(ViewStructure structure, @AutofillFlags int flags) { |
| 8907 |
onProvideStructure(structure, VIEW_STRUCTURE_FOR_AUTOFILL, flags); |
| 8908 |
} |
| 8909 |
|
| 8910 |
|
| 8911 |
|
| 8912 |
|
| 8913 |
|
| 8914 |
|
| 8915 |
|
| 8916 |
|
| 8917 |
|
| 8918 |
|
| 8919 |
|
| 8920 |
|
| 8921 |
|
| 8922 |
|
| 8923 |
|
| 8924 |
|
| 8925 |
|
| 8926 |
|
| 8927 |
|
| 8928 |
|
| 8929 |
|
| 8930 |
|
| 8931 |
|
| 8932 |
|
| 8933 |
|
| 8934 |
|
| 8935 |
|
| 8936 |
|
| 8937 |
|
| 8938 |
|
| 8939 |
|
| 8940 |
|
| 8941 |
|
| 8942 |
|
| 8943 |
|
| 8944 |
|
| 8945 |
|
| 8946 |
|
| 8947 |
|
| 8948 |
|
| 8949 |
|
| 8950 |
|
| 8951 |
|
| 8952 |
|
| 8953 |
|
| 8954 |
|
| 8955 |
|
| 8956 |
|
| 8957 |
|
| 8958 |
|
| 8959 |
|
| 8960 |
|
| 8961 |
|
| 8962 |
|
| 8963 |
|
| 8964 |
|
| 8965 |
public void onProvideContentCaptureStructure(@NonNull ViewStructure structure, int flags) { |
| 8966 |
onProvideStructure(structure, VIEW_STRUCTURE_FOR_CONTENT_CAPTURE, flags); |
| 8967 |
} |
| 8968 |
|
| 8969 |
|
| 8970 |
protected void onProvideStructure(@NonNull ViewStructure structure, |
| 8971 |
@ViewStructureType int viewFor, int flags) { |
| 8972 |
final int id = mID; |
| 8973 |
if (id != NO_ID && !isViewIdGenerated(id)) { |
| 8974 |
String pkg, type, entry; |
| 8975 |
try { |
| 8976 |
final Resources res = getResources(); |
| 8977 |
entry = res.getResourceEntryName(id); |
| 8978 |
type = res.getResourceTypeName(id); |
| 8979 |
pkg = res.getResourcePackageName(id); |
| 8980 |
} catch (Resources.NotFoundException e) { |
| 8981 |
entry = type = pkg = null; |
| 8982 |
} |
| 8983 |
structure.setId(id, pkg, type, entry); |
| 8984 |
} else { |
| 8985 |
structure.setId(id, null, null, null); |
| 8986 |
} |
| 8987 |
|
| 8988 |
if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL |
| 8989 |
|| viewFor == VIEW_STRUCTURE_FOR_CONTENT_CAPTURE) { |
| 8990 |
final @AutofillType int autofillType = getAutofillType(); |
| 8991 |
|
| 8992 |
|
| 8993 |
if (autofillType != AUTOFILL_TYPE_NONE) { |
| 8994 |
structure.setAutofillType(autofillType); |
| 8995 |
structure.setAutofillHints(getAutofillHints()); |
| 8996 |
structure.setAutofillValue(getAutofillValue()); |
| 8997 |
} |
| 8998 |
structure.setImportantForAutofill(getImportantForAutofill()); |
| 8999 |
structure.setReceiveContentMimeTypes(getReceiveContentMimeTypes()); |
| 9000 |
} |
| 9001 |
|
| 9002 |
int ignoredParentLeft = 0; |
| 9003 |
int ignoredParentTop = 0; |
| 9004 |
if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL |
| 9005 |
&& (flags & AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) == 0) { |
| 9006 |
View parentGroup = null; |
| 9007 |
|
| 9008 |
ViewParent viewParent = getParent(); |
| 9009 |
if (viewParent instanceof View) { |
| 9010 |
parentGroup = (View) viewParent; |
| 9011 |
} |
| 9012 |
|
| 9013 |
while (parentGroup != null && !parentGroup.isImportantForAutofill()) { |
| 9014 |
ignoredParentLeft += parentGroup.mLeft; |
| 9015 |
ignoredParentTop += parentGroup.mTop; |
| 9016 |
|
| 9017 |
viewParent = parentGroup.getParent(); |
| 9018 |
if (viewParent instanceof View) { |
| 9019 |
parentGroup = (View) viewParent; |
| 9020 |
} else { |
| 9021 |
break; |
| 9022 |
} |
| 9023 |
} |
| 9024 |
} |
| 9025 |
|
| 9026 |
structure.setDimens(ignoredParentLeft + mLeft, ignoredParentTop + mTop, mScrollX, mScrollY, |
| 9027 |
mRight - mLeft, mBottom - mTop); |
| 9028 |
if (viewFor == VIEW_STRUCTURE_FOR_ASSIST) { |
| 9029 |
if (!hasIdentityMatrix()) { |
| 9030 |
structure.setTransformation(getMatrix()); |
| 9031 |
} |
| 9032 |
structure.setElevation(getZ()); |
| 9033 |
} |
| 9034 |
structure.setVisibility(getVisibility()); |
| 9035 |
structure.setEnabled(isEnabled()); |
| 9036 |
if (isClickable()) { |
| 9037 |
structure.setClickable(true); |
| 9038 |
} |
| 9039 |
if (isFocusable()) { |
| 9040 |
structure.setFocusable(true); |
| 9041 |
} |
| 9042 |
if (isFocused()) { |
| 9043 |
structure.setFocused(true); |
| 9044 |
} |
| 9045 |
if (isAccessibilityFocused()) { |
| 9046 |
structure.setAccessibilityFocused(true); |
| 9047 |
} |
| 9048 |
if (isSelected()) { |
| 9049 |
structure.setSelected(true); |
| 9050 |
} |
| 9051 |
if (isActivated()) { |
| 9052 |
structure.setActivated(true); |
| 9053 |
} |
| 9054 |
if (isLongClickable()) { |
| 9055 |
structure.setLongClickable(true); |
| 9056 |
} |
| 9057 |
if (this instanceof Checkable) { |
| 9058 |
structure.setCheckable(true); |
| 9059 |
if (((Checkable)this).isChecked()) { |
| 9060 |
structure.setChecked(true); |
| 9061 |
} |
| 9062 |
} |
| 9063 |
if (isOpaque()) { |
| 9064 |
structure.setOpaque(true); |
| 9065 |
} |
| 9066 |
if (isContextClickable()) { |
| 9067 |
structure.setContextClickable(true); |
| 9068 |
} |
| 9069 |
structure.setClassName(getAccessibilityClassName().toString()); |
| 9070 |
structure.setContentDescription(getContentDescription()); |
| 9071 |
} |
| 9072 |
|
| 9073 |
|
| 9074 |
|
| 9075 |
|
| 9076 |
|
| 9077 |
|
| 9078 |
|
| 9079 |
|
| 9080 |
|
| 9081 |
public void onProvideVirtualStructure(ViewStructure structure) { |
| 9082 |
onProvideVirtualStructureCompat(structure, false); |
| 9083 |
} |
| 9084 |
|
| 9085 |
|
| 9086 |
|
| 9087 |
|
| 9088 |
|
| 9089 |
|
| 9090 |
|
| 9091 |
private void onProvideVirtualStructureCompat(ViewStructure structure, boolean forAutofill) { |
| 9092 |
final AccessibilityNodeProvider provider = getAccessibilityNodeProvider(); |
| 9093 |
if (provider != null) { |
| 9094 |
if (forAutofill && Log.isLoggable(AUTOFILL_LOG_TAG, Log.VERBOSE)) { |
| 9095 |
Log.v(AUTOFILL_LOG_TAG, "onProvideVirtualStructureCompat() for " + this); |
| 9096 |
} |
| 9097 |
final AccessibilityNodeInfo info = createAccessibilityNodeInfo(); |
| 9098 |
structure.setChildCount(1); |
| 9099 |
final ViewStructure root = structure.newChild(0); |
| 9100 |
populateVirtualStructure(root, provider, info, forAutofill); |
| 9101 |
info.recycle(); |
| 9102 |
} |
| 9103 |
} |
| 9104 |
|
| 9105 |
|
| 9106 |
|
| 9107 |
|
| 9108 |
|
| 9109 |
|
| 9110 |
|
| 9111 |
|
| 9112 |
|
| 9113 |
|
| 9114 |
|
| 9115 |
|
| 9116 |
|
| 9117 |
|
| 9118 |
|
| 9119 |
|
| 9120 |
|
| 9121 |
|
| 9122 |
|
| 9123 |
|
| 9124 |
|
| 9125 |
|
| 9126 |
|
| 9127 |
|
| 9128 |
|
| 9129 |
|
| 9130 |
|
| 9131 |
|
| 9132 |
|
| 9133 |
|
| 9134 |
|
| 9135 |
|
| 9136 |
|
| 9137 |
|
| 9138 |
|
| 9139 |
|
| 9140 |
|
| 9141 |
|
| 9142 |
|
| 9143 |
|
| 9144 |
|
| 9145 |
|
| 9146 |
|
| 9147 |
|
| 9148 |
|
| 9149 |
|
| 9150 |
|
| 9151 |
|
| 9152 |
|
| 9153 |
|
| 9154 |
|
| 9155 |
|
| 9156 |
|
| 9157 |
|
| 9158 |
|
| 9159 |
|
| 9160 |
|
| 9161 |
|
| 9162 |
|
| 9163 |
|
| 9164 |
|
| 9165 |
|
| 9166 |
|
| 9167 |
|
| 9168 |
|
| 9169 |
public void onProvideAutofillVirtualStructure(ViewStructure structure, int flags) { |
| 9170 |
if (mContext.isAutofillCompatibilityEnabled()) { |
| 9171 |
onProvideVirtualStructureCompat(structure, true); |
| 9172 |
} |
| 9173 |
} |
| 9174 |
|
| 9175 |
|
| 9176 |
|
| 9177 |
|
| 9178 |
|
| 9179 |
|
| 9180 |
|
| 9181 |
|
| 9182 |
|
| 9183 |
|
| 9184 |
|
| 9185 |
|
| 9186 |
|
| 9187 |
|
| 9188 |
|
| 9189 |
|
| 9190 |
|
| 9191 |
|
| 9192 |
|
| 9193 |
|
| 9194 |
|
| 9195 |
|
| 9196 |
|
| 9197 |
|
| 9198 |
|
| 9199 |
|
| 9200 |
|
| 9201 |
|
| 9202 |
|
| 9203 |
|
| 9204 |
|
| 9205 |
|
| 9206 |
|
| 9207 |
|
| 9208 |
|
| 9209 |
|
| 9210 |
|
| 9211 |
|
| 9212 |
public void setOnReceiveContentListener( |
| 9213 |
@SuppressLint("NullableCollection") @Nullable String[] mimeTypes, |
| 9214 |
@Nullable OnReceiveContentListener listener) { |
| 9215 |
if (listener != null) { |
| 9216 |
Preconditions.checkArgument(mimeTypes != null && mimeTypes.length > 0, |
| 9217 |
"When the listener is set, MIME types must also be set"); |
| 9218 |
} |
| 9219 |
if (mimeTypes != null) { |
| 9220 |
Preconditions.checkArgument(Arrays.stream(mimeTypes).noneMatch(t -> t.startsWith("*")), |
| 9221 |
"A MIME type set here must not start with *: " + Arrays.toString(mimeTypes)); |
| 9222 |
} |
| 9223 |
mReceiveContentMimeTypes = ArrayUtils.isEmpty(mimeTypes) ? null : mimeTypes; |
| 9224 |
getListenerInfo().mOnReceiveContentListener = listener; |
| 9225 |
} |
| 9226 |
|
| 9227 |
|
| 9228 |
|
| 9229 |
|
| 9230 |
|
| 9231 |
|
| 9232 |
|
| 9233 |
|
| 9234 |
|
| 9235 |
|
| 9236 |
|
| 9237 |
@Nullable |
| 9238 |
public ContentInfo performReceiveContent(@NonNull ContentInfo payload) { |
| 9239 |
final OnReceiveContentListener listener = (mListenerInfo == null) ? null |
| 9240 |
: getListenerInfo().mOnReceiveContentListener; |
| 9241 |
if (listener != null) { |
| 9242 |
final ContentInfo remaining = listener.onReceiveContent(this, payload); |
| 9243 |
return (remaining == null) ? null : onReceiveContent(remaining); |
| 9244 |
} |
| 9245 |
return onReceiveContent(payload); |
| 9246 |
} |
| 9247 |
|
| 9248 |
|
| 9249 |
|
| 9250 |
|
| 9251 |
|
| 9252 |
|
| 9253 |
|
| 9254 |
|
| 9255 |
|
| 9256 |
|
| 9257 |
|
| 9258 |
|
| 9259 |
|
| 9260 |
|
| 9261 |
|
| 9262 |
|
| 9263 |
@Nullable |
| 9264 |
public ContentInfo onReceiveContent(@NonNull ContentInfo payload) { |
| 9265 |
return payload; |
| 9266 |
} |
| 9267 |
|
| 9268 |
|
| 9269 |
|
| 9270 |
|
| 9271 |
|
| 9272 |
|
| 9273 |
|
| 9274 |
|
| 9275 |
|
| 9276 |
|
| 9277 |
|
| 9278 |
|
| 9279 |
|
| 9280 |
|
| 9281 |
|
| 9282 |
|
| 9283 |
|
| 9284 |
|
| 9285 |
|
| 9286 |
|
| 9287 |
|
| 9288 |
|
| 9289 |
@SuppressLint("NullableCollection") |
| 9290 |
@Nullable |
| 9291 |
public String[] getReceiveContentMimeTypes() { |
| 9292 |
return mReceiveContentMimeTypes; |
| 9293 |
} |
| 9294 |
|
| 9295 |
|
| 9296 |
|
| 9297 |
|
| 9298 |
|
| 9299 |
|
| 9300 |
|
| 9301 |
|
| 9302 |
|
| 9303 |
|
| 9304 |
|
| 9305 |
|
| 9306 |
|
| 9307 |
|
| 9308 |
|
| 9309 |
|
| 9310 |
|
| 9311 |
|
| 9312 |
|
| 9313 |
|
| 9314 |
|
| 9315 |
|
| 9316 |
|
| 9317 |
|
| 9318 |
|
| 9319 |
|
| 9320 |
|
| 9321 |
|
| 9322 |
|
| 9323 |
|
| 9324 |
|
| 9325 |
|
| 9326 |
|
| 9327 |
|
| 9328 |
|
| 9329 |
|
| 9330 |
|
| 9331 |
|
| 9332 |
|
| 9333 |
|
| 9334 |
|
| 9335 |
|
| 9336 |
|
| 9337 |
|
| 9338 |
|
| 9339 |
|
| 9340 |
public void autofill(@SuppressWarnings("unused") AutofillValue value) { |
| 9341 |
} |
| 9342 |
|
| 9343 |
|
| 9344 |
|
| 9345 |
|
| 9346 |
|
| 9347 |
|
| 9348 |
|
| 9349 |
|
| 9350 |
|
| 9351 |
|
| 9352 |
|
| 9353 |
|
| 9354 |
|
| 9355 |
|
| 9356 |
|
| 9357 |
|
| 9358 |
|
| 9359 |
|
| 9360 |
|
| 9361 |
|
| 9362 |
|
| 9363 |
|
| 9364 |
|
| 9365 |
|
| 9366 |
|
| 9367 |
|
| 9368 |
|
| 9369 |
public void autofill(@NonNull @SuppressWarnings("unused") SparseArray<AutofillValue> values) { |
| 9370 |
if (!mContext.isAutofillCompatibilityEnabled()) { |
| 9371 |
return; |
| 9372 |
} |
| 9373 |
final AccessibilityNodeProvider provider = getAccessibilityNodeProvider(); |
| 9374 |
if (provider == null) { |
| 9375 |
return; |
| 9376 |
} |
| 9377 |
final int valueCount = values.size(); |
| 9378 |
for (int i = 0; i < valueCount; i++) { |
| 9379 |
final AutofillValue value = values.valueAt(i); |
| 9380 |
if (value.isText()) { |
| 9381 |
final int virtualId = values.keyAt(i); |
| 9382 |
final CharSequence text = value.getTextValue(); |
| 9383 |
final Bundle arguments = new Bundle(); |
| 9384 |
arguments.putCharSequence( |
| 9385 |
AccessibilityNodeInfo.ACTION_ARGUMENT_SET_TEXT_CHARSEQUENCE, text); |
| 9386 |
provider.performAction(virtualId, AccessibilityNodeInfo.ACTION_SET_TEXT, arguments); |
| 9387 |
} |
| 9388 |
} |
| 9389 |
} |
| 9390 |
|
| 9391 |
|
| 9392 |
|
| 9393 |
|
| 9394 |
|
| 9395 |
|
| 9396 |
|
| 9397 |
|
| 9398 |
|
| 9399 |
|
| 9400 |
|
| 9401 |
public final AutofillId getAutofillId() { |
| 9402 |
if (mAutofillId == null) { |
| 9403 |
|
| 9404 |
|
| 9405 |
mAutofillId = new AutofillId(getAutofillViewId()); |
| 9406 |
} |
| 9407 |
return mAutofillId; |
| 9408 |
} |
| 9409 |
|
| 9410 |
|
| 9411 |
|
| 9412 |
|
| 9413 |
|
| 9414 |
|
| 9415 |
|
| 9416 |
|
| 9417 |
|
| 9418 |
|
| 9419 |
|
| 9420 |
|
| 9421 |
|
| 9422 |
|
| 9423 |
|
| 9424 |
|
| 9425 |
|
| 9426 |
|
| 9427 |
|
| 9428 |
|
| 9429 |
|
| 9430 |
|
| 9431 |
|
| 9432 |
|
| 9433 |
|
| 9434 |
|
| 9435 |
|
| 9436 |
|
| 9437 |
|
| 9438 |
|
| 9439 |
|
| 9440 |
|
| 9441 |
|
| 9442 |
|
| 9443 |
|
| 9444 |
|
| 9445 |
|
| 9446 |
|
| 9447 |
|
| 9448 |
|
| 9449 |
|
| 9450 |
|
| 9451 |
|
| 9452 |
|
| 9453 |
|
| 9454 |
|
| 9455 |
|
| 9456 |
|
| 9457 |
public void setAutofillId(@Nullable AutofillId id) { |
| 9458 |
|
| 9459 |
if (Log.isLoggable(AUTOFILL_LOG_TAG, Log.VERBOSE)) { |
| 9460 |
Log.v(AUTOFILL_LOG_TAG, "setAutofill(): from " + mAutofillId + " to " + id); |
| 9461 |
} |
| 9462 |
if (isAttachedToWindow()) { |
| 9463 |
throw new IllegalStateException("Cannot set autofill id when view is attached"); |
| 9464 |
} |
| 9465 |
if (id != null && !id.isNonVirtual()) { |
| 9466 |
throw new IllegalStateException("Cannot set autofill id assigned to virtual views"); |
| 9467 |
} |
| 9468 |
if (id == null && (mPrivateFlags3 & PFLAG3_AUTOFILLID_EXPLICITLY_SET) == 0) { |
| 9469 |
|
| 9470 |
return; |
| 9471 |
} |
| 9472 |
mAutofillId = id; |
| 9473 |
if (id != null) { |
| 9474 |
mAutofillViewId = id.getViewId(); |
| 9475 |
mPrivateFlags3 |= PFLAG3_AUTOFILLID_EXPLICITLY_SET; |
| 9476 |
} else { |
| 9477 |
mAutofillViewId = NO_ID; |
| 9478 |
mPrivateFlags3 &= ~PFLAG3_AUTOFILLID_EXPLICITLY_SET; |
| 9479 |
} |
| 9480 |
} |
| 9481 |
|
| 9482 |
|
| 9483 |
|
| 9484 |
|
| 9485 |
|
| 9486 |
|
| 9487 |
|
| 9488 |
|
| 9489 |
|
| 9490 |
|
| 9491 |
|
| 9492 |
public void resetSubtreeAutofillIds() { |
| 9493 |
if (mAutofillViewId == NO_ID) { |
| 9494 |
return; |
| 9495 |
} |
| 9496 |
if (Log.isLoggable(CONTENT_CAPTURE_LOG_TAG, Log.VERBOSE)) { |
| 9497 |
Log.v(CONTENT_CAPTURE_LOG_TAG, "resetAutofillId() for " + mAutofillViewId); |
| 9498 |
} else if (Log.isLoggable(AUTOFILL_LOG_TAG, Log.VERBOSE)) { |
| 9499 |
Log.v(AUTOFILL_LOG_TAG, "resetAutofillId() for " + mAutofillViewId); |
| 9500 |
} |
| 9501 |
mAutofillId = null; |
| 9502 |
mAutofillViewId = NO_ID; |
| 9503 |
mPrivateFlags3 &= ~PFLAG3_AUTOFILLID_EXPLICITLY_SET; |
| 9504 |
} |
| 9505 |
|
| 9506 |
|
| 9507 |
|
| 9508 |
|
| 9509 |
|
| 9510 |
|
| 9511 |
|
| 9512 |
|
| 9513 |
|
| 9514 |
|
| 9515 |
|
| 9516 |
|
| 9517 |
|
| 9518 |
|
| 9519 |
|
| 9520 |
public @AutofillType int getAutofillType() { |
| 9521 |
return AUTOFILL_TYPE_NONE; |
| 9522 |
} |
| 9523 |
|
| 9524 |
|
| 9525 |
|
| 9526 |
|
| 9527 |
|
| 9528 |
|
| 9529 |
|
| 9530 |
|
| 9531 |
|
| 9532 |
|
| 9533 |
|
| 9534 |
|
| 9535 |
@ViewDebug.ExportedProperty() |
| 9536 |
@InspectableProperty |
| 9537 |
@Nullable public String[] getAutofillHints() { |
| 9538 |
return mAutofillHints; |
| 9539 |
} |
| 9540 |
|
| 9541 |
|
| 9542 |
|
| 9543 |
|
| 9544 |
@TestApi |
| 9545 |
public boolean isAutofilled() { |
| 9546 |
return (mPrivateFlags3 & PFLAG3_IS_AUTOFILLED) != 0; |
| 9547 |
} |
| 9548 |
|
| 9549 |
|
| 9550 |
|
| 9551 |
|
| 9552 |
public boolean hideAutofillHighlight() { |
| 9553 |
return (mPrivateFlags4 & PFLAG4_AUTOFILL_HIDE_HIGHLIGHT) != 0; |
| 9554 |
} |
| 9555 |
|
| 9556 |
|
| 9557 |
|
| 9558 |
|
| 9559 |
|
| 9560 |
|
| 9561 |
|
| 9562 |
|
| 9563 |
|
| 9564 |
|
| 9565 |
@Nullable |
| 9566 |
public AutofillValue getAutofillValue() { |
| 9567 |
return null; |
| 9568 |
} |
| 9569 |
|
| 9570 |
|
| 9571 |
|
| 9572 |
|
| 9573 |
|
| 9574 |
|
| 9575 |
|
| 9576 |
|
| 9577 |
|
| 9578 |
|
| 9579 |
|
| 9580 |
|
| 9581 |
@ViewDebug.ExportedProperty(mapping = { |
| 9582 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_AUTOFILL_AUTO, to = "auto"), |
| 9583 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_AUTOFILL_YES, to = "yes"), |
| 9584 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_AUTOFILL_NO, to = "no"), |
| 9585 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, |
| 9586 |
to = "yesExcludeDescendants"), |
| 9587 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, |
| 9588 |
to = "noExcludeDescendants")}) |
| 9589 |
@InspectableProperty(enumMapping = { |
| 9590 |
@EnumEntry(value = IMPORTANT_FOR_AUTOFILL_AUTO, name = "auto"), |
| 9591 |
@EnumEntry(value = IMPORTANT_FOR_AUTOFILL_YES, name = "yes"), |
| 9592 |
@EnumEntry(value = IMPORTANT_FOR_AUTOFILL_NO, name = "no"), |
| 9593 |
@EnumEntry(value = IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS, |
| 9594 |
name = "yesExcludeDescendants"), |
| 9595 |
@EnumEntry(value = IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS, |
| 9596 |
name = "noExcludeDescendants"), |
| 9597 |
}) |
| 9598 |
public @AutofillImportance int getImportantForAutofill() { |
| 9599 |
return (mPrivateFlags3 |
| 9600 |
& PFLAG3_IMPORTANT_FOR_AUTOFILL_MASK) >> PFLAG3_IMPORTANT_FOR_AUTOFILL_SHIFT; |
| 9601 |
} |
| 9602 |
|
| 9603 |
|
| 9604 |
|
| 9605 |
|
| 9606 |
|
| 9607 |
|
| 9608 |
|
| 9609 |
|
| 9610 |
|
| 9611 |
|
| 9612 |
|
| 9613 |
|
| 9614 |
|
| 9615 |
|
| 9616 |
|
| 9617 |
|
| 9618 |
|
| 9619 |
|
| 9620 |
|
| 9621 |
|
| 9622 |
|
| 9623 |
|
| 9624 |
|
| 9625 |
|
| 9626 |
|
| 9627 |
|
| 9628 |
|
| 9629 |
|
| 9630 |
|
| 9631 |
|
| 9632 |
|
| 9633 |
|
| 9634 |
public void setImportantForAutofill(@AutofillImportance int mode) { |
| 9635 |
mPrivateFlags3 &= ~PFLAG3_IMPORTANT_FOR_AUTOFILL_MASK; |
| 9636 |
mPrivateFlags3 |= (mode << PFLAG3_IMPORTANT_FOR_AUTOFILL_SHIFT) |
| 9637 |
& PFLAG3_IMPORTANT_FOR_AUTOFILL_MASK; |
| 9638 |
} |
| 9639 |
|
| 9640 |
|
| 9641 |
|
| 9642 |
|
| 9643 |
|
| 9644 |
|
| 9645 |
|
| 9646 |
|
| 9647 |
|
| 9648 |
|
| 9649 |
|
| 9650 |
|
| 9651 |
|
| 9652 |
|
| 9653 |
|
| 9654 |
|
| 9655 |
|
| 9656 |
|
| 9657 |
|
| 9658 |
|
| 9659 |
|
| 9660 |
|
| 9661 |
|
| 9662 |
|
| 9663 |
|
| 9664 |
|
| 9665 |
|
| 9666 |
|
| 9667 |
|
| 9668 |
|
| 9669 |
|
| 9670 |
|
| 9671 |
|
| 9672 |
|
| 9673 |
|
| 9674 |
|
| 9675 |
|
| 9676 |
|
| 9677 |
|
| 9678 |
|
| 9679 |
|
| 9680 |
|
| 9681 |
|
| 9682 |
|
| 9683 |
|
| 9684 |
|
| 9685 |
|
| 9686 |
|
| 9687 |
|
| 9688 |
|
| 9689 |
|
| 9690 |
|
| 9691 |
|
| 9692 |
|
| 9693 |
|
| 9694 |
|
| 9695 |
|
| 9696 |
|
| 9697 |
|
| 9698 |
public final boolean isImportantForAutofill() { |
| 9699 |
|
| 9700 |
ViewParent parent = mParent; |
| 9701 |
while (parent instanceof View) { |
| 9702 |
final int parentImportance = ((View) parent).getImportantForAutofill(); |
| 9703 |
if (parentImportance == IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS |
| 9704 |
|| parentImportance == IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS) { |
| 9705 |
if (Log.isLoggable(AUTOFILL_LOG_TAG, Log.VERBOSE)) { |
| 9706 |
Log.v(AUTOFILL_LOG_TAG, "View (" + this + ") is not important for autofill " |
| 9707 |
+ "because parent " + parent + "'s importance is " + parentImportance); |
| 9708 |
} |
| 9709 |
return false; |
| 9710 |
} |
| 9711 |
parent = parent.getParent(); |
| 9712 |
} |
| 9713 |
|
| 9714 |
final int importance = getImportantForAutofill(); |
| 9715 |
|
| 9716 |
|
| 9717 |
if (importance == IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS |
| 9718 |
|| importance == IMPORTANT_FOR_AUTOFILL_YES) { |
| 9719 |
return true; |
| 9720 |
} |
| 9721 |
if (importance == IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS |
| 9722 |
|| importance == IMPORTANT_FOR_AUTOFILL_NO) { |
| 9723 |
if (Log.isLoggable(AUTOFILL_LOG_TAG, Log.VERBOSE)) { |
| 9724 |
Log.v(AUTOFILL_LOG_TAG, "View (" + this + ") is not important for autofill " |
| 9725 |
+ "because its importance is " + importance); |
| 9726 |
} |
| 9727 |
return false; |
| 9728 |
} |
| 9729 |
|
| 9730 |
|
| 9731 |
if (importance != IMPORTANT_FOR_AUTOFILL_AUTO) { |
| 9732 |
Log.w(AUTOFILL_LOG_TAG, "invalid autofill importance (" + importance + " on view " |
| 9733 |
+ this); |
| 9734 |
return false; |
| 9735 |
} |
| 9736 |
|
| 9737 |
|
| 9738 |
final int id = mID; |
| 9739 |
if (id != NO_ID && !isViewIdGenerated(id)) { |
| 9740 |
final Resources res = getResources(); |
| 9741 |
String entry = null; |
| 9742 |
String pkg = null; |
| 9743 |
try { |
| 9744 |
entry = res.getResourceEntryName(id); |
| 9745 |
pkg = res.getResourcePackageName(id); |
| 9746 |
} catch (Resources.NotFoundException e) { |
| 9747 |
|
| 9748 |
} |
| 9749 |
if (entry != null && pkg != null && pkg.equals(mContext.getPackageName())) { |
| 9750 |
return true; |
| 9751 |
} |
| 9752 |
} |
| 9753 |
|
| 9754 |
|
| 9755 |
if (getAutofillHints() != null) { |
| 9756 |
return true; |
| 9757 |
} |
| 9758 |
|
| 9759 |
|
| 9760 |
return false; |
| 9761 |
} |
| 9762 |
|
| 9763 |
|
| 9764 |
|
| 9765 |
|
| 9766 |
|
| 9767 |
|
| 9768 |
|
| 9769 |
|
| 9770 |
|
| 9771 |
|
| 9772 |
|
| 9773 |
|
| 9774 |
@ViewDebug.ExportedProperty(mapping = { |
| 9775 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_CONTENT_CAPTURE_AUTO, to = "auto"), |
| 9776 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_CONTENT_CAPTURE_YES, to = "yes"), |
| 9777 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_CONTENT_CAPTURE_NO, to = "no"), |
| 9778 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS, |
| 9779 |
to = "yesExcludeDescendants"), |
| 9780 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS, |
| 9781 |
to = "noExcludeDescendants")}) |
| 9782 |
@InspectableProperty(enumMapping = { |
| 9783 |
@EnumEntry(value = IMPORTANT_FOR_CONTENT_CAPTURE_AUTO, name = "auto"), |
| 9784 |
@EnumEntry(value = IMPORTANT_FOR_CONTENT_CAPTURE_YES, name = "yes"), |
| 9785 |
@EnumEntry(value = IMPORTANT_FOR_CONTENT_CAPTURE_NO, name = "no"), |
| 9786 |
@EnumEntry(value = IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS, |
| 9787 |
name = "yesExcludeDescendants"), |
| 9788 |
@EnumEntry(value = IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS, |
| 9789 |
name = "noExcludeDescendants"), |
| 9790 |
}) |
| 9791 |
public @ContentCaptureImportance int getImportantForContentCapture() { |
| 9792 |
|
| 9793 |
|
| 9794 |
return mPrivateFlags4 & PFLAG4_IMPORTANT_FOR_CONTENT_CAPTURE_MASK; |
| 9795 |
} |
| 9796 |
|
| 9797 |
|
| 9798 |
|
| 9799 |
|
| 9800 |
|
| 9801 |
|
| 9802 |
|
| 9803 |
|
| 9804 |
|
| 9805 |
|
| 9806 |
|
| 9807 |
|
| 9808 |
|
| 9809 |
|
| 9810 |
|
| 9811 |
public void setImportantForContentCapture(@ContentCaptureImportance int mode) { |
| 9812 |
|
| 9813 |
mPrivateFlags4 &= ~PFLAG4_IMPORTANT_FOR_CONTENT_CAPTURE_MASK; |
| 9814 |
|
| 9815 |
|
| 9816 |
|
| 9817 |
mPrivateFlags4 |= (mode & PFLAG4_IMPORTANT_FOR_CONTENT_CAPTURE_MASK); |
| 9818 |
} |
| 9819 |
|
| 9820 |
|
| 9821 |
|
| 9822 |
|
| 9823 |
|
| 9824 |
|
| 9825 |
|
| 9826 |
|
| 9827 |
|
| 9828 |
|
| 9829 |
|
| 9830 |
|
| 9831 |
|
| 9832 |
|
| 9833 |
|
| 9834 |
|
| 9835 |
|
| 9836 |
public final boolean isImportantForContentCapture() { |
| 9837 |
boolean isImportant; |
| 9838 |
if ((mPrivateFlags4 & PFLAG4_CONTENT_CAPTURE_IMPORTANCE_IS_CACHED) != 0) { |
| 9839 |
isImportant = (mPrivateFlags4 & PFLAG4_CONTENT_CAPTURE_IMPORTANCE_CACHED_VALUE) != 0; |
| 9840 |
return isImportant; |
| 9841 |
} |
| 9842 |
|
| 9843 |
isImportant = calculateIsImportantForContentCapture(); |
| 9844 |
|
| 9845 |
mPrivateFlags4 &= ~PFLAG4_CONTENT_CAPTURE_IMPORTANCE_CACHED_VALUE; |
| 9846 |
if (isImportant) { |
| 9847 |
mPrivateFlags4 |= PFLAG4_CONTENT_CAPTURE_IMPORTANCE_CACHED_VALUE; |
| 9848 |
} |
| 9849 |
mPrivateFlags4 |= PFLAG4_CONTENT_CAPTURE_IMPORTANCE_IS_CACHED; |
| 9850 |
return isImportant; |
| 9851 |
} |
| 9852 |
|
| 9853 |
|
| 9854 |
|
| 9855 |
|
| 9856 |
|
| 9857 |
private boolean calculateIsImportantForContentCapture() { |
| 9858 |
|
| 9859 |
ViewParent parent = mParent; |
| 9860 |
while (parent instanceof View) { |
| 9861 |
final int parentImportance = ((View) parent).getImportantForContentCapture(); |
| 9862 |
if (parentImportance == IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS |
| 9863 |
|| parentImportance == IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS) { |
| 9864 |
if (Log.isLoggable(CONTENT_CAPTURE_LOG_TAG, Log.VERBOSE)) { |
| 9865 |
Log.v(CONTENT_CAPTURE_LOG_TAG, "View (" + this + ") is not important for " |
| 9866 |
+ "content capture because parent " + parent + "'s importance is " |
| 9867 |
+ parentImportance); |
| 9868 |
} |
| 9869 |
return false; |
| 9870 |
} |
| 9871 |
parent = parent.getParent(); |
| 9872 |
} |
| 9873 |
|
| 9874 |
final int importance = getImportantForContentCapture(); |
| 9875 |
|
| 9876 |
|
| 9877 |
if (importance == IMPORTANT_FOR_CONTENT_CAPTURE_YES_EXCLUDE_DESCENDANTS |
| 9878 |
|| importance == IMPORTANT_FOR_CONTENT_CAPTURE_YES) { |
| 9879 |
return true; |
| 9880 |
} |
| 9881 |
if (importance == IMPORTANT_FOR_CONTENT_CAPTURE_NO_EXCLUDE_DESCENDANTS |
| 9882 |
|| importance == IMPORTANT_FOR_CONTENT_CAPTURE_NO) { |
| 9883 |
if (Log.isLoggable(CONTENT_CAPTURE_LOG_TAG, Log.VERBOSE)) { |
| 9884 |
Log.v(CONTENT_CAPTURE_LOG_TAG, "View (" + this + ") is not important for content " |
| 9885 |
+ "capture because its importance is " + importance); |
| 9886 |
} |
| 9887 |
return false; |
| 9888 |
} |
| 9889 |
|
| 9890 |
|
| 9891 |
if (importance != IMPORTANT_FOR_CONTENT_CAPTURE_AUTO) { |
| 9892 |
Log.w(CONTENT_CAPTURE_LOG_TAG, "invalid content capture importance (" + importance |
| 9893 |
+ " on view " + this); |
| 9894 |
return false; |
| 9895 |
} |
| 9896 |
|
| 9897 |
|
| 9898 |
if (this instanceof ViewGroup) { |
| 9899 |
final ViewGroup group = (ViewGroup) this; |
| 9900 |
for (int i = 0; i < group.getChildCount(); i++) { |
| 9901 |
final View child = group.getChildAt(i); |
| 9902 |
if (child.isImportantForContentCapture()) { |
| 9903 |
return true; |
| 9904 |
} |
| 9905 |
} |
| 9906 |
} |
| 9907 |
|
| 9908 |
|
| 9909 |
if (getAutofillHints() != null) { |
| 9910 |
return true; |
| 9911 |
} |
| 9912 |
|
| 9913 |
|
| 9914 |
return false; |
| 9915 |
} |
| 9916 |
|
| 9917 |
|
| 9918 |
|
| 9919 |
|
| 9920 |
|
| 9921 |
|
| 9922 |
|
| 9923 |
|
| 9924 |
|
| 9925 |
|
| 9926 |
|
| 9927 |
|
| 9928 |
|
| 9929 |
|
| 9930 |
|
| 9931 |
|
| 9932 |
|
| 9933 |
private void notifyAppearedOrDisappearedForContentCaptureIfNeeded(boolean appeared) { |
| 9934 |
AttachInfo ai = mAttachInfo; |
| 9935 |
|
| 9936 |
if (ai != null && !ai.mReadyForContentCaptureUpdates) return; |
| 9937 |
|
| 9938 |
|
| 9939 |
if (mContext.getContentCaptureOptions() == null) return; |
| 9940 |
|
| 9941 |
if (appeared) { |
| 9942 |
|
| 9943 |
|
| 9944 |
|
| 9945 |
|
| 9946 |
|
| 9947 |
|
| 9948 |
|
| 9949 |
final boolean isRecycledWithoutRelayout = getNotifiedContentCaptureDisappeared() |
| 9950 |
&& getVisibility() == VISIBLE |
| 9951 |
&& !isLayoutRequested(); |
| 9952 |
if (getVisibility() != VISIBLE || getNotifiedContentCaptureAppeared() |
| 9953 |
|| !(isLaidOut() || isRecycledWithoutRelayout)) { |
| 9954 |
if (DEBUG_CONTENT_CAPTURE) { |
| 9955 |
Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'appeared' on " + this + ": laid=" |
| 9956 |
+ isLaidOut() + ", visibleToUser=" + isVisibleToUser() |
| 9957 |
+ ", visible=" + (getVisibility() == VISIBLE) |
| 9958 |
+ ": alreadyNotifiedAppeared=" + getNotifiedContentCaptureAppeared() |
| 9959 |
+ ", alreadyNotifiedDisappeared=" |
| 9960 |
+ getNotifiedContentCaptureDisappeared()); |
| 9961 |
} |
| 9962 |
return; |
| 9963 |
} |
| 9964 |
} else { |
| 9965 |
if (!getNotifiedContentCaptureAppeared() || getNotifiedContentCaptureDisappeared()) { |
| 9966 |
if (DEBUG_CONTENT_CAPTURE) { |
| 9967 |
Log.v(CONTENT_CAPTURE_LOG_TAG, "Ignoring 'disappeared' on " + this + ": laid=" |
| 9968 |
+ isLaidOut() + ", visibleToUser=" + isVisibleToUser() |
| 9969 |
+ ", visible=" + (getVisibility() == VISIBLE) |
| 9970 |
+ ": alreadyNotifiedAppeared=" + getNotifiedContentCaptureAppeared() |
| 9971 |
+ ", alreadyNotifiedDisappeared=" |
| 9972 |
+ getNotifiedContentCaptureDisappeared()); |
| 9973 |
} |
| 9974 |
return; |
| 9975 |
} |
| 9976 |
} |
| 9977 |
|
| 9978 |
ContentCaptureSession session = getContentCaptureSession(); |
| 9979 |
if (session == null) return; |
| 9980 |
|
| 9981 |
|
| 9982 |
|
| 9983 |
if (!isImportantForContentCapture()) return; |
| 9984 |
|
| 9985 |
if (appeared) { |
| 9986 |
setNotifiedContentCaptureAppeared(); |
| 9987 |
|
| 9988 |
if (ai != null) { |
| 9989 |
ai.delayNotifyContentCaptureEvent(session, this, appeared); |
| 9990 |
} else { |
| 9991 |
if (DEBUG_CONTENT_CAPTURE) { |
| 9992 |
Log.w(CONTENT_CAPTURE_LOG_TAG, "no AttachInfo on appeared for " + this); |
| 9993 |
} |
| 9994 |
} |
| 9995 |
} else { |
| 9996 |
mPrivateFlags4 |= PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED; |
| 9997 |
mPrivateFlags4 &= ~PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED; |
| 9998 |
|
| 9999 |
if (ai != null) { |
| 10000 |
ai.delayNotifyContentCaptureEvent(session, this, appeared); |
| 10001 |
} else { |
| 10002 |
if (DEBUG_CONTENT_CAPTURE) { |
| 10003 |
Log.v(CONTENT_CAPTURE_LOG_TAG, "no AttachInfo on disappeared for " + this); |
| 10004 |
} |
| 10005 |
} |
| 10006 |
|
| 10007 |
|
| 10008 |
|
| 10009 |
|
| 10010 |
if (!isTemporarilyDetached()) { |
| 10011 |
clearTranslationState(); |
| 10012 |
} |
| 10013 |
} |
| 10014 |
} |
| 10015 |
|
| 10016 |
private void setNotifiedContentCaptureAppeared() { |
| 10017 |
mPrivateFlags4 |= PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED; |
| 10018 |
mPrivateFlags4 &= ~PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED; |
| 10019 |
} |
| 10020 |
|
| 10021 |
|
| 10022 |
protected boolean getNotifiedContentCaptureAppeared() { |
| 10023 |
return (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_APPEARED) != 0; |
| 10024 |
} |
| 10025 |
|
| 10026 |
|
| 10027 |
private boolean getNotifiedContentCaptureDisappeared() { |
| 10028 |
return (mPrivateFlags4 & PFLAG4_NOTIFIED_CONTENT_CAPTURE_DISAPPEARED) != 0; |
| 10029 |
} |
| 10030 |
|
| 10031 |
|
| 10032 |
|
| 10033 |
|
| 10034 |
|
| 10035 |
|
| 10036 |
|
| 10037 |
|
| 10038 |
|
| 10039 |
|
| 10040 |
|
| 10041 |
|
| 10042 |
|
| 10043 |
|
| 10044 |
|
| 10045 |
|
| 10046 |
|
| 10047 |
|
| 10048 |
|
| 10049 |
|
| 10050 |
|
| 10051 |
|
| 10052 |
|
| 10053 |
|
| 10054 |
|
| 10055 |
|
| 10056 |
|
| 10057 |
|
| 10058 |
public void setContentCaptureSession(@Nullable ContentCaptureSession contentCaptureSession) { |
| 10059 |
mContentCaptureSession = contentCaptureSession; |
| 10060 |
} |
| 10061 |
|
| 10062 |
|
| 10063 |
|
| 10064 |
|
| 10065 |
|
| 10066 |
|
| 10067 |
|
| 10068 |
|
| 10069 |
@Nullable |
| 10070 |
public final ContentCaptureSession getContentCaptureSession() { |
| 10071 |
if (mContentCaptureSessionCached) { |
| 10072 |
return mContentCaptureSession; |
| 10073 |
} |
| 10074 |
|
| 10075 |
mContentCaptureSession = getAndCacheContentCaptureSession(); |
| 10076 |
mContentCaptureSessionCached = true; |
| 10077 |
return mContentCaptureSession; |
| 10078 |
} |
| 10079 |
|
| 10080 |
@Nullable |
| 10081 |
private ContentCaptureSession getAndCacheContentCaptureSession() { |
| 10082 |
|
| 10083 |
if (mContentCaptureSession != null) { |
| 10084 |
return mContentCaptureSession; |
| 10085 |
} |
| 10086 |
|
| 10087 |
|
| 10088 |
ContentCaptureSession session = null; |
| 10089 |
if (mParent instanceof View) { |
| 10090 |
session = ((View) mParent).getContentCaptureSession(); |
| 10091 |
} |
| 10092 |
|
| 10093 |
|
| 10094 |
if (session == null) { |
| 10095 |
final ContentCaptureManager ccm = mContext |
| 10096 |
.getSystemService(ContentCaptureManager.class); |
| 10097 |
return ccm == null ? null : ccm.getMainContentCaptureSession(); |
| 10098 |
} |
| 10099 |
return session; |
| 10100 |
} |
| 10101 |
|
| 10102 |
@Nullable |
| 10103 |
private AutofillManager getAutofillManager() { |
| 10104 |
return mContext.getSystemService(AutofillManager.class); |
| 10105 |
} |
| 10106 |
|
| 10107 |
private boolean isAutofillable() { |
| 10108 |
if (getAutofillType() == AUTOFILL_TYPE_NONE) return false; |
| 10109 |
|
| 10110 |
if (!isImportantForAutofill()) { |
| 10111 |
|
| 10112 |
|
| 10113 |
final AutofillOptions options = mContext.getAutofillOptions(); |
| 10114 |
if (options == null || !options.isAugmentedAutofillEnabled(mContext)) { |
| 10115 |
return false; |
| 10116 |
} |
| 10117 |
final AutofillManager afm = getAutofillManager(); |
| 10118 |
if (afm == null) return false; |
| 10119 |
afm.notifyViewEnteredForAugmentedAutofill(this); |
| 10120 |
} |
| 10121 |
|
| 10122 |
return getAutofillViewId() > LAST_APP_AUTOFILL_ID; |
| 10123 |
} |
| 10124 |
|
| 10125 |
|
| 10126 |
public boolean canNotifyAutofillEnterExitEvent() { |
| 10127 |
return isAutofillable() && isAttachedToWindow(); |
| 10128 |
} |
| 10129 |
|
| 10130 |
private void populateVirtualStructure(ViewStructure structure, |
| 10131 |
AccessibilityNodeProvider provider, AccessibilityNodeInfo info, |
| 10132 |
boolean forAutofill) { |
| 10133 |
structure.setId(AccessibilityNodeInfo.getVirtualDescendantId(info.getSourceNodeId()), |
| 10134 |
null, null, info.getViewIdResourceName()); |
| 10135 |
Rect rect = structure.getTempRect(); |
| 10136 |
info.getBoundsInParent(rect); |
| 10137 |
structure.setDimens(rect.left, rect.top, 0, 0, rect.width(), rect.height()); |
| 10138 |
structure.setVisibility(VISIBLE); |
| 10139 |
structure.setEnabled(info.isEnabled()); |
| 10140 |
if (info.isClickable()) { |
| 10141 |
structure.setClickable(true); |
| 10142 |
} |
| 10143 |
if (info.isFocusable()) { |
| 10144 |
structure.setFocusable(true); |
| 10145 |
} |
| 10146 |
if (info.isFocused()) { |
| 10147 |
structure.setFocused(true); |
| 10148 |
} |
| 10149 |
if (info.isAccessibilityFocused()) { |
| 10150 |
structure.setAccessibilityFocused(true); |
| 10151 |
} |
| 10152 |
if (info.isSelected()) { |
| 10153 |
structure.setSelected(true); |
| 10154 |
} |
| 10155 |
if (info.isLongClickable()) { |
| 10156 |
structure.setLongClickable(true); |
| 10157 |
} |
| 10158 |
if (info.isCheckable()) { |
| 10159 |
structure.setCheckable(true); |
| 10160 |
if (info.isChecked()) { |
| 10161 |
structure.setChecked(true); |
| 10162 |
} |
| 10163 |
} |
| 10164 |
if (info.isContextClickable()) { |
| 10165 |
structure.setContextClickable(true); |
| 10166 |
} |
| 10167 |
if (forAutofill) { |
| 10168 |
structure.setAutofillId(new AutofillId(getAutofillId(), |
| 10169 |
AccessibilityNodeInfo.getVirtualDescendantId(info.getSourceNodeId()))); |
| 10170 |
} |
| 10171 |
CharSequence cname = info.getClassName(); |
| 10172 |
structure.setClassName(cname != null ? cname.toString() : null); |
| 10173 |
structure.setContentDescription(info.getContentDescription()); |
| 10174 |
if (forAutofill) { |
| 10175 |
final int maxTextLength = info.getMaxTextLength(); |
| 10176 |
if (maxTextLength != -1) { |
| 10177 |
structure.setMaxTextLength(maxTextLength); |
| 10178 |
} |
| 10179 |
structure.setHint(info.getHintText()); |
| 10180 |
} |
| 10181 |
CharSequence text = info.getText(); |
| 10182 |
boolean hasText = text != null || info.getError() != null; |
| 10183 |
if (hasText) { |
| 10184 |
structure.setText(text, info.getTextSelectionStart(), info.getTextSelectionEnd()); |
| 10185 |
} |
| 10186 |
if (forAutofill) { |
| 10187 |
if (info.isEditable()) { |
| 10188 |
structure.setDataIsSensitive(true); |
| 10189 |
if (hasText) { |
| 10190 |
structure.setAutofillType(AUTOFILL_TYPE_TEXT); |
| 10191 |
structure.setAutofillValue(AutofillValue.forText(text)); |
| 10192 |
} |
| 10193 |
int inputType = info.getInputType(); |
| 10194 |
if (inputType == 0 && info.isPassword()) { |
| 10195 |
inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD; |
| 10196 |
} |
| 10197 |
structure.setInputType(inputType); |
| 10198 |
} else { |
| 10199 |
structure.setDataIsSensitive(false); |
| 10200 |
} |
| 10201 |
} |
| 10202 |
final int NCHILDREN = info.getChildCount(); |
| 10203 |
if (NCHILDREN > 0) { |
| 10204 |
structure.setChildCount(NCHILDREN); |
| 10205 |
for (int i=0; i<NCHILDREN; i++) { |
| 10206 |
if (AccessibilityNodeInfo.getVirtualDescendantId(info.getChildNodeIds().get(i)) |
| 10207 |
== AccessibilityNodeProvider.HOST_VIEW_ID) { |
| 10208 |
Log.e(VIEW_LOG_TAG, "Virtual view pointing to its host. Ignoring"); |
| 10209 |
continue; |
| 10210 |
} |
| 10211 |
AccessibilityNodeInfo cinfo = provider.createAccessibilityNodeInfo( |
| 10212 |
AccessibilityNodeInfo.getVirtualDescendantId(info.getChildId(i))); |
| 10213 |
if (cinfo != null) { |
| 10214 |
ViewStructure child = structure.newChild(i); |
| 10215 |
populateVirtualStructure(child, provider, cinfo, forAutofill); |
| 10216 |
cinfo.recycle(); |
| 10217 |
} |
| 10218 |
} |
| 10219 |
} |
| 10220 |
} |
| 10221 |
|
| 10222 |
|
| 10223 |
|
| 10224 |
|
| 10225 |
|
| 10226 |
|
| 10227 |
public void dispatchProvideStructure(ViewStructure structure) { |
| 10228 |
dispatchProvideStructure(structure, VIEW_STRUCTURE_FOR_ASSIST, 0); |
| 10229 |
} |
| 10230 |
|
| 10231 |
|
| 10232 |
|
| 10233 |
|
| 10234 |
|
| 10235 |
|
| 10236 |
|
| 10237 |
|
| 10238 |
|
| 10239 |
|
| 10240 |
|
| 10241 |
|
| 10242 |
|
| 10243 |
|
| 10244 |
|
| 10245 |
|
| 10246 |
|
| 10247 |
|
| 10248 |
|
| 10249 |
|
| 10250 |
|
| 10251 |
|
| 10252 |
|
| 10253 |
|
| 10254 |
|
| 10255 |
|
| 10256 |
|
| 10257 |
|
| 10258 |
|
| 10259 |
|
| 10260 |
|
| 10261 |
|
| 10262 |
|
| 10263 |
|
| 10264 |
|
| 10265 |
|
| 10266 |
|
| 10267 |
|
| 10268 |
public void dispatchProvideAutofillStructure(@NonNull ViewStructure structure, |
| 10269 |
@AutofillFlags int flags) { |
| 10270 |
dispatchProvideStructure(structure, VIEW_STRUCTURE_FOR_AUTOFILL, flags); |
| 10271 |
} |
| 10272 |
|
| 10273 |
private void dispatchProvideStructure(@NonNull ViewStructure structure, |
| 10274 |
@ViewStructureType int viewFor, @AutofillFlags int flags) { |
| 10275 |
if (viewFor == VIEW_STRUCTURE_FOR_AUTOFILL) { |
| 10276 |
structure.setAutofillId(getAutofillId()); |
| 10277 |
onProvideAutofillStructure(structure, flags); |
| 10278 |
onProvideAutofillVirtualStructure(structure, flags); |
| 10279 |
} else if (!isAssistBlocked()) { |
| 10280 |
onProvideStructure(structure); |
| 10281 |
onProvideVirtualStructure(structure); |
| 10282 |
} else { |
| 10283 |
structure.setClassName(getAccessibilityClassName().toString()); |
| 10284 |
structure.setAssistBlocked(true); |
| 10285 |
} |
| 10286 |
} |
| 10287 |
|
| 10288 |
|
| 10289 |
|
| 10290 |
|
| 10291 |
|
| 10292 |
|
| 10293 |
public void dispatchInitialProvideContentCaptureStructure() { |
| 10294 |
AttachInfo ai = mAttachInfo; |
| 10295 |
if (ai == null) { |
| 10296 |
Log.w(CONTENT_CAPTURE_LOG_TAG, |
| 10297 |
"dispatchProvideContentCaptureStructure(): no AttachInfo for " + this); |
| 10298 |
return; |
| 10299 |
} |
| 10300 |
ContentCaptureManager ccm = ai.mContentCaptureManager; |
| 10301 |
if (ccm == null) { |
| 10302 |
Log.w(CONTENT_CAPTURE_LOG_TAG, "dispatchProvideContentCaptureStructure(): " |
| 10303 |
+ "no ContentCaptureManager for " + this); |
| 10304 |
return; |
| 10305 |
} |
| 10306 |
|
| 10307 |
|
| 10308 |
|
| 10309 |
|
| 10310 |
ai.mReadyForContentCaptureUpdates = true; |
| 10311 |
|
| 10312 |
if (!isImportantForContentCapture()) { |
| 10313 |
if (Log.isLoggable(CONTENT_CAPTURE_LOG_TAG, Log.DEBUG)) { |
| 10314 |
Log.d(CONTENT_CAPTURE_LOG_TAG, |
| 10315 |
"dispatchProvideContentCaptureStructure(): decorView is not important"); |
| 10316 |
} |
| 10317 |
return; |
| 10318 |
} |
| 10319 |
|
| 10320 |
ai.mContentCaptureManager = ccm; |
| 10321 |
|
| 10322 |
ContentCaptureSession session = getContentCaptureSession(); |
| 10323 |
if (session == null) { |
| 10324 |
if (Log.isLoggable(CONTENT_CAPTURE_LOG_TAG, Log.DEBUG)) { |
| 10325 |
Log.d(CONTENT_CAPTURE_LOG_TAG, |
| 10326 |
"dispatchProvideContentCaptureStructure(): no session for " + this); |
| 10327 |
} |
| 10328 |
return; |
| 10329 |
} |
| 10330 |
|
| 10331 |
session.internalNotifyViewTreeEvent( true); |
| 10332 |
try { |
| 10333 |
dispatchProvideContentCaptureStructure(); |
| 10334 |
} finally { |
| 10335 |
session.internalNotifyViewTreeEvent( false); |
| 10336 |
} |
| 10337 |
} |
| 10338 |
|
| 10339 |
|
| 10340 |
void dispatchProvideContentCaptureStructure() { |
| 10341 |
ContentCaptureSession session = getContentCaptureSession(); |
| 10342 |
if (session != null) { |
| 10343 |
ViewStructure structure = session.newViewStructure(this); |
| 10344 |
onProvideContentCaptureStructure(structure, 0); |
| 10345 |
setNotifiedContentCaptureAppeared(); |
| 10346 |
session.notifyViewAppeared(structure); |
| 10347 |
} |
| 10348 |
} |
| 10349 |
|
| 10350 |
|
| 10351 |
|
| 10352 |
|
| 10353 |
|
| 10354 |
|
| 10355 |
|
| 10356 |
|
| 10357 |
public void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) { |
| 10358 |
if (mAttachInfo == null) { |
| 10359 |
return; |
| 10360 |
} |
| 10361 |
|
| 10362 |
Rect bounds = mAttachInfo.mTmpInvalRect; |
| 10363 |
|
| 10364 |
getDrawingRect(bounds); |
| 10365 |
info.setBoundsInParent(bounds); |
| 10366 |
|
| 10367 |
getBoundsOnScreen(bounds, true); |
| 10368 |
info.setBoundsInScreen(bounds); |
| 10369 |
|
| 10370 |
ViewParent parent = getParentForAccessibility(); |
| 10371 |
if (parent instanceof View) { |
| 10372 |
info.setParent((View) parent); |
| 10373 |
} |
| 10374 |
|
| 10375 |
if (mID != View.NO_ID) { |
| 10376 |
View rootView = getRootView(); |
| 10377 |
if (rootView == null) { |
| 10378 |
rootView = this; |
| 10379 |
} |
| 10380 |
|
| 10381 |
View label = rootView.findLabelForView(this, mID); |
| 10382 |
if (label != null) { |
| 10383 |
info.setLabeledBy(label); |
| 10384 |
} |
| 10385 |
|
| 10386 |
if ((mAttachInfo.mAccessibilityFetchFlags |
| 10387 |
& AccessibilityNodeInfo.FLAG_REPORT_VIEW_IDS) != 0 |
| 10388 |
&& Resources.resourceHasPackage(mID)) { |
| 10389 |
try { |
| 10390 |
String viewId = getResources().getResourceName(mID); |
| 10391 |
info.setViewIdResourceName(viewId); |
| 10392 |
} catch (Resources.NotFoundException nfe) { |
| 10393 |
|
| 10394 |
} |
| 10395 |
} |
| 10396 |
} |
| 10397 |
|
| 10398 |
if (mLabelForId != View.NO_ID) { |
| 10399 |
View rootView = getRootView(); |
| 10400 |
if (rootView == null) { |
| 10401 |
rootView = this; |
| 10402 |
} |
| 10403 |
View labeled = rootView.findViewInsideOutShouldExist(this, mLabelForId); |
| 10404 |
if (labeled != null) { |
| 10405 |
info.setLabelFor(labeled); |
| 10406 |
} |
| 10407 |
} |
| 10408 |
|
| 10409 |
if (mAccessibilityTraversalBeforeId != View.NO_ID) { |
| 10410 |
View rootView = getRootView(); |
| 10411 |
if (rootView == null) { |
| 10412 |
rootView = this; |
| 10413 |
} |
| 10414 |
View next = rootView.findViewInsideOutShouldExist(this, |
| 10415 |
mAccessibilityTraversalBeforeId); |
| 10416 |
if (next != null && next.includeForAccessibility()) { |
| 10417 |
info.setTraversalBefore(next); |
| 10418 |
} |
| 10419 |
} |
| 10420 |
|
| 10421 |
if (mAccessibilityTraversalAfterId != View.NO_ID) { |
| 10422 |
View rootView = getRootView(); |
| 10423 |
if (rootView == null) { |
| 10424 |
rootView = this; |
| 10425 |
} |
| 10426 |
View next = rootView.findViewInsideOutShouldExist(this, |
| 10427 |
mAccessibilityTraversalAfterId); |
| 10428 |
if (next != null && next.includeForAccessibility()) { |
| 10429 |
info.setTraversalAfter(next); |
| 10430 |
} |
| 10431 |
} |
| 10432 |
|
| 10433 |
info.setVisibleToUser(isVisibleToUser()); |
| 10434 |
|
| 10435 |
info.setImportantForAccessibility(isImportantForAccessibility()); |
| 10436 |
info.setPackageName(mContext.getPackageName()); |
| 10437 |
info.setClassName(getAccessibilityClassName()); |
| 10438 |
info.setStateDescription(getStateDescription()); |
| 10439 |
info.setContentDescription(getContentDescription()); |
| 10440 |
|
| 10441 |
info.setEnabled(isEnabled()); |
| 10442 |
info.setClickable(isClickable()); |
| 10443 |
info.setFocusable(isFocusable()); |
| 10444 |
info.setScreenReaderFocusable(isScreenReaderFocusable()); |
| 10445 |
info.setFocused(isFocused()); |
| 10446 |
info.setAccessibilityFocused(isAccessibilityFocused()); |
| 10447 |
info.setSelected(isSelected()); |
| 10448 |
info.setLongClickable(isLongClickable()); |
| 10449 |
info.setContextClickable(isContextClickable()); |
| 10450 |
info.setLiveRegion(getAccessibilityLiveRegion()); |
| 10451 |
if ((mTooltipInfo != null) && (mTooltipInfo.mTooltipText != null)) { |
| 10452 |
info.setTooltipText(mTooltipInfo.mTooltipText); |
| 10453 |
info.addAction((mTooltipInfo.mTooltipPopup == null) |
| 10454 |
? AccessibilityNodeInfo.AccessibilityAction.ACTION_SHOW_TOOLTIP |
| 10455 |
: AccessibilityNodeInfo.AccessibilityAction.ACTION_HIDE_TOOLTIP); |
| 10456 |
} |
| 10457 |
|
| 10458 |
|
| 10459 |
|
| 10460 |
|
| 10461 |
info.addAction(AccessibilityNodeInfo.ACTION_SELECT); |
| 10462 |
info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_SELECTION); |
| 10463 |
|
| 10464 |
if (isFocusable()) { |
| 10465 |
if (isFocused()) { |
| 10466 |
info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_FOCUS); |
| 10467 |
} else { |
| 10468 |
info.addAction(AccessibilityNodeInfo.ACTION_FOCUS); |
| 10469 |
} |
| 10470 |
} |
| 10471 |
|
| 10472 |
if (!isAccessibilityFocused()) { |
| 10473 |
info.addAction(AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS); |
| 10474 |
} else { |
| 10475 |
info.addAction(AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS); |
| 10476 |
} |
| 10477 |
|
| 10478 |
if (isClickable() && isEnabled()) { |
| 10479 |
info.addAction(AccessibilityNodeInfo.ACTION_CLICK); |
| 10480 |
} |
| 10481 |
|
| 10482 |
if (isLongClickable() && isEnabled()) { |
| 10483 |
info.addAction(AccessibilityNodeInfo.ACTION_LONG_CLICK); |
| 10484 |
} |
| 10485 |
|
| 10486 |
if (isContextClickable() && isEnabled()) { |
| 10487 |
info.addAction(AccessibilityAction.ACTION_CONTEXT_CLICK); |
| 10488 |
} |
| 10489 |
|
| 10490 |
CharSequence text = getIterableTextForAccessibility(); |
| 10491 |
if (text != null && text.length() > 0) { |
| 10492 |
info.setTextSelection(getAccessibilitySelectionStart(), getAccessibilitySelectionEnd()); |
| 10493 |
|
| 10494 |
info.addAction(AccessibilityNodeInfo.ACTION_SET_SELECTION); |
| 10495 |
info.addAction(AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY); |
| 10496 |
info.addAction(AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY); |
| 10497 |
info.setMovementGranularities(AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER |
| 10498 |
| AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD |
| 10499 |
| AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH); |
| 10500 |
} |
| 10501 |
|
| 10502 |
info.addAction(AccessibilityAction.ACTION_SHOW_ON_SCREEN); |
| 10503 |
populateAccessibilityNodeInfoDrawingOrderInParent(info); |
| 10504 |
info.setPaneTitle(mAccessibilityPaneTitle); |
| 10505 |
info.setHeading(isAccessibilityHeading()); |
| 10506 |
|
| 10507 |
if (mTouchDelegate != null) { |
| 10508 |
info.setTouchDelegateInfo(mTouchDelegate.getTouchDelegateInfo()); |
| 10509 |
} |
| 10510 |
|
| 10511 |
if (startedSystemDragForAccessibility()) { |
| 10512 |
info.addAction(AccessibilityAction.ACTION_DRAG_CANCEL); |
| 10513 |
} |
| 10514 |
|
| 10515 |
if (canAcceptAccessibilityDrop()) { |
| 10516 |
info.addAction(AccessibilityAction.ACTION_DRAG_DROP); |
| 10517 |
} |
| 10518 |
} |
| 10519 |
|
| 10520 |
|
| 10521 |
|
| 10522 |
|
| 10523 |
|
| 10524 |
|
| 10525 |
|
| 10526 |
|
| 10527 |
|
| 10528 |
|
| 10529 |
|
| 10530 |
|
| 10531 |
|
| 10532 |
|
| 10533 |
|
| 10534 |
|
| 10535 |
|
| 10536 |
|
| 10537 |
|
| 10538 |
public void addExtraDataToAccessibilityNodeInfo( |
| 10539 |
@NonNull AccessibilityNodeInfo info, @NonNull String extraDataKey, |
| 10540 |
@Nullable Bundle arguments) { |
| 10541 |
} |
| 10542 |
|
| 10543 |
|
| 10544 |
|
| 10545 |
|
| 10546 |
|
| 10547 |
|
| 10548 |
private void populateAccessibilityNodeInfoDrawingOrderInParent(AccessibilityNodeInfo info) { |
| 10549 |
|
| 10550 |
|
| 10551 |
|
| 10552 |
|
| 10553 |
|
| 10554 |
if ((mPrivateFlags & PFLAG_HAS_BOUNDS) == 0) { |
| 10555 |
info.setDrawingOrder(0); |
| 10556 |
return; |
| 10557 |
} |
| 10558 |
int drawingOrderInParent = 1; |
| 10559 |
|
| 10560 |
View viewAtDrawingLevel = this; |
| 10561 |
final ViewParent parent = getParentForAccessibility(); |
| 10562 |
while (viewAtDrawingLevel != parent) { |
| 10563 |
final ViewParent currentParent = viewAtDrawingLevel.getParent(); |
| 10564 |
if (!(currentParent instanceof ViewGroup)) { |
| 10565 |
|
| 10566 |
drawingOrderInParent = 0; |
| 10567 |
break; |
| 10568 |
} else { |
| 10569 |
final ViewGroup parentGroup = (ViewGroup) currentParent; |
| 10570 |
final int childCount = parentGroup.getChildCount(); |
| 10571 |
if (childCount > 1) { |
| 10572 |
List<View> preorderedList = parentGroup.buildOrderedChildList(); |
| 10573 |
if (preorderedList != null) { |
| 10574 |
final int childDrawIndex = preorderedList.indexOf(viewAtDrawingLevel); |
| 10575 |
for (int i = 0; i < childDrawIndex; i++) { |
| 10576 |
drawingOrderInParent += numViewsForAccessibility(preorderedList.get(i)); |
| 10577 |
} |
| 10578 |
preorderedList.clear(); |
| 10579 |
} else { |
| 10580 |
final int childIndex = parentGroup.indexOfChild(viewAtDrawingLevel); |
| 10581 |
final boolean customOrder = parentGroup.isChildrenDrawingOrderEnabled(); |
| 10582 |
final int childDrawIndex = ((childIndex >= 0) && customOrder) ? parentGroup |
| 10583 |
.getChildDrawingOrder(childCount, childIndex) : childIndex; |
| 10584 |
final int numChildrenToIterate = customOrder ? childCount : childDrawIndex; |
| 10585 |
if (childDrawIndex != 0) { |
| 10586 |
for (int i = 0; i < numChildrenToIterate; i++) { |
| 10587 |
final int otherDrawIndex = (customOrder ? |
| 10588 |
parentGroup.getChildDrawingOrder(childCount, i) : i); |
| 10589 |
if (otherDrawIndex < childDrawIndex) { |
| 10590 |
drawingOrderInParent += |
| 10591 |
numViewsForAccessibility(parentGroup.getChildAt(i)); |
| 10592 |
} |
| 10593 |
} |
| 10594 |
} |
| 10595 |
} |
| 10596 |
} |
| 10597 |
} |
| 10598 |
viewAtDrawingLevel = (View) currentParent; |
| 10599 |
} |
| 10600 |
info.setDrawingOrder(drawingOrderInParent); |
| 10601 |
} |
| 10602 |
|
| 10603 |
private static int numViewsForAccessibility(View view) { |
| 10604 |
if (view != null) { |
| 10605 |
if (view.includeForAccessibility()) { |
| 10606 |
return 1; |
| 10607 |
} else if (view instanceof ViewGroup) { |
| 10608 |
return ((ViewGroup) view).getNumChildrenForAccessibility(); |
| 10609 |
} |
| 10610 |
} |
| 10611 |
return 0; |
| 10612 |
} |
| 10613 |
|
| 10614 |
private View findLabelForView(View view, int labeledId) { |
| 10615 |
if (mMatchLabelForPredicate == null) { |
| 10616 |
mMatchLabelForPredicate = new MatchLabelForPredicate(); |
| 10617 |
} |
| 10618 |
mMatchLabelForPredicate.mLabeledId = labeledId; |
| 10619 |
return findViewByPredicateInsideOut(view, mMatchLabelForPredicate); |
| 10620 |
} |
| 10621 |
|
| 10622 |
|
| 10623 |
|
| 10624 |
|
| 10625 |
|
| 10626 |
|
| 10627 |
|
| 10628 |
|
| 10629 |
|
| 10630 |
public boolean isVisibleToUserForAutofill(int virtualId) { |
| 10631 |
if (mContext.isAutofillCompatibilityEnabled()) { |
| 10632 |
final AccessibilityNodeProvider provider = getAccessibilityNodeProvider(); |
| 10633 |
if (provider != null) { |
| 10634 |
final AccessibilityNodeInfo node = provider.createAccessibilityNodeInfo(virtualId); |
| 10635 |
if (node != null) { |
| 10636 |
return node.isVisibleToUser(); |
| 10637 |
} |
| 10638 |
|
| 10639 |
} else { |
| 10640 |
Log.w(VIEW_LOG_TAG, "isVisibleToUserForAutofill(" + virtualId + "): no provider"); |
| 10641 |
} |
| 10642 |
return false; |
| 10643 |
} |
| 10644 |
return true; |
| 10645 |
} |
| 10646 |
|
| 10647 |
|
| 10648 |
|
| 10649 |
|
| 10650 |
|
| 10651 |
|
| 10652 |
|
| 10653 |
|
| 10654 |
|
| 10655 |
|
| 10656 |
@UnsupportedAppUsage |
| 10657 |
public boolean isVisibleToUser() { |
| 10658 |
return isVisibleToUser(null); |
| 10659 |
} |
| 10660 |
|
| 10661 |
|
| 10662 |
|
| 10663 |
|
| 10664 |
|
| 10665 |
|
| 10666 |
|
| 10667 |
|
| 10668 |
|
| 10669 |
|
| 10670 |
|
| 10671 |
|
| 10672 |
|
| 10673 |
|
| 10674 |
|
| 10675 |
|
| 10676 |
|
| 10677 |
|
| 10678 |
@UnsupportedAppUsage(trackingBug = 171933273) |
| 10679 |
protected boolean isVisibleToUser(Rect boundInView) { |
| 10680 |
if (mAttachInfo != null) { |
| 10681 |
|
| 10682 |
if (mAttachInfo.mWindowVisibility != View.VISIBLE) { |
| 10683 |
return false; |
| 10684 |
} |
| 10685 |
|
| 10686 |
|
| 10687 |
Object current = this; |
| 10688 |
while (current instanceof View) { |
| 10689 |
View view = (View) current; |
| 10690 |
|
| 10691 |
|
| 10692 |
if (view.getAlpha() <= 0 || view.getTransitionAlpha() <= 0 || |
| 10693 |
view.getVisibility() != VISIBLE) { |
| 10694 |
return false; |
| 10695 |
} |
| 10696 |
current = view.mParent; |
| 10697 |
} |
| 10698 |
|
| 10699 |
Rect visibleRect = mAttachInfo.mTmpInvalRect; |
| 10700 |
Point offset = mAttachInfo.mPoint; |
| 10701 |
if (!getGlobalVisibleRect(visibleRect, offset)) { |
| 10702 |
return false; |
| 10703 |
} |
| 10704 |
|
| 10705 |
if (boundInView != null) { |
| 10706 |
visibleRect.offset(-offset.x, -offset.y); |
| 10707 |
return boundInView.intersect(visibleRect); |
| 10708 |
} |
| 10709 |
return true; |
| 10710 |
} |
| 10711 |
return false; |
| 10712 |
} |
| 10713 |
|
| 10714 |
|
| 10715 |
|
| 10716 |
|
| 10717 |
|
| 10718 |
|
| 10719 |
|
| 10720 |
public AccessibilityDelegate getAccessibilityDelegate() { |
| 10721 |
return mAccessibilityDelegate; |
| 10722 |
} |
| 10723 |
|
| 10724 |
|
| 10725 |
|
| 10726 |
|
| 10727 |
|
| 10728 |
|
| 10729 |
|
| 10730 |
|
| 10731 |
|
| 10732 |
|
| 10733 |
|
| 10734 |
|
| 10735 |
|
| 10736 |
|
| 10737 |
|
| 10738 |
|
| 10739 |
|
| 10740 |
|
| 10741 |
|
| 10742 |
|
| 10743 |
|
| 10744 |
|
| 10745 |
public void setAccessibilityDelegate(@Nullable AccessibilityDelegate delegate) { |
| 10746 |
mAccessibilityDelegate = delegate; |
| 10747 |
} |
| 10748 |
|
| 10749 |
|
| 10750 |
|
| 10751 |
|
| 10752 |
|
| 10753 |
|
| 10754 |
|
| 10755 |
|
| 10756 |
|
| 10757 |
|
| 10758 |
|
| 10759 |
|
| 10760 |
|
| 10761 |
|
| 10762 |
|
| 10763 |
|
| 10764 |
|
| 10765 |
|
| 10766 |
|
| 10767 |
|
| 10768 |
|
| 10769 |
|
| 10770 |
|
| 10771 |
public AccessibilityNodeProvider getAccessibilityNodeProvider() { |
| 10772 |
if (mAccessibilityDelegate != null) { |
| 10773 |
return mAccessibilityDelegate.getAccessibilityNodeProvider(this); |
| 10774 |
} else { |
| 10775 |
return null; |
| 10776 |
} |
| 10777 |
} |
| 10778 |
|
| 10779 |
|
| 10780 |
|
| 10781 |
|
| 10782 |
|
| 10783 |
|
| 10784 |
|
| 10785 |
|
| 10786 |
@UnsupportedAppUsage |
| 10787 |
public int getAccessibilityViewId() { |
| 10788 |
if (mAccessibilityViewId == NO_ID) { |
| 10789 |
mAccessibilityViewId = sNextAccessibilityViewId++; |
| 10790 |
} |
| 10791 |
return mAccessibilityViewId; |
| 10792 |
} |
| 10793 |
|
| 10794 |
|
| 10795 |
|
| 10796 |
|
| 10797 |
|
| 10798 |
|
| 10799 |
|
| 10800 |
|
| 10801 |
public int getAutofillViewId() { |
| 10802 |
if (mAutofillViewId == NO_ID) { |
| 10803 |
mAutofillViewId = mContext.getNextAutofillId(); |
| 10804 |
} |
| 10805 |
return mAutofillViewId; |
| 10806 |
} |
| 10807 |
|
| 10808 |
|
| 10809 |
|
| 10810 |
|
| 10811 |
|
| 10812 |
|
| 10813 |
|
| 10814 |
|
| 10815 |
public int getAccessibilityWindowId() { |
| 10816 |
return mAttachInfo != null ? mAttachInfo.mAccessibilityWindowId |
| 10817 |
: AccessibilityWindowInfo.UNDEFINED_WINDOW_ID; |
| 10818 |
} |
| 10819 |
|
| 10820 |
|
| 10821 |
|
| 10822 |
|
| 10823 |
|
| 10824 |
|
| 10825 |
|
| 10826 |
|
| 10827 |
|
| 10828 |
|
| 10829 |
|
| 10830 |
|
| 10831 |
@ViewDebug.ExportedProperty(category = "accessibility") |
| 10832 |
public final @Nullable CharSequence getStateDescription() { |
| 10833 |
return mStateDescription; |
| 10834 |
} |
| 10835 |
|
| 10836 |
|
| 10837 |
|
| 10838 |
|
| 10839 |
|
| 10840 |
|
| 10841 |
|
| 10842 |
|
| 10843 |
|
| 10844 |
|
| 10845 |
|
| 10846 |
|
| 10847 |
|
| 10848 |
@ViewDebug.ExportedProperty(category = "accessibility") |
| 10849 |
@InspectableProperty |
| 10850 |
public CharSequence getContentDescription() { |
| 10851 |
return mContentDescription; |
| 10852 |
} |
| 10853 |
|
| 10854 |
|
| 10855 |
|
| 10856 |
|
| 10857 |
|
| 10858 |
|
| 10859 |
|
| 10860 |
|
| 10861 |
|
| 10862 |
|
| 10863 |
|
| 10864 |
|
| 10865 |
|
| 10866 |
|
| 10867 |
|
| 10868 |
|
| 10869 |
@RemotableViewMethod |
| 10870 |
public void setStateDescription(@Nullable CharSequence stateDescription) { |
| 10871 |
if (mStateDescription == null) { |
| 10872 |
if (stateDescription == null) { |
| 10873 |
return; |
| 10874 |
} |
| 10875 |
} else if (mStateDescription.equals(stateDescription)) { |
| 10876 |
return; |
| 10877 |
} |
| 10878 |
mStateDescription = stateDescription; |
| 10879 |
if (!TextUtils.isEmpty(stateDescription) |
| 10880 |
&& getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) { |
| 10881 |
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); |
| 10882 |
} |
| 10883 |
if (AccessibilityManager.getInstance(mContext).isEnabled()) { |
| 10884 |
AccessibilityEvent event = AccessibilityEvent.obtain(); |
| 10885 |
event.setEventType(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); |
| 10886 |
event.setContentChangeTypes(AccessibilityEvent.CONTENT_CHANGE_TYPE_STATE_DESCRIPTION); |
| 10887 |
sendAccessibilityEventUnchecked(event); |
| 10888 |
} |
| 10889 |
} |
| 10890 |
|
| 10891 |
|
| 10892 |
|
| 10893 |
|
| 10894 |
|
| 10895 |
|
| 10896 |
|
| 10897 |
|
| 10898 |
|
| 10899 |
|
| 10900 |
|
| 10901 |
|
| 10902 |
|
| 10903 |
|
| 10904 |
|
| 10905 |
|
| 10906 |
|
| 10907 |
@RemotableViewMethod |
| 10908 |
public void setContentDescription(CharSequence contentDescription) { |
| 10909 |
if (mContentDescription == null) { |
| 10910 |
if (contentDescription == null) { |
| 10911 |
return; |
| 10912 |
} |
| 10913 |
} else if (mContentDescription.equals(contentDescription)) { |
| 10914 |
return; |
| 10915 |
} |
| 10916 |
mContentDescription = contentDescription; |
| 10917 |
final boolean nonEmptyDesc = contentDescription != null && contentDescription.length() > 0; |
| 10918 |
if (nonEmptyDesc && getImportantForAccessibility() == IMPORTANT_FOR_ACCESSIBILITY_AUTO) { |
| 10919 |
setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_YES); |
| 10920 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 10921 |
} else { |
| 10922 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 10923 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION); |
| 10924 |
} |
| 10925 |
} |
| 10926 |
|
| 10927 |
|
| 10928 |
|
| 10929 |
|
| 10930 |
|
| 10931 |
|
| 10932 |
|
| 10933 |
|
| 10934 |
|
| 10935 |
|
| 10936 |
|
| 10937 |
|
| 10938 |
|
| 10939 |
|
| 10940 |
|
| 10941 |
|
| 10942 |
|
| 10943 |
|
| 10944 |
|
| 10945 |
|
| 10946 |
|
| 10947 |
|
| 10948 |
|
| 10949 |
@RemotableViewMethod |
| 10950 |
public void setAccessibilityTraversalBefore(@IdRes int beforeId) { |
| 10951 |
if (mAccessibilityTraversalBeforeId == beforeId) { |
| 10952 |
return; |
| 10953 |
} |
| 10954 |
mAccessibilityTraversalBeforeId = beforeId; |
| 10955 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 10956 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 10957 |
} |
| 10958 |
|
| 10959 |
|
| 10960 |
|
| 10961 |
|
| 10962 |
|
| 10963 |
|
| 10964 |
|
| 10965 |
|
| 10966 |
|
| 10967 |
@IdRes |
| 10968 |
@InspectableProperty |
| 10969 |
public int getAccessibilityTraversalBefore() { |
| 10970 |
return mAccessibilityTraversalBeforeId; |
| 10971 |
} |
| 10972 |
|
| 10973 |
|
| 10974 |
|
| 10975 |
|
| 10976 |
|
| 10977 |
|
| 10978 |
|
| 10979 |
|
| 10980 |
|
| 10981 |
|
| 10982 |
|
| 10983 |
|
| 10984 |
|
| 10985 |
|
| 10986 |
|
| 10987 |
|
| 10988 |
|
| 10989 |
|
| 10990 |
|
| 10991 |
|
| 10992 |
|
| 10993 |
|
| 10994 |
|
| 10995 |
@RemotableViewMethod |
| 10996 |
public void setAccessibilityTraversalAfter(@IdRes int afterId) { |
| 10997 |
if (mAccessibilityTraversalAfterId == afterId) { |
| 10998 |
return; |
| 10999 |
} |
| 11000 |
mAccessibilityTraversalAfterId = afterId; |
| 11001 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 11002 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 11003 |
} |
| 11004 |
|
| 11005 |
|
| 11006 |
|
| 11007 |
|
| 11008 |
|
| 11009 |
|
| 11010 |
|
| 11011 |
|
| 11012 |
|
| 11013 |
@IdRes |
| 11014 |
@InspectableProperty |
| 11015 |
public int getAccessibilityTraversalAfter() { |
| 11016 |
return mAccessibilityTraversalAfterId; |
| 11017 |
} |
| 11018 |
|
| 11019 |
|
| 11020 |
|
| 11021 |
|
| 11022 |
|
| 11023 |
|
| 11024 |
|
| 11025 |
@IdRes |
| 11026 |
@ViewDebug.ExportedProperty(category = "accessibility") |
| 11027 |
@InspectableProperty |
| 11028 |
public int getLabelFor() { |
| 11029 |
return mLabelForId; |
| 11030 |
} |
| 11031 |
|
| 11032 |
|
| 11033 |
|
| 11034 |
|
| 11035 |
|
| 11036 |
|
| 11037 |
|
| 11038 |
@RemotableViewMethod |
| 11039 |
public void setLabelFor(@IdRes int id) { |
| 11040 |
if (mLabelForId == id) { |
| 11041 |
return; |
| 11042 |
} |
| 11043 |
mLabelForId = id; |
| 11044 |
if (mLabelForId != View.NO_ID |
| 11045 |
&& mID == View.NO_ID) { |
| 11046 |
mID = generateViewId(); |
| 11047 |
} |
| 11048 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 11049 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 11050 |
} |
| 11051 |
|
| 11052 |
|
| 11053 |
|
| 11054 |
|
| 11055 |
|
| 11056 |
|
| 11057 |
|
| 11058 |
|
| 11059 |
|
| 11060 |
|
| 11061 |
|
| 11062 |
|
| 11063 |
|
| 11064 |
|
| 11065 |
@CallSuper |
| 11066 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 11067 |
protected void onFocusLost() { |
| 11068 |
resetPressedState(); |
| 11069 |
} |
| 11070 |
|
| 11071 |
private void resetPressedState() { |
| 11072 |
if ((mViewFlags & ENABLED_MASK) == DISABLED) { |
| 11073 |
return; |
| 11074 |
} |
| 11075 |
|
| 11076 |
if (isPressed()) { |
| 11077 |
setPressed(false); |
| 11078 |
|
| 11079 |
if (!mHasPerformedLongPress) { |
| 11080 |
removeLongPressCallback(); |
| 11081 |
} |
| 11082 |
} |
| 11083 |
} |
| 11084 |
|
| 11085 |
|
| 11086 |
|
| 11087 |
|
| 11088 |
|
| 11089 |
|
| 11090 |
@ViewDebug.ExportedProperty(category = "focus") |
| 11091 |
@InspectableProperty(hasAttributeId = false) |
| 11092 |
public boolean isFocused() { |
| 11093 |
return (mPrivateFlags & PFLAG_FOCUSED) != 0; |
| 11094 |
} |
| 11095 |
|
| 11096 |
|
| 11097 |
|
| 11098 |
|
| 11099 |
|
| 11100 |
|
| 11101 |
|
| 11102 |
|
| 11103 |
public View findFocus() { |
| 11104 |
return (mPrivateFlags & PFLAG_FOCUSED) != 0 ? this : null; |
| 11105 |
} |
| 11106 |
|
| 11107 |
|
| 11108 |
|
| 11109 |
|
| 11110 |
|
| 11111 |
|
| 11112 |
|
| 11113 |
|
| 11114 |
|
| 11115 |
|
| 11116 |
@InspectableProperty(name = "isScrollContainer") |
| 11117 |
public boolean isScrollContainer() { |
| 11118 |
return (mPrivateFlags & PFLAG_SCROLL_CONTAINER_ADDED) != 0; |
| 11119 |
} |
| 11120 |
|
| 11121 |
|
| 11122 |
|
| 11123 |
|
| 11124 |
|
| 11125 |
|
| 11126 |
|
| 11127 |
|
| 11128 |
|
| 11129 |
|
| 11130 |
public void setScrollContainer(boolean isScrollContainer) { |
| 11131 |
if (isScrollContainer) { |
| 11132 |
if (mAttachInfo != null && (mPrivateFlags&PFLAG_SCROLL_CONTAINER_ADDED) == 0) { |
| 11133 |
mAttachInfo.mScrollContainers.add(this); |
| 11134 |
mPrivateFlags |= PFLAG_SCROLL_CONTAINER_ADDED; |
| 11135 |
} |
| 11136 |
mPrivateFlags |= PFLAG_SCROLL_CONTAINER; |
| 11137 |
} else { |
| 11138 |
if ((mPrivateFlags&PFLAG_SCROLL_CONTAINER_ADDED) != 0) { |
| 11139 |
mAttachInfo.mScrollContainers.remove(this); |
| 11140 |
} |
| 11141 |
mPrivateFlags &= ~(PFLAG_SCROLL_CONTAINER|PFLAG_SCROLL_CONTAINER_ADDED); |
| 11142 |
} |
| 11143 |
} |
| 11144 |
|
| 11145 |
|
| 11146 |
|
| 11147 |
|
| 11148 |
|
| 11149 |
|
| 11150 |
|
| 11151 |
|
| 11152 |
|
| 11153 |
|
| 11154 |
|
| 11155 |
|
| 11156 |
|
| 11157 |
|
| 11158 |
|
| 11159 |
|
| 11160 |
|
| 11161 |
|
| 11162 |
|
| 11163 |
|
| 11164 |
|
| 11165 |
|
| 11166 |
|
| 11167 |
|
| 11168 |
|
| 11169 |
|
| 11170 |
@Deprecated |
| 11171 |
@DrawingCacheQuality |
| 11172 |
@InspectableProperty(enumMapping = { |
| 11173 |
@EnumEntry(value = DRAWING_CACHE_QUALITY_LOW, name = "low"), |
| 11174 |
@EnumEntry(value = DRAWING_CACHE_QUALITY_HIGH, name = "high"), |
| 11175 |
@EnumEntry(value = DRAWING_CACHE_QUALITY_AUTO, name = "auto") |
| 11176 |
}) |
| 11177 |
public int getDrawingCacheQuality() { |
| 11178 |
return mViewFlags & DRAWING_CACHE_QUALITY_MASK; |
| 11179 |
} |
| 11180 |
|
| 11181 |
|
| 11182 |
|
| 11183 |
|
| 11184 |
|
| 11185 |
|
| 11186 |
|
| 11187 |
|
| 11188 |
|
| 11189 |
|
| 11190 |
|
| 11191 |
|
| 11192 |
|
| 11193 |
|
| 11194 |
|
| 11195 |
|
| 11196 |
|
| 11197 |
|
| 11198 |
|
| 11199 |
|
| 11200 |
|
| 11201 |
|
| 11202 |
|
| 11203 |
|
| 11204 |
|
| 11205 |
|
| 11206 |
|
| 11207 |
@Deprecated |
| 11208 |
public void setDrawingCacheQuality(@DrawingCacheQuality int quality) { |
| 11209 |
setFlags(quality, DRAWING_CACHE_QUALITY_MASK); |
| 11210 |
} |
| 11211 |
|
| 11212 |
|
| 11213 |
|
| 11214 |
|
| 11215 |
|
| 11216 |
|
| 11217 |
|
| 11218 |
|
| 11219 |
|
| 11220 |
|
| 11221 |
|
| 11222 |
@InspectableProperty |
| 11223 |
public boolean getKeepScreenOn() { |
| 11224 |
return (mViewFlags & KEEP_SCREEN_ON) != 0; |
| 11225 |
} |
| 11226 |
|
| 11227 |
|
| 11228 |
|
| 11229 |
|
| 11230 |
|
| 11231 |
|
| 11232 |
|
| 11233 |
|
| 11234 |
|
| 11235 |
|
| 11236 |
|
| 11237 |
public void setKeepScreenOn(boolean keepScreenOn) { |
| 11238 |
setFlags(keepScreenOn ? KEEP_SCREEN_ON : 0, KEEP_SCREEN_ON); |
| 11239 |
} |
| 11240 |
|
| 11241 |
|
| 11242 |
|
| 11243 |
|
| 11244 |
|
| 11245 |
|
| 11246 |
|
| 11247 |
@IdRes |
| 11248 |
@InspectableProperty(name = "nextFocusLeft") |
| 11249 |
public int getNextFocusLeftId() { |
| 11250 |
return mNextFocusLeftId; |
| 11251 |
} |
| 11252 |
|
| 11253 |
|
| 11254 |
|
| 11255 |
|
| 11256 |
|
| 11257 |
|
| 11258 |
|
| 11259 |
|
| 11260 |
public void setNextFocusLeftId(@IdRes int nextFocusLeftId) { |
| 11261 |
mNextFocusLeftId = nextFocusLeftId; |
| 11262 |
} |
| 11263 |
|
| 11264 |
|
| 11265 |
|
| 11266 |
|
| 11267 |
|
| 11268 |
|
| 11269 |
|
| 11270 |
@IdRes |
| 11271 |
@InspectableProperty(name = "nextFocusRight") |
| 11272 |
public int getNextFocusRightId() { |
| 11273 |
return mNextFocusRightId; |
| 11274 |
} |
| 11275 |
|
| 11276 |
|
| 11277 |
|
| 11278 |
|
| 11279 |
|
| 11280 |
|
| 11281 |
|
| 11282 |
|
| 11283 |
public void setNextFocusRightId(@IdRes int nextFocusRightId) { |
| 11284 |
mNextFocusRightId = nextFocusRightId; |
| 11285 |
} |
| 11286 |
|
| 11287 |
|
| 11288 |
|
| 11289 |
|
| 11290 |
|
| 11291 |
|
| 11292 |
|
| 11293 |
@IdRes |
| 11294 |
@InspectableProperty(name = "nextFocusUp") |
| 11295 |
public int getNextFocusUpId() { |
| 11296 |
return mNextFocusUpId; |
| 11297 |
} |
| 11298 |
|
| 11299 |
|
| 11300 |
|
| 11301 |
|
| 11302 |
|
| 11303 |
|
| 11304 |
|
| 11305 |
|
| 11306 |
public void setNextFocusUpId(@IdRes int nextFocusUpId) { |
| 11307 |
mNextFocusUpId = nextFocusUpId; |
| 11308 |
} |
| 11309 |
|
| 11310 |
|
| 11311 |
|
| 11312 |
|
| 11313 |
|
| 11314 |
|
| 11315 |
|
| 11316 |
@IdRes |
| 11317 |
@InspectableProperty(name = "nextFocusDown") |
| 11318 |
public int getNextFocusDownId() { |
| 11319 |
return mNextFocusDownId; |
| 11320 |
} |
| 11321 |
|
| 11322 |
|
| 11323 |
|
| 11324 |
|
| 11325 |
|
| 11326 |
|
| 11327 |
|
| 11328 |
|
| 11329 |
public void setNextFocusDownId(@IdRes int nextFocusDownId) { |
| 11330 |
mNextFocusDownId = nextFocusDownId; |
| 11331 |
} |
| 11332 |
|
| 11333 |
|
| 11334 |
|
| 11335 |
|
| 11336 |
|
| 11337 |
|
| 11338 |
|
| 11339 |
@IdRes |
| 11340 |
@InspectableProperty(name = "nextFocusForward") |
| 11341 |
public int getNextFocusForwardId() { |
| 11342 |
return mNextFocusForwardId; |
| 11343 |
} |
| 11344 |
|
| 11345 |
|
| 11346 |
|
| 11347 |
|
| 11348 |
|
| 11349 |
|
| 11350 |
|
| 11351 |
|
| 11352 |
public void setNextFocusForwardId(@IdRes int nextFocusForwardId) { |
| 11353 |
mNextFocusForwardId = nextFocusForwardId; |
| 11354 |
} |
| 11355 |
|
| 11356 |
|
| 11357 |
|
| 11358 |
|
| 11359 |
|
| 11360 |
|
| 11361 |
|
| 11362 |
|
| 11363 |
@IdRes |
| 11364 |
@InspectableProperty(name = "nextClusterForward") |
| 11365 |
public int getNextClusterForwardId() { |
| 11366 |
return mNextClusterForwardId; |
| 11367 |
} |
| 11368 |
|
| 11369 |
|
| 11370 |
|
| 11371 |
|
| 11372 |
|
| 11373 |
|
| 11374 |
|
| 11375 |
|
| 11376 |
public void setNextClusterForwardId(@IdRes int nextClusterForwardId) { |
| 11377 |
mNextClusterForwardId = nextClusterForwardId; |
| 11378 |
} |
| 11379 |
|
| 11380 |
|
| 11381 |
|
| 11382 |
|
| 11383 |
|
| 11384 |
|
| 11385 |
public boolean isShown() { |
| 11386 |
View current = this; |
| 11387 |
|
| 11388 |
do { |
| 11389 |
if ((current.mViewFlags & VISIBILITY_MASK) != VISIBLE) { |
| 11390 |
return false; |
| 11391 |
} |
| 11392 |
ViewParent parent = current.mParent; |
| 11393 |
if (parent == null) { |
| 11394 |
return false; |
| 11395 |
} |
| 11396 |
if (!(parent instanceof View)) { |
| 11397 |
return true; |
| 11398 |
} |
| 11399 |
current = (View) parent; |
| 11400 |
} while (current != null); |
| 11401 |
|
| 11402 |
return false; |
| 11403 |
} |
| 11404 |
|
| 11405 |
private boolean detached() { |
| 11406 |
View current = this; |
| 11407 |
|
| 11408 |
do { |
| 11409 |
if ((current.mPrivateFlags4 & PFLAG4_DETACHED) != 0) { |
| 11410 |
return true; |
| 11411 |
} |
| 11412 |
ViewParent parent = current.mParent; |
| 11413 |
if (parent == null) { |
| 11414 |
return false; |
| 11415 |
} |
| 11416 |
if (!(parent instanceof View)) { |
| 11417 |
return false; |
| 11418 |
} |
| 11419 |
current = (View) parent; |
| 11420 |
} while (current != null); |
| 11421 |
|
| 11422 |
return false; |
| 11423 |
} |
| 11424 |
|
| 11425 |
|
| 11426 |
|
| 11427 |
|
| 11428 |
|
| 11429 |
|
| 11430 |
|
| 11431 |
|
| 11432 |
|
| 11433 |
|
| 11434 |
|
| 11435 |
|
| 11436 |
|
| 11437 |
|
| 11438 |
|
| 11439 |
|
| 11440 |
|
| 11441 |
|
| 11442 |
|
| 11443 |
|
| 11444 |
|
| 11445 |
|
| 11446 |
|
| 11447 |
|
| 11448 |
|
| 11449 |
|
| 11450 |
|
| 11451 |
|
| 11452 |
|
| 11453 |
|
| 11454 |
|
| 11455 |
|
| 11456 |
|
| 11457 |
|
| 11458 |
|
| 11459 |
|
| 11460 |
|
| 11461 |
|
| 11462 |
|
| 11463 |
|
| 11464 |
|
| 11465 |
|
| 11466 |
|
| 11467 |
|
| 11468 |
|
| 11469 |
|
| 11470 |
|
| 11471 |
|
| 11472 |
|
| 11473 |
|
| 11474 |
|
| 11475 |
|
| 11476 |
|
| 11477 |
|
| 11478 |
|
| 11479 |
|
| 11480 |
|
| 11481 |
|
| 11482 |
|
| 11483 |
|
| 11484 |
|
| 11485 |
|
| 11486 |
|
| 11487 |
|
| 11488 |
@Deprecated |
| 11489 |
protected boolean fitSystemWindows(Rect insets) { |
| 11490 |
if ((mPrivateFlags3 & PFLAG3_APPLYING_INSETS) == 0) { |
| 11491 |
if (insets == null) { |
| 11492 |
|
| 11493 |
|
| 11494 |
|
| 11495 |
return false; |
| 11496 |
} |
| 11497 |
|
| 11498 |
|
| 11499 |
|
| 11500 |
try { |
| 11501 |
mPrivateFlags3 |= PFLAG3_FITTING_SYSTEM_WINDOWS; |
| 11502 |
return dispatchApplyWindowInsets(new WindowInsets(insets)).isConsumed(); |
| 11503 |
} finally { |
| 11504 |
mPrivateFlags3 &= ~PFLAG3_FITTING_SYSTEM_WINDOWS; |
| 11505 |
} |
| 11506 |
} else { |
| 11507 |
|
| 11508 |
|
| 11509 |
return fitSystemWindowsInt(insets); |
| 11510 |
} |
| 11511 |
} |
| 11512 |
|
| 11513 |
private boolean fitSystemWindowsInt(Rect insets) { |
| 11514 |
if ((mViewFlags & FITS_SYSTEM_WINDOWS) == FITS_SYSTEM_WINDOWS) { |
| 11515 |
Rect localInsets = sThreadLocal.get(); |
| 11516 |
boolean res = computeFitSystemWindows(insets, localInsets); |
| 11517 |
applyInsets(localInsets); |
| 11518 |
return res; |
| 11519 |
} |
| 11520 |
return false; |
| 11521 |
} |
| 11522 |
|
| 11523 |
private void applyInsets(Rect insets) { |
| 11524 |
mUserPaddingStart = UNDEFINED_PADDING; |
| 11525 |
mUserPaddingEnd = UNDEFINED_PADDING; |
| 11526 |
mUserPaddingLeftInitial = insets.left; |
| 11527 |
mUserPaddingRightInitial = insets.right; |
| 11528 |
internalSetPadding(insets.left, insets.top, insets.right, insets.bottom); |
| 11529 |
} |
| 11530 |
|
| 11531 |
|
| 11532 |
|
| 11533 |
|
| 11534 |
|
| 11535 |
|
| 11536 |
|
| 11537 |
|
| 11538 |
|
| 11539 |
|
| 11540 |
|
| 11541 |
|
| 11542 |
|
| 11543 |
|
| 11544 |
|
| 11545 |
|
| 11546 |
|
| 11547 |
|
| 11548 |
|
| 11549 |
|
| 11550 |
|
| 11551 |
|
| 11552 |
|
| 11553 |
|
| 11554 |
|
| 11555 |
|
| 11556 |
public WindowInsets onApplyWindowInsets(WindowInsets insets) { |
| 11557 |
if ((mPrivateFlags4 & PFLAG4_FRAMEWORK_OPTIONAL_FITS_SYSTEM_WINDOWS) != 0 |
| 11558 |
&& (mViewFlags & FITS_SYSTEM_WINDOWS) != 0) { |
| 11559 |
return onApplyFrameworkOptionalFitSystemWindows(insets); |
| 11560 |
} |
| 11561 |
if ((mPrivateFlags3 & PFLAG3_FITTING_SYSTEM_WINDOWS) == 0) { |
| 11562 |
|
| 11563 |
|
| 11564 |
|
| 11565 |
if (fitSystemWindows(insets.getSystemWindowInsetsAsRect())) { |
| 11566 |
return insets.consumeSystemWindowInsets(); |
| 11567 |
} |
| 11568 |
} else { |
| 11569 |
|
| 11570 |
if (fitSystemWindowsInt(insets.getSystemWindowInsetsAsRect())) { |
| 11571 |
return insets.consumeSystemWindowInsets(); |
| 11572 |
} |
| 11573 |
} |
| 11574 |
return insets; |
| 11575 |
} |
| 11576 |
|
| 11577 |
private WindowInsets onApplyFrameworkOptionalFitSystemWindows(WindowInsets insets) { |
| 11578 |
Rect localInsets = sThreadLocal.get(); |
| 11579 |
WindowInsets result = computeSystemWindowInsets(insets, localInsets); |
| 11580 |
applyInsets(localInsets); |
| 11581 |
return result; |
| 11582 |
} |
| 11583 |
|
| 11584 |
|
| 11585 |
|
| 11586 |
|
| 11587 |
|
| 11588 |
|
| 11589 |
|
| 11590 |
|
| 11591 |
|
| 11592 |
|
| 11593 |
|
| 11594 |
|
| 11595 |
public void setOnApplyWindowInsetsListener(OnApplyWindowInsetsListener listener) { |
| 11596 |
getListenerInfo().mOnApplyWindowInsetsListener = listener; |
| 11597 |
} |
| 11598 |
|
| 11599 |
|
| 11600 |
|
| 11601 |
|
| 11602 |
|
| 11603 |
|
| 11604 |
|
| 11605 |
|
| 11606 |
|
| 11607 |
|
| 11608 |
|
| 11609 |
|
| 11610 |
|
| 11611 |
|
| 11612 |
|
| 11613 |
|
| 11614 |
|
| 11615 |
|
| 11616 |
|
| 11617 |
|
| 11618 |
|
| 11619 |
|
| 11620 |
public WindowInsets dispatchApplyWindowInsets(WindowInsets insets) { |
| 11621 |
try { |
| 11622 |
mPrivateFlags3 |= PFLAG3_APPLYING_INSETS; |
| 11623 |
if (mListenerInfo != null && mListenerInfo.mOnApplyWindowInsetsListener != null) { |
| 11624 |
return mListenerInfo.mOnApplyWindowInsetsListener.onApplyWindowInsets(this, insets); |
| 11625 |
} else { |
| 11626 |
return onApplyWindowInsets(insets); |
| 11627 |
} |
| 11628 |
} finally { |
| 11629 |
mPrivateFlags3 &= ~PFLAG3_APPLYING_INSETS; |
| 11630 |
} |
| 11631 |
} |
| 11632 |
|
| 11633 |
|
| 11634 |
|
| 11635 |
|
| 11636 |
|
| 11637 |
|
| 11638 |
|
| 11639 |
|
| 11640 |
|
| 11641 |
|
| 11642 |
|
| 11643 |
public void setWindowInsetsAnimationCallback( |
| 11644 |
@Nullable WindowInsetsAnimation.Callback callback) { |
| 11645 |
getListenerInfo().mWindowInsetsAnimationCallback = callback; |
| 11646 |
} |
| 11647 |
|
| 11648 |
|
| 11649 |
|
| 11650 |
|
| 11651 |
|
| 11652 |
|
| 11653 |
public boolean hasWindowInsetsAnimationCallback() { |
| 11654 |
return getListenerInfo().mWindowInsetsAnimationCallback != null; |
| 11655 |
} |
| 11656 |
|
| 11657 |
|
| 11658 |
|
| 11659 |
|
| 11660 |
|
| 11661 |
|
| 11662 |
|
| 11663 |
|
| 11664 |
public void dispatchWindowInsetsAnimationPrepare( |
| 11665 |
@NonNull WindowInsetsAnimation animation) { |
| 11666 |
if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationCallback != null) { |
| 11667 |
mListenerInfo.mWindowInsetsAnimationCallback.onPrepare(animation); |
| 11668 |
} |
| 11669 |
} |
| 11670 |
|
| 11671 |
|
| 11672 |
|
| 11673 |
|
| 11674 |
|
| 11675 |
|
| 11676 |
|
| 11677 |
|
| 11678 |
|
| 11679 |
@NonNull |
| 11680 |
public Bounds dispatchWindowInsetsAnimationStart( |
| 11681 |
@NonNull WindowInsetsAnimation animation, @NonNull Bounds bounds) { |
| 11682 |
if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationCallback != null) { |
| 11683 |
return mListenerInfo.mWindowInsetsAnimationCallback.onStart(animation, bounds); |
| 11684 |
} |
| 11685 |
return bounds; |
| 11686 |
} |
| 11687 |
|
| 11688 |
|
| 11689 |
|
| 11690 |
|
| 11691 |
|
| 11692 |
|
| 11693 |
|
| 11694 |
|
| 11695 |
@NonNull |
| 11696 |
public WindowInsets dispatchWindowInsetsAnimationProgress(@NonNull WindowInsets insets, |
| 11697 |
@NonNull List<WindowInsetsAnimation> runningAnimations) { |
| 11698 |
if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationCallback != null) { |
| 11699 |
return mListenerInfo.mWindowInsetsAnimationCallback.onProgress(insets, |
| 11700 |
runningAnimations); |
| 11701 |
} else { |
| 11702 |
return insets; |
| 11703 |
} |
| 11704 |
} |
| 11705 |
|
| 11706 |
|
| 11707 |
|
| 11708 |
|
| 11709 |
|
| 11710 |
|
| 11711 |
public void dispatchWindowInsetsAnimationEnd(@NonNull WindowInsetsAnimation animation) { |
| 11712 |
if (mListenerInfo != null && mListenerInfo.mWindowInsetsAnimationCallback != null) { |
| 11713 |
mListenerInfo.mWindowInsetsAnimationCallback.onEnd(animation); |
| 11714 |
} |
| 11715 |
} |
| 11716 |
|
| 11717 |
|
| 11718 |
|
| 11719 |
|
| 11720 |
|
| 11721 |
|
| 11722 |
|
| 11723 |
|
| 11724 |
|
| 11725 |
|
| 11726 |
|
| 11727 |
|
| 11728 |
|
| 11729 |
|
| 11730 |
|
| 11731 |
|
| 11732 |
|
| 11733 |
|
| 11734 |
|
| 11735 |
|
| 11736 |
|
| 11737 |
|
| 11738 |
|
| 11739 |
|
| 11740 |
|
| 11741 |
|
| 11742 |
|
| 11743 |
|
| 11744 |
public void setSystemGestureExclusionRects(@NonNull List<Rect> rects) { |
| 11745 |
if (rects.isEmpty() && mListenerInfo == null) return; |
| 11746 |
|
| 11747 |
final ListenerInfo info = getListenerInfo(); |
| 11748 |
if (info.mSystemGestureExclusionRects != null) { |
| 11749 |
info.mSystemGestureExclusionRects.clear(); |
| 11750 |
info.mSystemGestureExclusionRects.addAll(rects); |
| 11751 |
} else { |
| 11752 |
info.mSystemGestureExclusionRects = new ArrayList<>(rects); |
| 11753 |
} |
| 11754 |
|
| 11755 |
updatePositionUpdateListener(); |
| 11756 |
postUpdate(this::updateSystemGestureExclusionRects); |
| 11757 |
} |
| 11758 |
|
| 11759 |
private void updatePositionUpdateListener() { |
| 11760 |
final ListenerInfo info = getListenerInfo(); |
| 11761 |
if (getSystemGestureExclusionRects().isEmpty() |
| 11762 |
&& collectPreferKeepClearRects().isEmpty() |
| 11763 |
&& collectUnrestrictedPreferKeepClearRects().isEmpty() |
| 11764 |
&& (info.mHandwritingArea == null || !isAutoHandwritingEnabled())) { |
| 11765 |
if (info.mPositionUpdateListener != null) { |
| 11766 |
mRenderNode.removePositionUpdateListener(info.mPositionUpdateListener); |
| 11767 |
info.mPositionUpdateListener = null; |
| 11768 |
info.mPositionChangedUpdate = null; |
| 11769 |
} |
| 11770 |
} else { |
| 11771 |
if (info.mPositionUpdateListener == null) { |
| 11772 |
info.mPositionChangedUpdate = () -> { |
| 11773 |
updateSystemGestureExclusionRects(); |
| 11774 |
updateKeepClearRects(); |
| 11775 |
updateHandwritingArea(); |
| 11776 |
}; |
| 11777 |
info.mPositionUpdateListener = new RenderNode.PositionUpdateListener() { |
| 11778 |
@Override |
| 11779 |
public void positionChanged(long n, int l, int t, int r, int b) { |
| 11780 |
postUpdate(info.mPositionChangedUpdate); |
| 11781 |
} |
| 11782 |
|
| 11783 |
@Override |
| 11784 |
public void positionLost(long frameNumber) { |
| 11785 |
postUpdate(info.mPositionChangedUpdate); |
| 11786 |
} |
| 11787 |
}; |
| 11788 |
mRenderNode.addPositionUpdateListener(info.mPositionUpdateListener); |
| 11789 |
} |
| 11790 |
} |
| 11791 |
} |
| 11792 |
|
| 11793 |
|
| 11794 |
|
| 11795 |
|
| 11796 |
private void postUpdate(Runnable r) { |
| 11797 |
|
| 11798 |
final Handler h = getHandler(); |
| 11799 |
if (h != null) { |
| 11800 |
h.postAtFrontOfQueue(r); |
| 11801 |
} |
| 11802 |
} |
| 11803 |
|
| 11804 |
void updateSystemGestureExclusionRects() { |
| 11805 |
final AttachInfo ai = mAttachInfo; |
| 11806 |
if (ai != null) { |
| 11807 |
ai.mViewRootImpl.updateSystemGestureExclusionRectsForView(this); |
| 11808 |
} |
| 11809 |
} |
| 11810 |
|
| 11811 |
|
| 11812 |
|
| 11813 |
|
| 11814 |
|
| 11815 |
|
| 11816 |
|
| 11817 |
|
| 11818 |
|
| 11819 |
@NonNull |
| 11820 |
public List<Rect> getSystemGestureExclusionRects() { |
| 11821 |
final ListenerInfo info = mListenerInfo; |
| 11822 |
if (info != null) { |
| 11823 |
final List<Rect> list = info.mSystemGestureExclusionRects; |
| 11824 |
if (list != null) { |
| 11825 |
return list; |
| 11826 |
} |
| 11827 |
} |
| 11828 |
return Collections.emptyList(); |
| 11829 |
} |
| 11830 |
|
| 11831 |
|
| 11832 |
|
| 11833 |
|
| 11834 |
|
| 11835 |
|
| 11836 |
|
| 11837 |
|
| 11838 |
|
| 11839 |
|
| 11840 |
|
| 11841 |
|
| 11842 |
|
| 11843 |
|
| 11844 |
|
| 11845 |
|
| 11846 |
public final void setPreferKeepClear(boolean preferKeepClear) { |
| 11847 |
getListenerInfo().mPreferKeepClear = preferKeepClear; |
| 11848 |
updatePositionUpdateListener(); |
| 11849 |
postUpdate(this::updateKeepClearRects); |
| 11850 |
} |
| 11851 |
|
| 11852 |
|
| 11853 |
|
| 11854 |
|
| 11855 |
|
| 11856 |
|
| 11857 |
|
| 11858 |
|
| 11859 |
|
| 11860 |
|
| 11861 |
|
| 11862 |
public final boolean isPreferKeepClear() { |
| 11863 |
return mListenerInfo != null && mListenerInfo.mPreferKeepClear; |
| 11864 |
} |
| 11865 |
|
| 11866 |
|
| 11867 |
|
| 11868 |
|
| 11869 |
|
| 11870 |
|
| 11871 |
|
| 11872 |
|
| 11873 |
|
| 11874 |
|
| 11875 |
|
| 11876 |
|
| 11877 |
|
| 11878 |
|
| 11879 |
|
| 11880 |
|
| 11881 |
|
| 11882 |
public final void setPreferKeepClearRects(@NonNull List<Rect> rects) { |
| 11883 |
final ListenerInfo info = getListenerInfo(); |
| 11884 |
if (info.mKeepClearRects != null) { |
| 11885 |
info.mKeepClearRects.clear(); |
| 11886 |
info.mKeepClearRects.addAll(rects); |
| 11887 |
} else { |
| 11888 |
info.mKeepClearRects = new ArrayList<>(rects); |
| 11889 |
} |
| 11890 |
updatePositionUpdateListener(); |
| 11891 |
postUpdate(this::updateKeepClearRects); |
| 11892 |
} |
| 11893 |
|
| 11894 |
|
| 11895 |
|
| 11896 |
|
| 11897 |
|
| 11898 |
|
| 11899 |
@NonNull |
| 11900 |
public final List<Rect> getPreferKeepClearRects() { |
| 11901 |
final ListenerInfo info = mListenerInfo; |
| 11902 |
if (info != null && info.mKeepClearRects != null) { |
| 11903 |
return new ArrayList(info.mKeepClearRects); |
| 11904 |
} |
| 11905 |
|
| 11906 |
return Collections.emptyList(); |
| 11907 |
} |
| 11908 |
|
| 11909 |
|
| 11910 |
|
| 11911 |
|
| 11912 |
|
| 11913 |
|
| 11914 |
|
| 11915 |
|
| 11916 |
|
| 11917 |
|
| 11918 |
|
| 11919 |
|
| 11920 |
|
| 11921 |
|
| 11922 |
|
| 11923 |
|
| 11924 |
|
| 11925 |
@SystemApi |
| 11926 |
@RequiresPermission(android.Manifest.permission.SET_UNRESTRICTED_KEEP_CLEAR_AREAS) |
| 11927 |
public final void setUnrestrictedPreferKeepClearRects(@NonNull List<Rect> rects) { |
| 11928 |
final ListenerInfo info = getListenerInfo(); |
| 11929 |
if (info.mUnrestrictedKeepClearRects != null) { |
| 11930 |
info.mUnrestrictedKeepClearRects.clear(); |
| 11931 |
info.mUnrestrictedKeepClearRects.addAll(rects); |
| 11932 |
} else { |
| 11933 |
info.mUnrestrictedKeepClearRects = new ArrayList<>(rects); |
| 11934 |
} |
| 11935 |
updatePositionUpdateListener(); |
| 11936 |
postUpdate(this::updateKeepClearRects); |
| 11937 |
} |
| 11938 |
|
| 11939 |
|
| 11940 |
|
| 11941 |
|
| 11942 |
|
| 11943 |
|
| 11944 |
|
| 11945 |
|
| 11946 |
@SystemApi |
| 11947 |
@NonNull |
| 11948 |
public final List<Rect> getUnrestrictedPreferKeepClearRects() { |
| 11949 |
final ListenerInfo info = mListenerInfo; |
| 11950 |
if (info != null && info.mUnrestrictedKeepClearRects != null) { |
| 11951 |
return new ArrayList(info.mUnrestrictedKeepClearRects); |
| 11952 |
} |
| 11953 |
|
| 11954 |
return Collections.emptyList(); |
| 11955 |
} |
| 11956 |
|
| 11957 |
void updateKeepClearRects() { |
| 11958 |
final AttachInfo ai = mAttachInfo; |
| 11959 |
if (ai != null) { |
| 11960 |
ai.mViewRootImpl.updateKeepClearRectsForView(this); |
| 11961 |
} |
| 11962 |
} |
| 11963 |
|
| 11964 |
|
| 11965 |
|
| 11966 |
|
| 11967 |
|
| 11968 |
@NonNull |
| 11969 |
List<Rect> collectPreferKeepClearRects() { |
| 11970 |
ListenerInfo info = mListenerInfo; |
| 11971 |
boolean keepClearForFocus = isFocused() |
| 11972 |
&& ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled(); |
| 11973 |
boolean keepBoundsClear = (info != null && info.mPreferKeepClear) || keepClearForFocus; |
| 11974 |
boolean hasCustomKeepClearRects = info != null && info.mKeepClearRects != null; |
| 11975 |
|
| 11976 |
if (!keepBoundsClear && !hasCustomKeepClearRects) { |
| 11977 |
return Collections.emptyList(); |
| 11978 |
} else if (keepBoundsClear && !hasCustomKeepClearRects) { |
| 11979 |
return Collections.singletonList(new Rect(0, 0, getWidth(), getHeight())); |
| 11980 |
} |
| 11981 |
|
| 11982 |
final List<Rect> list = new ArrayList<>(); |
| 11983 |
if (keepBoundsClear) { |
| 11984 |
list.add(new Rect(0, 0, getWidth(), getHeight())); |
| 11985 |
} |
| 11986 |
|
| 11987 |
if (hasCustomKeepClearRects) { |
| 11988 |
list.addAll(info.mKeepClearRects); |
| 11989 |
} |
| 11990 |
|
| 11991 |
return list; |
| 11992 |
} |
| 11993 |
|
| 11994 |
private void updatePreferKeepClearForFocus() { |
| 11995 |
if (ViewConfiguration.get(mContext).isPreferKeepClearForFocusEnabled()) { |
| 11996 |
updatePositionUpdateListener(); |
| 11997 |
post(this::updateKeepClearRects); |
| 11998 |
} |
| 11999 |
} |
| 12000 |
|
| 12001 |
|
| 12002 |
|
| 12003 |
|
| 12004 |
|
| 12005 |
@NonNull |
| 12006 |
List<Rect> collectUnrestrictedPreferKeepClearRects() { |
| 12007 |
final ListenerInfo info = mListenerInfo; |
| 12008 |
if (info != null && info.mUnrestrictedKeepClearRects != null) { |
| 12009 |
return info.mUnrestrictedKeepClearRects; |
| 12010 |
} |
| 12011 |
|
| 12012 |
return Collections.emptyList(); |
| 12013 |
} |
| 12014 |
|
| 12015 |
|
| 12016 |
|
| 12017 |
|
| 12018 |
|
| 12019 |
|
| 12020 |
|
| 12021 |
|
| 12022 |
|
| 12023 |
|
| 12024 |
|
| 12025 |
|
| 12026 |
|
| 12027 |
|
| 12028 |
public void setHandwritingArea(@Nullable Rect rect) { |
| 12029 |
final ListenerInfo info = getListenerInfo(); |
| 12030 |
info.mHandwritingArea = rect; |
| 12031 |
updatePositionUpdateListener(); |
| 12032 |
postUpdate(this::updateHandwritingArea); |
| 12033 |
} |
| 12034 |
|
| 12035 |
|
| 12036 |
|
| 12037 |
|
| 12038 |
|
| 12039 |
|
| 12040 |
|
| 12041 |
@Nullable |
| 12042 |
public Rect getHandwritingArea() { |
| 12043 |
final ListenerInfo info = mListenerInfo; |
| 12044 |
if (info != null && info.mHandwritingArea != null) { |
| 12045 |
return new Rect(info.mHandwritingArea); |
| 12046 |
} |
| 12047 |
return null; |
| 12048 |
} |
| 12049 |
|
| 12050 |
void updateHandwritingArea() { |
| 12051 |
|
| 12052 |
if (!isAutoHandwritingEnabled()) return; |
| 12053 |
final AttachInfo ai = mAttachInfo; |
| 12054 |
if (ai != null) { |
| 12055 |
ai.mViewRootImpl.getHandwritingInitiator().updateHandwritingAreasForView(this); |
| 12056 |
} |
| 12057 |
} |
| 12058 |
|
| 12059 |
|
| 12060 |
|
| 12061 |
|
| 12062 |
|
| 12063 |
|
| 12064 |
|
| 12065 |
|
| 12066 |
|
| 12067 |
|
| 12068 |
|
| 12069 |
|
| 12070 |
|
| 12071 |
|
| 12072 |
|
| 12073 |
|
| 12074 |
public void getLocationInSurface(@NonNull @Size(2) int[] location) { |
| 12075 |
getLocationInWindow(location); |
| 12076 |
if (mAttachInfo != null && mAttachInfo.mViewRootImpl != null) { |
| 12077 |
location[0] += mAttachInfo.mViewRootImpl.mWindowAttributes.surfaceInsets.left; |
| 12078 |
location[1] += mAttachInfo.mViewRootImpl.mWindowAttributes.surfaceInsets.top; |
| 12079 |
} |
| 12080 |
} |
| 12081 |
|
| 12082 |
|
| 12083 |
|
| 12084 |
|
| 12085 |
|
| 12086 |
|
| 12087 |
|
| 12088 |
public WindowInsets getRootWindowInsets() { |
| 12089 |
if (mAttachInfo != null) { |
| 12090 |
return mAttachInfo.mViewRootImpl.getWindowInsets(false ); |
| 12091 |
} |
| 12092 |
return null; |
| 12093 |
} |
| 12094 |
|
| 12095 |
|
| 12096 |
|
| 12097 |
|
| 12098 |
|
| 12099 |
|
| 12100 |
|
| 12101 |
|
| 12102 |
public @Nullable WindowInsetsController getWindowInsetsController() { |
| 12103 |
if (mAttachInfo != null) { |
| 12104 |
return mAttachInfo.mViewRootImpl.getInsetsController(); |
| 12105 |
} |
| 12106 |
ViewParent parent = getParent(); |
| 12107 |
if (parent instanceof View) { |
| 12108 |
return ((View) parent).getWindowInsetsController(); |
| 12109 |
} else if (parent instanceof ViewRootImpl) { |
| 12110 |
|
| 12111 |
return ((ViewRootImpl) parent).getInsetsController(); |
| 12112 |
} |
| 12113 |
return null; |
| 12114 |
} |
| 12115 |
|
| 12116 |
|
| 12117 |
|
| 12118 |
|
| 12119 |
|
| 12120 |
|
| 12121 |
|
| 12122 |
|
| 12123 |
|
| 12124 |
@Nullable |
| 12125 |
public final OnBackInvokedDispatcher findOnBackInvokedDispatcher() { |
| 12126 |
ViewParent parent = getParent(); |
| 12127 |
if (parent != null) { |
| 12128 |
return parent.findOnBackInvokedDispatcherForChild(this, this); |
| 12129 |
} |
| 12130 |
return null; |
| 12131 |
} |
| 12132 |
|
| 12133 |
|
| 12134 |
|
| 12135 |
|
| 12136 |
|
| 12137 |
|
| 12138 |
|
| 12139 |
|
| 12140 |
|
| 12141 |
|
| 12142 |
|
| 12143 |
|
| 12144 |
@Deprecated |
| 12145 |
@UnsupportedAppUsage |
| 12146 |
protected boolean computeFitSystemWindows(Rect inoutInsets, Rect outLocalInsets) { |
| 12147 |
WindowInsets innerInsets = computeSystemWindowInsets(new WindowInsets(inoutInsets), |
| 12148 |
outLocalInsets); |
| 12149 |
inoutInsets.set(innerInsets.getSystemWindowInsetsAsRect()); |
| 12150 |
return innerInsets.isSystemWindowInsetsConsumed(); |
| 12151 |
} |
| 12152 |
|
| 12153 |
|
| 12154 |
|
| 12155 |
|
| 12156 |
|
| 12157 |
|
| 12158 |
|
| 12159 |
|
| 12160 |
|
| 12161 |
|
| 12162 |
|
| 12163 |
public WindowInsets computeSystemWindowInsets(WindowInsets in, Rect outLocalInsets) { |
| 12164 |
boolean isOptionalFitSystemWindows = (mViewFlags & OPTIONAL_FITS_SYSTEM_WINDOWS) != 0 |
| 12165 |
|| (mPrivateFlags4 & PFLAG4_FRAMEWORK_OPTIONAL_FITS_SYSTEM_WINDOWS) != 0; |
| 12166 |
if (isOptionalFitSystemWindows && mAttachInfo != null) { |
| 12167 |
OnContentApplyWindowInsetsListener listener = |
| 12168 |
mAttachInfo.mContentOnApplyWindowInsetsListener; |
| 12169 |
if (listener == null) { |
| 12170 |
|
| 12171 |
|
| 12172 |
outLocalInsets.setEmpty(); |
| 12173 |
return in; |
| 12174 |
} |
| 12175 |
Pair<Insets, WindowInsets> result = listener.onContentApplyWindowInsets(this, in); |
| 12176 |
outLocalInsets.set(result.first.toRect()); |
| 12177 |
return result.second; |
| 12178 |
} else { |
| 12179 |
outLocalInsets.set(in.getSystemWindowInsetsAsRect()); |
| 12180 |
return in.consumeSystemWindowInsets().inset(outLocalInsets); |
| 12181 |
} |
| 12182 |
} |
| 12183 |
|
| 12184 |
|
| 12185 |
|
| 12186 |
|
| 12187 |
|
| 12188 |
|
| 12189 |
|
| 12190 |
|
| 12191 |
|
| 12192 |
|
| 12193 |
|
| 12194 |
|
| 12195 |
|
| 12196 |
|
| 12197 |
|
| 12198 |
|
| 12199 |
|
| 12200 |
|
| 12201 |
|
| 12202 |
|
| 12203 |
public void setFitsSystemWindows(boolean fitSystemWindows) { |
| 12204 |
setFlags(fitSystemWindows ? FITS_SYSTEM_WINDOWS : 0, FITS_SYSTEM_WINDOWS); |
| 12205 |
} |
| 12206 |
|
| 12207 |
|
| 12208 |
|
| 12209 |
|
| 12210 |
|
| 12211 |
|
| 12212 |
|
| 12213 |
|
| 12214 |
|
| 12215 |
|
| 12216 |
|
| 12217 |
|
| 12218 |
|
| 12219 |
|
| 12220 |
@ViewDebug.ExportedProperty |
| 12221 |
@InspectableProperty |
| 12222 |
public boolean getFitsSystemWindows() { |
| 12223 |
return (mViewFlags & FITS_SYSTEM_WINDOWS) == FITS_SYSTEM_WINDOWS; |
| 12224 |
} |
| 12225 |
|
| 12226 |
|
| 12227 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 12228 |
public boolean fitsSystemWindows() { |
| 12229 |
return getFitsSystemWindows(); |
| 12230 |
} |
| 12231 |
|
| 12232 |
|
| 12233 |
|
| 12234 |
|
| 12235 |
|
| 12236 |
@Deprecated |
| 12237 |
public void requestFitSystemWindows() { |
| 12238 |
if (mParent != null) { |
| 12239 |
mParent.requestFitSystemWindows(); |
| 12240 |
} |
| 12241 |
} |
| 12242 |
|
| 12243 |
|
| 12244 |
|
| 12245 |
|
| 12246 |
public void requestApplyInsets() { |
| 12247 |
requestFitSystemWindows(); |
| 12248 |
} |
| 12249 |
|
| 12250 |
|
| 12251 |
|
| 12252 |
|
| 12253 |
|
| 12254 |
@UnsupportedAppUsage |
| 12255 |
public void makeOptionalFitsSystemWindows() { |
| 12256 |
setFlags(OPTIONAL_FITS_SYSTEM_WINDOWS, OPTIONAL_FITS_SYSTEM_WINDOWS); |
| 12257 |
} |
| 12258 |
|
| 12259 |
|
| 12260 |
|
| 12261 |
|
| 12262 |
|
| 12263 |
public void makeFrameworkOptionalFitsSystemWindows() { |
| 12264 |
mPrivateFlags4 |= PFLAG4_FRAMEWORK_OPTIONAL_FITS_SYSTEM_WINDOWS; |
| 12265 |
} |
| 12266 |
|
| 12267 |
|
| 12268 |
|
| 12269 |
|
| 12270 |
public boolean isFrameworkOptionalFitsSystemWindows() { |
| 12271 |
return (mPrivateFlags4 & PFLAG4_FRAMEWORK_OPTIONAL_FITS_SYSTEM_WINDOWS) != 0; |
| 12272 |
} |
| 12273 |
|
| 12274 |
|
| 12275 |
|
| 12276 |
|
| 12277 |
|
| 12278 |
|
| 12279 |
|
| 12280 |
@ViewDebug.ExportedProperty(mapping = { |
| 12281 |
@ViewDebug.IntToString(from = VISIBLE, to = "VISIBLE"), |
| 12282 |
@ViewDebug.IntToString(from = INVISIBLE, to = "INVISIBLE"), |
| 12283 |
@ViewDebug.IntToString(from = GONE, to = "GONE") |
| 12284 |
}) |
| 12285 |
@InspectableProperty(enumMapping = { |
| 12286 |
@EnumEntry(value = VISIBLE, name = "visible"), |
| 12287 |
@EnumEntry(value = INVISIBLE, name = "invisible"), |
| 12288 |
@EnumEntry(value = GONE, name = "gone") |
| 12289 |
}) |
| 12290 |
@Visibility |
| 12291 |
public int getVisibility() { |
| 12292 |
return mViewFlags & VISIBILITY_MASK; |
| 12293 |
} |
| 12294 |
|
| 12295 |
|
| 12296 |
|
| 12297 |
|
| 12298 |
|
| 12299 |
|
| 12300 |
|
| 12301 |
@RemotableViewMethod |
| 12302 |
public void setVisibility(@Visibility int visibility) { |
| 12303 |
setFlags(visibility, VISIBILITY_MASK); |
| 12304 |
} |
| 12305 |
|
| 12306 |
|
| 12307 |
|
| 12308 |
|
| 12309 |
|
| 12310 |
|
| 12311 |
|
| 12312 |
@ViewDebug.ExportedProperty |
| 12313 |
@InspectableProperty |
| 12314 |
public boolean isEnabled() { |
| 12315 |
return (mViewFlags & ENABLED_MASK) == ENABLED; |
| 12316 |
} |
| 12317 |
|
| 12318 |
|
| 12319 |
|
| 12320 |
|
| 12321 |
|
| 12322 |
|
| 12323 |
|
| 12324 |
@RemotableViewMethod |
| 12325 |
public void setEnabled(boolean enabled) { |
| 12326 |
if (enabled == isEnabled()) return; |
| 12327 |
|
| 12328 |
setFlags(enabled ? ENABLED : DISABLED, ENABLED_MASK); |
| 12329 |
|
| 12330 |
|
| 12331 |
|
| 12332 |
|
| 12333 |
|
| 12334 |
refreshDrawableState(); |
| 12335 |
|
| 12336 |
|
| 12337 |
|
| 12338 |
invalidate(true); |
| 12339 |
|
| 12340 |
if (!enabled) { |
| 12341 |
cancelPendingInputEvents(); |
| 12342 |
} |
| 12343 |
} |
| 12344 |
|
| 12345 |
|
| 12346 |
|
| 12347 |
|
| 12348 |
|
| 12349 |
|
| 12350 |
|
| 12351 |
|
| 12352 |
|
| 12353 |
|
| 12354 |
|
| 12355 |
|
| 12356 |
|
| 12357 |
@RemotableViewMethod |
| 12358 |
public void setFocusable(boolean focusable) { |
| 12359 |
setFocusable(focusable ? FOCUSABLE : NOT_FOCUSABLE); |
| 12360 |
} |
| 12361 |
|
| 12362 |
|
| 12363 |
|
| 12364 |
|
| 12365 |
|
| 12366 |
|
| 12367 |
|
| 12368 |
|
| 12369 |
|
| 12370 |
|
| 12371 |
|
| 12372 |
|
| 12373 |
|
| 12374 |
|
| 12375 |
|
| 12376 |
@RemotableViewMethod |
| 12377 |
public void setFocusable(@Focusable int focusable) { |
| 12378 |
if ((focusable & (FOCUSABLE_AUTO | FOCUSABLE)) == 0) { |
| 12379 |
setFlags(0, FOCUSABLE_IN_TOUCH_MODE); |
| 12380 |
} |
| 12381 |
setFlags(focusable, FOCUSABLE_MASK); |
| 12382 |
} |
| 12383 |
|
| 12384 |
|
| 12385 |
|
| 12386 |
|
| 12387 |
|
| 12388 |
|
| 12389 |
|
| 12390 |
|
| 12391 |
|
| 12392 |
|
| 12393 |
|
| 12394 |
|
| 12395 |
@RemotableViewMethod |
| 12396 |
public void setFocusableInTouchMode(boolean focusableInTouchMode) { |
| 12397 |
|
| 12398 |
|
| 12399 |
|
| 12400 |
|
| 12401 |
setFlags(focusableInTouchMode ? FOCUSABLE_IN_TOUCH_MODE : 0, FOCUSABLE_IN_TOUCH_MODE); |
| 12402 |
|
| 12403 |
|
| 12404 |
if (focusableInTouchMode) { |
| 12405 |
|
| 12406 |
setFlags(FOCUSABLE, FOCUSABLE_MASK); |
| 12407 |
} |
| 12408 |
} |
| 12409 |
|
| 12410 |
|
| 12411 |
|
| 12412 |
|
| 12413 |
|
| 12414 |
|
| 12415 |
|
| 12416 |
|
| 12417 |
|
| 12418 |
|
| 12419 |
|
| 12420 |
|
| 12421 |
|
| 12422 |
|
| 12423 |
|
| 12424 |
|
| 12425 |
|
| 12426 |
|
| 12427 |
|
| 12428 |
|
| 12429 |
|
| 12430 |
|
| 12431 |
|
| 12432 |
|
| 12433 |
|
| 12434 |
|
| 12435 |
public void setAutofillHints(@Nullable String... autofillHints) { |
| 12436 |
if (autofillHints == null || autofillHints.length == 0) { |
| 12437 |
mAutofillHints = null; |
| 12438 |
} else { |
| 12439 |
mAutofillHints = autofillHints; |
| 12440 |
} |
| 12441 |
} |
| 12442 |
|
| 12443 |
|
| 12444 |
|
| 12445 |
|
| 12446 |
@TestApi |
| 12447 |
public void setAutofilled(boolean isAutofilled, boolean hideHighlight) { |
| 12448 |
boolean wasChanged = isAutofilled != isAutofilled(); |
| 12449 |
|
| 12450 |
if (wasChanged) { |
| 12451 |
if (isAutofilled) { |
| 12452 |
mPrivateFlags3 |= PFLAG3_IS_AUTOFILLED; |
| 12453 |
} else { |
| 12454 |
mPrivateFlags3 &= ~PFLAG3_IS_AUTOFILLED; |
| 12455 |
} |
| 12456 |
|
| 12457 |
if (hideHighlight) { |
| 12458 |
mPrivateFlags4 |= PFLAG4_AUTOFILL_HIDE_HIGHLIGHT; |
| 12459 |
} else { |
| 12460 |
mPrivateFlags4 &= ~PFLAG4_AUTOFILL_HIDE_HIGHLIGHT; |
| 12461 |
} |
| 12462 |
|
| 12463 |
invalidate(); |
| 12464 |
} |
| 12465 |
} |
| 12466 |
|
| 12467 |
|
| 12468 |
|
| 12469 |
|
| 12470 |
|
| 12471 |
|
| 12472 |
|
| 12473 |
|
| 12474 |
|
| 12475 |
|
| 12476 |
|
| 12477 |
|
| 12478 |
|
| 12479 |
public void setSoundEffectsEnabled(boolean soundEffectsEnabled) { |
| 12480 |
setFlags(soundEffectsEnabled ? SOUND_EFFECTS_ENABLED: 0, SOUND_EFFECTS_ENABLED); |
| 12481 |
} |
| 12482 |
|
| 12483 |
|
| 12484 |
|
| 12485 |
|
| 12486 |
|
| 12487 |
|
| 12488 |
|
| 12489 |
|
| 12490 |
|
| 12491 |
@ViewDebug.ExportedProperty |
| 12492 |
@InspectableProperty |
| 12493 |
public boolean isSoundEffectsEnabled() { |
| 12494 |
return SOUND_EFFECTS_ENABLED == (mViewFlags & SOUND_EFFECTS_ENABLED); |
| 12495 |
} |
| 12496 |
|
| 12497 |
|
| 12498 |
|
| 12499 |
|
| 12500 |
|
| 12501 |
|
| 12502 |
|
| 12503 |
|
| 12504 |
|
| 12505 |
|
| 12506 |
|
| 12507 |
|
| 12508 |
|
| 12509 |
public void setHapticFeedbackEnabled(boolean hapticFeedbackEnabled) { |
| 12510 |
setFlags(hapticFeedbackEnabled ? HAPTIC_FEEDBACK_ENABLED: 0, HAPTIC_FEEDBACK_ENABLED); |
| 12511 |
} |
| 12512 |
|
| 12513 |
|
| 12514 |
|
| 12515 |
|
| 12516 |
|
| 12517 |
|
| 12518 |
|
| 12519 |
|
| 12520 |
|
| 12521 |
@ViewDebug.ExportedProperty |
| 12522 |
@InspectableProperty |
| 12523 |
public boolean isHapticFeedbackEnabled() { |
| 12524 |
return HAPTIC_FEEDBACK_ENABLED == (mViewFlags & HAPTIC_FEEDBACK_ENABLED); |
| 12525 |
} |
| 12526 |
|
| 12527 |
|
| 12528 |
|
| 12529 |
|
| 12530 |
|
| 12531 |
|
| 12532 |
|
| 12533 |
|
| 12534 |
|
| 12535 |
|
| 12536 |
|
| 12537 |
|
| 12538 |
|
| 12539 |
@ViewDebug.ExportedProperty(category = "layout", mapping = { |
| 12540 |
@ViewDebug.IntToString(from = LAYOUT_DIRECTION_LTR, to = "LTR"), |
| 12541 |
@ViewDebug.IntToString(from = LAYOUT_DIRECTION_RTL, to = "RTL"), |
| 12542 |
@ViewDebug.IntToString(from = LAYOUT_DIRECTION_INHERIT, to = "INHERIT"), |
| 12543 |
@ViewDebug.IntToString(from = LAYOUT_DIRECTION_LOCALE, to = "LOCALE") |
| 12544 |
}) |
| 12545 |
@InspectableProperty(hasAttributeId = false, enumMapping = { |
| 12546 |
@EnumEntry(value = LAYOUT_DIRECTION_LTR, name = "ltr"), |
| 12547 |
@EnumEntry(value = LAYOUT_DIRECTION_RTL, name = "rtl"), |
| 12548 |
@EnumEntry(value = LAYOUT_DIRECTION_INHERIT, name = "inherit"), |
| 12549 |
@EnumEntry(value = LAYOUT_DIRECTION_LOCALE, name = "locale") |
| 12550 |
}) |
| 12551 |
@LayoutDir |
| 12552 |
public int getRawLayoutDirection() { |
| 12553 |
return (mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_MASK) >> PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT; |
| 12554 |
} |
| 12555 |
|
| 12556 |
|
| 12557 |
|
| 12558 |
|
| 12559 |
|
| 12560 |
|
| 12561 |
|
| 12562 |
|
| 12563 |
|
| 12564 |
|
| 12565 |
|
| 12566 |
|
| 12567 |
|
| 12568 |
|
| 12569 |
|
| 12570 |
|
| 12571 |
|
| 12572 |
|
| 12573 |
@RemotableViewMethod |
| 12574 |
public void setLayoutDirection(@LayoutDir int layoutDirection) { |
| 12575 |
if (getRawLayoutDirection() != layoutDirection) { |
| 12576 |
|
| 12577 |
mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_MASK; |
| 12578 |
resetRtlProperties(); |
| 12579 |
|
| 12580 |
mPrivateFlags2 |= |
| 12581 |
((layoutDirection << PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) & PFLAG2_LAYOUT_DIRECTION_MASK); |
| 12582 |
|
| 12583 |
resolveRtlPropertiesIfNeeded(); |
| 12584 |
requestLayout(); |
| 12585 |
invalidate(true); |
| 12586 |
} |
| 12587 |
} |
| 12588 |
|
| 12589 |
|
| 12590 |
|
| 12591 |
|
| 12592 |
|
| 12593 |
|
| 12594 |
|
| 12595 |
|
| 12596 |
|
| 12597 |
|
| 12598 |
|
| 12599 |
|
| 12600 |
@ViewDebug.ExportedProperty(category = "layout", mapping = { |
| 12601 |
@ViewDebug.IntToString(from = LAYOUT_DIRECTION_LTR, to = "RESOLVED_DIRECTION_LTR"), |
| 12602 |
@ViewDebug.IntToString(from = LAYOUT_DIRECTION_RTL, to = "RESOLVED_DIRECTION_RTL") |
| 12603 |
}) |
| 12604 |
@InspectableProperty(enumMapping = { |
| 12605 |
@EnumEntry(value = LAYOUT_DIRECTION_LTR, name = "ltr"), |
| 12606 |
@EnumEntry(value = LAYOUT_DIRECTION_RTL, name = "rtl") |
| 12607 |
}) |
| 12608 |
@ResolvedLayoutDir |
| 12609 |
public int getLayoutDirection() { |
| 12610 |
final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; |
| 12611 |
if (targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR1) { |
| 12612 |
mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED; |
| 12613 |
return LAYOUT_DIRECTION_RESOLVED_DEFAULT; |
| 12614 |
} |
| 12615 |
return ((mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL) == |
| 12616 |
PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL) ? LAYOUT_DIRECTION_RTL : LAYOUT_DIRECTION_LTR; |
| 12617 |
} |
| 12618 |
|
| 12619 |
|
| 12620 |
|
| 12621 |
|
| 12622 |
|
| 12623 |
|
| 12624 |
|
| 12625 |
|
| 12626 |
|
| 12627 |
@ViewDebug.ExportedProperty(category = "layout") |
| 12628 |
@UnsupportedAppUsage |
| 12629 |
public boolean isLayoutRtl() { |
| 12630 |
return (getLayoutDirection() == LAYOUT_DIRECTION_RTL); |
| 12631 |
} |
| 12632 |
|
| 12633 |
|
| 12634 |
|
| 12635 |
|
| 12636 |
|
| 12637 |
|
| 12638 |
|
| 12639 |
|
| 12640 |
|
| 12641 |
|
| 12642 |
|
| 12643 |
|
| 12644 |
|
| 12645 |
@ViewDebug.ExportedProperty(category = "layout") |
| 12646 |
public boolean hasTransientState() { |
| 12647 |
return (mPrivateFlags2 & PFLAG2_HAS_TRANSIENT_STATE) == PFLAG2_HAS_TRANSIENT_STATE; |
| 12648 |
} |
| 12649 |
|
| 12650 |
|
| 12651 |
|
| 12652 |
|
| 12653 |
|
| 12654 |
|
| 12655 |
|
| 12656 |
|
| 12657 |
|
| 12658 |
|
| 12659 |
|
| 12660 |
|
| 12661 |
|
| 12662 |
|
| 12663 |
public void setHasTransientState(boolean hasTransientState) { |
| 12664 |
final boolean oldHasTransientState = hasTransientState(); |
| 12665 |
mTransientStateCount = hasTransientState ? mTransientStateCount + 1 : |
| 12666 |
mTransientStateCount - 1; |
| 12667 |
if (mTransientStateCount < 0) { |
| 12668 |
mTransientStateCount = 0; |
| 12669 |
Log.e(VIEW_LOG_TAG, "hasTransientState decremented below 0: " + |
| 12670 |
"unmatched pair of setHasTransientState calls"); |
| 12671 |
} else if ((hasTransientState && mTransientStateCount == 1) || |
| 12672 |
(!hasTransientState && mTransientStateCount == 0)) { |
| 12673 |
|
| 12674 |
mPrivateFlags2 = (mPrivateFlags2 & ~PFLAG2_HAS_TRANSIENT_STATE) | |
| 12675 |
(hasTransientState ? PFLAG2_HAS_TRANSIENT_STATE : 0); |
| 12676 |
final boolean newHasTransientState = hasTransientState(); |
| 12677 |
if (mParent != null && newHasTransientState != oldHasTransientState) { |
| 12678 |
try { |
| 12679 |
mParent.childHasTransientStateChanged(this, newHasTransientState); |
| 12680 |
} catch (AbstractMethodError e) { |
| 12681 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 12682 |
" does not fully implement ViewParent", e); |
| 12683 |
} |
| 12684 |
} |
| 12685 |
} |
| 12686 |
} |
| 12687 |
|
| 12688 |
|
| 12689 |
|
| 12690 |
|
| 12691 |
|
| 12692 |
|
| 12693 |
|
| 12694 |
|
| 12695 |
|
| 12696 |
public void setHasTranslationTransientState(boolean hasTranslationTransientState) { |
| 12697 |
if (hasTranslationTransientState) { |
| 12698 |
mPrivateFlags4 |= PFLAG4_HAS_TRANSLATION_TRANSIENT_STATE; |
| 12699 |
} else { |
| 12700 |
mPrivateFlags4 &= ~PFLAG4_HAS_TRANSLATION_TRANSIENT_STATE; |
| 12701 |
} |
| 12702 |
} |
| 12703 |
|
| 12704 |
|
| 12705 |
|
| 12706 |
|
| 12707 |
public boolean hasTranslationTransientState() { |
| 12708 |
return (mPrivateFlags4 & PFLAG4_HAS_TRANSLATION_TRANSIENT_STATE) |
| 12709 |
== PFLAG4_HAS_TRANSLATION_TRANSIENT_STATE; |
| 12710 |
} |
| 12711 |
|
| 12712 |
|
| 12713 |
|
| 12714 |
|
| 12715 |
public void clearTranslationState() { |
| 12716 |
if (mViewTranslationCallback != null) { |
| 12717 |
mViewTranslationCallback.onClearTranslation(this); |
| 12718 |
} |
| 12719 |
clearViewTranslationResponse(); |
| 12720 |
if (hasTranslationTransientState()) { |
| 12721 |
setHasTransientState(false); |
| 12722 |
setHasTranslationTransientState(false); |
| 12723 |
} |
| 12724 |
} |
| 12725 |
|
| 12726 |
|
| 12727 |
|
| 12728 |
|
| 12729 |
public boolean isAttachedToWindow() { |
| 12730 |
return mAttachInfo != null; |
| 12731 |
} |
| 12732 |
|
| 12733 |
|
| 12734 |
|
| 12735 |
|
| 12736 |
|
| 12737 |
public boolean isLaidOut() { |
| 12738 |
return (mPrivateFlags3 & PFLAG3_IS_LAID_OUT) == PFLAG3_IS_LAID_OUT; |
| 12739 |
} |
| 12740 |
|
| 12741 |
|
| 12742 |
|
| 12743 |
|
| 12744 |
boolean isLayoutValid() { |
| 12745 |
return isLaidOut() && ((mPrivateFlags & PFLAG_FORCE_LAYOUT) == 0); |
| 12746 |
} |
| 12747 |
|
| 12748 |
|
| 12749 |
|
| 12750 |
|
| 12751 |
|
| 12752 |
|
| 12753 |
|
| 12754 |
|
| 12755 |
|
| 12756 |
|
| 12757 |
|
| 12758 |
public void setWillNotDraw(boolean willNotDraw) { |
| 12759 |
setFlags(willNotDraw ? WILL_NOT_DRAW : 0, DRAW_MASK); |
| 12760 |
} |
| 12761 |
|
| 12762 |
|
| 12763 |
|
| 12764 |
|
| 12765 |
|
| 12766 |
|
| 12767 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 12768 |
public boolean willNotDraw() { |
| 12769 |
return (mViewFlags & DRAW_MASK) == WILL_NOT_DRAW; |
| 12770 |
} |
| 12771 |
|
| 12772 |
|
| 12773 |
|
| 12774 |
|
| 12775 |
|
| 12776 |
|
| 12777 |
|
| 12778 |
|
| 12779 |
|
| 12780 |
|
| 12781 |
|
| 12782 |
|
| 12783 |
|
| 12784 |
|
| 12785 |
|
| 12786 |
|
| 12787 |
|
| 12788 |
|
| 12789 |
|
| 12790 |
|
| 12791 |
|
| 12792 |
|
| 12793 |
|
| 12794 |
@Deprecated |
| 12795 |
public void setWillNotCacheDrawing(boolean willNotCacheDrawing) { |
| 12796 |
setFlags(willNotCacheDrawing ? WILL_NOT_CACHE_DRAWING : 0, WILL_NOT_CACHE_DRAWING); |
| 12797 |
} |
| 12798 |
|
| 12799 |
|
| 12800 |
|
| 12801 |
|
| 12802 |
|
| 12803 |
|
| 12804 |
|
| 12805 |
|
| 12806 |
|
| 12807 |
|
| 12808 |
|
| 12809 |
|
| 12810 |
|
| 12811 |
|
| 12812 |
|
| 12813 |
|
| 12814 |
|
| 12815 |
|
| 12816 |
|
| 12817 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 12818 |
@Deprecated |
| 12819 |
public boolean willNotCacheDrawing() { |
| 12820 |
return (mViewFlags & WILL_NOT_CACHE_DRAWING) == WILL_NOT_CACHE_DRAWING; |
| 12821 |
} |
| 12822 |
|
| 12823 |
|
| 12824 |
|
| 12825 |
|
| 12826 |
|
| 12827 |
|
| 12828 |
|
| 12829 |
|
| 12830 |
|
| 12831 |
@ViewDebug.ExportedProperty |
| 12832 |
@InspectableProperty |
| 12833 |
public boolean isClickable() { |
| 12834 |
return (mViewFlags & CLICKABLE) == CLICKABLE; |
| 12835 |
} |
| 12836 |
|
| 12837 |
|
| 12838 |
|
| 12839 |
|
| 12840 |
|
| 12841 |
|
| 12842 |
|
| 12843 |
|
| 12844 |
|
| 12845 |
|
| 12846 |
|
| 12847 |
|
| 12848 |
public void setClickable(boolean clickable) { |
| 12849 |
setFlags(clickable ? CLICKABLE : 0, CLICKABLE); |
| 12850 |
} |
| 12851 |
|
| 12852 |
|
| 12853 |
|
| 12854 |
|
| 12855 |
|
| 12856 |
|
| 12857 |
|
| 12858 |
|
| 12859 |
public void setAllowClickWhenDisabled(boolean clickableWhenDisabled) { |
| 12860 |
if (clickableWhenDisabled) { |
| 12861 |
mPrivateFlags4 |= PFLAG4_ALLOW_CLICK_WHEN_DISABLED; |
| 12862 |
} else { |
| 12863 |
mPrivateFlags4 &= ~PFLAG4_ALLOW_CLICK_WHEN_DISABLED; |
| 12864 |
} |
| 12865 |
} |
| 12866 |
|
| 12867 |
|
| 12868 |
|
| 12869 |
|
| 12870 |
|
| 12871 |
|
| 12872 |
|
| 12873 |
|
| 12874 |
|
| 12875 |
@InspectableProperty |
| 12876 |
public boolean isLongClickable() { |
| 12877 |
return (mViewFlags & LONG_CLICKABLE) == LONG_CLICKABLE; |
| 12878 |
} |
| 12879 |
|
| 12880 |
|
| 12881 |
|
| 12882 |
|
| 12883 |
|
| 12884 |
|
| 12885 |
|
| 12886 |
|
| 12887 |
|
| 12888 |
|
| 12889 |
|
| 12890 |
public void setLongClickable(boolean longClickable) { |
| 12891 |
setFlags(longClickable ? LONG_CLICKABLE : 0, LONG_CLICKABLE); |
| 12892 |
} |
| 12893 |
|
| 12894 |
|
| 12895 |
|
| 12896 |
|
| 12897 |
|
| 12898 |
|
| 12899 |
|
| 12900 |
|
| 12901 |
@InspectableProperty |
| 12902 |
public boolean isContextClickable() { |
| 12903 |
return (mViewFlags & CONTEXT_CLICKABLE) == CONTEXT_CLICKABLE; |
| 12904 |
} |
| 12905 |
|
| 12906 |
|
| 12907 |
|
| 12908 |
|
| 12909 |
|
| 12910 |
|
| 12911 |
|
| 12912 |
|
| 12913 |
public void setContextClickable(boolean contextClickable) { |
| 12914 |
setFlags(contextClickable ? CONTEXT_CLICKABLE : 0, CONTEXT_CLICKABLE); |
| 12915 |
} |
| 12916 |
|
| 12917 |
|
| 12918 |
|
| 12919 |
|
| 12920 |
|
| 12921 |
|
| 12922 |
|
| 12923 |
|
| 12924 |
|
| 12925 |
|
| 12926 |
|
| 12927 |
private void setPressed(boolean pressed, float x, float y) { |
| 12928 |
if (pressed) { |
| 12929 |
drawableHotspotChanged(x, y); |
| 12930 |
} |
| 12931 |
|
| 12932 |
setPressed(pressed); |
| 12933 |
} |
| 12934 |
|
| 12935 |
|
| 12936 |
|
| 12937 |
|
| 12938 |
|
| 12939 |
|
| 12940 |
|
| 12941 |
|
| 12942 |
|
| 12943 |
|
| 12944 |
public void setPressed(boolean pressed) { |
| 12945 |
final boolean needsRefresh = pressed != ((mPrivateFlags & PFLAG_PRESSED) == PFLAG_PRESSED); |
| 12946 |
|
| 12947 |
if (pressed) { |
| 12948 |
mPrivateFlags |= PFLAG_PRESSED; |
| 12949 |
} else { |
| 12950 |
mPrivateFlags &= ~PFLAG_PRESSED; |
| 12951 |
} |
| 12952 |
|
| 12953 |
if (needsRefresh) { |
| 12954 |
refreshDrawableState(); |
| 12955 |
} |
| 12956 |
dispatchSetPressed(pressed); |
| 12957 |
} |
| 12958 |
|
| 12959 |
|
| 12960 |
|
| 12961 |
|
| 12962 |
|
| 12963 |
|
| 12964 |
|
| 12965 |
|
| 12966 |
protected void dispatchSetPressed(boolean pressed) { |
| 12967 |
} |
| 12968 |
|
| 12969 |
|
| 12970 |
|
| 12971 |
|
| 12972 |
|
| 12973 |
|
| 12974 |
|
| 12975 |
|
| 12976 |
|
| 12977 |
|
| 12978 |
|
| 12979 |
|
| 12980 |
@ViewDebug.ExportedProperty |
| 12981 |
@InspectableProperty(hasAttributeId = false) |
| 12982 |
public boolean isPressed() { |
| 12983 |
return (mPrivateFlags & PFLAG_PRESSED) == PFLAG_PRESSED; |
| 12984 |
} |
| 12985 |
|
| 12986 |
|
| 12987 |
|
| 12988 |
|
| 12989 |
|
| 12990 |
|
| 12991 |
|
| 12992 |
|
| 12993 |
|
| 12994 |
|
| 12995 |
|
| 12996 |
|
| 12997 |
public boolean isAssistBlocked() { |
| 12998 |
return (mPrivateFlags3 & PFLAG3_ASSIST_BLOCKED) != 0; |
| 12999 |
} |
| 13000 |
|
| 13001 |
|
| 13002 |
|
| 13003 |
|
| 13004 |
|
| 13005 |
|
| 13006 |
|
| 13007 |
|
| 13008 |
|
| 13009 |
|
| 13010 |
|
| 13011 |
|
| 13012 |
|
| 13013 |
|
| 13014 |
|
| 13015 |
|
| 13016 |
@UnsupportedAppUsage |
| 13017 |
public void setAssistBlocked(boolean enabled) { |
| 13018 |
if (enabled) { |
| 13019 |
mPrivateFlags3 |= PFLAG3_ASSIST_BLOCKED; |
| 13020 |
} else { |
| 13021 |
mPrivateFlags3 &= ~PFLAG3_ASSIST_BLOCKED; |
| 13022 |
} |
| 13023 |
} |
| 13024 |
|
| 13025 |
|
| 13026 |
|
| 13027 |
|
| 13028 |
|
| 13029 |
|
| 13030 |
|
| 13031 |
|
| 13032 |
|
| 13033 |
|
| 13034 |
@InspectableProperty |
| 13035 |
public boolean isSaveEnabled() { |
| 13036 |
return (mViewFlags & SAVE_DISABLED_MASK) != SAVE_DISABLED; |
| 13037 |
} |
| 13038 |
|
| 13039 |
|
| 13040 |
|
| 13041 |
|
| 13042 |
|
| 13043 |
|
| 13044 |
|
| 13045 |
|
| 13046 |
|
| 13047 |
|
| 13048 |
|
| 13049 |
|
| 13050 |
|
| 13051 |
|
| 13052 |
|
| 13053 |
|
| 13054 |
|
| 13055 |
public void setSaveEnabled(boolean enabled) { |
| 13056 |
setFlags(enabled ? 0 : SAVE_DISABLED, SAVE_DISABLED_MASK); |
| 13057 |
} |
| 13058 |
|
| 13059 |
|
| 13060 |
|
| 13061 |
|
| 13062 |
|
| 13063 |
|
| 13064 |
|
| 13065 |
|
| 13066 |
|
| 13067 |
|
| 13068 |
|
| 13069 |
@ViewDebug.ExportedProperty |
| 13070 |
@InspectableProperty |
| 13071 |
public boolean getFilterTouchesWhenObscured() { |
| 13072 |
return (mViewFlags & FILTER_TOUCHES_WHEN_OBSCURED) != 0; |
| 13073 |
} |
| 13074 |
|
| 13075 |
|
| 13076 |
|
| 13077 |
|
| 13078 |
|
| 13079 |
|
| 13080 |
|
| 13081 |
|
| 13082 |
|
| 13083 |
|
| 13084 |
|
| 13085 |
public void setFilterTouchesWhenObscured(boolean enabled) { |
| 13086 |
setFlags(enabled ? FILTER_TOUCHES_WHEN_OBSCURED : 0, |
| 13087 |
FILTER_TOUCHES_WHEN_OBSCURED); |
| 13088 |
} |
| 13089 |
|
| 13090 |
|
| 13091 |
|
| 13092 |
|
| 13093 |
|
| 13094 |
|
| 13095 |
|
| 13096 |
|
| 13097 |
|
| 13098 |
|
| 13099 |
|
| 13100 |
public boolean isSaveFromParentEnabled() { |
| 13101 |
return (mViewFlags & PARENT_SAVE_DISABLED_MASK) != PARENT_SAVE_DISABLED; |
| 13102 |
} |
| 13103 |
|
| 13104 |
|
| 13105 |
|
| 13106 |
|
| 13107 |
|
| 13108 |
|
| 13109 |
|
| 13110 |
|
| 13111 |
|
| 13112 |
|
| 13113 |
|
| 13114 |
|
| 13115 |
|
| 13116 |
|
| 13117 |
public void setSaveFromParentEnabled(boolean enabled) { |
| 13118 |
setFlags(enabled ? 0 : PARENT_SAVE_DISABLED, PARENT_SAVE_DISABLED_MASK); |
| 13119 |
} |
| 13120 |
|
| 13121 |
|
| 13122 |
|
| 13123 |
|
| 13124 |
|
| 13125 |
|
| 13126 |
|
| 13127 |
@ViewDebug.ExportedProperty(category = "focus") |
| 13128 |
public final boolean isFocusable() { |
| 13129 |
return FOCUSABLE == (mViewFlags & FOCUSABLE); |
| 13130 |
} |
| 13131 |
|
| 13132 |
|
| 13133 |
|
| 13134 |
|
| 13135 |
|
| 13136 |
|
| 13137 |
|
| 13138 |
@ViewDebug.ExportedProperty(mapping = { |
| 13139 |
@ViewDebug.IntToString(from = NOT_FOCUSABLE, to = "NOT_FOCUSABLE"), |
| 13140 |
@ViewDebug.IntToString(from = FOCUSABLE, to = "FOCUSABLE"), |
| 13141 |
@ViewDebug.IntToString(from = FOCUSABLE_AUTO, to = "FOCUSABLE_AUTO") |
| 13142 |
}, category = "focus") |
| 13143 |
@InspectableProperty(enumMapping = { |
| 13144 |
@EnumEntry(value = NOT_FOCUSABLE, name = "false"), |
| 13145 |
@EnumEntry(value = FOCUSABLE, name = "true"), |
| 13146 |
@EnumEntry(value = FOCUSABLE_AUTO, name = "auto") |
| 13147 |
}) |
| 13148 |
@Focusable |
| 13149 |
public int getFocusable() { |
| 13150 |
return (mViewFlags & FOCUSABLE_AUTO) > 0 ? FOCUSABLE_AUTO : mViewFlags & FOCUSABLE; |
| 13151 |
} |
| 13152 |
|
| 13153 |
|
| 13154 |
|
| 13155 |
|
| 13156 |
|
| 13157 |
|
| 13158 |
|
| 13159 |
|
| 13160 |
|
| 13161 |
@ViewDebug.ExportedProperty(category = "focus") |
| 13162 |
@InspectableProperty |
| 13163 |
public final boolean isFocusableInTouchMode() { |
| 13164 |
return FOCUSABLE_IN_TOUCH_MODE == (mViewFlags & FOCUSABLE_IN_TOUCH_MODE); |
| 13165 |
} |
| 13166 |
|
| 13167 |
|
| 13168 |
|
| 13169 |
|
| 13170 |
|
| 13171 |
|
| 13172 |
|
| 13173 |
|
| 13174 |
|
| 13175 |
|
| 13176 |
@InspectableProperty |
| 13177 |
public boolean isScreenReaderFocusable() { |
| 13178 |
return (mPrivateFlags3 & PFLAG3_SCREEN_READER_FOCUSABLE) != 0; |
| 13179 |
} |
| 13180 |
|
| 13181 |
|
| 13182 |
|
| 13183 |
|
| 13184 |
|
| 13185 |
|
| 13186 |
|
| 13187 |
|
| 13188 |
|
| 13189 |
|
| 13190 |
|
| 13191 |
|
| 13192 |
|
| 13193 |
public void setScreenReaderFocusable(boolean screenReaderFocusable) { |
| 13194 |
updatePflags3AndNotifyA11yIfChanged(PFLAG3_SCREEN_READER_FOCUSABLE, screenReaderFocusable); |
| 13195 |
} |
| 13196 |
|
| 13197 |
|
| 13198 |
|
| 13199 |
|
| 13200 |
|
| 13201 |
|
| 13202 |
|
| 13203 |
|
| 13204 |
@InspectableProperty |
| 13205 |
public boolean isAccessibilityHeading() { |
| 13206 |
return (mPrivateFlags3 & PFLAG3_ACCESSIBILITY_HEADING) != 0; |
| 13207 |
} |
| 13208 |
|
| 13209 |
|
| 13210 |
|
| 13211 |
|
| 13212 |
|
| 13213 |
|
| 13214 |
|
| 13215 |
|
| 13216 |
|
| 13217 |
|
| 13218 |
|
| 13219 |
|
| 13220 |
public void setAccessibilityHeading(boolean isHeading) { |
| 13221 |
updatePflags3AndNotifyA11yIfChanged(PFLAG3_ACCESSIBILITY_HEADING, isHeading); |
| 13222 |
} |
| 13223 |
|
| 13224 |
private void updatePflags3AndNotifyA11yIfChanged(int mask, boolean newValue) { |
| 13225 |
int pflags3 = mPrivateFlags3; |
| 13226 |
if (newValue) { |
| 13227 |
pflags3 |= mask; |
| 13228 |
} else { |
| 13229 |
pflags3 &= ~mask; |
| 13230 |
} |
| 13231 |
|
| 13232 |
if (pflags3 != mPrivateFlags3) { |
| 13233 |
mPrivateFlags3 = pflags3; |
| 13234 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 13235 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 13236 |
} |
| 13237 |
} |
| 13238 |
|
| 13239 |
|
| 13240 |
|
| 13241 |
|
| 13242 |
|
| 13243 |
|
| 13244 |
|
| 13245 |
|
| 13246 |
|
| 13247 |
|
| 13248 |
public View focusSearch(@FocusRealDirection int direction) { |
| 13249 |
if (mParent != null) { |
| 13250 |
return mParent.focusSearch(this, direction); |
| 13251 |
} else { |
| 13252 |
return null; |
| 13253 |
} |
| 13254 |
} |
| 13255 |
|
| 13256 |
|
| 13257 |
|
| 13258 |
|
| 13259 |
|
| 13260 |
|
| 13261 |
|
| 13262 |
@ViewDebug.ExportedProperty(category = "focus") |
| 13263 |
@InspectableProperty |
| 13264 |
public final boolean isKeyboardNavigationCluster() { |
| 13265 |
return (mPrivateFlags3 & PFLAG3_CLUSTER) != 0; |
| 13266 |
} |
| 13267 |
|
| 13268 |
|
| 13269 |
|
| 13270 |
|
| 13271 |
|
| 13272 |
|
| 13273 |
|
| 13274 |
|
| 13275 |
View findKeyboardNavigationCluster() { |
| 13276 |
if (mParent instanceof View) { |
| 13277 |
View cluster = ((View) mParent).findKeyboardNavigationCluster(); |
| 13278 |
if (cluster != null) { |
| 13279 |
return cluster; |
| 13280 |
} else if (isKeyboardNavigationCluster()) { |
| 13281 |
return this; |
| 13282 |
} |
| 13283 |
} |
| 13284 |
return null; |
| 13285 |
} |
| 13286 |
|
| 13287 |
|
| 13288 |
|
| 13289 |
|
| 13290 |
|
| 13291 |
|
| 13292 |
|
| 13293 |
|
| 13294 |
public void setKeyboardNavigationCluster(boolean isCluster) { |
| 13295 |
if (isCluster) { |
| 13296 |
mPrivateFlags3 |= PFLAG3_CLUSTER; |
| 13297 |
} else { |
| 13298 |
mPrivateFlags3 &= ~PFLAG3_CLUSTER; |
| 13299 |
} |
| 13300 |
} |
| 13301 |
|
| 13302 |
|
| 13303 |
|
| 13304 |
|
| 13305 |
|
| 13306 |
|
| 13307 |
|
| 13308 |
|
| 13309 |
@TestApi |
| 13310 |
public final void setFocusedInCluster() { |
| 13311 |
setFocusedInCluster(findKeyboardNavigationCluster()); |
| 13312 |
} |
| 13313 |
|
| 13314 |
private void setFocusedInCluster(View cluster) { |
| 13315 |
if (this instanceof ViewGroup) { |
| 13316 |
((ViewGroup) this).mFocusedInCluster = null; |
| 13317 |
} |
| 13318 |
if (cluster == this) { |
| 13319 |
return; |
| 13320 |
} |
| 13321 |
ViewParent parent = mParent; |
| 13322 |
View child = this; |
| 13323 |
while (parent instanceof ViewGroup) { |
| 13324 |
((ViewGroup) parent).mFocusedInCluster = child; |
| 13325 |
if (parent == cluster) { |
| 13326 |
break; |
| 13327 |
} |
| 13328 |
child = (View) parent; |
| 13329 |
parent = parent.getParent(); |
| 13330 |
} |
| 13331 |
} |
| 13332 |
|
| 13333 |
private void updateFocusedInCluster(View oldFocus, @FocusDirection int direction) { |
| 13334 |
if (oldFocus != null) { |
| 13335 |
View oldCluster = oldFocus.findKeyboardNavigationCluster(); |
| 13336 |
View cluster = findKeyboardNavigationCluster(); |
| 13337 |
if (oldCluster != cluster) { |
| 13338 |
|
| 13339 |
|
| 13340 |
oldFocus.setFocusedInCluster(oldCluster); |
| 13341 |
if (!(oldFocus.mParent instanceof ViewGroup)) { |
| 13342 |
return; |
| 13343 |
} |
| 13344 |
if (direction == FOCUS_FORWARD || direction == FOCUS_BACKWARD) { |
| 13345 |
|
| 13346 |
|
| 13347 |
((ViewGroup) oldFocus.mParent).clearFocusedInCluster(oldFocus); |
| 13348 |
} else if (oldFocus instanceof ViewGroup |
| 13349 |
&& ((ViewGroup) oldFocus).getDescendantFocusability() |
| 13350 |
== ViewGroup.FOCUS_AFTER_DESCENDANTS |
| 13351 |
&& ViewRootImpl.isViewDescendantOf(this, oldFocus)) { |
| 13352 |
|
| 13353 |
|
| 13354 |
((ViewGroup) oldFocus.mParent).clearFocusedInCluster(oldFocus); |
| 13355 |
} |
| 13356 |
} |
| 13357 |
} |
| 13358 |
} |
| 13359 |
|
| 13360 |
|
| 13361 |
|
| 13362 |
|
| 13363 |
|
| 13364 |
|
| 13365 |
|
| 13366 |
|
| 13367 |
|
| 13368 |
|
| 13369 |
|
| 13370 |
|
| 13371 |
|
| 13372 |
@ViewDebug.ExportedProperty(category = "focus") |
| 13373 |
@InspectableProperty |
| 13374 |
public final boolean isFocusedByDefault() { |
| 13375 |
return (mPrivateFlags3 & PFLAG3_FOCUSED_BY_DEFAULT) != 0; |
| 13376 |
} |
| 13377 |
|
| 13378 |
|
| 13379 |
|
| 13380 |
|
| 13381 |
|
| 13382 |
|
| 13383 |
|
| 13384 |
|
| 13385 |
|
| 13386 |
|
| 13387 |
|
| 13388 |
|
| 13389 |
|
| 13390 |
|
| 13391 |
|
| 13392 |
@RemotableViewMethod |
| 13393 |
public void setFocusedByDefault(boolean isFocusedByDefault) { |
| 13394 |
if (isFocusedByDefault == ((mPrivateFlags3 & PFLAG3_FOCUSED_BY_DEFAULT) != 0)) { |
| 13395 |
return; |
| 13396 |
} |
| 13397 |
|
| 13398 |
if (isFocusedByDefault) { |
| 13399 |
mPrivateFlags3 |= PFLAG3_FOCUSED_BY_DEFAULT; |
| 13400 |
} else { |
| 13401 |
mPrivateFlags3 &= ~PFLAG3_FOCUSED_BY_DEFAULT; |
| 13402 |
} |
| 13403 |
|
| 13404 |
if (mParent instanceof ViewGroup) { |
| 13405 |
if (isFocusedByDefault) { |
| 13406 |
((ViewGroup) mParent).setDefaultFocus(this); |
| 13407 |
} else { |
| 13408 |
((ViewGroup) mParent).clearDefaultFocus(this); |
| 13409 |
} |
| 13410 |
} |
| 13411 |
} |
| 13412 |
|
| 13413 |
|
| 13414 |
|
| 13415 |
|
| 13416 |
|
| 13417 |
|
| 13418 |
boolean hasDefaultFocus() { |
| 13419 |
return isFocusedByDefault(); |
| 13420 |
} |
| 13421 |
|
| 13422 |
|
| 13423 |
|
| 13424 |
|
| 13425 |
|
| 13426 |
|
| 13427 |
|
| 13428 |
|
| 13429 |
|
| 13430 |
|
| 13431 |
|
| 13432 |
|
| 13433 |
public View keyboardNavigationClusterSearch(View currentCluster, |
| 13434 |
@FocusDirection int direction) { |
| 13435 |
if (isKeyboardNavigationCluster()) { |
| 13436 |
currentCluster = this; |
| 13437 |
} |
| 13438 |
if (isRootNamespace()) { |
| 13439 |
|
| 13440 |
|
| 13441 |
|
| 13442 |
return FocusFinder.getInstance().findNextKeyboardNavigationCluster( |
| 13443 |
this, currentCluster, direction); |
| 13444 |
} else if (mParent != null) { |
| 13445 |
return mParent.keyboardNavigationClusterSearch(currentCluster, direction); |
| 13446 |
} |
| 13447 |
return null; |
| 13448 |
} |
| 13449 |
|
| 13450 |
|
| 13451 |
|
| 13452 |
|
| 13453 |
|
| 13454 |
|
| 13455 |
|
| 13456 |
|
| 13457 |
|
| 13458 |
|
| 13459 |
|
| 13460 |
|
| 13461 |
public boolean dispatchUnhandledMove(View focused, @FocusRealDirection int direction) { |
| 13462 |
return false; |
| 13463 |
} |
| 13464 |
|
| 13465 |
|
| 13466 |
|
| 13467 |
|
| 13468 |
|
| 13469 |
|
| 13470 |
|
| 13471 |
|
| 13472 |
|
| 13473 |
|
| 13474 |
public void setDefaultFocusHighlightEnabled(boolean defaultFocusHighlightEnabled) { |
| 13475 |
mDefaultFocusHighlightEnabled = defaultFocusHighlightEnabled; |
| 13476 |
} |
| 13477 |
|
| 13478 |
|
| 13479 |
|
| 13480 |
|
| 13481 |
|
| 13482 |
|
| 13483 |
|
| 13484 |
|
| 13485 |
@ViewDebug.ExportedProperty(category = "focus") |
| 13486 |
@InspectableProperty |
| 13487 |
public final boolean getDefaultFocusHighlightEnabled() { |
| 13488 |
return mDefaultFocusHighlightEnabled; |
| 13489 |
} |
| 13490 |
|
| 13491 |
|
| 13492 |
|
| 13493 |
|
| 13494 |
|
| 13495 |
|
| 13496 |
|
| 13497 |
|
| 13498 |
|
| 13499 |
View findUserSetNextFocus(View root, @FocusDirection int direction) { |
| 13500 |
switch (direction) { |
| 13501 |
case FOCUS_LEFT: |
| 13502 |
if (mNextFocusLeftId == View.NO_ID) return null; |
| 13503 |
return findViewInsideOutShouldExist(root, mNextFocusLeftId); |
| 13504 |
case FOCUS_RIGHT: |
| 13505 |
if (mNextFocusRightId == View.NO_ID) return null; |
| 13506 |
return findViewInsideOutShouldExist(root, mNextFocusRightId); |
| 13507 |
case FOCUS_UP: |
| 13508 |
if (mNextFocusUpId == View.NO_ID) return null; |
| 13509 |
return findViewInsideOutShouldExist(root, mNextFocusUpId); |
| 13510 |
case FOCUS_DOWN: |
| 13511 |
if (mNextFocusDownId == View.NO_ID) return null; |
| 13512 |
return findViewInsideOutShouldExist(root, mNextFocusDownId); |
| 13513 |
case FOCUS_FORWARD: |
| 13514 |
if (mNextFocusForwardId == View.NO_ID) return null; |
| 13515 |
return findViewInsideOutShouldExist(root, mNextFocusForwardId); |
| 13516 |
case FOCUS_BACKWARD: { |
| 13517 |
if (mID == View.NO_ID) return null; |
| 13518 |
final View rootView = root; |
| 13519 |
final View startView = this; |
| 13520 |
|
| 13521 |
|
| 13522 |
|
| 13523 |
return root.findViewByPredicateInsideOut(startView, |
| 13524 |
t -> findViewInsideOutShouldExist(rootView, t, t.mNextFocusForwardId) |
| 13525 |
== startView); |
| 13526 |
} |
| 13527 |
} |
| 13528 |
return null; |
| 13529 |
} |
| 13530 |
|
| 13531 |
|
| 13532 |
|
| 13533 |
|
| 13534 |
|
| 13535 |
|
| 13536 |
|
| 13537 |
|
| 13538 |
|
| 13539 |
View findUserSetNextKeyboardNavigationCluster(View root, @FocusDirection int direction) { |
| 13540 |
switch (direction) { |
| 13541 |
case FOCUS_FORWARD: |
| 13542 |
if (mNextClusterForwardId == View.NO_ID) return null; |
| 13543 |
return findViewInsideOutShouldExist(root, mNextClusterForwardId); |
| 13544 |
case FOCUS_BACKWARD: { |
| 13545 |
if (mID == View.NO_ID) return null; |
| 13546 |
final int id = mID; |
| 13547 |
return root.findViewByPredicateInsideOut(this, |
| 13548 |
(Predicate<View>) t -> t.mNextClusterForwardId == id); |
| 13549 |
} |
| 13550 |
} |
| 13551 |
return null; |
| 13552 |
} |
| 13553 |
|
| 13554 |
private View findViewInsideOutShouldExist(View root, int id) { |
| 13555 |
return findViewInsideOutShouldExist(root, this, id); |
| 13556 |
} |
| 13557 |
|
| 13558 |
private View findViewInsideOutShouldExist(View root, View start, int id) { |
| 13559 |
if (mMatchIdPredicate == null) { |
| 13560 |
mMatchIdPredicate = new MatchIdPredicate(); |
| 13561 |
} |
| 13562 |
mMatchIdPredicate.mId = id; |
| 13563 |
View result = root.findViewByPredicateInsideOut(start, mMatchIdPredicate); |
| 13564 |
if (result == null) { |
| 13565 |
Log.w(VIEW_LOG_TAG, "couldn't find view with id " + id); |
| 13566 |
} |
| 13567 |
return result; |
| 13568 |
} |
| 13569 |
|
| 13570 |
|
| 13571 |
|
| 13572 |
|
| 13573 |
|
| 13574 |
|
| 13575 |
|
| 13576 |
|
| 13577 |
public ArrayList<View> getFocusables(@FocusDirection int direction) { |
| 13578 |
ArrayList<View> result = new ArrayList<View>(24); |
| 13579 |
addFocusables(result, direction); |
| 13580 |
return result; |
| 13581 |
} |
| 13582 |
|
| 13583 |
|
| 13584 |
|
| 13585 |
|
| 13586 |
|
| 13587 |
|
| 13588 |
|
| 13589 |
|
| 13590 |
|
| 13591 |
public void addFocusables(ArrayList<View> views, @FocusDirection int direction) { |
| 13592 |
addFocusables(views, direction, isInTouchMode() ? FOCUSABLES_TOUCH_MODE : FOCUSABLES_ALL); |
| 13593 |
} |
| 13594 |
|
| 13595 |
|
| 13596 |
|
| 13597 |
|
| 13598 |
|
| 13599 |
|
| 13600 |
|
| 13601 |
|
| 13602 |
|
| 13603 |
|
| 13604 |
|
| 13605 |
|
| 13606 |
|
| 13607 |
|
| 13608 |
|
| 13609 |
|
| 13610 |
|
| 13611 |
public void addFocusables(ArrayList<View> views, @FocusDirection int direction, |
| 13612 |
@FocusableMode int focusableMode) { |
| 13613 |
if (views == null) { |
| 13614 |
return; |
| 13615 |
} |
| 13616 |
if (!canTakeFocus()) { |
| 13617 |
return; |
| 13618 |
} |
| 13619 |
if ((focusableMode & FOCUSABLES_TOUCH_MODE) == FOCUSABLES_TOUCH_MODE |
| 13620 |
&& !isFocusableInTouchMode()) { |
| 13621 |
return; |
| 13622 |
} |
| 13623 |
views.add(this); |
| 13624 |
} |
| 13625 |
|
| 13626 |
|
| 13627 |
|
| 13628 |
|
| 13629 |
|
| 13630 |
|
| 13631 |
|
| 13632 |
|
| 13633 |
public void addKeyboardNavigationClusters( |
| 13634 |
@NonNull Collection<View> views, |
| 13635 |
int direction) { |
| 13636 |
if (!isKeyboardNavigationCluster()) { |
| 13637 |
return; |
| 13638 |
} |
| 13639 |
if (!hasFocusable()) { |
| 13640 |
return; |
| 13641 |
} |
| 13642 |
views.add(this); |
| 13643 |
} |
| 13644 |
|
| 13645 |
|
| 13646 |
|
| 13647 |
|
| 13648 |
|
| 13649 |
|
| 13650 |
|
| 13651 |
|
| 13652 |
|
| 13653 |
|
| 13654 |
|
| 13655 |
|
| 13656 |
|
| 13657 |
|
| 13658 |
|
| 13659 |
|
| 13660 |
public void findViewsWithText(ArrayList<View> outViews, CharSequence searched, |
| 13661 |
@FindViewFlags int flags) { |
| 13662 |
if (getAccessibilityNodeProvider() != null) { |
| 13663 |
if ((flags & FIND_VIEWS_WITH_ACCESSIBILITY_NODE_PROVIDERS) != 0) { |
| 13664 |
outViews.add(this); |
| 13665 |
} |
| 13666 |
} else if ((flags & FIND_VIEWS_WITH_CONTENT_DESCRIPTION) != 0 |
| 13667 |
&& (searched != null && searched.length() > 0) |
| 13668 |
&& (mContentDescription != null && mContentDescription.length() > 0)) { |
| 13669 |
String searchedLowerCase = searched.toString().toLowerCase(); |
| 13670 |
String contentDescriptionLowerCase = mContentDescription.toString().toLowerCase(); |
| 13671 |
if (contentDescriptionLowerCase.contains(searchedLowerCase)) { |
| 13672 |
outViews.add(this); |
| 13673 |
} |
| 13674 |
} |
| 13675 |
} |
| 13676 |
|
| 13677 |
|
| 13678 |
|
| 13679 |
|
| 13680 |
|
| 13681 |
|
| 13682 |
|
| 13683 |
public ArrayList<View> getTouchables() { |
| 13684 |
ArrayList<View> result = new ArrayList<View>(); |
| 13685 |
addTouchables(result); |
| 13686 |
return result; |
| 13687 |
} |
| 13688 |
|
| 13689 |
|
| 13690 |
|
| 13691 |
|
| 13692 |
|
| 13693 |
|
| 13694 |
|
| 13695 |
public void addTouchables(ArrayList<View> views) { |
| 13696 |
final int viewFlags = mViewFlags; |
| 13697 |
|
| 13698 |
if (((viewFlags & CLICKABLE) == CLICKABLE || (viewFlags & LONG_CLICKABLE) == LONG_CLICKABLE |
| 13699 |
|| (viewFlags & CONTEXT_CLICKABLE) == CONTEXT_CLICKABLE) |
| 13700 |
&& (viewFlags & ENABLED_MASK) == ENABLED) { |
| 13701 |
views.add(this); |
| 13702 |
} |
| 13703 |
} |
| 13704 |
|
| 13705 |
|
| 13706 |
|
| 13707 |
|
| 13708 |
|
| 13709 |
|
| 13710 |
@InspectableProperty(hasAttributeId = false) |
| 13711 |
public boolean isAccessibilityFocused() { |
| 13712 |
return (mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) != 0; |
| 13713 |
} |
| 13714 |
|
| 13715 |
|
| 13716 |
|
| 13717 |
|
| 13718 |
|
| 13719 |
|
| 13720 |
|
| 13721 |
|
| 13722 |
|
| 13723 |
|
| 13724 |
|
| 13725 |
|
| 13726 |
|
| 13727 |
|
| 13728 |
|
| 13729 |
@UnsupportedAppUsage |
| 13730 |
public boolean requestAccessibilityFocus() { |
| 13731 |
AccessibilityManager manager = AccessibilityManager.getInstance(mContext); |
| 13732 |
if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) { |
| 13733 |
return false; |
| 13734 |
} |
| 13735 |
if ((mViewFlags & VISIBILITY_MASK) != VISIBLE) { |
| 13736 |
return false; |
| 13737 |
} |
| 13738 |
if ((mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) == 0) { |
| 13739 |
mPrivateFlags2 |= PFLAG2_ACCESSIBILITY_FOCUSED; |
| 13740 |
ViewRootImpl viewRootImpl = getViewRootImpl(); |
| 13741 |
if (viewRootImpl != null) { |
| 13742 |
viewRootImpl.setAccessibilityFocus(this, null); |
| 13743 |
} |
| 13744 |
invalidate(); |
| 13745 |
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED); |
| 13746 |
return true; |
| 13747 |
} |
| 13748 |
return false; |
| 13749 |
} |
| 13750 |
|
| 13751 |
|
| 13752 |
|
| 13753 |
|
| 13754 |
|
| 13755 |
|
| 13756 |
|
| 13757 |
|
| 13758 |
|
| 13759 |
@UnsupportedAppUsage |
| 13760 |
public void clearAccessibilityFocus() { |
| 13761 |
clearAccessibilityFocusNoCallbacks(0); |
| 13762 |
|
| 13763 |
|
| 13764 |
|
| 13765 |
|
| 13766 |
|
| 13767 |
final ViewRootImpl viewRootImpl = getViewRootImpl(); |
| 13768 |
if (viewRootImpl != null) { |
| 13769 |
final View focusHost = viewRootImpl.getAccessibilityFocusedHost(); |
| 13770 |
if (focusHost != null && ViewRootImpl.isViewDescendantOf(focusHost, this)) { |
| 13771 |
viewRootImpl.setAccessibilityFocus(null, null); |
| 13772 |
} |
| 13773 |
} |
| 13774 |
} |
| 13775 |
|
| 13776 |
private void sendAccessibilityHoverEvent(int eventType) { |
| 13777 |
|
| 13778 |
|
| 13779 |
|
| 13780 |
|
| 13781 |
|
| 13782 |
|
| 13783 |
|
| 13784 |
|
| 13785 |
|
| 13786 |
View source = this; |
| 13787 |
while (true) { |
| 13788 |
if (source.includeForAccessibility()) { |
| 13789 |
source.sendAccessibilityEvent(eventType); |
| 13790 |
return; |
| 13791 |
} |
| 13792 |
ViewParent parent = source.getParent(); |
| 13793 |
if (parent instanceof View) { |
| 13794 |
source = (View) parent; |
| 13795 |
} else { |
| 13796 |
return; |
| 13797 |
} |
| 13798 |
} |
| 13799 |
} |
| 13800 |
|
| 13801 |
|
| 13802 |
|
| 13803 |
|
| 13804 |
|
| 13805 |
|
| 13806 |
|
| 13807 |
|
| 13808 |
|
| 13809 |
|
| 13810 |
|
| 13811 |
void clearAccessibilityFocusNoCallbacks(int action) { |
| 13812 |
if ((mPrivateFlags2 & PFLAG2_ACCESSIBILITY_FOCUSED) != 0) { |
| 13813 |
mPrivateFlags2 &= ~PFLAG2_ACCESSIBILITY_FOCUSED; |
| 13814 |
invalidate(); |
| 13815 |
if (AccessibilityManager.getInstance(mContext).isEnabled()) { |
| 13816 |
AccessibilityEvent event = AccessibilityEvent.obtain( |
| 13817 |
AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED); |
| 13818 |
event.setAction(action); |
| 13819 |
if (mAccessibilityDelegate != null) { |
| 13820 |
mAccessibilityDelegate.sendAccessibilityEventUnchecked(this, event); |
| 13821 |
} else { |
| 13822 |
sendAccessibilityEventUnchecked(event); |
| 13823 |
} |
| 13824 |
} |
| 13825 |
|
| 13826 |
updatePreferKeepClearForFocus(); |
| 13827 |
} |
| 13828 |
} |
| 13829 |
|
| 13830 |
|
| 13831 |
|
| 13832 |
|
| 13833 |
|
| 13834 |
|
| 13835 |
|
| 13836 |
|
| 13837 |
|
| 13838 |
|
| 13839 |
|
| 13840 |
|
| 13841 |
|
| 13842 |
|
| 13843 |
|
| 13844 |
|
| 13845 |
|
| 13846 |
|
| 13847 |
public final boolean requestFocus() { |
| 13848 |
return requestFocus(View.FOCUS_DOWN); |
| 13849 |
} |
| 13850 |
|
| 13851 |
|
| 13852 |
|
| 13853 |
|
| 13854 |
|
| 13855 |
|
| 13856 |
|
| 13857 |
@TestApi |
| 13858 |
public boolean restoreFocusInCluster(@FocusRealDirection int direction) { |
| 13859 |
|
| 13860 |
if (restoreDefaultFocus()) { |
| 13861 |
return true; |
| 13862 |
} |
| 13863 |
return requestFocus(direction); |
| 13864 |
} |
| 13865 |
|
| 13866 |
|
| 13867 |
|
| 13868 |
|
| 13869 |
|
| 13870 |
|
| 13871 |
|
| 13872 |
|
| 13873 |
@TestApi |
| 13874 |
public boolean restoreFocusNotInCluster() { |
| 13875 |
return requestFocus(View.FOCUS_DOWN); |
| 13876 |
} |
| 13877 |
|
| 13878 |
|
| 13879 |
|
| 13880 |
|
| 13881 |
|
| 13882 |
|
| 13883 |
|
| 13884 |
public boolean restoreDefaultFocus() { |
| 13885 |
return requestFocus(View.FOCUS_DOWN); |
| 13886 |
} |
| 13887 |
|
| 13888 |
|
| 13889 |
|
| 13890 |
|
| 13891 |
|
| 13892 |
|
| 13893 |
|
| 13894 |
|
| 13895 |
|
| 13896 |
|
| 13897 |
|
| 13898 |
|
| 13899 |
|
| 13900 |
|
| 13901 |
|
| 13902 |
|
| 13903 |
|
| 13904 |
|
| 13905 |
public final boolean requestFocus(int direction) { |
| 13906 |
return requestFocus(direction, null); |
| 13907 |
} |
| 13908 |
|
| 13909 |
|
| 13910 |
|
| 13911 |
|
| 13912 |
|
| 13913 |
|
| 13914 |
|
| 13915 |
|
| 13916 |
|
| 13917 |
|
| 13918 |
|
| 13919 |
|
| 13920 |
|
| 13921 |
|
| 13922 |
|
| 13923 |
|
| 13924 |
|
| 13925 |
|
| 13926 |
|
| 13927 |
|
| 13928 |
|
| 13929 |
|
| 13930 |
|
| 13931 |
|
| 13932 |
|
| 13933 |
|
| 13934 |
|
| 13935 |
|
| 13936 |
|
| 13937 |
|
| 13938 |
public boolean requestFocus(int direction, Rect previouslyFocusedRect) { |
| 13939 |
return requestFocusNoSearch(direction, previouslyFocusedRect); |
| 13940 |
} |
| 13941 |
|
| 13942 |
private boolean requestFocusNoSearch(int direction, Rect previouslyFocusedRect) { |
| 13943 |
|
| 13944 |
if (!canTakeFocus()) { |
| 13945 |
return false; |
| 13946 |
} |
| 13947 |
|
| 13948 |
|
| 13949 |
if (isInTouchMode() && |
| 13950 |
(FOCUSABLE_IN_TOUCH_MODE != (mViewFlags & FOCUSABLE_IN_TOUCH_MODE))) { |
| 13951 |
return false; |
| 13952 |
} |
| 13953 |
|
| 13954 |
|
| 13955 |
if (hasAncestorThatBlocksDescendantFocus()) { |
| 13956 |
return false; |
| 13957 |
} |
| 13958 |
|
| 13959 |
if (!isLayoutValid()) { |
| 13960 |
mPrivateFlags |= PFLAG_WANTS_FOCUS; |
| 13961 |
} else { |
| 13962 |
clearParentsWantFocus(); |
| 13963 |
} |
| 13964 |
|
| 13965 |
handleFocusGainInternal(direction, previouslyFocusedRect); |
| 13966 |
return true; |
| 13967 |
} |
| 13968 |
|
| 13969 |
void clearParentsWantFocus() { |
| 13970 |
if (mParent instanceof View) { |
| 13971 |
((View) mParent).mPrivateFlags &= ~PFLAG_WANTS_FOCUS; |
| 13972 |
((View) mParent).clearParentsWantFocus(); |
| 13973 |
} |
| 13974 |
} |
| 13975 |
|
| 13976 |
|
| 13977 |
|
| 13978 |
|
| 13979 |
|
| 13980 |
|
| 13981 |
|
| 13982 |
|
| 13983 |
|
| 13984 |
|
| 13985 |
|
| 13986 |
public final boolean requestFocusFromTouch() { |
| 13987 |
|
| 13988 |
if (isInTouchMode()) { |
| 13989 |
ViewRootImpl viewRoot = getViewRootImpl(); |
| 13990 |
if (viewRoot != null) { |
| 13991 |
viewRoot.ensureTouchMode(false); |
| 13992 |
} |
| 13993 |
} |
| 13994 |
return requestFocus(View.FOCUS_DOWN); |
| 13995 |
} |
| 13996 |
|
| 13997 |
|
| 13998 |
|
| 13999 |
|
| 14000 |
private boolean hasAncestorThatBlocksDescendantFocus() { |
| 14001 |
final boolean focusableInTouchMode = isFocusableInTouchMode(); |
| 14002 |
ViewParent ancestor = mParent; |
| 14003 |
while (ancestor instanceof ViewGroup) { |
| 14004 |
final ViewGroup vgAncestor = (ViewGroup) ancestor; |
| 14005 |
if (vgAncestor.getDescendantFocusability() == ViewGroup.FOCUS_BLOCK_DESCENDANTS |
| 14006 |
|| (!focusableInTouchMode && vgAncestor.shouldBlockFocusForTouchscreen())) { |
| 14007 |
return true; |
| 14008 |
} else { |
| 14009 |
ancestor = vgAncestor.getParent(); |
| 14010 |
} |
| 14011 |
} |
| 14012 |
return false; |
| 14013 |
} |
| 14014 |
|
| 14015 |
|
| 14016 |
|
| 14017 |
|
| 14018 |
|
| 14019 |
|
| 14020 |
|
| 14021 |
|
| 14022 |
|
| 14023 |
|
| 14024 |
|
| 14025 |
|
| 14026 |
|
| 14027 |
|
| 14028 |
|
| 14029 |
|
| 14030 |
|
| 14031 |
|
| 14032 |
@ViewDebug.ExportedProperty(category = "accessibility", mapping = { |
| 14033 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_AUTO, to = "auto"), |
| 14034 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_YES, to = "yes"), |
| 14035 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO, to = "no"), |
| 14036 |
@ViewDebug.IntToString(from = IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, |
| 14037 |
to = "noHideDescendants") |
| 14038 |
}) |
| 14039 |
@InspectableProperty(enumMapping = { |
| 14040 |
@EnumEntry(value = IMPORTANT_FOR_ACCESSIBILITY_AUTO, name = "auto"), |
| 14041 |
@EnumEntry(value = IMPORTANT_FOR_ACCESSIBILITY_YES, name = "yes"), |
| 14042 |
@EnumEntry(value = IMPORTANT_FOR_ACCESSIBILITY_NO, name = "no"), |
| 14043 |
@EnumEntry(value = IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS, |
| 14044 |
name = "noHideDescendants"), |
| 14045 |
}) |
| 14046 |
public int getImportantForAccessibility() { |
| 14047 |
return (mPrivateFlags2 & PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK) |
| 14048 |
>> PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT; |
| 14049 |
} |
| 14050 |
|
| 14051 |
|
| 14052 |
|
| 14053 |
|
| 14054 |
|
| 14055 |
|
| 14056 |
|
| 14057 |
|
| 14058 |
|
| 14059 |
|
| 14060 |
|
| 14061 |
|
| 14062 |
|
| 14063 |
|
| 14064 |
|
| 14065 |
|
| 14066 |
|
| 14067 |
|
| 14068 |
|
| 14069 |
|
| 14070 |
|
| 14071 |
|
| 14072 |
|
| 14073 |
|
| 14074 |
|
| 14075 |
|
| 14076 |
|
| 14077 |
|
| 14078 |
|
| 14079 |
public void setAccessibilityLiveRegion(int mode) { |
| 14080 |
if (mode != getAccessibilityLiveRegion()) { |
| 14081 |
mPrivateFlags2 &= ~PFLAG2_ACCESSIBILITY_LIVE_REGION_MASK; |
| 14082 |
mPrivateFlags2 |= (mode << PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT) |
| 14083 |
& PFLAG2_ACCESSIBILITY_LIVE_REGION_MASK; |
| 14084 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 14085 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 14086 |
} |
| 14087 |
} |
| 14088 |
|
| 14089 |
|
| 14090 |
|
| 14091 |
|
| 14092 |
|
| 14093 |
|
| 14094 |
|
| 14095 |
|
| 14096 |
|
| 14097 |
|
| 14098 |
@InspectableProperty(enumMapping = { |
| 14099 |
@EnumEntry(value = ACCESSIBILITY_LIVE_REGION_NONE, name = "none"), |
| 14100 |
@EnumEntry(value = ACCESSIBILITY_LIVE_REGION_POLITE, name = "polite"), |
| 14101 |
@EnumEntry(value = ACCESSIBILITY_LIVE_REGION_ASSERTIVE, name = "assertive") |
| 14102 |
}) |
| 14103 |
public int getAccessibilityLiveRegion() { |
| 14104 |
return (mPrivateFlags2 & PFLAG2_ACCESSIBILITY_LIVE_REGION_MASK) |
| 14105 |
>> PFLAG2_ACCESSIBILITY_LIVE_REGION_SHIFT; |
| 14106 |
} |
| 14107 |
|
| 14108 |
|
| 14109 |
|
| 14110 |
|
| 14111 |
|
| 14112 |
|
| 14113 |
|
| 14114 |
|
| 14115 |
|
| 14116 |
|
| 14117 |
|
| 14118 |
|
| 14119 |
|
| 14120 |
|
| 14121 |
|
| 14122 |
public void setImportantForAccessibility(int mode) { |
| 14123 |
final int oldMode = getImportantForAccessibility(); |
| 14124 |
if (mode != oldMode) { |
| 14125 |
final boolean hideDescendants = |
| 14126 |
mode == IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS; |
| 14127 |
|
| 14128 |
|
| 14129 |
|
| 14130 |
if (mode == IMPORTANT_FOR_ACCESSIBILITY_NO || hideDescendants) { |
| 14131 |
final View focusHost = findAccessibilityFocusHost(hideDescendants); |
| 14132 |
if (focusHost != null) { |
| 14133 |
focusHost.clearAccessibilityFocus(); |
| 14134 |
} |
| 14135 |
} |
| 14136 |
|
| 14137 |
|
| 14138 |
|
| 14139 |
|
| 14140 |
final boolean maySkipNotify = oldMode == IMPORTANT_FOR_ACCESSIBILITY_AUTO |
| 14141 |
|| mode == IMPORTANT_FOR_ACCESSIBILITY_AUTO; |
| 14142 |
final boolean oldIncludeForAccessibility = maySkipNotify && includeForAccessibility(); |
| 14143 |
mPrivateFlags2 &= ~PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK; |
| 14144 |
mPrivateFlags2 |= (mode << PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_SHIFT) |
| 14145 |
& PFLAG2_IMPORTANT_FOR_ACCESSIBILITY_MASK; |
| 14146 |
if (!maySkipNotify || oldIncludeForAccessibility != includeForAccessibility()) { |
| 14147 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 14148 |
} else { |
| 14149 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 14150 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 14151 |
} |
| 14152 |
} |
| 14153 |
} |
| 14154 |
|
| 14155 |
|
| 14156 |
|
| 14157 |
|
| 14158 |
|
| 14159 |
|
| 14160 |
|
| 14161 |
|
| 14162 |
private View findAccessibilityFocusHost(boolean searchDescendants) { |
| 14163 |
if (isAccessibilityFocusedViewOrHost()) { |
| 14164 |
return this; |
| 14165 |
} |
| 14166 |
|
| 14167 |
if (searchDescendants) { |
| 14168 |
final ViewRootImpl viewRoot = getViewRootImpl(); |
| 14169 |
if (viewRoot != null) { |
| 14170 |
final View focusHost = viewRoot.getAccessibilityFocusedHost(); |
| 14171 |
if (focusHost != null && ViewRootImpl.isViewDescendantOf(focusHost, this)) { |
| 14172 |
return focusHost; |
| 14173 |
} |
| 14174 |
} |
| 14175 |
} |
| 14176 |
|
| 14177 |
return null; |
| 14178 |
} |
| 14179 |
|
| 14180 |
|
| 14181 |
|
| 14182 |
|
| 14183 |
|
| 14184 |
|
| 14185 |
|
| 14186 |
|
| 14187 |
|
| 14188 |
|
| 14189 |
|
| 14190 |
|
| 14191 |
|
| 14192 |
|
| 14193 |
|
| 14194 |
|
| 14195 |
|
| 14196 |
|
| 14197 |
|
| 14198 |
|
| 14199 |
|
| 14200 |
|
| 14201 |
|
| 14202 |
|
| 14203 |
|
| 14204 |
|
| 14205 |
|
| 14206 |
|
| 14207 |
|
| 14208 |
|
| 14209 |
|
| 14210 |
|
| 14211 |
|
| 14212 |
|
| 14213 |
|
| 14214 |
|
| 14215 |
public boolean isImportantForAccessibility() { |
| 14216 |
final int mode = getImportantForAccessibility(); |
| 14217 |
if (mode == IMPORTANT_FOR_ACCESSIBILITY_NO |
| 14218 |
|| mode == IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) { |
| 14219 |
return false; |
| 14220 |
} |
| 14221 |
|
| 14222 |
|
| 14223 |
ViewParent parent = mParent; |
| 14224 |
while (parent instanceof View) { |
| 14225 |
if (((View) parent).getImportantForAccessibility() |
| 14226 |
== IMPORTANT_FOR_ACCESSIBILITY_NO_HIDE_DESCENDANTS) { |
| 14227 |
return false; |
| 14228 |
} |
| 14229 |
parent = parent.getParent(); |
| 14230 |
} |
| 14231 |
|
| 14232 |
return mode == IMPORTANT_FOR_ACCESSIBILITY_YES || isActionableForAccessibility() |
| 14233 |
|| hasListenersForAccessibility() || getAccessibilityNodeProvider() != null |
| 14234 |
|| getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE |
| 14235 |
|| isAccessibilityPane(); |
| 14236 |
} |
| 14237 |
|
| 14238 |
|
| 14239 |
|
| 14240 |
|
| 14241 |
|
| 14242 |
|
| 14243 |
|
| 14244 |
|
| 14245 |
public ViewParent getParentForAccessibility() { |
| 14246 |
if (mParent instanceof View) { |
| 14247 |
View parentView = (View) mParent; |
| 14248 |
if (parentView.includeForAccessibility()) { |
| 14249 |
return mParent; |
| 14250 |
} else { |
| 14251 |
return mParent.getParentForAccessibility(); |
| 14252 |
} |
| 14253 |
} |
| 14254 |
return null; |
| 14255 |
} |
| 14256 |
|
| 14257 |
|
| 14258 |
View getSelfOrParentImportantForA11y() { |
| 14259 |
if (isImportantForAccessibility()) return this; |
| 14260 |
ViewParent parent = getParentForAccessibility(); |
| 14261 |
if (parent instanceof View) return (View) parent; |
| 14262 |
return null; |
| 14263 |
} |
| 14264 |
|
| 14265 |
|
| 14266 |
|
| 14267 |
|
| 14268 |
|
| 14269 |
|
| 14270 |
|
| 14271 |
|
| 14272 |
|
| 14273 |
public void addChildrenForAccessibility(ArrayList<View> outChildren) { |
| 14274 |
|
| 14275 |
} |
| 14276 |
|
| 14277 |
|
| 14278 |
|
| 14279 |
|
| 14280 |
|
| 14281 |
|
| 14282 |
|
| 14283 |
|
| 14284 |
|
| 14285 |
|
| 14286 |
|
| 14287 |
@UnsupportedAppUsage |
| 14288 |
public boolean includeForAccessibility() { |
| 14289 |
if (mAttachInfo != null) { |
| 14290 |
return (mAttachInfo.mAccessibilityFetchFlags |
| 14291 |
& AccessibilityNodeInfo.FLAG_INCLUDE_NOT_IMPORTANT_VIEWS) != 0 |
| 14292 |
|| isImportantForAccessibility(); |
| 14293 |
} |
| 14294 |
return false; |
| 14295 |
} |
| 14296 |
|
| 14297 |
|
| 14298 |
|
| 14299 |
|
| 14300 |
|
| 14301 |
|
| 14302 |
|
| 14303 |
|
| 14304 |
|
| 14305 |
|
| 14306 |
public boolean isActionableForAccessibility() { |
| 14307 |
return (isClickable() || isLongClickable() || isFocusable()); |
| 14308 |
} |
| 14309 |
|
| 14310 |
|
| 14311 |
|
| 14312 |
|
| 14313 |
|
| 14314 |
|
| 14315 |
|
| 14316 |
private boolean hasListenersForAccessibility() { |
| 14317 |
ListenerInfo info = getListenerInfo(); |
| 14318 |
return mTouchDelegate != null || info.mOnKeyListener != null |
| 14319 |
|| info.mOnTouchListener != null || info.mOnGenericMotionListener != null |
| 14320 |
|| info.mOnHoverListener != null || info.mOnDragListener != null; |
| 14321 |
} |
| 14322 |
|
| 14323 |
|
| 14324 |
|
| 14325 |
|
| 14326 |
|
| 14327 |
|
| 14328 |
|
| 14329 |
|
| 14330 |
|
| 14331 |
|
| 14332 |
|
| 14333 |
|
| 14334 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 14335 |
public void notifyViewAccessibilityStateChangedIfNeeded(int changeType) { |
| 14336 |
if (!AccessibilityManager.getInstance(mContext).isEnabled() || mAttachInfo == null) { |
| 14337 |
return; |
| 14338 |
} |
| 14339 |
|
| 14340 |
|
| 14341 |
|
| 14342 |
|
| 14343 |
if ((changeType != AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE) |
| 14344 |
&& (isAccessibilityPane() |
| 14345 |
|| (changeType == AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED) |
| 14346 |
&& isAggregatedVisible())) { |
| 14347 |
|
| 14348 |
|
| 14349 |
if ((isAggregatedVisible()) |
| 14350 |
|| (changeType == AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED)) { |
| 14351 |
final AccessibilityEvent event = AccessibilityEvent.obtain(); |
| 14352 |
onInitializeAccessibilityEvent(event); |
| 14353 |
event.setEventType(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED); |
| 14354 |
event.setContentChangeTypes(changeType); |
| 14355 |
event.setSource(this); |
| 14356 |
onPopulateAccessibilityEvent(event); |
| 14357 |
if (mParent != null) { |
| 14358 |
try { |
| 14359 |
mParent.requestSendAccessibilityEvent(this, event); |
| 14360 |
} catch (AbstractMethodError e) { |
| 14361 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() |
| 14362 |
+ " does not fully implement ViewParent", e); |
| 14363 |
} |
| 14364 |
} |
| 14365 |
return; |
| 14366 |
} |
| 14367 |
} |
| 14368 |
|
| 14369 |
|
| 14370 |
|
| 14371 |
if (getAccessibilityLiveRegion() != ACCESSIBILITY_LIVE_REGION_NONE) { |
| 14372 |
final AccessibilityEvent event = AccessibilityEvent.obtain(); |
| 14373 |
event.setEventType(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); |
| 14374 |
event.setContentChangeTypes(changeType); |
| 14375 |
sendAccessibilityEventUnchecked(event); |
| 14376 |
} else if (mParent != null) { |
| 14377 |
try { |
| 14378 |
mParent.notifySubtreeAccessibilityStateChanged(this, this, changeType); |
| 14379 |
} catch (AbstractMethodError e) { |
| 14380 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 14381 |
" does not fully implement ViewParent", e); |
| 14382 |
} |
| 14383 |
} |
| 14384 |
} |
| 14385 |
|
| 14386 |
|
| 14387 |
|
| 14388 |
|
| 14389 |
|
| 14390 |
|
| 14391 |
|
| 14392 |
|
| 14393 |
|
| 14394 |
|
| 14395 |
|
| 14396 |
|
| 14397 |
@UnsupportedAppUsage |
| 14398 |
public void notifySubtreeAccessibilityStateChangedIfNeeded() { |
| 14399 |
if (!AccessibilityManager.getInstance(mContext).isEnabled() || mAttachInfo == null) { |
| 14400 |
return; |
| 14401 |
} |
| 14402 |
|
| 14403 |
if ((mPrivateFlags2 & PFLAG2_SUBTREE_ACCESSIBILITY_STATE_CHANGED) == 0) { |
| 14404 |
mPrivateFlags2 |= PFLAG2_SUBTREE_ACCESSIBILITY_STATE_CHANGED; |
| 14405 |
if (mParent != null) { |
| 14406 |
try { |
| 14407 |
mParent.notifySubtreeAccessibilityStateChanged( |
| 14408 |
this, this, AccessibilityEvent.CONTENT_CHANGE_TYPE_SUBTREE); |
| 14409 |
} catch (AbstractMethodError e) { |
| 14410 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 14411 |
" does not fully implement ViewParent", e); |
| 14412 |
} |
| 14413 |
} |
| 14414 |
} |
| 14415 |
} |
| 14416 |
|
| 14417 |
private void notifySubtreeAccessibilityStateChangedByParentIfNeeded() { |
| 14418 |
if (!AccessibilityManager.getInstance(mContext).isEnabled()) { |
| 14419 |
return; |
| 14420 |
} |
| 14421 |
|
| 14422 |
final View sendA11yEventView = (View) getParentForAccessibility(); |
| 14423 |
if (sendA11yEventView != null && sendA11yEventView.isShown()) { |
| 14424 |
sendA11yEventView.notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 14425 |
} |
| 14426 |
} |
| 14427 |
|
| 14428 |
|
| 14429 |
|
| 14430 |
|
| 14431 |
|
| 14432 |
|
| 14433 |
|
| 14434 |
|
| 14435 |
|
| 14436 |
|
| 14437 |
|
| 14438 |
|
| 14439 |
|
| 14440 |
|
| 14441 |
public void setTransitionVisibility(@Visibility int visibility) { |
| 14442 |
mViewFlags = (mViewFlags & ~View.VISIBILITY_MASK) | visibility; |
| 14443 |
} |
| 14444 |
|
| 14445 |
|
| 14446 |
|
| 14447 |
|
| 14448 |
|
| 14449 |
void resetSubtreeAccessibilityStateChanged() { |
| 14450 |
mPrivateFlags2 &= ~PFLAG2_SUBTREE_ACCESSIBILITY_STATE_CHANGED; |
| 14451 |
} |
| 14452 |
|
| 14453 |
|
| 14454 |
|
| 14455 |
|
| 14456 |
|
| 14457 |
|
| 14458 |
|
| 14459 |
|
| 14460 |
|
| 14461 |
|
| 14462 |
|
| 14463 |
|
| 14464 |
|
| 14465 |
|
| 14466 |
|
| 14467 |
|
| 14468 |
|
| 14469 |
|
| 14470 |
|
| 14471 |
|
| 14472 |
public boolean dispatchNestedPrePerformAccessibilityAction(int action, |
| 14473 |
@Nullable Bundle arguments) { |
| 14474 |
for (ViewParent p = getParent(); p != null; p = p.getParent()) { |
| 14475 |
if (p.onNestedPrePerformAccessibilityAction(this, action, arguments)) { |
| 14476 |
return true; |
| 14477 |
} |
| 14478 |
} |
| 14479 |
return false; |
| 14480 |
} |
| 14481 |
|
| 14482 |
|
| 14483 |
|
| 14484 |
|
| 14485 |
|
| 14486 |
|
| 14487 |
|
| 14488 |
|
| 14489 |
|
| 14490 |
|
| 14491 |
|
| 14492 |
|
| 14493 |
|
| 14494 |
|
| 14495 |
|
| 14496 |
|
| 14497 |
|
| 14498 |
|
| 14499 |
|
| 14500 |
|
| 14501 |
public boolean performAccessibilityAction(int action, @Nullable Bundle arguments) { |
| 14502 |
if (mAccessibilityDelegate != null) { |
| 14503 |
return mAccessibilityDelegate.performAccessibilityAction(this, action, arguments); |
| 14504 |
} else { |
| 14505 |
return performAccessibilityActionInternal(action, arguments); |
| 14506 |
} |
| 14507 |
} |
| 14508 |
|
| 14509 |
|
| 14510 |
|
| 14511 |
|
| 14512 |
|
| 14513 |
|
| 14514 |
|
| 14515 |
|
| 14516 |
@UnsupportedAppUsage |
| 14517 |
public boolean performAccessibilityActionInternal(int action, @Nullable Bundle arguments) { |
| 14518 |
if (isNestedScrollingEnabled() |
| 14519 |
&& (action == AccessibilityNodeInfo.ACTION_SCROLL_BACKWARD |
| 14520 |
|| action == AccessibilityNodeInfo.ACTION_SCROLL_FORWARD |
| 14521 |
|| action == R.id.accessibilityActionScrollUp |
| 14522 |
|| action == R.id.accessibilityActionScrollLeft |
| 14523 |
|| action == R.id.accessibilityActionScrollDown |
| 14524 |
|| action == R.id.accessibilityActionScrollRight)) { |
| 14525 |
if (dispatchNestedPrePerformAccessibilityAction(action, arguments)) { |
| 14526 |
return true; |
| 14527 |
} |
| 14528 |
} |
| 14529 |
|
| 14530 |
switch (action) { |
| 14531 |
case AccessibilityNodeInfo.ACTION_CLICK: { |
| 14532 |
if (isClickable()) { |
| 14533 |
performClickInternal(); |
| 14534 |
return true; |
| 14535 |
} |
| 14536 |
} break; |
| 14537 |
case AccessibilityNodeInfo.ACTION_LONG_CLICK: { |
| 14538 |
if (isLongClickable()) { |
| 14539 |
performLongClick(); |
| 14540 |
return true; |
| 14541 |
} |
| 14542 |
} break; |
| 14543 |
case AccessibilityNodeInfo.ACTION_FOCUS: { |
| 14544 |
if (!hasFocus()) { |
| 14545 |
|
| 14546 |
|
| 14547 |
getViewRootImpl().ensureTouchMode(false); |
| 14548 |
return requestFocus(); |
| 14549 |
} |
| 14550 |
} break; |
| 14551 |
case AccessibilityNodeInfo.ACTION_CLEAR_FOCUS: { |
| 14552 |
if (hasFocus()) { |
| 14553 |
clearFocus(); |
| 14554 |
return !isFocused(); |
| 14555 |
} |
| 14556 |
} break; |
| 14557 |
case AccessibilityNodeInfo.ACTION_SELECT: { |
| 14558 |
if (!isSelected()) { |
| 14559 |
setSelected(true); |
| 14560 |
return isSelected(); |
| 14561 |
} |
| 14562 |
} break; |
| 14563 |
case AccessibilityNodeInfo.ACTION_CLEAR_SELECTION: { |
| 14564 |
if (isSelected()) { |
| 14565 |
setSelected(false); |
| 14566 |
return !isSelected(); |
| 14567 |
} |
| 14568 |
} break; |
| 14569 |
case AccessibilityNodeInfo.ACTION_ACCESSIBILITY_FOCUS: { |
| 14570 |
if (!isAccessibilityFocused()) { |
| 14571 |
return requestAccessibilityFocus(); |
| 14572 |
} |
| 14573 |
} break; |
| 14574 |
case AccessibilityNodeInfo.ACTION_CLEAR_ACCESSIBILITY_FOCUS: { |
| 14575 |
if (isAccessibilityFocused()) { |
| 14576 |
clearAccessibilityFocus(); |
| 14577 |
return true; |
| 14578 |
} |
| 14579 |
} break; |
| 14580 |
case AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY: { |
| 14581 |
if (arguments != null) { |
| 14582 |
final int granularity = arguments.getInt( |
| 14583 |
AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT); |
| 14584 |
final boolean extendSelection = arguments.getBoolean( |
| 14585 |
AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN); |
| 14586 |
return traverseAtGranularity(granularity, true, extendSelection); |
| 14587 |
} |
| 14588 |
} break; |
| 14589 |
case AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY: { |
| 14590 |
if (arguments != null) { |
| 14591 |
final int granularity = arguments.getInt( |
| 14592 |
AccessibilityNodeInfo.ACTION_ARGUMENT_MOVEMENT_GRANULARITY_INT); |
| 14593 |
final boolean extendSelection = arguments.getBoolean( |
| 14594 |
AccessibilityNodeInfo.ACTION_ARGUMENT_EXTEND_SELECTION_BOOLEAN); |
| 14595 |
return traverseAtGranularity(granularity, false, extendSelection); |
| 14596 |
} |
| 14597 |
} break; |
| 14598 |
case AccessibilityNodeInfo.ACTION_SET_SELECTION: { |
| 14599 |
CharSequence text = getIterableTextForAccessibility(); |
| 14600 |
if (text == null) { |
| 14601 |
return false; |
| 14602 |
} |
| 14603 |
final int start = (arguments != null) ? arguments.getInt( |
| 14604 |
AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_START_INT, -1) : -1; |
| 14605 |
final int end = (arguments != null) ? arguments.getInt( |
| 14606 |
AccessibilityNodeInfo.ACTION_ARGUMENT_SELECTION_END_INT, -1) : -1; |
| 14607 |
|
| 14608 |
if ((getAccessibilitySelectionStart() != start |
| 14609 |
|| getAccessibilitySelectionEnd() != end) |
| 14610 |
&& (start == end)) { |
| 14611 |
setAccessibilitySelection(start, end); |
| 14612 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 14613 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 14614 |
return true; |
| 14615 |
} |
| 14616 |
} break; |
| 14617 |
case R.id.accessibilityActionShowOnScreen: { |
| 14618 |
if (mAttachInfo != null) { |
| 14619 |
final Rect r = mAttachInfo.mTmpInvalRect; |
| 14620 |
getDrawingRect(r); |
| 14621 |
return requestRectangleOnScreen(r, true); |
| 14622 |
} |
| 14623 |
} break; |
| 14624 |
case R.id.accessibilityActionContextClick: { |
| 14625 |
if (isContextClickable()) { |
| 14626 |
performContextClick(); |
| 14627 |
return true; |
| 14628 |
} |
| 14629 |
} break; |
| 14630 |
case R.id.accessibilityActionShowTooltip: { |
| 14631 |
if ((mTooltipInfo != null) && (mTooltipInfo.mTooltipPopup != null)) { |
| 14632 |
|
| 14633 |
return false; |
| 14634 |
} |
| 14635 |
return showLongClickTooltip(0, 0); |
| 14636 |
} |
| 14637 |
case R.id.accessibilityActionHideTooltip: { |
| 14638 |
if ((mTooltipInfo == null) || (mTooltipInfo.mTooltipPopup == null)) { |
| 14639 |
|
| 14640 |
return false; |
| 14641 |
} |
| 14642 |
hideTooltip(); |
| 14643 |
return true; |
| 14644 |
} |
| 14645 |
case R.id.accessibilityActionDragDrop: { |
| 14646 |
if (!canAcceptAccessibilityDrop()) { |
| 14647 |
return false; |
| 14648 |
} |
| 14649 |
try { |
| 14650 |
if (mAttachInfo != null && mAttachInfo.mSession != null) { |
| 14651 |
final int[] location = new int[2]; |
| 14652 |
getLocationInWindow(location); |
| 14653 |
final int centerX = location[0] + getWidth() / 2; |
| 14654 |
final int centerY = location[1] + getHeight() / 2; |
| 14655 |
return mAttachInfo.mSession.dropForAccessibility(mAttachInfo.mWindow, |
| 14656 |
centerX, centerY); |
| 14657 |
} |
| 14658 |
} catch (RemoteException e) { |
| 14659 |
Log.e(VIEW_LOG_TAG, "Unable to drop for accessibility", e); |
| 14660 |
} |
| 14661 |
return false; |
| 14662 |
} |
| 14663 |
case R.id.accessibilityActionDragCancel: { |
| 14664 |
if (!startedSystemDragForAccessibility()) { |
| 14665 |
return false; |
| 14666 |
} |
| 14667 |
if (mAttachInfo != null && mAttachInfo.mDragToken != null) { |
| 14668 |
cancelDragAndDrop(); |
| 14669 |
return true; |
| 14670 |
} |
| 14671 |
return false; |
| 14672 |
} |
| 14673 |
} |
| 14674 |
return false; |
| 14675 |
} |
| 14676 |
|
| 14677 |
private boolean canAcceptAccessibilityDrop() { |
| 14678 |
if (!canAcceptDrag()) { |
| 14679 |
return false; |
| 14680 |
} |
| 14681 |
ListenerInfo li = mListenerInfo; |
| 14682 |
return (li != null) && (li.mOnDragListener != null || li.mOnReceiveContentListener != null); |
| 14683 |
} |
| 14684 |
|
| 14685 |
private boolean traverseAtGranularity(int granularity, boolean forward, |
| 14686 |
boolean extendSelection) { |
| 14687 |
CharSequence text = getIterableTextForAccessibility(); |
| 14688 |
if (text == null || text.length() == 0) { |
| 14689 |
return false; |
| 14690 |
} |
| 14691 |
TextSegmentIterator iterator = getIteratorForGranularity(granularity); |
| 14692 |
if (iterator == null) { |
| 14693 |
return false; |
| 14694 |
} |
| 14695 |
int current = getAccessibilitySelectionEnd(); |
| 14696 |
if (current == ACCESSIBILITY_CURSOR_POSITION_UNDEFINED) { |
| 14697 |
current = forward ? 0 : text.length(); |
| 14698 |
} |
| 14699 |
final int[] range = forward ? iterator.following(current) : iterator.preceding(current); |
| 14700 |
if (range == null) { |
| 14701 |
return false; |
| 14702 |
} |
| 14703 |
final int segmentStart = range[0]; |
| 14704 |
final int segmentEnd = range[1]; |
| 14705 |
int selectionStart; |
| 14706 |
int selectionEnd; |
| 14707 |
if (extendSelection && isAccessibilitySelectionExtendable()) { |
| 14708 |
prepareForExtendedAccessibilitySelection(); |
| 14709 |
selectionStart = getAccessibilitySelectionStart(); |
| 14710 |
if (selectionStart == ACCESSIBILITY_CURSOR_POSITION_UNDEFINED) { |
| 14711 |
selectionStart = forward ? segmentStart : segmentEnd; |
| 14712 |
} |
| 14713 |
selectionEnd = forward ? segmentEnd : segmentStart; |
| 14714 |
} else { |
| 14715 |
selectionStart = selectionEnd= forward ? segmentEnd : segmentStart; |
| 14716 |
} |
| 14717 |
setAccessibilitySelection(selectionStart, selectionEnd); |
| 14718 |
final int action = forward ? AccessibilityNodeInfo.ACTION_NEXT_AT_MOVEMENT_GRANULARITY |
| 14719 |
: AccessibilityNodeInfo.ACTION_PREVIOUS_AT_MOVEMENT_GRANULARITY; |
| 14720 |
sendViewTextTraversedAtGranularityEvent(action, granularity, segmentStart, segmentEnd); |
| 14721 |
return true; |
| 14722 |
} |
| 14723 |
|
| 14724 |
|
| 14725 |
|
| 14726 |
|
| 14727 |
|
| 14728 |
|
| 14729 |
|
| 14730 |
|
| 14731 |
@UnsupportedAppUsage |
| 14732 |
public CharSequence getIterableTextForAccessibility() { |
| 14733 |
return getContentDescription(); |
| 14734 |
} |
| 14735 |
|
| 14736 |
|
| 14737 |
|
| 14738 |
|
| 14739 |
|
| 14740 |
|
| 14741 |
|
| 14742 |
|
| 14743 |
public boolean isAccessibilitySelectionExtendable() { |
| 14744 |
return false; |
| 14745 |
} |
| 14746 |
|
| 14747 |
|
| 14748 |
|
| 14749 |
|
| 14750 |
|
| 14751 |
public void prepareForExtendedAccessibilitySelection() { |
| 14752 |
return; |
| 14753 |
} |
| 14754 |
|
| 14755 |
|
| 14756 |
|
| 14757 |
|
| 14758 |
public int getAccessibilitySelectionStart() { |
| 14759 |
return mAccessibilityCursorPosition; |
| 14760 |
} |
| 14761 |
|
| 14762 |
|
| 14763 |
|
| 14764 |
|
| 14765 |
public int getAccessibilitySelectionEnd() { |
| 14766 |
return getAccessibilitySelectionStart(); |
| 14767 |
} |
| 14768 |
|
| 14769 |
|
| 14770 |
|
| 14771 |
|
| 14772 |
public void setAccessibilitySelection(int start, int end) { |
| 14773 |
if (start == end && end == mAccessibilityCursorPosition) { |
| 14774 |
return; |
| 14775 |
} |
| 14776 |
if (start >= 0 && start == end && end <= getIterableTextForAccessibility().length()) { |
| 14777 |
mAccessibilityCursorPosition = start; |
| 14778 |
} else { |
| 14779 |
mAccessibilityCursorPosition = ACCESSIBILITY_CURSOR_POSITION_UNDEFINED; |
| 14780 |
} |
| 14781 |
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_TEXT_SELECTION_CHANGED); |
| 14782 |
} |
| 14783 |
|
| 14784 |
private void sendViewTextTraversedAtGranularityEvent(int action, int granularity, |
| 14785 |
int fromIndex, int toIndex) { |
| 14786 |
if (mParent == null) { |
| 14787 |
return; |
| 14788 |
} |
| 14789 |
AccessibilityEvent event = AccessibilityEvent.obtain( |
| 14790 |
AccessibilityEvent.TYPE_VIEW_TEXT_TRAVERSED_AT_MOVEMENT_GRANULARITY); |
| 14791 |
onInitializeAccessibilityEvent(event); |
| 14792 |
onPopulateAccessibilityEvent(event); |
| 14793 |
event.setFromIndex(fromIndex); |
| 14794 |
event.setToIndex(toIndex); |
| 14795 |
event.setAction(action); |
| 14796 |
event.setMovementGranularity(granularity); |
| 14797 |
mParent.requestSendAccessibilityEvent(this, event); |
| 14798 |
} |
| 14799 |
|
| 14800 |
|
| 14801 |
|
| 14802 |
|
| 14803 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 14804 |
public TextSegmentIterator getIteratorForGranularity(int granularity) { |
| 14805 |
switch (granularity) { |
| 14806 |
case AccessibilityNodeInfo.MOVEMENT_GRANULARITY_CHARACTER: { |
| 14807 |
CharSequence text = getIterableTextForAccessibility(); |
| 14808 |
if (text != null && text.length() > 0) { |
| 14809 |
CharacterTextSegmentIterator iterator = |
| 14810 |
CharacterTextSegmentIterator.getInstance( |
| 14811 |
mContext.getResources().getConfiguration().locale); |
| 14812 |
iterator.initialize(text.toString()); |
| 14813 |
return iterator; |
| 14814 |
} |
| 14815 |
} break; |
| 14816 |
case AccessibilityNodeInfo.MOVEMENT_GRANULARITY_WORD: { |
| 14817 |
CharSequence text = getIterableTextForAccessibility(); |
| 14818 |
if (text != null && text.length() > 0) { |
| 14819 |
WordTextSegmentIterator iterator = |
| 14820 |
WordTextSegmentIterator.getInstance( |
| 14821 |
mContext.getResources().getConfiguration().locale); |
| 14822 |
iterator.initialize(text.toString()); |
| 14823 |
return iterator; |
| 14824 |
} |
| 14825 |
} break; |
| 14826 |
case AccessibilityNodeInfo.MOVEMENT_GRANULARITY_PARAGRAPH: { |
| 14827 |
CharSequence text = getIterableTextForAccessibility(); |
| 14828 |
if (text != null && text.length() > 0) { |
| 14829 |
ParagraphTextSegmentIterator iterator = |
| 14830 |
ParagraphTextSegmentIterator.getInstance(); |
| 14831 |
iterator.initialize(text.toString()); |
| 14832 |
return iterator; |
| 14833 |
} |
| 14834 |
} break; |
| 14835 |
} |
| 14836 |
return null; |
| 14837 |
} |
| 14838 |
|
| 14839 |
|
| 14840 |
|
| 14841 |
|
| 14842 |
|
| 14843 |
|
| 14844 |
|
| 14845 |
|
| 14846 |
|
| 14847 |
|
| 14848 |
|
| 14849 |
|
| 14850 |
|
| 14851 |
|
| 14852 |
|
| 14853 |
|
| 14854 |
|
| 14855 |
public final boolean isTemporarilyDetached() { |
| 14856 |
return (mPrivateFlags3 & PFLAG3_TEMPORARY_DETACH) != 0; |
| 14857 |
} |
| 14858 |
|
| 14859 |
|
| 14860 |
|
| 14861 |
|
| 14862 |
|
| 14863 |
@CallSuper |
| 14864 |
public void dispatchStartTemporaryDetach() { |
| 14865 |
mPrivateFlags3 |= PFLAG3_TEMPORARY_DETACH; |
| 14866 |
notifyEnterOrExitForAutoFillIfNeeded(false); |
| 14867 |
notifyAppearedOrDisappearedForContentCaptureIfNeeded(false); |
| 14868 |
onStartTemporaryDetach(); |
| 14869 |
} |
| 14870 |
|
| 14871 |
|
| 14872 |
|
| 14873 |
|
| 14874 |
|
| 14875 |
|
| 14876 |
|
| 14877 |
public void onStartTemporaryDetach() { |
| 14878 |
removeUnsetPressCallback(); |
| 14879 |
mPrivateFlags |= PFLAG_CANCEL_NEXT_UP_EVENT; |
| 14880 |
} |
| 14881 |
|
| 14882 |
|
| 14883 |
|
| 14884 |
|
| 14885 |
|
| 14886 |
@CallSuper |
| 14887 |
public void dispatchFinishTemporaryDetach() { |
| 14888 |
mPrivateFlags3 &= ~PFLAG3_TEMPORARY_DETACH; |
| 14889 |
onFinishTemporaryDetach(); |
| 14890 |
if (hasWindowFocus() && hasFocus()) { |
| 14891 |
notifyFocusChangeToImeFocusController(true ); |
| 14892 |
} |
| 14893 |
notifyEnterOrExitForAutoFillIfNeeded(true); |
| 14894 |
notifyAppearedOrDisappearedForContentCaptureIfNeeded(true); |
| 14895 |
} |
| 14896 |
|
| 14897 |
|
| 14898 |
|
| 14899 |
|
| 14900 |
|
| 14901 |
public void onFinishTemporaryDetach() { |
| 14902 |
} |
| 14903 |
|
| 14904 |
|
| 14905 |
|
| 14906 |
|
| 14907 |
|
| 14908 |
|
| 14909 |
|
| 14910 |
|
| 14911 |
public KeyEvent.DispatcherState getKeyDispatcherState() { |
| 14912 |
return mAttachInfo != null ? mAttachInfo.mKeyDispatchState : null; |
| 14913 |
} |
| 14914 |
|
| 14915 |
|
| 14916 |
|
| 14917 |
|
| 14918 |
|
| 14919 |
|
| 14920 |
|
| 14921 |
|
| 14922 |
|
| 14923 |
|
| 14924 |
|
| 14925 |
public boolean dispatchKeyEventPreIme(KeyEvent event) { |
| 14926 |
return onKeyPreIme(event.getKeyCode(), event); |
| 14927 |
} |
| 14928 |
|
| 14929 |
|
| 14930 |
|
| 14931 |
|
| 14932 |
|
| 14933 |
|
| 14934 |
|
| 14935 |
|
| 14936 |
|
| 14937 |
|
| 14938 |
|
| 14939 |
public boolean dispatchKeyEvent(KeyEvent event) { |
| 14940 |
if (mInputEventConsistencyVerifier != null) { |
| 14941 |
mInputEventConsistencyVerifier.onKeyEvent(event, 0); |
| 14942 |
} |
| 14943 |
|
| 14944 |
|
| 14945 |
|
| 14946 |
ListenerInfo li = mListenerInfo; |
| 14947 |
if (li != null && li.mOnKeyListener != null && (mViewFlags & ENABLED_MASK) == ENABLED |
| 14948 |
&& li.mOnKeyListener.onKey(this, event.getKeyCode(), event)) { |
| 14949 |
return true; |
| 14950 |
} |
| 14951 |
|
| 14952 |
if (event.dispatch(this, mAttachInfo != null |
| 14953 |
? mAttachInfo.mKeyDispatchState : null, this)) { |
| 14954 |
return true; |
| 14955 |
} |
| 14956 |
|
| 14957 |
if (mInputEventConsistencyVerifier != null) { |
| 14958 |
mInputEventConsistencyVerifier.onUnhandledEvent(event, 0); |
| 14959 |
} |
| 14960 |
return false; |
| 14961 |
} |
| 14962 |
|
| 14963 |
|
| 14964 |
|
| 14965 |
|
| 14966 |
|
| 14967 |
|
| 14968 |
|
| 14969 |
public boolean dispatchKeyShortcutEvent(KeyEvent event) { |
| 14970 |
return onKeyShortcut(event.getKeyCode(), event); |
| 14971 |
} |
| 14972 |
|
| 14973 |
|
| 14974 |
|
| 14975 |
|
| 14976 |
|
| 14977 |
|
| 14978 |
|
| 14979 |
|
| 14980 |
public boolean dispatchTouchEvent(MotionEvent event) { |
| 14981 |
|
| 14982 |
if (event.isTargetAccessibilityFocus()) { |
| 14983 |
|
| 14984 |
if (!isAccessibilityFocusedViewOrHost()) { |
| 14985 |
return false; |
| 14986 |
} |
| 14987 |
|
| 14988 |
event.setTargetAccessibilityFocus(false); |
| 14989 |
} |
| 14990 |
boolean result = false; |
| 14991 |
|
| 14992 |
if (mInputEventConsistencyVerifier != null) { |
| 14993 |
mInputEventConsistencyVerifier.onTouchEvent(event, 0); |
| 14994 |
} |
| 14995 |
|
| 14996 |
final int actionMasked = event.getActionMasked(); |
| 14997 |
if (actionMasked == MotionEvent.ACTION_DOWN) { |
| 14998 |
|
| 14999 |
stopNestedScroll(); |
| 15000 |
} |
| 15001 |
|
| 15002 |
if (onFilterTouchEventForSecurity(event)) { |
| 15003 |
if ((mViewFlags & ENABLED_MASK) == ENABLED && handleScrollBarDragging(event)) { |
| 15004 |
result = true; |
| 15005 |
} |
| 15006 |
|
| 15007 |
ListenerInfo li = mListenerInfo; |
| 15008 |
if (li != null && li.mOnTouchListener != null |
| 15009 |
&& (mViewFlags & ENABLED_MASK) == ENABLED |
| 15010 |
&& li.mOnTouchListener.onTouch(this, event)) { |
| 15011 |
result = true; |
| 15012 |
} |
| 15013 |
|
| 15014 |
if (!result && onTouchEvent(event)) { |
| 15015 |
result = true; |
| 15016 |
} |
| 15017 |
} |
| 15018 |
|
| 15019 |
if (!result && mInputEventConsistencyVerifier != null) { |
| 15020 |
mInputEventConsistencyVerifier.onUnhandledEvent(event, 0); |
| 15021 |
} |
| 15022 |
|
| 15023 |
|
| 15024 |
|
| 15025 |
|
| 15026 |
if (actionMasked == MotionEvent.ACTION_UP || |
| 15027 |
actionMasked == MotionEvent.ACTION_CANCEL || |
| 15028 |
(actionMasked == MotionEvent.ACTION_DOWN && !result)) { |
| 15029 |
stopNestedScroll(); |
| 15030 |
} |
| 15031 |
|
| 15032 |
return result; |
| 15033 |
} |
| 15034 |
|
| 15035 |
boolean isAccessibilityFocusedViewOrHost() { |
| 15036 |
return isAccessibilityFocused() || (getViewRootImpl() != null && getViewRootImpl() |
| 15037 |
.getAccessibilityFocusedHost() == this); |
| 15038 |
} |
| 15039 |
|
| 15040 |
|
| 15041 |
|
| 15042 |
|
| 15043 |
|
| 15044 |
|
| 15045 |
|
| 15046 |
protected boolean canReceivePointerEvents() { |
| 15047 |
return (mViewFlags & VISIBILITY_MASK) == VISIBLE || getAnimation() != null; |
| 15048 |
} |
| 15049 |
|
| 15050 |
|
| 15051 |
|
| 15052 |
|
| 15053 |
|
| 15054 |
|
| 15055 |
|
| 15056 |
|
| 15057 |
|
| 15058 |
public boolean onFilterTouchEventForSecurity(MotionEvent event) { |
| 15059 |
|
| 15060 |
if ((mViewFlags & FILTER_TOUCHES_WHEN_OBSCURED) != 0 |
| 15061 |
&& (event.getFlags() & MotionEvent.FLAG_WINDOW_IS_OBSCURED) != 0) { |
| 15062 |
|
| 15063 |
return false; |
| 15064 |
} |
| 15065 |
return true; |
| 15066 |
} |
| 15067 |
|
| 15068 |
|
| 15069 |
|
| 15070 |
|
| 15071 |
|
| 15072 |
|
| 15073 |
|
| 15074 |
public boolean dispatchTrackballEvent(MotionEvent event) { |
| 15075 |
if (mInputEventConsistencyVerifier != null) { |
| 15076 |
mInputEventConsistencyVerifier.onTrackballEvent(event, 0); |
| 15077 |
} |
| 15078 |
|
| 15079 |
return onTrackballEvent(event); |
| 15080 |
} |
| 15081 |
|
| 15082 |
|
| 15083 |
|
| 15084 |
|
| 15085 |
|
| 15086 |
|
| 15087 |
|
| 15088 |
public boolean dispatchCapturedPointerEvent(MotionEvent event) { |
| 15089 |
if (!hasPointerCapture()) { |
| 15090 |
return false; |
| 15091 |
} |
| 15092 |
|
| 15093 |
ListenerInfo li = mListenerInfo; |
| 15094 |
if (li != null && li.mOnCapturedPointerListener != null |
| 15095 |
&& li.mOnCapturedPointerListener.onCapturedPointer(this, event)) { |
| 15096 |
return true; |
| 15097 |
} |
| 15098 |
return onCapturedPointerEvent(event); |
| 15099 |
} |
| 15100 |
|
| 15101 |
|
| 15102 |
|
| 15103 |
|
| 15104 |
|
| 15105 |
|
| 15106 |
|
| 15107 |
|
| 15108 |
|
| 15109 |
|
| 15110 |
|
| 15111 |
|
| 15112 |
|
| 15113 |
public boolean dispatchGenericMotionEvent(MotionEvent event) { |
| 15114 |
if (mInputEventConsistencyVerifier != null) { |
| 15115 |
mInputEventConsistencyVerifier.onGenericMotionEvent(event, 0); |
| 15116 |
} |
| 15117 |
|
| 15118 |
final int source = event.getSource(); |
| 15119 |
if ((source & InputDevice.SOURCE_CLASS_POINTER) != 0) { |
| 15120 |
final int action = event.getAction(); |
| 15121 |
if (action == MotionEvent.ACTION_HOVER_ENTER |
| 15122 |
|| action == MotionEvent.ACTION_HOVER_MOVE |
| 15123 |
|| action == MotionEvent.ACTION_HOVER_EXIT) { |
| 15124 |
if (dispatchHoverEvent(event)) { |
| 15125 |
return true; |
| 15126 |
} |
| 15127 |
} else if (dispatchGenericPointerEvent(event)) { |
| 15128 |
return true; |
| 15129 |
} |
| 15130 |
} else if (dispatchGenericFocusedEvent(event)) { |
| 15131 |
return true; |
| 15132 |
} |
| 15133 |
|
| 15134 |
if (dispatchGenericMotionEventInternal(event)) { |
| 15135 |
return true; |
| 15136 |
} |
| 15137 |
|
| 15138 |
if (mInputEventConsistencyVerifier != null) { |
| 15139 |
mInputEventConsistencyVerifier.onUnhandledEvent(event, 0); |
| 15140 |
} |
| 15141 |
return false; |
| 15142 |
} |
| 15143 |
|
| 15144 |
private boolean dispatchGenericMotionEventInternal(MotionEvent event) { |
| 15145 |
|
| 15146 |
ListenerInfo li = mListenerInfo; |
| 15147 |
if (li != null && li.mOnGenericMotionListener != null |
| 15148 |
&& (mViewFlags & ENABLED_MASK) == ENABLED |
| 15149 |
&& li.mOnGenericMotionListener.onGenericMotion(this, event)) { |
| 15150 |
return true; |
| 15151 |
} |
| 15152 |
|
| 15153 |
if (onGenericMotionEvent(event)) { |
| 15154 |
return true; |
| 15155 |
} |
| 15156 |
|
| 15157 |
final int actionButton = event.getActionButton(); |
| 15158 |
switch (event.getActionMasked()) { |
| 15159 |
case MotionEvent.ACTION_BUTTON_PRESS: |
| 15160 |
if (isContextClickable() && !mInContextButtonPress && !mHasPerformedLongPress |
| 15161 |
&& (actionButton == MotionEvent.BUTTON_STYLUS_PRIMARY |
| 15162 |
|| actionButton == MotionEvent.BUTTON_SECONDARY)) { |
| 15163 |
if (performContextClick(event.getX(), event.getY())) { |
| 15164 |
mInContextButtonPress = true; |
| 15165 |
setPressed(true, event.getX(), event.getY()); |
| 15166 |
removeTapCallback(); |
| 15167 |
removeLongPressCallback(); |
| 15168 |
return true; |
| 15169 |
} |
| 15170 |
} |
| 15171 |
break; |
| 15172 |
|
| 15173 |
case MotionEvent.ACTION_BUTTON_RELEASE: |
| 15174 |
if (mInContextButtonPress && (actionButton == MotionEvent.BUTTON_STYLUS_PRIMARY |
| 15175 |
|| actionButton == MotionEvent.BUTTON_SECONDARY)) { |
| 15176 |
mInContextButtonPress = false; |
| 15177 |
mIgnoreNextUpEvent = true; |
| 15178 |
} |
| 15179 |
break; |
| 15180 |
} |
| 15181 |
|
| 15182 |
if (mInputEventConsistencyVerifier != null) { |
| 15183 |
mInputEventConsistencyVerifier.onUnhandledEvent(event, 0); |
| 15184 |
} |
| 15185 |
return false; |
| 15186 |
} |
| 15187 |
|
| 15188 |
|
| 15189 |
|
| 15190 |
|
| 15191 |
|
| 15192 |
|
| 15193 |
|
| 15194 |
|
| 15195 |
|
| 15196 |
|
| 15197 |
|
| 15198 |
protected boolean dispatchHoverEvent(MotionEvent event) { |
| 15199 |
ListenerInfo li = mListenerInfo; |
| 15200 |
|
| 15201 |
if (li != null && li.mOnHoverListener != null |
| 15202 |
&& (mViewFlags & ENABLED_MASK) == ENABLED |
| 15203 |
&& li.mOnHoverListener.onHover(this, event)) { |
| 15204 |
return true; |
| 15205 |
} |
| 15206 |
|
| 15207 |
return onHoverEvent(event); |
| 15208 |
} |
| 15209 |
|
| 15210 |
|
| 15211 |
|
| 15212 |
|
| 15213 |
|
| 15214 |
|
| 15215 |
|
| 15216 |
protected boolean hasHoveredChild() { |
| 15217 |
return false; |
| 15218 |
} |
| 15219 |
|
| 15220 |
|
| 15221 |
|
| 15222 |
|
| 15223 |
|
| 15224 |
|
| 15225 |
protected boolean pointInHoveredChild(MotionEvent event) { |
| 15226 |
return false; |
| 15227 |
} |
| 15228 |
|
| 15229 |
|
| 15230 |
|
| 15231 |
|
| 15232 |
|
| 15233 |
|
| 15234 |
|
| 15235 |
|
| 15236 |
|
| 15237 |
|
| 15238 |
|
| 15239 |
protected boolean dispatchGenericPointerEvent(MotionEvent event) { |
| 15240 |
return false; |
| 15241 |
} |
| 15242 |
|
| 15243 |
|
| 15244 |
|
| 15245 |
|
| 15246 |
|
| 15247 |
|
| 15248 |
|
| 15249 |
|
| 15250 |
|
| 15251 |
|
| 15252 |
|
| 15253 |
protected boolean dispatchGenericFocusedEvent(MotionEvent event) { |
| 15254 |
return false; |
| 15255 |
} |
| 15256 |
|
| 15257 |
|
| 15258 |
|
| 15259 |
|
| 15260 |
|
| 15261 |
|
| 15262 |
|
| 15263 |
|
| 15264 |
|
| 15265 |
|
| 15266 |
|
| 15267 |
|
| 15268 |
|
| 15269 |
|
| 15270 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 15271 |
public final boolean dispatchPointerEvent(MotionEvent event) { |
| 15272 |
if (event.isTouchEvent()) { |
| 15273 |
return dispatchTouchEvent(event); |
| 15274 |
} else { |
| 15275 |
return dispatchGenericMotionEvent(event); |
| 15276 |
} |
| 15277 |
} |
| 15278 |
|
| 15279 |
|
| 15280 |
|
| 15281 |
|
| 15282 |
|
| 15283 |
|
| 15284 |
|
| 15285 |
|
| 15286 |
public void dispatchWindowFocusChanged(boolean hasFocus) { |
| 15287 |
onWindowFocusChanged(hasFocus); |
| 15288 |
} |
| 15289 |
|
| 15290 |
|
| 15291 |
|
| 15292 |
|
| 15293 |
|
| 15294 |
|
| 15295 |
|
| 15296 |
|
| 15297 |
|
| 15298 |
|
| 15299 |
|
| 15300 |
public void onWindowFocusChanged(boolean hasWindowFocus) { |
| 15301 |
if (!hasWindowFocus) { |
| 15302 |
if (isPressed()) { |
| 15303 |
setPressed(false); |
| 15304 |
} |
| 15305 |
mPrivateFlags3 &= ~PFLAG3_FINGER_DOWN; |
| 15306 |
if ((mPrivateFlags & PFLAG_FOCUSED) != 0) { |
| 15307 |
notifyFocusChangeToImeFocusController(false ); |
| 15308 |
} |
| 15309 |
removeLongPressCallback(); |
| 15310 |
removeTapCallback(); |
| 15311 |
onFocusLost(); |
| 15312 |
} else if ((mPrivateFlags & PFLAG_FOCUSED) != 0) { |
| 15313 |
notifyFocusChangeToImeFocusController(true ); |
| 15314 |
} |
| 15315 |
|
| 15316 |
refreshDrawableState(); |
| 15317 |
} |
| 15318 |
|
| 15319 |
|
| 15320 |
|
| 15321 |
|
| 15322 |
|
| 15323 |
|
| 15324 |
|
| 15325 |
public boolean hasWindowFocus() { |
| 15326 |
return mAttachInfo != null && mAttachInfo.mHasWindowFocus; |
| 15327 |
} |
| 15328 |
|
| 15329 |
|
| 15330 |
|
| 15331 |
|
| 15332 |
|
| 15333 |
public boolean hasImeFocus() { |
| 15334 |
return getViewRootImpl() != null && getViewRootImpl().getImeFocusController().hasImeFocus(); |
| 15335 |
} |
| 15336 |
|
| 15337 |
|
| 15338 |
|
| 15339 |
|
| 15340 |
|
| 15341 |
|
| 15342 |
|
| 15343 |
|
| 15344 |
|
| 15345 |
protected void dispatchVisibilityChanged(@NonNull View changedView, |
| 15346 |
@Visibility int visibility) { |
| 15347 |
onVisibilityChanged(changedView, visibility); |
| 15348 |
} |
| 15349 |
|
| 15350 |
|
| 15351 |
|
| 15352 |
|
| 15353 |
|
| 15354 |
|
| 15355 |
|
| 15356 |
|
| 15357 |
|
| 15358 |
|
| 15359 |
protected void onVisibilityChanged(@NonNull View changedView, @Visibility int visibility) { |
| 15360 |
} |
| 15361 |
|
| 15362 |
|
| 15363 |
|
| 15364 |
|
| 15365 |
|
| 15366 |
|
| 15367 |
|
| 15368 |
|
| 15369 |
|
| 15370 |
|
| 15371 |
public void dispatchDisplayHint(@Visibility int hint) { |
| 15372 |
onDisplayHint(hint); |
| 15373 |
} |
| 15374 |
|
| 15375 |
|
| 15376 |
|
| 15377 |
|
| 15378 |
|
| 15379 |
|
| 15380 |
|
| 15381 |
|
| 15382 |
|
| 15383 |
|
| 15384 |
protected void onDisplayHint(@Visibility int hint) { |
| 15385 |
} |
| 15386 |
|
| 15387 |
|
| 15388 |
|
| 15389 |
|
| 15390 |
|
| 15391 |
|
| 15392 |
|
| 15393 |
|
| 15394 |
|
| 15395 |
public void dispatchWindowVisibilityChanged(@Visibility int visibility) { |
| 15396 |
onWindowVisibilityChanged(visibility); |
| 15397 |
} |
| 15398 |
|
| 15399 |
|
| 15400 |
|
| 15401 |
|
| 15402 |
|
| 15403 |
|
| 15404 |
|
| 15405 |
|
| 15406 |
|
| 15407 |
|
| 15408 |
|
| 15409 |
protected void onWindowVisibilityChanged(@Visibility int visibility) { |
| 15410 |
if (visibility == VISIBLE) { |
| 15411 |
initialAwakenScrollBars(); |
| 15412 |
} |
| 15413 |
} |
| 15414 |
|
| 15415 |
|
| 15416 |
|
| 15417 |
|
| 15418 |
|
| 15419 |
|
| 15420 |
|
| 15421 |
public boolean isAggregatedVisible() { |
| 15422 |
return (mPrivateFlags3 & PFLAG3_AGGREGATED_VISIBLE) != 0; |
| 15423 |
} |
| 15424 |
|
| 15425 |
|
| 15426 |
|
| 15427 |
|
| 15428 |
|
| 15429 |
|
| 15430 |
|
| 15431 |
|
| 15432 |
|
| 15433 |
|
| 15434 |
boolean dispatchVisibilityAggregated(boolean isVisible) { |
| 15435 |
final boolean thisVisible = getVisibility() == VISIBLE; |
| 15436 |
|
| 15437 |
if (thisVisible || !isVisible) { |
| 15438 |
onVisibilityAggregated(isVisible); |
| 15439 |
} |
| 15440 |
return thisVisible && isVisible; |
| 15441 |
} |
| 15442 |
|
| 15443 |
|
| 15444 |
|
| 15445 |
|
| 15446 |
|
| 15447 |
|
| 15448 |
|
| 15449 |
|
| 15450 |
@CallSuper |
| 15451 |
public void onVisibilityAggregated(boolean isVisible) { |
| 15452 |
|
| 15453 |
boolean oldVisible = isAggregatedVisible(); |
| 15454 |
mPrivateFlags3 = isVisible ? (mPrivateFlags3 | PFLAG3_AGGREGATED_VISIBLE) |
| 15455 |
: (mPrivateFlags3 & ~PFLAG3_AGGREGATED_VISIBLE); |
| 15456 |
if (isVisible && mAttachInfo != null) { |
| 15457 |
initialAwakenScrollBars(); |
| 15458 |
} |
| 15459 |
|
| 15460 |
final Drawable dr = mBackground; |
| 15461 |
if (dr != null && isVisible != dr.isVisible()) { |
| 15462 |
dr.setVisible(isVisible, false); |
| 15463 |
} |
| 15464 |
final Drawable hl = mDefaultFocusHighlight; |
| 15465 |
if (hl != null && isVisible != hl.isVisible()) { |
| 15466 |
hl.setVisible(isVisible, false); |
| 15467 |
} |
| 15468 |
final Drawable fg = mForegroundInfo != null ? mForegroundInfo.mDrawable : null; |
| 15469 |
if (fg != null && isVisible != fg.isVisible()) { |
| 15470 |
fg.setVisible(isVisible, false); |
| 15471 |
} |
| 15472 |
|
| 15473 |
if (isAutofillable()) { |
| 15474 |
AutofillManager afm = getAutofillManager(); |
| 15475 |
|
| 15476 |
if (afm != null && getAutofillViewId() > LAST_APP_AUTOFILL_ID) { |
| 15477 |
if (mVisibilityChangeForAutofillHandler != null) { |
| 15478 |
mVisibilityChangeForAutofillHandler.removeMessages(0); |
| 15479 |
} |
| 15480 |
|
| 15481 |
|
| 15482 |
|
| 15483 |
if (isVisible) { |
| 15484 |
afm.notifyViewVisibilityChanged(this, true); |
| 15485 |
} else { |
| 15486 |
if (mVisibilityChangeForAutofillHandler == null) { |
| 15487 |
mVisibilityChangeForAutofillHandler = |
| 15488 |
new VisibilityChangeForAutofillHandler(afm, this); |
| 15489 |
} |
| 15490 |
|
| 15491 |
|
| 15492 |
mVisibilityChangeForAutofillHandler.obtainMessage(0, this).sendToTarget(); |
| 15493 |
} |
| 15494 |
} |
| 15495 |
} |
| 15496 |
|
| 15497 |
if (isVisible != oldVisible) { |
| 15498 |
if (isAccessibilityPane()) { |
| 15499 |
notifyViewAccessibilityStateChangedIfNeeded(isVisible |
| 15500 |
? AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_APPEARED |
| 15501 |
: AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED); |
| 15502 |
} |
| 15503 |
|
| 15504 |
notifyAppearedOrDisappearedForContentCaptureIfNeeded(isVisible); |
| 15505 |
|
| 15506 |
if (!getSystemGestureExclusionRects().isEmpty()) { |
| 15507 |
postUpdate(this::updateSystemGestureExclusionRects); |
| 15508 |
} |
| 15509 |
|
| 15510 |
if (!collectPreferKeepClearRects().isEmpty()) { |
| 15511 |
postUpdate(this::updateKeepClearRects); |
| 15512 |
} |
| 15513 |
} |
| 15514 |
} |
| 15515 |
|
| 15516 |
|
| 15517 |
|
| 15518 |
|
| 15519 |
|
| 15520 |
|
| 15521 |
|
| 15522 |
@Visibility |
| 15523 |
public int getWindowVisibility() { |
| 15524 |
return mAttachInfo != null ? mAttachInfo.mWindowVisibility : GONE; |
| 15525 |
} |
| 15526 |
|
| 15527 |
|
| 15528 |
|
| 15529 |
|
| 15530 |
|
| 15531 |
|
| 15532 |
|
| 15533 |
|
| 15534 |
|
| 15535 |
|
| 15536 |
|
| 15537 |
|
| 15538 |
|
| 15539 |
public void getWindowVisibleDisplayFrame(Rect outRect) { |
| 15540 |
if (mAttachInfo != null) { |
| 15541 |
mAttachInfo.mViewRootImpl.getWindowVisibleDisplayFrame(outRect); |
| 15542 |
return; |
| 15543 |
} |
| 15544 |
|
| 15545 |
|
| 15546 |
Display d = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY); |
| 15547 |
d.getRectSize(outRect); |
| 15548 |
} |
| 15549 |
|
| 15550 |
|
| 15551 |
|
| 15552 |
|
| 15553 |
|
| 15554 |
|
| 15555 |
|
| 15556 |
@UnsupportedAppUsage |
| 15557 |
public void getWindowDisplayFrame(Rect outRect) { |
| 15558 |
if (mAttachInfo != null) { |
| 15559 |
mAttachInfo.mViewRootImpl.getDisplayFrame(outRect); |
| 15560 |
return; |
| 15561 |
} |
| 15562 |
|
| 15563 |
|
| 15564 |
Display d = DisplayManagerGlobal.getInstance().getRealDisplay(Display.DEFAULT_DISPLAY); |
| 15565 |
d.getRectSize(outRect); |
| 15566 |
} |
| 15567 |
|
| 15568 |
|
| 15569 |
|
| 15570 |
|
| 15571 |
|
| 15572 |
|
| 15573 |
|
| 15574 |
|
| 15575 |
|
| 15576 |
|
| 15577 |
public void dispatchConfigurationChanged(Configuration newConfig) { |
| 15578 |
onConfigurationChanged(newConfig); |
| 15579 |
} |
| 15580 |
|
| 15581 |
|
| 15582 |
|
| 15583 |
|
| 15584 |
|
| 15585 |
|
| 15586 |
|
| 15587 |
|
| 15588 |
|
| 15589 |
|
| 15590 |
|
| 15591 |
protected void onConfigurationChanged(Configuration newConfig) { |
| 15592 |
} |
| 15593 |
|
| 15594 |
|
| 15595 |
|
| 15596 |
|
| 15597 |
|
| 15598 |
void dispatchCollectViewAttributes(AttachInfo attachInfo, int visibility) { |
| 15599 |
performCollectViewAttributes(attachInfo, visibility); |
| 15600 |
} |
| 15601 |
|
| 15602 |
void performCollectViewAttributes(AttachInfo attachInfo, int visibility) { |
| 15603 |
if ((visibility & VISIBILITY_MASK) == VISIBLE) { |
| 15604 |
if ((mViewFlags & KEEP_SCREEN_ON) == KEEP_SCREEN_ON) { |
| 15605 |
attachInfo.mKeepScreenOn = true; |
| 15606 |
} |
| 15607 |
attachInfo.mSystemUiVisibility |= mSystemUiVisibility; |
| 15608 |
ListenerInfo li = mListenerInfo; |
| 15609 |
if (li != null && li.mOnSystemUiVisibilityChangeListener != null) { |
| 15610 |
attachInfo.mHasSystemUiListeners = true; |
| 15611 |
} |
| 15612 |
} |
| 15613 |
} |
| 15614 |
|
| 15615 |
void needGlobalAttributesUpdate(boolean force) { |
| 15616 |
final AttachInfo ai = mAttachInfo; |
| 15617 |
if (ai != null && !ai.mRecomputeGlobalAttributes) { |
| 15618 |
if (force || ai.mKeepScreenOn || (ai.mSystemUiVisibility != 0) |
| 15619 |
|| ai.mHasSystemUiListeners) { |
| 15620 |
ai.mRecomputeGlobalAttributes = true; |
| 15621 |
} |
| 15622 |
} |
| 15623 |
} |
| 15624 |
|
| 15625 |
|
| 15626 |
|
| 15627 |
|
| 15628 |
|
| 15629 |
|
| 15630 |
|
| 15631 |
|
| 15632 |
@ViewDebug.ExportedProperty |
| 15633 |
public boolean isInTouchMode() { |
| 15634 |
if (mAttachInfo != null) { |
| 15635 |
return mAttachInfo.mInTouchMode; |
| 15636 |
} else { |
| 15637 |
return ViewRootImpl.isInTouchMode(); |
| 15638 |
} |
| 15639 |
} |
| 15640 |
|
| 15641 |
|
| 15642 |
|
| 15643 |
|
| 15644 |
|
| 15645 |
|
| 15646 |
|
| 15647 |
@ViewDebug.CapturedViewProperty |
| 15648 |
@UiContext |
| 15649 |
public final Context getContext() { |
| 15650 |
return mContext; |
| 15651 |
} |
| 15652 |
|
| 15653 |
|
| 15654 |
|
| 15655 |
|
| 15656 |
|
| 15657 |
|
| 15658 |
|
| 15659 |
|
| 15660 |
|
| 15661 |
|
| 15662 |
|
| 15663 |
|
| 15664 |
|
| 15665 |
public boolean onKeyPreIme(int keyCode, KeyEvent event) { |
| 15666 |
return false; |
| 15667 |
} |
| 15668 |
|
| 15669 |
|
| 15670 |
|
| 15671 |
|
| 15672 |
|
| 15673 |
|
| 15674 |
|
| 15675 |
|
| 15676 |
|
| 15677 |
|
| 15678 |
|
| 15679 |
|
| 15680 |
|
| 15681 |
|
| 15682 |
|
| 15683 |
public boolean onKeyDown(int keyCode, KeyEvent event) { |
| 15684 |
if (KeyEvent.isConfirmKey(keyCode) && event.hasNoModifiers()) { |
| 15685 |
if ((mViewFlags & ENABLED_MASK) == DISABLED) { |
| 15686 |
return true; |
| 15687 |
} |
| 15688 |
|
| 15689 |
if (event.getRepeatCount() == 0) { |
| 15690 |
|
| 15691 |
final boolean clickable = (mViewFlags & CLICKABLE) == CLICKABLE |
| 15692 |
|| (mViewFlags & LONG_CLICKABLE) == LONG_CLICKABLE; |
| 15693 |
if (clickable || (mViewFlags & TOOLTIP) == TOOLTIP) { |
| 15694 |
|
| 15695 |
|
| 15696 |
final float x = getWidth() / 2f; |
| 15697 |
final float y = getHeight() / 2f; |
| 15698 |
if (clickable) { |
| 15699 |
setPressed(true, x, y); |
| 15700 |
} |
| 15701 |
checkForLongClick( |
| 15702 |
ViewConfiguration.getLongPressTimeout(), |
| 15703 |
x, |
| 15704 |
y, |
| 15705 |
|
| 15706 |
TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION); |
| 15707 |
return true; |
| 15708 |
} |
| 15709 |
} |
| 15710 |
} |
| 15711 |
|
| 15712 |
return false; |
| 15713 |
} |
| 15714 |
|
| 15715 |
|
| 15716 |
|
| 15717 |
|
| 15718 |
|
| 15719 |
|
| 15720 |
|
| 15721 |
|
| 15722 |
|
| 15723 |
public boolean onKeyLongPress(int keyCode, KeyEvent event) { |
| 15724 |
return false; |
| 15725 |
} |
| 15726 |
|
| 15727 |
|
| 15728 |
|
| 15729 |
|
| 15730 |
|
| 15731 |
|
| 15732 |
|
| 15733 |
|
| 15734 |
|
| 15735 |
|
| 15736 |
|
| 15737 |
|
| 15738 |
|
| 15739 |
|
| 15740 |
public boolean onKeyUp(int keyCode, KeyEvent event) { |
| 15741 |
if (KeyEvent.isConfirmKey(keyCode) && event.hasNoModifiers()) { |
| 15742 |
if ((mViewFlags & ENABLED_MASK) == DISABLED) { |
| 15743 |
return true; |
| 15744 |
} |
| 15745 |
if ((mViewFlags & CLICKABLE) == CLICKABLE && isPressed()) { |
| 15746 |
setPressed(false); |
| 15747 |
|
| 15748 |
if (!mHasPerformedLongPress) { |
| 15749 |
|
| 15750 |
removeLongPressCallback(); |
| 15751 |
if (!event.isCanceled()) { |
| 15752 |
return performClickInternal(); |
| 15753 |
} |
| 15754 |
} |
| 15755 |
} |
| 15756 |
} |
| 15757 |
return false; |
| 15758 |
} |
| 15759 |
|
| 15760 |
|
| 15761 |
|
| 15762 |
|
| 15763 |
|
| 15764 |
|
| 15765 |
|
| 15766 |
|
| 15767 |
|
| 15768 |
|
| 15769 |
|
| 15770 |
|
| 15771 |
|
| 15772 |
|
| 15773 |
public boolean onKeyMultiple(int keyCode, int repeatCount, KeyEvent event) { |
| 15774 |
return false; |
| 15775 |
} |
| 15776 |
|
| 15777 |
|
| 15778 |
|
| 15779 |
|
| 15780 |
|
| 15781 |
|
| 15782 |
|
| 15783 |
|
| 15784 |
|
| 15785 |
|
| 15786 |
|
| 15787 |
|
| 15788 |
public boolean onKeyShortcut(int keyCode, KeyEvent event) { |
| 15789 |
return false; |
| 15790 |
} |
| 15791 |
|
| 15792 |
|
| 15793 |
|
| 15794 |
|
| 15795 |
|
| 15796 |
|
| 15797 |
|
| 15798 |
|
| 15799 |
|
| 15800 |
|
| 15801 |
|
| 15802 |
|
| 15803 |
|
| 15804 |
|
| 15805 |
|
| 15806 |
|
| 15807 |
|
| 15808 |
|
| 15809 |
public boolean onCheckIsTextEditor() { |
| 15810 |
return false; |
| 15811 |
} |
| 15812 |
|
| 15813 |
|
| 15814 |
|
| 15815 |
|
| 15816 |
|
| 15817 |
|
| 15818 |
|
| 15819 |
|
| 15820 |
|
| 15821 |
|
| 15822 |
|
| 15823 |
|
| 15824 |
|
| 15825 |
|
| 15826 |
|
| 15827 |
|
| 15828 |
|
| 15829 |
|
| 15830 |
|
| 15831 |
|
| 15832 |
public InputConnection onCreateInputConnection(EditorInfo outAttrs) { |
| 15833 |
return null; |
| 15834 |
} |
| 15835 |
|
| 15836 |
|
| 15837 |
|
| 15838 |
|
| 15839 |
|
| 15840 |
|
| 15841 |
|
| 15842 |
|
| 15843 |
|
| 15844 |
|
| 15845 |
|
| 15846 |
|
| 15847 |
|
| 15848 |
|
| 15849 |
|
| 15850 |
|
| 15851 |
|
| 15852 |
|
| 15853 |
public void onInputConnectionOpenedInternal(@NonNull InputConnection inputConnection, |
| 15854 |
@NonNull EditorInfo editorInfo, @Nullable Handler handler) {} |
| 15855 |
|
| 15856 |
|
| 15857 |
|
| 15858 |
|
| 15859 |
|
| 15860 |
|
| 15861 |
|
| 15862 |
|
| 15863 |
|
| 15864 |
|
| 15865 |
|
| 15866 |
|
| 15867 |
|
| 15868 |
|
| 15869 |
|
| 15870 |
public void onInputConnectionClosedInternal() {} |
| 15871 |
|
| 15872 |
|
| 15873 |
|
| 15874 |
|
| 15875 |
|
| 15876 |
|
| 15877 |
|
| 15878 |
|
| 15879 |
|
| 15880 |
|
| 15881 |
|
| 15882 |
public boolean checkInputConnectionProxy(View view) { |
| 15883 |
return false; |
| 15884 |
} |
| 15885 |
|
| 15886 |
|
| 15887 |
|
| 15888 |
|
| 15889 |
|
| 15890 |
|
| 15891 |
|
| 15892 |
|
| 15893 |
|
| 15894 |
|
| 15895 |
|
| 15896 |
public void createContextMenu(ContextMenu menu) { |
| 15897 |
ContextMenuInfo menuInfo = getContextMenuInfo(); |
| 15898 |
|
| 15899 |
|
| 15900 |
|
| 15901 |
((MenuBuilder)menu).setCurrentMenuInfo(menuInfo); |
| 15902 |
|
| 15903 |
onCreateContextMenu(menu); |
| 15904 |
ListenerInfo li = mListenerInfo; |
| 15905 |
if (li != null && li.mOnCreateContextMenuListener != null) { |
| 15906 |
li.mOnCreateContextMenuListener.onCreateContextMenu(menu, this, menuInfo); |
| 15907 |
} |
| 15908 |
|
| 15909 |
|
| 15910 |
|
| 15911 |
((MenuBuilder)menu).setCurrentMenuInfo(null); |
| 15912 |
|
| 15913 |
if (mParent != null) { |
| 15914 |
mParent.createContextMenu(menu); |
| 15915 |
} |
| 15916 |
} |
| 15917 |
|
| 15918 |
|
| 15919 |
|
| 15920 |
|
| 15921 |
|
| 15922 |
|
| 15923 |
|
| 15924 |
|
| 15925 |
|
| 15926 |
|
| 15927 |
|
| 15928 |
protected ContextMenuInfo getContextMenuInfo() { |
| 15929 |
return null; |
| 15930 |
} |
| 15931 |
|
| 15932 |
|
| 15933 |
|
| 15934 |
|
| 15935 |
|
| 15936 |
|
| 15937 |
|
| 15938 |
protected void onCreateContextMenu(ContextMenu menu) { |
| 15939 |
} |
| 15940 |
|
| 15941 |
|
| 15942 |
|
| 15943 |
|
| 15944 |
|
| 15945 |
|
| 15946 |
|
| 15947 |
|
| 15948 |
|
| 15949 |
|
| 15950 |
|
| 15951 |
|
| 15952 |
|
| 15953 |
public boolean onTrackballEvent(MotionEvent event) { |
| 15954 |
return false; |
| 15955 |
} |
| 15956 |
|
| 15957 |
|
| 15958 |
|
| 15959 |
|
| 15960 |
|
| 15961 |
|
| 15962 |
|
| 15963 |
|
| 15964 |
|
| 15965 |
|
| 15966 |
|
| 15967 |
|
| 15968 |
|
| 15969 |
|
| 15970 |
|
| 15971 |
|
| 15972 |
|
| 15973 |
|
| 15974 |
|
| 15975 |
|
| 15976 |
|
| 15977 |
|
| 15978 |
|
| 15979 |
|
| 15980 |
|
| 15981 |
|
| 15982 |
|
| 15983 |
|
| 15984 |
|
| 15985 |
|
| 15986 |
|
| 15987 |
|
| 15988 |
|
| 15989 |
|
| 15990 |
|
| 15991 |
|
| 15992 |
|
| 15993 |
|
| 15994 |
public boolean onGenericMotionEvent(MotionEvent event) { |
| 15995 |
return false; |
| 15996 |
} |
| 15997 |
|
| 15998 |
|
| 15999 |
|
| 16000 |
|
| 16001 |
|
| 16002 |
|
| 16003 |
|
| 16004 |
|
| 16005 |
|
| 16006 |
|
| 16007 |
|
| 16008 |
|
| 16009 |
|
| 16010 |
|
| 16011 |
|
| 16012 |
private boolean dispatchTouchExplorationHoverEvent(MotionEvent event) { |
| 16013 |
final AccessibilityManager manager = AccessibilityManager.getInstance(mContext); |
| 16014 |
if (!manager.isEnabled() || !manager.isTouchExplorationEnabled()) { |
| 16015 |
return false; |
| 16016 |
} |
| 16017 |
|
| 16018 |
final boolean oldHoveringTouchDelegate = mHoveringTouchDelegate; |
| 16019 |
final int action = event.getActionMasked(); |
| 16020 |
boolean pointInDelegateRegion = false; |
| 16021 |
boolean handled = false; |
| 16022 |
|
| 16023 |
final AccessibilityNodeInfo.TouchDelegateInfo info = mTouchDelegate.getTouchDelegateInfo(); |
| 16024 |
for (int i = 0; i < info.getRegionCount(); i++) { |
| 16025 |
Region r = info.getRegionAt(i); |
| 16026 |
if (r.contains((int) event.getX(), (int) event.getY())) { |
| 16027 |
pointInDelegateRegion = true; |
| 16028 |
} |
| 16029 |
} |
| 16030 |
|
| 16031 |
|
| 16032 |
|
| 16033 |
|
| 16034 |
|
| 16035 |
if (!oldHoveringTouchDelegate) { |
| 16036 |
if ((action == MotionEvent.ACTION_HOVER_ENTER |
| 16037 |
|| action == MotionEvent.ACTION_HOVER_MOVE) |
| 16038 |
&& !pointInHoveredChild(event) |
| 16039 |
&& pointInDelegateRegion) { |
| 16040 |
mHoveringTouchDelegate = true; |
| 16041 |
} |
| 16042 |
} else { |
| 16043 |
if (action == MotionEvent.ACTION_HOVER_EXIT |
| 16044 |
|| (action == MotionEvent.ACTION_HOVER_MOVE |
| 16045 |
&& (pointInHoveredChild(event) || !pointInDelegateRegion))) { |
| 16046 |
mHoveringTouchDelegate = false; |
| 16047 |
} |
| 16048 |
} |
| 16049 |
switch (action) { |
| 16050 |
case MotionEvent.ACTION_HOVER_MOVE: |
| 16051 |
if (oldHoveringTouchDelegate && mHoveringTouchDelegate) { |
| 16052 |
|
| 16053 |
handled = mTouchDelegate.onTouchExplorationHoverEvent(event); |
| 16054 |
} else if (!oldHoveringTouchDelegate && mHoveringTouchDelegate) { |
| 16055 |
|
| 16056 |
MotionEvent eventNoHistory = (event.getHistorySize() == 0) |
| 16057 |
? event : MotionEvent.obtainNoHistory(event); |
| 16058 |
eventNoHistory.setAction(MotionEvent.ACTION_HOVER_ENTER); |
| 16059 |
handled = mTouchDelegate.onTouchExplorationHoverEvent(eventNoHistory); |
| 16060 |
eventNoHistory.setAction(action); |
| 16061 |
handled |= mTouchDelegate.onTouchExplorationHoverEvent(eventNoHistory); |
| 16062 |
} else if (oldHoveringTouchDelegate && !mHoveringTouchDelegate) { |
| 16063 |
|
| 16064 |
final boolean hoverExitPending = event.isHoverExitPending(); |
| 16065 |
event.setHoverExitPending(true); |
| 16066 |
mTouchDelegate.onTouchExplorationHoverEvent(event); |
| 16067 |
MotionEvent eventNoHistory = (event.getHistorySize() == 0) |
| 16068 |
? event : MotionEvent.obtainNoHistory(event); |
| 16069 |
eventNoHistory.setHoverExitPending(hoverExitPending); |
| 16070 |
eventNoHistory.setAction(MotionEvent.ACTION_HOVER_EXIT); |
| 16071 |
mTouchDelegate.onTouchExplorationHoverEvent(eventNoHistory); |
| 16072 |
} |
| 16073 |
break; |
| 16074 |
case MotionEvent.ACTION_HOVER_ENTER: |
| 16075 |
if (!oldHoveringTouchDelegate && mHoveringTouchDelegate) { |
| 16076 |
handled = mTouchDelegate.onTouchExplorationHoverEvent(event); |
| 16077 |
} |
| 16078 |
break; |
| 16079 |
case MotionEvent.ACTION_HOVER_EXIT: |
| 16080 |
if (oldHoveringTouchDelegate) { |
| 16081 |
mTouchDelegate.onTouchExplorationHoverEvent(event); |
| 16082 |
} |
| 16083 |
break; |
| 16084 |
} |
| 16085 |
return handled; |
| 16086 |
} |
| 16087 |
|
| 16088 |
|
| 16089 |
|
| 16090 |
|
| 16091 |
|
| 16092 |
|
| 16093 |
|
| 16094 |
|
| 16095 |
|
| 16096 |
|
| 16097 |
|
| 16098 |
|
| 16099 |
|
| 16100 |
|
| 16101 |
|
| 16102 |
|
| 16103 |
|
| 16104 |
|
| 16105 |
|
| 16106 |
|
| 16107 |
|
| 16108 |
|
| 16109 |
|
| 16110 |
|
| 16111 |
|
| 16112 |
|
| 16113 |
|
| 16114 |
|
| 16115 |
|
| 16116 |
|
| 16117 |
|
| 16118 |
|
| 16119 |
|
| 16120 |
|
| 16121 |
|
| 16122 |
|
| 16123 |
|
| 16124 |
public boolean onHoverEvent(MotionEvent event) { |
| 16125 |
if (mTouchDelegate != null && dispatchTouchExplorationHoverEvent(event)) { |
| 16126 |
return true; |
| 16127 |
} |
| 16128 |
|
| 16129 |
|
| 16130 |
|
| 16131 |
|
| 16132 |
final int action = event.getActionMasked(); |
| 16133 |
if (!mSendingHoverAccessibilityEvents) { |
| 16134 |
if ((action == MotionEvent.ACTION_HOVER_ENTER |
| 16135 |
|| action == MotionEvent.ACTION_HOVER_MOVE) |
| 16136 |
&& !hasHoveredChild() |
| 16137 |
&& pointInView(event.getX(), event.getY())) { |
| 16138 |
sendAccessibilityHoverEvent(AccessibilityEvent.TYPE_VIEW_HOVER_ENTER); |
| 16139 |
mSendingHoverAccessibilityEvents = true; |
| 16140 |
} |
| 16141 |
} else { |
| 16142 |
if (action == MotionEvent.ACTION_HOVER_EXIT |
| 16143 |
|| (action == MotionEvent.ACTION_HOVER_MOVE |
| 16144 |
&& !pointInView(event.getX(), event.getY()))) { |
| 16145 |
mSendingHoverAccessibilityEvents = false; |
| 16146 |
sendAccessibilityHoverEvent(AccessibilityEvent.TYPE_VIEW_HOVER_EXIT); |
| 16147 |
} |
| 16148 |
} |
| 16149 |
|
| 16150 |
if ((action == MotionEvent.ACTION_HOVER_ENTER || action == MotionEvent.ACTION_HOVER_MOVE) |
| 16151 |
&& event.isFromSource(InputDevice.SOURCE_MOUSE) |
| 16152 |
&& isOnScrollbar(event.getX(), event.getY())) { |
| 16153 |
awakenScrollBars(); |
| 16154 |
} |
| 16155 |
|
| 16156 |
|
| 16157 |
|
| 16158 |
if (isHoverable() || isHovered()) { |
| 16159 |
switch (action) { |
| 16160 |
case MotionEvent.ACTION_HOVER_ENTER: |
| 16161 |
setHovered(true); |
| 16162 |
break; |
| 16163 |
case MotionEvent.ACTION_HOVER_EXIT: |
| 16164 |
setHovered(false); |
| 16165 |
break; |
| 16166 |
} |
| 16167 |
|
| 16168 |
|
| 16169 |
|
| 16170 |
|
| 16171 |
|
| 16172 |
|
| 16173 |
|
| 16174 |
|
| 16175 |
dispatchGenericMotionEventInternal(event); |
| 16176 |
|
| 16177 |
|
| 16178 |
return true; |
| 16179 |
} |
| 16180 |
|
| 16181 |
return false; |
| 16182 |
} |
| 16183 |
|
| 16184 |
|
| 16185 |
|
| 16186 |
|
| 16187 |
|
| 16188 |
|
| 16189 |
|
| 16190 |
private boolean isHoverable() { |
| 16191 |
final int viewFlags = mViewFlags; |
| 16192 |
if ((viewFlags & ENABLED_MASK) == DISABLED) { |
| 16193 |
return false; |
| 16194 |
} |
| 16195 |
|
| 16196 |
return (viewFlags & CLICKABLE) == CLICKABLE |
| 16197 |
|| (viewFlags & LONG_CLICKABLE) == LONG_CLICKABLE |
| 16198 |
|| (viewFlags & CONTEXT_CLICKABLE) == CONTEXT_CLICKABLE; |
| 16199 |
} |
| 16200 |
|
| 16201 |
|
| 16202 |
|
| 16203 |
|
| 16204 |
|
| 16205 |
|
| 16206 |
|
| 16207 |
|
| 16208 |
|
| 16209 |
@ViewDebug.ExportedProperty |
| 16210 |
public boolean isHovered() { |
| 16211 |
return (mPrivateFlags & PFLAG_HOVERED) != 0; |
| 16212 |
} |
| 16213 |
|
| 16214 |
|
| 16215 |
|
| 16216 |
|
| 16217 |
|
| 16218 |
|
| 16219 |
|
| 16220 |
|
| 16221 |
|
| 16222 |
|
| 16223 |
|
| 16224 |
|
| 16225 |
|
| 16226 |
|
| 16227 |
|
| 16228 |
|
| 16229 |
public void setHovered(boolean hovered) { |
| 16230 |
if (hovered) { |
| 16231 |
if ((mPrivateFlags & PFLAG_HOVERED) == 0) { |
| 16232 |
mPrivateFlags |= PFLAG_HOVERED; |
| 16233 |
refreshDrawableState(); |
| 16234 |
onHoverChanged(true); |
| 16235 |
} |
| 16236 |
} else { |
| 16237 |
if ((mPrivateFlags & PFLAG_HOVERED) != 0) { |
| 16238 |
mPrivateFlags &= ~PFLAG_HOVERED; |
| 16239 |
refreshDrawableState(); |
| 16240 |
onHoverChanged(false); |
| 16241 |
} |
| 16242 |
} |
| 16243 |
} |
| 16244 |
|
| 16245 |
|
| 16246 |
|
| 16247 |
|
| 16248 |
|
| 16249 |
|
| 16250 |
|
| 16251 |
|
| 16252 |
|
| 16253 |
|
| 16254 |
|
| 16255 |
|
| 16256 |
|
| 16257 |
public void onHoverChanged(boolean hovered) { |
| 16258 |
} |
| 16259 |
|
| 16260 |
|
| 16261 |
|
| 16262 |
|
| 16263 |
|
| 16264 |
|
| 16265 |
|
| 16266 |
|
| 16267 |
|
| 16268 |
protected boolean handleScrollBarDragging(MotionEvent event) { |
| 16269 |
if (mScrollCache == null) { |
| 16270 |
return false; |
| 16271 |
} |
| 16272 |
final float x = event.getX(); |
| 16273 |
final float y = event.getY(); |
| 16274 |
final int action = event.getAction(); |
| 16275 |
if ((mScrollCache.mScrollBarDraggingState == ScrollabilityCache.NOT_DRAGGING |
| 16276 |
&& action != MotionEvent.ACTION_DOWN) |
| 16277 |
|| !event.isFromSource(InputDevice.SOURCE_MOUSE) |
| 16278 |
|| !event.isButtonPressed(MotionEvent.BUTTON_PRIMARY)) { |
| 16279 |
mScrollCache.mScrollBarDraggingState = ScrollabilityCache.NOT_DRAGGING; |
| 16280 |
return false; |
| 16281 |
} |
| 16282 |
|
| 16283 |
switch (action) { |
| 16284 |
case MotionEvent.ACTION_MOVE: |
| 16285 |
if (mScrollCache.mScrollBarDraggingState == ScrollabilityCache.NOT_DRAGGING) { |
| 16286 |
return false; |
| 16287 |
} |
| 16288 |
if (mScrollCache.mScrollBarDraggingState |
| 16289 |
== ScrollabilityCache.DRAGGING_VERTICAL_SCROLL_BAR) { |
| 16290 |
final Rect bounds = mScrollCache.mScrollBarBounds; |
| 16291 |
getVerticalScrollBarBounds(bounds, null); |
| 16292 |
final int range = computeVerticalScrollRange(); |
| 16293 |
final int offset = computeVerticalScrollOffset(); |
| 16294 |
final int extent = computeVerticalScrollExtent(); |
| 16295 |
|
| 16296 |
final int thumbLength = ScrollBarUtils.getThumbLength( |
| 16297 |
bounds.height(), bounds.width(), extent, range); |
| 16298 |
final int thumbOffset = ScrollBarUtils.getThumbOffset( |
| 16299 |
bounds.height(), thumbLength, extent, range, offset); |
| 16300 |
|
| 16301 |
final float diff = y - mScrollCache.mScrollBarDraggingPos; |
| 16302 |
final float maxThumbOffset = bounds.height() - thumbLength; |
| 16303 |
final float newThumbOffset = |
| 16304 |
Math.min(Math.max(thumbOffset + diff, 0.0f), maxThumbOffset); |
| 16305 |
final int height = getHeight(); |
| 16306 |
if (Math.round(newThumbOffset) != thumbOffset && maxThumbOffset > 0 |
| 16307 |
&& height > 0 && extent > 0) { |
| 16308 |
final int newY = Math.round((range - extent) |
| 16309 |
/ ((float)extent / height) * (newThumbOffset / maxThumbOffset)); |
| 16310 |
if (newY != getScrollY()) { |
| 16311 |
mScrollCache.mScrollBarDraggingPos = y; |
| 16312 |
setScrollY(newY); |
| 16313 |
} |
| 16314 |
} |
| 16315 |
return true; |
| 16316 |
} |
| 16317 |
if (mScrollCache.mScrollBarDraggingState |
| 16318 |
== ScrollabilityCache.DRAGGING_HORIZONTAL_SCROLL_BAR) { |
| 16319 |
final Rect bounds = mScrollCache.mScrollBarBounds; |
| 16320 |
getHorizontalScrollBarBounds(bounds, null); |
| 16321 |
final int range = computeHorizontalScrollRange(); |
| 16322 |
final int offset = computeHorizontalScrollOffset(); |
| 16323 |
final int extent = computeHorizontalScrollExtent(); |
| 16324 |
|
| 16325 |
final int thumbLength = ScrollBarUtils.getThumbLength( |
| 16326 |
bounds.width(), bounds.height(), extent, range); |
| 16327 |
final int thumbOffset = ScrollBarUtils.getThumbOffset( |
| 16328 |
bounds.width(), thumbLength, extent, range, offset); |
| 16329 |
|
| 16330 |
final float diff = x - mScrollCache.mScrollBarDraggingPos; |
| 16331 |
final float maxThumbOffset = bounds.width() - thumbLength; |
| 16332 |
final float newThumbOffset = |
| 16333 |
Math.min(Math.max(thumbOffset + diff, 0.0f), maxThumbOffset); |
| 16334 |
final int width = getWidth(); |
| 16335 |
if (Math.round(newThumbOffset) != thumbOffset && maxThumbOffset > 0 |
| 16336 |
&& width > 0 && extent > 0) { |
| 16337 |
final int newX = Math.round((range - extent) |
| 16338 |
/ ((float)extent / width) * (newThumbOffset / maxThumbOffset)); |
| 16339 |
if (newX != getScrollX()) { |
| 16340 |
mScrollCache.mScrollBarDraggingPos = x; |
| 16341 |
setScrollX(newX); |
| 16342 |
} |
| 16343 |
} |
| 16344 |
return true; |
| 16345 |
} |
| 16346 |
case MotionEvent.ACTION_DOWN: |
| 16347 |
if (mScrollCache.state == ScrollabilityCache.OFF) { |
| 16348 |
return false; |
| 16349 |
} |
| 16350 |
if (isOnVerticalScrollbarThumb(x, y)) { |
| 16351 |
mScrollCache.mScrollBarDraggingState = |
| 16352 |
ScrollabilityCache.DRAGGING_VERTICAL_SCROLL_BAR; |
| 16353 |
mScrollCache.mScrollBarDraggingPos = y; |
| 16354 |
return true; |
| 16355 |
} |
| 16356 |
if (isOnHorizontalScrollbarThumb(x, y)) { |
| 16357 |
mScrollCache.mScrollBarDraggingState = |
| 16358 |
ScrollabilityCache.DRAGGING_HORIZONTAL_SCROLL_BAR; |
| 16359 |
mScrollCache.mScrollBarDraggingPos = x; |
| 16360 |
return true; |
| 16361 |
} |
| 16362 |
} |
| 16363 |
mScrollCache.mScrollBarDraggingState = ScrollabilityCache.NOT_DRAGGING; |
| 16364 |
return false; |
| 16365 |
} |
| 16366 |
|
| 16367 |
|
| 16368 |
|
| 16369 |
|
| 16370 |
|
| 16371 |
|
| 16372 |
|
| 16373 |
|
| 16374 |
|
| 16375 |
|
| 16376 |
|
| 16377 |
|
| 16378 |
|
| 16379 |
|
| 16380 |
|
| 16381 |
|
| 16382 |
|
| 16383 |
|
| 16384 |
public boolean onTouchEvent(MotionEvent event) { |
| 16385 |
final float x = event.getX(); |
| 16386 |
final float y = event.getY(); |
| 16387 |
final int viewFlags = mViewFlags; |
| 16388 |
final int action = event.getAction(); |
| 16389 |
|
| 16390 |
final boolean clickable = ((viewFlags & CLICKABLE) == CLICKABLE |
| 16391 |
|| (viewFlags & LONG_CLICKABLE) == LONG_CLICKABLE) |
| 16392 |
|| (viewFlags & CONTEXT_CLICKABLE) == CONTEXT_CLICKABLE; |
| 16393 |
|
| 16394 |
if ((viewFlags & ENABLED_MASK) == DISABLED |
| 16395 |
&& (mPrivateFlags4 & PFLAG4_ALLOW_CLICK_WHEN_DISABLED) == 0) { |
| 16396 |
if (action == MotionEvent.ACTION_UP && (mPrivateFlags & PFLAG_PRESSED) != 0) { |
| 16397 |
setPressed(false); |
| 16398 |
} |
| 16399 |
mPrivateFlags3 &= ~PFLAG3_FINGER_DOWN; |
| 16400 |
|
| 16401 |
|
| 16402 |
return clickable; |
| 16403 |
} |
| 16404 |
if (mTouchDelegate != null) { |
| 16405 |
if (mTouchDelegate.onTouchEvent(event)) { |
| 16406 |
return true; |
| 16407 |
} |
| 16408 |
} |
| 16409 |
|
| 16410 |
if (clickable || (viewFlags & TOOLTIP) == TOOLTIP) { |
| 16411 |
switch (action) { |
| 16412 |
case MotionEvent.ACTION_UP: |
| 16413 |
mPrivateFlags3 &= ~PFLAG3_FINGER_DOWN; |
| 16414 |
if ((viewFlags & TOOLTIP) == TOOLTIP) { |
| 16415 |
handleTooltipUp(); |
| 16416 |
} |
| 16417 |
if (!clickable) { |
| 16418 |
removeTapCallback(); |
| 16419 |
removeLongPressCallback(); |
| 16420 |
mInContextButtonPress = false; |
| 16421 |
mHasPerformedLongPress = false; |
| 16422 |
mIgnoreNextUpEvent = false; |
| 16423 |
break; |
| 16424 |
} |
| 16425 |
boolean prepressed = (mPrivateFlags & PFLAG_PREPRESSED) != 0; |
| 16426 |
if ((mPrivateFlags & PFLAG_PRESSED) != 0 || prepressed) { |
| 16427 |
|
| 16428 |
|
| 16429 |
boolean focusTaken = false; |
| 16430 |
if (isFocusable() && isFocusableInTouchMode() && !isFocused()) { |
| 16431 |
focusTaken = requestFocus(); |
| 16432 |
} |
| 16433 |
|
| 16434 |
if (prepressed) { |
| 16435 |
|
| 16436 |
|
| 16437 |
|
| 16438 |
|
| 16439 |
setPressed(true, x, y); |
| 16440 |
} |
| 16441 |
|
| 16442 |
if (!mHasPerformedLongPress && !mIgnoreNextUpEvent) { |
| 16443 |
|
| 16444 |
removeLongPressCallback(); |
| 16445 |
|
| 16446 |
|
| 16447 |
if (!focusTaken) { |
| 16448 |
|
| 16449 |
|
| 16450 |
|
| 16451 |
if (mPerformClick == null) { |
| 16452 |
mPerformClick = new PerformClick(); |
| 16453 |
} |
| 16454 |
if (!post(mPerformClick)) { |
| 16455 |
performClickInternal(); |
| 16456 |
} |
| 16457 |
} |
| 16458 |
} |
| 16459 |
|
| 16460 |
if (mUnsetPressedState == null) { |
| 16461 |
mUnsetPressedState = new UnsetPressedState(); |
| 16462 |
} |
| 16463 |
|
| 16464 |
if (prepressed) { |
| 16465 |
postDelayed(mUnsetPressedState, |
| 16466 |
ViewConfiguration.getPressedStateDuration()); |
| 16467 |
} else if (!post(mUnsetPressedState)) { |
| 16468 |
|
| 16469 |
mUnsetPressedState.run(); |
| 16470 |
} |
| 16471 |
|
| 16472 |
removeTapCallback(); |
| 16473 |
} |
| 16474 |
mIgnoreNextUpEvent = false; |
| 16475 |
break; |
| 16476 |
|
| 16477 |
case MotionEvent.ACTION_DOWN: |
| 16478 |
if (event.getSource() == InputDevice.SOURCE_TOUCHSCREEN) { |
| 16479 |
mPrivateFlags3 |= PFLAG3_FINGER_DOWN; |
| 16480 |
} |
| 16481 |
mHasPerformedLongPress = false; |
| 16482 |
|
| 16483 |
if (!clickable) { |
| 16484 |
checkForLongClick( |
| 16485 |
ViewConfiguration.getLongPressTimeout(), |
| 16486 |
x, |
| 16487 |
y, |
| 16488 |
TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); |
| 16489 |
break; |
| 16490 |
} |
| 16491 |
|
| 16492 |
if (performButtonActionOnTouchDown(event)) { |
| 16493 |
break; |
| 16494 |
} |
| 16495 |
|
| 16496 |
|
| 16497 |
boolean isInScrollingContainer = isInScrollingContainer(); |
| 16498 |
|
| 16499 |
|
| 16500 |
|
| 16501 |
if (isInScrollingContainer) { |
| 16502 |
mPrivateFlags |= PFLAG_PREPRESSED; |
| 16503 |
if (mPendingCheckForTap == null) { |
| 16504 |
mPendingCheckForTap = new CheckForTap(); |
| 16505 |
} |
| 16506 |
mPendingCheckForTap.x = event.getX(); |
| 16507 |
mPendingCheckForTap.y = event.getY(); |
| 16508 |
postDelayed(mPendingCheckForTap, ViewConfiguration.getTapTimeout()); |
| 16509 |
} else { |
| 16510 |
|
| 16511 |
setPressed(true, x, y); |
| 16512 |
checkForLongClick( |
| 16513 |
ViewConfiguration.getLongPressTimeout(), |
| 16514 |
x, |
| 16515 |
y, |
| 16516 |
TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); |
| 16517 |
} |
| 16518 |
break; |
| 16519 |
|
| 16520 |
case MotionEvent.ACTION_CANCEL: |
| 16521 |
if (clickable) { |
| 16522 |
setPressed(false); |
| 16523 |
} |
| 16524 |
removeTapCallback(); |
| 16525 |
removeLongPressCallback(); |
| 16526 |
mInContextButtonPress = false; |
| 16527 |
mHasPerformedLongPress = false; |
| 16528 |
mIgnoreNextUpEvent = false; |
| 16529 |
mPrivateFlags3 &= ~PFLAG3_FINGER_DOWN; |
| 16530 |
break; |
| 16531 |
|
| 16532 |
case MotionEvent.ACTION_MOVE: |
| 16533 |
if (clickable) { |
| 16534 |
drawableHotspotChanged(x, y); |
| 16535 |
} |
| 16536 |
|
| 16537 |
final int motionClassification = event.getClassification(); |
| 16538 |
final boolean ambiguousGesture = |
| 16539 |
motionClassification == MotionEvent.CLASSIFICATION_AMBIGUOUS_GESTURE; |
| 16540 |
int touchSlop = mTouchSlop; |
| 16541 |
if (ambiguousGesture && hasPendingLongPressCallback()) { |
| 16542 |
if (!pointInView(x, y, touchSlop)) { |
| 16543 |
|
| 16544 |
|
| 16545 |
|
| 16546 |
removeLongPressCallback(); |
| 16547 |
long delay = (long) (ViewConfiguration.getLongPressTimeout() |
| 16548 |
* mAmbiguousGestureMultiplier); |
| 16549 |
|
| 16550 |
delay -= event.getEventTime() - event.getDownTime(); |
| 16551 |
checkForLongClick( |
| 16552 |
delay, |
| 16553 |
x, |
| 16554 |
y, |
| 16555 |
TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); |
| 16556 |
} |
| 16557 |
touchSlop *= mAmbiguousGestureMultiplier; |
| 16558 |
} |
| 16559 |
|
| 16560 |
|
| 16561 |
if (!pointInView(x, y, touchSlop)) { |
| 16562 |
|
| 16563 |
|
| 16564 |
removeTapCallback(); |
| 16565 |
removeLongPressCallback(); |
| 16566 |
if ((mPrivateFlags & PFLAG_PRESSED) != 0) { |
| 16567 |
setPressed(false); |
| 16568 |
} |
| 16569 |
mPrivateFlags3 &= ~PFLAG3_FINGER_DOWN; |
| 16570 |
} |
| 16571 |
|
| 16572 |
final boolean deepPress = |
| 16573 |
motionClassification == MotionEvent.CLASSIFICATION_DEEP_PRESS; |
| 16574 |
if (deepPress && hasPendingLongPressCallback()) { |
| 16575 |
|
| 16576 |
removeLongPressCallback(); |
| 16577 |
checkForLongClick( |
| 16578 |
0 , |
| 16579 |
x, |
| 16580 |
y, |
| 16581 |
TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__DEEP_PRESS); |
| 16582 |
} |
| 16583 |
|
| 16584 |
break; |
| 16585 |
} |
| 16586 |
|
| 16587 |
return true; |
| 16588 |
} |
| 16589 |
|
| 16590 |
return false; |
| 16591 |
} |
| 16592 |
|
| 16593 |
|
| 16594 |
|
| 16595 |
|
| 16596 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 16597 |
public boolean isInScrollingContainer() { |
| 16598 |
ViewParent p = getParent(); |
| 16599 |
while (p != null && p instanceof ViewGroup) { |
| 16600 |
if (((ViewGroup) p).shouldDelayChildPressedState()) { |
| 16601 |
return true; |
| 16602 |
} |
| 16603 |
p = p.getParent(); |
| 16604 |
} |
| 16605 |
return false; |
| 16606 |
} |
| 16607 |
|
| 16608 |
|
| 16609 |
|
| 16610 |
|
| 16611 |
private void removeLongPressCallback() { |
| 16612 |
if (mPendingCheckForLongPress != null) { |
| 16613 |
removeCallbacks(mPendingCheckForLongPress); |
| 16614 |
} |
| 16615 |
} |
| 16616 |
|
| 16617 |
|
| 16618 |
|
| 16619 |
|
| 16620 |
|
| 16621 |
private boolean hasPendingLongPressCallback() { |
| 16622 |
if (mPendingCheckForLongPress == null) { |
| 16623 |
return false; |
| 16624 |
} |
| 16625 |
final AttachInfo attachInfo = mAttachInfo; |
| 16626 |
if (attachInfo == null) { |
| 16627 |
return false; |
| 16628 |
} |
| 16629 |
return attachInfo.mHandler.hasCallbacks(mPendingCheckForLongPress); |
| 16630 |
} |
| 16631 |
|
| 16632 |
|
| 16633 |
|
| 16634 |
|
| 16635 |
@UnsupportedAppUsage |
| 16636 |
private void removePerformClickCallback() { |
| 16637 |
if (mPerformClick != null) { |
| 16638 |
removeCallbacks(mPerformClick); |
| 16639 |
} |
| 16640 |
} |
| 16641 |
|
| 16642 |
|
| 16643 |
|
| 16644 |
|
| 16645 |
private void removeUnsetPressCallback() { |
| 16646 |
if ((mPrivateFlags & PFLAG_PRESSED) != 0 && mUnsetPressedState != null) { |
| 16647 |
setPressed(false); |
| 16648 |
removeCallbacks(mUnsetPressedState); |
| 16649 |
} |
| 16650 |
} |
| 16651 |
|
| 16652 |
|
| 16653 |
|
| 16654 |
|
| 16655 |
private void removeTapCallback() { |
| 16656 |
if (mPendingCheckForTap != null) { |
| 16657 |
mPrivateFlags &= ~PFLAG_PREPRESSED; |
| 16658 |
removeCallbacks(mPendingCheckForTap); |
| 16659 |
} |
| 16660 |
} |
| 16661 |
|
| 16662 |
|
| 16663 |
|
| 16664 |
|
| 16665 |
|
| 16666 |
|
| 16667 |
|
| 16668 |
public void cancelLongPress() { |
| 16669 |
removeLongPressCallback(); |
| 16670 |
|
| 16671 |
|
| 16672 |
|
| 16673 |
|
| 16674 |
|
| 16675 |
|
| 16676 |
removeTapCallback(); |
| 16677 |
} |
| 16678 |
|
| 16679 |
|
| 16680 |
|
| 16681 |
|
| 16682 |
public void setTouchDelegate(TouchDelegate delegate) { |
| 16683 |
mTouchDelegate = delegate; |
| 16684 |
} |
| 16685 |
|
| 16686 |
|
| 16687 |
|
| 16688 |
|
| 16689 |
public TouchDelegate getTouchDelegate() { |
| 16690 |
return mTouchDelegate; |
| 16691 |
} |
| 16692 |
|
| 16693 |
|
| 16694 |
|
| 16695 |
|
| 16696 |
|
| 16697 |
|
| 16698 |
|
| 16699 |
|
| 16700 |
|
| 16701 |
|
| 16702 |
|
| 16703 |
|
| 16704 |
|
| 16705 |
|
| 16706 |
|
| 16707 |
|
| 16708 |
|
| 16709 |
|
| 16710 |
|
| 16711 |
|
| 16712 |
public final void requestUnbufferedDispatch(MotionEvent event) { |
| 16713 |
final int action = event.getAction(); |
| 16714 |
if (mAttachInfo == null |
| 16715 |
|| action != MotionEvent.ACTION_DOWN && action != MotionEvent.ACTION_MOVE |
| 16716 |
|| !event.isTouchEvent()) { |
| 16717 |
return; |
| 16718 |
} |
| 16719 |
mAttachInfo.mUnbufferedDispatchRequested = true; |
| 16720 |
} |
| 16721 |
|
| 16722 |
|
| 16723 |
|
| 16724 |
|
| 16725 |
|
| 16726 |
|
| 16727 |
|
| 16728 |
|
| 16729 |
|
| 16730 |
|
| 16731 |
|
| 16732 |
|
| 16733 |
public final void requestUnbufferedDispatch(@InputSourceClass int source) { |
| 16734 |
if (mUnbufferedInputSource == source) { |
| 16735 |
return; |
| 16736 |
} |
| 16737 |
mUnbufferedInputSource = source; |
| 16738 |
if (mParent != null) { |
| 16739 |
mParent.onDescendantUnbufferedRequested(); |
| 16740 |
} |
| 16741 |
} |
| 16742 |
|
| 16743 |
private boolean hasSize() { |
| 16744 |
return (mBottom > mTop) && (mRight > mLeft); |
| 16745 |
} |
| 16746 |
|
| 16747 |
private boolean canTakeFocus() { |
| 16748 |
return ((mViewFlags & VISIBILITY_MASK) == VISIBLE) |
| 16749 |
&& ((mViewFlags & FOCUSABLE) == FOCUSABLE) |
| 16750 |
&& ((mViewFlags & ENABLED_MASK) == ENABLED) |
| 16751 |
&& (sCanFocusZeroSized || !isLayoutValid() || hasSize()); |
| 16752 |
} |
| 16753 |
|
| 16754 |
|
| 16755 |
|
| 16756 |
|
| 16757 |
|
| 16758 |
|
| 16759 |
|
| 16760 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
| 16761 |
void setFlags(int flags, int mask) { |
| 16762 |
final boolean accessibilityEnabled = |
| 16763 |
AccessibilityManager.getInstance(mContext).isEnabled(); |
| 16764 |
final boolean oldIncludeForAccessibility = accessibilityEnabled && includeForAccessibility(); |
| 16765 |
|
| 16766 |
int old = mViewFlags; |
| 16767 |
mViewFlags = (mViewFlags & ~mask) | (flags & mask); |
| 16768 |
|
| 16769 |
int changed = mViewFlags ^ old; |
| 16770 |
if (changed == 0) { |
| 16771 |
return; |
| 16772 |
} |
| 16773 |
int privateFlags = mPrivateFlags; |
| 16774 |
boolean shouldNotifyFocusableAvailable = false; |
| 16775 |
|
| 16776 |
|
| 16777 |
int focusableChangedByAuto = 0; |
| 16778 |
if (((mViewFlags & FOCUSABLE_AUTO) != 0) |
| 16779 |
&& (changed & (FOCUSABLE_MASK | CLICKABLE)) != 0) { |
| 16780 |
|
| 16781 |
final int newFocus; |
| 16782 |
if ((mViewFlags & CLICKABLE) != 0) { |
| 16783 |
newFocus = FOCUSABLE; |
| 16784 |
} else { |
| 16785 |
newFocus = NOT_FOCUSABLE; |
| 16786 |
} |
| 16787 |
mViewFlags = (mViewFlags & ~FOCUSABLE) | newFocus; |
| 16788 |
focusableChangedByAuto = (old & FOCUSABLE) ^ (newFocus & FOCUSABLE); |
| 16789 |
changed = (changed & ~FOCUSABLE) | focusableChangedByAuto; |
| 16790 |
} |
| 16791 |
|
| 16792 |
|
| 16793 |
if (((changed & FOCUSABLE) != 0) && ((privateFlags & PFLAG_HAS_BOUNDS) != 0)) { |
| 16794 |
if (((old & FOCUSABLE) == FOCUSABLE) |
| 16795 |
&& ((privateFlags & PFLAG_FOCUSED) != 0)) { |
| 16796 |
|
| 16797 |
clearFocus(); |
| 16798 |
if (mParent instanceof ViewGroup) { |
| 16799 |
((ViewGroup) mParent).clearFocusedInCluster(); |
| 16800 |
} |
| 16801 |
} else if (((old & FOCUSABLE) == NOT_FOCUSABLE) |
| 16802 |
&& ((privateFlags & PFLAG_FOCUSED) == 0)) { |
| 16803 |
|
| 16804 |
|
| 16805 |
|
| 16806 |
|
| 16807 |
if (mParent != null) { |
| 16808 |
ViewRootImpl viewRootImpl = getViewRootImpl(); |
| 16809 |
if (!sAutoFocusableOffUIThreadWontNotifyParents |
| 16810 |
|| focusableChangedByAuto == 0 |
| 16811 |
|| viewRootImpl == null |
| 16812 |
|| viewRootImpl.mThread == Thread.currentThread()) { |
| 16813 |
shouldNotifyFocusableAvailable = canTakeFocus(); |
| 16814 |
} |
| 16815 |
} |
| 16816 |
} |
| 16817 |
} |
| 16818 |
|
| 16819 |
final int newVisibility = flags & VISIBILITY_MASK; |
| 16820 |
if (newVisibility == VISIBLE) { |
| 16821 |
if ((changed & VISIBILITY_MASK) != 0) { |
| 16822 |
|
| 16823 |
|
| 16824 |
|
| 16825 |
|
| 16826 |
|
| 16827 |
mPrivateFlags |= PFLAG_DRAWN; |
| 16828 |
invalidate(true); |
| 16829 |
|
| 16830 |
needGlobalAttributesUpdate(true); |
| 16831 |
|
| 16832 |
|
| 16833 |
|
| 16834 |
|
| 16835 |
shouldNotifyFocusableAvailable = hasSize(); |
| 16836 |
} |
| 16837 |
} |
| 16838 |
|
| 16839 |
if ((changed & ENABLED_MASK) != 0) { |
| 16840 |
if ((mViewFlags & ENABLED_MASK) == ENABLED) { |
| 16841 |
|
| 16842 |
|
| 16843 |
|
| 16844 |
shouldNotifyFocusableAvailable = canTakeFocus(); |
| 16845 |
} else { |
| 16846 |
if (isFocused()) clearFocus(); |
| 16847 |
} |
| 16848 |
} |
| 16849 |
|
| 16850 |
if (shouldNotifyFocusableAvailable && mParent != null) { |
| 16851 |
mParent.focusableViewAvailable(this); |
| 16852 |
} |
| 16853 |
|
| 16854 |
|
| 16855 |
if ((changed & GONE) != 0) { |
| 16856 |
needGlobalAttributesUpdate(false); |
| 16857 |
requestLayout(); |
| 16858 |
|
| 16859 |
if (((mViewFlags & VISIBILITY_MASK) == GONE)) { |
| 16860 |
if (hasFocus()) { |
| 16861 |
clearFocus(); |
| 16862 |
if (mParent instanceof ViewGroup) { |
| 16863 |
((ViewGroup) mParent).clearFocusedInCluster(); |
| 16864 |
} |
| 16865 |
} |
| 16866 |
clearAccessibilityFocus(); |
| 16867 |
destroyDrawingCache(); |
| 16868 |
if (mParent instanceof View) { |
| 16869 |
|
| 16870 |
((View) mParent).invalidate(true); |
| 16871 |
} |
| 16872 |
|
| 16873 |
|
| 16874 |
mPrivateFlags |= PFLAG_DRAWN; |
| 16875 |
} |
| 16876 |
if (mAttachInfo != null) { |
| 16877 |
mAttachInfo.mViewVisibilityChanged = true; |
| 16878 |
} |
| 16879 |
} |
| 16880 |
|
| 16881 |
|
| 16882 |
if ((changed & INVISIBLE) != 0) { |
| 16883 |
needGlobalAttributesUpdate(false); |
| 16884 |
|
| 16885 |
|
| 16886 |
|
| 16887 |
|
| 16888 |
mPrivateFlags |= PFLAG_DRAWN; |
| 16889 |
|
| 16890 |
if (((mViewFlags & VISIBILITY_MASK) == INVISIBLE)) { |
| 16891 |
|
| 16892 |
if (getRootView() != this) { |
| 16893 |
if (hasFocus()) { |
| 16894 |
clearFocus(); |
| 16895 |
if (mParent instanceof ViewGroup) { |
| 16896 |
((ViewGroup) mParent).clearFocusedInCluster(); |
| 16897 |
} |
| 16898 |
} |
| 16899 |
clearAccessibilityFocus(); |
| 16900 |
} |
| 16901 |
} |
| 16902 |
if (mAttachInfo != null) { |
| 16903 |
mAttachInfo.mViewVisibilityChanged = true; |
| 16904 |
} |
| 16905 |
} |
| 16906 |
|
| 16907 |
if ((changed & VISIBILITY_MASK) != 0) { |
| 16908 |
|
| 16909 |
if (newVisibility != VISIBLE && mAttachInfo != null) { |
| 16910 |
cleanupDraw(); |
| 16911 |
} |
| 16912 |
|
| 16913 |
if (mParent instanceof ViewGroup) { |
| 16914 |
ViewGroup parent = (ViewGroup) mParent; |
| 16915 |
parent.onChildVisibilityChanged(this, (changed & VISIBILITY_MASK), |
| 16916 |
newVisibility); |
| 16917 |
parent.invalidate(true); |
| 16918 |
} else if (mParent != null) { |
| 16919 |
mParent.invalidateChild(this, null); |
| 16920 |
} |
| 16921 |
|
| 16922 |
if (mAttachInfo != null) { |
| 16923 |
dispatchVisibilityChanged(this, newVisibility); |
| 16924 |
|
| 16925 |
|
| 16926 |
|
| 16927 |
|
| 16928 |
|
| 16929 |
|
| 16930 |
if (mParent != null && getWindowVisibility() == VISIBLE && |
| 16931 |
((!(mParent instanceof ViewGroup)) || ((ViewGroup) mParent).isShown())) { |
| 16932 |
dispatchVisibilityAggregated(newVisibility == VISIBLE); |
| 16933 |
} |
| 16934 |
|
| 16935 |
|
| 16936 |
if ((old & VISIBILITY_MASK) == VISIBLE) { |
| 16937 |
notifySubtreeAccessibilityStateChangedByParentIfNeeded(); |
| 16938 |
} else { |
| 16939 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 16940 |
} |
| 16941 |
} |
| 16942 |
} |
| 16943 |
|
| 16944 |
if ((changed & WILL_NOT_CACHE_DRAWING) != 0) { |
| 16945 |
destroyDrawingCache(); |
| 16946 |
} |
| 16947 |
|
| 16948 |
if ((changed & DRAWING_CACHE_ENABLED) != 0) { |
| 16949 |
destroyDrawingCache(); |
| 16950 |
mPrivateFlags &= ~PFLAG_DRAWING_CACHE_VALID; |
| 16951 |
invalidateParentCaches(); |
| 16952 |
} |
| 16953 |
|
| 16954 |
if ((changed & DRAWING_CACHE_QUALITY_MASK) != 0) { |
| 16955 |
destroyDrawingCache(); |
| 16956 |
mPrivateFlags &= ~PFLAG_DRAWING_CACHE_VALID; |
| 16957 |
} |
| 16958 |
|
| 16959 |
if ((changed & DRAW_MASK) != 0) { |
| 16960 |
if ((mViewFlags & WILL_NOT_DRAW) != 0) { |
| 16961 |
if (mBackground != null |
| 16962 |
|| mDefaultFocusHighlight != null |
| 16963 |
|| (mForegroundInfo != null && mForegroundInfo.mDrawable != null)) { |
| 16964 |
mPrivateFlags &= ~PFLAG_SKIP_DRAW; |
| 16965 |
} else { |
| 16966 |
mPrivateFlags |= PFLAG_SKIP_DRAW; |
| 16967 |
} |
| 16968 |
} else { |
| 16969 |
mPrivateFlags &= ~PFLAG_SKIP_DRAW; |
| 16970 |
} |
| 16971 |
requestLayout(); |
| 16972 |
invalidate(true); |
| 16973 |
} |
| 16974 |
|
| 16975 |
if ((changed & KEEP_SCREEN_ON) != 0) { |
| 16976 |
if (mParent != null && mAttachInfo != null && !mAttachInfo.mRecomputeGlobalAttributes) { |
| 16977 |
mParent.recomputeViewAttributes(this); |
| 16978 |
} |
| 16979 |
} |
| 16980 |
|
| 16981 |
if (accessibilityEnabled) { |
| 16982 |
|
| 16983 |
|
| 16984 |
if (isAccessibilityPane()) { |
| 16985 |
changed &= ~VISIBILITY_MASK; |
| 16986 |
} |
| 16987 |
if ((changed & FOCUSABLE) != 0 || (changed & VISIBILITY_MASK) != 0 |
| 16988 |
|| (changed & CLICKABLE) != 0 || (changed & LONG_CLICKABLE) != 0 |
| 16989 |
|| (changed & CONTEXT_CLICKABLE) != 0) { |
| 16990 |
if (oldIncludeForAccessibility != includeForAccessibility()) { |
| 16991 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 16992 |
} else { |
| 16993 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 16994 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 16995 |
} |
| 16996 |
} else if ((changed & ENABLED_MASK) != 0) { |
| 16997 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 16998 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 16999 |
} |
| 17000 |
} |
| 17001 |
} |
| 17002 |
|
| 17003 |
|
| 17004 |
|
| 17005 |
|
| 17006 |
|
| 17007 |
|
| 17008 |
|
| 17009 |
|
| 17010 |
|
| 17011 |
|
| 17012 |
|
| 17013 |
|
| 17014 |
public void bringToFront() { |
| 17015 |
if (mParent != null) { |
| 17016 |
mParent.bringChildToFront(this); |
| 17017 |
} |
| 17018 |
} |
| 17019 |
|
| 17020 |
|
| 17021 |
|
| 17022 |
|
| 17023 |
|
| 17024 |
|
| 17025 |
|
| 17026 |
|
| 17027 |
|
| 17028 |
|
| 17029 |
|
| 17030 |
|
| 17031 |
protected void onScrollChanged(int l, int t, int oldl, int oldt) { |
| 17032 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 17033 |
postSendViewScrolledAccessibilityEventCallback(l - oldl, t - oldt); |
| 17034 |
|
| 17035 |
mBackgroundSizeChanged = true; |
| 17036 |
mDefaultFocusHighlightSizeChanged = true; |
| 17037 |
if (mForegroundInfo != null) { |
| 17038 |
mForegroundInfo.mBoundsChanged = true; |
| 17039 |
} |
| 17040 |
|
| 17041 |
final AttachInfo ai = mAttachInfo; |
| 17042 |
if (ai != null) { |
| 17043 |
ai.mViewScrollChanged = true; |
| 17044 |
} |
| 17045 |
|
| 17046 |
if (mListenerInfo != null && mListenerInfo.mOnScrollChangeListener != null) { |
| 17047 |
mListenerInfo.mOnScrollChangeListener.onScrollChange(this, l, t, oldl, oldt); |
| 17048 |
} |
| 17049 |
} |
| 17050 |
|
| 17051 |
|
| 17052 |
|
| 17053 |
|
| 17054 |
|
| 17055 |
|
| 17056 |
|
| 17057 |
|
| 17058 |
|
| 17059 |
|
| 17060 |
|
| 17061 |
|
| 17062 |
|
| 17063 |
public interface OnScrollChangeListener { |
| 17064 |
|
| 17065 |
|
| 17066 |
|
| 17067 |
|
| 17068 |
|
| 17069 |
|
| 17070 |
|
| 17071 |
|
| 17072 |
|
| 17073 |
void onScrollChange(View v, int scrollX, int scrollY, int oldScrollX, int oldScrollY); |
| 17074 |
} |
| 17075 |
|
| 17076 |
|
| 17077 |
|
| 17078 |
|
| 17079 |
|
| 17080 |
public interface OnLayoutChangeListener { |
| 17081 |
|
| 17082 |
|
| 17083 |
|
| 17084 |
|
| 17085 |
|
| 17086 |
|
| 17087 |
|
| 17088 |
|
| 17089 |
|
| 17090 |
|
| 17091 |
|
| 17092 |
|
| 17093 |
|
| 17094 |
void onLayoutChange(View v, int left, int top, int right, int bottom, |
| 17095 |
int oldLeft, int oldTop, int oldRight, int oldBottom); |
| 17096 |
} |
| 17097 |
|
| 17098 |
|
| 17099 |
|
| 17100 |
|
| 17101 |
|
| 17102 |
|
| 17103 |
|
| 17104 |
|
| 17105 |
|
| 17106 |
|
| 17107 |
|
| 17108 |
protected void onSizeChanged(int w, int h, int oldw, int oldh) { |
| 17109 |
} |
| 17110 |
|
| 17111 |
|
| 17112 |
|
| 17113 |
|
| 17114 |
|
| 17115 |
|
| 17116 |
|
| 17117 |
protected void dispatchDraw(Canvas canvas) { |
| 17118 |
|
| 17119 |
} |
| 17120 |
|
| 17121 |
|
| 17122 |
|
| 17123 |
|
| 17124 |
|
| 17125 |
|
| 17126 |
|
| 17127 |
public final ViewParent getParent() { |
| 17128 |
return mParent; |
| 17129 |
} |
| 17130 |
|
| 17131 |
|
| 17132 |
|
| 17133 |
|
| 17134 |
|
| 17135 |
|
| 17136 |
|
| 17137 |
public void setScrollX(int value) { |
| 17138 |
scrollTo(value, mScrollY); |
| 17139 |
} |
| 17140 |
|
| 17141 |
|
| 17142 |
|
| 17143 |
|
| 17144 |
|
| 17145 |
|
| 17146 |
|
| 17147 |
public void setScrollY(int value) { |
| 17148 |
scrollTo(mScrollX, value); |
| 17149 |
} |
| 17150 |
|
| 17151 |
|
| 17152 |
|
| 17153 |
|
| 17154 |
|
| 17155 |
|
| 17156 |
|
| 17157 |
|
| 17158 |
|
| 17159 |
@InspectableProperty |
| 17160 |
public final int getScrollX() { |
| 17161 |
return mScrollX; |
| 17162 |
} |
| 17163 |
|
| 17164 |
|
| 17165 |
|
| 17166 |
|
| 17167 |
|
| 17168 |
|
| 17169 |
|
| 17170 |
|
| 17171 |
@InspectableProperty |
| 17172 |
public final int getScrollY() { |
| 17173 |
return mScrollY; |
| 17174 |
} |
| 17175 |
|
| 17176 |
|
| 17177 |
|
| 17178 |
|
| 17179 |
|
| 17180 |
|
| 17181 |
@ViewDebug.ExportedProperty(category = "layout") |
| 17182 |
public final int getWidth() { |
| 17183 |
return mRight - mLeft; |
| 17184 |
} |
| 17185 |
|
| 17186 |
|
| 17187 |
|
| 17188 |
|
| 17189 |
|
| 17190 |
|
| 17191 |
@ViewDebug.ExportedProperty(category = "layout") |
| 17192 |
public final int getHeight() { |
| 17193 |
return mBottom - mTop; |
| 17194 |
} |
| 17195 |
|
| 17196 |
|
| 17197 |
|
| 17198 |
|
| 17199 |
|
| 17200 |
|
| 17201 |
|
| 17202 |
|
| 17203 |
|
| 17204 |
|
| 17205 |
public void getDrawingRect(Rect outRect) { |
| 17206 |
outRect.left = mScrollX; |
| 17207 |
outRect.top = mScrollY; |
| 17208 |
outRect.right = mScrollX + (mRight - mLeft); |
| 17209 |
outRect.bottom = mScrollY + (mBottom - mTop); |
| 17210 |
} |
| 17211 |
|
| 17212 |
|
| 17213 |
|
| 17214 |
|
| 17215 |
|
| 17216 |
|
| 17217 |
|
| 17218 |
|
| 17219 |
public final int getMeasuredWidth() { |
| 17220 |
return mMeasuredWidth & MEASURED_SIZE_MASK; |
| 17221 |
} |
| 17222 |
|
| 17223 |
|
| 17224 |
|
| 17225 |
|
| 17226 |
|
| 17227 |
|
| 17228 |
|
| 17229 |
|
| 17230 |
|
| 17231 |
|
| 17232 |
@ViewDebug.ExportedProperty(category = "measurement", flagMapping = { |
| 17233 |
@ViewDebug.FlagToString(mask = MEASURED_STATE_MASK, equals = MEASURED_STATE_TOO_SMALL, |
| 17234 |
name = "MEASURED_STATE_TOO_SMALL"), |
| 17235 |
}) |
| 17236 |
public final int getMeasuredWidthAndState() { |
| 17237 |
return mMeasuredWidth; |
| 17238 |
} |
| 17239 |
|
| 17240 |
|
| 17241 |
|
| 17242 |
|
| 17243 |
|
| 17244 |
|
| 17245 |
|
| 17246 |
|
| 17247 |
public final int getMeasuredHeight() { |
| 17248 |
return mMeasuredHeight & MEASURED_SIZE_MASK; |
| 17249 |
} |
| 17250 |
|
| 17251 |
|
| 17252 |
|
| 17253 |
|
| 17254 |
|
| 17255 |
|
| 17256 |
|
| 17257 |
|
| 17258 |
|
| 17259 |
|
| 17260 |
@ViewDebug.ExportedProperty(category = "measurement", flagMapping = { |
| 17261 |
@ViewDebug.FlagToString(mask = MEASURED_STATE_MASK, equals = MEASURED_STATE_TOO_SMALL, |
| 17262 |
name = "MEASURED_STATE_TOO_SMALL"), |
| 17263 |
}) |
| 17264 |
public final int getMeasuredHeightAndState() { |
| 17265 |
return mMeasuredHeight; |
| 17266 |
} |
| 17267 |
|
| 17268 |
|
| 17269 |
|
| 17270 |
|
| 17271 |
|
| 17272 |
|
| 17273 |
|
| 17274 |
|
| 17275 |
public final int getMeasuredState() { |
| 17276 |
return (mMeasuredWidth&MEASURED_STATE_MASK) |
| 17277 |
| ((mMeasuredHeight>>MEASURED_HEIGHT_STATE_SHIFT) |
| 17278 |
& (MEASURED_STATE_MASK>>MEASURED_HEIGHT_STATE_SHIFT)); |
| 17279 |
} |
| 17280 |
|
| 17281 |
|
| 17282 |
|
| 17283 |
|
| 17284 |
|
| 17285 |
|
| 17286 |
|
| 17287 |
|
| 17288 |
|
| 17289 |
|
| 17290 |
|
| 17291 |
|
| 17292 |
public Matrix getMatrix() { |
| 17293 |
ensureTransformationInfo(); |
| 17294 |
final Matrix matrix = mTransformationInfo.mMatrix; |
| 17295 |
mRenderNode.getMatrix(matrix); |
| 17296 |
return matrix; |
| 17297 |
} |
| 17298 |
|
| 17299 |
|
| 17300 |
|
| 17301 |
|
| 17302 |
|
| 17303 |
|
| 17304 |
|
| 17305 |
|
| 17306 |
@UnsupportedAppUsage |
| 17307 |
public final boolean hasIdentityMatrix() { |
| 17308 |
return mRenderNode.hasIdentityMatrix(); |
| 17309 |
} |
| 17310 |
|
| 17311 |
@UnsupportedAppUsage |
| 17312 |
void ensureTransformationInfo() { |
| 17313 |
if (mTransformationInfo == null) { |
| 17314 |
mTransformationInfo = new TransformationInfo(); |
| 17315 |
} |
| 17316 |
} |
| 17317 |
|
| 17318 |
|
| 17319 |
|
| 17320 |
|
| 17321 |
|
| 17322 |
|
| 17323 |
|
| 17324 |
|
| 17325 |
|
| 17326 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 17327 |
public final Matrix getInverseMatrix() { |
| 17328 |
ensureTransformationInfo(); |
| 17329 |
if (mTransformationInfo.mInverseMatrix == null) { |
| 17330 |
mTransformationInfo.mInverseMatrix = new Matrix(); |
| 17331 |
} |
| 17332 |
final Matrix matrix = mTransformationInfo.mInverseMatrix; |
| 17333 |
mRenderNode.getInverseMatrix(matrix); |
| 17334 |
return matrix; |
| 17335 |
} |
| 17336 |
|
| 17337 |
|
| 17338 |
|
| 17339 |
|
| 17340 |
|
| 17341 |
|
| 17342 |
|
| 17343 |
|
| 17344 |
public float getCameraDistance() { |
| 17345 |
final float dpi = mResources.getDisplayMetrics().densityDpi; |
| 17346 |
return mRenderNode.getCameraDistance() * dpi; |
| 17347 |
} |
| 17348 |
|
| 17349 |
|
| 17350 |
|
| 17351 |
|
| 17352 |
|
| 17353 |
|
| 17354 |
|
| 17355 |
|
| 17356 |
|
| 17357 |
|
| 17358 |
|
| 17359 |
|
| 17360 |
|
| 17361 |
|
| 17362 |
|
| 17363 |
|
| 17364 |
|
| 17365 |
|
| 17366 |
|
| 17367 |
|
| 17368 |
|
| 17369 |
|
| 17370 |
|
| 17371 |
|
| 17372 |
|
| 17373 |
|
| 17374 |
|
| 17375 |
|
| 17376 |
|
| 17377 |
|
| 17378 |
|
| 17379 |
|
| 17380 |
|
| 17381 |
|
| 17382 |
|
| 17383 |
|
| 17384 |
|
| 17385 |
|
| 17386 |
|
| 17387 |
|
| 17388 |
public void setCameraDistance(float distance) { |
| 17389 |
final float dpi = mResources.getDisplayMetrics().densityDpi; |
| 17390 |
|
| 17391 |
invalidateViewProperty(true, false); |
| 17392 |
mRenderNode.setCameraDistance(Math.abs(distance) / dpi); |
| 17393 |
invalidateViewProperty(false, false); |
| 17394 |
|
| 17395 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 17396 |
} |
| 17397 |
|
| 17398 |
|
| 17399 |
|
| 17400 |
|
| 17401 |
|
| 17402 |
|
| 17403 |
|
| 17404 |
|
| 17405 |
|
| 17406 |
|
| 17407 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17408 |
@InspectableProperty |
| 17409 |
public float getRotation() { |
| 17410 |
return mRenderNode.getRotationZ(); |
| 17411 |
} |
| 17412 |
|
| 17413 |
|
| 17414 |
|
| 17415 |
|
| 17416 |
|
| 17417 |
|
| 17418 |
|
| 17419 |
|
| 17420 |
|
| 17421 |
|
| 17422 |
|
| 17423 |
|
| 17424 |
|
| 17425 |
|
| 17426 |
|
| 17427 |
@RemotableViewMethod |
| 17428 |
public void setRotation(float rotation) { |
| 17429 |
if (rotation != getRotation()) { |
| 17430 |
|
| 17431 |
invalidateViewProperty(true, false); |
| 17432 |
mRenderNode.setRotationZ(rotation); |
| 17433 |
invalidateViewProperty(false, true); |
| 17434 |
|
| 17435 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 17436 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 17437 |
} |
| 17438 |
} |
| 17439 |
|
| 17440 |
|
| 17441 |
|
| 17442 |
|
| 17443 |
|
| 17444 |
|
| 17445 |
|
| 17446 |
|
| 17447 |
|
| 17448 |
|
| 17449 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17450 |
@InspectableProperty |
| 17451 |
public float getRotationY() { |
| 17452 |
return mRenderNode.getRotationY(); |
| 17453 |
} |
| 17454 |
|
| 17455 |
|
| 17456 |
|
| 17457 |
|
| 17458 |
|
| 17459 |
|
| 17460 |
|
| 17461 |
|
| 17462 |
|
| 17463 |
|
| 17464 |
|
| 17465 |
|
| 17466 |
|
| 17467 |
|
| 17468 |
|
| 17469 |
|
| 17470 |
|
| 17471 |
|
| 17472 |
|
| 17473 |
|
| 17474 |
@RemotableViewMethod |
| 17475 |
public void setRotationY(float rotationY) { |
| 17476 |
if (rotationY != getRotationY()) { |
| 17477 |
invalidateViewProperty(true, false); |
| 17478 |
mRenderNode.setRotationY(rotationY); |
| 17479 |
invalidateViewProperty(false, true); |
| 17480 |
|
| 17481 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 17482 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 17483 |
} |
| 17484 |
} |
| 17485 |
|
| 17486 |
|
| 17487 |
|
| 17488 |
|
| 17489 |
|
| 17490 |
|
| 17491 |
|
| 17492 |
|
| 17493 |
|
| 17494 |
|
| 17495 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17496 |
@InspectableProperty |
| 17497 |
public float getRotationX() { |
| 17498 |
return mRenderNode.getRotationX(); |
| 17499 |
} |
| 17500 |
|
| 17501 |
|
| 17502 |
|
| 17503 |
|
| 17504 |
|
| 17505 |
|
| 17506 |
|
| 17507 |
|
| 17508 |
|
| 17509 |
|
| 17510 |
|
| 17511 |
|
| 17512 |
|
| 17513 |
|
| 17514 |
|
| 17515 |
|
| 17516 |
|
| 17517 |
|
| 17518 |
|
| 17519 |
|
| 17520 |
@RemotableViewMethod |
| 17521 |
public void setRotationX(float rotationX) { |
| 17522 |
if (rotationX != getRotationX()) { |
| 17523 |
invalidateViewProperty(true, false); |
| 17524 |
mRenderNode.setRotationX(rotationX); |
| 17525 |
invalidateViewProperty(false, true); |
| 17526 |
|
| 17527 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 17528 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 17529 |
} |
| 17530 |
} |
| 17531 |
|
| 17532 |
|
| 17533 |
|
| 17534 |
|
| 17535 |
|
| 17536 |
|
| 17537 |
|
| 17538 |
|
| 17539 |
|
| 17540 |
|
| 17541 |
|
| 17542 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17543 |
@InspectableProperty |
| 17544 |
public float getScaleX() { |
| 17545 |
return mRenderNode.getScaleX(); |
| 17546 |
} |
| 17547 |
|
| 17548 |
|
| 17549 |
|
| 17550 |
|
| 17551 |
|
| 17552 |
|
| 17553 |
|
| 17554 |
|
| 17555 |
|
| 17556 |
|
| 17557 |
|
| 17558 |
@RemotableViewMethod |
| 17559 |
public void setScaleX(float scaleX) { |
| 17560 |
if (scaleX != getScaleX()) { |
| 17561 |
scaleX = sanitizeFloatPropertyValue(scaleX, "scaleX"); |
| 17562 |
invalidateViewProperty(true, false); |
| 17563 |
mRenderNode.setScaleX(scaleX); |
| 17564 |
invalidateViewProperty(false, true); |
| 17565 |
|
| 17566 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 17567 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 17568 |
} |
| 17569 |
} |
| 17570 |
|
| 17571 |
|
| 17572 |
|
| 17573 |
|
| 17574 |
|
| 17575 |
|
| 17576 |
|
| 17577 |
|
| 17578 |
|
| 17579 |
|
| 17580 |
|
| 17581 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17582 |
@InspectableProperty |
| 17583 |
public float getScaleY() { |
| 17584 |
return mRenderNode.getScaleY(); |
| 17585 |
} |
| 17586 |
|
| 17587 |
|
| 17588 |
|
| 17589 |
|
| 17590 |
|
| 17591 |
|
| 17592 |
|
| 17593 |
|
| 17594 |
|
| 17595 |
|
| 17596 |
|
| 17597 |
@RemotableViewMethod |
| 17598 |
public void setScaleY(float scaleY) { |
| 17599 |
if (scaleY != getScaleY()) { |
| 17600 |
scaleY = sanitizeFloatPropertyValue(scaleY, "scaleY"); |
| 17601 |
invalidateViewProperty(true, false); |
| 17602 |
mRenderNode.setScaleY(scaleY); |
| 17603 |
invalidateViewProperty(false, true); |
| 17604 |
|
| 17605 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 17606 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 17607 |
} |
| 17608 |
} |
| 17609 |
|
| 17610 |
|
| 17611 |
|
| 17612 |
|
| 17613 |
|
| 17614 |
|
| 17615 |
|
| 17616 |
|
| 17617 |
|
| 17618 |
|
| 17619 |
|
| 17620 |
|
| 17621 |
|
| 17622 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17623 |
@InspectableProperty(name = "transformPivotX") |
| 17624 |
public float getPivotX() { |
| 17625 |
return mRenderNode.getPivotX(); |
| 17626 |
} |
| 17627 |
|
| 17628 |
|
| 17629 |
|
| 17630 |
|
| 17631 |
|
| 17632 |
|
| 17633 |
|
| 17634 |
|
| 17635 |
|
| 17636 |
|
| 17637 |
|
| 17638 |
|
| 17639 |
|
| 17640 |
|
| 17641 |
|
| 17642 |
|
| 17643 |
@RemotableViewMethod |
| 17644 |
public void setPivotX(float pivotX) { |
| 17645 |
if (!mRenderNode.isPivotExplicitlySet() || pivotX != getPivotX()) { |
| 17646 |
invalidateViewProperty(true, false); |
| 17647 |
mRenderNode.setPivotX(pivotX); |
| 17648 |
invalidateViewProperty(false, true); |
| 17649 |
|
| 17650 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 17651 |
} |
| 17652 |
} |
| 17653 |
|
| 17654 |
|
| 17655 |
|
| 17656 |
|
| 17657 |
|
| 17658 |
|
| 17659 |
|
| 17660 |
|
| 17661 |
|
| 17662 |
|
| 17663 |
|
| 17664 |
|
| 17665 |
|
| 17666 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17667 |
@InspectableProperty(name = "transformPivotY") |
| 17668 |
public float getPivotY() { |
| 17669 |
return mRenderNode.getPivotY(); |
| 17670 |
} |
| 17671 |
|
| 17672 |
|
| 17673 |
|
| 17674 |
|
| 17675 |
|
| 17676 |
|
| 17677 |
|
| 17678 |
|
| 17679 |
|
| 17680 |
|
| 17681 |
|
| 17682 |
|
| 17683 |
|
| 17684 |
|
| 17685 |
|
| 17686 |
@RemotableViewMethod |
| 17687 |
public void setPivotY(float pivotY) { |
| 17688 |
if (!mRenderNode.isPivotExplicitlySet() || pivotY != getPivotY()) { |
| 17689 |
invalidateViewProperty(true, false); |
| 17690 |
mRenderNode.setPivotY(pivotY); |
| 17691 |
invalidateViewProperty(false, true); |
| 17692 |
|
| 17693 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 17694 |
} |
| 17695 |
} |
| 17696 |
|
| 17697 |
|
| 17698 |
|
| 17699 |
|
| 17700 |
|
| 17701 |
|
| 17702 |
|
| 17703 |
|
| 17704 |
public boolean isPivotSet() { |
| 17705 |
return mRenderNode.isPivotExplicitlySet(); |
| 17706 |
} |
| 17707 |
|
| 17708 |
|
| 17709 |
|
| 17710 |
|
| 17711 |
|
| 17712 |
|
| 17713 |
public void resetPivot() { |
| 17714 |
if (mRenderNode.resetPivot()) { |
| 17715 |
invalidateViewProperty(false, false); |
| 17716 |
} |
| 17717 |
} |
| 17718 |
|
| 17719 |
|
| 17720 |
|
| 17721 |
|
| 17722 |
|
| 17723 |
|
| 17724 |
|
| 17725 |
|
| 17726 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17727 |
@InspectableProperty |
| 17728 |
public float getAlpha() { |
| 17729 |
return mTransformationInfo != null ? mTransformationInfo.mAlpha : 1; |
| 17730 |
} |
| 17731 |
|
| 17732 |
|
| 17733 |
|
| 17734 |
|
| 17735 |
|
| 17736 |
|
| 17737 |
|
| 17738 |
|
| 17739 |
|
| 17740 |
|
| 17741 |
|
| 17742 |
|
| 17743 |
|
| 17744 |
|
| 17745 |
|
| 17746 |
public void forceHasOverlappingRendering(boolean hasOverlappingRendering) { |
| 17747 |
mPrivateFlags3 |= PFLAG3_HAS_OVERLAPPING_RENDERING_FORCED; |
| 17748 |
if (hasOverlappingRendering) { |
| 17749 |
mPrivateFlags3 |= PFLAG3_OVERLAPPING_RENDERING_FORCED_VALUE; |
| 17750 |
} else { |
| 17751 |
mPrivateFlags3 &= ~PFLAG3_OVERLAPPING_RENDERING_FORCED_VALUE; |
| 17752 |
} |
| 17753 |
} |
| 17754 |
|
| 17755 |
|
| 17756 |
|
| 17757 |
|
| 17758 |
|
| 17759 |
|
| 17760 |
|
| 17761 |
|
| 17762 |
public final boolean getHasOverlappingRendering() { |
| 17763 |
return (mPrivateFlags3 & PFLAG3_HAS_OVERLAPPING_RENDERING_FORCED) != 0 ? |
| 17764 |
(mPrivateFlags3 & PFLAG3_OVERLAPPING_RENDERING_FORCED_VALUE) != 0 : |
| 17765 |
hasOverlappingRendering(); |
| 17766 |
} |
| 17767 |
|
| 17768 |
|
| 17769 |
|
| 17770 |
|
| 17771 |
|
| 17772 |
|
| 17773 |
|
| 17774 |
|
| 17775 |
|
| 17776 |
|
| 17777 |
|
| 17778 |
|
| 17779 |
|
| 17780 |
|
| 17781 |
|
| 17782 |
|
| 17783 |
|
| 17784 |
|
| 17785 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17786 |
public boolean hasOverlappingRendering() { |
| 17787 |
return true; |
| 17788 |
} |
| 17789 |
|
| 17790 |
|
| 17791 |
|
| 17792 |
|
| 17793 |
|
| 17794 |
|
| 17795 |
|
| 17796 |
|
| 17797 |
|
| 17798 |
|
| 17799 |
|
| 17800 |
|
| 17801 |
|
| 17802 |
|
| 17803 |
|
| 17804 |
|
| 17805 |
|
| 17806 |
|
| 17807 |
|
| 17808 |
|
| 17809 |
|
| 17810 |
|
| 17811 |
|
| 17812 |
|
| 17813 |
|
| 17814 |
|
| 17815 |
|
| 17816 |
|
| 17817 |
|
| 17818 |
|
| 17819 |
|
| 17820 |
|
| 17821 |
|
| 17822 |
|
| 17823 |
|
| 17824 |
|
| 17825 |
|
| 17826 |
|
| 17827 |
@RemotableViewMethod |
| 17828 |
public void setAlpha(@FloatRange(from=0.0, to=1.0) float alpha) { |
| 17829 |
ensureTransformationInfo(); |
| 17830 |
if (mTransformationInfo.mAlpha != alpha) { |
| 17831 |
setAlphaInternal(alpha); |
| 17832 |
if (onSetAlpha((int) (alpha * 255))) { |
| 17833 |
mPrivateFlags |= PFLAG_ALPHA_SET; |
| 17834 |
|
| 17835 |
invalidateParentCaches(); |
| 17836 |
invalidate(true); |
| 17837 |
} else { |
| 17838 |
mPrivateFlags &= ~PFLAG_ALPHA_SET; |
| 17839 |
invalidateViewProperty(true, false); |
| 17840 |
mRenderNode.setAlpha(getFinalAlpha()); |
| 17841 |
} |
| 17842 |
} |
| 17843 |
} |
| 17844 |
|
| 17845 |
|
| 17846 |
|
| 17847 |
|
| 17848 |
|
| 17849 |
|
| 17850 |
|
| 17851 |
|
| 17852 |
|
| 17853 |
|
| 17854 |
|
| 17855 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768435) |
| 17856 |
boolean setAlphaNoInvalidation(float alpha) { |
| 17857 |
ensureTransformationInfo(); |
| 17858 |
if (mTransformationInfo.mAlpha != alpha) { |
| 17859 |
setAlphaInternal(alpha); |
| 17860 |
boolean subclassHandlesAlpha = onSetAlpha((int) (alpha * 255)); |
| 17861 |
if (subclassHandlesAlpha) { |
| 17862 |
mPrivateFlags |= PFLAG_ALPHA_SET; |
| 17863 |
return true; |
| 17864 |
} else { |
| 17865 |
mPrivateFlags &= ~PFLAG_ALPHA_SET; |
| 17866 |
mRenderNode.setAlpha(getFinalAlpha()); |
| 17867 |
} |
| 17868 |
} |
| 17869 |
return false; |
| 17870 |
} |
| 17871 |
|
| 17872 |
void setAlphaInternal(float alpha) { |
| 17873 |
float oldAlpha = mTransformationInfo.mAlpha; |
| 17874 |
mTransformationInfo.mAlpha = alpha; |
| 17875 |
|
| 17876 |
if ((alpha == 0) ^ (oldAlpha == 0)) { |
| 17877 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 17878 |
} |
| 17879 |
} |
| 17880 |
|
| 17881 |
|
| 17882 |
|
| 17883 |
|
| 17884 |
|
| 17885 |
|
| 17886 |
|
| 17887 |
|
| 17888 |
public void setTransitionAlpha(float alpha) { |
| 17889 |
ensureTransformationInfo(); |
| 17890 |
if (mTransformationInfo.mTransitionAlpha != alpha) { |
| 17891 |
mTransformationInfo.mTransitionAlpha = alpha; |
| 17892 |
mPrivateFlags &= ~PFLAG_ALPHA_SET; |
| 17893 |
invalidateViewProperty(true, false); |
| 17894 |
mRenderNode.setAlpha(getFinalAlpha()); |
| 17895 |
} |
| 17896 |
} |
| 17897 |
|
| 17898 |
|
| 17899 |
|
| 17900 |
|
| 17901 |
|
| 17902 |
private float getFinalAlpha() { |
| 17903 |
if (mTransformationInfo != null) { |
| 17904 |
return mTransformationInfo.mAlpha * mTransformationInfo.mTransitionAlpha; |
| 17905 |
} |
| 17906 |
return 1; |
| 17907 |
} |
| 17908 |
|
| 17909 |
|
| 17910 |
|
| 17911 |
|
| 17912 |
|
| 17913 |
|
| 17914 |
|
| 17915 |
|
| 17916 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17917 |
public float getTransitionAlpha() { |
| 17918 |
return mTransformationInfo != null ? mTransformationInfo.mTransitionAlpha : 1; |
| 17919 |
} |
| 17920 |
|
| 17921 |
|
| 17922 |
|
| 17923 |
|
| 17924 |
|
| 17925 |
|
| 17926 |
|
| 17927 |
|
| 17928 |
|
| 17929 |
|
| 17930 |
|
| 17931 |
|
| 17932 |
|
| 17933 |
|
| 17934 |
|
| 17935 |
|
| 17936 |
|
| 17937 |
public void setForceDarkAllowed(boolean allow) { |
| 17938 |
if (mRenderNode.setForceDarkAllowed(allow)) { |
| 17939 |
|
| 17940 |
|
| 17941 |
invalidate(); |
| 17942 |
} |
| 17943 |
} |
| 17944 |
|
| 17945 |
|
| 17946 |
|
| 17947 |
|
| 17948 |
|
| 17949 |
|
| 17950 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 17951 |
@InspectableProperty |
| 17952 |
public boolean isForceDarkAllowed() { |
| 17953 |
return mRenderNode.isForceDarkAllowed(); |
| 17954 |
} |
| 17955 |
|
| 17956 |
|
| 17957 |
|
| 17958 |
|
| 17959 |
|
| 17960 |
|
| 17961 |
@ViewDebug.CapturedViewProperty |
| 17962 |
public final int getTop() { |
| 17963 |
return mTop; |
| 17964 |
} |
| 17965 |
|
| 17966 |
|
| 17967 |
|
| 17968 |
|
| 17969 |
|
| 17970 |
|
| 17971 |
|
| 17972 |
|
| 17973 |
public final void setTop(int top) { |
| 17974 |
if (top != mTop) { |
| 17975 |
final boolean matrixIsIdentity = hasIdentityMatrix(); |
| 17976 |
if (matrixIsIdentity) { |
| 17977 |
if (mAttachInfo != null) { |
| 17978 |
int minTop; |
| 17979 |
int yLoc; |
| 17980 |
if (top < mTop) { |
| 17981 |
minTop = top; |
| 17982 |
yLoc = top - mTop; |
| 17983 |
} else { |
| 17984 |
minTop = mTop; |
| 17985 |
yLoc = 0; |
| 17986 |
} |
| 17987 |
invalidate(0, yLoc, mRight - mLeft, mBottom - minTop); |
| 17988 |
} |
| 17989 |
} else { |
| 17990 |
|
| 17991 |
invalidate(true); |
| 17992 |
} |
| 17993 |
|
| 17994 |
int width = mRight - mLeft; |
| 17995 |
int oldHeight = mBottom - mTop; |
| 17996 |
|
| 17997 |
mTop = top; |
| 17998 |
mRenderNode.setTop(mTop); |
| 17999 |
|
| 18000 |
sizeChange(width, mBottom - mTop, width, oldHeight); |
| 18001 |
|
| 18002 |
if (!matrixIsIdentity) { |
| 18003 |
mPrivateFlags |= PFLAG_DRAWN; |
| 18004 |
invalidate(true); |
| 18005 |
} |
| 18006 |
mBackgroundSizeChanged = true; |
| 18007 |
mDefaultFocusHighlightSizeChanged = true; |
| 18008 |
if (mForegroundInfo != null) { |
| 18009 |
mForegroundInfo.mBoundsChanged = true; |
| 18010 |
} |
| 18011 |
invalidateParentIfNeeded(); |
| 18012 |
} |
| 18013 |
} |
| 18014 |
|
| 18015 |
|
| 18016 |
|
| 18017 |
|
| 18018 |
|
| 18019 |
|
| 18020 |
@ViewDebug.CapturedViewProperty |
| 18021 |
public final int getBottom() { |
| 18022 |
return mBottom; |
| 18023 |
} |
| 18024 |
|
| 18025 |
|
| 18026 |
|
| 18027 |
|
| 18028 |
|
| 18029 |
|
| 18030 |
public boolean isDirty() { |
| 18031 |
return (mPrivateFlags & PFLAG_DIRTY_MASK) != 0; |
| 18032 |
} |
| 18033 |
|
| 18034 |
|
| 18035 |
|
| 18036 |
|
| 18037 |
|
| 18038 |
|
| 18039 |
|
| 18040 |
|
| 18041 |
public final void setBottom(int bottom) { |
| 18042 |
if (bottom != mBottom) { |
| 18043 |
final boolean matrixIsIdentity = hasIdentityMatrix(); |
| 18044 |
if (matrixIsIdentity) { |
| 18045 |
if (mAttachInfo != null) { |
| 18046 |
int maxBottom; |
| 18047 |
if (bottom < mBottom) { |
| 18048 |
maxBottom = mBottom; |
| 18049 |
} else { |
| 18050 |
maxBottom = bottom; |
| 18051 |
} |
| 18052 |
invalidate(0, 0, mRight - mLeft, maxBottom - mTop); |
| 18053 |
} |
| 18054 |
} else { |
| 18055 |
|
| 18056 |
invalidate(true); |
| 18057 |
} |
| 18058 |
|
| 18059 |
int width = mRight - mLeft; |
| 18060 |
int oldHeight = mBottom - mTop; |
| 18061 |
|
| 18062 |
mBottom = bottom; |
| 18063 |
mRenderNode.setBottom(mBottom); |
| 18064 |
|
| 18065 |
sizeChange(width, mBottom - mTop, width, oldHeight); |
| 18066 |
|
| 18067 |
if (!matrixIsIdentity) { |
| 18068 |
mPrivateFlags |= PFLAG_DRAWN; |
| 18069 |
invalidate(true); |
| 18070 |
} |
| 18071 |
mBackgroundSizeChanged = true; |
| 18072 |
mDefaultFocusHighlightSizeChanged = true; |
| 18073 |
if (mForegroundInfo != null) { |
| 18074 |
mForegroundInfo.mBoundsChanged = true; |
| 18075 |
} |
| 18076 |
invalidateParentIfNeeded(); |
| 18077 |
} |
| 18078 |
} |
| 18079 |
|
| 18080 |
|
| 18081 |
|
| 18082 |
|
| 18083 |
|
| 18084 |
|
| 18085 |
@ViewDebug.CapturedViewProperty |
| 18086 |
public final int getLeft() { |
| 18087 |
return mLeft; |
| 18088 |
} |
| 18089 |
|
| 18090 |
|
| 18091 |
|
| 18092 |
|
| 18093 |
|
| 18094 |
|
| 18095 |
|
| 18096 |
|
| 18097 |
public final void setLeft(int left) { |
| 18098 |
if (left != mLeft) { |
| 18099 |
final boolean matrixIsIdentity = hasIdentityMatrix(); |
| 18100 |
if (matrixIsIdentity) { |
| 18101 |
if (mAttachInfo != null) { |
| 18102 |
int minLeft; |
| 18103 |
int xLoc; |
| 18104 |
if (left < mLeft) { |
| 18105 |
minLeft = left; |
| 18106 |
xLoc = left - mLeft; |
| 18107 |
} else { |
| 18108 |
minLeft = mLeft; |
| 18109 |
xLoc = 0; |
| 18110 |
} |
| 18111 |
invalidate(xLoc, 0, mRight - minLeft, mBottom - mTop); |
| 18112 |
} |
| 18113 |
} else { |
| 18114 |
|
| 18115 |
invalidate(true); |
| 18116 |
} |
| 18117 |
|
| 18118 |
int oldWidth = mRight - mLeft; |
| 18119 |
int height = mBottom - mTop; |
| 18120 |
|
| 18121 |
mLeft = left; |
| 18122 |
mRenderNode.setLeft(left); |
| 18123 |
|
| 18124 |
sizeChange(mRight - mLeft, height, oldWidth, height); |
| 18125 |
|
| 18126 |
if (!matrixIsIdentity) { |
| 18127 |
mPrivateFlags |= PFLAG_DRAWN; |
| 18128 |
invalidate(true); |
| 18129 |
} |
| 18130 |
mBackgroundSizeChanged = true; |
| 18131 |
mDefaultFocusHighlightSizeChanged = true; |
| 18132 |
if (mForegroundInfo != null) { |
| 18133 |
mForegroundInfo.mBoundsChanged = true; |
| 18134 |
} |
| 18135 |
invalidateParentIfNeeded(); |
| 18136 |
} |
| 18137 |
} |
| 18138 |
|
| 18139 |
|
| 18140 |
|
| 18141 |
|
| 18142 |
|
| 18143 |
|
| 18144 |
@ViewDebug.CapturedViewProperty |
| 18145 |
public final int getRight() { |
| 18146 |
return mRight; |
| 18147 |
} |
| 18148 |
|
| 18149 |
|
| 18150 |
|
| 18151 |
|
| 18152 |
|
| 18153 |
|
| 18154 |
|
| 18155 |
|
| 18156 |
public final void setRight(int right) { |
| 18157 |
if (right != mRight) { |
| 18158 |
final boolean matrixIsIdentity = hasIdentityMatrix(); |
| 18159 |
if (matrixIsIdentity) { |
| 18160 |
if (mAttachInfo != null) { |
| 18161 |
int maxRight; |
| 18162 |
if (right < mRight) { |
| 18163 |
maxRight = mRight; |
| 18164 |
} else { |
| 18165 |
maxRight = right; |
| 18166 |
} |
| 18167 |
invalidate(0, 0, maxRight - mLeft, mBottom - mTop); |
| 18168 |
} |
| 18169 |
} else { |
| 18170 |
|
| 18171 |
invalidate(true); |
| 18172 |
} |
| 18173 |
|
| 18174 |
int oldWidth = mRight - mLeft; |
| 18175 |
int height = mBottom - mTop; |
| 18176 |
|
| 18177 |
mRight = right; |
| 18178 |
mRenderNode.setRight(mRight); |
| 18179 |
|
| 18180 |
sizeChange(mRight - mLeft, height, oldWidth, height); |
| 18181 |
|
| 18182 |
if (!matrixIsIdentity) { |
| 18183 |
mPrivateFlags |= PFLAG_DRAWN; |
| 18184 |
invalidate(true); |
| 18185 |
} |
| 18186 |
mBackgroundSizeChanged = true; |
| 18187 |
mDefaultFocusHighlightSizeChanged = true; |
| 18188 |
if (mForegroundInfo != null) { |
| 18189 |
mForegroundInfo.mBoundsChanged = true; |
| 18190 |
} |
| 18191 |
invalidateParentIfNeeded(); |
| 18192 |
} |
| 18193 |
} |
| 18194 |
|
| 18195 |
private static float sanitizeFloatPropertyValue(float value, String propertyName) { |
| 18196 |
return sanitizeFloatPropertyValue(value, propertyName, -Float.MAX_VALUE, Float.MAX_VALUE); |
| 18197 |
} |
| 18198 |
|
| 18199 |
private static float sanitizeFloatPropertyValue(float value, String propertyName, |
| 18200 |
float min, float max) { |
| 18201 |
|
| 18202 |
if (value >= min && value <= max) return value; |
| 18203 |
|
| 18204 |
if (value < min || value == Float.NEGATIVE_INFINITY) { |
| 18205 |
if (sThrowOnInvalidFloatProperties) { |
| 18206 |
throw new IllegalArgumentException("Cannot set '" + propertyName + "' to " |
| 18207 |
+ value + ", the value must be >= " + min); |
| 18208 |
} |
| 18209 |
return min; |
| 18210 |
} |
| 18211 |
|
| 18212 |
if (value > max || value == Float.POSITIVE_INFINITY) { |
| 18213 |
if (sThrowOnInvalidFloatProperties) { |
| 18214 |
throw new IllegalArgumentException("Cannot set '" + propertyName + "' to " |
| 18215 |
+ value + ", the value must be <= " + max); |
| 18216 |
} |
| 18217 |
return max; |
| 18218 |
} |
| 18219 |
|
| 18220 |
if (Float.isNaN(value)) { |
| 18221 |
if (sThrowOnInvalidFloatProperties) { |
| 18222 |
throw new IllegalArgumentException( |
| 18223 |
"Cannot set '" + propertyName + "' to Float.NaN"); |
| 18224 |
} |
| 18225 |
return 0; |
| 18226 |
} |
| 18227 |
|
| 18228 |
|
| 18229 |
throw new IllegalStateException("How do you get here?? " + value); |
| 18230 |
} |
| 18231 |
|
| 18232 |
|
| 18233 |
|
| 18234 |
|
| 18235 |
|
| 18236 |
|
| 18237 |
|
| 18238 |
|
| 18239 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 18240 |
public float getX() { |
| 18241 |
return mLeft + getTranslationX(); |
| 18242 |
} |
| 18243 |
|
| 18244 |
|
| 18245 |
|
| 18246 |
|
| 18247 |
|
| 18248 |
|
| 18249 |
|
| 18250 |
|
| 18251 |
public void setX(float x) { |
| 18252 |
setTranslationX(x - mLeft); |
| 18253 |
} |
| 18254 |
|
| 18255 |
|
| 18256 |
|
| 18257 |
|
| 18258 |
|
| 18259 |
|
| 18260 |
|
| 18261 |
|
| 18262 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 18263 |
public float getY() { |
| 18264 |
return mTop + getTranslationY(); |
| 18265 |
} |
| 18266 |
|
| 18267 |
|
| 18268 |
|
| 18269 |
|
| 18270 |
|
| 18271 |
|
| 18272 |
|
| 18273 |
|
| 18274 |
public void setY(float y) { |
| 18275 |
setTranslationY(y - mTop); |
| 18276 |
} |
| 18277 |
|
| 18278 |
|
| 18279 |
|
| 18280 |
|
| 18281 |
|
| 18282 |
|
| 18283 |
|
| 18284 |
|
| 18285 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 18286 |
public float getZ() { |
| 18287 |
return getElevation() + getTranslationZ(); |
| 18288 |
} |
| 18289 |
|
| 18290 |
|
| 18291 |
|
| 18292 |
|
| 18293 |
|
| 18294 |
|
| 18295 |
|
| 18296 |
|
| 18297 |
public void setZ(float z) { |
| 18298 |
setTranslationZ(z - getElevation()); |
| 18299 |
} |
| 18300 |
|
| 18301 |
|
| 18302 |
|
| 18303 |
|
| 18304 |
|
| 18305 |
|
| 18306 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 18307 |
@InspectableProperty |
| 18308 |
public float getElevation() { |
| 18309 |
return mRenderNode.getElevation(); |
| 18310 |
} |
| 18311 |
|
| 18312 |
|
| 18313 |
|
| 18314 |
|
| 18315 |
|
| 18316 |
|
| 18317 |
@RemotableViewMethod |
| 18318 |
public void setElevation(float elevation) { |
| 18319 |
if (elevation != getElevation()) { |
| 18320 |
elevation = sanitizeFloatPropertyValue(elevation, "elevation"); |
| 18321 |
invalidateViewProperty(true, false); |
| 18322 |
mRenderNode.setElevation(elevation); |
| 18323 |
invalidateViewProperty(false, true); |
| 18324 |
|
| 18325 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 18326 |
} |
| 18327 |
} |
| 18328 |
|
| 18329 |
|
| 18330 |
|
| 18331 |
|
| 18332 |
|
| 18333 |
|
| 18334 |
|
| 18335 |
|
| 18336 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 18337 |
@InspectableProperty |
| 18338 |
public float getTranslationX() { |
| 18339 |
return mRenderNode.getTranslationX(); |
| 18340 |
} |
| 18341 |
|
| 18342 |
|
| 18343 |
|
| 18344 |
|
| 18345 |
|
| 18346 |
|
| 18347 |
|
| 18348 |
|
| 18349 |
|
| 18350 |
|
| 18351 |
|
| 18352 |
@RemotableViewMethod |
| 18353 |
public void setTranslationX(float translationX) { |
| 18354 |
if (translationX != getTranslationX()) { |
| 18355 |
invalidateViewProperty(true, false); |
| 18356 |
mRenderNode.setTranslationX(translationX); |
| 18357 |
invalidateViewProperty(false, true); |
| 18358 |
|
| 18359 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 18360 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 18361 |
} |
| 18362 |
} |
| 18363 |
|
| 18364 |
|
| 18365 |
|
| 18366 |
|
| 18367 |
|
| 18368 |
|
| 18369 |
|
| 18370 |
|
| 18371 |
|
| 18372 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 18373 |
@InspectableProperty |
| 18374 |
public float getTranslationY() { |
| 18375 |
return mRenderNode.getTranslationY(); |
| 18376 |
} |
| 18377 |
|
| 18378 |
|
| 18379 |
|
| 18380 |
|
| 18381 |
|
| 18382 |
|
| 18383 |
|
| 18384 |
|
| 18385 |
|
| 18386 |
|
| 18387 |
|
| 18388 |
@RemotableViewMethod |
| 18389 |
public void setTranslationY(float translationY) { |
| 18390 |
if (translationY != getTranslationY()) { |
| 18391 |
invalidateViewProperty(true, false); |
| 18392 |
mRenderNode.setTranslationY(translationY); |
| 18393 |
invalidateViewProperty(false, true); |
| 18394 |
|
| 18395 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 18396 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 18397 |
} |
| 18398 |
} |
| 18399 |
|
| 18400 |
|
| 18401 |
|
| 18402 |
|
| 18403 |
|
| 18404 |
|
| 18405 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 18406 |
@InspectableProperty |
| 18407 |
public float getTranslationZ() { |
| 18408 |
return mRenderNode.getTranslationZ(); |
| 18409 |
} |
| 18410 |
|
| 18411 |
|
| 18412 |
|
| 18413 |
|
| 18414 |
|
| 18415 |
|
| 18416 |
@RemotableViewMethod |
| 18417 |
public void setTranslationZ(float translationZ) { |
| 18418 |
if (translationZ != getTranslationZ()) { |
| 18419 |
translationZ = sanitizeFloatPropertyValue(translationZ, "translationZ"); |
| 18420 |
invalidateViewProperty(true, false); |
| 18421 |
mRenderNode.setTranslationZ(translationZ); |
| 18422 |
invalidateViewProperty(false, true); |
| 18423 |
|
| 18424 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 18425 |
} |
| 18426 |
} |
| 18427 |
|
| 18428 |
|
| 18429 |
|
| 18430 |
|
| 18431 |
|
| 18432 |
|
| 18433 |
|
| 18434 |
|
| 18435 |
|
| 18436 |
|
| 18437 |
|
| 18438 |
|
| 18439 |
public void setAnimationMatrix(@Nullable Matrix matrix) { |
| 18440 |
invalidateViewProperty(true, false); |
| 18441 |
mRenderNode.setAnimationMatrix(matrix); |
| 18442 |
invalidateViewProperty(false, true); |
| 18443 |
|
| 18444 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 18445 |
} |
| 18446 |
|
| 18447 |
|
| 18448 |
|
| 18449 |
|
| 18450 |
|
| 18451 |
|
| 18452 |
|
| 18453 |
|
| 18454 |
|
| 18455 |
|
| 18456 |
|
| 18457 |
|
| 18458 |
@Nullable |
| 18459 |
public Matrix getAnimationMatrix() { |
| 18460 |
return mRenderNode.getAnimationMatrix(); |
| 18461 |
} |
| 18462 |
|
| 18463 |
|
| 18464 |
|
| 18465 |
|
| 18466 |
|
| 18467 |
|
| 18468 |
|
| 18469 |
@InspectableProperty |
| 18470 |
public StateListAnimator getStateListAnimator() { |
| 18471 |
return mStateListAnimator; |
| 18472 |
} |
| 18473 |
|
| 18474 |
|
| 18475 |
|
| 18476 |
|
| 18477 |
|
| 18478 |
|
| 18479 |
|
| 18480 |
|
| 18481 |
|
| 18482 |
public void setStateListAnimator(StateListAnimator stateListAnimator) { |
| 18483 |
if (mStateListAnimator == stateListAnimator) { |
| 18484 |
return; |
| 18485 |
} |
| 18486 |
if (mStateListAnimator != null) { |
| 18487 |
mStateListAnimator.setTarget(null); |
| 18488 |
} |
| 18489 |
mStateListAnimator = stateListAnimator; |
| 18490 |
if (stateListAnimator != null) { |
| 18491 |
stateListAnimator.setTarget(this); |
| 18492 |
if (isAttachedToWindow()) { |
| 18493 |
stateListAnimator.setState(getDrawableState()); |
| 18494 |
} |
| 18495 |
} |
| 18496 |
} |
| 18497 |
|
| 18498 |
|
| 18499 |
|
| 18500 |
|
| 18501 |
|
| 18502 |
|
| 18503 |
|
| 18504 |
|
| 18505 |
|
| 18506 |
|
| 18507 |
public final boolean getClipToOutline() { |
| 18508 |
return mRenderNode.getClipToOutline(); |
| 18509 |
} |
| 18510 |
|
| 18511 |
|
| 18512 |
|
| 18513 |
|
| 18514 |
|
| 18515 |
|
| 18516 |
|
| 18517 |
|
| 18518 |
|
| 18519 |
|
| 18520 |
|
| 18521 |
|
| 18522 |
|
| 18523 |
|
| 18524 |
|
| 18525 |
|
| 18526 |
|
| 18527 |
|
| 18528 |
@RemotableViewMethod |
| 18529 |
public void setClipToOutline(boolean clipToOutline) { |
| 18530 |
damageInParent(); |
| 18531 |
if (getClipToOutline() != clipToOutline) { |
| 18532 |
mRenderNode.setClipToOutline(clipToOutline); |
| 18533 |
} |
| 18534 |
} |
| 18535 |
|
| 18536 |
|
| 18537 |
private static final int PROVIDER_BACKGROUND = 0; |
| 18538 |
private static final int PROVIDER_NONE = 1; |
| 18539 |
private static final int PROVIDER_BOUNDS = 2; |
| 18540 |
private static final int PROVIDER_PADDED_BOUNDS = 3; |
| 18541 |
private void setOutlineProviderFromAttribute(int providerInt) { |
| 18542 |
switch (providerInt) { |
| 18543 |
case PROVIDER_BACKGROUND: |
| 18544 |
setOutlineProvider(ViewOutlineProvider.BACKGROUND); |
| 18545 |
break; |
| 18546 |
case PROVIDER_NONE: |
| 18547 |
setOutlineProvider(null); |
| 18548 |
break; |
| 18549 |
case PROVIDER_BOUNDS: |
| 18550 |
setOutlineProvider(ViewOutlineProvider.BOUNDS); |
| 18551 |
break; |
| 18552 |
case PROVIDER_PADDED_BOUNDS: |
| 18553 |
setOutlineProvider(ViewOutlineProvider.PADDED_BOUNDS); |
| 18554 |
break; |
| 18555 |
} |
| 18556 |
} |
| 18557 |
|
| 18558 |
|
| 18559 |
|
| 18560 |
|
| 18561 |
|
| 18562 |
|
| 18563 |
|
| 18564 |
|
| 18565 |
|
| 18566 |
|
| 18567 |
|
| 18568 |
|
| 18569 |
|
| 18570 |
|
| 18571 |
|
| 18572 |
|
| 18573 |
|
| 18574 |
|
| 18575 |
public void setOutlineProvider(ViewOutlineProvider provider) { |
| 18576 |
mOutlineProvider = provider; |
| 18577 |
invalidateOutline(); |
| 18578 |
} |
| 18579 |
|
| 18580 |
|
| 18581 |
|
| 18582 |
|
| 18583 |
|
| 18584 |
|
| 18585 |
|
| 18586 |
@InspectableProperty |
| 18587 |
public ViewOutlineProvider getOutlineProvider() { |
| 18588 |
return mOutlineProvider; |
| 18589 |
} |
| 18590 |
|
| 18591 |
|
| 18592 |
|
| 18593 |
|
| 18594 |
|
| 18595 |
|
| 18596 |
public void invalidateOutline() { |
| 18597 |
rebuildOutline(); |
| 18598 |
|
| 18599 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 18600 |
invalidateViewProperty(false, false); |
| 18601 |
} |
| 18602 |
|
| 18603 |
|
| 18604 |
|
| 18605 |
|
| 18606 |
|
| 18607 |
|
| 18608 |
|
| 18609 |
|
| 18610 |
|
| 18611 |
|
| 18612 |
private void rebuildOutline() { |
| 18613 |
|
| 18614 |
if (mAttachInfo == null) return; |
| 18615 |
|
| 18616 |
if (mOutlineProvider == null) { |
| 18617 |
|
| 18618 |
mRenderNode.setOutline(null); |
| 18619 |
} else { |
| 18620 |
final Outline outline = mAttachInfo.mTmpOutline; |
| 18621 |
outline.setEmpty(); |
| 18622 |
outline.setAlpha(1.0f); |
| 18623 |
|
| 18624 |
mOutlineProvider.getOutline(this, outline); |
| 18625 |
mRenderNode.setOutline(outline); |
| 18626 |
} |
| 18627 |
} |
| 18628 |
|
| 18629 |
|
| 18630 |
|
| 18631 |
|
| 18632 |
|
| 18633 |
|
| 18634 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 18635 |
public boolean hasShadow() { |
| 18636 |
return mRenderNode.hasShadow(); |
| 18637 |
} |
| 18638 |
|
| 18639 |
|
| 18640 |
|
| 18641 |
|
| 18642 |
|
| 18643 |
|
| 18644 |
|
| 18645 |
|
| 18646 |
|
| 18647 |
|
| 18648 |
|
| 18649 |
|
| 18650 |
|
| 18651 |
|
| 18652 |
|
| 18653 |
public void setOutlineSpotShadowColor(@ColorInt int color) { |
| 18654 |
if (mRenderNode.setSpotShadowColor(color)) { |
| 18655 |
invalidateViewProperty(true, true); |
| 18656 |
} |
| 18657 |
} |
| 18658 |
|
| 18659 |
|
| 18660 |
|
| 18661 |
|
| 18662 |
|
| 18663 |
@InspectableProperty |
| 18664 |
public @ColorInt int getOutlineSpotShadowColor() { |
| 18665 |
return mRenderNode.getSpotShadowColor(); |
| 18666 |
} |
| 18667 |
|
| 18668 |
|
| 18669 |
|
| 18670 |
|
| 18671 |
|
| 18672 |
|
| 18673 |
|
| 18674 |
|
| 18675 |
|
| 18676 |
|
| 18677 |
|
| 18678 |
|
| 18679 |
|
| 18680 |
|
| 18681 |
|
| 18682 |
public void setOutlineAmbientShadowColor(@ColorInt int color) { |
| 18683 |
if (mRenderNode.setAmbientShadowColor(color)) { |
| 18684 |
invalidateViewProperty(true, true); |
| 18685 |
} |
| 18686 |
} |
| 18687 |
|
| 18688 |
|
| 18689 |
|
| 18690 |
|
| 18691 |
|
| 18692 |
@InspectableProperty |
| 18693 |
public @ColorInt int getOutlineAmbientShadowColor() { |
| 18694 |
return mRenderNode.getAmbientShadowColor(); |
| 18695 |
} |
| 18696 |
|
| 18697 |
|
| 18698 |
|
| 18699 |
public void setRevealClip(boolean shouldClip, float x, float y, float radius) { |
| 18700 |
mRenderNode.setRevealClip(shouldClip, x, y, radius); |
| 18701 |
invalidateViewProperty(false, false); |
| 18702 |
} |
| 18703 |
|
| 18704 |
|
| 18705 |
|
| 18706 |
|
| 18707 |
|
| 18708 |
|
| 18709 |
public void getHitRect(Rect outRect) { |
| 18710 |
if (hasIdentityMatrix() || mAttachInfo == null) { |
| 18711 |
outRect.set(mLeft, mTop, mRight, mBottom); |
| 18712 |
} else { |
| 18713 |
final RectF tmpRect = mAttachInfo.mTmpTransformRect; |
| 18714 |
tmpRect.set(0, 0, getWidth(), getHeight()); |
| 18715 |
getMatrix().mapRect(tmpRect); |
| 18716 |
outRect.set((int) tmpRect.left + mLeft, (int) tmpRect.top + mTop, |
| 18717 |
(int) tmpRect.right + mLeft, (int) tmpRect.bottom + mTop); |
| 18718 |
} |
| 18719 |
} |
| 18720 |
|
| 18721 |
|
| 18722 |
|
| 18723 |
|
| 18724 |
final boolean pointInView(float localX, float localY) { |
| 18725 |
return pointInView(localX, localY, 0); |
| 18726 |
} |
| 18727 |
|
| 18728 |
|
| 18729 |
|
| 18730 |
|
| 18731 |
|
| 18732 |
|
| 18733 |
|
| 18734 |
|
| 18735 |
|
| 18736 |
@UnsupportedAppUsage |
| 18737 |
public boolean pointInView(float localX, float localY, float slop) { |
| 18738 |
return localX >= -slop && localY >= -slop && localX < ((mRight - mLeft) + slop) && |
| 18739 |
localY < ((mBottom - mTop) + slop); |
| 18740 |
} |
| 18741 |
|
| 18742 |
|
| 18743 |
|
| 18744 |
|
| 18745 |
|
| 18746 |
|
| 18747 |
|
| 18748 |
|
| 18749 |
|
| 18750 |
|
| 18751 |
|
| 18752 |
|
| 18753 |
public void getFocusedRect(Rect r) { |
| 18754 |
getDrawingRect(r); |
| 18755 |
} |
| 18756 |
|
| 18757 |
|
| 18758 |
|
| 18759 |
|
| 18760 |
|
| 18761 |
|
| 18762 |
|
| 18763 |
|
| 18764 |
|
| 18765 |
|
| 18766 |
|
| 18767 |
|
| 18768 |
|
| 18769 |
|
| 18770 |
|
| 18771 |
|
| 18772 |
|
| 18773 |
|
| 18774 |
|
| 18775 |
|
| 18776 |
|
| 18777 |
|
| 18778 |
|
| 18779 |
|
| 18780 |
|
| 18781 |
|
| 18782 |
|
| 18783 |
|
| 18784 |
|
| 18785 |
|
| 18786 |
|
| 18787 |
|
| 18788 |
|
| 18789 |
|
| 18790 |
public boolean getGlobalVisibleRect(Rect r, Point globalOffset) { |
| 18791 |
int width = mRight - mLeft; |
| 18792 |
int height = mBottom - mTop; |
| 18793 |
if (width > 0 && height > 0) { |
| 18794 |
r.set(0, 0, width, height); |
| 18795 |
if (globalOffset != null) { |
| 18796 |
globalOffset.set(-mScrollX, -mScrollY); |
| 18797 |
} |
| 18798 |
return mParent == null || mParent.getChildVisibleRect(this, r, globalOffset); |
| 18799 |
} |
| 18800 |
return false; |
| 18801 |
} |
| 18802 |
|
| 18803 |
|
| 18804 |
|
| 18805 |
|
| 18806 |
|
| 18807 |
|
| 18808 |
|
| 18809 |
|
| 18810 |
|
| 18811 |
|
| 18812 |
|
| 18813 |
|
| 18814 |
|
| 18815 |
|
| 18816 |
|
| 18817 |
public final boolean getGlobalVisibleRect(Rect r) { |
| 18818 |
return getGlobalVisibleRect(r, null); |
| 18819 |
} |
| 18820 |
|
| 18821 |
|
| 18822 |
|
| 18823 |
|
| 18824 |
|
| 18825 |
|
| 18826 |
|
| 18827 |
|
| 18828 |
|
| 18829 |
|
| 18830 |
|
| 18831 |
|
| 18832 |
|
| 18833 |
|
| 18834 |
|
| 18835 |
|
| 18836 |
|
| 18837 |
|
| 18838 |
|
| 18839 |
|
| 18840 |
|
| 18841 |
|
| 18842 |
|
| 18843 |
|
| 18844 |
|
| 18845 |
public final boolean getLocalVisibleRect(Rect r) { |
| 18846 |
final Point offset = mAttachInfo != null ? mAttachInfo.mPoint : new Point(); |
| 18847 |
if (getGlobalVisibleRect(r, offset)) { |
| 18848 |
r.offset(-offset.x, -offset.y); |
| 18849 |
return true; |
| 18850 |
} |
| 18851 |
return false; |
| 18852 |
} |
| 18853 |
|
| 18854 |
|
| 18855 |
|
| 18856 |
|
| 18857 |
|
| 18858 |
|
| 18859 |
public void offsetTopAndBottom(int offset) { |
| 18860 |
if (offset != 0) { |
| 18861 |
final boolean matrixIsIdentity = hasIdentityMatrix(); |
| 18862 |
if (matrixIsIdentity) { |
| 18863 |
if (isHardwareAccelerated()) { |
| 18864 |
invalidateViewProperty(false, false); |
| 18865 |
} else { |
| 18866 |
final ViewParent p = mParent; |
| 18867 |
if (p != null && mAttachInfo != null) { |
| 18868 |
final Rect r = mAttachInfo.mTmpInvalRect; |
| 18869 |
int minTop; |
| 18870 |
int maxBottom; |
| 18871 |
int yLoc; |
| 18872 |
if (offset < 0) { |
| 18873 |
minTop = mTop + offset; |
| 18874 |
maxBottom = mBottom; |
| 18875 |
yLoc = offset; |
| 18876 |
} else { |
| 18877 |
minTop = mTop; |
| 18878 |
maxBottom = mBottom + offset; |
| 18879 |
yLoc = 0; |
| 18880 |
} |
| 18881 |
r.set(0, yLoc, mRight - mLeft, maxBottom - minTop); |
| 18882 |
p.invalidateChild(this, r); |
| 18883 |
} |
| 18884 |
} |
| 18885 |
} else { |
| 18886 |
invalidateViewProperty(false, false); |
| 18887 |
} |
| 18888 |
|
| 18889 |
mTop += offset; |
| 18890 |
mBottom += offset; |
| 18891 |
mRenderNode.offsetTopAndBottom(offset); |
| 18892 |
if (isHardwareAccelerated()) { |
| 18893 |
invalidateViewProperty(false, false); |
| 18894 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 18895 |
} else { |
| 18896 |
if (!matrixIsIdentity) { |
| 18897 |
invalidateViewProperty(false, true); |
| 18898 |
} |
| 18899 |
invalidateParentIfNeeded(); |
| 18900 |
} |
| 18901 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 18902 |
} |
| 18903 |
} |
| 18904 |
|
| 18905 |
|
| 18906 |
|
| 18907 |
|
| 18908 |
|
| 18909 |
|
| 18910 |
public void offsetLeftAndRight(int offset) { |
| 18911 |
if (offset != 0) { |
| 18912 |
final boolean matrixIsIdentity = hasIdentityMatrix(); |
| 18913 |
if (matrixIsIdentity) { |
| 18914 |
if (isHardwareAccelerated()) { |
| 18915 |
invalidateViewProperty(false, false); |
| 18916 |
} else { |
| 18917 |
final ViewParent p = mParent; |
| 18918 |
if (p != null && mAttachInfo != null) { |
| 18919 |
final Rect r = mAttachInfo.mTmpInvalRect; |
| 18920 |
int minLeft; |
| 18921 |
int maxRight; |
| 18922 |
if (offset < 0) { |
| 18923 |
minLeft = mLeft + offset; |
| 18924 |
maxRight = mRight; |
| 18925 |
} else { |
| 18926 |
minLeft = mLeft; |
| 18927 |
maxRight = mRight + offset; |
| 18928 |
} |
| 18929 |
r.set(0, 0, maxRight - minLeft, mBottom - mTop); |
| 18930 |
p.invalidateChild(this, r); |
| 18931 |
} |
| 18932 |
} |
| 18933 |
} else { |
| 18934 |
invalidateViewProperty(false, false); |
| 18935 |
} |
| 18936 |
|
| 18937 |
mLeft += offset; |
| 18938 |
mRight += offset; |
| 18939 |
mRenderNode.offsetLeftAndRight(offset); |
| 18940 |
if (isHardwareAccelerated()) { |
| 18941 |
invalidateViewProperty(false, false); |
| 18942 |
invalidateParentIfNeededAndWasQuickRejected(); |
| 18943 |
} else { |
| 18944 |
if (!matrixIsIdentity) { |
| 18945 |
invalidateViewProperty(false, true); |
| 18946 |
} |
| 18947 |
invalidateParentIfNeeded(); |
| 18948 |
} |
| 18949 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 18950 |
} |
| 18951 |
} |
| 18952 |
|
| 18953 |
|
| 18954 |
|
| 18955 |
|
| 18956 |
|
| 18957 |
|
| 18958 |
|
| 18959 |
|
| 18960 |
|
| 18961 |
|
| 18962 |
|
| 18963 |
|
| 18964 |
|
| 18965 |
|
| 18966 |
|
| 18967 |
|
| 18968 |
@ViewDebug.ExportedProperty(deepExport = true, prefix = "layout_") |
| 18969 |
public ViewGroup.LayoutParams getLayoutParams() { |
| 18970 |
return mLayoutParams; |
| 18971 |
} |
| 18972 |
|
| 18973 |
|
| 18974 |
|
| 18975 |
|
| 18976 |
|
| 18977 |
|
| 18978 |
|
| 18979 |
|
| 18980 |
|
| 18981 |
|
| 18982 |
public void setLayoutParams(ViewGroup.LayoutParams params) { |
| 18983 |
if (params == null) { |
| 18984 |
throw new NullPointerException("Layout parameters cannot be null"); |
| 18985 |
} |
| 18986 |
mLayoutParams = params; |
| 18987 |
resolveLayoutParams(); |
| 18988 |
if (mParent instanceof ViewGroup) { |
| 18989 |
((ViewGroup) mParent).onSetLayoutParams(this, params); |
| 18990 |
} |
| 18991 |
requestLayout(); |
| 18992 |
} |
| 18993 |
|
| 18994 |
|
| 18995 |
|
| 18996 |
|
| 18997 |
|
| 18998 |
|
| 18999 |
public void resolveLayoutParams() { |
| 19000 |
if (mLayoutParams != null) { |
| 19001 |
mLayoutParams.resolveLayoutDirection(getLayoutDirection()); |
| 19002 |
} |
| 19003 |
} |
| 19004 |
|
| 19005 |
|
| 19006 |
|
| 19007 |
|
| 19008 |
|
| 19009 |
|
| 19010 |
|
| 19011 |
|
| 19012 |
public void scrollTo(int x, int y) { |
| 19013 |
if (mScrollX != x || mScrollY != y) { |
| 19014 |
int oldX = mScrollX; |
| 19015 |
int oldY = mScrollY; |
| 19016 |
mScrollX = x; |
| 19017 |
mScrollY = y; |
| 19018 |
invalidateParentCaches(); |
| 19019 |
onScrollChanged(mScrollX, mScrollY, oldX, oldY); |
| 19020 |
if (!awakenScrollBars()) { |
| 19021 |
postInvalidateOnAnimation(); |
| 19022 |
} |
| 19023 |
} |
| 19024 |
} |
| 19025 |
|
| 19026 |
|
| 19027 |
|
| 19028 |
|
| 19029 |
|
| 19030 |
|
| 19031 |
|
| 19032 |
|
| 19033 |
public void scrollBy(int x, int y) { |
| 19034 |
scrollTo(mScrollX + x, mScrollY + y); |
| 19035 |
} |
| 19036 |
|
| 19037 |
|
| 19038 |
|
| 19039 |
|
| 19040 |
|
| 19041 |
|
| 19042 |
|
| 19043 |
|
| 19044 |
|
| 19045 |
|
| 19046 |
|
| 19047 |
|
| 19048 |
|
| 19049 |
|
| 19050 |
|
| 19051 |
|
| 19052 |
|
| 19053 |
|
| 19054 |
|
| 19055 |
|
| 19056 |
|
| 19057 |
|
| 19058 |
|
| 19059 |
|
| 19060 |
|
| 19061 |
|
| 19062 |
|
| 19063 |
|
| 19064 |
|
| 19065 |
|
| 19066 |
protected boolean awakenScrollBars() { |
| 19067 |
return mScrollCache != null && |
| 19068 |
awakenScrollBars(mScrollCache.scrollBarDefaultDelayBeforeFade, true); |
| 19069 |
} |
| 19070 |
|
| 19071 |
|
| 19072 |
|
| 19073 |
|
| 19074 |
|
| 19075 |
|
| 19076 |
|
| 19077 |
|
| 19078 |
|
| 19079 |
private boolean initialAwakenScrollBars() { |
| 19080 |
return mScrollCache != null && |
| 19081 |
awakenScrollBars(mScrollCache.scrollBarDefaultDelayBeforeFade * 4, true); |
| 19082 |
} |
| 19083 |
|
| 19084 |
|
| 19085 |
|
| 19086 |
|
| 19087 |
|
| 19088 |
|
| 19089 |
|
| 19090 |
|
| 19091 |
|
| 19092 |
|
| 19093 |
|
| 19094 |
|
| 19095 |
|
| 19096 |
|
| 19097 |
|
| 19098 |
|
| 19099 |
|
| 19100 |
|
| 19101 |
|
| 19102 |
|
| 19103 |
|
| 19104 |
|
| 19105 |
|
| 19106 |
|
| 19107 |
|
| 19108 |
|
| 19109 |
|
| 19110 |
|
| 19111 |
|
| 19112 |
|
| 19113 |
|
| 19114 |
|
| 19115 |
|
| 19116 |
|
| 19117 |
|
| 19118 |
protected boolean awakenScrollBars(int startDelay) { |
| 19119 |
return awakenScrollBars(startDelay, true); |
| 19120 |
} |
| 19121 |
|
| 19122 |
|
| 19123 |
|
| 19124 |
|
| 19125 |
|
| 19126 |
|
| 19127 |
|
| 19128 |
|
| 19129 |
|
| 19130 |
|
| 19131 |
|
| 19132 |
|
| 19133 |
|
| 19134 |
|
| 19135 |
|
| 19136 |
|
| 19137 |
|
| 19138 |
|
| 19139 |
|
| 19140 |
|
| 19141 |
|
| 19142 |
|
| 19143 |
|
| 19144 |
|
| 19145 |
|
| 19146 |
|
| 19147 |
|
| 19148 |
|
| 19149 |
|
| 19150 |
|
| 19151 |
|
| 19152 |
|
| 19153 |
|
| 19154 |
|
| 19155 |
|
| 19156 |
|
| 19157 |
|
| 19158 |
|
| 19159 |
|
| 19160 |
protected boolean awakenScrollBars(int startDelay, boolean invalidate) { |
| 19161 |
final ScrollabilityCache scrollCache = mScrollCache; |
| 19162 |
|
| 19163 |
if (scrollCache == null || !scrollCache.fadeScrollBars) { |
| 19164 |
return false; |
| 19165 |
} |
| 19166 |
|
| 19167 |
if (scrollCache.scrollBar == null) { |
| 19168 |
scrollCache.scrollBar = new ScrollBarDrawable(); |
| 19169 |
scrollCache.scrollBar.setState(getDrawableState()); |
| 19170 |
scrollCache.scrollBar.setCallback(this); |
| 19171 |
} |
| 19172 |
|
| 19173 |
if (isHorizontalScrollBarEnabled() || isVerticalScrollBarEnabled()) { |
| 19174 |
|
| 19175 |
if (invalidate) { |
| 19176 |
|
| 19177 |
postInvalidateOnAnimation(); |
| 19178 |
} |
| 19179 |
|
| 19180 |
if (scrollCache.state == ScrollabilityCache.OFF) { |
| 19181 |
|
| 19182 |
|
| 19183 |
|
| 19184 |
final int KEY_REPEAT_FIRST_DELAY = 750; |
| 19185 |
startDelay = Math.max(KEY_REPEAT_FIRST_DELAY, startDelay); |
| 19186 |
} |
| 19187 |
|
| 19188 |
|
| 19189 |
|
| 19190 |
long fadeStartTime = AnimationUtils.currentAnimationTimeMillis() + startDelay; |
| 19191 |
scrollCache.fadeStartTime = fadeStartTime; |
| 19192 |
scrollCache.state = ScrollabilityCache.ON; |
| 19193 |
|
| 19194 |
|
| 19195 |
if (mAttachInfo != null) { |
| 19196 |
mAttachInfo.mHandler.removeCallbacks(scrollCache); |
| 19197 |
mAttachInfo.mHandler.postAtTime(scrollCache, fadeStartTime); |
| 19198 |
} |
| 19199 |
|
| 19200 |
return true; |
| 19201 |
} |
| 19202 |
|
| 19203 |
return false; |
| 19204 |
} |
| 19205 |
|
| 19206 |
|
| 19207 |
|
| 19208 |
|
| 19209 |
|
| 19210 |
private boolean skipInvalidate() { |
| 19211 |
return (mViewFlags & VISIBILITY_MASK) != VISIBLE && mCurrentAnimation == null && |
| 19212 |
(!(mParent instanceof ViewGroup) || |
| 19213 |
!((ViewGroup) mParent).isViewTransitioning(this)); |
| 19214 |
} |
| 19215 |
|
| 19216 |
|
| 19217 |
|
| 19218 |
|
| 19219 |
|
| 19220 |
|
| 19221 |
|
| 19222 |
|
| 19223 |
|
| 19224 |
|
| 19225 |
|
| 19226 |
|
| 19227 |
|
| 19228 |
|
| 19229 |
|
| 19230 |
|
| 19231 |
|
| 19232 |
|
| 19233 |
|
| 19234 |
@Deprecated |
| 19235 |
public void invalidate(Rect dirty) { |
| 19236 |
final int scrollX = mScrollX; |
| 19237 |
final int scrollY = mScrollY; |
| 19238 |
invalidateInternal(dirty.left - scrollX, dirty.top - scrollY, |
| 19239 |
dirty.right - scrollX, dirty.bottom - scrollY, true, false); |
| 19240 |
} |
| 19241 |
|
| 19242 |
|
| 19243 |
|
| 19244 |
|
| 19245 |
|
| 19246 |
|
| 19247 |
|
| 19248 |
|
| 19249 |
|
| 19250 |
|
| 19251 |
|
| 19252 |
|
| 19253 |
|
| 19254 |
|
| 19255 |
|
| 19256 |
|
| 19257 |
|
| 19258 |
|
| 19259 |
|
| 19260 |
|
| 19261 |
@Deprecated |
| 19262 |
public void invalidate(int l, int t, int r, int b) { |
| 19263 |
final int scrollX = mScrollX; |
| 19264 |
final int scrollY = mScrollY; |
| 19265 |
invalidateInternal(l - scrollX, t - scrollY, r - scrollX, b - scrollY, true, false); |
| 19266 |
} |
| 19267 |
|
| 19268 |
|
| 19269 |
|
| 19270 |
|
| 19271 |
|
| 19272 |
|
| 19273 |
|
| 19274 |
|
| 19275 |
|
| 19276 |
public void invalidate() { |
| 19277 |
invalidate(true); |
| 19278 |
} |
| 19279 |
|
| 19280 |
|
| 19281 |
|
| 19282 |
|
| 19283 |
|
| 19284 |
|
| 19285 |
|
| 19286 |
|
| 19287 |
|
| 19288 |
|
| 19289 |
|
| 19290 |
|
| 19291 |
|
| 19292 |
|
| 19293 |
@UnsupportedAppUsage |
| 19294 |
public void invalidate(boolean invalidateCache) { |
| 19295 |
invalidateInternal(0, 0, mRight - mLeft, mBottom - mTop, invalidateCache, true); |
| 19296 |
} |
| 19297 |
|
| 19298 |
void invalidateInternal(int l, int t, int r, int b, boolean invalidateCache, |
| 19299 |
boolean fullInvalidate) { |
| 19300 |
if (mGhostView != null) { |
| 19301 |
mGhostView.invalidate(true); |
| 19302 |
return; |
| 19303 |
} |
| 19304 |
|
| 19305 |
if (skipInvalidate()) { |
| 19306 |
return; |
| 19307 |
} |
| 19308 |
|
| 19309 |
|
| 19310 |
mPrivateFlags4 &= ~PFLAG4_CONTENT_CAPTURE_IMPORTANCE_MASK; |
| 19311 |
mContentCaptureSessionCached = false; |
| 19312 |
|
| 19313 |
if ((mPrivateFlags & (PFLAG_DRAWN | PFLAG_HAS_BOUNDS)) == (PFLAG_DRAWN | PFLAG_HAS_BOUNDS) |
| 19314 |
|| (invalidateCache && (mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) == PFLAG_DRAWING_CACHE_VALID) |
| 19315 |
|| (mPrivateFlags & PFLAG_INVALIDATED) != PFLAG_INVALIDATED |
| 19316 |
|| (fullInvalidate && isOpaque() != mLastIsOpaque)) { |
| 19317 |
if (fullInvalidate) { |
| 19318 |
mLastIsOpaque = isOpaque(); |
| 19319 |
mPrivateFlags &= ~PFLAG_DRAWN; |
| 19320 |
} |
| 19321 |
|
| 19322 |
mPrivateFlags |= PFLAG_DIRTY; |
| 19323 |
|
| 19324 |
if (invalidateCache) { |
| 19325 |
mPrivateFlags |= PFLAG_INVALIDATED; |
| 19326 |
mPrivateFlags &= ~PFLAG_DRAWING_CACHE_VALID; |
| 19327 |
} |
| 19328 |
|
| 19329 |
|
| 19330 |
final AttachInfo ai = mAttachInfo; |
| 19331 |
final ViewParent p = mParent; |
| 19332 |
if (p != null && ai != null && l < r && t < b) { |
| 19333 |
final Rect damage = ai.mTmpInvalRect; |
| 19334 |
damage.set(l, t, r, b); |
| 19335 |
p.invalidateChild(this, damage); |
| 19336 |
} |
| 19337 |
|
| 19338 |
|
| 19339 |
if (mBackground != null && mBackground.isProjected()) { |
| 19340 |
final View receiver = getProjectionReceiver(); |
| 19341 |
if (receiver != null) { |
| 19342 |
receiver.damageInParent(); |
| 19343 |
} |
| 19344 |
} |
| 19345 |
} |
| 19346 |
} |
| 19347 |
|
| 19348 |
|
| 19349 |
|
| 19350 |
|
| 19351 |
private View getProjectionReceiver() { |
| 19352 |
ViewParent p = getParent(); |
| 19353 |
while (p != null && p instanceof View) { |
| 19354 |
final View v = (View) p; |
| 19355 |
if (v.isProjectionReceiver()) { |
| 19356 |
return v; |
| 19357 |
} |
| 19358 |
p = p.getParent(); |
| 19359 |
} |
| 19360 |
|
| 19361 |
return null; |
| 19362 |
} |
| 19363 |
|
| 19364 |
|
| 19365 |
|
| 19366 |
|
| 19367 |
private boolean isProjectionReceiver() { |
| 19368 |
return mBackground != null; |
| 19369 |
} |
| 19370 |
|
| 19371 |
|
| 19372 |
|
| 19373 |
|
| 19374 |
|
| 19375 |
|
| 19376 |
|
| 19377 |
|
| 19378 |
|
| 19379 |
|
| 19380 |
|
| 19381 |
|
| 19382 |
|
| 19383 |
|
| 19384 |
|
| 19385 |
|
| 19386 |
|
| 19387 |
@UnsupportedAppUsage |
| 19388 |
void invalidateViewProperty(boolean invalidateParent, boolean forceRedraw) { |
| 19389 |
if (!isHardwareAccelerated() |
| 19390 |
|| !mRenderNode.hasDisplayList() |
| 19391 |
|| (mPrivateFlags & PFLAG_DRAW_ANIMATION) != 0) { |
| 19392 |
if (invalidateParent) { |
| 19393 |
invalidateParentCaches(); |
| 19394 |
} |
| 19395 |
if (forceRedraw) { |
| 19396 |
mPrivateFlags |= PFLAG_DRAWN; |
| 19397 |
} |
| 19398 |
invalidate(false); |
| 19399 |
} else { |
| 19400 |
damageInParent(); |
| 19401 |
} |
| 19402 |
} |
| 19403 |
|
| 19404 |
|
| 19405 |
|
| 19406 |
|
| 19407 |
|
| 19408 |
|
| 19409 |
protected void damageInParent() { |
| 19410 |
if (mParent != null && mAttachInfo != null) { |
| 19411 |
mParent.onDescendantInvalidated(this, this); |
| 19412 |
} |
| 19413 |
} |
| 19414 |
|
| 19415 |
|
| 19416 |
|
| 19417 |
|
| 19418 |
|
| 19419 |
|
| 19420 |
|
| 19421 |
|
| 19422 |
|
| 19423 |
|
| 19424 |
@UnsupportedAppUsage |
| 19425 |
protected void invalidateParentCaches() { |
| 19426 |
if (mParent instanceof View) { |
| 19427 |
((View) mParent).mPrivateFlags |= PFLAG_INVALIDATED; |
| 19428 |
} |
| 19429 |
} |
| 19430 |
|
| 19431 |
|
| 19432 |
|
| 19433 |
|
| 19434 |
|
| 19435 |
|
| 19436 |
|
| 19437 |
|
| 19438 |
|
| 19439 |
|
| 19440 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 19441 |
protected void invalidateParentIfNeeded() { |
| 19442 |
if (isHardwareAccelerated() && mParent instanceof View) { |
| 19443 |
((View) mParent).invalidate(true); |
| 19444 |
} |
| 19445 |
} |
| 19446 |
|
| 19447 |
|
| 19448 |
|
| 19449 |
|
| 19450 |
protected void invalidateParentIfNeededAndWasQuickRejected() { |
| 19451 |
if ((mPrivateFlags2 & PFLAG2_VIEW_QUICK_REJECTED) != 0) { |
| 19452 |
|
| 19453 |
invalidateParentIfNeeded(); |
| 19454 |
} |
| 19455 |
} |
| 19456 |
|
| 19457 |
|
| 19458 |
|
| 19459 |
|
| 19460 |
|
| 19461 |
|
| 19462 |
|
| 19463 |
|
| 19464 |
|
| 19465 |
|
| 19466 |
|
| 19467 |
|
| 19468 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 19469 |
public boolean isOpaque() { |
| 19470 |
return (mPrivateFlags & PFLAG_OPAQUE_MASK) == PFLAG_OPAQUE_MASK && |
| 19471 |
getFinalAlpha() >= 1.0f; |
| 19472 |
} |
| 19473 |
|
| 19474 |
|
| 19475 |
|
| 19476 |
|
| 19477 |
@UnsupportedAppUsage |
| 19478 |
protected void computeOpaqueFlags() { |
| 19479 |
|
| 19480 |
|
| 19481 |
|
| 19482 |
|
| 19483 |
|
| 19484 |
if (mBackground != null && mBackground.getOpacity() == PixelFormat.OPAQUE) { |
| 19485 |
mPrivateFlags |= PFLAG_OPAQUE_BACKGROUND; |
| 19486 |
} else { |
| 19487 |
mPrivateFlags &= ~PFLAG_OPAQUE_BACKGROUND; |
| 19488 |
} |
| 19489 |
|
| 19490 |
final int flags = mViewFlags; |
| 19491 |
if (((flags & SCROLLBARS_VERTICAL) == 0 && (flags & SCROLLBARS_HORIZONTAL) == 0) || |
| 19492 |
(flags & SCROLLBARS_STYLE_MASK) == SCROLLBARS_INSIDE_OVERLAY || |
| 19493 |
(flags & SCROLLBARS_STYLE_MASK) == SCROLLBARS_OUTSIDE_OVERLAY) { |
| 19494 |
mPrivateFlags |= PFLAG_OPAQUE_SCROLLBARS; |
| 19495 |
} else { |
| 19496 |
mPrivateFlags &= ~PFLAG_OPAQUE_SCROLLBARS; |
| 19497 |
} |
| 19498 |
} |
| 19499 |
|
| 19500 |
|
| 19501 |
|
| 19502 |
|
| 19503 |
protected boolean hasOpaqueScrollbars() { |
| 19504 |
return (mPrivateFlags & PFLAG_OPAQUE_SCROLLBARS) == PFLAG_OPAQUE_SCROLLBARS; |
| 19505 |
} |
| 19506 |
|
| 19507 |
|
| 19508 |
|
| 19509 |
|
| 19510 |
|
| 19511 |
public Handler getHandler() { |
| 19512 |
final AttachInfo attachInfo = mAttachInfo; |
| 19513 |
if (attachInfo != null) { |
| 19514 |
return attachInfo.mHandler; |
| 19515 |
} |
| 19516 |
return null; |
| 19517 |
} |
| 19518 |
|
| 19519 |
|
| 19520 |
|
| 19521 |
|
| 19522 |
|
| 19523 |
|
| 19524 |
private HandlerActionQueue getRunQueue() { |
| 19525 |
if (mRunQueue == null) { |
| 19526 |
mRunQueue = new HandlerActionQueue(); |
| 19527 |
} |
| 19528 |
return mRunQueue; |
| 19529 |
} |
| 19530 |
|
| 19531 |
|
| 19532 |
|
| 19533 |
|
| 19534 |
|
| 19535 |
|
| 19536 |
@UnsupportedAppUsage |
| 19537 |
public ViewRootImpl getViewRootImpl() { |
| 19538 |
if (mAttachInfo != null) { |
| 19539 |
return mAttachInfo.mViewRootImpl; |
| 19540 |
} |
| 19541 |
return null; |
| 19542 |
} |
| 19543 |
|
| 19544 |
|
| 19545 |
|
| 19546 |
|
| 19547 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 19548 |
public ThreadedRenderer getThreadedRenderer() { |
| 19549 |
return mAttachInfo != null ? mAttachInfo.mThreadedRenderer : null; |
| 19550 |
} |
| 19551 |
|
| 19552 |
|
| 19553 |
|
| 19554 |
|
| 19555 |
|
| 19556 |
|
| 19557 |
|
| 19558 |
|
| 19559 |
|
| 19560 |
|
| 19561 |
|
| 19562 |
|
| 19563 |
|
| 19564 |
|
| 19565 |
public boolean post(Runnable action) { |
| 19566 |
final AttachInfo attachInfo = mAttachInfo; |
| 19567 |
if (attachInfo != null) { |
| 19568 |
return attachInfo.mHandler.post(action); |
| 19569 |
} |
| 19570 |
|
| 19571 |
|
| 19572 |
|
| 19573 |
getRunQueue().post(action); |
| 19574 |
return true; |
| 19575 |
} |
| 19576 |
|
| 19577 |
|
| 19578 |
|
| 19579 |
|
| 19580 |
|
| 19581 |
|
| 19582 |
|
| 19583 |
|
| 19584 |
|
| 19585 |
|
| 19586 |
|
| 19587 |
|
| 19588 |
|
| 19589 |
|
| 19590 |
|
| 19591 |
|
| 19592 |
|
| 19593 |
|
| 19594 |
|
| 19595 |
|
| 19596 |
public boolean postDelayed(Runnable action, long delayMillis) { |
| 19597 |
final AttachInfo attachInfo = mAttachInfo; |
| 19598 |
if (attachInfo != null) { |
| 19599 |
return attachInfo.mHandler.postDelayed(action, delayMillis); |
| 19600 |
} |
| 19601 |
|
| 19602 |
|
| 19603 |
|
| 19604 |
getRunQueue().postDelayed(action, delayMillis); |
| 19605 |
return true; |
| 19606 |
} |
| 19607 |
|
| 19608 |
|
| 19609 |
|
| 19610 |
|
| 19611 |
|
| 19612 |
|
| 19613 |
|
| 19614 |
|
| 19615 |
|
| 19616 |
|
| 19617 |
public void postOnAnimation(Runnable action) { |
| 19618 |
final AttachInfo attachInfo = mAttachInfo; |
| 19619 |
if (attachInfo != null) { |
| 19620 |
attachInfo.mViewRootImpl.mChoreographer.postCallback( |
| 19621 |
Choreographer.CALLBACK_ANIMATION, action, null); |
| 19622 |
} else { |
| 19623 |
|
| 19624 |
|
| 19625 |
getRunQueue().post(action); |
| 19626 |
} |
| 19627 |
} |
| 19628 |
|
| 19629 |
|
| 19630 |
|
| 19631 |
|
| 19632 |
|
| 19633 |
|
| 19634 |
|
| 19635 |
|
| 19636 |
|
| 19637 |
|
| 19638 |
|
| 19639 |
|
| 19640 |
|
| 19641 |
public void postOnAnimationDelayed(Runnable action, long delayMillis) { |
| 19642 |
final AttachInfo attachInfo = mAttachInfo; |
| 19643 |
if (attachInfo != null) { |
| 19644 |
attachInfo.mViewRootImpl.mChoreographer.postCallbackDelayed( |
| 19645 |
Choreographer.CALLBACK_ANIMATION, action, null, delayMillis); |
| 19646 |
} else { |
| 19647 |
|
| 19648 |
|
| 19649 |
getRunQueue().postDelayed(action, delayMillis); |
| 19650 |
} |
| 19651 |
} |
| 19652 |
|
| 19653 |
|
| 19654 |
|
| 19655 |
|
| 19656 |
|
| 19657 |
|
| 19658 |
|
| 19659 |
|
| 19660 |
|
| 19661 |
|
| 19662 |
|
| 19663 |
|
| 19664 |
|
| 19665 |
|
| 19666 |
|
| 19667 |
|
| 19668 |
public boolean removeCallbacks(Runnable action) { |
| 19669 |
if (action != null) { |
| 19670 |
final AttachInfo attachInfo = mAttachInfo; |
| 19671 |
if (attachInfo != null) { |
| 19672 |
attachInfo.mHandler.removeCallbacks(action); |
| 19673 |
attachInfo.mViewRootImpl.mChoreographer.removeCallbacks( |
| 19674 |
Choreographer.CALLBACK_ANIMATION, action, null); |
| 19675 |
} |
| 19676 |
getRunQueue().removeCallbacks(action); |
| 19677 |
} |
| 19678 |
return true; |
| 19679 |
} |
| 19680 |
|
| 19681 |
|
| 19682 |
|
| 19683 |
|
| 19684 |
|
| 19685 |
|
| 19686 |
|
| 19687 |
|
| 19688 |
|
| 19689 |
|
| 19690 |
|
| 19691 |
public void postInvalidate() { |
| 19692 |
postInvalidateDelayed(0); |
| 19693 |
} |
| 19694 |
|
| 19695 |
|
| 19696 |
|
| 19697 |
|
| 19698 |
|
| 19699 |
|
| 19700 |
|
| 19701 |
|
| 19702 |
|
| 19703 |
|
| 19704 |
|
| 19705 |
|
| 19706 |
|
| 19707 |
|
| 19708 |
|
| 19709 |
|
| 19710 |
|
| 19711 |
public void postInvalidate(int left, int top, int right, int bottom) { |
| 19712 |
postInvalidateDelayed(0, left, top, right, bottom); |
| 19713 |
} |
| 19714 |
|
| 19715 |
|
| 19716 |
|
| 19717 |
|
| 19718 |
|
| 19719 |
|
| 19720 |
|
| 19721 |
|
| 19722 |
|
| 19723 |
|
| 19724 |
|
| 19725 |
|
| 19726 |
|
| 19727 |
|
| 19728 |
public void postInvalidateDelayed(long delayMilliseconds) { |
| 19729 |
|
| 19730 |
|
| 19731 |
final AttachInfo attachInfo = mAttachInfo; |
| 19732 |
if (attachInfo != null) { |
| 19733 |
attachInfo.mViewRootImpl.dispatchInvalidateDelayed(this, delayMilliseconds); |
| 19734 |
} |
| 19735 |
} |
| 19736 |
|
| 19737 |
|
| 19738 |
|
| 19739 |
|
| 19740 |
|
| 19741 |
|
| 19742 |
|
| 19743 |
|
| 19744 |
|
| 19745 |
|
| 19746 |
|
| 19747 |
|
| 19748 |
|
| 19749 |
|
| 19750 |
|
| 19751 |
|
| 19752 |
|
| 19753 |
|
| 19754 |
|
| 19755 |
public void postInvalidateDelayed(long delayMilliseconds, int left, int top, |
| 19756 |
int right, int bottom) { |
| 19757 |
|
| 19758 |
|
| 19759 |
|
| 19760 |
final AttachInfo attachInfo = mAttachInfo; |
| 19761 |
if (attachInfo != null) { |
| 19762 |
final AttachInfo.InvalidateInfo info = AttachInfo.InvalidateInfo.obtain(); |
| 19763 |
info.target = this; |
| 19764 |
info.left = left; |
| 19765 |
info.top = top; |
| 19766 |
info.right = right; |
| 19767 |
info.bottom = bottom; |
| 19768 |
|
| 19769 |
attachInfo.mViewRootImpl.dispatchInvalidateRectDelayed(info, delayMilliseconds); |
| 19770 |
} |
| 19771 |
} |
| 19772 |
|
| 19773 |
|
| 19774 |
|
| 19775 |
|
| 19776 |
|
| 19777 |
|
| 19778 |
|
| 19779 |
|
| 19780 |
|
| 19781 |
|
| 19782 |
public void postInvalidateOnAnimation() { |
| 19783 |
|
| 19784 |
|
| 19785 |
final AttachInfo attachInfo = mAttachInfo; |
| 19786 |
if (attachInfo != null) { |
| 19787 |
attachInfo.mViewRootImpl.dispatchInvalidateOnAnimation(this); |
| 19788 |
} |
| 19789 |
} |
| 19790 |
|
| 19791 |
|
| 19792 |
|
| 19793 |
|
| 19794 |
|
| 19795 |
|
| 19796 |
|
| 19797 |
|
| 19798 |
|
| 19799 |
|
| 19800 |
|
| 19801 |
|
| 19802 |
|
| 19803 |
|
| 19804 |
|
| 19805 |
|
| 19806 |
public void postInvalidateOnAnimation(int left, int top, int right, int bottom) { |
| 19807 |
|
| 19808 |
|
| 19809 |
final AttachInfo attachInfo = mAttachInfo; |
| 19810 |
if (attachInfo != null) { |
| 19811 |
final AttachInfo.InvalidateInfo info = AttachInfo.InvalidateInfo.obtain(); |
| 19812 |
info.target = this; |
| 19813 |
info.left = left; |
| 19814 |
info.top = top; |
| 19815 |
info.right = right; |
| 19816 |
info.bottom = bottom; |
| 19817 |
|
| 19818 |
attachInfo.mViewRootImpl.dispatchInvalidateRectOnAnimation(info); |
| 19819 |
} |
| 19820 |
} |
| 19821 |
|
| 19822 |
|
| 19823 |
|
| 19824 |
|
| 19825 |
|
| 19826 |
|
| 19827 |
private void postSendViewScrolledAccessibilityEventCallback(int dx, int dy) { |
| 19828 |
if (AccessibilityManager.getInstance(mContext).isEnabled()) { |
| 19829 |
AccessibilityEvent event = |
| 19830 |
AccessibilityEvent.obtain(AccessibilityEvent.TYPE_VIEW_SCROLLED); |
| 19831 |
event.setScrollDeltaX(dx); |
| 19832 |
event.setScrollDeltaY(dy); |
| 19833 |
sendAccessibilityEventUnchecked(event); |
| 19834 |
} |
| 19835 |
} |
| 19836 |
|
| 19837 |
|
| 19838 |
|
| 19839 |
|
| 19840 |
|
| 19841 |
|
| 19842 |
|
| 19843 |
public void computeScroll() { |
| 19844 |
} |
| 19845 |
|
| 19846 |
|
| 19847 |
|
| 19848 |
|
| 19849 |
|
| 19850 |
|
| 19851 |
|
| 19852 |
|
| 19853 |
|
| 19854 |
|
| 19855 |
|
| 19856 |
|
| 19857 |
public boolean isHorizontalFadingEdgeEnabled() { |
| 19858 |
return (mViewFlags & FADING_EDGE_HORIZONTAL) == FADING_EDGE_HORIZONTAL; |
| 19859 |
} |
| 19860 |
|
| 19861 |
|
| 19862 |
|
| 19863 |
|
| 19864 |
|
| 19865 |
|
| 19866 |
|
| 19867 |
|
| 19868 |
|
| 19869 |
|
| 19870 |
|
| 19871 |
|
| 19872 |
|
| 19873 |
public void setHorizontalFadingEdgeEnabled(boolean horizontalFadingEdgeEnabled) { |
| 19874 |
if (isHorizontalFadingEdgeEnabled() != horizontalFadingEdgeEnabled) { |
| 19875 |
if (horizontalFadingEdgeEnabled) { |
| 19876 |
initScrollCache(); |
| 19877 |
} |
| 19878 |
|
| 19879 |
mViewFlags ^= FADING_EDGE_HORIZONTAL; |
| 19880 |
} |
| 19881 |
} |
| 19882 |
|
| 19883 |
|
| 19884 |
|
| 19885 |
|
| 19886 |
|
| 19887 |
|
| 19888 |
|
| 19889 |
|
| 19890 |
|
| 19891 |
|
| 19892 |
|
| 19893 |
|
| 19894 |
public boolean isVerticalFadingEdgeEnabled() { |
| 19895 |
return (mViewFlags & FADING_EDGE_VERTICAL) == FADING_EDGE_VERTICAL; |
| 19896 |
} |
| 19897 |
|
| 19898 |
|
| 19899 |
|
| 19900 |
|
| 19901 |
|
| 19902 |
|
| 19903 |
|
| 19904 |
|
| 19905 |
|
| 19906 |
|
| 19907 |
|
| 19908 |
|
| 19909 |
|
| 19910 |
public void setVerticalFadingEdgeEnabled(boolean verticalFadingEdgeEnabled) { |
| 19911 |
if (isVerticalFadingEdgeEnabled() != verticalFadingEdgeEnabled) { |
| 19912 |
if (verticalFadingEdgeEnabled) { |
| 19913 |
initScrollCache(); |
| 19914 |
} |
| 19915 |
|
| 19916 |
mViewFlags ^= FADING_EDGE_VERTICAL; |
| 19917 |
} |
| 19918 |
} |
| 19919 |
|
| 19920 |
|
| 19921 |
|
| 19922 |
|
| 19923 |
|
| 19924 |
|
| 19925 |
|
| 19926 |
|
| 19927 |
@InspectableProperty(name = "requiresFadingEdge", flagMapping = { |
| 19928 |
@FlagEntry(target = FADING_EDGE_NONE, mask = FADING_EDGE_MASK, name = "none"), |
| 19929 |
@FlagEntry(target = FADING_EDGE_VERTICAL, name = "vertical"), |
| 19930 |
@FlagEntry(target = FADING_EDGE_HORIZONTAL, name = "horizontal") |
| 19931 |
}) |
| 19932 |
public int getFadingEdge() { |
| 19933 |
return mViewFlags & FADING_EDGE_MASK; |
| 19934 |
} |
| 19935 |
|
| 19936 |
|
| 19937 |
|
| 19938 |
|
| 19939 |
|
| 19940 |
|
| 19941 |
|
| 19942 |
@InspectableProperty |
| 19943 |
public int getFadingEdgeLength() { |
| 19944 |
if (mScrollCache != null && (mViewFlags & FADING_EDGE_MASK) != FADING_EDGE_NONE) { |
| 19945 |
return mScrollCache.fadingEdgeLength; |
| 19946 |
} |
| 19947 |
return 0; |
| 19948 |
} |
| 19949 |
|
| 19950 |
|
| 19951 |
|
| 19952 |
|
| 19953 |
|
| 19954 |
|
| 19955 |
|
| 19956 |
|
| 19957 |
|
| 19958 |
|
| 19959 |
|
| 19960 |
protected float getTopFadingEdgeStrength() { |
| 19961 |
return computeVerticalScrollOffset() > 0 ? 1.0f : 0.0f; |
| 19962 |
} |
| 19963 |
|
| 19964 |
|
| 19965 |
|
| 19966 |
|
| 19967 |
|
| 19968 |
|
| 19969 |
|
| 19970 |
|
| 19971 |
|
| 19972 |
|
| 19973 |
|
| 19974 |
protected float getBottomFadingEdgeStrength() { |
| 19975 |
return computeVerticalScrollOffset() + computeVerticalScrollExtent() < |
| 19976 |
computeVerticalScrollRange() ? 1.0f : 0.0f; |
| 19977 |
} |
| 19978 |
|
| 19979 |
|
| 19980 |
|
| 19981 |
|
| 19982 |
|
| 19983 |
|
| 19984 |
|
| 19985 |
|
| 19986 |
|
| 19987 |
|
| 19988 |
|
| 19989 |
protected float getLeftFadingEdgeStrength() { |
| 19990 |
return computeHorizontalScrollOffset() > 0 ? 1.0f : 0.0f; |
| 19991 |
} |
| 19992 |
|
| 19993 |
|
| 19994 |
|
| 19995 |
|
| 19996 |
|
| 19997 |
|
| 19998 |
|
| 19999 |
|
| 20000 |
|
| 20001 |
|
| 20002 |
|
| 20003 |
protected float getRightFadingEdgeStrength() { |
| 20004 |
return computeHorizontalScrollOffset() + computeHorizontalScrollExtent() < |
| 20005 |
computeHorizontalScrollRange() ? 1.0f : 0.0f; |
| 20006 |
} |
| 20007 |
|
| 20008 |
|
| 20009 |
|
| 20010 |
|
| 20011 |
|
| 20012 |
|
| 20013 |
|
| 20014 |
|
| 20015 |
|
| 20016 |
|
| 20017 |
public boolean isHorizontalScrollBarEnabled() { |
| 20018 |
return (mViewFlags & SCROLLBARS_HORIZONTAL) == SCROLLBARS_HORIZONTAL; |
| 20019 |
} |
| 20020 |
|
| 20021 |
|
| 20022 |
|
| 20023 |
|
| 20024 |
|
| 20025 |
|
| 20026 |
|
| 20027 |
|
| 20028 |
|
| 20029 |
|
| 20030 |
public void setHorizontalScrollBarEnabled(boolean horizontalScrollBarEnabled) { |
| 20031 |
if (isHorizontalScrollBarEnabled() != horizontalScrollBarEnabled) { |
| 20032 |
mViewFlags ^= SCROLLBARS_HORIZONTAL; |
| 20033 |
computeOpaqueFlags(); |
| 20034 |
resolvePadding(); |
| 20035 |
} |
| 20036 |
} |
| 20037 |
|
| 20038 |
|
| 20039 |
|
| 20040 |
|
| 20041 |
|
| 20042 |
|
| 20043 |
|
| 20044 |
|
| 20045 |
|
| 20046 |
|
| 20047 |
public boolean isVerticalScrollBarEnabled() { |
| 20048 |
return (mViewFlags & SCROLLBARS_VERTICAL) == SCROLLBARS_VERTICAL; |
| 20049 |
} |
| 20050 |
|
| 20051 |
|
| 20052 |
|
| 20053 |
|
| 20054 |
|
| 20055 |
|
| 20056 |
|
| 20057 |
|
| 20058 |
|
| 20059 |
|
| 20060 |
public void setVerticalScrollBarEnabled(boolean verticalScrollBarEnabled) { |
| 20061 |
if (isVerticalScrollBarEnabled() != verticalScrollBarEnabled) { |
| 20062 |
mViewFlags ^= SCROLLBARS_VERTICAL; |
| 20063 |
computeOpaqueFlags(); |
| 20064 |
resolvePadding(); |
| 20065 |
} |
| 20066 |
} |
| 20067 |
|
| 20068 |
|
| 20069 |
|
| 20070 |
|
| 20071 |
@UnsupportedAppUsage |
| 20072 |
protected void recomputePadding() { |
| 20073 |
internalSetPadding(mUserPaddingLeft, mPaddingTop, mUserPaddingRight, mUserPaddingBottom); |
| 20074 |
} |
| 20075 |
|
| 20076 |
|
| 20077 |
|
| 20078 |
|
| 20079 |
|
| 20080 |
|
| 20081 |
|
| 20082 |
|
| 20083 |
public void setScrollbarFadingEnabled(boolean fadeScrollbars) { |
| 20084 |
initScrollCache(); |
| 20085 |
final ScrollabilityCache scrollabilityCache = mScrollCache; |
| 20086 |
scrollabilityCache.fadeScrollBars = fadeScrollbars; |
| 20087 |
if (fadeScrollbars) { |
| 20088 |
scrollabilityCache.state = ScrollabilityCache.OFF; |
| 20089 |
} else { |
| 20090 |
scrollabilityCache.state = ScrollabilityCache.ON; |
| 20091 |
} |
| 20092 |
} |
| 20093 |
|
| 20094 |
|
| 20095 |
|
| 20096 |
|
| 20097 |
|
| 20098 |
|
| 20099 |
|
| 20100 |
|
| 20101 |
|
| 20102 |
public boolean isScrollbarFadingEnabled() { |
| 20103 |
return mScrollCache != null && mScrollCache.fadeScrollBars; |
| 20104 |
} |
| 20105 |
|
| 20106 |
|
| 20107 |
|
| 20108 |
|
| 20109 |
|
| 20110 |
|
| 20111 |
|
| 20112 |
|
| 20113 |
|
| 20114 |
@InspectableProperty(name = "scrollbarDefaultDelayBeforeFade") |
| 20115 |
public int getScrollBarDefaultDelayBeforeFade() { |
| 20116 |
return mScrollCache == null ? ViewConfiguration.getScrollDefaultDelay() : |
| 20117 |
mScrollCache.scrollBarDefaultDelayBeforeFade; |
| 20118 |
} |
| 20119 |
|
| 20120 |
|
| 20121 |
|
| 20122 |
|
| 20123 |
|
| 20124 |
|
| 20125 |
|
| 20126 |
|
| 20127 |
public void setScrollBarDefaultDelayBeforeFade(int scrollBarDefaultDelayBeforeFade) { |
| 20128 |
getScrollCache().scrollBarDefaultDelayBeforeFade = scrollBarDefaultDelayBeforeFade; |
| 20129 |
} |
| 20130 |
|
| 20131 |
|
| 20132 |
|
| 20133 |
|
| 20134 |
|
| 20135 |
|
| 20136 |
|
| 20137 |
|
| 20138 |
|
| 20139 |
@InspectableProperty(name = "scrollbarFadeDuration") |
| 20140 |
public int getScrollBarFadeDuration() { |
| 20141 |
return mScrollCache == null ? ViewConfiguration.getScrollBarFadeDuration() : |
| 20142 |
mScrollCache.scrollBarFadeDuration; |
| 20143 |
} |
| 20144 |
|
| 20145 |
|
| 20146 |
|
| 20147 |
|
| 20148 |
|
| 20149 |
|
| 20150 |
|
| 20151 |
|
| 20152 |
public void setScrollBarFadeDuration(int scrollBarFadeDuration) { |
| 20153 |
getScrollCache().scrollBarFadeDuration = scrollBarFadeDuration; |
| 20154 |
} |
| 20155 |
|
| 20156 |
|
| 20157 |
|
| 20158 |
|
| 20159 |
|
| 20160 |
|
| 20161 |
|
| 20162 |
|
| 20163 |
|
| 20164 |
@InspectableProperty(name = "scrollbarSize") |
| 20165 |
public int getScrollBarSize() { |
| 20166 |
return mScrollCache == null ? ViewConfiguration.get(mContext).getScaledScrollBarSize() : |
| 20167 |
mScrollCache.scrollBarSize; |
| 20168 |
} |
| 20169 |
|
| 20170 |
|
| 20171 |
|
| 20172 |
|
| 20173 |
|
| 20174 |
|
| 20175 |
|
| 20176 |
|
| 20177 |
public void setScrollBarSize(int scrollBarSize) { |
| 20178 |
getScrollCache().scrollBarSize = scrollBarSize; |
| 20179 |
} |
| 20180 |
|
| 20181 |
|
| 20182 |
|
| 20183 |
|
| 20184 |
|
| 20185 |
|
| 20186 |
|
| 20187 |
|
| 20188 |
|
| 20189 |
|
| 20190 |
|
| 20191 |
|
| 20192 |
|
| 20193 |
|
| 20194 |
|
| 20195 |
|
| 20196 |
|
| 20197 |
|
| 20198 |
|
| 20199 |
|
| 20200 |
public void setScrollBarStyle(@ScrollBarStyle int style) { |
| 20201 |
if (style != (mViewFlags & SCROLLBARS_STYLE_MASK)) { |
| 20202 |
mViewFlags = (mViewFlags & ~SCROLLBARS_STYLE_MASK) | (style & SCROLLBARS_STYLE_MASK); |
| 20203 |
computeOpaqueFlags(); |
| 20204 |
resolvePadding(); |
| 20205 |
} |
| 20206 |
} |
| 20207 |
|
| 20208 |
|
| 20209 |
|
| 20210 |
|
| 20211 |
|
| 20212 |
|
| 20213 |
|
| 20214 |
|
| 20215 |
|
| 20216 |
|
| 20217 |
|
| 20218 |
@ViewDebug.ExportedProperty(mapping = { |
| 20219 |
@ViewDebug.IntToString(from = SCROLLBARS_INSIDE_OVERLAY, to = "INSIDE_OVERLAY"), |
| 20220 |
@ViewDebug.IntToString(from = SCROLLBARS_INSIDE_INSET, to = "INSIDE_INSET"), |
| 20221 |
@ViewDebug.IntToString(from = SCROLLBARS_OUTSIDE_OVERLAY, to = "OUTSIDE_OVERLAY"), |
| 20222 |
@ViewDebug.IntToString(from = SCROLLBARS_OUTSIDE_INSET, to = "OUTSIDE_INSET") |
| 20223 |
}) |
| 20224 |
@InspectableProperty(name = "scrollbarStyle", enumMapping = { |
| 20225 |
@EnumEntry(value = SCROLLBARS_INSIDE_OVERLAY, name = "insideOverlay"), |
| 20226 |
@EnumEntry(value = SCROLLBARS_INSIDE_INSET, name = "insideInset"), |
| 20227 |
@EnumEntry(value = SCROLLBARS_OUTSIDE_OVERLAY, name = "outsideOverlay"), |
| 20228 |
@EnumEntry(value = SCROLLBARS_OUTSIDE_INSET, name = "outsideInset") |
| 20229 |
}) |
| 20230 |
@ScrollBarStyle |
| 20231 |
public int getScrollBarStyle() { |
| 20232 |
return mViewFlags & SCROLLBARS_STYLE_MASK; |
| 20233 |
} |
| 20234 |
|
| 20235 |
|
| 20236 |
|
| 20237 |
|
| 20238 |
|
| 20239 |
|
| 20240 |
|
| 20241 |
|
| 20242 |
|
| 20243 |
|
| 20244 |
|
| 20245 |
|
| 20246 |
|
| 20247 |
|
| 20248 |
|
| 20249 |
|
| 20250 |
|
| 20251 |
protected int computeHorizontalScrollRange() { |
| 20252 |
return getWidth(); |
| 20253 |
} |
| 20254 |
|
| 20255 |
|
| 20256 |
|
| 20257 |
|
| 20258 |
|
| 20259 |
|
| 20260 |
|
| 20261 |
|
| 20262 |
|
| 20263 |
|
| 20264 |
|
| 20265 |
|
| 20266 |
|
| 20267 |
|
| 20268 |
|
| 20269 |
|
| 20270 |
|
| 20271 |
protected int computeHorizontalScrollOffset() { |
| 20272 |
return mScrollX; |
| 20273 |
} |
| 20274 |
|
| 20275 |
|
| 20276 |
|
| 20277 |
|
| 20278 |
|
| 20279 |
|
| 20280 |
|
| 20281 |
|
| 20282 |
|
| 20283 |
|
| 20284 |
|
| 20285 |
|
| 20286 |
|
| 20287 |
|
| 20288 |
|
| 20289 |
|
| 20290 |
|
| 20291 |
protected int computeHorizontalScrollExtent() { |
| 20292 |
return getWidth(); |
| 20293 |
} |
| 20294 |
|
| 20295 |
|
| 20296 |
|
| 20297 |
|
| 20298 |
|
| 20299 |
|
| 20300 |
|
| 20301 |
|
| 20302 |
|
| 20303 |
|
| 20304 |
|
| 20305 |
|
| 20306 |
|
| 20307 |
|
| 20308 |
|
| 20309 |
protected int computeVerticalScrollRange() { |
| 20310 |
return getHeight(); |
| 20311 |
} |
| 20312 |
|
| 20313 |
|
| 20314 |
|
| 20315 |
|
| 20316 |
|
| 20317 |
|
| 20318 |
|
| 20319 |
|
| 20320 |
|
| 20321 |
|
| 20322 |
|
| 20323 |
|
| 20324 |
|
| 20325 |
|
| 20326 |
|
| 20327 |
|
| 20328 |
|
| 20329 |
protected int computeVerticalScrollOffset() { |
| 20330 |
return mScrollY; |
| 20331 |
} |
| 20332 |
|
| 20333 |
|
| 20334 |
|
| 20335 |
|
| 20336 |
|
| 20337 |
|
| 20338 |
|
| 20339 |
|
| 20340 |
|
| 20341 |
|
| 20342 |
|
| 20343 |
|
| 20344 |
|
| 20345 |
|
| 20346 |
|
| 20347 |
|
| 20348 |
|
| 20349 |
protected int computeVerticalScrollExtent() { |
| 20350 |
return getHeight(); |
| 20351 |
} |
| 20352 |
|
| 20353 |
|
| 20354 |
|
| 20355 |
|
| 20356 |
|
| 20357 |
|
| 20358 |
|
| 20359 |
|
| 20360 |
|
| 20361 |
|
| 20362 |
public boolean canScrollHorizontally(int direction) { |
| 20363 |
final int offset = computeHorizontalScrollOffset(); |
| 20364 |
final int range = computeHorizontalScrollRange() - computeHorizontalScrollExtent(); |
| 20365 |
if (range == 0) return false; |
| 20366 |
if (direction < 0) { |
| 20367 |
return offset > 0; |
| 20368 |
} else { |
| 20369 |
return offset < range - 1; |
| 20370 |
} |
| 20371 |
} |
| 20372 |
|
| 20373 |
|
| 20374 |
|
| 20375 |
|
| 20376 |
|
| 20377 |
|
| 20378 |
|
| 20379 |
|
| 20380 |
|
| 20381 |
|
| 20382 |
public boolean canScrollVertically(int direction) { |
| 20383 |
final int offset = computeVerticalScrollOffset(); |
| 20384 |
final int range = computeVerticalScrollRange() - computeVerticalScrollExtent(); |
| 20385 |
if (range == 0) return false; |
| 20386 |
if (direction < 0) { |
| 20387 |
return offset > 0; |
| 20388 |
} else { |
| 20389 |
return offset < range - 1; |
| 20390 |
} |
| 20391 |
} |
| 20392 |
|
| 20393 |
void getScrollIndicatorBounds(@NonNull Rect out) { |
| 20394 |
out.left = mScrollX; |
| 20395 |
out.right = mScrollX + mRight - mLeft; |
| 20396 |
out.top = mScrollY; |
| 20397 |
out.bottom = mScrollY + mBottom - mTop; |
| 20398 |
} |
| 20399 |
|
| 20400 |
private void onDrawScrollIndicators(Canvas c) { |
| 20401 |
if ((mPrivateFlags3 & SCROLL_INDICATORS_PFLAG3_MASK) == 0) { |
| 20402 |
|
| 20403 |
return; |
| 20404 |
} |
| 20405 |
|
| 20406 |
final Drawable dr = mScrollIndicatorDrawable; |
| 20407 |
if (dr == null) { |
| 20408 |
|
| 20409 |
return; |
| 20410 |
} |
| 20411 |
|
| 20412 |
if (mAttachInfo == null) { |
| 20413 |
|
| 20414 |
return; |
| 20415 |
} |
| 20416 |
|
| 20417 |
final int h = dr.getIntrinsicHeight(); |
| 20418 |
final int w = dr.getIntrinsicWidth(); |
| 20419 |
final Rect rect = mAttachInfo.mTmpInvalRect; |
| 20420 |
getScrollIndicatorBounds(rect); |
| 20421 |
|
| 20422 |
if ((mPrivateFlags3 & PFLAG3_SCROLL_INDICATOR_TOP) != 0) { |
| 20423 |
final boolean canScrollUp = canScrollVertically(-1); |
| 20424 |
if (canScrollUp) { |
| 20425 |
dr.setBounds(rect.left, rect.top, rect.right, rect.top + h); |
| 20426 |
dr.draw(c); |
| 20427 |
} |
| 20428 |
} |
| 20429 |
|
| 20430 |
if ((mPrivateFlags3 & PFLAG3_SCROLL_INDICATOR_BOTTOM) != 0) { |
| 20431 |
final boolean canScrollDown = canScrollVertically(1); |
| 20432 |
if (canScrollDown) { |
| 20433 |
dr.setBounds(rect.left, rect.bottom - h, rect.right, rect.bottom); |
| 20434 |
dr.draw(c); |
| 20435 |
} |
| 20436 |
} |
| 20437 |
|
| 20438 |
final int leftRtl; |
| 20439 |
final int rightRtl; |
| 20440 |
if (getLayoutDirection() == LAYOUT_DIRECTION_RTL) { |
| 20441 |
leftRtl = PFLAG3_SCROLL_INDICATOR_END; |
| 20442 |
rightRtl = PFLAG3_SCROLL_INDICATOR_START; |
| 20443 |
} else { |
| 20444 |
leftRtl = PFLAG3_SCROLL_INDICATOR_START; |
| 20445 |
rightRtl = PFLAG3_SCROLL_INDICATOR_END; |
| 20446 |
} |
| 20447 |
|
| 20448 |
final int leftMask = PFLAG3_SCROLL_INDICATOR_LEFT | leftRtl; |
| 20449 |
if ((mPrivateFlags3 & leftMask) != 0) { |
| 20450 |
final boolean canScrollLeft = canScrollHorizontally(-1); |
| 20451 |
if (canScrollLeft) { |
| 20452 |
dr.setBounds(rect.left, rect.top, rect.left + w, rect.bottom); |
| 20453 |
dr.draw(c); |
| 20454 |
} |
| 20455 |
} |
| 20456 |
|
| 20457 |
final int rightMask = PFLAG3_SCROLL_INDICATOR_RIGHT | rightRtl; |
| 20458 |
if ((mPrivateFlags3 & rightMask) != 0) { |
| 20459 |
final boolean canScrollRight = canScrollHorizontally(1); |
| 20460 |
if (canScrollRight) { |
| 20461 |
dr.setBounds(rect.right - w, rect.top, rect.right, rect.bottom); |
| 20462 |
dr.draw(c); |
| 20463 |
} |
| 20464 |
} |
| 20465 |
} |
| 20466 |
|
| 20467 |
private void getHorizontalScrollBarBounds(@Nullable Rect drawBounds, |
| 20468 |
@Nullable Rect touchBounds) { |
| 20469 |
final Rect bounds = drawBounds != null ? drawBounds : touchBounds; |
| 20470 |
if (bounds == null) { |
| 20471 |
return; |
| 20472 |
} |
| 20473 |
final int inside = (mViewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0; |
| 20474 |
final boolean drawVerticalScrollBar = isVerticalScrollBarEnabled() |
| 20475 |
&& !isVerticalScrollBarHidden(); |
| 20476 |
final int size = getHorizontalScrollbarHeight(); |
| 20477 |
final int verticalScrollBarGap = drawVerticalScrollBar ? |
| 20478 |
getVerticalScrollbarWidth() : 0; |
| 20479 |
final int width = mRight - mLeft; |
| 20480 |
final int height = mBottom - mTop; |
| 20481 |
bounds.top = mScrollY + height - size - (mUserPaddingBottom & inside); |
| 20482 |
bounds.left = mScrollX + (mPaddingLeft & inside); |
| 20483 |
bounds.right = mScrollX + width - (mUserPaddingRight & inside) - verticalScrollBarGap; |
| 20484 |
bounds.bottom = bounds.top + size; |
| 20485 |
|
| 20486 |
if (touchBounds == null) { |
| 20487 |
return; |
| 20488 |
} |
| 20489 |
if (touchBounds != bounds) { |
| 20490 |
touchBounds.set(bounds); |
| 20491 |
} |
| 20492 |
final int minTouchTarget = mScrollCache.scrollBarMinTouchTarget; |
| 20493 |
if (touchBounds.height() < minTouchTarget) { |
| 20494 |
final int adjust = (minTouchTarget - touchBounds.height()) / 2; |
| 20495 |
touchBounds.bottom = Math.min(touchBounds.bottom + adjust, mScrollY + height); |
| 20496 |
touchBounds.top = touchBounds.bottom - minTouchTarget; |
| 20497 |
} |
| 20498 |
if (touchBounds.width() < minTouchTarget) { |
| 20499 |
final int adjust = (minTouchTarget - touchBounds.width()) / 2; |
| 20500 |
touchBounds.left -= adjust; |
| 20501 |
touchBounds.right = touchBounds.left + minTouchTarget; |
| 20502 |
} |
| 20503 |
} |
| 20504 |
|
| 20505 |
private void getVerticalScrollBarBounds(@Nullable Rect bounds, @Nullable Rect touchBounds) { |
| 20506 |
if (mRoundScrollbarRenderer == null) { |
| 20507 |
getStraightVerticalScrollBarBounds(bounds, touchBounds); |
| 20508 |
} else { |
| 20509 |
getRoundVerticalScrollBarBounds(bounds != null ? bounds : touchBounds); |
| 20510 |
} |
| 20511 |
} |
| 20512 |
|
| 20513 |
private void getRoundVerticalScrollBarBounds(Rect bounds) { |
| 20514 |
final int width = mRight - mLeft; |
| 20515 |
final int height = mBottom - mTop; |
| 20516 |
|
| 20517 |
|
| 20518 |
bounds.left = mScrollX; |
| 20519 |
bounds.top = mScrollY; |
| 20520 |
bounds.right = bounds.left + width; |
| 20521 |
bounds.bottom = mScrollY + height; |
| 20522 |
} |
| 20523 |
|
| 20524 |
private void getStraightVerticalScrollBarBounds(@Nullable Rect drawBounds, |
| 20525 |
@Nullable Rect touchBounds) { |
| 20526 |
final Rect bounds = drawBounds != null ? drawBounds : touchBounds; |
| 20527 |
if (bounds == null) { |
| 20528 |
return; |
| 20529 |
} |
| 20530 |
final int inside = (mViewFlags & SCROLLBARS_OUTSIDE_MASK) == 0 ? ~0 : 0; |
| 20531 |
final int size = getVerticalScrollbarWidth(); |
| 20532 |
int verticalScrollbarPosition = mVerticalScrollbarPosition; |
| 20533 |
if (verticalScrollbarPosition == SCROLLBAR_POSITION_DEFAULT) { |
| 20534 |
verticalScrollbarPosition = isLayoutRtl() ? |
| 20535 |
SCROLLBAR_POSITION_LEFT : SCROLLBAR_POSITION_RIGHT; |
| 20536 |
} |
| 20537 |
final int width = mRight - mLeft; |
| 20538 |
final int height = mBottom - mTop; |
| 20539 |
switch (verticalScrollbarPosition) { |
| 20540 |
default: |
| 20541 |
case SCROLLBAR_POSITION_RIGHT: |
| 20542 |
bounds.left = mScrollX + width - size - (mUserPaddingRight & inside); |
| 20543 |
break; |
| 20544 |
case SCROLLBAR_POSITION_LEFT: |
| 20545 |
bounds.left = mScrollX + (mUserPaddingLeft & inside); |
| 20546 |
break; |
| 20547 |
} |
| 20548 |
bounds.top = mScrollY + (mPaddingTop & inside); |
| 20549 |
bounds.right = bounds.left + size; |
| 20550 |
bounds.bottom = mScrollY + height - (mUserPaddingBottom & inside); |
| 20551 |
|
| 20552 |
if (touchBounds == null) { |
| 20553 |
return; |
| 20554 |
} |
| 20555 |
if (touchBounds != bounds) { |
| 20556 |
touchBounds.set(bounds); |
| 20557 |
} |
| 20558 |
final int minTouchTarget = mScrollCache.scrollBarMinTouchTarget; |
| 20559 |
if (touchBounds.width() < minTouchTarget) { |
| 20560 |
final int adjust = (minTouchTarget - touchBounds.width()) / 2; |
| 20561 |
if (verticalScrollbarPosition == SCROLLBAR_POSITION_RIGHT) { |
| 20562 |
touchBounds.right = Math.min(touchBounds.right + adjust, mScrollX + width); |
| 20563 |
touchBounds.left = touchBounds.right - minTouchTarget; |
| 20564 |
} else { |
| 20565 |
touchBounds.left = Math.max(touchBounds.left + adjust, mScrollX); |
| 20566 |
touchBounds.right = touchBounds.left + minTouchTarget; |
| 20567 |
} |
| 20568 |
} |
| 20569 |
if (touchBounds.height() < minTouchTarget) { |
| 20570 |
final int adjust = (minTouchTarget - touchBounds.height()) / 2; |
| 20571 |
touchBounds.top -= adjust; |
| 20572 |
touchBounds.bottom = touchBounds.top + minTouchTarget; |
| 20573 |
} |
| 20574 |
} |
| 20575 |
|
| 20576 |
|
| 20577 |
|
| 20578 |
|
| 20579 |
|
| 20580 |
|
| 20581 |
|
| 20582 |
|
| 20583 |
|
| 20584 |
protected final void onDrawScrollBars(Canvas canvas) { |
| 20585 |
|
| 20586 |
final ScrollabilityCache cache = mScrollCache; |
| 20587 |
|
| 20588 |
if (cache != null) { |
| 20589 |
|
| 20590 |
int state = cache.state; |
| 20591 |
|
| 20592 |
if (state == ScrollabilityCache.OFF) { |
| 20593 |
return; |
| 20594 |
} |
| 20595 |
|
| 20596 |
boolean invalidate = false; |
| 20597 |
|
| 20598 |
if (state == ScrollabilityCache.FADING) { |
| 20599 |
|
| 20600 |
if (cache.interpolatorValues == null) { |
| 20601 |
cache.interpolatorValues = new float[1]; |
| 20602 |
} |
| 20603 |
|
| 20604 |
float[] values = cache.interpolatorValues; |
| 20605 |
|
| 20606 |
|
| 20607 |
if (cache.scrollBarInterpolator.timeToValues(values) == |
| 20608 |
Interpolator.Result.FREEZE_END) { |
| 20609 |
cache.state = ScrollabilityCache.OFF; |
| 20610 |
} else { |
| 20611 |
cache.scrollBar.mutate().setAlpha(Math.round(values[0])); |
| 20612 |
} |
| 20613 |
|
| 20614 |
|
| 20615 |
|
| 20616 |
|
| 20617 |
invalidate = true; |
| 20618 |
} else { |
| 20619 |
|
| 20620 |
|
| 20621 |
cache.scrollBar.mutate().setAlpha(255); |
| 20622 |
} |
| 20623 |
|
| 20624 |
final boolean drawHorizontalScrollBar = isHorizontalScrollBarEnabled(); |
| 20625 |
final boolean drawVerticalScrollBar = isVerticalScrollBarEnabled() |
| 20626 |
&& !isVerticalScrollBarHidden(); |
| 20627 |
|
| 20628 |
|
| 20629 |
if (mRoundScrollbarRenderer != null) { |
| 20630 |
if (drawVerticalScrollBar) { |
| 20631 |
final Rect bounds = cache.mScrollBarBounds; |
| 20632 |
getVerticalScrollBarBounds(bounds, null); |
| 20633 |
mRoundScrollbarRenderer.drawRoundScrollbars( |
| 20634 |
canvas, (float) cache.scrollBar.getAlpha() / 255f, bounds); |
| 20635 |
if (invalidate) { |
| 20636 |
invalidate(); |
| 20637 |
} |
| 20638 |
} |
| 20639 |
|
| 20640 |
} else if (drawVerticalScrollBar || drawHorizontalScrollBar) { |
| 20641 |
final ScrollBarDrawable scrollBar = cache.scrollBar; |
| 20642 |
|
| 20643 |
if (drawHorizontalScrollBar) { |
| 20644 |
scrollBar.setParameters(computeHorizontalScrollRange(), |
| 20645 |
computeHorizontalScrollOffset(), |
| 20646 |
computeHorizontalScrollExtent(), false); |
| 20647 |
final Rect bounds = cache.mScrollBarBounds; |
| 20648 |
getHorizontalScrollBarBounds(bounds, null); |
| 20649 |
onDrawHorizontalScrollBar(canvas, scrollBar, bounds.left, bounds.top, |
| 20650 |
bounds.right, bounds.bottom); |
| 20651 |
if (invalidate) { |
| 20652 |
invalidate(bounds); |
| 20653 |
} |
| 20654 |
} |
| 20655 |
|
| 20656 |
if (drawVerticalScrollBar) { |
| 20657 |
scrollBar.setParameters(computeVerticalScrollRange(), |
| 20658 |
computeVerticalScrollOffset(), |
| 20659 |
computeVerticalScrollExtent(), true); |
| 20660 |
final Rect bounds = cache.mScrollBarBounds; |
| 20661 |
getVerticalScrollBarBounds(bounds, null); |
| 20662 |
onDrawVerticalScrollBar(canvas, scrollBar, bounds.left, bounds.top, |
| 20663 |
bounds.right, bounds.bottom); |
| 20664 |
if (invalidate) { |
| 20665 |
invalidate(bounds); |
| 20666 |
} |
| 20667 |
} |
| 20668 |
} |
| 20669 |
} |
| 20670 |
} |
| 20671 |
|
| 20672 |
|
| 20673 |
|
| 20674 |
|
| 20675 |
|
| 20676 |
|
| 20677 |
|
| 20678 |
protected boolean isVerticalScrollBarHidden() { |
| 20679 |
return false; |
| 20680 |
} |
| 20681 |
|
| 20682 |
|
| 20683 |
|
| 20684 |
|
| 20685 |
|
| 20686 |
|
| 20687 |
|
| 20688 |
|
| 20689 |
|
| 20690 |
|
| 20691 |
|
| 20692 |
|
| 20693 |
|
| 20694 |
|
| 20695 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 20696 |
protected void onDrawHorizontalScrollBar(Canvas canvas, Drawable scrollBar, |
| 20697 |
int l, int t, int r, int b) { |
| 20698 |
scrollBar.setBounds(l, t, r, b); |
| 20699 |
scrollBar.draw(canvas); |
| 20700 |
} |
| 20701 |
|
| 20702 |
|
| 20703 |
|
| 20704 |
|
| 20705 |
|
| 20706 |
|
| 20707 |
|
| 20708 |
|
| 20709 |
|
| 20710 |
|
| 20711 |
|
| 20712 |
|
| 20713 |
|
| 20714 |
|
| 20715 |
@UnsupportedAppUsage |
| 20716 |
protected void onDrawVerticalScrollBar(Canvas canvas, Drawable scrollBar, |
| 20717 |
int l, int t, int r, int b) { |
| 20718 |
scrollBar.setBounds(l, t, r, b); |
| 20719 |
scrollBar.draw(canvas); |
| 20720 |
} |
| 20721 |
|
| 20722 |
|
| 20723 |
|
| 20724 |
|
| 20725 |
|
| 20726 |
|
| 20727 |
protected void onDraw(Canvas canvas) { |
| 20728 |
} |
| 20729 |
|
| 20730 |
|
| 20731 |
|
| 20732 |
|
| 20733 |
|
| 20734 |
@UnsupportedAppUsage |
| 20735 |
void assignParent(ViewParent parent) { |
| 20736 |
if (mParent == null) { |
| 20737 |
mParent = parent; |
| 20738 |
} else if (parent == null) { |
| 20739 |
mParent = null; |
| 20740 |
} else { |
| 20741 |
throw new RuntimeException("view " + this + " being added, but" |
| 20742 |
+ " it already has a parent"); |
| 20743 |
} |
| 20744 |
} |
| 20745 |
|
| 20746 |
|
| 20747 |
|
| 20748 |
|
| 20749 |
|
| 20750 |
|
| 20751 |
|
| 20752 |
|
| 20753 |
|
| 20754 |
|
| 20755 |
@CallSuper |
| 20756 |
protected void onAttachedToWindow() { |
| 20757 |
if (mParent != null && (mPrivateFlags & PFLAG_REQUEST_TRANSPARENT_REGIONS) != 0) { |
| 20758 |
mParent.requestTransparentRegion(this); |
| 20759 |
} |
| 20760 |
|
| 20761 |
mPrivateFlags3 &= ~PFLAG3_IS_LAID_OUT; |
| 20762 |
|
| 20763 |
jumpDrawablesToCurrentState(); |
| 20764 |
|
| 20765 |
AccessibilityNodeIdManager.getInstance().registerViewWithId(this, getAccessibilityViewId()); |
| 20766 |
resetSubtreeAccessibilityStateChanged(); |
| 20767 |
|
| 20768 |
|
| 20769 |
rebuildOutline(); |
| 20770 |
|
| 20771 |
if (isFocused()) { |
| 20772 |
notifyFocusChangeToImeFocusController(true ); |
| 20773 |
} |
| 20774 |
} |
| 20775 |
|
| 20776 |
|
| 20777 |
|
| 20778 |
|
| 20779 |
|
| 20780 |
|
| 20781 |
|
| 20782 |
|
| 20783 |
public boolean resolveRtlPropertiesIfNeeded() { |
| 20784 |
if (!needRtlPropertiesResolution()) return false; |
| 20785 |
|
| 20786 |
|
| 20787 |
if (!isLayoutDirectionResolved()) { |
| 20788 |
resolveLayoutDirection(); |
| 20789 |
resolveLayoutParams(); |
| 20790 |
} |
| 20791 |
|
| 20792 |
if (!isTextDirectionResolved()) { |
| 20793 |
resolveTextDirection(); |
| 20794 |
} |
| 20795 |
if (!isTextAlignmentResolved()) { |
| 20796 |
resolveTextAlignment(); |
| 20797 |
} |
| 20798 |
|
| 20799 |
|
| 20800 |
if (!areDrawablesResolved()) { |
| 20801 |
resolveDrawables(); |
| 20802 |
} |
| 20803 |
if (!isPaddingResolved()) { |
| 20804 |
resolvePadding(); |
| 20805 |
} |
| 20806 |
onRtlPropertiesChanged(getLayoutDirection()); |
| 20807 |
return true; |
| 20808 |
} |
| 20809 |
|
| 20810 |
|
| 20811 |
|
| 20812 |
|
| 20813 |
|
| 20814 |
|
| 20815 |
@TestApi |
| 20816 |
public void resetRtlProperties() { |
| 20817 |
resetResolvedLayoutDirection(); |
| 20818 |
resetResolvedTextDirection(); |
| 20819 |
resetResolvedTextAlignment(); |
| 20820 |
resetResolvedPadding(); |
| 20821 |
resetResolvedDrawables(); |
| 20822 |
} |
| 20823 |
|
| 20824 |
|
| 20825 |
|
| 20826 |
|
| 20827 |
void dispatchScreenStateChanged(int screenState) { |
| 20828 |
onScreenStateChanged(screenState); |
| 20829 |
} |
| 20830 |
|
| 20831 |
|
| 20832 |
|
| 20833 |
|
| 20834 |
|
| 20835 |
|
| 20836 |
|
| 20837 |
|
| 20838 |
|
| 20839 |
|
| 20840 |
public void onScreenStateChanged(int screenState) { |
| 20841 |
} |
| 20842 |
|
| 20843 |
|
| 20844 |
|
| 20845 |
|
| 20846 |
void dispatchMovedToDisplay(Display display, Configuration config) { |
| 20847 |
mAttachInfo.mDisplay = display; |
| 20848 |
mAttachInfo.mDisplayState = display.getState(); |
| 20849 |
onMovedToDisplay(display.getDisplayId(), config); |
| 20850 |
} |
| 20851 |
|
| 20852 |
|
| 20853 |
|
| 20854 |
|
| 20855 |
|
| 20856 |
|
| 20857 |
|
| 20858 |
|
| 20859 |
|
| 20860 |
|
| 20861 |
|
| 20862 |
|
| 20863 |
|
| 20864 |
|
| 20865 |
|
| 20866 |
|
| 20867 |
|
| 20868 |
|
| 20869 |
|
| 20870 |
|
| 20871 |
|
| 20872 |
public void onMovedToDisplay(int displayId, Configuration config) { |
| 20873 |
} |
| 20874 |
|
| 20875 |
|
| 20876 |
|
| 20877 |
|
| 20878 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 20879 |
private boolean hasRtlSupport() { |
| 20880 |
return mContext.getApplicationInfo().hasRtlSupport(); |
| 20881 |
} |
| 20882 |
|
| 20883 |
|
| 20884 |
|
| 20885 |
|
| 20886 |
|
| 20887 |
private boolean isRtlCompatibilityMode() { |
| 20888 |
final int targetSdkVersion = getContext().getApplicationInfo().targetSdkVersion; |
| 20889 |
return targetSdkVersion < Build.VERSION_CODES.JELLY_BEAN_MR1 || !hasRtlSupport(); |
| 20890 |
} |
| 20891 |
|
| 20892 |
|
| 20893 |
|
| 20894 |
|
| 20895 |
|
| 20896 |
private boolean needRtlPropertiesResolution() { |
| 20897 |
return (mPrivateFlags2 & ALL_RTL_PROPERTIES_RESOLVED) != ALL_RTL_PROPERTIES_RESOLVED; |
| 20898 |
} |
| 20899 |
|
| 20900 |
|
| 20901 |
|
| 20902 |
|
| 20903 |
|
| 20904 |
|
| 20905 |
|
| 20906 |
|
| 20907 |
|
| 20908 |
|
| 20909 |
|
| 20910 |
|
| 20911 |
|
| 20912 |
|
| 20913 |
|
| 20914 |
public void onRtlPropertiesChanged(@ResolvedLayoutDir int layoutDirection) { |
| 20915 |
} |
| 20916 |
|
| 20917 |
|
| 20918 |
|
| 20919 |
|
| 20920 |
|
| 20921 |
|
| 20922 |
|
| 20923 |
|
| 20924 |
|
| 20925 |
public boolean resolveLayoutDirection() { |
| 20926 |
|
| 20927 |
mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK; |
| 20928 |
|
| 20929 |
if (hasRtlSupport()) { |
| 20930 |
|
| 20931 |
switch ((mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_MASK) >> |
| 20932 |
PFLAG2_LAYOUT_DIRECTION_MASK_SHIFT) { |
| 20933 |
case LAYOUT_DIRECTION_INHERIT: |
| 20934 |
|
| 20935 |
|
| 20936 |
if (!canResolveLayoutDirection()) return false; |
| 20937 |
|
| 20938 |
|
| 20939 |
try { |
| 20940 |
if (!mParent.isLayoutDirectionResolved()) return false; |
| 20941 |
|
| 20942 |
if (mParent.getLayoutDirection() == LAYOUT_DIRECTION_RTL) { |
| 20943 |
mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL; |
| 20944 |
} |
| 20945 |
} catch (AbstractMethodError e) { |
| 20946 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 20947 |
" does not fully implement ViewParent", e); |
| 20948 |
} |
| 20949 |
break; |
| 20950 |
case LAYOUT_DIRECTION_RTL: |
| 20951 |
mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL; |
| 20952 |
break; |
| 20953 |
case LAYOUT_DIRECTION_LOCALE: |
| 20954 |
if((LAYOUT_DIRECTION_RTL == |
| 20955 |
TextUtils.getLayoutDirectionFromLocale(Locale.getDefault()))) { |
| 20956 |
mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED_RTL; |
| 20957 |
} |
| 20958 |
break; |
| 20959 |
default: |
| 20960 |
|
| 20961 |
} |
| 20962 |
} |
| 20963 |
|
| 20964 |
|
| 20965 |
mPrivateFlags2 |= PFLAG2_LAYOUT_DIRECTION_RESOLVED; |
| 20966 |
return true; |
| 20967 |
} |
| 20968 |
|
| 20969 |
|
| 20970 |
|
| 20971 |
|
| 20972 |
|
| 20973 |
|
| 20974 |
public boolean canResolveLayoutDirection() { |
| 20975 |
switch (getRawLayoutDirection()) { |
| 20976 |
case LAYOUT_DIRECTION_INHERIT: |
| 20977 |
if (mParent != null) { |
| 20978 |
try { |
| 20979 |
return mParent.canResolveLayoutDirection(); |
| 20980 |
} catch (AbstractMethodError e) { |
| 20981 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 20982 |
" does not fully implement ViewParent", e); |
| 20983 |
} |
| 20984 |
} |
| 20985 |
return false; |
| 20986 |
|
| 20987 |
default: |
| 20988 |
return true; |
| 20989 |
} |
| 20990 |
} |
| 20991 |
|
| 20992 |
|
| 20993 |
|
| 20994 |
|
| 20995 |
|
| 20996 |
|
| 20997 |
|
| 20998 |
@TestApi |
| 20999 |
public void resetResolvedLayoutDirection() { |
| 21000 |
|
| 21001 |
mPrivateFlags2 &= ~PFLAG2_LAYOUT_DIRECTION_RESOLVED_MASK; |
| 21002 |
} |
| 21003 |
|
| 21004 |
|
| 21005 |
|
| 21006 |
|
| 21007 |
|
| 21008 |
|
| 21009 |
public boolean isLayoutDirectionInherited() { |
| 21010 |
return (getRawLayoutDirection() == LAYOUT_DIRECTION_INHERIT); |
| 21011 |
} |
| 21012 |
|
| 21013 |
|
| 21014 |
|
| 21015 |
|
| 21016 |
public boolean isLayoutDirectionResolved() { |
| 21017 |
return (mPrivateFlags2 & PFLAG2_LAYOUT_DIRECTION_RESOLVED) == PFLAG2_LAYOUT_DIRECTION_RESOLVED; |
| 21018 |
} |
| 21019 |
|
| 21020 |
|
| 21021 |
|
| 21022 |
|
| 21023 |
|
| 21024 |
|
| 21025 |
@UnsupportedAppUsage |
| 21026 |
boolean isPaddingResolved() { |
| 21027 |
return (mPrivateFlags2 & PFLAG2_PADDING_RESOLVED) == PFLAG2_PADDING_RESOLVED; |
| 21028 |
} |
| 21029 |
|
| 21030 |
|
| 21031 |
|
| 21032 |
|
| 21033 |
|
| 21034 |
|
| 21035 |
|
| 21036 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 21037 |
public void resolvePadding() { |
| 21038 |
final int resolvedLayoutDirection = getLayoutDirection(); |
| 21039 |
|
| 21040 |
if (!isRtlCompatibilityMode()) { |
| 21041 |
|
| 21042 |
|
| 21043 |
|
| 21044 |
|
| 21045 |
if (mBackground != null && (!mLeftPaddingDefined || !mRightPaddingDefined)) { |
| 21046 |
Rect padding = sThreadLocal.get(); |
| 21047 |
if (padding == null) { |
| 21048 |
padding = new Rect(); |
| 21049 |
sThreadLocal.set(padding); |
| 21050 |
} |
| 21051 |
mBackground.getPadding(padding); |
| 21052 |
if (!mLeftPaddingDefined) { |
| 21053 |
mUserPaddingLeftInitial = padding.left; |
| 21054 |
} |
| 21055 |
if (!mRightPaddingDefined) { |
| 21056 |
mUserPaddingRightInitial = padding.right; |
| 21057 |
} |
| 21058 |
} |
| 21059 |
switch (resolvedLayoutDirection) { |
| 21060 |
case LAYOUT_DIRECTION_RTL: |
| 21061 |
if (mUserPaddingStart != UNDEFINED_PADDING) { |
| 21062 |
mUserPaddingRight = mUserPaddingStart; |
| 21063 |
} else { |
| 21064 |
mUserPaddingRight = mUserPaddingRightInitial; |
| 21065 |
} |
| 21066 |
if (mUserPaddingEnd != UNDEFINED_PADDING) { |
| 21067 |
mUserPaddingLeft = mUserPaddingEnd; |
| 21068 |
} else { |
| 21069 |
mUserPaddingLeft = mUserPaddingLeftInitial; |
| 21070 |
} |
| 21071 |
break; |
| 21072 |
case LAYOUT_DIRECTION_LTR: |
| 21073 |
default: |
| 21074 |
if (mUserPaddingStart != UNDEFINED_PADDING) { |
| 21075 |
mUserPaddingLeft = mUserPaddingStart; |
| 21076 |
} else { |
| 21077 |
mUserPaddingLeft = mUserPaddingLeftInitial; |
| 21078 |
} |
| 21079 |
if (mUserPaddingEnd != UNDEFINED_PADDING) { |
| 21080 |
mUserPaddingRight = mUserPaddingEnd; |
| 21081 |
} else { |
| 21082 |
mUserPaddingRight = mUserPaddingRightInitial; |
| 21083 |
} |
| 21084 |
} |
| 21085 |
|
| 21086 |
mUserPaddingBottom = (mUserPaddingBottom >= 0) ? mUserPaddingBottom : mPaddingBottom; |
| 21087 |
} |
| 21088 |
|
| 21089 |
internalSetPadding(mUserPaddingLeft, mPaddingTop, mUserPaddingRight, mUserPaddingBottom); |
| 21090 |
onRtlPropertiesChanged(resolvedLayoutDirection); |
| 21091 |
|
| 21092 |
mPrivateFlags2 |= PFLAG2_PADDING_RESOLVED; |
| 21093 |
} |
| 21094 |
|
| 21095 |
|
| 21096 |
|
| 21097 |
|
| 21098 |
|
| 21099 |
|
| 21100 |
@TestApi |
| 21101 |
public void resetResolvedPadding() { |
| 21102 |
resetResolvedPaddingInternal(); |
| 21103 |
} |
| 21104 |
|
| 21105 |
|
| 21106 |
|
| 21107 |
|
| 21108 |
|
| 21109 |
void resetResolvedPaddingInternal() { |
| 21110 |
mPrivateFlags2 &= ~PFLAG2_PADDING_RESOLVED; |
| 21111 |
} |
| 21112 |
|
| 21113 |
|
| 21114 |
|
| 21115 |
|
| 21116 |
|
| 21117 |
|
| 21118 |
|
| 21119 |
@CallSuper |
| 21120 |
protected void onDetachedFromWindow() { |
| 21121 |
} |
| 21122 |
|
| 21123 |
|
| 21124 |
|
| 21125 |
|
| 21126 |
|
| 21127 |
|
| 21128 |
|
| 21129 |
|
| 21130 |
|
| 21131 |
|
| 21132 |
|
| 21133 |
@CallSuper |
| 21134 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 21135 |
protected void onDetachedFromWindowInternal() { |
| 21136 |
mPrivateFlags &= ~PFLAG_CANCEL_NEXT_UP_EVENT; |
| 21137 |
mPrivateFlags3 &= ~PFLAG3_IS_LAID_OUT; |
| 21138 |
mPrivateFlags3 &= ~PFLAG3_TEMPORARY_DETACH; |
| 21139 |
|
| 21140 |
removeUnsetPressCallback(); |
| 21141 |
removeLongPressCallback(); |
| 21142 |
removePerformClickCallback(); |
| 21143 |
clearAccessibilityThrottles(); |
| 21144 |
stopNestedScroll(); |
| 21145 |
|
| 21146 |
|
| 21147 |
|
| 21148 |
jumpDrawablesToCurrentState(); |
| 21149 |
|
| 21150 |
destroyDrawingCache(); |
| 21151 |
|
| 21152 |
cleanupDraw(); |
| 21153 |
mCurrentAnimation = null; |
| 21154 |
|
| 21155 |
if ((mViewFlags & TOOLTIP) == TOOLTIP) { |
| 21156 |
hideTooltip(); |
| 21157 |
} |
| 21158 |
|
| 21159 |
AccessibilityNodeIdManager.getInstance().unregisterViewWithId(getAccessibilityViewId()); |
| 21160 |
|
| 21161 |
if (mBackgroundRenderNode != null) { |
| 21162 |
mBackgroundRenderNode.forceEndAnimators(); |
| 21163 |
} |
| 21164 |
mRenderNode.forceEndAnimators(); |
| 21165 |
} |
| 21166 |
|
| 21167 |
private void cleanupDraw() { |
| 21168 |
resetDisplayList(); |
| 21169 |
if (mAttachInfo != null) { |
| 21170 |
mAttachInfo.mViewRootImpl.cancelInvalidate(this); |
| 21171 |
} |
| 21172 |
} |
| 21173 |
|
| 21174 |
void invalidateInheritedLayoutMode(int layoutModeOfRoot) { |
| 21175 |
} |
| 21176 |
|
| 21177 |
|
| 21178 |
|
| 21179 |
|
| 21180 |
protected int getWindowAttachCount() { |
| 21181 |
return mWindowAttachCount; |
| 21182 |
} |
| 21183 |
|
| 21184 |
|
| 21185 |
|
| 21186 |
|
| 21187 |
|
| 21188 |
|
| 21189 |
public IBinder getWindowToken() { |
| 21190 |
return mAttachInfo != null ? mAttachInfo.mWindowToken : null; |
| 21191 |
} |
| 21192 |
|
| 21193 |
|
| 21194 |
|
| 21195 |
|
| 21196 |
|
| 21197 |
public WindowId getWindowId() { |
| 21198 |
AttachInfo ai = mAttachInfo; |
| 21199 |
if (ai == null) { |
| 21200 |
return null; |
| 21201 |
} |
| 21202 |
if (ai.mWindowId == null) { |
| 21203 |
try { |
| 21204 |
ai.mIWindowId = ai.mSession.getWindowId(ai.mWindowToken); |
| 21205 |
if (ai.mIWindowId != null) { |
| 21206 |
ai.mWindowId = new WindowId(ai.mIWindowId); |
| 21207 |
} |
| 21208 |
} catch (RemoteException e) { |
| 21209 |
} |
| 21210 |
} |
| 21211 |
return ai.mWindowId; |
| 21212 |
} |
| 21213 |
|
| 21214 |
|
| 21215 |
|
| 21216 |
|
| 21217 |
|
| 21218 |
|
| 21219 |
|
| 21220 |
|
| 21221 |
|
| 21222 |
|
| 21223 |
|
| 21224 |
public IBinder getApplicationWindowToken() { |
| 21225 |
AttachInfo ai = mAttachInfo; |
| 21226 |
if (ai != null) { |
| 21227 |
IBinder appWindowToken = ai.mPanelParentWindowToken; |
| 21228 |
if (appWindowToken == null) { |
| 21229 |
appWindowToken = ai.mWindowToken; |
| 21230 |
} |
| 21231 |
return appWindowToken; |
| 21232 |
} |
| 21233 |
return null; |
| 21234 |
} |
| 21235 |
|
| 21236 |
|
| 21237 |
|
| 21238 |
|
| 21239 |
|
| 21240 |
|
| 21241 |
public Display getDisplay() { |
| 21242 |
return mAttachInfo != null ? mAttachInfo.mDisplay : null; |
| 21243 |
} |
| 21244 |
|
| 21245 |
|
| 21246 |
|
| 21247 |
|
| 21248 |
|
| 21249 |
|
| 21250 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023) |
| 21251 |
IWindowSession getWindowSession() { |
| 21252 |
return mAttachInfo != null ? mAttachInfo.mSession : null; |
| 21253 |
} |
| 21254 |
|
| 21255 |
|
| 21256 |
|
| 21257 |
|
| 21258 |
|
| 21259 |
protected IWindow getWindow() { |
| 21260 |
return mAttachInfo != null ? mAttachInfo.mWindow : null; |
| 21261 |
} |
| 21262 |
|
| 21263 |
|
| 21264 |
|
| 21265 |
|
| 21266 |
int combineVisibility(int vis1, int vis2) { |
| 21267 |
|
| 21268 |
return Math.max(vis1, vis2); |
| 21269 |
} |
| 21270 |
|
| 21271 |
private boolean mShouldFakeFocus = false; |
| 21272 |
|
| 21273 |
|
| 21274 |
|
| 21275 |
|
| 21276 |
|
| 21277 |
|
| 21278 |
public void fakeFocusAfterAttachingToWindow() { |
| 21279 |
mShouldFakeFocus = true; |
| 21280 |
} |
| 21281 |
|
| 21282 |
|
| 21283 |
|
| 21284 |
|
| 21285 |
|
| 21286 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 21287 |
void dispatchAttachedToWindow(AttachInfo info, int visibility) { |
| 21288 |
mAttachInfo = info; |
| 21289 |
if (mOverlay != null) { |
| 21290 |
mOverlay.getOverlayView().dispatchAttachedToWindow(info, visibility); |
| 21291 |
} |
| 21292 |
mWindowAttachCount++; |
| 21293 |
|
| 21294 |
mPrivateFlags |= PFLAG_DRAWABLE_STATE_DIRTY; |
| 21295 |
if (mFloatingTreeObserver != null) { |
| 21296 |
info.mTreeObserver.merge(mFloatingTreeObserver); |
| 21297 |
mFloatingTreeObserver = null; |
| 21298 |
} |
| 21299 |
|
| 21300 |
registerPendingFrameMetricsObservers(); |
| 21301 |
|
| 21302 |
if ((mPrivateFlags&PFLAG_SCROLL_CONTAINER) != 0) { |
| 21303 |
mAttachInfo.mScrollContainers.add(this); |
| 21304 |
mPrivateFlags |= PFLAG_SCROLL_CONTAINER_ADDED; |
| 21305 |
} |
| 21306 |
|
| 21307 |
if (mRunQueue != null) { |
| 21308 |
mRunQueue.executeActions(info.mHandler); |
| 21309 |
mRunQueue = null; |
| 21310 |
} |
| 21311 |
performCollectViewAttributes(mAttachInfo, visibility); |
| 21312 |
onAttachedToWindow(); |
| 21313 |
|
| 21314 |
ListenerInfo li = mListenerInfo; |
| 21315 |
final CopyOnWriteArrayList<OnAttachStateChangeListener> listeners = |
| 21316 |
li != null ? li.mOnAttachStateChangeListeners : null; |
| 21317 |
if (listeners != null && listeners.size() > 0) { |
| 21318 |
|
| 21319 |
|
| 21320 |
|
| 21321 |
|
| 21322 |
for (OnAttachStateChangeListener listener : listeners) { |
| 21323 |
listener.onViewAttachedToWindow(this); |
| 21324 |
} |
| 21325 |
} |
| 21326 |
|
| 21327 |
int vis = info.mWindowVisibility; |
| 21328 |
if (vis != GONE) { |
| 21329 |
onWindowVisibilityChanged(vis); |
| 21330 |
if (isShown()) { |
| 21331 |
|
| 21332 |
|
| 21333 |
onVisibilityAggregated(vis == VISIBLE); |
| 21334 |
} |
| 21335 |
} |
| 21336 |
|
| 21337 |
|
| 21338 |
|
| 21339 |
|
| 21340 |
onVisibilityChanged(this, visibility); |
| 21341 |
|
| 21342 |
if ((mPrivateFlags&PFLAG_DRAWABLE_STATE_DIRTY) != 0) { |
| 21343 |
|
| 21344 |
refreshDrawableState(); |
| 21345 |
} |
| 21346 |
needGlobalAttributesUpdate(false); |
| 21347 |
|
| 21348 |
notifyEnterOrExitForAutoFillIfNeeded(true); |
| 21349 |
notifyAppearedOrDisappearedForContentCaptureIfNeeded(true); |
| 21350 |
|
| 21351 |
if (mShouldFakeFocus) { |
| 21352 |
getViewRootImpl().dispatchCompatFakeFocus(); |
| 21353 |
mShouldFakeFocus = false; |
| 21354 |
} |
| 21355 |
} |
| 21356 |
|
| 21357 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 21358 |
void dispatchDetachedFromWindow() { |
| 21359 |
AttachInfo info = mAttachInfo; |
| 21360 |
if (info != null) { |
| 21361 |
int vis = info.mWindowVisibility; |
| 21362 |
if (vis != GONE) { |
| 21363 |
onWindowVisibilityChanged(GONE); |
| 21364 |
if (isShown()) { |
| 21365 |
|
| 21366 |
|
| 21367 |
onVisibilityAggregated(false); |
| 21368 |
} |
| 21369 |
} |
| 21370 |
} |
| 21371 |
|
| 21372 |
onDetachedFromWindow(); |
| 21373 |
onDetachedFromWindowInternal(); |
| 21374 |
|
| 21375 |
if (info != null) { |
| 21376 |
info.mViewRootImpl.getImeFocusController().onViewDetachedFromWindow(this); |
| 21377 |
} |
| 21378 |
|
| 21379 |
ListenerInfo li = mListenerInfo; |
| 21380 |
final CopyOnWriteArrayList<OnAttachStateChangeListener> listeners = |
| 21381 |
li != null ? li.mOnAttachStateChangeListeners : null; |
| 21382 |
if (listeners != null && listeners.size() > 0) { |
| 21383 |
|
| 21384 |
|
| 21385 |
|
| 21386 |
|
| 21387 |
for (OnAttachStateChangeListener listener : listeners) { |
| 21388 |
listener.onViewDetachedFromWindow(this); |
| 21389 |
} |
| 21390 |
} |
| 21391 |
|
| 21392 |
if ((mPrivateFlags & PFLAG_SCROLL_CONTAINER_ADDED) != 0) { |
| 21393 |
mAttachInfo.mScrollContainers.remove(this); |
| 21394 |
mPrivateFlags &= ~PFLAG_SCROLL_CONTAINER_ADDED; |
| 21395 |
} |
| 21396 |
|
| 21397 |
notifyAppearedOrDisappearedForContentCaptureIfNeeded(false); |
| 21398 |
|
| 21399 |
mAttachInfo = null; |
| 21400 |
if (mOverlay != null) { |
| 21401 |
mOverlay.getOverlayView().dispatchDetachedFromWindow(); |
| 21402 |
} |
| 21403 |
|
| 21404 |
notifyEnterOrExitForAutoFillIfNeeded(false); |
| 21405 |
|
| 21406 |
if (info != null && !collectPreferKeepClearRects().isEmpty()) { |
| 21407 |
info.mViewRootImpl.updateKeepClearRectsForView(this); |
| 21408 |
} |
| 21409 |
} |
| 21410 |
|
| 21411 |
|
| 21412 |
|
| 21413 |
|
| 21414 |
|
| 21415 |
|
| 21416 |
|
| 21417 |
|
| 21418 |
|
| 21419 |
|
| 21420 |
|
| 21421 |
|
| 21422 |
|
| 21423 |
|
| 21424 |
|
| 21425 |
|
| 21426 |
|
| 21427 |
|
| 21428 |
|
| 21429 |
|
| 21430 |
|
| 21431 |
|
| 21432 |
public final void cancelPendingInputEvents() { |
| 21433 |
dispatchCancelPendingInputEvents(); |
| 21434 |
} |
| 21435 |
|
| 21436 |
|
| 21437 |
|
| 21438 |
|
| 21439 |
|
| 21440 |
void dispatchCancelPendingInputEvents() { |
| 21441 |
mPrivateFlags3 &= ~PFLAG3_CALLED_SUPER; |
| 21442 |
onCancelPendingInputEvents(); |
| 21443 |
if ((mPrivateFlags3 & PFLAG3_CALLED_SUPER) != PFLAG3_CALLED_SUPER) { |
| 21444 |
throw new SuperNotCalledException("View " + getClass().getSimpleName() + |
| 21445 |
" did not call through to super.onCancelPendingInputEvents()"); |
| 21446 |
} |
| 21447 |
} |
| 21448 |
|
| 21449 |
|
| 21450 |
|
| 21451 |
|
| 21452 |
|
| 21453 |
|
| 21454 |
|
| 21455 |
|
| 21456 |
|
| 21457 |
|
| 21458 |
|
| 21459 |
|
| 21460 |
public void onCancelPendingInputEvents() { |
| 21461 |
removePerformClickCallback(); |
| 21462 |
cancelLongPress(); |
| 21463 |
mPrivateFlags3 |= PFLAG3_CALLED_SUPER; |
| 21464 |
} |
| 21465 |
|
| 21466 |
|
| 21467 |
|
| 21468 |
|
| 21469 |
|
| 21470 |
|
| 21471 |
|
| 21472 |
|
| 21473 |
|
| 21474 |
|
| 21475 |
public void saveHierarchyState(SparseArray<Parcelable> container) { |
| 21476 |
dispatchSaveInstanceState(container); |
| 21477 |
} |
| 21478 |
|
| 21479 |
|
| 21480 |
|
| 21481 |
|
| 21482 |
|
| 21483 |
|
| 21484 |
|
| 21485 |
|
| 21486 |
|
| 21487 |
|
| 21488 |
|
| 21489 |
|
| 21490 |
protected void dispatchSaveInstanceState(SparseArray<Parcelable> container) { |
| 21491 |
if (mID != NO_ID && (mViewFlags & SAVE_DISABLED_MASK) == 0) { |
| 21492 |
mPrivateFlags &= ~PFLAG_SAVE_STATE_CALLED; |
| 21493 |
Parcelable state = onSaveInstanceState(); |
| 21494 |
if ((mPrivateFlags & PFLAG_SAVE_STATE_CALLED) == 0) { |
| 21495 |
throw new IllegalStateException( |
| 21496 |
"Derived class did not call super.onSaveInstanceState()"); |
| 21497 |
} |
| 21498 |
if (state != null) { |
| 21499 |
|
| 21500 |
|
| 21501 |
container.put(mID, state); |
| 21502 |
} |
| 21503 |
} |
| 21504 |
} |
| 21505 |
|
| 21506 |
|
| 21507 |
|
| 21508 |
|
| 21509 |
|
| 21510 |
|
| 21511 |
|
| 21512 |
|
| 21513 |
|
| 21514 |
|
| 21515 |
|
| 21516 |
|
| 21517 |
|
| 21518 |
|
| 21519 |
|
| 21520 |
|
| 21521 |
|
| 21522 |
|
| 21523 |
|
| 21524 |
|
| 21525 |
|
| 21526 |
@CallSuper |
| 21527 |
@Nullable protected Parcelable onSaveInstanceState() { |
| 21528 |
mPrivateFlags |= PFLAG_SAVE_STATE_CALLED; |
| 21529 |
if (mStartActivityRequestWho != null || isAutofilled() |
| 21530 |
|| mAutofillViewId > LAST_APP_AUTOFILL_ID) { |
| 21531 |
BaseSavedState state = new BaseSavedState(AbsSavedState.EMPTY_STATE); |
| 21532 |
|
| 21533 |
if (mStartActivityRequestWho != null) { |
| 21534 |
state.mSavedData |= BaseSavedState.START_ACTIVITY_REQUESTED_WHO_SAVED; |
| 21535 |
} |
| 21536 |
|
| 21537 |
if (isAutofilled()) { |
| 21538 |
state.mSavedData |= BaseSavedState.IS_AUTOFILLED; |
| 21539 |
} |
| 21540 |
|
| 21541 |
if (mAutofillViewId > LAST_APP_AUTOFILL_ID) { |
| 21542 |
state.mSavedData |= BaseSavedState.AUTOFILL_ID; |
| 21543 |
} |
| 21544 |
|
| 21545 |
state.mStartActivityRequestWhoSaved = mStartActivityRequestWho; |
| 21546 |
state.mIsAutofilled = isAutofilled(); |
| 21547 |
state.mHideHighlight = hideAutofillHighlight(); |
| 21548 |
state.mAutofillViewId = mAutofillViewId; |
| 21549 |
return state; |
| 21550 |
} |
| 21551 |
return BaseSavedState.EMPTY_STATE; |
| 21552 |
} |
| 21553 |
|
| 21554 |
|
| 21555 |
|
| 21556 |
|
| 21557 |
|
| 21558 |
|
| 21559 |
|
| 21560 |
|
| 21561 |
|
| 21562 |
|
| 21563 |
public void restoreHierarchyState(SparseArray<Parcelable> container) { |
| 21564 |
dispatchRestoreInstanceState(container); |
| 21565 |
} |
| 21566 |
|
| 21567 |
|
| 21568 |
|
| 21569 |
|
| 21570 |
|
| 21571 |
|
| 21572 |
|
| 21573 |
|
| 21574 |
|
| 21575 |
|
| 21576 |
|
| 21577 |
|
| 21578 |
|
| 21579 |
protected void dispatchRestoreInstanceState(SparseArray<Parcelable> container) { |
| 21580 |
if (mID != NO_ID) { |
| 21581 |
Parcelable state = container.get(mID); |
| 21582 |
if (state != null) { |
| 21583 |
|
| 21584 |
|
| 21585 |
mPrivateFlags &= ~PFLAG_SAVE_STATE_CALLED; |
| 21586 |
onRestoreInstanceState(state); |
| 21587 |
if ((mPrivateFlags & PFLAG_SAVE_STATE_CALLED) == 0) { |
| 21588 |
throw new IllegalStateException( |
| 21589 |
"Derived class did not call super.onRestoreInstanceState()"); |
| 21590 |
} |
| 21591 |
} |
| 21592 |
} |
| 21593 |
} |
| 21594 |
|
| 21595 |
|
| 21596 |
|
| 21597 |
|
| 21598 |
|
| 21599 |
|
| 21600 |
|
| 21601 |
|
| 21602 |
|
| 21603 |
|
| 21604 |
|
| 21605 |
|
| 21606 |
|
| 21607 |
@CallSuper |
| 21608 |
protected void onRestoreInstanceState(Parcelable state) { |
| 21609 |
mPrivateFlags |= PFLAG_SAVE_STATE_CALLED; |
| 21610 |
if (state != null && !(state instanceof AbsSavedState)) { |
| 21611 |
throw new IllegalArgumentException("Wrong state class, expecting View State but " |
| 21612 |
+ "received " + state.getClass().toString() + " instead. This usually happens " |
| 21613 |
+ "when two views of different type have the same id in the same hierarchy. " |
| 21614 |
+ "This view's id is " + ViewDebug.resolveId(mContext, getId()) + ". Make sure " |
| 21615 |
+ "other views do not use the same id."); |
| 21616 |
} |
| 21617 |
if (state != null && state instanceof BaseSavedState) { |
| 21618 |
BaseSavedState baseState = (BaseSavedState) state; |
| 21619 |
|
| 21620 |
if ((baseState.mSavedData & BaseSavedState.START_ACTIVITY_REQUESTED_WHO_SAVED) != 0) { |
| 21621 |
mStartActivityRequestWho = baseState.mStartActivityRequestWhoSaved; |
| 21622 |
} |
| 21623 |
if ((baseState.mSavedData & BaseSavedState.IS_AUTOFILLED) != 0) { |
| 21624 |
setAutofilled(baseState.mIsAutofilled, baseState.mHideHighlight); |
| 21625 |
} |
| 21626 |
if ((baseState.mSavedData & BaseSavedState.AUTOFILL_ID) != 0) { |
| 21627 |
|
| 21628 |
|
| 21629 |
|
| 21630 |
((BaseSavedState) state).mSavedData &= ~BaseSavedState.AUTOFILL_ID; |
| 21631 |
|
| 21632 |
if ((mPrivateFlags3 & PFLAG3_AUTOFILLID_EXPLICITLY_SET) != 0) { |
| 21633 |
|
| 21634 |
if (Log.isLoggable(AUTOFILL_LOG_TAG, Log.DEBUG)) { |
| 21635 |
Log.d(AUTOFILL_LOG_TAG, "onRestoreInstanceState(): not setting autofillId " |
| 21636 |
+ "to " + baseState.mAutofillViewId + " because view explicitly set" |
| 21637 |
+ " it to " + mAutofillId); |
| 21638 |
} |
| 21639 |
} else { |
| 21640 |
mAutofillViewId = baseState.mAutofillViewId; |
| 21641 |
mAutofillId = null; |
| 21642 |
} |
| 21643 |
} |
| 21644 |
} |
| 21645 |
} |
| 21646 |
|
| 21647 |
|
| 21648 |
|
| 21649 |
|
| 21650 |
|
| 21651 |
|
| 21652 |
public long getDrawingTime() { |
| 21653 |
return mAttachInfo != null ? mAttachInfo.mDrawingTime : 0; |
| 21654 |
} |
| 21655 |
|
| 21656 |
|
| 21657 |
|
| 21658 |
|
| 21659 |
|
| 21660 |
|
| 21661 |
|
| 21662 |
|
| 21663 |
|
| 21664 |
|
| 21665 |
|
| 21666 |
|
| 21667 |
|
| 21668 |
|
| 21669 |
|
| 21670 |
|
| 21671 |
|
| 21672 |
|
| 21673 |
|
| 21674 |
|
| 21675 |
|
| 21676 |
|
| 21677 |
public void setDuplicateParentStateEnabled(boolean enabled) { |
| 21678 |
setFlags(enabled ? DUPLICATE_PARENT_STATE : 0, DUPLICATE_PARENT_STATE); |
| 21679 |
} |
| 21680 |
|
| 21681 |
|
| 21682 |
|
| 21683 |
|
| 21684 |
|
| 21685 |
|
| 21686 |
|
| 21687 |
|
| 21688 |
|
| 21689 |
|
| 21690 |
@InspectableProperty(name = "duplicateParentState") |
| 21691 |
public boolean isDuplicateParentStateEnabled() { |
| 21692 |
return (mViewFlags & DUPLICATE_PARENT_STATE) == DUPLICATE_PARENT_STATE; |
| 21693 |
} |
| 21694 |
|
| 21695 |
|
| 21696 |
|
| 21697 |
|
| 21698 |
|
| 21699 |
|
| 21700 |
|
| 21701 |
|
| 21702 |
|
| 21703 |
|
| 21704 |
|
| 21705 |
|
| 21706 |
|
| 21707 |
|
| 21708 |
|
| 21709 |
|
| 21710 |
|
| 21711 |
|
| 21712 |
|
| 21713 |
|
| 21714 |
|
| 21715 |
|
| 21716 |
|
| 21717 |
|
| 21718 |
|
| 21719 |
|
| 21720 |
|
| 21721 |
|
| 21722 |
|
| 21723 |
|
| 21724 |
|
| 21725 |
|
| 21726 |
|
| 21727 |
|
| 21728 |
|
| 21729 |
|
| 21730 |
|
| 21731 |
|
| 21732 |
public void setLayerType(@LayerType int layerType, @Nullable Paint paint) { |
| 21733 |
if (layerType < LAYER_TYPE_NONE || layerType > LAYER_TYPE_HARDWARE) { |
| 21734 |
throw new IllegalArgumentException("Layer type can only be one of: LAYER_TYPE_NONE, " |
| 21735 |
+ "LAYER_TYPE_SOFTWARE or LAYER_TYPE_HARDWARE"); |
| 21736 |
} |
| 21737 |
|
| 21738 |
boolean typeChanged = mRenderNode.setLayerType(layerType); |
| 21739 |
|
| 21740 |
if (!typeChanged) { |
| 21741 |
setLayerPaint(paint); |
| 21742 |
return; |
| 21743 |
} |
| 21744 |
|
| 21745 |
if (layerType != LAYER_TYPE_SOFTWARE) { |
| 21746 |
|
| 21747 |
|
| 21748 |
|
| 21749 |
destroyDrawingCache(); |
| 21750 |
} |
| 21751 |
|
| 21752 |
mLayerType = layerType; |
| 21753 |
mLayerPaint = mLayerType == LAYER_TYPE_NONE ? null : paint; |
| 21754 |
mRenderNode.setLayerPaint(mLayerPaint); |
| 21755 |
|
| 21756 |
|
| 21757 |
|
| 21758 |
invalidateParentCaches(); |
| 21759 |
invalidate(true); |
| 21760 |
} |
| 21761 |
|
| 21762 |
|
| 21763 |
|
| 21764 |
|
| 21765 |
|
| 21766 |
|
| 21767 |
|
| 21768 |
|
| 21769 |
|
| 21770 |
|
| 21771 |
public void setRenderEffect(@Nullable RenderEffect renderEffect) { |
| 21772 |
if (mRenderNode.setRenderEffect(renderEffect)) { |
| 21773 |
invalidateViewProperty(true, true); |
| 21774 |
} |
| 21775 |
} |
| 21776 |
|
| 21777 |
|
| 21778 |
|
| 21779 |
|
| 21780 |
|
| 21781 |
|
| 21782 |
|
| 21783 |
|
| 21784 |
|
| 21785 |
|
| 21786 |
|
| 21787 |
|
| 21788 |
|
| 21789 |
|
| 21790 |
|
| 21791 |
|
| 21792 |
|
| 21793 |
|
| 21794 |
|
| 21795 |
|
| 21796 |
|
| 21797 |
|
| 21798 |
|
| 21799 |
|
| 21800 |
|
| 21801 |
|
| 21802 |
public void setLayerPaint(@Nullable Paint paint) { |
| 21803 |
int layerType = getLayerType(); |
| 21804 |
if (layerType != LAYER_TYPE_NONE) { |
| 21805 |
mLayerPaint = paint; |
| 21806 |
if (layerType == LAYER_TYPE_HARDWARE) { |
| 21807 |
if (mRenderNode.setLayerPaint(paint)) { |
| 21808 |
invalidateViewProperty(false, false); |
| 21809 |
} |
| 21810 |
} else { |
| 21811 |
invalidate(); |
| 21812 |
} |
| 21813 |
} |
| 21814 |
} |
| 21815 |
|
| 21816 |
|
| 21817 |
|
| 21818 |
|
| 21819 |
|
| 21820 |
|
| 21821 |
|
| 21822 |
|
| 21823 |
|
| 21824 |
|
| 21825 |
|
| 21826 |
|
| 21827 |
|
| 21828 |
|
| 21829 |
|
| 21830 |
|
| 21831 |
@InspectableProperty(enumMapping = { |
| 21832 |
@EnumEntry(value = LAYER_TYPE_NONE, name = "none"), |
| 21833 |
@EnumEntry(value = LAYER_TYPE_SOFTWARE, name = "software"), |
| 21834 |
@EnumEntry(value = LAYER_TYPE_HARDWARE, name = "hardware") |
| 21835 |
}) |
| 21836 |
@LayerType |
| 21837 |
public int getLayerType() { |
| 21838 |
return mLayerType; |
| 21839 |
} |
| 21840 |
|
| 21841 |
|
| 21842 |
|
| 21843 |
|
| 21844 |
|
| 21845 |
|
| 21846 |
|
| 21847 |
|
| 21848 |
|
| 21849 |
|
| 21850 |
|
| 21851 |
|
| 21852 |
|
| 21853 |
|
| 21854 |
public void buildLayer() { |
| 21855 |
if (mLayerType == LAYER_TYPE_NONE) return; |
| 21856 |
|
| 21857 |
final AttachInfo attachInfo = mAttachInfo; |
| 21858 |
if (attachInfo == null) { |
| 21859 |
throw new IllegalStateException("This view must be attached to a window first"); |
| 21860 |
} |
| 21861 |
|
| 21862 |
if (getWidth() == 0 || getHeight() == 0) { |
| 21863 |
return; |
| 21864 |
} |
| 21865 |
|
| 21866 |
switch (mLayerType) { |
| 21867 |
case LAYER_TYPE_HARDWARE: |
| 21868 |
updateDisplayListIfDirty(); |
| 21869 |
if (attachInfo.mThreadedRenderer != null && mRenderNode.hasDisplayList()) { |
| 21870 |
attachInfo.mThreadedRenderer.buildLayer(mRenderNode); |
| 21871 |
} |
| 21872 |
break; |
| 21873 |
case LAYER_TYPE_SOFTWARE: |
| 21874 |
buildDrawingCache(true); |
| 21875 |
break; |
| 21876 |
} |
| 21877 |
} |
| 21878 |
|
| 21879 |
|
| 21880 |
|
| 21881 |
|
| 21882 |
|
| 21883 |
|
| 21884 |
|
| 21885 |
|
| 21886 |
|
| 21887 |
|
| 21888 |
|
| 21889 |
|
| 21890 |
@CallSuper |
| 21891 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 21892 |
protected void destroyHardwareResources() { |
| 21893 |
if (mOverlay != null) { |
| 21894 |
mOverlay.getOverlayView().destroyHardwareResources(); |
| 21895 |
} |
| 21896 |
if (mGhostView != null) { |
| 21897 |
mGhostView.destroyHardwareResources(); |
| 21898 |
} |
| 21899 |
} |
| 21900 |
|
| 21901 |
|
| 21902 |
|
| 21903 |
|
| 21904 |
|
| 21905 |
|
| 21906 |
|
| 21907 |
|
| 21908 |
|
| 21909 |
|
| 21910 |
|
| 21911 |
|
| 21912 |
|
| 21913 |
|
| 21914 |
|
| 21915 |
|
| 21916 |
|
| 21917 |
|
| 21918 |
|
| 21919 |
|
| 21920 |
|
| 21921 |
|
| 21922 |
|
| 21923 |
|
| 21924 |
|
| 21925 |
|
| 21926 |
|
| 21927 |
|
| 21928 |
|
| 21929 |
|
| 21930 |
|
| 21931 |
|
| 21932 |
|
| 21933 |
|
| 21934 |
|
| 21935 |
|
| 21936 |
|
| 21937 |
|
| 21938 |
|
| 21939 |
|
| 21940 |
|
| 21941 |
@Deprecated |
| 21942 |
public void setDrawingCacheEnabled(boolean enabled) { |
| 21943 |
mCachingFailed = false; |
| 21944 |
setFlags(enabled ? DRAWING_CACHE_ENABLED : 0, DRAWING_CACHE_ENABLED); |
| 21945 |
} |
| 21946 |
|
| 21947 |
|
| 21948 |
|
| 21949 |
|
| 21950 |
|
| 21951 |
|
| 21952 |
|
| 21953 |
|
| 21954 |
|
| 21955 |
|
| 21956 |
|
| 21957 |
|
| 21958 |
|
| 21959 |
|
| 21960 |
|
| 21961 |
|
| 21962 |
|
| 21963 |
|
| 21964 |
|
| 21965 |
|
| 21966 |
|
| 21967 |
|
| 21968 |
@Deprecated |
| 21969 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 21970 |
public boolean isDrawingCacheEnabled() { |
| 21971 |
return (mViewFlags & DRAWING_CACHE_ENABLED) == DRAWING_CACHE_ENABLED; |
| 21972 |
} |
| 21973 |
|
| 21974 |
|
| 21975 |
|
| 21976 |
|
| 21977 |
|
| 21978 |
|
| 21979 |
|
| 21980 |
@SuppressWarnings({"UnusedDeclaration"}) |
| 21981 |
public void outputDirtyFlags(String indent, boolean clear, int clearMask) { |
| 21982 |
Log.d(VIEW_LOG_TAG, indent + this + " DIRTY(" |
| 21983 |
+ (mPrivateFlags & View.PFLAG_DIRTY_MASK) |
| 21984 |
+ ") DRAWN(" + (mPrivateFlags & PFLAG_DRAWN) + ")" + " CACHE_VALID(" |
| 21985 |
+ (mPrivateFlags & View.PFLAG_DRAWING_CACHE_VALID) |
| 21986 |
+ ") INVALIDATED(" + (mPrivateFlags & PFLAG_INVALIDATED) + ")"); |
| 21987 |
if (clear) { |
| 21988 |
mPrivateFlags &= clearMask; |
| 21989 |
} |
| 21990 |
if (this instanceof ViewGroup) { |
| 21991 |
ViewGroup parent = (ViewGroup) this; |
| 21992 |
final int count = parent.getChildCount(); |
| 21993 |
for (int i = 0; i < count; i++) { |
| 21994 |
final View child = parent.getChildAt(i); |
| 21995 |
child.outputDirtyFlags(indent + " ", clear, clearMask); |
| 21996 |
} |
| 21997 |
} |
| 21998 |
} |
| 21999 |
|
| 22000 |
|
| 22001 |
|
| 22002 |
|
| 22003 |
|
| 22004 |
|
| 22005 |
|
| 22006 |
|
| 22007 |
|
| 22008 |
protected void dispatchGetDisplayList() {} |
| 22009 |
|
| 22010 |
|
| 22011 |
|
| 22012 |
|
| 22013 |
|
| 22014 |
|
| 22015 |
|
| 22016 |
|
| 22017 |
|
| 22018 |
public boolean canHaveDisplayList() { |
| 22019 |
return !(mAttachInfo == null || mAttachInfo.mThreadedRenderer == null); |
| 22020 |
} |
| 22021 |
|
| 22022 |
|
| 22023 |
|
| 22024 |
|
| 22025 |
|
| 22026 |
@NonNull |
| 22027 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 22028 |
public RenderNode updateDisplayListIfDirty() { |
| 22029 |
final RenderNode renderNode = mRenderNode; |
| 22030 |
if (!canHaveDisplayList()) { |
| 22031 |
|
| 22032 |
return renderNode; |
| 22033 |
} |
| 22034 |
|
| 22035 |
if ((mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) == 0 |
| 22036 |
|| !renderNode.hasDisplayList() |
| 22037 |
|| (mRecreateDisplayList)) { |
| 22038 |
|
| 22039 |
|
| 22040 |
if (renderNode.hasDisplayList() |
| 22041 |
&& !mRecreateDisplayList) { |
| 22042 |
mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID; |
| 22043 |
mPrivateFlags &= ~PFLAG_DIRTY_MASK; |
| 22044 |
dispatchGetDisplayList(); |
| 22045 |
|
| 22046 |
return renderNode; |
| 22047 |
} |
| 22048 |
|
| 22049 |
|
| 22050 |
|
| 22051 |
mRecreateDisplayList = true; |
| 22052 |
|
| 22053 |
int width = mRight - mLeft; |
| 22054 |
int height = mBottom - mTop; |
| 22055 |
int layerType = getLayerType(); |
| 22056 |
|
| 22057 |
|
| 22058 |
|
| 22059 |
renderNode.clearStretch(); |
| 22060 |
|
| 22061 |
final RecordingCanvas canvas = renderNode.beginRecording(width, height); |
| 22062 |
|
| 22063 |
try { |
| 22064 |
if (layerType == LAYER_TYPE_SOFTWARE) { |
| 22065 |
buildDrawingCache(true); |
| 22066 |
Bitmap cache = getDrawingCache(true); |
| 22067 |
if (cache != null) { |
| 22068 |
canvas.drawBitmap(cache, 0, 0, mLayerPaint); |
| 22069 |
} |
| 22070 |
} else { |
| 22071 |
computeScroll(); |
| 22072 |
|
| 22073 |
canvas.translate(-mScrollX, -mScrollY); |
| 22074 |
mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID; |
| 22075 |
mPrivateFlags &= ~PFLAG_DIRTY_MASK; |
| 22076 |
|
| 22077 |
|
| 22078 |
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) { |
| 22079 |
dispatchDraw(canvas); |
| 22080 |
drawAutofilledHighlight(canvas); |
| 22081 |
if (mOverlay != null && !mOverlay.isEmpty()) { |
| 22082 |
mOverlay.getOverlayView().draw(canvas); |
| 22083 |
} |
| 22084 |
if (isShowingLayoutBounds()) { |
| 22085 |
debugDrawFocus(canvas); |
| 22086 |
} |
| 22087 |
} else { |
| 22088 |
draw(canvas); |
| 22089 |
} |
| 22090 |
} |
| 22091 |
} finally { |
| 22092 |
renderNode.endRecording(); |
| 22093 |
setDisplayListProperties(renderNode); |
| 22094 |
} |
| 22095 |
} else { |
| 22096 |
mPrivateFlags |= PFLAG_DRAWN | PFLAG_DRAWING_CACHE_VALID; |
| 22097 |
mPrivateFlags &= ~PFLAG_DIRTY_MASK; |
| 22098 |
} |
| 22099 |
return renderNode; |
| 22100 |
} |
| 22101 |
|
| 22102 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 22103 |
private void resetDisplayList() { |
| 22104 |
mRenderNode.discardDisplayList(); |
| 22105 |
if (mBackgroundRenderNode != null) { |
| 22106 |
mBackgroundRenderNode.discardDisplayList(); |
| 22107 |
} |
| 22108 |
} |
| 22109 |
|
| 22110 |
|
| 22111 |
|
| 22112 |
|
| 22113 |
|
| 22114 |
|
| 22115 |
|
| 22116 |
|
| 22117 |
|
| 22118 |
|
| 22119 |
|
| 22120 |
|
| 22121 |
|
| 22122 |
|
| 22123 |
|
| 22124 |
|
| 22125 |
|
| 22126 |
|
| 22127 |
|
| 22128 |
|
| 22129 |
|
| 22130 |
@Deprecated |
| 22131 |
public Bitmap getDrawingCache() { |
| 22132 |
return getDrawingCache(false); |
| 22133 |
} |
| 22134 |
|
| 22135 |
|
| 22136 |
|
| 22137 |
|
| 22138 |
|
| 22139 |
|
| 22140 |
|
| 22141 |
|
| 22142 |
|
| 22143 |
|
| 22144 |
|
| 22145 |
|
| 22146 |
|
| 22147 |
|
| 22148 |
|
| 22149 |
|
| 22150 |
|
| 22151 |
|
| 22152 |
|
| 22153 |
|
| 22154 |
|
| 22155 |
|
| 22156 |
|
| 22157 |
|
| 22158 |
|
| 22159 |
|
| 22160 |
|
| 22161 |
|
| 22162 |
|
| 22163 |
|
| 22164 |
|
| 22165 |
|
| 22166 |
|
| 22167 |
|
| 22168 |
|
| 22169 |
|
| 22170 |
|
| 22171 |
|
| 22172 |
|
| 22173 |
|
| 22174 |
|
| 22175 |
@Deprecated |
| 22176 |
public Bitmap getDrawingCache(boolean autoScale) { |
| 22177 |
if ((mViewFlags & WILL_NOT_CACHE_DRAWING) == WILL_NOT_CACHE_DRAWING) { |
| 22178 |
return null; |
| 22179 |
} |
| 22180 |
if ((mViewFlags & DRAWING_CACHE_ENABLED) == DRAWING_CACHE_ENABLED) { |
| 22181 |
buildDrawingCache(autoScale); |
| 22182 |
} |
| 22183 |
return autoScale ? mDrawingCache : mUnscaledDrawingCache; |
| 22184 |
} |
| 22185 |
|
| 22186 |
|
| 22187 |
|
| 22188 |
|
| 22189 |
|
| 22190 |
|
| 22191 |
|
| 22192 |
|
| 22193 |
|
| 22194 |
|
| 22195 |
|
| 22196 |
|
| 22197 |
|
| 22198 |
|
| 22199 |
|
| 22200 |
|
| 22201 |
|
| 22202 |
|
| 22203 |
|
| 22204 |
|
| 22205 |
|
| 22206 |
|
| 22207 |
|
| 22208 |
|
| 22209 |
@Deprecated |
| 22210 |
public void destroyDrawingCache() { |
| 22211 |
if (mDrawingCache != null) { |
| 22212 |
mDrawingCache.recycle(); |
| 22213 |
mDrawingCache = null; |
| 22214 |
} |
| 22215 |
if (mUnscaledDrawingCache != null) { |
| 22216 |
mUnscaledDrawingCache.recycle(); |
| 22217 |
mUnscaledDrawingCache = null; |
| 22218 |
} |
| 22219 |
} |
| 22220 |
|
| 22221 |
|
| 22222 |
|
| 22223 |
|
| 22224 |
|
| 22225 |
|
| 22226 |
|
| 22227 |
|
| 22228 |
|
| 22229 |
|
| 22230 |
|
| 22231 |
|
| 22232 |
|
| 22233 |
|
| 22234 |
|
| 22235 |
|
| 22236 |
|
| 22237 |
|
| 22238 |
|
| 22239 |
|
| 22240 |
|
| 22241 |
|
| 22242 |
|
| 22243 |
|
| 22244 |
|
| 22245 |
@Deprecated |
| 22246 |
public void setDrawingCacheBackgroundColor(@ColorInt int color) { |
| 22247 |
if (color != mDrawingCacheBackgroundColor) { |
| 22248 |
mDrawingCacheBackgroundColor = color; |
| 22249 |
mPrivateFlags &= ~PFLAG_DRAWING_CACHE_VALID; |
| 22250 |
} |
| 22251 |
} |
| 22252 |
|
| 22253 |
|
| 22254 |
|
| 22255 |
|
| 22256 |
|
| 22257 |
|
| 22258 |
|
| 22259 |
|
| 22260 |
|
| 22261 |
|
| 22262 |
|
| 22263 |
|
| 22264 |
|
| 22265 |
|
| 22266 |
|
| 22267 |
|
| 22268 |
|
| 22269 |
|
| 22270 |
|
| 22271 |
@Deprecated |
| 22272 |
@ColorInt |
| 22273 |
public int getDrawingCacheBackgroundColor() { |
| 22274 |
return mDrawingCacheBackgroundColor; |
| 22275 |
} |
| 22276 |
|
| 22277 |
|
| 22278 |
|
| 22279 |
|
| 22280 |
|
| 22281 |
|
| 22282 |
|
| 22283 |
|
| 22284 |
|
| 22285 |
|
| 22286 |
|
| 22287 |
|
| 22288 |
|
| 22289 |
|
| 22290 |
|
| 22291 |
|
| 22292 |
|
| 22293 |
|
| 22294 |
|
| 22295 |
@Deprecated |
| 22296 |
public void buildDrawingCache() { |
| 22297 |
buildDrawingCache(false); |
| 22298 |
} |
| 22299 |
|
| 22300 |
|
| 22301 |
|
| 22302 |
|
| 22303 |
|
| 22304 |
|
| 22305 |
|
| 22306 |
|
| 22307 |
|
| 22308 |
|
| 22309 |
|
| 22310 |
|
| 22311 |
|
| 22312 |
|
| 22313 |
|
| 22314 |
|
| 22315 |
|
| 22316 |
|
| 22317 |
|
| 22318 |
|
| 22319 |
|
| 22320 |
|
| 22321 |
|
| 22322 |
|
| 22323 |
|
| 22324 |
|
| 22325 |
|
| 22326 |
|
| 22327 |
|
| 22328 |
|
| 22329 |
|
| 22330 |
|
| 22331 |
|
| 22332 |
|
| 22333 |
|
| 22334 |
|
| 22335 |
|
| 22336 |
@Deprecated |
| 22337 |
public void buildDrawingCache(boolean autoScale) { |
| 22338 |
if ((mPrivateFlags & PFLAG_DRAWING_CACHE_VALID) == 0 || (autoScale ? |
| 22339 |
mDrawingCache == null : mUnscaledDrawingCache == null)) { |
| 22340 |
if (Trace.isTagEnabled(Trace.TRACE_TAG_VIEW)) { |
| 22341 |
Trace.traceBegin(Trace.TRACE_TAG_VIEW, |
| 22342 |
"buildDrawingCache/SW Layer for " + getClass().getSimpleName()); |
| 22343 |
} |
| 22344 |
try { |
| 22345 |
buildDrawingCacheImpl(autoScale); |
| 22346 |
} finally { |
| 22347 |
Trace.traceEnd(Trace.TRACE_TAG_VIEW); |
| 22348 |
} |
| 22349 |
} |
| 22350 |
} |
| 22351 |
|
| 22352 |
|
| 22353 |
|
| 22354 |
|
| 22355 |
private void buildDrawingCacheImpl(boolean autoScale) { |
| 22356 |
mCachingFailed = false; |
| 22357 |
|
| 22358 |
int width = mRight - mLeft; |
| 22359 |
int height = mBottom - mTop; |
| 22360 |
|
| 22361 |
final AttachInfo attachInfo = mAttachInfo; |
| 22362 |
final boolean scalingRequired = attachInfo != null && attachInfo.mScalingRequired; |
| 22363 |
|
| 22364 |
if (autoScale && scalingRequired) { |
| 22365 |
width = (int) ((width * attachInfo.mApplicationScale) + 0.5f); |
| 22366 |
height = (int) ((height * attachInfo.mApplicationScale) + 0.5f); |
| 22367 |
} |
| 22368 |
|
| 22369 |
final int drawingCacheBackgroundColor = mDrawingCacheBackgroundColor; |
| 22370 |
final boolean opaque = drawingCacheBackgroundColor != 0 || isOpaque(); |
| 22371 |
final boolean use32BitCache = attachInfo != null && attachInfo.mUse32BitDrawingCache; |
| 22372 |
|
| 22373 |
final long projectedBitmapSize = width * height * (opaque && !use32BitCache ? 2 : 4); |
| 22374 |
final long drawingCacheSize = |
| 22375 |
ViewConfiguration.get(mContext).getScaledMaximumDrawingCacheSize(); |
| 22376 |
if (width <= 0 || height <= 0 || projectedBitmapSize > drawingCacheSize) { |
| 22377 |
if (width > 0 && height > 0) { |
| 22378 |
Log.w(VIEW_LOG_TAG, getClass().getSimpleName() + " not displayed because it is" |
| 22379 |
+ " too large to fit into a software layer (or drawing cache), needs " |
| 22380 |
+ projectedBitmapSize + " bytes, only " |
| 22381 |
+ drawingCacheSize + " available"); |
| 22382 |
} |
| 22383 |
destroyDrawingCache(); |
| 22384 |
mCachingFailed = true; |
| 22385 |
return; |
| 22386 |
} |
| 22387 |
|
| 22388 |
boolean clear = true; |
| 22389 |
Bitmap bitmap = autoScale ? mDrawingCache : mUnscaledDrawingCache; |
| 22390 |
|
| 22391 |
if (bitmap == null || bitmap.getWidth() != width || bitmap.getHeight() != height) { |
| 22392 |
Bitmap.Config quality; |
| 22393 |
if (!opaque) { |
| 22394 |
|
| 22395 |
|
| 22396 |
switch (mViewFlags & DRAWING_CACHE_QUALITY_MASK) { |
| 22397 |
case DRAWING_CACHE_QUALITY_AUTO: |
| 22398 |
case DRAWING_CACHE_QUALITY_LOW: |
| 22399 |
case DRAWING_CACHE_QUALITY_HIGH: |
| 22400 |
default: |
| 22401 |
quality = Bitmap.Config.ARGB_8888; |
| 22402 |
break; |
| 22403 |
} |
| 22404 |
} else { |
| 22405 |
|
| 22406 |
|
| 22407 |
quality = use32BitCache ? Bitmap.Config.ARGB_8888 : Bitmap.Config.RGB_565; |
| 22408 |
} |
| 22409 |
|
| 22410 |
|
| 22411 |
if (bitmap != null) bitmap.recycle(); |
| 22412 |
|
| 22413 |
try { |
| 22414 |
bitmap = Bitmap.createBitmap(mResources.getDisplayMetrics(), |
| 22415 |
width, height, quality); |
| 22416 |
bitmap.setDensity(getResources().getDisplayMetrics().densityDpi); |
| 22417 |
if (autoScale) { |
| 22418 |
mDrawingCache = bitmap; |
| 22419 |
} else { |
| 22420 |
mUnscaledDrawingCache = bitmap; |
| 22421 |
} |
| 22422 |
if (opaque && use32BitCache) bitmap.setHasAlpha(false); |
| 22423 |
} catch (OutOfMemoryError e) { |
| 22424 |
|
| 22425 |
|
| 22426 |
|
| 22427 |
if (autoScale) { |
| 22428 |
mDrawingCache = null; |
| 22429 |
} else { |
| 22430 |
mUnscaledDrawingCache = null; |
| 22431 |
} |
| 22432 |
mCachingFailed = true; |
| 22433 |
return; |
| 22434 |
} |
| 22435 |
|
| 22436 |
clear = drawingCacheBackgroundColor != 0; |
| 22437 |
} |
| 22438 |
|
| 22439 |
Canvas canvas; |
| 22440 |
if (attachInfo != null) { |
| 22441 |
canvas = attachInfo.mCanvas; |
| 22442 |
if (canvas == null) { |
| 22443 |
canvas = new Canvas(); |
| 22444 |
} |
| 22445 |
canvas.setBitmap(bitmap); |
| 22446 |
|
| 22447 |
|
| 22448 |
|
| 22449 |
|
| 22450 |
attachInfo.mCanvas = null; |
| 22451 |
} else { |
| 22452 |
|
| 22453 |
canvas = new Canvas(bitmap); |
| 22454 |
} |
| 22455 |
|
| 22456 |
if (clear) { |
| 22457 |
bitmap.eraseColor(drawingCacheBackgroundColor); |
| 22458 |
} |
| 22459 |
|
| 22460 |
computeScroll(); |
| 22461 |
final int restoreCount = canvas.save(); |
| 22462 |
|
| 22463 |
if (autoScale && scalingRequired) { |
| 22464 |
final float scale = attachInfo.mApplicationScale; |
| 22465 |
canvas.scale(scale, scale); |
| 22466 |
} |
| 22467 |
|
| 22468 |
canvas.translate(-mScrollX, -mScrollY); |
| 22469 |
|
| 22470 |
mPrivateFlags |= PFLAG_DRAWN; |
| 22471 |
if (mAttachInfo == null || !mAttachInfo.mHardwareAccelerated || |
| 22472 |
mLayerType != LAYER_TYPE_NONE) { |
| 22473 |
mPrivateFlags |= PFLAG_DRAWING_CACHE_VALID; |
| 22474 |
} |
| 22475 |
|
| 22476 |
|
| 22477 |
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) { |
| 22478 |
mPrivateFlags &= ~PFLAG_DIRTY_MASK; |
| 22479 |
dispatchDraw(canvas); |
| 22480 |
drawAutofilledHighlight(canvas); |
| 22481 |
if (mOverlay != null && !mOverlay.isEmpty()) { |
| 22482 |
mOverlay.getOverlayView().draw(canvas); |
| 22483 |
} |
| 22484 |
} else { |
| 22485 |
draw(canvas); |
| 22486 |
} |
| 22487 |
|
| 22488 |
canvas.restoreToCount(restoreCount); |
| 22489 |
canvas.setBitmap(null); |
| 22490 |
|
| 22491 |
if (attachInfo != null) { |
| 22492 |
|
| 22493 |
attachInfo.mCanvas = canvas; |
| 22494 |
} |
| 22495 |
} |
| 22496 |
|
| 22497 |
|
| 22498 |
|
| 22499 |
|
| 22500 |
|
| 22501 |
|
| 22502 |
|
| 22503 |
@UnsupportedAppUsage |
| 22504 |
public Bitmap createSnapshot(ViewDebug.CanvasProvider canvasProvider, boolean skipChildren) { |
| 22505 |
int width = mRight - mLeft; |
| 22506 |
int height = mBottom - mTop; |
| 22507 |
|
| 22508 |
final AttachInfo attachInfo = mAttachInfo; |
| 22509 |
final float scale = attachInfo != null ? attachInfo.mApplicationScale : 1.0f; |
| 22510 |
width = (int) ((width * scale) + 0.5f); |
| 22511 |
height = (int) ((height * scale) + 0.5f); |
| 22512 |
|
| 22513 |
Canvas oldCanvas = null; |
| 22514 |
try { |
| 22515 |
Canvas canvas = canvasProvider.getCanvas(this, |
| 22516 |
width > 0 ? width : 1, height > 0 ? height : 1); |
| 22517 |
|
| 22518 |
if (attachInfo != null) { |
| 22519 |
oldCanvas = attachInfo.mCanvas; |
| 22520 |
|
| 22521 |
|
| 22522 |
|
| 22523 |
|
| 22524 |
attachInfo.mCanvas = null; |
| 22525 |
} |
| 22526 |
|
| 22527 |
computeScroll(); |
| 22528 |
final int restoreCount = canvas.save(); |
| 22529 |
canvas.scale(scale, scale); |
| 22530 |
canvas.translate(-mScrollX, -mScrollY); |
| 22531 |
|
| 22532 |
|
| 22533 |
int flags = mPrivateFlags; |
| 22534 |
mPrivateFlags &= ~PFLAG_DIRTY_MASK; |
| 22535 |
|
| 22536 |
|
| 22537 |
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) { |
| 22538 |
dispatchDraw(canvas); |
| 22539 |
drawAutofilledHighlight(canvas); |
| 22540 |
if (mOverlay != null && !mOverlay.isEmpty()) { |
| 22541 |
mOverlay.getOverlayView().draw(canvas); |
| 22542 |
} |
| 22543 |
} else { |
| 22544 |
draw(canvas); |
| 22545 |
} |
| 22546 |
|
| 22547 |
mPrivateFlags = flags; |
| 22548 |
canvas.restoreToCount(restoreCount); |
| 22549 |
return canvasProvider.createBitmap(); |
| 22550 |
} finally { |
| 22551 |
if (oldCanvas != null) { |
| 22552 |
attachInfo.mCanvas = oldCanvas; |
| 22553 |
} |
| 22554 |
} |
| 22555 |
} |
| 22556 |
|
| 22557 |
|
| 22558 |
|
| 22559 |
|
| 22560 |
|
| 22561 |
|
| 22562 |
|
| 22563 |
|
| 22564 |
|
| 22565 |
|
| 22566 |
|
| 22567 |
|
| 22568 |
|
| 22569 |
|
| 22570 |
|
| 22571 |
|
| 22572 |
public boolean isInEditMode() { |
| 22573 |
return false; |
| 22574 |
} |
| 22575 |
|
| 22576 |
|
| 22577 |
|
| 22578 |
|
| 22579 |
|
| 22580 |
|
| 22581 |
|
| 22582 |
|
| 22583 |
|
| 22584 |
|
| 22585 |
|
| 22586 |
|
| 22587 |
|
| 22588 |
|
| 22589 |
|
| 22590 |
|
| 22591 |
|
| 22592 |
|
| 22593 |
|
| 22594 |
protected boolean isPaddingOffsetRequired() { |
| 22595 |
return false; |
| 22596 |
} |
| 22597 |
|
| 22598 |
|
| 22599 |
|
| 22600 |
|
| 22601 |
|
| 22602 |
|
| 22603 |
|
| 22604 |
|
| 22605 |
|
| 22606 |
|
| 22607 |
|
| 22608 |
protected int getLeftPaddingOffset() { |
| 22609 |
return 0; |
| 22610 |
} |
| 22611 |
|
| 22612 |
|
| 22613 |
|
| 22614 |
|
| 22615 |
|
| 22616 |
|
| 22617 |
|
| 22618 |
|
| 22619 |
|
| 22620 |
|
| 22621 |
|
| 22622 |
protected int getRightPaddingOffset() { |
| 22623 |
return 0; |
| 22624 |
} |
| 22625 |
|
| 22626 |
|
| 22627 |
|
| 22628 |
|
| 22629 |
|
| 22630 |
|
| 22631 |
|
| 22632 |
|
| 22633 |
|
| 22634 |
|
| 22635 |
|
| 22636 |
protected int getTopPaddingOffset() { |
| 22637 |
return 0; |
| 22638 |
} |
| 22639 |
|
| 22640 |
|
| 22641 |
|
| 22642 |
|
| 22643 |
|
| 22644 |
|
| 22645 |
|
| 22646 |
|
| 22647 |
|
| 22648 |
|
| 22649 |
|
| 22650 |
protected int getBottomPaddingOffset() { |
| 22651 |
return 0; |
| 22652 |
} |
| 22653 |
|
| 22654 |
|
| 22655 |
|
| 22656 |
|
| 22657 |
|
| 22658 |
protected int getFadeTop(boolean offsetRequired) { |
| 22659 |
int top = mPaddingTop; |
| 22660 |
if (offsetRequired) top += getTopPaddingOffset(); |
| 22661 |
return top; |
| 22662 |
} |
| 22663 |
|
| 22664 |
|
| 22665 |
|
| 22666 |
|
| 22667 |
|
| 22668 |
protected int getFadeHeight(boolean offsetRequired) { |
| 22669 |
int padding = mPaddingTop; |
| 22670 |
if (offsetRequired) padding += getTopPaddingOffset(); |
| 22671 |
return mBottom - mTop - mPaddingBottom - padding; |
| 22672 |
} |
| 22673 |
|
| 22674 |
|
| 22675 |
|
| 22676 |
|
| 22677 |
|
| 22678 |
|
| 22679 |
|
| 22680 |
|
| 22681 |
|
| 22682 |
|
| 22683 |
|
| 22684 |
|
| 22685 |
|
| 22686 |
|
| 22687 |
|
| 22688 |
|
| 22689 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 22690 |
public boolean isHardwareAccelerated() { |
| 22691 |
return mAttachInfo != null && mAttachInfo.mHardwareAccelerated; |
| 22692 |
} |
| 22693 |
|
| 22694 |
|
| 22695 |
|
| 22696 |
|
| 22697 |
|
| 22698 |
|
| 22699 |
|
| 22700 |
|
| 22701 |
|
| 22702 |
public void setClipBounds(Rect clipBounds) { |
| 22703 |
if (clipBounds == mClipBounds |
| 22704 |
|| (clipBounds != null && clipBounds.equals(mClipBounds))) { |
| 22705 |
return; |
| 22706 |
} |
| 22707 |
if (clipBounds != null) { |
| 22708 |
if (mClipBounds == null) { |
| 22709 |
mClipBounds = new Rect(clipBounds); |
| 22710 |
} else { |
| 22711 |
mClipBounds.set(clipBounds); |
| 22712 |
} |
| 22713 |
} else { |
| 22714 |
mClipBounds = null; |
| 22715 |
} |
| 22716 |
mRenderNode.setClipRect(mClipBounds); |
| 22717 |
invalidateViewProperty(false, false); |
| 22718 |
} |
| 22719 |
|
| 22720 |
|
| 22721 |
|
| 22722 |
|
| 22723 |
|
| 22724 |
|
| 22725 |
|
| 22726 |
public Rect getClipBounds() { |
| 22727 |
return (mClipBounds != null) ? new Rect(mClipBounds) : null; |
| 22728 |
} |
| 22729 |
|
| 22730 |
|
| 22731 |
|
| 22732 |
|
| 22733 |
|
| 22734 |
|
| 22735 |
|
| 22736 |
|
| 22737 |
|
| 22738 |
|
| 22739 |
|
| 22740 |
public boolean getClipBounds(Rect outRect) { |
| 22741 |
if (mClipBounds != null) { |
| 22742 |
outRect.set(mClipBounds); |
| 22743 |
return true; |
| 22744 |
} |
| 22745 |
return false; |
| 22746 |
} |
| 22747 |
|
| 22748 |
|
| 22749 |
|
| 22750 |
|
| 22751 |
|
| 22752 |
private boolean applyLegacyAnimation(ViewGroup parent, long drawingTime, |
| 22753 |
Animation a, boolean scalingRequired) { |
| 22754 |
Transformation invalidationTransform; |
| 22755 |
final int flags = parent.mGroupFlags; |
| 22756 |
final boolean initialized = a.isInitialized(); |
| 22757 |
if (!initialized) { |
| 22758 |
a.initialize(mRight - mLeft, mBottom - mTop, parent.getWidth(), parent.getHeight()); |
| 22759 |
a.initializeInvalidateRegion(0, 0, mRight - mLeft, mBottom - mTop); |
| 22760 |
if (mAttachInfo != null) a.setListenerHandler(mAttachInfo.mHandler); |
| 22761 |
onAnimationStart(); |
| 22762 |
} |
| 22763 |
|
| 22764 |
final Transformation t = parent.getChildTransformation(); |
| 22765 |
boolean more = a.getTransformation(drawingTime, t, 1f); |
| 22766 |
if (scalingRequired && mAttachInfo.mApplicationScale != 1f) { |
| 22767 |
if (parent.mInvalidationTransformation == null) { |
| 22768 |
parent.mInvalidationTransformation = new Transformation(); |
| 22769 |
} |
| 22770 |
invalidationTransform = parent.mInvalidationTransformation; |
| 22771 |
a.getTransformation(drawingTime, invalidationTransform, 1f); |
| 22772 |
} else { |
| 22773 |
invalidationTransform = t; |
| 22774 |
} |
| 22775 |
|
| 22776 |
if (more) { |
| 22777 |
if (!a.willChangeBounds()) { |
| 22778 |
if ((flags & (ViewGroup.FLAG_OPTIMIZE_INVALIDATE | ViewGroup.FLAG_ANIMATION_DONE)) == |
| 22779 |
ViewGroup.FLAG_OPTIMIZE_INVALIDATE) { |
| 22780 |
parent.mGroupFlags |= ViewGroup.FLAG_INVALIDATE_REQUIRED; |
| 22781 |
} else if ((flags & ViewGroup.FLAG_INVALIDATE_REQUIRED) == 0) { |
| 22782 |
|
| 22783 |
|
| 22784 |
parent.mPrivateFlags |= PFLAG_DRAW_ANIMATION; |
| 22785 |
parent.invalidate(mLeft, mTop, mRight, mBottom); |
| 22786 |
} |
| 22787 |
} else { |
| 22788 |
if (parent.mInvalidateRegion == null) { |
| 22789 |
parent.mInvalidateRegion = new RectF(); |
| 22790 |
} |
| 22791 |
final RectF region = parent.mInvalidateRegion; |
| 22792 |
a.getInvalidateRegion(0, 0, mRight - mLeft, mBottom - mTop, region, |
| 22793 |
invalidationTransform); |
| 22794 |
|
| 22795 |
|
| 22796 |
|
| 22797 |
parent.mPrivateFlags |= PFLAG_DRAW_ANIMATION; |
| 22798 |
|
| 22799 |
final int left = mLeft + (int) region.left; |
| 22800 |
final int top = mTop + (int) region.top; |
| 22801 |
parent.invalidate(left, top, left + (int) (region.width() + .5f), |
| 22802 |
top + (int) (region.height() + .5f)); |
| 22803 |
} |
| 22804 |
} |
| 22805 |
return more; |
| 22806 |
} |
| 22807 |
|
| 22808 |
|
| 22809 |
|
| 22810 |
|
| 22811 |
|
| 22812 |
void setDisplayListProperties(RenderNode renderNode) { |
| 22813 |
if (renderNode != null) { |
| 22814 |
renderNode.setHasOverlappingRendering(getHasOverlappingRendering()); |
| 22815 |
renderNode.setClipToBounds(mParent instanceof ViewGroup |
| 22816 |
&& ((ViewGroup) mParent).getClipChildren()); |
| 22817 |
|
| 22818 |
float alpha = 1; |
| 22819 |
if (mParent instanceof ViewGroup && (((ViewGroup) mParent).mGroupFlags & |
| 22820 |
ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) { |
| 22821 |
ViewGroup parentVG = (ViewGroup) mParent; |
| 22822 |
final Transformation t = parentVG.getChildTransformation(); |
| 22823 |
if (parentVG.getChildStaticTransformation(this, t)) { |
| 22824 |
final int transformType = t.getTransformationType(); |
| 22825 |
if (transformType != Transformation.TYPE_IDENTITY) { |
| 22826 |
if ((transformType & Transformation.TYPE_ALPHA) != 0) { |
| 22827 |
alpha = t.getAlpha(); |
| 22828 |
} |
| 22829 |
if ((transformType & Transformation.TYPE_MATRIX) != 0) { |
| 22830 |
renderNode.setStaticMatrix(t.getMatrix()); |
| 22831 |
} |
| 22832 |
} |
| 22833 |
} |
| 22834 |
} |
| 22835 |
if (mTransformationInfo != null) { |
| 22836 |
alpha *= getFinalAlpha(); |
| 22837 |
if (alpha < 1) { |
| 22838 |
final int multipliedAlpha = (int) (255 * alpha); |
| 22839 |
if (onSetAlpha(multipliedAlpha)) { |
| 22840 |
alpha = 1; |
| 22841 |
} |
| 22842 |
} |
| 22843 |
renderNode.setAlpha(alpha); |
| 22844 |
} else if (alpha < 1) { |
| 22845 |
renderNode.setAlpha(alpha); |
| 22846 |
} |
| 22847 |
} |
| 22848 |
} |
| 22849 |
|
| 22850 |
|
| 22851 |
|
| 22852 |
|
| 22853 |
|
| 22854 |
|
| 22855 |
|
| 22856 |
|
| 22857 |
|
| 22858 |
protected final boolean drawsWithRenderNode(Canvas canvas) { |
| 22859 |
return mAttachInfo != null |
| 22860 |
&& mAttachInfo.mHardwareAccelerated |
| 22861 |
&& canvas.isHardwareAccelerated(); |
| 22862 |
} |
| 22863 |
|
| 22864 |
|
| 22865 |
|
| 22866 |
|
| 22867 |
|
| 22868 |
|
| 22869 |
|
| 22870 |
boolean draw(Canvas canvas, ViewGroup parent, long drawingTime) { |
| 22871 |
|
| 22872 |
final boolean hardwareAcceleratedCanvas = canvas.isHardwareAccelerated(); |
| 22873 |
|
| 22874 |
boolean drawingWithRenderNode = drawsWithRenderNode(canvas); |
| 22875 |
|
| 22876 |
boolean more = false; |
| 22877 |
final boolean childHasIdentityMatrix = hasIdentityMatrix(); |
| 22878 |
final int parentFlags = parent.mGroupFlags; |
| 22879 |
|
| 22880 |
if ((parentFlags & ViewGroup.FLAG_CLEAR_TRANSFORMATION) != 0) { |
| 22881 |
parent.getChildTransformation().clear(); |
| 22882 |
parent.mGroupFlags &= ~ViewGroup.FLAG_CLEAR_TRANSFORMATION; |
| 22883 |
} |
| 22884 |
|
| 22885 |
Transformation transformToApply = null; |
| 22886 |
boolean concatMatrix = false; |
| 22887 |
final boolean scalingRequired = mAttachInfo != null && mAttachInfo.mScalingRequired; |
| 22888 |
final Animation a = getAnimation(); |
| 22889 |
if (a != null) { |
| 22890 |
more = applyLegacyAnimation(parent, drawingTime, a, scalingRequired); |
| 22891 |
concatMatrix = a.willChangeTransformationMatrix(); |
| 22892 |
if (concatMatrix) { |
| 22893 |
mPrivateFlags3 |= PFLAG3_VIEW_IS_ANIMATING_TRANSFORM; |
| 22894 |
} |
| 22895 |
transformToApply = parent.getChildTransformation(); |
| 22896 |
} else { |
| 22897 |
if ((mPrivateFlags3 & PFLAG3_VIEW_IS_ANIMATING_TRANSFORM) != 0) { |
| 22898 |
|
| 22899 |
mRenderNode.setAnimationMatrix(null); |
| 22900 |
mPrivateFlags3 &= ~PFLAG3_VIEW_IS_ANIMATING_TRANSFORM; |
| 22901 |
} |
| 22902 |
if (!drawingWithRenderNode |
| 22903 |
&& (parentFlags & ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS) != 0) { |
| 22904 |
final Transformation t = parent.getChildTransformation(); |
| 22905 |
final boolean hasTransform = parent.getChildStaticTransformation(this, t); |
| 22906 |
if (hasTransform) { |
| 22907 |
final int transformType = t.getTransformationType(); |
| 22908 |
transformToApply = transformType != Transformation.TYPE_IDENTITY ? t : null; |
| 22909 |
concatMatrix = (transformType & Transformation.TYPE_MATRIX) != 0; |
| 22910 |
} |
| 22911 |
} |
| 22912 |
} |
| 22913 |
|
| 22914 |
concatMatrix |= !childHasIdentityMatrix; |
| 22915 |
|
| 22916 |
|
| 22917 |
|
| 22918 |
mPrivateFlags |= PFLAG_DRAWN; |
| 22919 |
|
| 22920 |
if (!concatMatrix && |
| 22921 |
(parentFlags & (ViewGroup.FLAG_SUPPORT_STATIC_TRANSFORMATIONS | |
| 22922 |
ViewGroup.FLAG_CLIP_CHILDREN)) == ViewGroup.FLAG_CLIP_CHILDREN && |
| 22923 |
canvas.quickReject(mLeft, mTop, mRight, mBottom) && |
| 22924 |
(mPrivateFlags & PFLAG_DRAW_ANIMATION) == 0) { |
| 22925 |
mPrivateFlags2 |= PFLAG2_VIEW_QUICK_REJECTED; |
| 22926 |
return more; |
| 22927 |
} |
| 22928 |
mPrivateFlags2 &= ~PFLAG2_VIEW_QUICK_REJECTED; |
| 22929 |
|
| 22930 |
if (hardwareAcceleratedCanvas) { |
| 22931 |
|
| 22932 |
|
| 22933 |
mRecreateDisplayList = (mPrivateFlags & PFLAG_INVALIDATED) != 0; |
| 22934 |
mPrivateFlags &= ~PFLAG_INVALIDATED; |
| 22935 |
} |
| 22936 |
|
| 22937 |
RenderNode renderNode = null; |
| 22938 |
Bitmap cache = null; |
| 22939 |
int layerType = getLayerType(); |
| 22940 |
if (layerType == LAYER_TYPE_SOFTWARE || !drawingWithRenderNode) { |
| 22941 |
if (layerType != LAYER_TYPE_NONE) { |
| 22942 |
|
| 22943 |
layerType = LAYER_TYPE_SOFTWARE; |
| 22944 |
buildDrawingCache(true); |
| 22945 |
} |
| 22946 |
cache = getDrawingCache(true); |
| 22947 |
} |
| 22948 |
|
| 22949 |
if (drawingWithRenderNode) { |
| 22950 |
|
| 22951 |
|
| 22952 |
renderNode = updateDisplayListIfDirty(); |
| 22953 |
if (!renderNode.hasDisplayList()) { |
| 22954 |
|
| 22955 |
|
| 22956 |
|
| 22957 |
renderNode = null; |
| 22958 |
drawingWithRenderNode = false; |
| 22959 |
} |
| 22960 |
} |
| 22961 |
|
| 22962 |
int sx = 0; |
| 22963 |
int sy = 0; |
| 22964 |
if (!drawingWithRenderNode) { |
| 22965 |
computeScroll(); |
| 22966 |
sx = mScrollX; |
| 22967 |
sy = mScrollY; |
| 22968 |
} |
| 22969 |
|
| 22970 |
final boolean drawingWithDrawingCache = cache != null && !drawingWithRenderNode; |
| 22971 |
final boolean offsetForScroll = cache == null && !drawingWithRenderNode; |
| 22972 |
|
| 22973 |
int restoreTo = -1; |
| 22974 |
if (!drawingWithRenderNode || transformToApply != null) { |
| 22975 |
restoreTo = canvas.save(); |
| 22976 |
} |
| 22977 |
if (offsetForScroll) { |
| 22978 |
canvas.translate(mLeft - sx, mTop - sy); |
| 22979 |
} else { |
| 22980 |
if (!drawingWithRenderNode) { |
| 22981 |
canvas.translate(mLeft, mTop); |
| 22982 |
} |
| 22983 |
if (scalingRequired) { |
| 22984 |
if (drawingWithRenderNode) { |
| 22985 |
|
| 22986 |
restoreTo = canvas.save(); |
| 22987 |
} |
| 22988 |
|
| 22989 |
final float scale = 1.0f / mAttachInfo.mApplicationScale; |
| 22990 |
canvas.scale(scale, scale); |
| 22991 |
} |
| 22992 |
} |
| 22993 |
|
| 22994 |
float alpha = drawingWithRenderNode ? 1 : (getAlpha() * getTransitionAlpha()); |
| 22995 |
if (transformToApply != null |
| 22996 |
|| alpha < 1 |
| 22997 |
|| !hasIdentityMatrix() |
| 22998 |
|| (mPrivateFlags3 & PFLAG3_VIEW_IS_ANIMATING_ALPHA) != 0) { |
| 22999 |
if (transformToApply != null || !childHasIdentityMatrix) { |
| 23000 |
int transX = 0; |
| 23001 |
int transY = 0; |
| 23002 |
|
| 23003 |
if (offsetForScroll) { |
| 23004 |
transX = -sx; |
| 23005 |
transY = -sy; |
| 23006 |
} |
| 23007 |
|
| 23008 |
if (transformToApply != null) { |
| 23009 |
if (concatMatrix) { |
| 23010 |
if (drawingWithRenderNode) { |
| 23011 |
renderNode.setAnimationMatrix(transformToApply.getMatrix()); |
| 23012 |
} else { |
| 23013 |
|
| 23014 |
|
| 23015 |
canvas.translate(-transX, -transY); |
| 23016 |
canvas.concat(transformToApply.getMatrix()); |
| 23017 |
canvas.translate(transX, transY); |
| 23018 |
} |
| 23019 |
parent.mGroupFlags |= ViewGroup.FLAG_CLEAR_TRANSFORMATION; |
| 23020 |
} |
| 23021 |
|
| 23022 |
float transformAlpha = transformToApply.getAlpha(); |
| 23023 |
if (transformAlpha < 1) { |
| 23024 |
alpha *= transformAlpha; |
| 23025 |
parent.mGroupFlags |= ViewGroup.FLAG_CLEAR_TRANSFORMATION; |
| 23026 |
} |
| 23027 |
} |
| 23028 |
|
| 23029 |
if (!childHasIdentityMatrix && !drawingWithRenderNode) { |
| 23030 |
canvas.translate(-transX, -transY); |
| 23031 |
canvas.concat(getMatrix()); |
| 23032 |
canvas.translate(transX, transY); |
| 23033 |
} |
| 23034 |
} |
| 23035 |
|
| 23036 |
|
| 23037 |
if (alpha < 1 || (mPrivateFlags3 & PFLAG3_VIEW_IS_ANIMATING_ALPHA) != 0) { |
| 23038 |
if (alpha < 1) { |
| 23039 |
mPrivateFlags3 |= PFLAG3_VIEW_IS_ANIMATING_ALPHA; |
| 23040 |
} else { |
| 23041 |
mPrivateFlags3 &= ~PFLAG3_VIEW_IS_ANIMATING_ALPHA; |
| 23042 |
} |
| 23043 |
parent.mGroupFlags |= ViewGroup.FLAG_CLEAR_TRANSFORMATION; |
| 23044 |
if (!drawingWithDrawingCache) { |
| 23045 |
final int multipliedAlpha = (int) (255 * alpha); |
| 23046 |
if (!onSetAlpha(multipliedAlpha)) { |
| 23047 |
if (drawingWithRenderNode) { |
| 23048 |
renderNode.setAlpha(alpha * getAlpha() * getTransitionAlpha()); |
| 23049 |
} else if (layerType == LAYER_TYPE_NONE) { |
| 23050 |
canvas.saveLayerAlpha(sx, sy, sx + getWidth(), sy + getHeight(), |
| 23051 |
multipliedAlpha); |
| 23052 |
} |
| 23053 |
} else { |
| 23054 |
|
| 23055 |
mPrivateFlags |= PFLAG_ALPHA_SET; |
| 23056 |
} |
| 23057 |
} |
| 23058 |
} |
| 23059 |
} else if ((mPrivateFlags & PFLAG_ALPHA_SET) == PFLAG_ALPHA_SET) { |
| 23060 |
onSetAlpha(255); |
| 23061 |
mPrivateFlags &= ~PFLAG_ALPHA_SET; |
| 23062 |
} |
| 23063 |
|
| 23064 |
if (!drawingWithRenderNode) { |
| 23065 |
|
| 23066 |
if ((parentFlags & ViewGroup.FLAG_CLIP_CHILDREN) != 0 && cache == null) { |
| 23067 |
if (offsetForScroll) { |
| 23068 |
canvas.clipRect(sx, sy, sx + getWidth(), sy + getHeight()); |
| 23069 |
} else { |
| 23070 |
if (!scalingRequired || cache == null) { |
| 23071 |
canvas.clipRect(0, 0, getWidth(), getHeight()); |
| 23072 |
} else { |
| 23073 |
canvas.clipRect(0, 0, cache.getWidth(), cache.getHeight()); |
| 23074 |
} |
| 23075 |
} |
| 23076 |
} |
| 23077 |
|
| 23078 |
if (mClipBounds != null) { |
| 23079 |
|
| 23080 |
canvas.clipRect(mClipBounds); |
| 23081 |
} |
| 23082 |
} |
| 23083 |
|
| 23084 |
if (!drawingWithDrawingCache) { |
| 23085 |
if (drawingWithRenderNode) { |
| 23086 |
mPrivateFlags &= ~PFLAG_DIRTY_MASK; |
| 23087 |
((RecordingCanvas) canvas).drawRenderNode(renderNode); |
| 23088 |
} else { |
| 23089 |
|
| 23090 |
if ((mPrivateFlags & PFLAG_SKIP_DRAW) == PFLAG_SKIP_DRAW) { |
| 23091 |
mPrivateFlags &= ~PFLAG_DIRTY_MASK; |
| 23092 |
dispatchDraw(canvas); |
| 23093 |
} else { |
| 23094 |
draw(canvas); |
| 23095 |
} |
| 23096 |
} |
| 23097 |
} else if (cache != null) { |
| 23098 |
mPrivateFlags &= ~PFLAG_DIRTY_MASK; |
| 23099 |
if (layerType == LAYER_TYPE_NONE || mLayerPaint == null) { |
| 23100 |
|
| 23101 |
Paint cachePaint = parent.mCachePaint; |
| 23102 |
if (cachePaint == null) { |
| 23103 |
cachePaint = new Paint(); |
| 23104 |
cachePaint.setDither(false); |
| 23105 |
parent.mCachePaint = cachePaint; |
| 23106 |
} |
| 23107 |
cachePaint.setAlpha((int) (alpha * 255)); |
| 23108 |
canvas.drawBitmap(cache, 0.0f, 0.0f, cachePaint); |
| 23109 |
} else { |
| 23110 |
|
| 23111 |
int layerPaintAlpha = mLayerPaint.getAlpha(); |
| 23112 |
if (alpha < 1) { |
| 23113 |
mLayerPaint.setAlpha((int) (alpha * layerPaintAlpha)); |
| 23114 |
} |
| 23115 |
canvas.drawBitmap(cache, 0.0f, 0.0f, mLayerPaint); |
| 23116 |
if (alpha < 1) { |
| 23117 |
mLayerPaint.setAlpha(layerPaintAlpha); |
| 23118 |
} |
| 23119 |
} |
| 23120 |
} |
| 23121 |
|
| 23122 |
if (restoreTo >= 0) { |
| 23123 |
canvas.restoreToCount(restoreTo); |
| 23124 |
} |
| 23125 |
|
| 23126 |
if (a != null && !more) { |
| 23127 |
if (!hardwareAcceleratedCanvas && !a.getFillAfter()) { |
| 23128 |
onSetAlpha(255); |
| 23129 |
} |
| 23130 |
parent.finishAnimatingView(this, a); |
| 23131 |
} |
| 23132 |
|
| 23133 |
if (more && hardwareAcceleratedCanvas) { |
| 23134 |
if (a.hasAlpha() && (mPrivateFlags & PFLAG_ALPHA_SET) == PFLAG_ALPHA_SET) { |
| 23135 |
|
| 23136 |
invalidate(true); |
| 23137 |
} |
| 23138 |
} |
| 23139 |
|
| 23140 |
mRecreateDisplayList = false; |
| 23141 |
|
| 23142 |
return more; |
| 23143 |
} |
| 23144 |
|
| 23145 |
static Paint getDebugPaint() { |
| 23146 |
if (sDebugPaint == null) { |
| 23147 |
sDebugPaint = new Paint(); |
| 23148 |
sDebugPaint.setAntiAlias(false); |
| 23149 |
} |
| 23150 |
return sDebugPaint; |
| 23151 |
} |
| 23152 |
|
| 23153 |
final int dipsToPixels(int dips) { |
| 23154 |
float scale = getContext().getResources().getDisplayMetrics().density; |
| 23155 |
return (int) (dips * scale + 0.5f); |
| 23156 |
} |
| 23157 |
|
| 23158 |
final private void debugDrawFocus(Canvas canvas) { |
| 23159 |
if (isFocused()) { |
| 23160 |
final int cornerSquareSize = dipsToPixels(DEBUG_CORNERS_SIZE_DIP); |
| 23161 |
final int l = mScrollX; |
| 23162 |
final int r = l + mRight - mLeft; |
| 23163 |
final int t = mScrollY; |
| 23164 |
final int b = t + mBottom - mTop; |
| 23165 |
|
| 23166 |
final Paint paint = getDebugPaint(); |
| 23167 |
paint.setColor(DEBUG_CORNERS_COLOR); |
| 23168 |
|
| 23169 |
|
| 23170 |
paint.setStyle(Paint.Style.FILL); |
| 23171 |
canvas.drawRect(l, t, l + cornerSquareSize, t + cornerSquareSize, paint); |
| 23172 |
canvas.drawRect(r - cornerSquareSize, t, r, t + cornerSquareSize, paint); |
| 23173 |
canvas.drawRect(l, b - cornerSquareSize, l + cornerSquareSize, b, paint); |
| 23174 |
canvas.drawRect(r - cornerSquareSize, b - cornerSquareSize, r, b, paint); |
| 23175 |
|
| 23176 |
|
| 23177 |
paint.setStyle(Paint.Style.STROKE); |
| 23178 |
canvas.drawLine(l, t, r, b, paint); |
| 23179 |
canvas.drawLine(l, b, r, t, paint); |
| 23180 |
} |
| 23181 |
} |
| 23182 |
|
| 23183 |
|
| 23184 |
|
| 23185 |
|
| 23186 |
|
| 23187 |
|
| 23188 |
|
| 23189 |
|
| 23190 |
|
| 23191 |
|
| 23192 |
@CallSuper |
| 23193 |
public void draw(Canvas canvas) { |
| 23194 |
final int privateFlags = mPrivateFlags; |
| 23195 |
mPrivateFlags = (privateFlags & ~PFLAG_DIRTY_MASK) | PFLAG_DRAWN; |
| 23196 |
|
| 23197 |
|
| 23198 |
|
| 23199 |
|
| 23200 |
|
| 23201 |
|
| 23202 |
|
| 23203 |
|
| 23204 |
|
| 23205 |
|
| 23206 |
|
| 23207 |
|
| 23208 |
|
| 23209 |
|
| 23210 |
|
| 23211 |
int saveCount; |
| 23212 |
|
| 23213 |
drawBackground(canvas); |
| 23214 |
|
| 23215 |
|
| 23216 |
final int viewFlags = mViewFlags; |
| 23217 |
boolean horizontalEdges = (viewFlags & FADING_EDGE_HORIZONTAL) != 0; |
| 23218 |
boolean verticalEdges = (viewFlags & FADING_EDGE_VERTICAL) != 0; |
| 23219 |
if (!verticalEdges && !horizontalEdges) { |
| 23220 |
|
| 23221 |
onDraw(canvas); |
| 23222 |
|
| 23223 |
|
| 23224 |
dispatchDraw(canvas); |
| 23225 |
|
| 23226 |
drawAutofilledHighlight(canvas); |
| 23227 |
|
| 23228 |
|
| 23229 |
if (mOverlay != null && !mOverlay.isEmpty()) { |
| 23230 |
mOverlay.getOverlayView().dispatchDraw(canvas); |
| 23231 |
} |
| 23232 |
|
| 23233 |
|
| 23234 |
onDrawForeground(canvas); |
| 23235 |
|
| 23236 |
|
| 23237 |
drawDefaultFocusHighlight(canvas); |
| 23238 |
|
| 23239 |
if (isShowingLayoutBounds()) { |
| 23240 |
debugDrawFocus(canvas); |
| 23241 |
} |
| 23242 |
|
| 23243 |
|
| 23244 |
return; |
| 23245 |
} |
| 23246 |
|
| 23247 |
|
| 23248 |
|
| 23249 |
|
| 23250 |
|
| 23251 |
|
| 23252 |
|
| 23253 |
|
| 23254 |
boolean drawTop = false; |
| 23255 |
boolean drawBottom = false; |
| 23256 |
boolean drawLeft = false; |
| 23257 |
boolean drawRight = false; |
| 23258 |
|
| 23259 |
float topFadeStrength = 0.0f; |
| 23260 |
float bottomFadeStrength = 0.0f; |
| 23261 |
float leftFadeStrength = 0.0f; |
| 23262 |
float rightFadeStrength = 0.0f; |
| 23263 |
|
| 23264 |
|
| 23265 |
int paddingLeft = mPaddingLeft; |
| 23266 |
|
| 23267 |
final boolean offsetRequired = isPaddingOffsetRequired(); |
| 23268 |
if (offsetRequired) { |
| 23269 |
paddingLeft += getLeftPaddingOffset(); |
| 23270 |
} |
| 23271 |
|
| 23272 |
int left = mScrollX + paddingLeft; |
| 23273 |
int right = left + mRight - mLeft - mPaddingRight - paddingLeft; |
| 23274 |
int top = mScrollY + getFadeTop(offsetRequired); |
| 23275 |
int bottom = top + getFadeHeight(offsetRequired); |
| 23276 |
|
| 23277 |
if (offsetRequired) { |
| 23278 |
right += getRightPaddingOffset(); |
| 23279 |
bottom += getBottomPaddingOffset(); |
| 23280 |
} |
| 23281 |
|
| 23282 |
final ScrollabilityCache scrollabilityCache = mScrollCache; |
| 23283 |
final float fadeHeight = scrollabilityCache.fadingEdgeLength; |
| 23284 |
int length = (int) fadeHeight; |
| 23285 |
|
| 23286 |
|
| 23287 |
|
| 23288 |
if (verticalEdges && (top + length > bottom - length)) { |
| 23289 |
length = (bottom - top) / 2; |
| 23290 |
} |
| 23291 |
|
| 23292 |
|
| 23293 |
if (horizontalEdges && (left + length > right - length)) { |
| 23294 |
length = (right - left) / 2; |
| 23295 |
} |
| 23296 |
|
| 23297 |
if (verticalEdges) { |
| 23298 |
topFadeStrength = Math.max(0.0f, Math.min(1.0f, getTopFadingEdgeStrength())); |
| 23299 |
drawTop = topFadeStrength * fadeHeight > 1.0f; |
| 23300 |
bottomFadeStrength = Math.max(0.0f, Math.min(1.0f, getBottomFadingEdgeStrength())); |
| 23301 |
drawBottom = bottomFadeStrength * fadeHeight > 1.0f; |
| 23302 |
} |
| 23303 |
|
| 23304 |
if (horizontalEdges) { |
| 23305 |
leftFadeStrength = Math.max(0.0f, Math.min(1.0f, getLeftFadingEdgeStrength())); |
| 23306 |
drawLeft = leftFadeStrength * fadeHeight > 1.0f; |
| 23307 |
rightFadeStrength = Math.max(0.0f, Math.min(1.0f, getRightFadingEdgeStrength())); |
| 23308 |
drawRight = rightFadeStrength * fadeHeight > 1.0f; |
| 23309 |
} |
| 23310 |
|
| 23311 |
saveCount = canvas.getSaveCount(); |
| 23312 |
int topSaveCount = -1; |
| 23313 |
int bottomSaveCount = -1; |
| 23314 |
int leftSaveCount = -1; |
| 23315 |
int rightSaveCount = -1; |
| 23316 |
|
| 23317 |
int solidColor = getSolidColor(); |
| 23318 |
if (solidColor == 0) { |
| 23319 |
if (drawTop) { |
| 23320 |
topSaveCount = canvas.saveUnclippedLayer(left, top, right, top + length); |
| 23321 |
} |
| 23322 |
|
| 23323 |
if (drawBottom) { |
| 23324 |
bottomSaveCount = canvas.saveUnclippedLayer(left, bottom - length, right, bottom); |
| 23325 |
} |
| 23326 |
|
| 23327 |
if (drawLeft) { |
| 23328 |
leftSaveCount = canvas.saveUnclippedLayer(left, top, left + length, bottom); |
| 23329 |
} |
| 23330 |
|
| 23331 |
if (drawRight) { |
| 23332 |
rightSaveCount = canvas.saveUnclippedLayer(right - length, top, right, bottom); |
| 23333 |
} |
| 23334 |
} else { |
| 23335 |
scrollabilityCache.setFadeColor(solidColor); |
| 23336 |
} |
| 23337 |
|
| 23338 |
|
| 23339 |
onDraw(canvas); |
| 23340 |
|
| 23341 |
|
| 23342 |
dispatchDraw(canvas); |
| 23343 |
|
| 23344 |
|
| 23345 |
final Paint p = scrollabilityCache.paint; |
| 23346 |
final Matrix matrix = scrollabilityCache.matrix; |
| 23347 |
final Shader fade = scrollabilityCache.shader; |
| 23348 |
|
| 23349 |
|
| 23350 |
if (drawRight) { |
| 23351 |
matrix.setScale(1, fadeHeight * rightFadeStrength); |
| 23352 |
matrix.postRotate(90); |
| 23353 |
matrix.postTranslate(right, top); |
| 23354 |
fade.setLocalMatrix(matrix); |
| 23355 |
p.setShader(fade); |
| 23356 |
if (solidColor == 0) { |
| 23357 |
canvas.restoreUnclippedLayer(rightSaveCount, p); |
| 23358 |
|
| 23359 |
} else { |
| 23360 |
canvas.drawRect(right - length, top, right, bottom, p); |
| 23361 |
} |
| 23362 |
} |
| 23363 |
|
| 23364 |
if (drawLeft) { |
| 23365 |
matrix.setScale(1, fadeHeight * leftFadeStrength); |
| 23366 |
matrix.postRotate(-90); |
| 23367 |
matrix.postTranslate(left, top); |
| 23368 |
fade.setLocalMatrix(matrix); |
| 23369 |
p.setShader(fade); |
| 23370 |
if (solidColor == 0) { |
| 23371 |
canvas.restoreUnclippedLayer(leftSaveCount, p); |
| 23372 |
} else { |
| 23373 |
canvas.drawRect(left, top, left + length, bottom, p); |
| 23374 |
} |
| 23375 |
} |
| 23376 |
|
| 23377 |
if (drawBottom) { |
| 23378 |
matrix.setScale(1, fadeHeight * bottomFadeStrength); |
| 23379 |
matrix.postRotate(180); |
| 23380 |
matrix.postTranslate(left, bottom); |
| 23381 |
fade.setLocalMatrix(matrix); |
| 23382 |
p.setShader(fade); |
| 23383 |
if (solidColor == 0) { |
| 23384 |
canvas.restoreUnclippedLayer(bottomSaveCount, p); |
| 23385 |
} else { |
| 23386 |
canvas.drawRect(left, bottom - length, right, bottom, p); |
| 23387 |
} |
| 23388 |
} |
| 23389 |
|
| 23390 |
if (drawTop) { |
| 23391 |
matrix.setScale(1, fadeHeight * topFadeStrength); |
| 23392 |
matrix.postTranslate(left, top); |
| 23393 |
fade.setLocalMatrix(matrix); |
| 23394 |
p.setShader(fade); |
| 23395 |
if (solidColor == 0) { |
| 23396 |
canvas.restoreUnclippedLayer(topSaveCount, p); |
| 23397 |
} else { |
| 23398 |
canvas.drawRect(left, top, right, top + length, p); |
| 23399 |
} |
| 23400 |
} |
| 23401 |
|
| 23402 |
canvas.restoreToCount(saveCount); |
| 23403 |
|
| 23404 |
drawAutofilledHighlight(canvas); |
| 23405 |
|
| 23406 |
|
| 23407 |
if (mOverlay != null && !mOverlay.isEmpty()) { |
| 23408 |
mOverlay.getOverlayView().dispatchDraw(canvas); |
| 23409 |
} |
| 23410 |
|
| 23411 |
|
| 23412 |
onDrawForeground(canvas); |
| 23413 |
|
| 23414 |
|
| 23415 |
drawDefaultFocusHighlight(canvas); |
| 23416 |
|
| 23417 |
if (isShowingLayoutBounds()) { |
| 23418 |
debugDrawFocus(canvas); |
| 23419 |
} |
| 23420 |
} |
| 23421 |
|
| 23422 |
|
| 23423 |
|
| 23424 |
|
| 23425 |
|
| 23426 |
|
| 23427 |
@UnsupportedAppUsage |
| 23428 |
private void drawBackground(Canvas canvas) { |
| 23429 |
final Drawable background = mBackground; |
| 23430 |
if (background == null) { |
| 23431 |
return; |
| 23432 |
} |
| 23433 |
|
| 23434 |
setBackgroundBounds(); |
| 23435 |
|
| 23436 |
|
| 23437 |
if (canvas.isHardwareAccelerated() && mAttachInfo != null |
| 23438 |
&& mAttachInfo.mThreadedRenderer != null) { |
| 23439 |
mBackgroundRenderNode = getDrawableRenderNode(background, mBackgroundRenderNode); |
| 23440 |
|
| 23441 |
final RenderNode renderNode = mBackgroundRenderNode; |
| 23442 |
if (renderNode != null && renderNode.hasDisplayList()) { |
| 23443 |
setBackgroundRenderNodeProperties(renderNode); |
| 23444 |
((RecordingCanvas) canvas).drawRenderNode(renderNode); |
| 23445 |
return; |
| 23446 |
} |
| 23447 |
} |
| 23448 |
|
| 23449 |
final int scrollX = mScrollX; |
| 23450 |
final int scrollY = mScrollY; |
| 23451 |
if ((scrollX | scrollY) == 0) { |
| 23452 |
background.draw(canvas); |
| 23453 |
} else { |
| 23454 |
canvas.translate(scrollX, scrollY); |
| 23455 |
background.draw(canvas); |
| 23456 |
canvas.translate(-scrollX, -scrollY); |
| 23457 |
} |
| 23458 |
} |
| 23459 |
|
| 23460 |
|
| 23461 |
|
| 23462 |
|
| 23463 |
|
| 23464 |
|
| 23465 |
void setBackgroundBounds() { |
| 23466 |
if (mBackgroundSizeChanged && mBackground != null) { |
| 23467 |
mBackground.setBounds(0, 0, mRight - mLeft, mBottom - mTop); |
| 23468 |
mBackgroundSizeChanged = false; |
| 23469 |
rebuildOutline(); |
| 23470 |
} |
| 23471 |
} |
| 23472 |
|
| 23473 |
private void setBackgroundRenderNodeProperties(RenderNode renderNode) { |
| 23474 |
renderNode.setTranslationX(mScrollX); |
| 23475 |
renderNode.setTranslationY(mScrollY); |
| 23476 |
} |
| 23477 |
|
| 23478 |
|
| 23479 |
|
| 23480 |
|
| 23481 |
|
| 23482 |
|
| 23483 |
|
| 23484 |
|
| 23485 |
|
| 23486 |
private RenderNode getDrawableRenderNode(Drawable drawable, RenderNode renderNode) { |
| 23487 |
if (renderNode == null) { |
| 23488 |
renderNode = RenderNode.create(drawable.getClass().getName(), |
| 23489 |
new ViewAnimationHostBridge(this)); |
| 23490 |
renderNode.setUsageHint(RenderNode.USAGE_BACKGROUND); |
| 23491 |
} |
| 23492 |
|
| 23493 |
final Rect bounds = drawable.getBounds(); |
| 23494 |
final int width = bounds.width(); |
| 23495 |
final int height = bounds.height(); |
| 23496 |
|
| 23497 |
|
| 23498 |
|
| 23499 |
renderNode.clearStretch(); |
| 23500 |
|
| 23501 |
final RecordingCanvas canvas = renderNode.beginRecording(width, height); |
| 23502 |
|
| 23503 |
|
| 23504 |
|
| 23505 |
|
| 23506 |
|
| 23507 |
canvas.translate(-bounds.left, -bounds.top); |
| 23508 |
|
| 23509 |
try { |
| 23510 |
drawable.draw(canvas); |
| 23511 |
} finally { |
| 23512 |
renderNode.endRecording(); |
| 23513 |
} |
| 23514 |
|
| 23515 |
|
| 23516 |
renderNode.setLeftTopRightBottom(bounds.left, bounds.top, bounds.right, bounds.bottom); |
| 23517 |
renderNode.setProjectBackwards(drawable.isProjected()); |
| 23518 |
renderNode.setProjectionReceiver(true); |
| 23519 |
renderNode.setClipToBounds(false); |
| 23520 |
return renderNode; |
| 23521 |
} |
| 23522 |
|
| 23523 |
|
| 23524 |
|
| 23525 |
|
| 23526 |
|
| 23527 |
|
| 23528 |
|
| 23529 |
|
| 23530 |
|
| 23531 |
|
| 23532 |
|
| 23533 |
|
| 23534 |
|
| 23535 |
|
| 23536 |
|
| 23537 |
public ViewOverlay getOverlay() { |
| 23538 |
if (mOverlay == null) { |
| 23539 |
mOverlay = new ViewOverlay(mContext, this); |
| 23540 |
} |
| 23541 |
return mOverlay; |
| 23542 |
} |
| 23543 |
|
| 23544 |
|
| 23545 |
|
| 23546 |
|
| 23547 |
|
| 23548 |
|
| 23549 |
|
| 23550 |
|
| 23551 |
|
| 23552 |
|
| 23553 |
|
| 23554 |
|
| 23555 |
@ViewDebug.ExportedProperty(category = "drawing") |
| 23556 |
@InspectableProperty |
| 23557 |
@ColorInt |
| 23558 |
public int getSolidColor() { |
| 23559 |
return 0; |
| 23560 |
} |
| 23561 |
|
| 23562 |
|
| 23563 |
|
| 23564 |
|
| 23565 |
|
| 23566 |
|
| 23567 |
|
| 23568 |
private static String printFlags(int flags) { |
| 23569 |
String output = ""; |
| 23570 |
int numFlags = 0; |
| 23571 |
if ((flags & FOCUSABLE) == FOCUSABLE) { |
| 23572 |
output += "TAKES_FOCUS"; |
| 23573 |
numFlags++; |
| 23574 |
} |
| 23575 |
|
| 23576 |
switch (flags & VISIBILITY_MASK) { |
| 23577 |
case INVISIBLE: |
| 23578 |
if (numFlags > 0) { |
| 23579 |
output += " "; |
| 23580 |
} |
| 23581 |
output += "INVISIBLE"; |
| 23582 |
|
| 23583 |
break; |
| 23584 |
case GONE: |
| 23585 |
if (numFlags > 0) { |
| 23586 |
output += " "; |
| 23587 |
} |
| 23588 |
output += "GONE"; |
| 23589 |
|
| 23590 |
break; |
| 23591 |
default: |
| 23592 |
break; |
| 23593 |
} |
| 23594 |
return output; |
| 23595 |
} |
| 23596 |
|
| 23597 |
|
| 23598 |
|
| 23599 |
|
| 23600 |
|
| 23601 |
|
| 23602 |
|
| 23603 |
|
| 23604 |
private static String printPrivateFlags(int privateFlags) { |
| 23605 |
String output = ""; |
| 23606 |
int numFlags = 0; |
| 23607 |
|
| 23608 |
if ((privateFlags & PFLAG_WANTS_FOCUS) == PFLAG_WANTS_FOCUS) { |
| 23609 |
output += "WANTS_FOCUS"; |
| 23610 |
numFlags++; |
| 23611 |
} |
| 23612 |
|
| 23613 |
if ((privateFlags & PFLAG_FOCUSED) == PFLAG_FOCUSED) { |
| 23614 |
if (numFlags > 0) { |
| 23615 |
output += " "; |
| 23616 |
} |
| 23617 |
output += "FOCUSED"; |
| 23618 |
numFlags++; |
| 23619 |
} |
| 23620 |
|
| 23621 |
if ((privateFlags & PFLAG_SELECTED) == PFLAG_SELECTED) { |
| 23622 |
if (numFlags > 0) { |
| 23623 |
output += " "; |
| 23624 |
} |
| 23625 |
output += "SELECTED"; |
| 23626 |
numFlags++; |
| 23627 |
} |
| 23628 |
|
| 23629 |
if ((privateFlags & PFLAG_IS_ROOT_NAMESPACE) == PFLAG_IS_ROOT_NAMESPACE) { |
| 23630 |
if (numFlags > 0) { |
| 23631 |
output += " "; |
| 23632 |
} |
| 23633 |
output += "IS_ROOT_NAMESPACE"; |
| 23634 |
numFlags++; |
| 23635 |
} |
| 23636 |
|
| 23637 |
if ((privateFlags & PFLAG_HAS_BOUNDS) == PFLAG_HAS_BOUNDS) { |
| 23638 |
if (numFlags > 0) { |
| 23639 |
output += " "; |
| 23640 |
} |
| 23641 |
output += "HAS_BOUNDS"; |
| 23642 |
numFlags++; |
| 23643 |
} |
| 23644 |
|
| 23645 |
if ((privateFlags & PFLAG_DRAWN) == PFLAG_DRAWN) { |
| 23646 |
if (numFlags > 0) { |
| 23647 |
output += " "; |
| 23648 |
} |
| 23649 |
output += "DRAWN"; |
| 23650 |
|
| 23651 |
} |
| 23652 |
return output; |
| 23653 |
} |
| 23654 |
|
| 23655 |
|
| 23656 |
|
| 23657 |
|
| 23658 |
|
| 23659 |
|
| 23660 |
|
| 23661 |
public boolean isLayoutRequested() { |
| 23662 |
return (mPrivateFlags & PFLAG_FORCE_LAYOUT) == PFLAG_FORCE_LAYOUT; |
| 23663 |
} |
| 23664 |
|
| 23665 |
|
| 23666 |
|
| 23667 |
|
| 23668 |
|
| 23669 |
public static boolean isLayoutModeOptical(Object o) { |
| 23670 |
return o instanceof ViewGroup && ((ViewGroup) o).isLayoutModeOptical(); |
| 23671 |
} |
| 23672 |
|
| 23673 |
private boolean setOpticalFrame(int left, int top, int right, int bottom) { |
| 23674 |
Insets parentInsets = mParent instanceof View ? |
| 23675 |
((View) mParent).getOpticalInsets() : Insets.NONE; |
| 23676 |
Insets childInsets = getOpticalInsets(); |
| 23677 |
return setFrame( |
| 23678 |
left + parentInsets.left - childInsets.left, |
| 23679 |
top + parentInsets.top - childInsets.top, |
| 23680 |
right + parentInsets.left + childInsets.right, |
| 23681 |
bottom + parentInsets.top + childInsets.bottom); |
| 23682 |
} |
| 23683 |
|
| 23684 |
|
| 23685 |
|
| 23686 |
|
| 23687 |
|
| 23688 |
|
| 23689 |
|
| 23690 |
|
| 23691 |
|
| 23692 |
|
| 23693 |
|
| 23694 |
|
| 23695 |
|
| 23696 |
|
| 23697 |
|
| 23698 |
|
| 23699 |
|
| 23700 |
|
| 23701 |
|
| 23702 |
|
| 23703 |
|
| 23704 |
@SuppressWarnings({"unchecked"}) |
| 23705 |
public void layout(int l, int t, int r, int b) { |
| 23706 |
if ((mPrivateFlags3 & PFLAG3_MEASURE_NEEDED_BEFORE_LAYOUT) != 0) { |
| 23707 |
onMeasure(mOldWidthMeasureSpec, mOldHeightMeasureSpec); |
| 23708 |
mPrivateFlags3 &= ~PFLAG3_MEASURE_NEEDED_BEFORE_LAYOUT; |
| 23709 |
} |
| 23710 |
|
| 23711 |
int oldL = mLeft; |
| 23712 |
int oldT = mTop; |
| 23713 |
int oldB = mBottom; |
| 23714 |
int oldR = mRight; |
| 23715 |
|
| 23716 |
boolean changed = isLayoutModeOptical(mParent) ? |
| 23717 |
setOpticalFrame(l, t, r, b) : setFrame(l, t, r, b); |
| 23718 |
|
| 23719 |
if (changed || (mPrivateFlags & PFLAG_LAYOUT_REQUIRED) == PFLAG_LAYOUT_REQUIRED) { |
| 23720 |
onLayout(changed, l, t, r, b); |
| 23721 |
|
| 23722 |
if (shouldDrawRoundScrollbar()) { |
| 23723 |
if(mRoundScrollbarRenderer == null) { |
| 23724 |
mRoundScrollbarRenderer = new RoundScrollbarRenderer(this); |
| 23725 |
} |
| 23726 |
} else { |
| 23727 |
mRoundScrollbarRenderer = null; |
| 23728 |
} |
| 23729 |
|
| 23730 |
mPrivateFlags &= ~PFLAG_LAYOUT_REQUIRED; |
| 23731 |
|
| 23732 |
ListenerInfo li = mListenerInfo; |
| 23733 |
if (li != null && li.mOnLayoutChangeListeners != null) { |
| 23734 |
ArrayList<OnLayoutChangeListener> listenersCopy = |
| 23735 |
(ArrayList<OnLayoutChangeListener>)li.mOnLayoutChangeListeners.clone(); |
| 23736 |
int numListeners = listenersCopy.size(); |
| 23737 |
for (int i = 0; i < numListeners; ++i) { |
| 23738 |
listenersCopy.get(i).onLayoutChange(this, l, t, r, b, oldL, oldT, oldR, oldB); |
| 23739 |
} |
| 23740 |
} |
| 23741 |
} |
| 23742 |
|
| 23743 |
final boolean wasLayoutValid = isLayoutValid(); |
| 23744 |
|
| 23745 |
mPrivateFlags &= ~PFLAG_FORCE_LAYOUT; |
| 23746 |
mPrivateFlags3 |= PFLAG3_IS_LAID_OUT; |
| 23747 |
|
| 23748 |
if (!wasLayoutValid && isFocused()) { |
| 23749 |
mPrivateFlags &= ~PFLAG_WANTS_FOCUS; |
| 23750 |
if (canTakeFocus()) { |
| 23751 |
|
| 23752 |
clearParentsWantFocus(); |
| 23753 |
} else if (getViewRootImpl() == null || !getViewRootImpl().isInLayout()) { |
| 23754 |
|
| 23755 |
|
| 23756 |
|
| 23757 |
clearFocusInternal(null, true, false); |
| 23758 |
clearParentsWantFocus(); |
| 23759 |
} else if (!hasParentWantsFocus()) { |
| 23760 |
|
| 23761 |
clearFocusInternal(null, true, false); |
| 23762 |
} |
| 23763 |
|
| 23764 |
} else if ((mPrivateFlags & PFLAG_WANTS_FOCUS) != 0) { |
| 23765 |
mPrivateFlags &= ~PFLAG_WANTS_FOCUS; |
| 23766 |
View focused = findFocus(); |
| 23767 |
if (focused != null) { |
| 23768 |
|
| 23769 |
if (!restoreDefaultFocus() && !hasParentWantsFocus()) { |
| 23770 |
|
| 23771 |
|
| 23772 |
focused.clearFocusInternal(null, true, false); |
| 23773 |
} |
| 23774 |
} |
| 23775 |
} |
| 23776 |
|
| 23777 |
if ((mPrivateFlags3 & PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT) != 0) { |
| 23778 |
mPrivateFlags3 &= ~PFLAG3_NOTIFY_AUTOFILL_ENTER_ON_LAYOUT; |
| 23779 |
notifyEnterOrExitForAutoFillIfNeeded(true); |
| 23780 |
} |
| 23781 |
|
| 23782 |
notifyAppearedOrDisappearedForContentCaptureIfNeeded(true); |
| 23783 |
} |
| 23784 |
|
| 23785 |
private boolean hasParentWantsFocus() { |
| 23786 |
ViewParent parent = mParent; |
| 23787 |
while (parent instanceof ViewGroup) { |
| 23788 |
ViewGroup pv = (ViewGroup) parent; |
| 23789 |
if ((pv.mPrivateFlags & PFLAG_WANTS_FOCUS) != 0) { |
| 23790 |
return true; |
| 23791 |
} |
| 23792 |
parent = pv.mParent; |
| 23793 |
} |
| 23794 |
return false; |
| 23795 |
} |
| 23796 |
|
| 23797 |
|
| 23798 |
|
| 23799 |
|
| 23800 |
|
| 23801 |
|
| 23802 |
|
| 23803 |
|
| 23804 |
|
| 23805 |
|
| 23806 |
|
| 23807 |
|
| 23808 |
|
| 23809 |
|
| 23810 |
protected void onLayout(boolean changed, int left, int top, int right, int bottom) { |
| 23811 |
} |
| 23812 |
|
| 23813 |
|
| 23814 |
|
| 23815 |
|
| 23816 |
|
| 23817 |
|
| 23818 |
|
| 23819 |
|
| 23820 |
|
| 23821 |
|
| 23822 |
|
| 23823 |
|
| 23824 |
|
| 23825 |
|
| 23826 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P) |
| 23827 |
protected boolean setFrame(int left, int top, int right, int bottom) { |
| 23828 |
boolean changed = false; |
| 23829 |
|
| 23830 |
if (DBG) { |
| 23831 |
Log.d(VIEW_LOG_TAG, this + " View.setFrame(" + left + "," + top + "," |
| 23832 |
+ right + "," + bottom + ")"); |
| 23833 |
} |
| 23834 |
|
| 23835 |
if (mLeft != left || mRight != right || mTop != top || mBottom != bottom) { |
| 23836 |
changed = true; |
| 23837 |
|
| 23838 |
|
| 23839 |
int drawn = mPrivateFlags & PFLAG_DRAWN; |
| 23840 |
|
| 23841 |
int oldWidth = mRight - mLeft; |
| 23842 |
int oldHeight = mBottom - mTop; |
| 23843 |
int newWidth = right - left; |
| 23844 |
int newHeight = bottom - top; |
| 23845 |
boolean sizeChanged = (newWidth != oldWidth) || (newHeight != oldHeight); |
| 23846 |
|
| 23847 |
|
| 23848 |
invalidate(sizeChanged); |
| 23849 |
|
| 23850 |
mLeft = left; |
| 23851 |
mTop = top; |
| 23852 |
mRight = right; |
| 23853 |
mBottom = bottom; |
| 23854 |
mRenderNode.setLeftTopRightBottom(mLeft, mTop, mRight, mBottom); |
| 23855 |
|
| 23856 |
mPrivateFlags |= PFLAG_HAS_BOUNDS; |
| 23857 |
|
| 23858 |
|
| 23859 |
if (sizeChanged) { |
| 23860 |
sizeChange(newWidth, newHeight, oldWidth, oldHeight); |
| 23861 |
} |
| 23862 |
|
| 23863 |
if ((mViewFlags & VISIBILITY_MASK) == VISIBLE || mGhostView != null) { |
| 23864 |
|
| 23865 |
|
| 23866 |
|
| 23867 |
|
| 23868 |
|
| 23869 |
mPrivateFlags |= PFLAG_DRAWN; |
| 23870 |
invalidate(sizeChanged); |
| 23871 |
|
| 23872 |
|
| 23873 |
invalidateParentCaches(); |
| 23874 |
} |
| 23875 |
|
| 23876 |
|
| 23877 |
mPrivateFlags |= drawn; |
| 23878 |
|
| 23879 |
mBackgroundSizeChanged = true; |
| 23880 |
mDefaultFocusHighlightSizeChanged = true; |
| 23881 |
if (mForegroundInfo != null) { |
| 23882 |
mForegroundInfo.mBoundsChanged = true; |
| 23883 |
} |
| 23884 |
|
| 23885 |
notifySubtreeAccessibilityStateChangedIfNeeded(); |
| 23886 |
} |
| 23887 |
return changed; |
| 23888 |
} |
| 23889 |
|
| 23890 |
|
| 23891 |
|
| 23892 |
|
| 23893 |
|
| 23894 |
|
| 23895 |
|
| 23896 |
|
| 23897 |
|
| 23898 |
|
| 23899 |
|
| 23900 |
|
| 23901 |
|
| 23902 |
|
| 23903 |
public final void setLeftTopRightBottom(int left, int top, int right, int bottom) { |
| 23904 |
setFrame(left, top, right, bottom); |
| 23905 |
} |
| 23906 |
|
| 23907 |
private void sizeChange(int newWidth, int newHeight, int oldWidth, int oldHeight) { |
| 23908 |
onSizeChanged(newWidth, newHeight, oldWidth, oldHeight); |
| 23909 |
if (mOverlay != null) { |
| 23910 |
mOverlay.getOverlayView().setRight(newWidth); |
| 23911 |
mOverlay.getOverlayView().setBottom(newHeight); |
| 23912 |
} |
| 23913 |
|
| 23914 |
|
| 23915 |
if (!sCanFocusZeroSized && isLayoutValid() |
| 23916 |
|
| 23917 |
&& !(mParent instanceof ViewGroup && ((ViewGroup) mParent).isLayoutSuppressed())) { |
| 23918 |
if (newWidth <= 0 || newHeight <= 0) { |
| 23919 |
if (hasFocus()) { |
| 23920 |
clearFocus(); |
| 23921 |
if (mParent instanceof ViewGroup) { |
| 23922 |
((ViewGroup) mParent).clearFocusedInCluster(); |
| 23923 |
} |
| 23924 |
} |
| 23925 |
clearAccessibilityFocus(); |
| 23926 |
} else if (oldWidth <= 0 || oldHeight <= 0) { |
| 23927 |
if (mParent != null && canTakeFocus()) { |
| 23928 |
mParent.focusableViewAvailable(this); |
| 23929 |
} |
| 23930 |
} |
| 23931 |
} |
| 23932 |
rebuildOutline(); |
| 23933 |
} |
| 23934 |
|
| 23935 |
|
| 23936 |
|
| 23937 |
|
| 23938 |
|
| 23939 |
|
| 23940 |
|
| 23941 |
|
| 23942 |
@CallSuper |
| 23943 |
protected void onFinishInflate() { |
| 23944 |
} |
| 23945 |
|
| 23946 |
|
| 23947 |
|
| 23948 |
|
| 23949 |
|
| 23950 |
|
| 23951 |
public Resources getResources() { |
| 23952 |
return mResources; |
| 23953 |
} |
| 23954 |
|
| 23955 |
|
| 23956 |
|
| 23957 |
|
| 23958 |
|
| 23959 |
|
| 23960 |
@Override |
| 23961 |
public void invalidateDrawable(@NonNull Drawable drawable) { |
| 23962 |
if (verifyDrawable(drawable)) { |
| 23963 |
final Rect dirty = drawable.getDirtyBounds(); |
| 23964 |
final int scrollX = mScrollX; |
| 23965 |
final int scrollY = mScrollY; |
| 23966 |
|
| 23967 |
invalidate(dirty.left + scrollX, dirty.top + scrollY, |
| 23968 |
dirty.right + scrollX, dirty.bottom + scrollY); |
| 23969 |
rebuildOutline(); |
| 23970 |
} |
| 23971 |
} |
| 23972 |
|
| 23973 |
|
| 23974 |
|
| 23975 |
|
| 23976 |
|
| 23977 |
|
| 23978 |
|
| 23979 |
|
| 23980 |
|
| 23981 |
@Override |
| 23982 |
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) { |
| 23983 |
if (verifyDrawable(who) && what != null) { |
| 23984 |
final long delay = when - SystemClock.uptimeMillis(); |
| 23985 |
if (mAttachInfo != null) { |
| 23986 |
mAttachInfo.mViewRootImpl.mChoreographer.postCallbackDelayed( |
| 23987 |
Choreographer.CALLBACK_ANIMATION, what, who, |
| 23988 |
Choreographer.subtractFrameDelay(delay)); |
| 23989 |
} else { |
| 23990 |
|
| 23991 |
|
| 23992 |
getRunQueue().postDelayed(what, delay); |
| 23993 |
} |
| 23994 |
} |
| 23995 |
} |
| 23996 |
|
| 23997 |
|
| 23998 |
|
| 23999 |
|
| 24000 |
|
| 24001 |
|
| 24002 |
|
| 24003 |
@Override |
| 24004 |
public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) { |
| 24005 |
if (verifyDrawable(who) && what != null) { |
| 24006 |
if (mAttachInfo != null) { |
| 24007 |
mAttachInfo.mViewRootImpl.mChoreographer.removeCallbacks( |
| 24008 |
Choreographer.CALLBACK_ANIMATION, what, who); |
| 24009 |
} |
| 24010 |
getRunQueue().removeCallbacks(what); |
| 24011 |
} |
| 24012 |
} |
| 24013 |
|
| 24014 |
|
| 24015 |
|
| 24016 |
|
| 24017 |
|
| 24018 |
|
| 24019 |
|
| 24020 |
|
| 24021 |
|
| 24022 |
|
| 24023 |
public void unscheduleDrawable(Drawable who) { |
| 24024 |
if (mAttachInfo != null && who != null) { |
| 24025 |
mAttachInfo.mViewRootImpl.mChoreographer.removeCallbacks( |
| 24026 |
Choreographer.CALLBACK_ANIMATION, null, who); |
| 24027 |
} |
| 24028 |
} |
| 24029 |
|
| 24030 |
|
| 24031 |
|
| 24032 |
|
| 24033 |
|
| 24034 |
|
| 24035 |
|
| 24036 |
|
| 24037 |
|
| 24038 |
protected void resolveDrawables() { |
| 24039 |
|
| 24040 |
|
| 24041 |
|
| 24042 |
|
| 24043 |
|
| 24044 |
|
| 24045 |
|
| 24046 |
if (!isLayoutDirectionResolved() && |
| 24047 |
getRawLayoutDirection() == View.LAYOUT_DIRECTION_INHERIT) { |
| 24048 |
return; |
| 24049 |
} |
| 24050 |
|
| 24051 |
final int layoutDirection = isLayoutDirectionResolved() ? |
| 24052 |
getLayoutDirection() : getRawLayoutDirection(); |
| 24053 |
|
| 24054 |
if (mBackground != null) { |
| 24055 |
mBackground.setLayoutDirection(layoutDirection); |
| 24056 |
} |
| 24057 |
if (mForegroundInfo != null && mForegroundInfo.mDrawable != null) { |
| 24058 |
mForegroundInfo.mDrawable.setLayoutDirection(layoutDirection); |
| 24059 |
} |
| 24060 |
if (mDefaultFocusHighlight != null) { |
| 24061 |
mDefaultFocusHighlight.setLayoutDirection(layoutDirection); |
| 24062 |
} |
| 24063 |
mPrivateFlags2 |= PFLAG2_DRAWABLE_RESOLVED; |
| 24064 |
onResolveDrawables(layoutDirection); |
| 24065 |
} |
| 24066 |
|
| 24067 |
boolean areDrawablesResolved() { |
| 24068 |
return (mPrivateFlags2 & PFLAG2_DRAWABLE_RESOLVED) == PFLAG2_DRAWABLE_RESOLVED; |
| 24069 |
} |
| 24070 |
|
| 24071 |
|
| 24072 |
|
| 24073 |
|
| 24074 |
|
| 24075 |
|
| 24076 |
|
| 24077 |
|
| 24078 |
|
| 24079 |
|
| 24080 |
|
| 24081 |
|
| 24082 |
|
| 24083 |
public void onResolveDrawables(@ResolvedLayoutDir int layoutDirection) { |
| 24084 |
} |
| 24085 |
|
| 24086 |
|
| 24087 |
|
| 24088 |
|
| 24089 |
@TestApi |
| 24090 |
protected void resetResolvedDrawables() { |
| 24091 |
resetResolvedDrawablesInternal(); |
| 24092 |
} |
| 24093 |
|
| 24094 |
void resetResolvedDrawablesInternal() { |
| 24095 |
mPrivateFlags2 &= ~PFLAG2_DRAWABLE_RESOLVED; |
| 24096 |
} |
| 24097 |
|
| 24098 |
|
| 24099 |
|
| 24100 |
|
| 24101 |
|
| 24102 |
|
| 24103 |
|
| 24104 |
|
| 24105 |
|
| 24106 |
|
| 24107 |
|
| 24108 |
|
| 24109 |
|
| 24110 |
|
| 24111 |
|
| 24112 |
|
| 24113 |
|
| 24114 |
|
| 24115 |
|
| 24116 |
|
| 24117 |
@CallSuper |
| 24118 |
protected boolean verifyDrawable(@NonNull Drawable who) { |
| 24119 |
|
| 24120 |
|
| 24121 |
|
| 24122 |
return who == mBackground || (mForegroundInfo != null && mForegroundInfo.mDrawable == who) |
| 24123 |
|| (mDefaultFocusHighlight == who); |
| 24124 |
} |
| 24125 |
|
| 24126 |
|
| 24127 |
|
| 24128 |
|
| 24129 |
|
| 24130 |
|
| 24131 |
|
| 24132 |
|
| 24133 |
|
| 24134 |
|
| 24135 |
|
| 24136 |
|
| 24137 |
@CallSuper |
| 24138 |
protected void drawableStateChanged() { |
| 24139 |
final int[] state = getDrawableState(); |
| 24140 |
boolean changed = false; |
| 24141 |
|
| 24142 |
final Drawable bg = mBackground; |
| 24143 |
if (bg != null && bg.isStateful()) { |
| 24144 |
changed |= bg.setState(state); |
| 24145 |
} |
| 24146 |
|
| 24147 |
final Drawable hl = mDefaultFocusHighlight; |
| 24148 |
if (hl != null && hl.isStateful()) { |
| 24149 |
changed |= hl.setState(state); |
| 24150 |
} |
| 24151 |
|
| 24152 |
final Drawable fg = mForegroundInfo != null ? mForegroundInfo.mDrawable : null; |
| 24153 |
if (fg != null && fg.isStateful()) { |
| 24154 |
changed |= fg.setState(state); |
| 24155 |
} |
| 24156 |
|
| 24157 |
if (mScrollCache != null) { |
| 24158 |
final Drawable scrollBar = mScrollCache.scrollBar; |
| 24159 |
if (scrollBar != null && scrollBar.isStateful()) { |
| 24160 |
changed |= scrollBar.setState(state) |
| 24161 |
&& mScrollCache.state != ScrollabilityCache.OFF; |
| 24162 |
} |
| 24163 |
} |
| 24164 |
|
| 24165 |
if (mStateListAnimator != null) { |
| 24166 |
mStateListAnimator.setState(state); |
| 24167 |
} |
| 24168 |
|
| 24169 |
if (!isAggregatedVisible()) { |
| 24170 |
|
| 24171 |
jumpDrawablesToCurrentState(); |
| 24172 |
} |
| 24173 |
|
| 24174 |
if (changed) { |
| 24175 |
invalidate(); |
| 24176 |
} |
| 24177 |
} |
| 24178 |
|
| 24179 |
|
| 24180 |
|
| 24181 |
|
| 24182 |
|
| 24183 |
|
| 24184 |
|
| 24185 |
|
| 24186 |
|
| 24187 |
|
| 24188 |
|
| 24189 |
|
| 24190 |
|
| 24191 |
@CallSuper |
| 24192 |
public void drawableHotspotChanged(float x, float y) { |
| 24193 |
if (mBackground != null) { |
| 24194 |
mBackground.setHotspot(x, y); |
| 24195 |
} |
| 24196 |
if (mDefaultFocusHighlight != null) { |
| 24197 |
mDefaultFocusHighlight.setHotspot(x, y); |
| 24198 |
} |
| 24199 |
if (mForegroundInfo != null && mForegroundInfo.mDrawable != null) { |
| 24200 |
mForegroundInfo.mDrawable.setHotspot(x, y); |
| 24201 |
} |
| 24202 |
|
| 24203 |
dispatchDrawableHotspotChanged(x, y); |
| 24204 |
} |
| 24205 |
|
| 24206 |
|
| 24207 |
|
| 24208 |
|
| 24209 |
|
| 24210 |
|
| 24211 |
|
| 24212 |
|
| 24213 |
public void dispatchDrawableHotspotChanged(float x, float y) { |
| 24214 |
} |
| 24215 |
|
| 24216 |
|
| 24217 |
|
| 24218 |
|
| 24219 |
|
| 24220 |
|
| 24221 |
|
| 24222 |
|
| 24223 |
|
| 24224 |
public void refreshDrawableState() { |
| 24225 |
mPrivateFlags |= PFLAG_DRAWABLE_STATE_DIRTY; |
| 24226 |
drawableStateChanged(); |
| 24227 |
|
| 24228 |
ViewParent parent = mParent; |
| 24229 |
if (parent != null) { |
| 24230 |
parent.childDrawableStateChanged(this); |
| 24231 |
} |
| 24232 |
} |
| 24233 |
|
| 24234 |
|
| 24235 |
|
| 24236 |
|
| 24237 |
|
| 24238 |
private Drawable getDefaultFocusHighlightDrawable() { |
| 24239 |
if (mDefaultFocusHighlightCache == null) { |
| 24240 |
if (mContext != null) { |
| 24241 |
final int[] attrs = new int[] { android.R.attr.selectableItemBackground }; |
| 24242 |
final TypedArray ta = mContext.obtainStyledAttributes(attrs); |
| 24243 |
mDefaultFocusHighlightCache = ta.getDrawable(0); |
| 24244 |
ta.recycle(); |
| 24245 |
} |
| 24246 |
} |
| 24247 |
return mDefaultFocusHighlightCache; |
| 24248 |
} |
| 24249 |
|
| 24250 |
|
| 24251 |
|
| 24252 |
|
| 24253 |
|
| 24254 |
private void setDefaultFocusHighlight(Drawable highlight) { |
| 24255 |
mDefaultFocusHighlight = highlight; |
| 24256 |
mDefaultFocusHighlightSizeChanged = true; |
| 24257 |
if (highlight != null) { |
| 24258 |
if ((mPrivateFlags & PFLAG_SKIP_DRAW) != 0) { |
| 24259 |
mPrivateFlags &= ~PFLAG_SKIP_DRAW; |
| 24260 |
} |
| 24261 |
highlight.setLayoutDirection(getLayoutDirection()); |
| 24262 |
if (highlight.isStateful()) { |
| 24263 |
highlight.setState(getDrawableState()); |
| 24264 |
} |
| 24265 |
if (isAttachedToWindow()) { |
| 24266 |
highlight.setVisible(getWindowVisibility() == VISIBLE && isShown(), false); |
| 24267 |
} |
| 24268 |
|
| 24269 |
highlight.setCallback(this); |
| 24270 |
} else if ((mViewFlags & WILL_NOT_DRAW) != 0 && mBackground == null |
| 24271 |
&& (mForegroundInfo == null || mForegroundInfo.mDrawable == null)) { |
| 24272 |
mPrivateFlags |= PFLAG_SKIP_DRAW; |
| 24273 |
} |
| 24274 |
invalidate(); |
| 24275 |
} |
| 24276 |
|
| 24277 |
|
| 24278 |
|
| 24279 |
|
| 24280 |
|
| 24281 |
|
| 24282 |
|
| 24283 |
|
| 24284 |
|
| 24285 |
|
| 24286 |
|
| 24287 |
|
| 24288 |
|
| 24289 |
|
| 24290 |
|
| 24291 |
@TestApi |
| 24292 |
public boolean isDefaultFocusHighlightNeeded(Drawable background, Drawable foreground) { |
| 24293 |
final boolean lackFocusState = (background == null || !background.isStateful() |
| 24294 |
|| !background.hasFocusStateSpecified()) |
| 24295 |
&& (foreground == null || !foreground.isStateful() |
| 24296 |
|| !foreground.hasFocusStateSpecified()); |
| 24297 |
return !isInTouchMode() && getDefaultFocusHighlightEnabled() && lackFocusState |
| 24298 |
&& isAttachedToWindow() && sUseDefaultFocusHighlight; |
| 24299 |
} |
| 24300 |
|
| 24301 |
|
| 24302 |
|
| 24303 |
|
| 24304 |
|
| 24305 |
|
| 24306 |
|
| 24307 |
private void switchDefaultFocusHighlight() { |
| 24308 |
if (isFocused()) { |
| 24309 |
final boolean needed = isDefaultFocusHighlightNeeded(mBackground, |
| 24310 |
mForegroundInfo == null ? null : mForegroundInfo.mDrawable); |
| 24311 |
final boolean active = mDefaultFocusHighlight != null; |
| 24312 |
if (needed && !active) { |
| 24313 |
setDefaultFocusHighlight(getDefaultFocusHighlightDrawable()); |
| 24314 |
} else if (!needed && active) { |
| 24315 |
|
| 24316 |
setDefaultFocusHighlight(null); |
| 24317 |
} |
| 24318 |
} |
| 24319 |
} |
| 24320 |
|
| 24321 |
|
| 24322 |
|
| 24323 |
|
| 24324 |
|
| 24325 |
private void drawDefaultFocusHighlight(Canvas canvas) { |
| 24326 |
if (mDefaultFocusHighlight != null && isFocused()) { |
| 24327 |
if (mDefaultFocusHighlightSizeChanged) { |
| 24328 |
mDefaultFocusHighlightSizeChanged = false; |
| 24329 |
final int l = mScrollX; |
| 24330 |
final int r = l + mRight - mLeft; |
| 24331 |
final int t = mScrollY; |
| 24332 |
final int b = t + mBottom - mTop; |
| 24333 |
mDefaultFocusHighlight.setBounds(l, t, r, b); |
| 24334 |
} |
| 24335 |
mDefaultFocusHighlight.draw(canvas); |
| 24336 |
} |
| 24337 |
} |
| 24338 |
|
| 24339 |
|
| 24340 |
|
| 24341 |
|
| 24342 |
|
| 24343 |
|
| 24344 |
|
| 24345 |
|
| 24346 |
|
| 24347 |
|
| 24348 |
|
| 24349 |
public final int[] getDrawableState() { |
| 24350 |
if ((mDrawableState != null) && ((mPrivateFlags & PFLAG_DRAWABLE_STATE_DIRTY) == 0)) { |
| 24351 |
return mDrawableState; |
| 24352 |
} else { |
| 24353 |
mDrawableState = onCreateDrawableState(0); |
| 24354 |
mPrivateFlags &= ~PFLAG_DRAWABLE_STATE_DIRTY; |
| 24355 |
return mDrawableState; |
| 24356 |
} |
| 24357 |
} |
| 24358 |
|
| 24359 |
|
| 24360 |
|
| 24361 |
|
| 24362 |
|
| 24363 |
|
| 24364 |
|
| 24365 |
|
| 24366 |
|
| 24367 |
|
| 24368 |
|
| 24369 |
|
| 24370 |
|
| 24371 |
|
| 24372 |
|
| 24373 |
|
| 24374 |
protected int[] onCreateDrawableState(int extraSpace) { |
| 24375 |
if ((mViewFlags & DUPLICATE_PARENT_STATE) == DUPLICATE_PARENT_STATE && |
| 24376 |
mParent instanceof View) { |
| 24377 |
return ((View) mParent).onCreateDrawableState(extraSpace); |
| 24378 |
} |
| 24379 |
|
| 24380 |
int[] drawableState; |
| 24381 |
|
| 24382 |
int privateFlags = mPrivateFlags; |
| 24383 |
|
| 24384 |
int viewStateIndex = 0; |
| 24385 |
if ((privateFlags & PFLAG_PRESSED) != 0) viewStateIndex |= StateSet.VIEW_STATE_PRESSED; |
| 24386 |
if ((mViewFlags & ENABLED_MASK) == ENABLED) viewStateIndex |= StateSet.VIEW_STATE_ENABLED; |
| 24387 |
if (isFocused()) viewStateIndex |= StateSet.VIEW_STATE_FOCUSED; |
| 24388 |
if ((privateFlags & PFLAG_SELECTED) != 0) viewStateIndex |= StateSet.VIEW_STATE_SELECTED; |
| 24389 |
if (hasWindowFocus()) viewStateIndex |= StateSet.VIEW_STATE_WINDOW_FOCUSED; |
| 24390 |
if ((privateFlags & PFLAG_ACTIVATED) != 0) viewStateIndex |= StateSet.VIEW_STATE_ACTIVATED; |
| 24391 |
if (mAttachInfo != null && mAttachInfo.mHardwareAccelerationRequested) { |
| 24392 |
|
| 24393 |
|
| 24394 |
|
| 24395 |
viewStateIndex |= StateSet.VIEW_STATE_ACCELERATED; |
| 24396 |
} |
| 24397 |
if ((privateFlags & PFLAG_HOVERED) != 0) viewStateIndex |= StateSet.VIEW_STATE_HOVERED; |
| 24398 |
|
| 24399 |
final int privateFlags2 = mPrivateFlags2; |
| 24400 |
if ((privateFlags2 & PFLAG2_DRAG_CAN_ACCEPT) != 0) { |
| 24401 |
viewStateIndex |= StateSet.VIEW_STATE_DRAG_CAN_ACCEPT; |
| 24402 |
} |
| 24403 |
if ((privateFlags2 & PFLAG2_DRAG_HOVERED) != 0) { |
| 24404 |
viewStateIndex |= StateSet.VIEW_STATE_DRAG_HOVERED; |
| 24405 |
} |
| 24406 |
|
| 24407 |
drawableState = StateSet.get(viewStateIndex); |
| 24408 |
|
| 24409 |
|
| 24410 |
if (false) { |
| 24411 |
Log.i("View", "drawableStateIndex=" + viewStateIndex); |
| 24412 |
Log.i("View", toString() |
| 24413 |
+ " pressed=" + ((privateFlags & PFLAG_PRESSED) != 0) |
| 24414 |
+ " en=" + ((mViewFlags & ENABLED_MASK) == ENABLED) |
| 24415 |
+ " fo=" + hasFocus() |
| 24416 |
+ " sl=" + ((privateFlags & PFLAG_SELECTED) != 0) |
| 24417 |
+ " wf=" + hasWindowFocus() |
| 24418 |
+ ": " + Arrays.toString(drawableState)); |
| 24419 |
} |
| 24420 |
|
| 24421 |
if (extraSpace == 0) { |
| 24422 |
return drawableState; |
| 24423 |
} |
| 24424 |
|
| 24425 |
final int[] fullState; |
| 24426 |
if (drawableState != null) { |
| 24427 |
fullState = new int[drawableState.length + extraSpace]; |
| 24428 |
System.arraycopy(drawableState, 0, fullState, 0, drawableState.length); |
| 24429 |
} else { |
| 24430 |
fullState = new int[extraSpace]; |
| 24431 |
} |
| 24432 |
|
| 24433 |
return fullState; |
| 24434 |
} |
| 24435 |
|
| 24436 |
|
| 24437 |
|
| 24438 |
|
| 24439 |
|
| 24440 |
|
| 24441 |
|
| 24442 |
|
| 24443 |
|
| 24444 |
|
| 24445 |
|
| 24446 |
|
| 24447 |
|
| 24448 |
|
| 24449 |
|
| 24450 |
|
| 24451 |
|
| 24452 |
|
| 24453 |
protected static int[] mergeDrawableStates(int[] baseState, int[] additionalState) { |
| 24454 |
final int N = baseState.length; |
| 24455 |
int i = N - 1; |
| 24456 |
while (i >= 0 && baseState[i] == 0) { |
| 24457 |
i--; |
| 24458 |
} |
| 24459 |
System.arraycopy(additionalState, 0, baseState, i + 1, additionalState.length); |
| 24460 |
return baseState; |
| 24461 |
} |
| 24462 |
|
| 24463 |
|
| 24464 |
|
| 24465 |
|
| 24466 |
|
| 24467 |
|
| 24468 |
|
| 24469 |
|
| 24470 |
@CallSuper |
| 24471 |
public void jumpDrawablesToCurrentState() { |
| 24472 |
if (mBackground != null) { |
| 24473 |
mBackground.jumpToCurrentState(); |
| 24474 |
} |
| 24475 |
if (mStateListAnimator != null) { |
| 24476 |
mStateListAnimator.jumpToCurrentState(); |
| 24477 |
} |
| 24478 |
if (mDefaultFocusHighlight != null) { |
| 24479 |
mDefaultFocusHighlight.jumpToCurrentState(); |
| 24480 |
} |
| 24481 |
if (mForegroundInfo != null && mForegroundInfo.mDrawable != null) { |
| 24482 |
mForegroundInfo.mDrawable.jumpToCurrentState(); |
| 24483 |
} |
| 24484 |
} |
| 24485 |
|
| 24486 |
|
| 24487 |
|
| 24488 |
|
| 24489 |
|
| 24490 |
@RemotableViewMethod |
| 24491 |
public void setBackgroundColor(@ColorInt int color) { |
| 24492 |
if (mBackground instanceof ColorDrawable) { |
| 24493 |
((ColorDrawable) mBackground.mutate()).setColor(color); |
| 24494 |
computeOpaqueFlags(); |
| 24495 |
mBackgroundResource = 0; |
| 24496 |
} else { |
| 24497 |
setBackground(new ColorDrawable(color)); |
| 24498 |
} |
| 24499 |
} |
| 24500 |
|
| 24501 |
|
| 24502 |
|
| 24503 |
|
| 24504 |
|
| 24505 |
|
| 24506 |
|
| 24507 |
|
| 24508 |
@RemotableViewMethod |
| 24509 |
public void setBackgroundResource(@DrawableRes int resid) { |
| 24510 |
if (resid != 0 && resid == mBackgroundResource) { |
| 24511 |
return; |
| 24512 |
} |
| 24513 |
|
| 24514 |
Drawable d = null; |
| 24515 |
if (resid != 0) { |
| 24516 |
d = mContext.getDrawable(resid); |
| 24517 |
} |
| 24518 |
setBackground(d); |
| 24519 |
|
| 24520 |
mBackgroundResource = resid; |
| 24521 |
} |
| 24522 |
|
| 24523 |
|
| 24524 |
|
| 24525 |
|
| 24526 |
|
| 24527 |
|
| 24528 |
|
| 24529 |
|
| 24530 |
|
| 24531 |
|
| 24532 |
|
| 24533 |
public void setBackground(Drawable background) { |
| 24534 |
|
| 24535 |
setBackgroundDrawable(background); |
| 24536 |
} |
| 24537 |
|
| 24538 |
|
| 24539 |
|
| 24540 |
|
| 24541 |
@Deprecated |
| 24542 |
public void setBackgroundDrawable(Drawable background) { |
| 24543 |
computeOpaqueFlags(); |
| 24544 |
|
| 24545 |
if (background == mBackground) { |
| 24546 |
return; |
| 24547 |
} |
| 24548 |
|
| 24549 |
boolean requestLayout = false; |
| 24550 |
|
| 24551 |
mBackgroundResource = 0; |
| 24552 |
|
| 24553 |
|
| 24554 |
|
| 24555 |
|
| 24556 |
|
| 24557 |
if (mBackground != null) { |
| 24558 |
if (isAttachedToWindow()) { |
| 24559 |
mBackground.setVisible(false, false); |
| 24560 |
} |
| 24561 |
mBackground.setCallback(null); |
| 24562 |
unscheduleDrawable(mBackground); |
| 24563 |
} |
| 24564 |
|
| 24565 |
if (background != null) { |
| 24566 |
Rect padding = sThreadLocal.get(); |
| 24567 |
if (padding == null) { |
| 24568 |
padding = new Rect(); |
| 24569 |
sThreadLocal.set(padding); |
| 24570 |
} |
| 24571 |
resetResolvedDrawablesInternal(); |
| 24572 |
background.setLayoutDirection(getLayoutDirection()); |
| 24573 |
if (background.getPadding(padding)) { |
| 24574 |
resetResolvedPaddingInternal(); |
| 24575 |
switch (background.getLayoutDirection()) { |
| 24576 |
case LAYOUT_DIRECTION_RTL: |
| 24577 |
mUserPaddingLeftInitial = padding.right; |
| 24578 |
mUserPaddingRightInitial = padding.left; |
| 24579 |
internalSetPadding(padding.right, padding.top, padding.left, padding.bottom); |
| 24580 |
break; |
| 24581 |
case LAYOUT_DIRECTION_LTR: |
| 24582 |
default: |
| 24583 |
mUserPaddingLeftInitial = padding.left; |
| 24584 |
mUserPaddingRightInitial = padding.right; |
| 24585 |
internalSetPadding(padding.left, padding.top, padding.right, padding.bottom); |
| 24586 |
} |
| 24587 |
mLeftPaddingDefined = false; |
| 24588 |
mRightPaddingDefined = false; |
| 24589 |
} |
| 24590 |
|
| 24591 |
|
| 24592 |
|
| 24593 |
if (mBackground == null |
| 24594 |
|| mBackground.getMinimumHeight() != background.getMinimumHeight() |
| 24595 |
|| mBackground.getMinimumWidth() != background.getMinimumWidth()) { |
| 24596 |
requestLayout = true; |
| 24597 |
} |
| 24598 |
|
| 24599 |
|
| 24600 |
|
| 24601 |
|
| 24602 |
|
| 24603 |
|
| 24604 |
mBackground = background; |
| 24605 |
if (background.isStateful()) { |
| 24606 |
background.setState(getDrawableState()); |
| 24607 |
} |
| 24608 |
if (isAttachedToWindow()) { |
| 24609 |
background.setVisible(getWindowVisibility() == VISIBLE && isShown(), false); |
| 24610 |
} |
| 24611 |
|
| 24612 |
applyBackgroundTint(); |
| 24613 |
|
| 24614 |
|
| 24615 |
background.setCallback(this); |
| 24616 |
|
| 24617 |
if ((mPrivateFlags & PFLAG_SKIP_DRAW) != 0) { |
| 24618 |
mPrivateFlags &= ~PFLAG_SKIP_DRAW; |
| 24619 |
requestLayout = true; |
| 24620 |
} |
| 24621 |
} else { |
| 24622 |
|
| 24623 |
mBackground = null; |
| 24624 |
if ((mViewFlags & WILL_NOT_DRAW) != 0 |
| 24625 |
&& (mDefaultFocusHighlight == null) |
| 24626 |
&& (mForegroundInfo == null || mForegroundInfo.mDrawable == null)) { |
| 24627 |
mPrivateFlags |= PFLAG_SKIP_DRAW; |
| 24628 |
} |
| 24629 |
|
| 24630 |
|
| 24631 |
|
| 24632 |
|
| 24633 |
|
| 24634 |
|
| 24635 |
|
| 24636 |
|
| 24637 |
|
| 24638 |
|
| 24639 |
requestLayout = true; |
| 24640 |
} |
| 24641 |
|
| 24642 |
computeOpaqueFlags(); |
| 24643 |
|
| 24644 |
if (requestLayout) { |
| 24645 |
requestLayout(); |
| 24646 |
} |
| 24647 |
|
| 24648 |
mBackgroundSizeChanged = true; |
| 24649 |
invalidate(true); |
| 24650 |
invalidateOutline(); |
| 24651 |
} |
| 24652 |
|
| 24653 |
|
| 24654 |
|
| 24655 |
|
| 24656 |
|
| 24657 |
|
| 24658 |
|
| 24659 |
|
| 24660 |
|
| 24661 |
|
| 24662 |
@InspectableProperty |
| 24663 |
public Drawable getBackground() { |
| 24664 |
return mBackground; |
| 24665 |
} |
| 24666 |
|
| 24667 |
|
| 24668 |
|
| 24669 |
|
| 24670 |
|
| 24671 |
|
| 24672 |
|
| 24673 |
|
| 24674 |
|
| 24675 |
|
| 24676 |
|
| 24677 |
|
| 24678 |
|
| 24679 |
|
| 24680 |
|
| 24681 |
@RemotableViewMethod |
| 24682 |
public void setBackgroundTintList(@Nullable ColorStateList tint) { |
| 24683 |
if (mBackgroundTint == null) { |
| 24684 |
mBackgroundTint = new TintInfo(); |
| 24685 |
} |
| 24686 |
mBackgroundTint.mTintList = tint; |
| 24687 |
mBackgroundTint.mHasTintList = true; |
| 24688 |
|
| 24689 |
applyBackgroundTint(); |
| 24690 |
} |
| 24691 |
|
| 24692 |
|
| 24693 |
|
| 24694 |
|
| 24695 |
|
| 24696 |
|
| 24697 |
|
| 24698 |
|
| 24699 |
@InspectableProperty(name = "backgroundTint") |
| 24700 |
@Nullable |
| 24701 |
public ColorStateList getBackgroundTintList() { |
| 24702 |
return mBackgroundTint != null ? mBackgroundTint.mTintList : null; |
| 24703 |
} |
| 24704 |
|
| 24705 |
|
| 24706 |
|
| 24707 |
|
| 24708 |
|
| 24709 |
|
| 24710 |
|
| 24711 |
|
| 24712 |
|
| 24713 |
|
| 24714 |
|
| 24715 |
|
| 24716 |
public void setBackgroundTintMode(@Nullable PorterDuff.Mode tintMode) { |
| 24717 |
BlendMode mode = null; |
| 24718 |
if (tintMode != null) { |
| 24719 |
mode = BlendMode.fromValue(tintMode.nativeInt); |
| 24720 |
} |
| 24721 |
|
| 24722 |
setBackgroundTintBlendMode(mode); |
| 24723 |
} |
| 24724 |
|
| 24725 |
|
| 24726 |
|
| 24727 |
|
| 24728 |
|
| 24729 |
|
| 24730 |
|
| 24731 |
|
| 24732 |
|
| 24733 |
|
| 24734 |
|
| 24735 |
|
| 24736 |
@RemotableViewMethod |
| 24737 |
public void setBackgroundTintBlendMode(@Nullable BlendMode blendMode) { |
| 24738 |
if (mBackgroundTint == null) { |
| 24739 |
mBackgroundTint = new TintInfo(); |
| 24740 |
} |
| 24741 |
|
| 24742 |
mBackgroundTint.mBlendMode = blendMode; |
| 24743 |
mBackgroundTint.mHasTintMode = true; |
| 24744 |
|
| 24745 |
applyBackgroundTint(); |
| 24746 |
} |
| 24747 |
|
| 24748 |
|
| 24749 |
|
| 24750 |
|
| 24751 |
|
| 24752 |
|
| 24753 |
|
| 24754 |
|
| 24755 |
|
| 24756 |
|
| 24757 |
|
| 24758 |
@Nullable |
| 24759 |
@InspectableProperty |
| 24760 |
public PorterDuff.Mode getBackgroundTintMode() { |
| 24761 |
PorterDuff.Mode porterDuffMode; |
| 24762 |
if (mBackgroundTint != null && mBackgroundTint.mBlendMode != null) { |
| 24763 |
porterDuffMode = BlendMode.blendModeToPorterDuffMode(mBackgroundTint.mBlendMode); |
| 24764 |
} else { |
| 24765 |
porterDuffMode = null; |
| 24766 |
} |
| 24767 |
return porterDuffMode; |
| 24768 |
} |
| 24769 |
|
| 24770 |
|
| 24771 |
|
| 24772 |
|
| 24773 |
|
| 24774 |
|
| 24775 |
|
| 24776 |
|
| 24777 |
|
| 24778 |
|
| 24779 |
public @Nullable BlendMode getBackgroundTintBlendMode() { |
| 24780 |
return mBackgroundTint != null ? mBackgroundTint.mBlendMode : null; |
| 24781 |
} |
| 24782 |
|
| 24783 |
private void applyBackgroundTint() { |
| 24784 |
if (mBackground != null && mBackgroundTint != null) { |
| 24785 |
final TintInfo tintInfo = mBackgroundTint; |
| 24786 |
if (tintInfo.mHasTintList || tintInfo.mHasTintMode) { |
| 24787 |
mBackground = mBackground.mutate(); |
| 24788 |
|
| 24789 |
if (tintInfo.mHasTintList) { |
| 24790 |
mBackground.setTintList(tintInfo.mTintList); |
| 24791 |
} |
| 24792 |
|
| 24793 |
if (tintInfo.mHasTintMode) { |
| 24794 |
mBackground.setTintBlendMode(tintInfo.mBlendMode); |
| 24795 |
} |
| 24796 |
|
| 24797 |
|
| 24798 |
|
| 24799 |
if (mBackground.isStateful()) { |
| 24800 |
mBackground.setState(getDrawableState()); |
| 24801 |
} |
| 24802 |
} |
| 24803 |
} |
| 24804 |
} |
| 24805 |
|
| 24806 |
|
| 24807 |
|
| 24808 |
|
| 24809 |
|
| 24810 |
|
| 24811 |
|
| 24812 |
|
| 24813 |
|
| 24814 |
@InspectableProperty |
| 24815 |
public Drawable getForeground() { |
| 24816 |
return mForegroundInfo != null ? mForegroundInfo.mDrawable : null; |
| 24817 |
} |
| 24818 |
|
| 24819 |
|
| 24820 |
|
| 24821 |
|
| 24822 |
|
| 24823 |
|
| 24824 |
|
| 24825 |
|
| 24826 |
public void setForeground(Drawable foreground) { |
| 24827 |
if (mForegroundInfo == null) { |
| 24828 |
if (foreground == null) { |
| 24829 |
|
| 24830 |
return; |
| 24831 |
} |
| 24832 |
mForegroundInfo = new ForegroundInfo(); |
| 24833 |
} |
| 24834 |
|
| 24835 |
if (foreground == mForegroundInfo.mDrawable) { |
| 24836 |
|
| 24837 |
return; |
| 24838 |
} |
| 24839 |
|
| 24840 |
if (mForegroundInfo.mDrawable != null) { |
| 24841 |
if (isAttachedToWindow()) { |
| 24842 |
mForegroundInfo.mDrawable.setVisible(false, false); |
| 24843 |
} |
| 24844 |
mForegroundInfo.mDrawable.setCallback(null); |
| 24845 |
unscheduleDrawable(mForegroundInfo.mDrawable); |
| 24846 |
} |
| 24847 |
|
| 24848 |
mForegroundInfo.mDrawable = foreground; |
| 24849 |
mForegroundInfo.mBoundsChanged = true; |
| 24850 |
if (foreground != null) { |
| 24851 |
if ((mPrivateFlags & PFLAG_SKIP_DRAW) != 0) { |
| 24852 |
mPrivateFlags &= ~PFLAG_SKIP_DRAW; |
| 24853 |
} |
| 24854 |
foreground.setLayoutDirection(getLayoutDirection()); |
| 24855 |
if (foreground.isStateful()) { |
| 24856 |
foreground.setState(getDrawableState()); |
| 24857 |
} |
| 24858 |
applyForegroundTint(); |
| 24859 |
if (isAttachedToWindow()) { |
| 24860 |
foreground.setVisible(getWindowVisibility() == VISIBLE && isShown(), false); |
| 24861 |
} |
| 24862 |
|
| 24863 |
foreground.setCallback(this); |
| 24864 |
} else if ((mViewFlags & WILL_NOT_DRAW) != 0 && mBackground == null |
| 24865 |
&& (mDefaultFocusHighlight == null)) { |
| 24866 |
mPrivateFlags |= PFLAG_SKIP_DRAW; |
| 24867 |
} |
| 24868 |
requestLayout(); |
| 24869 |
invalidate(); |
| 24870 |
} |
| 24871 |
|
| 24872 |
|
| 24873 |
|
| 24874 |
|
| 24875 |
|
| 24876 |
|
| 24877 |
|
| 24878 |
|
| 24879 |
|
| 24880 |
public boolean isForegroundInsidePadding() { |
| 24881 |
return mForegroundInfo != null ? mForegroundInfo.mInsidePadding : true; |
| 24882 |
} |
| 24883 |
|
| 24884 |
|
| 24885 |
|
| 24886 |
|
| 24887 |
|
| 24888 |
|
| 24889 |
|
| 24890 |
|
| 24891 |
|
| 24892 |
|
| 24893 |
@InspectableProperty(valueType = InspectableProperty.ValueType.GRAVITY) |
| 24894 |
public int getForegroundGravity() { |
| 24895 |
return mForegroundInfo != null ? mForegroundInfo.mGravity |
| 24896 |
: Gravity.START | Gravity.TOP; |
| 24897 |
} |
| 24898 |
|
| 24899 |
|
| 24900 |
|
| 24901 |
|
| 24902 |
|
| 24903 |
|
| 24904 |
|
| 24905 |
|
| 24906 |
|
| 24907 |
|
| 24908 |
public void setForegroundGravity(int gravity) { |
| 24909 |
if (mForegroundInfo == null) { |
| 24910 |
mForegroundInfo = new ForegroundInfo(); |
| 24911 |
} |
| 24912 |
|
| 24913 |
if (mForegroundInfo.mGravity != gravity) { |
| 24914 |
if ((gravity & Gravity.RELATIVE_HORIZONTAL_GRAVITY_MASK) == 0) { |
| 24915 |
gravity |= Gravity.START; |
| 24916 |
} |
| 24917 |
|
| 24918 |
if ((gravity & Gravity.VERTICAL_GRAVITY_MASK) == 0) { |
| 24919 |
gravity |= Gravity.TOP; |
| 24920 |
} |
| 24921 |
|
| 24922 |
mForegroundInfo.mGravity = gravity; |
| 24923 |
requestLayout(); |
| 24924 |
} |
| 24925 |
} |
| 24926 |
|
| 24927 |
|
| 24928 |
|
| 24929 |
|
| 24930 |
|
| 24931 |
|
| 24932 |
|
| 24933 |
|
| 24934 |
|
| 24935 |
|
| 24936 |
|
| 24937 |
|
| 24938 |
|
| 24939 |
|
| 24940 |
|
| 24941 |
@RemotableViewMethod |
| 24942 |
public void setForegroundTintList(@Nullable ColorStateList tint) { |
| 24943 |
if (mForegroundInfo == null) { |
| 24944 |
mForegroundInfo = new ForegroundInfo(); |
| 24945 |
} |
| 24946 |
if (mForegroundInfo.mTintInfo == null) { |
| 24947 |
mForegroundInfo.mTintInfo = new TintInfo(); |
| 24948 |
} |
| 24949 |
mForegroundInfo.mTintInfo.mTintList = tint; |
| 24950 |
mForegroundInfo.mTintInfo.mHasTintList = true; |
| 24951 |
|
| 24952 |
applyForegroundTint(); |
| 24953 |
} |
| 24954 |
|
| 24955 |
|
| 24956 |
|
| 24957 |
|
| 24958 |
|
| 24959 |
|
| 24960 |
|
| 24961 |
|
| 24962 |
@InspectableProperty(name = "foregroundTint") |
| 24963 |
@Nullable |
| 24964 |
public ColorStateList getForegroundTintList() { |
| 24965 |
return mForegroundInfo != null && mForegroundInfo.mTintInfo != null |
| 24966 |
? mForegroundInfo.mTintInfo.mTintList : null; |
| 24967 |
} |
| 24968 |
|
| 24969 |
|
| 24970 |
|
| 24971 |
|
| 24972 |
|
| 24973 |
|
| 24974 |
|
| 24975 |
|
| 24976 |
|
| 24977 |
|
| 24978 |
|
| 24979 |
|
| 24980 |
|
| 24981 |
public void setForegroundTintMode(@Nullable PorterDuff.Mode tintMode) { |
| 24982 |
BlendMode mode = null; |
| 24983 |
if (tintMode != null) { |
| 24984 |
mode = BlendMode.fromValue(tintMode.nativeInt); |
| 24985 |
} |
| 24986 |
setForegroundTintBlendMode(mode); |
| 24987 |
} |
| 24988 |
|
| 24989 |
|
| 24990 |
|
| 24991 |
|
| 24992 |
|
| 24993 |
|
| 24994 |
|
| 24995 |
|
| 24996 |
|
| 24997 |
|
| 24998 |
|
| 24999 |
|
| 25000 |
@RemotableViewMethod |
| 25001 |
public void setForegroundTintBlendMode(@Nullable BlendMode blendMode) { |
| 25002 |
if (mForegroundInfo == null) { |
| 25003 |
mForegroundInfo = new ForegroundInfo(); |
| 25004 |
} |
| 25005 |
if (mForegroundInfo.mTintInfo == null) { |
| 25006 |
mForegroundInfo.mTintInfo = new TintInfo(); |
| 25007 |
} |
| 25008 |
mForegroundInfo.mTintInfo.mBlendMode = blendMode; |
| 25009 |
mForegroundInfo.mTintInfo.mHasTintMode = true; |
| 25010 |
|
| 25011 |
applyForegroundTint(); |
| 25012 |
} |
| 25013 |
|
| 25014 |
|
| 25015 |
|
| 25016 |
|
| 25017 |
|
| 25018 |
|
| 25019 |
|
| 25020 |
|
| 25021 |
|
| 25022 |
|
| 25023 |
@InspectableProperty |
| 25024 |
@Nullable |
| 25025 |
public PorterDuff.Mode getForegroundTintMode() { |
| 25026 |
BlendMode blendMode = mForegroundInfo != null && mForegroundInfo.mTintInfo != null |
| 25027 |
? mForegroundInfo.mTintInfo.mBlendMode : null; |
| 25028 |
if (blendMode != null) { |
| 25029 |
return BlendMode.blendModeToPorterDuffMode(blendMode); |
| 25030 |
} else { |
| 25031 |
return null; |
| 25032 |
} |
| 25033 |
} |
| 25034 |
|
| 25035 |
|
| 25036 |
|
| 25037 |
|
| 25038 |
|
| 25039 |
|
| 25040 |
|
| 25041 |
|
| 25042 |
|
| 25043 |
|
| 25044 |
|
| 25045 |
public @Nullable BlendMode getForegroundTintBlendMode() { |
| 25046 |
return mForegroundInfo != null && mForegroundInfo.mTintInfo != null |
| 25047 |
? mForegroundInfo.mTintInfo.mBlendMode : null; |
| 25048 |
} |
| 25049 |
|
| 25050 |
private void applyForegroundTint() { |
| 25051 |
if (mForegroundInfo != null && mForegroundInfo.mDrawable != null |
| 25052 |
&& mForegroundInfo.mTintInfo != null) { |
| 25053 |
final TintInfo tintInfo = mForegroundInfo.mTintInfo; |
| 25054 |
if (tintInfo.mHasTintList || tintInfo.mHasTintMode) { |
| 25055 |
mForegroundInfo.mDrawable = mForegroundInfo.mDrawable.mutate(); |
| 25056 |
|
| 25057 |
if (tintInfo.mHasTintList) { |
| 25058 |
mForegroundInfo.mDrawable.setTintList(tintInfo.mTintList); |
| 25059 |
} |
| 25060 |
|
| 25061 |
if (tintInfo.mHasTintMode) { |
| 25062 |
mForegroundInfo.mDrawable.setTintBlendMode(tintInfo.mBlendMode); |
| 25063 |
} |
| 25064 |
|
| 25065 |
|
| 25066 |
|
| 25067 |
if (mForegroundInfo.mDrawable.isStateful()) { |
| 25068 |
mForegroundInfo.mDrawable.setState(getDrawableState()); |
| 25069 |
} |
| 25070 |
} |
| 25071 |
} |
| 25072 |
} |
| 25073 |
|
| 25074 |
|
| 25075 |
|
| 25076 |
|
| 25077 |
|
| 25078 |
|
| 25079 |
|
| 25080 |
|
| 25081 |
@Nullable private Drawable getAutofilledDrawable() { |
| 25082 |
if (mAttachInfo == null) { |
| 25083 |
return null; |
| 25084 |
} |
| 25085 |
|
| 25086 |
if (mAttachInfo.mAutofilledDrawable == null) { |
| 25087 |
Context rootContext = getRootView().getContext(); |
| 25088 |
TypedArray a = rootContext.getTheme().obtainStyledAttributes(AUTOFILL_HIGHLIGHT_ATTR); |
| 25089 |
int attributeResourceId = a.getResourceId(0, 0); |
| 25090 |
mAttachInfo.mAutofilledDrawable = rootContext.getDrawable(attributeResourceId); |
| 25091 |
a.recycle(); |
| 25092 |
} |
| 25093 |
|
| 25094 |
return mAttachInfo.mAutofilledDrawable; |
| 25095 |
} |
| 25096 |
|
| 25097 |
|
| 25098 |
|
| 25099 |
|
| 25100 |
|
| 25101 |
|
| 25102 |
|
| 25103 |
private void drawAutofilledHighlight(@NonNull Canvas canvas) { |
| 25104 |
if (isAutofilled() && !hideAutofillHighlight()) { |
| 25105 |
Drawable autofilledHighlight = getAutofilledDrawable(); |
| 25106 |
|
| 25107 |
if (autofilledHighlight != null) { |
| 25108 |
autofilledHighlight.setBounds(0, 0, getWidth(), getHeight()); |
| 25109 |
autofilledHighlight.draw(canvas); |
| 25110 |
} |
| 25111 |
} |
| 25112 |
} |
| 25113 |
|
| 25114 |
|
| 25115 |
|
| 25116 |
|
| 25117 |
|
| 25118 |
|
| 25119 |
|
| 25120 |
|
| 25121 |
|
| 25122 |
|
| 25123 |
public void onDrawForeground(Canvas canvas) { |
| 25124 |
onDrawScrollIndicators(canvas); |
| 25125 |
onDrawScrollBars(canvas); |
| 25126 |
|
| 25127 |
final Drawable foreground = mForegroundInfo != null ? mForegroundInfo.mDrawable : null; |
| 25128 |
if (foreground != null) { |
| 25129 |
if (mForegroundInfo.mBoundsChanged) { |
| 25130 |
mForegroundInfo.mBoundsChanged = false; |
| 25131 |
final Rect selfBounds = mForegroundInfo.mSelfBounds; |
| 25132 |
final Rect overlayBounds = mForegroundInfo.mOverlayBounds; |
| 25133 |
|
| 25134 |
if (mForegroundInfo.mInsidePadding) { |
| 25135 |
selfBounds.set(0, 0, getWidth(), getHeight()); |
| 25136 |
} else { |
| 25137 |
selfBounds.set(getPaddingLeft(), getPaddingTop(), |
| 25138 |
getWidth() - getPaddingRight(), getHeight() - getPaddingBottom()); |
| 25139 |
} |
| 25140 |
|
| 25141 |
final int ld = getLayoutDirection(); |
| 25142 |
Gravity.apply(mForegroundInfo.mGravity, foreground.getIntrinsicWidth(), |
| 25143 |
foreground.getIntrinsicHeight(), selfBounds, overlayBounds, ld); |
| 25144 |
foreground.setBounds(overlayBounds); |
| 25145 |
} |
| 25146 |
|
| 25147 |
foreground.draw(canvas); |
| 25148 |
} |
| 25149 |
} |
| 25150 |
|
| 25151 |
|
| 25152 |
|
| 25153 |
|
| 25154 |
|
| 25155 |
|
| 25156 |
|
| 25157 |
|
| 25158 |
|
| 25159 |
|
| 25160 |
|
| 25161 |
|
| 25162 |
|
| 25163 |
|
| 25164 |
|
| 25165 |
|
| 25166 |
|
| 25167 |
|
| 25168 |
public void setPadding(int left, int top, int right, int bottom) { |
| 25169 |
resetResolvedPaddingInternal(); |
| 25170 |
|
| 25171 |
mUserPaddingStart = UNDEFINED_PADDING; |
| 25172 |
mUserPaddingEnd = UNDEFINED_PADDING; |
| 25173 |
|
| 25174 |
mUserPaddingLeftInitial = left; |
| 25175 |
mUserPaddingRightInitial = right; |
| 25176 |
|
| 25177 |
mLeftPaddingDefined = true; |
| 25178 |
mRightPaddingDefined = true; |
| 25179 |
|
| 25180 |
internalSetPadding(left, top, right, bottom); |
| 25181 |
} |
| 25182 |
|
| 25183 |
|
| 25184 |
|
| 25185 |
|
| 25186 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 123768420) |
| 25187 |
protected void internalSetPadding(int left, int top, int right, int bottom) { |
| 25188 |
mUserPaddingLeft = left; |
| 25189 |
mUserPaddingRight = right; |
| 25190 |
mUserPaddingBottom = bottom; |
| 25191 |
|
| 25192 |
final int viewFlags = mViewFlags; |
| 25193 |
boolean changed = false; |
| 25194 |
|
| 25195 |
|
| 25196 |
if ((viewFlags & (SCROLLBARS_VERTICAL|SCROLLBARS_HORIZONTAL)) != 0) { |
| 25197 |
if ((viewFlags & SCROLLBARS_VERTICAL) != 0) { |
| 25198 |
final int offset = (viewFlags & SCROLLBARS_INSET_MASK) == 0 |
| 25199 |
? 0 : getVerticalScrollbarWidth(); |
| 25200 |
switch (mVerticalScrollbarPosition) { |
| 25201 |
case SCROLLBAR_POSITION_DEFAULT: |
| 25202 |
if (isLayoutRtl()) { |
| 25203 |
left += offset; |
| 25204 |
} else { |
| 25205 |
right += offset; |
| 25206 |
} |
| 25207 |
break; |
| 25208 |
case SCROLLBAR_POSITION_RIGHT: |
| 25209 |
right += offset; |
| 25210 |
break; |
| 25211 |
case SCROLLBAR_POSITION_LEFT: |
| 25212 |
left += offset; |
| 25213 |
break; |
| 25214 |
} |
| 25215 |
} |
| 25216 |
if ((viewFlags & SCROLLBARS_HORIZONTAL) != 0) { |
| 25217 |
bottom += (viewFlags & SCROLLBARS_INSET_MASK) == 0 |
| 25218 |
? 0 : getHorizontalScrollbarHeight(); |
| 25219 |
} |
| 25220 |
} |
| 25221 |
|
| 25222 |
if (mPaddingLeft != left) { |
| 25223 |
changed = true; |
| 25224 |
mPaddingLeft = left; |
| 25225 |
} |
| 25226 |
if (mPaddingTop != top) { |
| 25227 |
changed = true; |
| 25228 |
mPaddingTop = top; |
| 25229 |
} |
| 25230 |
if (mPaddingRight != right) { |
| 25231 |
changed = true; |
| 25232 |
mPaddingRight = right; |
| 25233 |
} |
| 25234 |
if (mPaddingBottom != bottom) { |
| 25235 |
changed = true; |
| 25236 |
mPaddingBottom = bottom; |
| 25237 |
} |
| 25238 |
|
| 25239 |
if (changed) { |
| 25240 |
requestLayout(); |
| 25241 |
invalidateOutline(); |
| 25242 |
} |
| 25243 |
} |
| 25244 |
|
| 25245 |
|
| 25246 |
|
| 25247 |
|
| 25248 |
|
| 25249 |
|
| 25250 |
|
| 25251 |
|
| 25252 |
|
| 25253 |
|
| 25254 |
|
| 25255 |
|
| 25256 |
|
| 25257 |
|
| 25258 |
|
| 25259 |
|
| 25260 |
|
| 25261 |
|
| 25262 |
public void setPaddingRelative(int start, int top, int end, int bottom) { |
| 25263 |
resetResolvedPaddingInternal(); |
| 25264 |
|
| 25265 |
mUserPaddingStart = start; |
| 25266 |
mUserPaddingEnd = end; |
| 25267 |
mLeftPaddingDefined = true; |
| 25268 |
mRightPaddingDefined = true; |
| 25269 |
|
| 25270 |
switch(getLayoutDirection()) { |
| 25271 |
case LAYOUT_DIRECTION_RTL: |
| 25272 |
mUserPaddingLeftInitial = end; |
| 25273 |
mUserPaddingRightInitial = start; |
| 25274 |
internalSetPadding(end, top, start, bottom); |
| 25275 |
break; |
| 25276 |
case LAYOUT_DIRECTION_LTR: |
| 25277 |
default: |
| 25278 |
mUserPaddingLeftInitial = start; |
| 25279 |
mUserPaddingRightInitial = end; |
| 25280 |
internalSetPadding(start, top, end, bottom); |
| 25281 |
} |
| 25282 |
} |
| 25283 |
|
| 25284 |
|
| 25285 |
|
| 25286 |
|
| 25287 |
|
| 25288 |
|
| 25289 |
|
| 25290 |
|
| 25291 |
@LayoutRes |
| 25292 |
public int getSourceLayoutResId() { |
| 25293 |
return mSourceLayoutId; |
| 25294 |
} |
| 25295 |
|
| 25296 |
|
| 25297 |
|
| 25298 |
|
| 25299 |
|
| 25300 |
|
| 25301 |
@InspectableProperty |
| 25302 |
public int getPaddingTop() { |
| 25303 |
return mPaddingTop; |
| 25304 |
} |
| 25305 |
|
| 25306 |
|
| 25307 |
|
| 25308 |
|
| 25309 |
|
| 25310 |
|
| 25311 |
|
| 25312 |
|
| 25313 |
@InspectableProperty |
| 25314 |
public int getPaddingBottom() { |
| 25315 |
return mPaddingBottom; |
| 25316 |
} |
| 25317 |
|
| 25318 |
|
| 25319 |
|
| 25320 |
|
| 25321 |
|
| 25322 |
|
| 25323 |
|
| 25324 |
|
| 25325 |
@InspectableProperty |
| 25326 |
public int getPaddingLeft() { |
| 25327 |
if (!isPaddingResolved()) { |
| 25328 |
resolvePadding(); |
| 25329 |
} |
| 25330 |
return mPaddingLeft; |
| 25331 |
} |
| 25332 |
|
| 25333 |
|
| 25334 |
|
| 25335 |
|
| 25336 |
|
| 25337 |
|
| 25338 |
|
| 25339 |
|
| 25340 |
public int getPaddingStart() { |
| 25341 |
if (!isPaddingResolved()) { |
| 25342 |
resolvePadding(); |
| 25343 |
} |
| 25344 |
return (getLayoutDirection() == LAYOUT_DIRECTION_RTL) ? |
| 25345 |
mPaddingRight : mPaddingLeft; |
| 25346 |
} |
| 25347 |
|
| 25348 |
|
| 25349 |
|
| 25350 |
|
| 25351 |
|
| 25352 |
|
| 25353 |
|
| 25354 |
|
| 25355 |
@InspectableProperty |
| 25356 |
public int getPaddingRight() { |
| 25357 |
if (!isPaddingResolved()) { |
| 25358 |
resolvePadding(); |
| 25359 |
} |
| 25360 |
return mPaddingRight; |
| 25361 |
} |
| 25362 |
|
| 25363 |
|
| 25364 |
|
| 25365 |
|
| 25366 |
|
| 25367 |
|
| 25368 |
|
| 25369 |
|
| 25370 |
public int getPaddingEnd() { |
| 25371 |
if (!isPaddingResolved()) { |
| 25372 |
resolvePadding(); |
| 25373 |
} |
| 25374 |
return (getLayoutDirection() == LAYOUT_DIRECTION_RTL) ? |
| 25375 |
mPaddingLeft : mPaddingRight; |
| 25376 |
} |
| 25377 |
|
| 25378 |
|
| 25379 |
|
| 25380 |
|
| 25381 |
|
| 25382 |
|
| 25383 |
|
| 25384 |
|
| 25385 |
|
| 25386 |
public boolean isPaddingRelative() { |
| 25387 |
return (mUserPaddingStart != UNDEFINED_PADDING || mUserPaddingEnd != UNDEFINED_PADDING); |
| 25388 |
} |
| 25389 |
|
| 25390 |
Insets computeOpticalInsets() { |
| 25391 |
return (mBackground == null) ? Insets.NONE : mBackground.getOpticalInsets(); |
| 25392 |
} |
| 25393 |
|
| 25394 |
|
| 25395 |
|
| 25396 |
|
| 25397 |
@UnsupportedAppUsage |
| 25398 |
public void resetPaddingToInitialValues() { |
| 25399 |
if (isRtlCompatibilityMode()) { |
| 25400 |
mPaddingLeft = mUserPaddingLeftInitial; |
| 25401 |
mPaddingRight = mUserPaddingRightInitial; |
| 25402 |
return; |
| 25403 |
} |
| 25404 |
if (isLayoutRtl()) { |
| 25405 |
mPaddingLeft = (mUserPaddingEnd >= 0) ? mUserPaddingEnd : mUserPaddingLeftInitial; |
| 25406 |
mPaddingRight = (mUserPaddingStart >= 0) ? mUserPaddingStart : mUserPaddingRightInitial; |
| 25407 |
} else { |
| 25408 |
mPaddingLeft = (mUserPaddingStart >= 0) ? mUserPaddingStart : mUserPaddingLeftInitial; |
| 25409 |
mPaddingRight = (mUserPaddingEnd >= 0) ? mUserPaddingEnd : mUserPaddingRightInitial; |
| 25410 |
} |
| 25411 |
} |
| 25412 |
|
| 25413 |
|
| 25414 |
|
| 25415 |
|
| 25416 |
public Insets getOpticalInsets() { |
| 25417 |
if (mLayoutInsets == null) { |
| 25418 |
mLayoutInsets = computeOpticalInsets(); |
| 25419 |
} |
| 25420 |
return mLayoutInsets; |
| 25421 |
} |
| 25422 |
|
| 25423 |
|
| 25424 |
|
| 25425 |
|
| 25426 |
|
| 25427 |
|
| 25428 |
|
| 25429 |
|
| 25430 |
|
| 25431 |
|
| 25432 |
|
| 25433 |
public void setOpticalInsets(Insets insets) { |
| 25434 |
mLayoutInsets = insets; |
| 25435 |
} |
| 25436 |
|
| 25437 |
|
| 25438 |
|
| 25439 |
|
| 25440 |
|
| 25441 |
|
| 25442 |
|
| 25443 |
|
| 25444 |
|
| 25445 |
public void setSelected(boolean selected) { |
| 25446 |
|
| 25447 |
if (((mPrivateFlags & PFLAG_SELECTED) != 0) != selected) { |
| 25448 |
mPrivateFlags = (mPrivateFlags & ~PFLAG_SELECTED) | (selected ? PFLAG_SELECTED : 0); |
| 25449 |
if (!selected) resetPressedState(); |
| 25450 |
invalidate(true); |
| 25451 |
refreshDrawableState(); |
| 25452 |
dispatchSetSelected(selected); |
| 25453 |
if (selected) { |
| 25454 |
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_SELECTED); |
| 25455 |
} else { |
| 25456 |
notifyViewAccessibilityStateChangedIfNeeded( |
| 25457 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 25458 |
} |
| 25459 |
} |
| 25460 |
} |
| 25461 |
|
| 25462 |
|
| 25463 |
|
| 25464 |
|
| 25465 |
|
| 25466 |
|
| 25467 |
|
| 25468 |
|
| 25469 |
protected void dispatchSetSelected(boolean selected) { |
| 25470 |
} |
| 25471 |
|
| 25472 |
|
| 25473 |
|
| 25474 |
|
| 25475 |
|
| 25476 |
|
| 25477 |
@ViewDebug.ExportedProperty |
| 25478 |
@InspectableProperty(hasAttributeId = false) |
| 25479 |
public boolean isSelected() { |
| 25480 |
return (mPrivateFlags & PFLAG_SELECTED) != 0; |
| 25481 |
} |
| 25482 |
|
| 25483 |
|
| 25484 |
|
| 25485 |
|
| 25486 |
|
| 25487 |
|
| 25488 |
|
| 25489 |
|
| 25490 |
|
| 25491 |
|
| 25492 |
|
| 25493 |
|
| 25494 |
|
| 25495 |
|
| 25496 |
public void setActivated(boolean activated) { |
| 25497 |
|
| 25498 |
if (((mPrivateFlags & PFLAG_ACTIVATED) != 0) != activated) { |
| 25499 |
mPrivateFlags = (mPrivateFlags & ~PFLAG_ACTIVATED) | (activated ? PFLAG_ACTIVATED : 0); |
| 25500 |
invalidate(true); |
| 25501 |
refreshDrawableState(); |
| 25502 |
dispatchSetActivated(activated); |
| 25503 |
} |
| 25504 |
} |
| 25505 |
|
| 25506 |
|
| 25507 |
|
| 25508 |
|
| 25509 |
|
| 25510 |
|
| 25511 |
|
| 25512 |
|
| 25513 |
protected void dispatchSetActivated(boolean activated) { |
| 25514 |
} |
| 25515 |
|
| 25516 |
|
| 25517 |
|
| 25518 |
|
| 25519 |
|
| 25520 |
|
| 25521 |
@ViewDebug.ExportedProperty |
| 25522 |
@InspectableProperty(hasAttributeId = false) |
| 25523 |
public boolean isActivated() { |
| 25524 |
return (mPrivateFlags & PFLAG_ACTIVATED) != 0; |
| 25525 |
} |
| 25526 |
|
| 25527 |
|
| 25528 |
|
| 25529 |
|
| 25530 |
|
| 25531 |
|
| 25532 |
|
| 25533 |
|
| 25534 |
|
| 25535 |
|
| 25536 |
|
| 25537 |
|
| 25538 |
|
| 25539 |
public ViewTreeObserver getViewTreeObserver() { |
| 25540 |
if (mAttachInfo != null) { |
| 25541 |
return mAttachInfo.mTreeObserver; |
| 25542 |
} |
| 25543 |
if (mFloatingTreeObserver == null) { |
| 25544 |
mFloatingTreeObserver = new ViewTreeObserver(mContext); |
| 25545 |
} |
| 25546 |
return mFloatingTreeObserver; |
| 25547 |
} |
| 25548 |
|
| 25549 |
|
| 25550 |
|
| 25551 |
|
| 25552 |
|
| 25553 |
|
| 25554 |
public View getRootView() { |
| 25555 |
if (mAttachInfo != null) { |
| 25556 |
final View v = mAttachInfo.mRootView; |
| 25557 |
if (v != null) { |
| 25558 |
return v; |
| 25559 |
} |
| 25560 |
} |
| 25561 |
|
| 25562 |
View parent = this; |
| 25563 |
|
| 25564 |
while (parent.mParent instanceof View) { |
| 25565 |
parent = (View) parent.mParent; |
| 25566 |
} |
| 25567 |
|
| 25568 |
return parent; |
| 25569 |
} |
| 25570 |
|
| 25571 |
|
| 25572 |
|
| 25573 |
|
| 25574 |
|
| 25575 |
|
| 25576 |
|
| 25577 |
|
| 25578 |
|
| 25579 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 25580 |
public boolean toGlobalMotionEvent(MotionEvent ev) { |
| 25581 |
final AttachInfo info = mAttachInfo; |
| 25582 |
if (info == null) { |
| 25583 |
return false; |
| 25584 |
} |
| 25585 |
|
| 25586 |
final Matrix m = info.mTmpMatrix; |
| 25587 |
m.set(Matrix.IDENTITY_MATRIX); |
| 25588 |
transformMatrixToGlobal(m); |
| 25589 |
ev.transform(m); |
| 25590 |
return true; |
| 25591 |
} |
| 25592 |
|
| 25593 |
|
| 25594 |
|
| 25595 |
|
| 25596 |
|
| 25597 |
|
| 25598 |
|
| 25599 |
|
| 25600 |
|
| 25601 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 25602 |
public boolean toLocalMotionEvent(MotionEvent ev) { |
| 25603 |
final AttachInfo info = mAttachInfo; |
| 25604 |
if (info == null) { |
| 25605 |
return false; |
| 25606 |
} |
| 25607 |
|
| 25608 |
final Matrix m = info.mTmpMatrix; |
| 25609 |
m.set(Matrix.IDENTITY_MATRIX); |
| 25610 |
transformMatrixToLocal(m); |
| 25611 |
ev.transform(m); |
| 25612 |
return true; |
| 25613 |
} |
| 25614 |
|
| 25615 |
|
| 25616 |
|
| 25617 |
|
| 25618 |
|
| 25619 |
|
| 25620 |
|
| 25621 |
public void transformMatrixToGlobal(@NonNull Matrix matrix) { |
| 25622 |
final ViewParent parent = mParent; |
| 25623 |
if (parent instanceof View) { |
| 25624 |
final View vp = (View) parent; |
| 25625 |
vp.transformMatrixToGlobal(matrix); |
| 25626 |
matrix.preTranslate(-vp.mScrollX, -vp.mScrollY); |
| 25627 |
} else if (parent instanceof ViewRootImpl) { |
| 25628 |
final ViewRootImpl vr = (ViewRootImpl) parent; |
| 25629 |
vr.transformMatrixToGlobal(matrix); |
| 25630 |
matrix.preTranslate(0, -vr.mCurScrollY); |
| 25631 |
} |
| 25632 |
|
| 25633 |
matrix.preTranslate(mLeft, mTop); |
| 25634 |
|
| 25635 |
if (!hasIdentityMatrix()) { |
| 25636 |
matrix.preConcat(getMatrix()); |
| 25637 |
} |
| 25638 |
} |
| 25639 |
|
| 25640 |
|
| 25641 |
|
| 25642 |
|
| 25643 |
|
| 25644 |
|
| 25645 |
|
| 25646 |
public void transformMatrixToLocal(@NonNull Matrix matrix) { |
| 25647 |
final ViewParent parent = mParent; |
| 25648 |
if (parent instanceof View) { |
| 25649 |
final View vp = (View) parent; |
| 25650 |
vp.transformMatrixToLocal(matrix); |
| 25651 |
matrix.postTranslate(vp.mScrollX, vp.mScrollY); |
| 25652 |
} else if (parent instanceof ViewRootImpl) { |
| 25653 |
final ViewRootImpl vr = (ViewRootImpl) parent; |
| 25654 |
vr.transformMatrixToLocal(matrix); |
| 25655 |
matrix.postTranslate(0, vr.mCurScrollY); |
| 25656 |
} |
| 25657 |
|
| 25658 |
matrix.postTranslate(-mLeft, -mTop); |
| 25659 |
|
| 25660 |
if (!hasIdentityMatrix()) { |
| 25661 |
matrix.postConcat(getInverseMatrix()); |
| 25662 |
} |
| 25663 |
} |
| 25664 |
|
| 25665 |
|
| 25666 |
|
| 25667 |
|
| 25668 |
@ViewDebug.ExportedProperty(category = "layout", indexMapping = { |
| 25669 |
@ViewDebug.IntToString(from = 0, to = "x"), |
| 25670 |
@ViewDebug.IntToString(from = 1, to = "y") |
| 25671 |
}) |
| 25672 |
@UnsupportedAppUsage |
| 25673 |
public int[] getLocationOnScreen() { |
| 25674 |
int[] location = new int[2]; |
| 25675 |
getLocationOnScreen(location); |
| 25676 |
return location; |
| 25677 |
} |
| 25678 |
|
| 25679 |
|
| 25680 |
|
| 25681 |
|
| 25682 |
|
| 25683 |
|
| 25684 |
|
| 25685 |
|
| 25686 |
|
| 25687 |
|
| 25688 |
|
| 25689 |
|
| 25690 |
|
| 25691 |
|
| 25692 |
|
| 25693 |
|
| 25694 |
|
| 25695 |
|
| 25696 |
|
| 25697 |
|
| 25698 |
|
| 25699 |
|
| 25700 |
|
| 25701 |
|
| 25702 |
|
| 25703 |
|
| 25704 |
|
| 25705 |
|
| 25706 |
public void getLocationOnScreen(@Size(2) int[] outLocation) { |
| 25707 |
getLocationInWindow(outLocation); |
| 25708 |
|
| 25709 |
final AttachInfo info = mAttachInfo; |
| 25710 |
if (info != null) { |
| 25711 |
outLocation[0] += info.mWindowLeft; |
| 25712 |
outLocation[1] += info.mWindowTop; |
| 25713 |
} |
| 25714 |
} |
| 25715 |
|
| 25716 |
|
| 25717 |
|
| 25718 |
|
| 25719 |
|
| 25720 |
|
| 25721 |
|
| 25722 |
|
| 25723 |
|
| 25724 |
|
| 25725 |
|
| 25726 |
|
| 25727 |
|
| 25728 |
|
| 25729 |
|
| 25730 |
|
| 25731 |
|
| 25732 |
|
| 25733 |
|
| 25734 |
|
| 25735 |
|
| 25736 |
|
| 25737 |
public void getLocationInWindow(@Size(2) int[] outLocation) { |
| 25738 |
if (outLocation == null || outLocation.length < 2) { |
| 25739 |
throw new IllegalArgumentException("outLocation must be an array of two integers"); |
| 25740 |
} |
| 25741 |
|
| 25742 |
outLocation[0] = 0; |
| 25743 |
outLocation[1] = 0; |
| 25744 |
|
| 25745 |
transformFromViewToWindowSpace(outLocation); |
| 25746 |
} |
| 25747 |
|
| 25748 |
|
| 25749 |
public void transformFromViewToWindowSpace(@Size(2) int[] inOutLocation) { |
| 25750 |
if (inOutLocation == null || inOutLocation.length < 2) { |
| 25751 |
throw new IllegalArgumentException("inOutLocation must be an array of two integers"); |
| 25752 |
} |
| 25753 |
|
| 25754 |
if (mAttachInfo == null) { |
| 25755 |
|
| 25756 |
inOutLocation[0] = inOutLocation[1] = 0; |
| 25757 |
return; |
| 25758 |
} |
| 25759 |
|
| 25760 |
float position[] = mAttachInfo.mTmpTransformLocation; |
| 25761 |
position[0] = inOutLocation[0]; |
| 25762 |
position[1] = inOutLocation[1]; |
| 25763 |
|
| 25764 |
if (!hasIdentityMatrix()) { |
| 25765 |
getMatrix().mapPoints(position); |
| 25766 |
} |
| 25767 |
|
| 25768 |
position[0] += mLeft; |
| 25769 |
position[1] += mTop; |
| 25770 |
|
| 25771 |
ViewParent viewParent = mParent; |
| 25772 |
while (viewParent instanceof View) { |
| 25773 |
final View view = (View) viewParent; |
| 25774 |
|
| 25775 |
position[0] -= view.mScrollX; |
| 25776 |
position[1] -= view.mScrollY; |
| 25777 |
|
| 25778 |
if (!view.hasIdentityMatrix()) { |
| 25779 |
view.getMatrix().mapPoints(position); |
| 25780 |
} |
| 25781 |
|
| 25782 |
position[0] += view.mLeft; |
| 25783 |
position[1] += view.mTop; |
| 25784 |
|
| 25785 |
viewParent = view.mParent; |
| 25786 |
} |
| 25787 |
|
| 25788 |
if (viewParent instanceof ViewRootImpl) { |
| 25789 |
|
| 25790 |
final ViewRootImpl vr = (ViewRootImpl) viewParent; |
| 25791 |
position[1] -= vr.mCurScrollY; |
| 25792 |
} |
| 25793 |
|
| 25794 |
inOutLocation[0] = Math.round(position[0]); |
| 25795 |
inOutLocation[1] = Math.round(position[1]); |
| 25796 |
} |
| 25797 |
|
| 25798 |
|
| 25799 |
|
| 25800 |
|
| 25801 |
|
| 25802 |
|
| 25803 |
protected <T extends View> T findViewTraversal(@IdRes int id) { |
| 25804 |
if (id == mID) { |
| 25805 |
return (T) this; |
| 25806 |
} |
| 25807 |
return null; |
| 25808 |
} |
| 25809 |
|
| 25810 |
|
| 25811 |
|
| 25812 |
|
| 25813 |
|
| 25814 |
|
| 25815 |
protected <T extends View> T findViewWithTagTraversal(Object tag) { |
| 25816 |
if (tag != null && tag.equals(mTag)) { |
| 25817 |
return (T) this; |
| 25818 |
} |
| 25819 |
return null; |
| 25820 |
} |
| 25821 |
|
| 25822 |
|
| 25823 |
|
| 25824 |
|
| 25825 |
|
| 25826 |
|
| 25827 |
|
| 25828 |
protected <T extends View> T findViewByPredicateTraversal(Predicate<View> predicate, |
| 25829 |
View childToSkip) { |
| 25830 |
if (predicate.test(this)) { |
| 25831 |
return (T) this; |
| 25832 |
} |
| 25833 |
return null; |
| 25834 |
} |
| 25835 |
|
| 25836 |
|
| 25837 |
|
| 25838 |
|
| 25839 |
|
| 25840 |
|
| 25841 |
|
| 25842 |
|
| 25843 |
|
| 25844 |
|
| 25845 |
|
| 25846 |
|
| 25847 |
|
| 25848 |
|
| 25849 |
|
| 25850 |
@Nullable |
| 25851 |
public final <T extends View> T findViewById(@IdRes int id) { |
| 25852 |
if (id == NO_ID) { |
| 25853 |
return null; |
| 25854 |
} |
| 25855 |
return findViewTraversal(id); |
| 25856 |
} |
| 25857 |
|
| 25858 |
|
| 25859 |
|
| 25860 |
|
| 25861 |
|
| 25862 |
|
| 25863 |
|
| 25864 |
|
| 25865 |
|
| 25866 |
|
| 25867 |
|
| 25868 |
|
| 25869 |
|
| 25870 |
|
| 25871 |
|
| 25872 |
@NonNull |
| 25873 |
public final <T extends View> T requireViewById(@IdRes int id) { |
| 25874 |
T view = findViewById(id); |
| 25875 |
if (view == null) { |
| 25876 |
throw new IllegalArgumentException("ID does not reference a View inside this View"); |
| 25877 |
} |
| 25878 |
return view; |
| 25879 |
} |
| 25880 |
|
| 25881 |
|
| 25882 |
|
| 25883 |
|
| 25884 |
|
| 25885 |
|
| 25886 |
|
| 25887 |
|
| 25888 |
|
| 25889 |
|
| 25890 |
|
| 25891 |
|
| 25892 |
|
| 25893 |
|
| 25894 |
|
| 25895 |
public <T extends View> T findViewByAccessibilityIdTraversal(int accessibilityId) { |
| 25896 |
if (getAccessibilityViewId() == accessibilityId) { |
| 25897 |
return (T) this; |
| 25898 |
} |
| 25899 |
return null; |
| 25900 |
} |
| 25901 |
|
| 25902 |
|
| 25903 |
|
| 25904 |
|
| 25905 |
|
| 25906 |
|
| 25907 |
|
| 25908 |
|
| 25909 |
|
| 25910 |
|
| 25911 |
|
| 25912 |
public <T extends View> T findViewByAutofillIdTraversal(int autofillId) { |
| 25913 |
if (getAutofillViewId() == autofillId) { |
| 25914 |
return (T) this; |
| 25915 |
} |
| 25916 |
return null; |
| 25917 |
} |
| 25918 |
|
| 25919 |
|
| 25920 |
|
| 25921 |
|
| 25922 |
|
| 25923 |
|
| 25924 |
|
| 25925 |
|
| 25926 |
public final <T extends View> T findViewWithTag(Object tag) { |
| 25927 |
if (tag == null) { |
| 25928 |
return null; |
| 25929 |
} |
| 25930 |
return findViewWithTagTraversal(tag); |
| 25931 |
} |
| 25932 |
|
| 25933 |
|
| 25934 |
|
| 25935 |
|
| 25936 |
|
| 25937 |
|
| 25938 |
|
| 25939 |
|
| 25940 |
|
| 25941 |
public final <T extends View> T findViewByPredicate(Predicate<View> predicate) { |
| 25942 |
return findViewByPredicateTraversal(predicate, null); |
| 25943 |
} |
| 25944 |
|
| 25945 |
|
| 25946 |
|
| 25947 |
|
| 25948 |
|
| 25949 |
|
| 25950 |
|
| 25951 |
|
| 25952 |
|
| 25953 |
|
| 25954 |
|
| 25955 |
|
| 25956 |
|
| 25957 |
|
| 25958 |
|
| 25959 |
|
| 25960 |
|
| 25961 |
public final <T extends View> T findViewByPredicateInsideOut( |
| 25962 |
View start, Predicate<View> predicate) { |
| 25963 |
View childToSkip = null; |
| 25964 |
for (;;) { |
| 25965 |
T view = start.findViewByPredicateTraversal(predicate, childToSkip); |
| 25966 |
if (view != null || start == this) { |
| 25967 |
return view; |
| 25968 |
} |
| 25969 |
|
| 25970 |
ViewParent parent = start.getParent(); |
| 25971 |
if (parent == null || !(parent instanceof View)) { |
| 25972 |
return null; |
| 25973 |
} |
| 25974 |
|
| 25975 |
childToSkip = start; |
| 25976 |
start = (View) parent; |
| 25977 |
} |
| 25978 |
} |
| 25979 |
|
| 25980 |
|
| 25981 |
|
| 25982 |
|
| 25983 |
|
| 25984 |
|
| 25985 |
|
| 25986 |
|
| 25987 |
|
| 25988 |
|
| 25989 |
|
| 25990 |
|
| 25991 |
|
| 25992 |
|
| 25993 |
public void setId(@IdRes int id) { |
| 25994 |
mID = id; |
| 25995 |
if (mID == View.NO_ID && mLabelForId != View.NO_ID) { |
| 25996 |
mID = generateViewId(); |
| 25997 |
} |
| 25998 |
} |
| 25999 |
|
| 26000 |
|
| 26001 |
|
| 26002 |
|
| 26003 |
|
| 26004 |
|
| 26005 |
|
| 26006 |
@UnsupportedAppUsage |
| 26007 |
@TestApi |
| 26008 |
public void setIsRootNamespace(boolean isRoot) { |
| 26009 |
if (isRoot) { |
| 26010 |
mPrivateFlags |= PFLAG_IS_ROOT_NAMESPACE; |
| 26011 |
} else { |
| 26012 |
mPrivateFlags &= ~PFLAG_IS_ROOT_NAMESPACE; |
| 26013 |
} |
| 26014 |
} |
| 26015 |
|
| 26016 |
|
| 26017 |
|
| 26018 |
|
| 26019 |
|
| 26020 |
|
| 26021 |
@UnsupportedAppUsage |
| 26022 |
public boolean isRootNamespace() { |
| 26023 |
return (mPrivateFlags&PFLAG_IS_ROOT_NAMESPACE) != 0; |
| 26024 |
} |
| 26025 |
|
| 26026 |
|
| 26027 |
|
| 26028 |
|
| 26029 |
|
| 26030 |
|
| 26031 |
|
| 26032 |
|
| 26033 |
|
| 26034 |
|
| 26035 |
|
| 26036 |
@IdRes |
| 26037 |
@ViewDebug.CapturedViewProperty |
| 26038 |
@InspectableProperty |
| 26039 |
public int getId() { |
| 26040 |
return mID; |
| 26041 |
} |
| 26042 |
|
| 26043 |
|
| 26044 |
|
| 26045 |
|
| 26046 |
|
| 26047 |
|
| 26048 |
|
| 26049 |
public long getUniqueDrawingId() { |
| 26050 |
return mRenderNode.getUniqueId(); |
| 26051 |
} |
| 26052 |
|
| 26053 |
|
| 26054 |
|
| 26055 |
|
| 26056 |
|
| 26057 |
|
| 26058 |
|
| 26059 |
|
| 26060 |
|
| 26061 |
|
| 26062 |
@ViewDebug.ExportedProperty |
| 26063 |
@InspectableProperty |
| 26064 |
public Object getTag() { |
| 26065 |
return mTag; |
| 26066 |
} |
| 26067 |
|
| 26068 |
|
| 26069 |
|
| 26070 |
|
| 26071 |
|
| 26072 |
|
| 26073 |
|
| 26074 |
|
| 26075 |
|
| 26076 |
|
| 26077 |
|
| 26078 |
|
| 26079 |
public void setTag(final Object tag) { |
| 26080 |
mTag = tag; |
| 26081 |
} |
| 26082 |
|
| 26083 |
|
| 26084 |
|
| 26085 |
|
| 26086 |
|
| 26087 |
|
| 26088 |
|
| 26089 |
|
| 26090 |
|
| 26091 |
|
| 26092 |
|
| 26093 |
|
| 26094 |
public Object getTag(int key) { |
| 26095 |
if (mKeyedTags != null) return mKeyedTags.get(key); |
| 26096 |
return null; |
| 26097 |
} |
| 26098 |
|
| 26099 |
|
| 26100 |
|
| 26101 |
|
| 26102 |
|
| 26103 |
|
| 26104 |
|
| 26105 |
|
| 26106 |
|
| 26107 |
|
| 26108 |
|
| 26109 |
|
| 26110 |
|
| 26111 |
|
| 26112 |
|
| 26113 |
|
| 26114 |
|
| 26115 |
|
| 26116 |
|
| 26117 |
|
| 26118 |
|
| 26119 |
|
| 26120 |
public void setTag(int key, final Object tag) { |
| 26121 |
|
| 26122 |
|
| 26123 |
if ((key >>> 24) < 2) { |
| 26124 |
throw new IllegalArgumentException("The key must be an application-specific " |
| 26125 |
+ "resource id."); |
| 26126 |
} |
| 26127 |
|
| 26128 |
setKeyedTag(key, tag); |
| 26129 |
} |
| 26130 |
|
| 26131 |
|
| 26132 |
|
| 26133 |
|
| 26134 |
|
| 26135 |
|
| 26136 |
|
| 26137 |
@UnsupportedAppUsage |
| 26138 |
public void setTagInternal(int key, Object tag) { |
| 26139 |
if ((key >>> 24) != 0x1) { |
| 26140 |
throw new IllegalArgumentException("The key must be a framework-specific " |
| 26141 |
+ "resource id."); |
| 26142 |
} |
| 26143 |
|
| 26144 |
setKeyedTag(key, tag); |
| 26145 |
} |
| 26146 |
|
| 26147 |
private void setKeyedTag(int key, Object tag) { |
| 26148 |
if (mKeyedTags == null) { |
| 26149 |
mKeyedTags = new SparseArray<Object>(2); |
| 26150 |
} |
| 26151 |
|
| 26152 |
mKeyedTags.put(key, tag); |
| 26153 |
} |
| 26154 |
|
| 26155 |
|
| 26156 |
|
| 26157 |
|
| 26158 |
|
| 26159 |
|
| 26160 |
|
| 26161 |
@UnsupportedAppUsage |
| 26162 |
public void debug() { |
| 26163 |
debug(0); |
| 26164 |
} |
| 26165 |
|
| 26166 |
|
| 26167 |
|
| 26168 |
|
| 26169 |
|
| 26170 |
|
| 26171 |
|
| 26172 |
|
| 26173 |
|
| 26174 |
|
| 26175 |
@UnsupportedAppUsage |
| 26176 |
protected void debug(int depth) { |
| 26177 |
String output = debugIndent(depth - 1); |
| 26178 |
|
| 26179 |
output += "+ " + this; |
| 26180 |
int id = getId(); |
| 26181 |
if (id != -1) { |
| 26182 |
output += " (id=" + id + ")"; |
| 26183 |
} |
| 26184 |
Object tag = getTag(); |
| 26185 |
if (tag != null) { |
| 26186 |
output += " (tag=" + tag + ")"; |
| 26187 |
} |
| 26188 |
Log.d(VIEW_LOG_TAG, output); |
| 26189 |
|
| 26190 |
if ((mPrivateFlags & PFLAG_FOCUSED) != 0) { |
| 26191 |
output = debugIndent(depth) + " FOCUSED"; |
| 26192 |
Log.d(VIEW_LOG_TAG, output); |
| 26193 |
} |
| 26194 |
|
| 26195 |
output = debugIndent(depth); |
| 26196 |
output += "frame={" + mLeft + ", " + mTop + ", " + mRight |
| 26197 |
+ ", " + mBottom + "} scroll={" + mScrollX + ", " + mScrollY |
| 26198 |
+ "} "; |
| 26199 |
Log.d(VIEW_LOG_TAG, output); |
| 26200 |
|
| 26201 |
if (mPaddingLeft != 0 || mPaddingTop != 0 || mPaddingRight != 0 |
| 26202 |
|| mPaddingBottom != 0) { |
| 26203 |
output = debugIndent(depth); |
| 26204 |
output += "padding={" + mPaddingLeft + ", " + mPaddingTop |
| 26205 |
+ ", " + mPaddingRight + ", " + mPaddingBottom + "}"; |
| 26206 |
Log.d(VIEW_LOG_TAG, output); |
| 26207 |
} |
| 26208 |
|
| 26209 |
output = debugIndent(depth); |
| 26210 |
output += "mMeasureWidth=" + mMeasuredWidth + |
| 26211 |
" mMeasureHeight=" + mMeasuredHeight; |
| 26212 |
Log.d(VIEW_LOG_TAG, output); |
| 26213 |
|
| 26214 |
output = debugIndent(depth); |
| 26215 |
if (mLayoutParams == null) { |
| 26216 |
output += "BAD! no layout params"; |
| 26217 |
} else { |
| 26218 |
output = mLayoutParams.debug(output); |
| 26219 |
} |
| 26220 |
Log.d(VIEW_LOG_TAG, output); |
| 26221 |
|
| 26222 |
output = debugIndent(depth); |
| 26223 |
output += "flags={"; |
| 26224 |
output += View.printFlags(mViewFlags); |
| 26225 |
output += "}"; |
| 26226 |
Log.d(VIEW_LOG_TAG, output); |
| 26227 |
|
| 26228 |
output = debugIndent(depth); |
| 26229 |
output += "privateFlags={"; |
| 26230 |
output += View.printPrivateFlags(mPrivateFlags); |
| 26231 |
output += "}"; |
| 26232 |
Log.d(VIEW_LOG_TAG, output); |
| 26233 |
} |
| 26234 |
|
| 26235 |
|
| 26236 |
|
| 26237 |
|
| 26238 |
|
| 26239 |
|
| 26240 |
|
| 26241 |
|
| 26242 |
|
| 26243 |
protected static String debugIndent(int depth) { |
| 26244 |
StringBuilder spaces = new StringBuilder((depth * 2 + 3) * 2); |
| 26245 |
for (int i = 0; i < (depth * 2) + 3; i++) { |
| 26246 |
spaces.append(' ').append(' '); |
| 26247 |
} |
| 26248 |
return spaces.toString(); |
| 26249 |
} |
| 26250 |
|
| 26251 |
|
| 26252 |
|
| 26253 |
|
| 26254 |
|
| 26255 |
|
| 26256 |
|
| 26257 |
|
| 26258 |
|
| 26259 |
@ViewDebug.ExportedProperty(category = "layout") |
| 26260 |
@InspectableProperty |
| 26261 |
public int getBaseline() { |
| 26262 |
return -1; |
| 26263 |
} |
| 26264 |
|
| 26265 |
|
| 26266 |
|
| 26267 |
|
| 26268 |
|
| 26269 |
|
| 26270 |
|
| 26271 |
|
| 26272 |
public boolean isInLayout() { |
| 26273 |
ViewRootImpl viewRoot = getViewRootImpl(); |
| 26274 |
return (viewRoot != null && viewRoot.isInLayout()); |
| 26275 |
} |
| 26276 |
|
| 26277 |
|
| 26278 |
|
| 26279 |
|
| 26280 |
|
| 26281 |
|
| 26282 |
|
| 26283 |
|
| 26284 |
|
| 26285 |
|
| 26286 |
|
| 26287 |
|
| 26288 |
@CallSuper |
| 26289 |
public void requestLayout() { |
| 26290 |
if (mMeasureCache != null) mMeasureCache.clear(); |
| 26291 |
|
| 26292 |
if (mAttachInfo != null && mAttachInfo.mViewRequestingLayout == null) { |
| 26293 |
|
| 26294 |
|
| 26295 |
ViewRootImpl viewRoot = getViewRootImpl(); |
| 26296 |
if (viewRoot != null && viewRoot.isInLayout()) { |
| 26297 |
if (!viewRoot.requestLayoutDuringLayout(this)) { |
| 26298 |
return; |
| 26299 |
} |
| 26300 |
} |
| 26301 |
mAttachInfo.mViewRequestingLayout = this; |
| 26302 |
} |
| 26303 |
|
| 26304 |
mPrivateFlags |= PFLAG_FORCE_LAYOUT; |
| 26305 |
mPrivateFlags |= PFLAG_INVALIDATED; |
| 26306 |
|
| 26307 |
if (mParent != null && !mParent.isLayoutRequested()) { |
| 26308 |
mParent.requestLayout(); |
| 26309 |
} |
| 26310 |
if (mAttachInfo != null && mAttachInfo.mViewRequestingLayout == this) { |
| 26311 |
mAttachInfo.mViewRequestingLayout = null; |
| 26312 |
} |
| 26313 |
} |
| 26314 |
|
| 26315 |
|
| 26316 |
|
| 26317 |
|
| 26318 |
|
| 26319 |
|
| 26320 |
public void forceLayout() { |
| 26321 |
if (mMeasureCache != null) mMeasureCache.clear(); |
| 26322 |
|
| 26323 |
mPrivateFlags |= PFLAG_FORCE_LAYOUT; |
| 26324 |
mPrivateFlags |= PFLAG_INVALIDATED; |
| 26325 |
} |
| 26326 |
|
| 26327 |
|
| 26328 |
|
| 26329 |
|
| 26330 |
|
| 26331 |
|
| 26332 |
|
| 26333 |
|
| 26334 |
|
| 26335 |
|
| 26336 |
|
| 26337 |
|
| 26338 |
|
| 26339 |
|
| 26340 |
|
| 26341 |
|
| 26342 |
|
| 26343 |
|
| 26344 |
|
| 26345 |
|
| 26346 |
|
| 26347 |
public final void measure(int widthMeasureSpec, int heightMeasureSpec) { |
| 26348 |
boolean optical = isLayoutModeOptical(this); |
| 26349 |
if (optical != isLayoutModeOptical(mParent)) { |
| 26350 |
Insets insets = getOpticalInsets(); |
| 26351 |
int oWidth = insets.left + insets.right; |
| 26352 |
int oHeight = insets.top + insets.bottom; |
| 26353 |
widthMeasureSpec = MeasureSpec.adjust(widthMeasureSpec, optical ? -oWidth : oWidth); |
| 26354 |
heightMeasureSpec = MeasureSpec.adjust(heightMeasureSpec, optical ? -oHeight : oHeight); |
| 26355 |
} |
| 26356 |
|
| 26357 |
|
| 26358 |
long key = (long) widthMeasureSpec << 32 | (long) heightMeasureSpec & 0xffffffffL; |
| 26359 |
if (mMeasureCache == null) mMeasureCache = new LongSparseLongArray(2); |
| 26360 |
|
| 26361 |
final boolean forceLayout = (mPrivateFlags & PFLAG_FORCE_LAYOUT) == PFLAG_FORCE_LAYOUT; |
| 26362 |
|
| 26363 |
|
| 26364 |
|
| 26365 |
|
| 26366 |
final boolean specChanged = widthMeasureSpec != mOldWidthMeasureSpec |
| 26367 |
|| heightMeasureSpec != mOldHeightMeasureSpec; |
| 26368 |
final boolean isSpecExactly = MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.EXACTLY |
| 26369 |
&& MeasureSpec.getMode(heightMeasureSpec) == MeasureSpec.EXACTLY; |
| 26370 |
final boolean matchesSpecSize = getMeasuredWidth() == MeasureSpec.getSize(widthMeasureSpec) |
| 26371 |
&& getMeasuredHeight() == MeasureSpec.getSize(heightMeasureSpec); |
| 26372 |
final boolean needsLayout = specChanged |
| 26373 |
&& (sAlwaysRemeasureExactly || !isSpecExactly || !matchesSpecSize); |
| 26374 |
|
| 26375 |
if (forceLayout || needsLayout) { |
| 26376 |
|
| 26377 |
mPrivateFlags &= ~PFLAG_MEASURED_DIMENSION_SET; |
| 26378 |
|
| 26379 |
resolveRtlPropertiesIfNeeded(); |
| 26380 |
|
| 26381 |
int cacheIndex = forceLayout ? -1 : mMeasureCache.indexOfKey(key); |
| 26382 |
if (cacheIndex < 0 || sIgnoreMeasureCache) { |
| 26383 |
|
| 26384 |
onMeasure(widthMeasureSpec, heightMeasureSpec); |
| 26385 |
mPrivateFlags3 &= ~PFLAG3_MEASURE_NEEDED_BEFORE_LAYOUT; |
| 26386 |
} else { |
| 26387 |
long value = mMeasureCache.valueAt(cacheIndex); |
| 26388 |
|
| 26389 |
setMeasuredDimensionRaw((int) (value >> 32), (int) value); |
| 26390 |
mPrivateFlags3 |= PFLAG3_MEASURE_NEEDED_BEFORE_LAYOUT; |
| 26391 |
} |
| 26392 |
|
| 26393 |
|
| 26394 |
|
| 26395 |
if ((mPrivateFlags & PFLAG_MEASURED_DIMENSION_SET) != PFLAG_MEASURED_DIMENSION_SET) { |
| 26396 |
throw new IllegalStateException("View with id " + getId() + ": " |
| 26397 |
+ getClass().getName() + "#onMeasure() did not set the" |
| 26398 |
+ " measured dimension by calling" |
| 26399 |
+ " setMeasuredDimension()"); |
| 26400 |
} |
| 26401 |
|
| 26402 |
mPrivateFlags |= PFLAG_LAYOUT_REQUIRED; |
| 26403 |
} |
| 26404 |
|
| 26405 |
mOldWidthMeasureSpec = widthMeasureSpec; |
| 26406 |
mOldHeightMeasureSpec = heightMeasureSpec; |
| 26407 |
|
| 26408 |
mMeasureCache.put(key, ((long) mMeasuredWidth) << 32 | |
| 26409 |
(long) mMeasuredHeight & 0xffffffffL); |
| 26410 |
} |
| 26411 |
|
| 26412 |
|
| 26413 |
|
| 26414 |
|
| 26415 |
|
| 26416 |
|
| 26417 |
|
| 26418 |
|
| 26419 |
|
| 26420 |
|
| 26421 |
|
| 26422 |
|
| 26423 |
|
| 26424 |
|
| 26425 |
|
| 26426 |
|
| 26427 |
|
| 26428 |
|
| 26429 |
|
| 26430 |
|
| 26431 |
|
| 26432 |
|
| 26433 |
|
| 26434 |
|
| 26435 |
|
| 26436 |
|
| 26437 |
|
| 26438 |
|
| 26439 |
|
| 26440 |
|
| 26441 |
|
| 26442 |
|
| 26443 |
|
| 26444 |
|
| 26445 |
|
| 26446 |
|
| 26447 |
|
| 26448 |
|
| 26449 |
|
| 26450 |
|
| 26451 |
|
| 26452 |
|
| 26453 |
|
| 26454 |
|
| 26455 |
|
| 26456 |
|
| 26457 |
|
| 26458 |
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { |
| 26459 |
setMeasuredDimension(getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec), |
| 26460 |
getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec)); |
| 26461 |
} |
| 26462 |
|
| 26463 |
|
| 26464 |
|
| 26465 |
|
| 26466 |
|
| 26467 |
|
| 26468 |
|
| 26469 |
|
| 26470 |
|
| 26471 |
|
| 26472 |
|
| 26473 |
|
| 26474 |
|
| 26475 |
protected final void setMeasuredDimension(int measuredWidth, int measuredHeight) { |
| 26476 |
boolean optical = isLayoutModeOptical(this); |
| 26477 |
if (optical != isLayoutModeOptical(mParent)) { |
| 26478 |
Insets insets = getOpticalInsets(); |
| 26479 |
int opticalWidth = insets.left + insets.right; |
| 26480 |
int opticalHeight = insets.top + insets.bottom; |
| 26481 |
|
| 26482 |
measuredWidth += optical ? opticalWidth : -opticalWidth; |
| 26483 |
measuredHeight += optical ? opticalHeight : -opticalHeight; |
| 26484 |
} |
| 26485 |
setMeasuredDimensionRaw(measuredWidth, measuredHeight); |
| 26486 |
} |
| 26487 |
|
| 26488 |
|
| 26489 |
|
| 26490 |
|
| 26491 |
|
| 26492 |
|
| 26493 |
|
| 26494 |
|
| 26495 |
|
| 26496 |
|
| 26497 |
|
| 26498 |
|
| 26499 |
|
| 26500 |
private void setMeasuredDimensionRaw(int measuredWidth, int measuredHeight) { |
| 26501 |
mMeasuredWidth = measuredWidth; |
| 26502 |
mMeasuredHeight = measuredHeight; |
| 26503 |
|
| 26504 |
mPrivateFlags |= PFLAG_MEASURED_DIMENSION_SET; |
| 26505 |
} |
| 26506 |
|
| 26507 |
|
| 26508 |
|
| 26509 |
|
| 26510 |
|
| 26511 |
|
| 26512 |
|
| 26513 |
|
| 26514 |
|
| 26515 |
public static int combineMeasuredStates(int curState, int newState) { |
| 26516 |
return curState | newState; |
| 26517 |
} |
| 26518 |
|
| 26519 |
|
| 26520 |
|
| 26521 |
|
| 26522 |
|
| 26523 |
public static int resolveSize(int size, int measureSpec) { |
| 26524 |
return resolveSizeAndState(size, measureSpec, 0) & MEASURED_SIZE_MASK; |
| 26525 |
} |
| 26526 |
|
| 26527 |
|
| 26528 |
|
| 26529 |
|
| 26530 |
|
| 26531 |
|
| 26532 |
|
| 26533 |
|
| 26534 |
|
| 26535 |
|
| 26536 |
|
| 26537 |
|
| 26538 |
|
| 26539 |
|
| 26540 |
|
| 26541 |
|
| 26542 |
|
| 26543 |
public static int resolveSizeAndState(int size, int measureSpec, int childMeasuredState) { |
| 26544 |
final int specMode = MeasureSpec.getMode(measureSpec); |
| 26545 |
final int specSize = MeasureSpec.getSize(measureSpec); |
| 26546 |
final int result; |
| 26547 |
switch (specMode) { |
| 26548 |
case MeasureSpec.AT_MOST: |
| 26549 |
if (specSize < size) { |
| 26550 |
result = specSize | MEASURED_STATE_TOO_SMALL; |
| 26551 |
} else { |
| 26552 |
result = size; |
| 26553 |
} |
| 26554 |
break; |
| 26555 |
case MeasureSpec.EXACTLY: |
| 26556 |
result = specSize; |
| 26557 |
break; |
| 26558 |
case MeasureSpec.UNSPECIFIED: |
| 26559 |
default: |
| 26560 |
result = size; |
| 26561 |
} |
| 26562 |
return result | (childMeasuredState & MEASURED_STATE_MASK); |
| 26563 |
} |
| 26564 |
|
| 26565 |
|
| 26566 |
|
| 26567 |
|
| 26568 |
|
| 26569 |
|
| 26570 |
|
| 26571 |
|
| 26572 |
|
| 26573 |
|
| 26574 |
public static int getDefaultSize(int size, int measureSpec) { |
| 26575 |
int result = size; |
| 26576 |
int specMode = MeasureSpec.getMode(measureSpec); |
| 26577 |
int specSize = MeasureSpec.getSize(measureSpec); |
| 26578 |
|
| 26579 |
switch (specMode) { |
| 26580 |
case MeasureSpec.UNSPECIFIED: |
| 26581 |
result = size; |
| 26582 |
break; |
| 26583 |
case MeasureSpec.AT_MOST: |
| 26584 |
case MeasureSpec.EXACTLY: |
| 26585 |
result = specSize; |
| 26586 |
break; |
| 26587 |
} |
| 26588 |
return result; |
| 26589 |
} |
| 26590 |
|
| 26591 |
|
| 26592 |
|
| 26593 |
|
| 26594 |
|
| 26595 |
|
| 26596 |
|
| 26597 |
|
| 26598 |
|
| 26599 |
|
| 26600 |
|
| 26601 |
|
| 26602 |
protected int getSuggestedMinimumHeight() { |
| 26603 |
return (mBackground == null) ? mMinHeight : max(mMinHeight, mBackground.getMinimumHeight()); |
| 26604 |
|
| 26605 |
} |
| 26606 |
|
| 26607 |
|
| 26608 |
|
| 26609 |
|
| 26610 |
|
| 26611 |
|
| 26612 |
|
| 26613 |
|
| 26614 |
|
| 26615 |
|
| 26616 |
|
| 26617 |
|
| 26618 |
protected int getSuggestedMinimumWidth() { |
| 26619 |
return (mBackground == null) ? mMinWidth : max(mMinWidth, mBackground.getMinimumWidth()); |
| 26620 |
} |
| 26621 |
|
| 26622 |
|
| 26623 |
|
| 26624 |
|
| 26625 |
|
| 26626 |
|
| 26627 |
|
| 26628 |
|
| 26629 |
|
| 26630 |
|
| 26631 |
@InspectableProperty(name = "minHeight") |
| 26632 |
public int getMinimumHeight() { |
| 26633 |
return mMinHeight; |
| 26634 |
} |
| 26635 |
|
| 26636 |
|
| 26637 |
|
| 26638 |
|
| 26639 |
|
| 26640 |
|
| 26641 |
|
| 26642 |
|
| 26643 |
|
| 26644 |
|
| 26645 |
|
| 26646 |
|
| 26647 |
@RemotableViewMethod |
| 26648 |
public void setMinimumHeight(int minHeight) { |
| 26649 |
mMinHeight = minHeight; |
| 26650 |
requestLayout(); |
| 26651 |
} |
| 26652 |
|
| 26653 |
|
| 26654 |
|
| 26655 |
|
| 26656 |
|
| 26657 |
|
| 26658 |
|
| 26659 |
|
| 26660 |
|
| 26661 |
|
| 26662 |
@InspectableProperty(name = "minWidth") |
| 26663 |
public int getMinimumWidth() { |
| 26664 |
return mMinWidth; |
| 26665 |
} |
| 26666 |
|
| 26667 |
|
| 26668 |
|
| 26669 |
|
| 26670 |
|
| 26671 |
|
| 26672 |
|
| 26673 |
|
| 26674 |
|
| 26675 |
|
| 26676 |
|
| 26677 |
|
| 26678 |
@RemotableViewMethod |
| 26679 |
public void setMinimumWidth(int minWidth) { |
| 26680 |
mMinWidth = minWidth; |
| 26681 |
requestLayout(); |
| 26682 |
|
| 26683 |
} |
| 26684 |
|
| 26685 |
|
| 26686 |
|
| 26687 |
|
| 26688 |
|
| 26689 |
|
| 26690 |
|
| 26691 |
public Animation getAnimation() { |
| 26692 |
return mCurrentAnimation; |
| 26693 |
} |
| 26694 |
|
| 26695 |
|
| 26696 |
|
| 26697 |
|
| 26698 |
|
| 26699 |
|
| 26700 |
public void startAnimation(Animation animation) { |
| 26701 |
animation.setStartTime(Animation.START_ON_FIRST_FRAME); |
| 26702 |
setAnimation(animation); |
| 26703 |
invalidateParentCaches(); |
| 26704 |
invalidate(true); |
| 26705 |
} |
| 26706 |
|
| 26707 |
|
| 26708 |
|
| 26709 |
|
| 26710 |
public void clearAnimation() { |
| 26711 |
if (mCurrentAnimation != null) { |
| 26712 |
mCurrentAnimation.detach(); |
| 26713 |
} |
| 26714 |
mCurrentAnimation = null; |
| 26715 |
invalidateParentIfNeeded(); |
| 26716 |
} |
| 26717 |
|
| 26718 |
|
| 26719 |
|
| 26720 |
|
| 26721 |
|
| 26722 |
|
| 26723 |
|
| 26724 |
|
| 26725 |
|
| 26726 |
|
| 26727 |
|
| 26728 |
|
| 26729 |
|
| 26730 |
|
| 26731 |
public void setAnimation(Animation animation) { |
| 26732 |
mCurrentAnimation = animation; |
| 26733 |
|
| 26734 |
if (animation != null) { |
| 26735 |
|
| 26736 |
|
| 26737 |
|
| 26738 |
if (mAttachInfo != null && mAttachInfo.mDisplayState == Display.STATE_OFF |
| 26739 |
&& animation.getStartTime() == Animation.START_ON_FIRST_FRAME) { |
| 26740 |
animation.setStartTime(AnimationUtils.currentAnimationTimeMillis()); |
| 26741 |
} |
| 26742 |
animation.reset(); |
| 26743 |
} |
| 26744 |
} |
| 26745 |
|
| 26746 |
|
| 26747 |
|
| 26748 |
|
| 26749 |
|
| 26750 |
|
| 26751 |
|
| 26752 |
|
| 26753 |
|
| 26754 |
@CallSuper |
| 26755 |
protected void onAnimationStart() { |
| 26756 |
mPrivateFlags |= PFLAG_ANIMATION_STARTED; |
| 26757 |
} |
| 26758 |
|
| 26759 |
|
| 26760 |
|
| 26761 |
|
| 26762 |
|
| 26763 |
|
| 26764 |
|
| 26765 |
|
| 26766 |
|
| 26767 |
@CallSuper |
| 26768 |
protected void onAnimationEnd() { |
| 26769 |
mPrivateFlags &= ~PFLAG_ANIMATION_STARTED; |
| 26770 |
} |
| 26771 |
|
| 26772 |
|
| 26773 |
|
| 26774 |
|
| 26775 |
|
| 26776 |
|
| 26777 |
|
| 26778 |
|
| 26779 |
|
| 26780 |
|
| 26781 |
|
| 26782 |
|
| 26783 |
protected boolean onSetAlpha(int alpha) { |
| 26784 |
return false; |
| 26785 |
} |
| 26786 |
|
| 26787 |
|
| 26788 |
|
| 26789 |
|
| 26790 |
|
| 26791 |
|
| 26792 |
|
| 26793 |
|
| 26794 |
|
| 26795 |
|
| 26796 |
|
| 26797 |
|
| 26798 |
|
| 26799 |
|
| 26800 |
|
| 26801 |
public boolean gatherTransparentRegion(@Nullable Region region) { |
| 26802 |
final AttachInfo attachInfo = mAttachInfo; |
| 26803 |
if (region != null && attachInfo != null) { |
| 26804 |
final int pflags = mPrivateFlags; |
| 26805 |
if ((pflags & PFLAG_SKIP_DRAW) == 0) { |
| 26806 |
|
| 26807 |
|
| 26808 |
final int[] location = attachInfo.mTransparentLocation; |
| 26809 |
getLocationInWindow(location); |
| 26810 |
|
| 26811 |
|
| 26812 |
|
| 26813 |
|
| 26814 |
int shadowOffset = getZ() > 0 ? (int) getZ() : 0; |
| 26815 |
region.op(location[0] - shadowOffset, location[1] - shadowOffset, |
| 26816 |
location[0] + mRight - mLeft + shadowOffset, |
| 26817 |
location[1] + mBottom - mTop + (shadowOffset * 3), Region.Op.DIFFERENCE); |
| 26818 |
} else { |
| 26819 |
if (mBackground != null && mBackground.getOpacity() != PixelFormat.TRANSPARENT) { |
| 26820 |
|
| 26821 |
|
| 26822 |
applyDrawableToTransparentRegion(mBackground, region); |
| 26823 |
} |
| 26824 |
if (mForegroundInfo != null && mForegroundInfo.mDrawable != null |
| 26825 |
&& mForegroundInfo.mDrawable.getOpacity() != PixelFormat.TRANSPARENT) { |
| 26826 |
|
| 26827 |
applyDrawableToTransparentRegion(mForegroundInfo.mDrawable, region); |
| 26828 |
} |
| 26829 |
if (mDefaultFocusHighlight != null |
| 26830 |
&& mDefaultFocusHighlight.getOpacity() != PixelFormat.TRANSPARENT) { |
| 26831 |
|
| 26832 |
applyDrawableToTransparentRegion(mDefaultFocusHighlight, region); |
| 26833 |
} |
| 26834 |
} |
| 26835 |
} |
| 26836 |
return true; |
| 26837 |
} |
| 26838 |
|
| 26839 |
|
| 26840 |
|
| 26841 |
|
| 26842 |
|
| 26843 |
|
| 26844 |
|
| 26845 |
|
| 26846 |
|
| 26847 |
|
| 26848 |
|
| 26849 |
|
| 26850 |
|
| 26851 |
public void playSoundEffect(@SoundEffectConstants.SoundEffect int soundConstant) { |
| 26852 |
if (mAttachInfo == null || mAttachInfo.mRootCallbacks == null || !isSoundEffectsEnabled()) { |
| 26853 |
return; |
| 26854 |
} |
| 26855 |
mAttachInfo.mRootCallbacks.playSoundEffect(soundConstant); |
| 26856 |
} |
| 26857 |
|
| 26858 |
|
| 26859 |
|
| 26860 |
|
| 26861 |
|
| 26862 |
|
| 26863 |
|
| 26864 |
|
| 26865 |
|
| 26866 |
|
| 26867 |
|
| 26868 |
|
| 26869 |
|
| 26870 |
|
| 26871 |
|
| 26872 |
|
| 26873 |
public boolean performHapticFeedback(int feedbackConstant) { |
| 26874 |
return performHapticFeedback(feedbackConstant, 0); |
| 26875 |
} |
| 26876 |
|
| 26877 |
|
| 26878 |
|
| 26879 |
|
| 26880 |
|
| 26881 |
|
| 26882 |
|
| 26883 |
|
| 26884 |
|
| 26885 |
|
| 26886 |
public boolean performHapticFeedback(int feedbackConstant, int flags) { |
| 26887 |
if (mAttachInfo == null) { |
| 26888 |
return false; |
| 26889 |
} |
| 26890 |
|
| 26891 |
if ((flags & HapticFeedbackConstants.FLAG_IGNORE_VIEW_SETTING) == 0 |
| 26892 |
&& !isHapticFeedbackEnabled()) { |
| 26893 |
return false; |
| 26894 |
} |
| 26895 |
return mAttachInfo.mRootCallbacks.performHapticFeedback(feedbackConstant, |
| 26896 |
(flags & HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING) != 0); |
| 26897 |
} |
| 26898 |
|
| 26899 |
|
| 26900 |
|
| 26901 |
|
| 26902 |
|
| 26903 |
|
| 26904 |
|
| 26905 |
|
| 26906 |
|
| 26907 |
|
| 26908 |
|
| 26909 |
|
| 26910 |
|
| 26911 |
|
| 26912 |
|
| 26913 |
|
| 26914 |
|
| 26915 |
|
| 26916 |
|
| 26917 |
|
| 26918 |
|
| 26919 |
|
| 26920 |
|
| 26921 |
|
| 26922 |
|
| 26923 |
|
| 26924 |
|
| 26925 |
|
| 26926 |
|
| 26927 |
|
| 26928 |
|
| 26929 |
|
| 26930 |
|
| 26931 |
|
| 26932 |
|
| 26933 |
|
| 26934 |
|
| 26935 |
|
| 26936 |
|
| 26937 |
|
| 26938 |
|
| 26939 |
|
| 26940 |
|
| 26941 |
|
| 26942 |
|
| 26943 |
|
| 26944 |
|
| 26945 |
|
| 26946 |
|
| 26947 |
|
| 26948 |
@Deprecated |
| 26949 |
public void setSystemUiVisibility(int visibility) { |
| 26950 |
if (visibility != mSystemUiVisibility) { |
| 26951 |
mSystemUiVisibility = visibility; |
| 26952 |
if (mParent != null && mAttachInfo != null && !mAttachInfo.mRecomputeGlobalAttributes) { |
| 26953 |
mParent.recomputeViewAttributes(this); |
| 26954 |
} |
| 26955 |
} |
| 26956 |
} |
| 26957 |
|
| 26958 |
|
| 26959 |
|
| 26960 |
|
| 26961 |
|
| 26962 |
|
| 26963 |
|
| 26964 |
|
| 26965 |
|
| 26966 |
|
| 26967 |
|
| 26968 |
|
| 26969 |
@Deprecated |
| 26970 |
public int getSystemUiVisibility() { |
| 26971 |
return mSystemUiVisibility; |
| 26972 |
} |
| 26973 |
|
| 26974 |
|
| 26975 |
|
| 26976 |
|
| 26977 |
|
| 26978 |
|
| 26979 |
|
| 26980 |
|
| 26981 |
|
| 26982 |
|
| 26983 |
@Deprecated |
| 26984 |
public int getWindowSystemUiVisibility() { |
| 26985 |
return mAttachInfo != null ? mAttachInfo.mSystemUiVisibility : 0; |
| 26986 |
} |
| 26987 |
|
| 26988 |
|
| 26989 |
|
| 26990 |
|
| 26991 |
|
| 26992 |
|
| 26993 |
|
| 26994 |
|
| 26995 |
|
| 26996 |
|
| 26997 |
|
| 26998 |
|
| 26999 |
@Deprecated |
| 27000 |
public void onWindowSystemUiVisibilityChanged(int visible) { |
| 27001 |
} |
| 27002 |
|
| 27003 |
|
| 27004 |
|
| 27005 |
|
| 27006 |
|
| 27007 |
|
| 27008 |
|
| 27009 |
|
| 27010 |
@Deprecated |
| 27011 |
public void dispatchWindowSystemUiVisiblityChanged(int visible) { |
| 27012 |
onWindowSystemUiVisibilityChanged(visible); |
| 27013 |
} |
| 27014 |
|
| 27015 |
|
| 27016 |
|
| 27017 |
|
| 27018 |
|
| 27019 |
|
| 27020 |
|
| 27021 |
|
| 27022 |
@Deprecated |
| 27023 |
public void setOnSystemUiVisibilityChangeListener(OnSystemUiVisibilityChangeListener l) { |
| 27024 |
getListenerInfo().mOnSystemUiVisibilityChangeListener = l; |
| 27025 |
if (mParent != null && mAttachInfo != null && !mAttachInfo.mRecomputeGlobalAttributes) { |
| 27026 |
mParent.recomputeViewAttributes(this); |
| 27027 |
} |
| 27028 |
} |
| 27029 |
|
| 27030 |
|
| 27031 |
|
| 27032 |
|
| 27033 |
|
| 27034 |
|
| 27035 |
|
| 27036 |
|
| 27037 |
@Deprecated |
| 27038 |
public void dispatchSystemUiVisibilityChanged(int visibility) { |
| 27039 |
ListenerInfo li = mListenerInfo; |
| 27040 |
if (li != null && li.mOnSystemUiVisibilityChangeListener != null) { |
| 27041 |
li.mOnSystemUiVisibilityChangeListener.onSystemUiVisibilityChange( |
| 27042 |
visibility & PUBLIC_STATUS_BAR_VISIBILITY_MASK); |
| 27043 |
} |
| 27044 |
} |
| 27045 |
|
| 27046 |
boolean updateLocalSystemUiVisibility(int localValue, int localChanges) { |
| 27047 |
int val = (mSystemUiVisibility&~localChanges) | (localValue&localChanges); |
| 27048 |
if (val != mSystemUiVisibility) { |
| 27049 |
setSystemUiVisibility(val); |
| 27050 |
return true; |
| 27051 |
} |
| 27052 |
return false; |
| 27053 |
} |
| 27054 |
|
| 27055 |
|
| 27056 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 27057 |
public void setDisabledSystemUiVisibility(int flags) { |
| 27058 |
if (mAttachInfo != null) { |
| 27059 |
if (mAttachInfo.mDisabledSystemUiVisibility != flags) { |
| 27060 |
mAttachInfo.mDisabledSystemUiVisibility = flags; |
| 27061 |
if (mParent != null) { |
| 27062 |
mParent.recomputeViewAttributes(this); |
| 27063 |
} |
| 27064 |
} |
| 27065 |
} |
| 27066 |
} |
| 27067 |
|
| 27068 |
|
| 27069 |
|
| 27070 |
|
| 27071 |
|
| 27072 |
|
| 27073 |
public void onSystemBarAppearanceChanged(@WindowInsetsController.Appearance int appearance) { |
| 27074 |
} |
| 27075 |
|
| 27076 |
|
| 27077 |
|
| 27078 |
|
| 27079 |
|
| 27080 |
|
| 27081 |
|
| 27082 |
|
| 27083 |
|
| 27084 |
|
| 27085 |
|
| 27086 |
|
| 27087 |
|
| 27088 |
|
| 27089 |
|
| 27090 |
|
| 27091 |
|
| 27092 |
|
| 27093 |
|
| 27094 |
|
| 27095 |
|
| 27096 |
|
| 27097 |
|
| 27098 |
|
| 27099 |
|
| 27100 |
|
| 27101 |
|
| 27102 |
|
| 27103 |
|
| 27104 |
public static class DragShadowBuilder { |
| 27105 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 27106 |
private final WeakReference<View> mView; |
| 27107 |
|
| 27108 |
|
| 27109 |
|
| 27110 |
|
| 27111 |
|
| 27112 |
|
| 27113 |
|
| 27114 |
public DragShadowBuilder(View view) { |
| 27115 |
mView = new WeakReference<View>(view); |
| 27116 |
} |
| 27117 |
|
| 27118 |
|
| 27119 |
|
| 27120 |
|
| 27121 |
|
| 27122 |
|
| 27123 |
|
| 27124 |
|
| 27125 |
public DragShadowBuilder() { |
| 27126 |
mView = new WeakReference<View>(null); |
| 27127 |
} |
| 27128 |
|
| 27129 |
|
| 27130 |
|
| 27131 |
|
| 27132 |
|
| 27133 |
|
| 27134 |
|
| 27135 |
|
| 27136 |
|
| 27137 |
|
| 27138 |
|
| 27139 |
@SuppressWarnings({"JavadocReference"}) |
| 27140 |
final public View getView() { |
| 27141 |
return mView.get(); |
| 27142 |
} |
| 27143 |
|
| 27144 |
|
| 27145 |
|
| 27146 |
|
| 27147 |
|
| 27148 |
|
| 27149 |
|
| 27150 |
|
| 27151 |
|
| 27152 |
|
| 27153 |
|
| 27154 |
|
| 27155 |
|
| 27156 |
|
| 27157 |
|
| 27158 |
|
| 27159 |
|
| 27160 |
|
| 27161 |
|
| 27162 |
|
| 27163 |
|
| 27164 |
public void onProvideShadowMetrics(Point outShadowSize, Point outShadowTouchPoint) { |
| 27165 |
final View view = mView.get(); |
| 27166 |
if (view != null) { |
| 27167 |
outShadowSize.set(view.getWidth(), view.getHeight()); |
| 27168 |
outShadowTouchPoint.set(outShadowSize.x / 2, outShadowSize.y / 2); |
| 27169 |
} else { |
| 27170 |
Log.e(View.VIEW_LOG_TAG, "Asked for drag thumb metrics but no view"); |
| 27171 |
} |
| 27172 |
} |
| 27173 |
|
| 27174 |
|
| 27175 |
|
| 27176 |
|
| 27177 |
|
| 27178 |
|
| 27179 |
|
| 27180 |
|
| 27181 |
public void onDrawShadow(Canvas canvas) { |
| 27182 |
final View view = mView.get(); |
| 27183 |
if (view != null) { |
| 27184 |
view.draw(canvas); |
| 27185 |
} else { |
| 27186 |
Log.e(View.VIEW_LOG_TAG, "Asked to draw drag shadow but no view"); |
| 27187 |
} |
| 27188 |
} |
| 27189 |
} |
| 27190 |
|
| 27191 |
|
| 27192 |
|
| 27193 |
|
| 27194 |
|
| 27195 |
@Deprecated |
| 27196 |
public final boolean startDrag(ClipData data, DragShadowBuilder shadowBuilder, |
| 27197 |
Object myLocalState, int flags) { |
| 27198 |
return startDragAndDrop(data, shadowBuilder, myLocalState, flags); |
| 27199 |
} |
| 27200 |
|
| 27201 |
|
| 27202 |
|
| 27203 |
|
| 27204 |
|
| 27205 |
|
| 27206 |
|
| 27207 |
|
| 27208 |
|
| 27209 |
|
| 27210 |
|
| 27211 |
|
| 27212 |
|
| 27213 |
|
| 27214 |
|
| 27215 |
|
| 27216 |
|
| 27217 |
|
| 27218 |
|
| 27219 |
|
| 27220 |
|
| 27221 |
|
| 27222 |
|
| 27223 |
|
| 27224 |
|
| 27225 |
|
| 27226 |
|
| 27227 |
|
| 27228 |
|
| 27229 |
|
| 27230 |
|
| 27231 |
|
| 27232 |
|
| 27233 |
|
| 27234 |
|
| 27235 |
|
| 27236 |
|
| 27237 |
|
| 27238 |
|
| 27239 |
|
| 27240 |
|
| 27241 |
|
| 27242 |
|
| 27243 |
|
| 27244 |
|
| 27245 |
|
| 27246 |
|
| 27247 |
|
| 27248 |
|
| 27249 |
|
| 27250 |
|
| 27251 |
|
| 27252 |
public final boolean startDragAndDrop(ClipData data, DragShadowBuilder shadowBuilder, |
| 27253 |
Object myLocalState, int flags) { |
| 27254 |
if (ViewDebug.DEBUG_DRAG) { |
| 27255 |
Log.d(VIEW_LOG_TAG, "startDragAndDrop: data=" + data + " flags=" + flags); |
| 27256 |
} |
| 27257 |
if (mAttachInfo == null) { |
| 27258 |
Log.w(VIEW_LOG_TAG, "startDragAndDrop called on a detached view."); |
| 27259 |
return false; |
| 27260 |
} |
| 27261 |
if (!mAttachInfo.mViewRootImpl.mSurface.isValid()) { |
| 27262 |
Log.w(VIEW_LOG_TAG, "startDragAndDrop called with an invalid surface."); |
| 27263 |
return false; |
| 27264 |
} |
| 27265 |
|
| 27266 |
if (data != null) { |
| 27267 |
data.prepareToLeaveProcess((flags & View.DRAG_FLAG_GLOBAL) != 0); |
| 27268 |
} |
| 27269 |
|
| 27270 |
Rect bounds = new Rect(); |
| 27271 |
getBoundsOnScreen(bounds, true); |
| 27272 |
|
| 27273 |
Point lastTouchPoint = new Point(); |
| 27274 |
mAttachInfo.mViewRootImpl.getLastTouchPoint(lastTouchPoint); |
| 27275 |
final ViewRootImpl root = mAttachInfo.mViewRootImpl; |
| 27276 |
|
| 27277 |
|
| 27278 |
final boolean a11yEnabled = AccessibilityManager.getInstance(mContext).isEnabled(); |
| 27279 |
if (a11yEnabled && (flags & View.DRAG_FLAG_ACCESSIBILITY_ACTION) != 0) { |
| 27280 |
try { |
| 27281 |
IBinder token = mAttachInfo.mSession.performDrag( |
| 27282 |
mAttachInfo.mWindow, flags, null, |
| 27283 |
mAttachInfo.mViewRootImpl.getLastTouchSource(), |
| 27284 |
0f, 0f, 0f, 0f, data); |
| 27285 |
if (ViewDebug.DEBUG_DRAG) { |
| 27286 |
Log.d(VIEW_LOG_TAG, "startDragAndDrop via a11y action returned " + token); |
| 27287 |
} |
| 27288 |
if (token != null) { |
| 27289 |
root.setLocalDragState(myLocalState); |
| 27290 |
mAttachInfo.mDragToken = token; |
| 27291 |
mAttachInfo.mViewRootImpl.setDragStartedViewForAccessibility(this); |
| 27292 |
setAccessibilityDragStarted(true); |
| 27293 |
} |
| 27294 |
return token != null; |
| 27295 |
} catch (Exception e) { |
| 27296 |
Log.e(VIEW_LOG_TAG, "Unable to initiate a11y drag", e); |
| 27297 |
return false; |
| 27298 |
} |
| 27299 |
} |
| 27300 |
|
| 27301 |
Point shadowSize = new Point(); |
| 27302 |
Point shadowTouchPoint = new Point(); |
| 27303 |
shadowBuilder.onProvideShadowMetrics(shadowSize, shadowTouchPoint); |
| 27304 |
|
| 27305 |
if ((shadowSize.x < 0) || (shadowSize.y < 0) |
| 27306 |
|| (shadowTouchPoint.x < 0) || (shadowTouchPoint.y < 0)) { |
| 27307 |
throw new IllegalStateException("Drag shadow dimensions must not be negative"); |
| 27308 |
} |
| 27309 |
|
| 27310 |
|
| 27311 |
|
| 27312 |
if (shadowSize.x == 0 || shadowSize.y == 0) { |
| 27313 |
if (!sAcceptZeroSizeDragShadow) { |
| 27314 |
throw new IllegalStateException("Drag shadow dimensions must be positive"); |
| 27315 |
} |
| 27316 |
shadowSize.x = 1; |
| 27317 |
shadowSize.y = 1; |
| 27318 |
} |
| 27319 |
|
| 27320 |
if (ViewDebug.DEBUG_DRAG) { |
| 27321 |
Log.d(VIEW_LOG_TAG, "drag shadow: width=" + shadowSize.x + " height=" + shadowSize.y |
| 27322 |
+ " shadowX=" + shadowTouchPoint.x + " shadowY=" + shadowTouchPoint.y); |
| 27323 |
} |
| 27324 |
|
| 27325 |
final SurfaceSession session = new SurfaceSession(); |
| 27326 |
final SurfaceControl surfaceControl = new SurfaceControl.Builder(session) |
| 27327 |
.setName("drag surface") |
| 27328 |
.setParent(root.getSurfaceControl()) |
| 27329 |
.setBufferSize(shadowSize.x, shadowSize.y) |
| 27330 |
.setFormat(PixelFormat.TRANSLUCENT) |
| 27331 |
.setCallsite("View.startDragAndDrop") |
| 27332 |
.build(); |
| 27333 |
final Surface surface = new Surface(); |
| 27334 |
surface.copyFrom(surfaceControl); |
| 27335 |
IBinder token = null; |
| 27336 |
try { |
| 27337 |
final Canvas canvas = isHardwareAccelerated() |
| 27338 |
? surface.lockHardwareCanvas() |
| 27339 |
: surface.lockCanvas(null); |
| 27340 |
try { |
| 27341 |
canvas.drawColor(0, PorterDuff.Mode.CLEAR); |
| 27342 |
shadowBuilder.onDrawShadow(canvas); |
| 27343 |
} finally { |
| 27344 |
surface.unlockCanvasAndPost(canvas); |
| 27345 |
} |
| 27346 |
|
| 27347 |
token = mAttachInfo.mSession.performDrag(mAttachInfo.mWindow, flags, surfaceControl, |
| 27348 |
root.getLastTouchSource(), lastTouchPoint.x, lastTouchPoint.y, |
| 27349 |
shadowTouchPoint.x, shadowTouchPoint.y, data); |
| 27350 |
if (ViewDebug.DEBUG_DRAG) { |
| 27351 |
Log.d(VIEW_LOG_TAG, "performDrag returned " + token); |
| 27352 |
} |
| 27353 |
if (token != null) { |
| 27354 |
if (mAttachInfo.mDragSurface != null) { |
| 27355 |
mAttachInfo.mDragSurface.release(); |
| 27356 |
} |
| 27357 |
mAttachInfo.mDragSurface = surface; |
| 27358 |
mAttachInfo.mDragToken = token; |
| 27359 |
|
| 27360 |
root.setLocalDragState(myLocalState); |
| 27361 |
if (a11yEnabled) { |
| 27362 |
|
| 27363 |
mAttachInfo.mViewRootImpl.setDragStartedViewForAccessibility(this); |
| 27364 |
} |
| 27365 |
} |
| 27366 |
return token != null; |
| 27367 |
} catch (Exception e) { |
| 27368 |
Log.e(VIEW_LOG_TAG, "Unable to initiate drag", e); |
| 27369 |
return false; |
| 27370 |
} finally { |
| 27371 |
if (token == null) { |
| 27372 |
surface.destroy(); |
| 27373 |
} |
| 27374 |
session.kill(); |
| 27375 |
} |
| 27376 |
} |
| 27377 |
|
| 27378 |
void setAccessibilityDragStarted(boolean started) { |
| 27379 |
int pflags4 = mPrivateFlags4; |
| 27380 |
if (started) { |
| 27381 |
pflags4 |= PFLAG4_DRAG_A11Y_STARTED; |
| 27382 |
} else { |
| 27383 |
pflags4 &= ~PFLAG4_DRAG_A11Y_STARTED; |
| 27384 |
} |
| 27385 |
|
| 27386 |
if (pflags4 != mPrivateFlags4) { |
| 27387 |
mPrivateFlags4 = pflags4; |
| 27388 |
sendWindowContentChangedAccessibilityEvent(CONTENT_CHANGE_TYPE_UNDEFINED); |
| 27389 |
} |
| 27390 |
} |
| 27391 |
|
| 27392 |
private boolean startedSystemDragForAccessibility() { |
| 27393 |
return (mPrivateFlags4 & PFLAG4_DRAG_A11Y_STARTED) != 0; |
| 27394 |
} |
| 27395 |
|
| 27396 |
|
| 27397 |
|
| 27398 |
|
| 27399 |
|
| 27400 |
|
| 27401 |
|
| 27402 |
|
| 27403 |
|
| 27404 |
|
| 27405 |
|
| 27406 |
|
| 27407 |
|
| 27408 |
|
| 27409 |
|
| 27410 |
|
| 27411 |
|
| 27412 |
|
| 27413 |
public final void cancelDragAndDrop() { |
| 27414 |
if (ViewDebug.DEBUG_DRAG) { |
| 27415 |
Log.d(VIEW_LOG_TAG, "cancelDragAndDrop"); |
| 27416 |
} |
| 27417 |
if (mAttachInfo == null) { |
| 27418 |
Log.w(VIEW_LOG_TAG, "cancelDragAndDrop called on a detached view."); |
| 27419 |
return; |
| 27420 |
} |
| 27421 |
if (mAttachInfo.mDragToken != null) { |
| 27422 |
try { |
| 27423 |
mAttachInfo.mSession.cancelDragAndDrop(mAttachInfo.mDragToken, false); |
| 27424 |
} catch (Exception e) { |
| 27425 |
Log.e(VIEW_LOG_TAG, "Unable to cancel drag", e); |
| 27426 |
} |
| 27427 |
mAttachInfo.mDragToken = null; |
| 27428 |
} else { |
| 27429 |
Log.e(VIEW_LOG_TAG, "No active drag to cancel"); |
| 27430 |
} |
| 27431 |
} |
| 27432 |
|
| 27433 |
|
| 27434 |
|
| 27435 |
|
| 27436 |
|
| 27437 |
|
| 27438 |
|
| 27439 |
public final void updateDragShadow(DragShadowBuilder shadowBuilder) { |
| 27440 |
if (ViewDebug.DEBUG_DRAG) { |
| 27441 |
Log.d(VIEW_LOG_TAG, "updateDragShadow"); |
| 27442 |
} |
| 27443 |
if (mAttachInfo == null) { |
| 27444 |
Log.w(VIEW_LOG_TAG, "updateDragShadow called on a detached view."); |
| 27445 |
return; |
| 27446 |
} |
| 27447 |
if (mAttachInfo.mDragToken != null) { |
| 27448 |
try { |
| 27449 |
Canvas canvas = isHardwareAccelerated() |
| 27450 |
? mAttachInfo.mDragSurface.lockHardwareCanvas() |
| 27451 |
: mAttachInfo.mDragSurface.lockCanvas(null); |
| 27452 |
try { |
| 27453 |
canvas.drawColor(0, PorterDuff.Mode.CLEAR); |
| 27454 |
shadowBuilder.onDrawShadow(canvas); |
| 27455 |
} finally { |
| 27456 |
mAttachInfo.mDragSurface.unlockCanvasAndPost(canvas); |
| 27457 |
} |
| 27458 |
} catch (Exception e) { |
| 27459 |
Log.e(VIEW_LOG_TAG, "Unable to update drag shadow", e); |
| 27460 |
} |
| 27461 |
} else { |
| 27462 |
Log.e(VIEW_LOG_TAG, "No active drag"); |
| 27463 |
} |
| 27464 |
} |
| 27465 |
|
| 27466 |
|
| 27467 |
|
| 27468 |
|
| 27469 |
|
| 27470 |
|
| 27471 |
|
| 27472 |
|
| 27473 |
|
| 27474 |
public final boolean startMovingTask(float startX, float startY) { |
| 27475 |
if (ViewDebug.DEBUG_POSITIONING) { |
| 27476 |
Log.d(VIEW_LOG_TAG, "startMovingTask: {" + startX + "," + startY + "}"); |
| 27477 |
} |
| 27478 |
try { |
| 27479 |
return mAttachInfo.mSession.startMovingTask(mAttachInfo.mWindow, startX, startY); |
| 27480 |
} catch (RemoteException e) { |
| 27481 |
Log.e(VIEW_LOG_TAG, "Unable to start moving", e); |
| 27482 |
} |
| 27483 |
return false; |
| 27484 |
} |
| 27485 |
|
| 27486 |
|
| 27487 |
|
| 27488 |
|
| 27489 |
|
| 27490 |
public void finishMovingTask() { |
| 27491 |
if (ViewDebug.DEBUG_POSITIONING) { |
| 27492 |
Log.d(VIEW_LOG_TAG, "finishMovingTask"); |
| 27493 |
} |
| 27494 |
try { |
| 27495 |
mAttachInfo.mSession.finishMovingTask(mAttachInfo.mWindow); |
| 27496 |
} catch (RemoteException e) { |
| 27497 |
Log.e(VIEW_LOG_TAG, "Unable to finish moving", e); |
| 27498 |
} |
| 27499 |
} |
| 27500 |
|
| 27501 |
|
| 27502 |
|
| 27503 |
|
| 27504 |
|
| 27505 |
|
| 27506 |
|
| 27507 |
|
| 27508 |
|
| 27509 |
|
| 27510 |
|
| 27511 |
|
| 27512 |
|
| 27513 |
|
| 27514 |
|
| 27515 |
|
| 27516 |
|
| 27517 |
|
| 27518 |
|
| 27519 |
|
| 27520 |
|
| 27521 |
|
| 27522 |
|
| 27523 |
|
| 27524 |
|
| 27525 |
|
| 27526 |
|
| 27527 |
|
| 27528 |
|
| 27529 |
|
| 27530 |
|
| 27531 |
|
| 27532 |
|
| 27533 |
|
| 27534 |
|
| 27535 |
|
| 27536 |
|
| 27537 |
|
| 27538 |
public boolean onDragEvent(DragEvent event) { |
| 27539 |
if (mListenerInfo == null || mListenerInfo.mOnReceiveContentListener == null) { |
| 27540 |
return false; |
| 27541 |
} |
| 27542 |
|
| 27543 |
if (event.getAction() == DragEvent.ACTION_DRAG_STARTED) { |
| 27544 |
return true; |
| 27545 |
} |
| 27546 |
if (event.getAction() == DragEvent.ACTION_DROP) { |
| 27547 |
final DragAndDropPermissions permissions = DragAndDropPermissions.obtain(event); |
| 27548 |
if (permissions != null) { |
| 27549 |
permissions.takeTransient(); |
| 27550 |
} |
| 27551 |
final ContentInfo payload = |
| 27552 |
new ContentInfo.Builder(event.getClipData(), SOURCE_DRAG_AND_DROP) |
| 27553 |
.setDragAndDropPermissions(permissions) |
| 27554 |
.build(); |
| 27555 |
ContentInfo remainingPayload = performReceiveContent(payload); |
| 27556 |
|
| 27557 |
return remainingPayload != payload; |
| 27558 |
} |
| 27559 |
return false; |
| 27560 |
} |
| 27561 |
|
| 27562 |
|
| 27563 |
boolean dispatchDragEnterExitInPreN(DragEvent event) { |
| 27564 |
return callDragEventHandler(event); |
| 27565 |
} |
| 27566 |
|
| 27567 |
|
| 27568 |
|
| 27569 |
|
| 27570 |
|
| 27571 |
|
| 27572 |
|
| 27573 |
|
| 27574 |
|
| 27575 |
|
| 27576 |
|
| 27577 |
|
| 27578 |
|
| 27579 |
|
| 27580 |
|
| 27581 |
|
| 27582 |
|
| 27583 |
public boolean dispatchDragEvent(DragEvent event) { |
| 27584 |
event.mEventHandlerWasCalled = true; |
| 27585 |
if (event.mAction == DragEvent.ACTION_DRAG_LOCATION || |
| 27586 |
event.mAction == DragEvent.ACTION_DROP) { |
| 27587 |
|
| 27588 |
|
| 27589 |
getViewRootImpl().setDragFocus(this, event); |
| 27590 |
} |
| 27591 |
return callDragEventHandler(event); |
| 27592 |
} |
| 27593 |
|
| 27594 |
final boolean callDragEventHandler(DragEvent event) { |
| 27595 |
final boolean result; |
| 27596 |
|
| 27597 |
ListenerInfo li = mListenerInfo; |
| 27598 |
|
| 27599 |
if (li != null && li.mOnDragListener != null && (mViewFlags & ENABLED_MASK) == ENABLED |
| 27600 |
&& li.mOnDragListener.onDrag(this, event)) { |
| 27601 |
result = true; |
| 27602 |
} else { |
| 27603 |
result = onDragEvent(event); |
| 27604 |
} |
| 27605 |
|
| 27606 |
switch (event.mAction) { |
| 27607 |
case DragEvent.ACTION_DRAG_STARTED: { |
| 27608 |
if (result && li != null && li.mOnDragListener != null) { |
| 27609 |
sendWindowContentChangedAccessibilityEvent( |
| 27610 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 27611 |
} |
| 27612 |
} break; |
| 27613 |
case DragEvent.ACTION_DRAG_ENTERED: { |
| 27614 |
mPrivateFlags2 |= View.PFLAG2_DRAG_HOVERED; |
| 27615 |
refreshDrawableState(); |
| 27616 |
} break; |
| 27617 |
case DragEvent.ACTION_DRAG_EXITED: { |
| 27618 |
mPrivateFlags2 &= ~View.PFLAG2_DRAG_HOVERED; |
| 27619 |
refreshDrawableState(); |
| 27620 |
} break; |
| 27621 |
case DragEvent.ACTION_DROP: { |
| 27622 |
if (result && li != null && (li.mOnDragListener != null |
| 27623 |
|| li.mOnReceiveContentListener != null)) { |
| 27624 |
sendWindowContentChangedAccessibilityEvent( |
| 27625 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_DRAG_DROPPED); |
| 27626 |
} |
| 27627 |
} break; |
| 27628 |
case DragEvent.ACTION_DRAG_ENDED: { |
| 27629 |
sendWindowContentChangedAccessibilityEvent( |
| 27630 |
AccessibilityEvent.CONTENT_CHANGE_TYPE_UNDEFINED); |
| 27631 |
mPrivateFlags2 &= ~View.DRAG_MASK; |
| 27632 |
refreshDrawableState(); |
| 27633 |
} break; |
| 27634 |
} |
| 27635 |
|
| 27636 |
return result; |
| 27637 |
} |
| 27638 |
|
| 27639 |
boolean canAcceptDrag() { |
| 27640 |
return (mPrivateFlags2 & PFLAG2_DRAG_CAN_ACCEPT) != 0; |
| 27641 |
} |
| 27642 |
|
| 27643 |
void sendWindowContentChangedAccessibilityEvent(int changeType) { |
| 27644 |
if (AccessibilityManager.getInstance(mContext).isEnabled()) { |
| 27645 |
AccessibilityEvent event = AccessibilityEvent.obtain(); |
| 27646 |
event.setEventType(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED); |
| 27647 |
event.setContentChangeTypes(changeType); |
| 27648 |
sendAccessibilityEventUnchecked(event); |
| 27649 |
} |
| 27650 |
} |
| 27651 |
|
| 27652 |
|
| 27653 |
|
| 27654 |
|
| 27655 |
|
| 27656 |
|
| 27657 |
@UnsupportedAppUsage |
| 27658 |
public void onCloseSystemDialogs(String reason) { |
| 27659 |
} |
| 27660 |
|
| 27661 |
|
| 27662 |
|
| 27663 |
|
| 27664 |
|
| 27665 |
|
| 27666 |
|
| 27667 |
|
| 27668 |
|
| 27669 |
|
| 27670 |
|
| 27671 |
|
| 27672 |
|
| 27673 |
|
| 27674 |
|
| 27675 |
|
| 27676 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 27677 |
public void applyDrawableToTransparentRegion(Drawable dr, Region region) { |
| 27678 |
if (DBG) { |
| 27679 |
Log.i("View", "Getting transparent region for: " + this); |
| 27680 |
} |
| 27681 |
final Region r = dr.getTransparentRegion(); |
| 27682 |
final Rect db = dr.getBounds(); |
| 27683 |
final AttachInfo attachInfo = mAttachInfo; |
| 27684 |
if (r != null && attachInfo != null) { |
| 27685 |
final int w = getRight()-getLeft(); |
| 27686 |
final int h = getBottom()-getTop(); |
| 27687 |
if (db.left > 0) { |
| 27688 |
|
| 27689 |
r.op(0, 0, db.left, h, Region.Op.UNION); |
| 27690 |
} |
| 27691 |
if (db.right < w) { |
| 27692 |
|
| 27693 |
r.op(db.right, 0, w, h, Region.Op.UNION); |
| 27694 |
} |
| 27695 |
if (db.top > 0) { |
| 27696 |
|
| 27697 |
r.op(0, 0, w, db.top, Region.Op.UNION); |
| 27698 |
} |
| 27699 |
if (db.bottom < h) { |
| 27700 |
|
| 27701 |
r.op(0, db.bottom, w, h, Region.Op.UNION); |
| 27702 |
} |
| 27703 |
final int[] location = attachInfo.mTransparentLocation; |
| 27704 |
getLocationInWindow(location); |
| 27705 |
r.translate(location[0], location[1]); |
| 27706 |
region.op(r, Region.Op.INTERSECT); |
| 27707 |
} else { |
| 27708 |
region.op(db, Region.Op.DIFFERENCE); |
| 27709 |
} |
| 27710 |
} |
| 27711 |
|
| 27712 |
private void checkForLongClick(long delay, float x, float y, int classification) { |
| 27713 |
if ((mViewFlags & LONG_CLICKABLE) == LONG_CLICKABLE || (mViewFlags & TOOLTIP) == TOOLTIP) { |
| 27714 |
mHasPerformedLongPress = false; |
| 27715 |
|
| 27716 |
if (mPendingCheckForLongPress == null) { |
| 27717 |
mPendingCheckForLongPress = new CheckForLongPress(); |
| 27718 |
} |
| 27719 |
mPendingCheckForLongPress.setAnchor(x, y); |
| 27720 |
mPendingCheckForLongPress.rememberWindowAttachCount(); |
| 27721 |
mPendingCheckForLongPress.rememberPressedState(); |
| 27722 |
mPendingCheckForLongPress.setClassification(classification); |
| 27723 |
postDelayed(mPendingCheckForLongPress, delay); |
| 27724 |
} |
| 27725 |
} |
| 27726 |
|
| 27727 |
|
| 27728 |
|
| 27729 |
|
| 27730 |
|
| 27731 |
|
| 27732 |
|
| 27733 |
|
| 27734 |
|
| 27735 |
|
| 27736 |
|
| 27737 |
public static View inflate(Context context, @LayoutRes int resource, ViewGroup root) { |
| 27738 |
LayoutInflater factory = LayoutInflater.from(context); |
| 27739 |
return factory.inflate(resource, root); |
| 27740 |
} |
| 27741 |
|
| 27742 |
|
| 27743 |
|
| 27744 |
|
| 27745 |
|
| 27746 |
|
| 27747 |
|
| 27748 |
|
| 27749 |
|
| 27750 |
|
| 27751 |
|
| 27752 |
|
| 27753 |
|
| 27754 |
|
| 27755 |
|
| 27756 |
|
| 27757 |
|
| 27758 |
|
| 27759 |
|
| 27760 |
|
| 27761 |
|
| 27762 |
|
| 27763 |
|
| 27764 |
@SuppressWarnings({"UnusedParameters"}) |
| 27765 |
protected boolean overScrollBy(int deltaX, int deltaY, |
| 27766 |
int scrollX, int scrollY, |
| 27767 |
int scrollRangeX, int scrollRangeY, |
| 27768 |
int maxOverScrollX, int maxOverScrollY, |
| 27769 |
boolean isTouchEvent) { |
| 27770 |
final int overScrollMode = mOverScrollMode; |
| 27771 |
final boolean canScrollHorizontal = |
| 27772 |
computeHorizontalScrollRange() > computeHorizontalScrollExtent(); |
| 27773 |
final boolean canScrollVertical = |
| 27774 |
computeVerticalScrollRange() > computeVerticalScrollExtent(); |
| 27775 |
final boolean overScrollHorizontal = overScrollMode == OVER_SCROLL_ALWAYS || |
| 27776 |
(overScrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && canScrollHorizontal); |
| 27777 |
final boolean overScrollVertical = overScrollMode == OVER_SCROLL_ALWAYS || |
| 27778 |
(overScrollMode == OVER_SCROLL_IF_CONTENT_SCROLLS && canScrollVertical); |
| 27779 |
|
| 27780 |
int newScrollX = scrollX + deltaX; |
| 27781 |
if (!overScrollHorizontal) { |
| 27782 |
maxOverScrollX = 0; |
| 27783 |
} |
| 27784 |
|
| 27785 |
int newScrollY = scrollY + deltaY; |
| 27786 |
if (!overScrollVertical) { |
| 27787 |
maxOverScrollY = 0; |
| 27788 |
} |
| 27789 |
|
| 27790 |
|
| 27791 |
final int left = -maxOverScrollX; |
| 27792 |
final int right = maxOverScrollX + scrollRangeX; |
| 27793 |
final int top = -maxOverScrollY; |
| 27794 |
final int bottom = maxOverScrollY + scrollRangeY; |
| 27795 |
|
| 27796 |
boolean clampedX = false; |
| 27797 |
if (newScrollX > right) { |
| 27798 |
newScrollX = right; |
| 27799 |
clampedX = true; |
| 27800 |
} else if (newScrollX < left) { |
| 27801 |
newScrollX = left; |
| 27802 |
clampedX = true; |
| 27803 |
} |
| 27804 |
|
| 27805 |
boolean clampedY = false; |
| 27806 |
if (newScrollY > bottom) { |
| 27807 |
newScrollY = bottom; |
| 27808 |
clampedY = true; |
| 27809 |
} else if (newScrollY < top) { |
| 27810 |
newScrollY = top; |
| 27811 |
clampedY = true; |
| 27812 |
} |
| 27813 |
|
| 27814 |
onOverScrolled(newScrollX, newScrollY, clampedX, clampedY); |
| 27815 |
|
| 27816 |
return clampedX || clampedY; |
| 27817 |
} |
| 27818 |
|
| 27819 |
|
| 27820 |
|
| 27821 |
|
| 27822 |
|
| 27823 |
|
| 27824 |
|
| 27825 |
|
| 27826 |
|
| 27827 |
|
| 27828 |
protected void onOverScrolled(int scrollX, int scrollY, |
| 27829 |
boolean clampedX, boolean clampedY) { |
| 27830 |
|
| 27831 |
} |
| 27832 |
|
| 27833 |
|
| 27834 |
|
| 27835 |
|
| 27836 |
|
| 27837 |
|
| 27838 |
|
| 27839 |
|
| 27840 |
|
| 27841 |
@InspectableProperty(enumMapping = { |
| 27842 |
@EnumEntry(value = OVER_SCROLL_ALWAYS, name = "always"), |
| 27843 |
@EnumEntry(value = OVER_SCROLL_IF_CONTENT_SCROLLS, name = "ifContentScrolls"), |
| 27844 |
@EnumEntry(value = OVER_SCROLL_NEVER, name = "never") |
| 27845 |
}) |
| 27846 |
public int getOverScrollMode() { |
| 27847 |
return mOverScrollMode; |
| 27848 |
} |
| 27849 |
|
| 27850 |
|
| 27851 |
|
| 27852 |
|
| 27853 |
|
| 27854 |
|
| 27855 |
|
| 27856 |
|
| 27857 |
|
| 27858 |
|
| 27859 |
|
| 27860 |
|
| 27861 |
public void setOverScrollMode(int overScrollMode) { |
| 27862 |
if (overScrollMode != OVER_SCROLL_ALWAYS && |
| 27863 |
overScrollMode != OVER_SCROLL_IF_CONTENT_SCROLLS && |
| 27864 |
overScrollMode != OVER_SCROLL_NEVER) { |
| 27865 |
throw new IllegalArgumentException("Invalid overscroll mode " + overScrollMode); |
| 27866 |
} |
| 27867 |
mOverScrollMode = overScrollMode; |
| 27868 |
} |
| 27869 |
|
| 27870 |
|
| 27871 |
|
| 27872 |
|
| 27873 |
|
| 27874 |
|
| 27875 |
|
| 27876 |
|
| 27877 |
|
| 27878 |
|
| 27879 |
|
| 27880 |
|
| 27881 |
|
| 27882 |
|
| 27883 |
public void setNestedScrollingEnabled(boolean enabled) { |
| 27884 |
if (enabled) { |
| 27885 |
mPrivateFlags3 |= PFLAG3_NESTED_SCROLLING_ENABLED; |
| 27886 |
} else { |
| 27887 |
stopNestedScroll(); |
| 27888 |
mPrivateFlags3 &= ~PFLAG3_NESTED_SCROLLING_ENABLED; |
| 27889 |
} |
| 27890 |
} |
| 27891 |
|
| 27892 |
|
| 27893 |
|
| 27894 |
|
| 27895 |
|
| 27896 |
|
| 27897 |
|
| 27898 |
|
| 27899 |
|
| 27900 |
|
| 27901 |
|
| 27902 |
|
| 27903 |
|
| 27904 |
@InspectableProperty |
| 27905 |
public boolean isNestedScrollingEnabled() { |
| 27906 |
return (mPrivateFlags3 & PFLAG3_NESTED_SCROLLING_ENABLED) == |
| 27907 |
PFLAG3_NESTED_SCROLLING_ENABLED; |
| 27908 |
} |
| 27909 |
|
| 27910 |
|
| 27911 |
|
| 27912 |
|
| 27913 |
|
| 27914 |
|
| 27915 |
|
| 27916 |
|
| 27917 |
|
| 27918 |
|
| 27919 |
|
| 27920 |
|
| 27921 |
|
| 27922 |
|
| 27923 |
|
| 27924 |
|
| 27925 |
|
| 27926 |
|
| 27927 |
|
| 27928 |
|
| 27929 |
|
| 27930 |
|
| 27931 |
|
| 27932 |
|
| 27933 |
|
| 27934 |
|
| 27935 |
|
| 27936 |
|
| 27937 |
|
| 27938 |
|
| 27939 |
|
| 27940 |
|
| 27941 |
|
| 27942 |
|
| 27943 |
|
| 27944 |
|
| 27945 |
|
| 27946 |
|
| 27947 |
public boolean startNestedScroll(int axes) { |
| 27948 |
if (hasNestedScrollingParent()) { |
| 27949 |
|
| 27950 |
return true; |
| 27951 |
} |
| 27952 |
if (isNestedScrollingEnabled()) { |
| 27953 |
ViewParent p = getParent(); |
| 27954 |
View child = this; |
| 27955 |
while (p != null) { |
| 27956 |
try { |
| 27957 |
if (p.onStartNestedScroll(child, this, axes)) { |
| 27958 |
mNestedScrollingParent = p; |
| 27959 |
p.onNestedScrollAccepted(child, this, axes); |
| 27960 |
return true; |
| 27961 |
} |
| 27962 |
} catch (AbstractMethodError e) { |
| 27963 |
Log.e(VIEW_LOG_TAG, "ViewParent " + p + " does not implement interface " + |
| 27964 |
"method onStartNestedScroll", e); |
| 27965 |
|
| 27966 |
} |
| 27967 |
if (p instanceof View) { |
| 27968 |
child = (View) p; |
| 27969 |
} |
| 27970 |
p = p.getParent(); |
| 27971 |
} |
| 27972 |
} |
| 27973 |
return false; |
| 27974 |
} |
| 27975 |
|
| 27976 |
|
| 27977 |
|
| 27978 |
|
| 27979 |
|
| 27980 |
|
| 27981 |
|
| 27982 |
|
| 27983 |
public void stopNestedScroll() { |
| 27984 |
if (mNestedScrollingParent != null) { |
| 27985 |
mNestedScrollingParent.onStopNestedScroll(this); |
| 27986 |
mNestedScrollingParent = null; |
| 27987 |
} |
| 27988 |
} |
| 27989 |
|
| 27990 |
|
| 27991 |
|
| 27992 |
|
| 27993 |
|
| 27994 |
|
| 27995 |
|
| 27996 |
|
| 27997 |
|
| 27998 |
public boolean hasNestedScrollingParent() { |
| 27999 |
return mNestedScrollingParent != null; |
| 28000 |
} |
| 28001 |
|
| 28002 |
|
| 28003 |
|
| 28004 |
|
| 28005 |
|
| 28006 |
|
| 28007 |
|
| 28008 |
|
| 28009 |
|
| 28010 |
|
| 28011 |
|
| 28012 |
|
| 28013 |
|
| 28014 |
|
| 28015 |
|
| 28016 |
|
| 28017 |
|
| 28018 |
|
| 28019 |
|
| 28020 |
|
| 28021 |
|
| 28022 |
|
| 28023 |
|
| 28024 |
|
| 28025 |
public boolean dispatchNestedScroll(int dxConsumed, int dyConsumed, |
| 28026 |
int dxUnconsumed, int dyUnconsumed, @Nullable @Size(2) int[] offsetInWindow) { |
| 28027 |
if (isNestedScrollingEnabled() && mNestedScrollingParent != null) { |
| 28028 |
if (dxConsumed != 0 || dyConsumed != 0 || dxUnconsumed != 0 || dyUnconsumed != 0) { |
| 28029 |
int startX = 0; |
| 28030 |
int startY = 0; |
| 28031 |
if (offsetInWindow != null) { |
| 28032 |
getLocationInWindow(offsetInWindow); |
| 28033 |
startX = offsetInWindow[0]; |
| 28034 |
startY = offsetInWindow[1]; |
| 28035 |
} |
| 28036 |
|
| 28037 |
mNestedScrollingParent.onNestedScroll(this, dxConsumed, dyConsumed, |
| 28038 |
dxUnconsumed, dyUnconsumed); |
| 28039 |
|
| 28040 |
if (offsetInWindow != null) { |
| 28041 |
getLocationInWindow(offsetInWindow); |
| 28042 |
offsetInWindow[0] -= startX; |
| 28043 |
offsetInWindow[1] -= startY; |
| 28044 |
} |
| 28045 |
return true; |
| 28046 |
} else if (offsetInWindow != null) { |
| 28047 |
|
| 28048 |
offsetInWindow[0] = 0; |
| 28049 |
offsetInWindow[1] = 0; |
| 28050 |
} |
| 28051 |
} |
| 28052 |
return false; |
| 28053 |
} |
| 28054 |
|
| 28055 |
|
| 28056 |
|
| 28057 |
|
| 28058 |
|
| 28059 |
|
| 28060 |
|
| 28061 |
|
| 28062 |
|
| 28063 |
|
| 28064 |
|
| 28065 |
|
| 28066 |
|
| 28067 |
|
| 28068 |
|
| 28069 |
|
| 28070 |
|
| 28071 |
|
| 28072 |
|
| 28073 |
|
| 28074 |
public boolean dispatchNestedPreScroll(int dx, int dy, |
| 28075 |
@Nullable @Size(2) int[] consumed, @Nullable @Size(2) int[] offsetInWindow) { |
| 28076 |
if (isNestedScrollingEnabled() && mNestedScrollingParent != null) { |
| 28077 |
if (dx != 0 || dy != 0) { |
| 28078 |
int startX = 0; |
| 28079 |
int startY = 0; |
| 28080 |
if (offsetInWindow != null) { |
| 28081 |
getLocationInWindow(offsetInWindow); |
| 28082 |
startX = offsetInWindow[0]; |
| 28083 |
startY = offsetInWindow[1]; |
| 28084 |
} |
| 28085 |
|
| 28086 |
if (consumed == null) { |
| 28087 |
if (mTempNestedScrollConsumed == null) { |
| 28088 |
mTempNestedScrollConsumed = new int[2]; |
| 28089 |
} |
| 28090 |
consumed = mTempNestedScrollConsumed; |
| 28091 |
} |
| 28092 |
consumed[0] = 0; |
| 28093 |
consumed[1] = 0; |
| 28094 |
mNestedScrollingParent.onNestedPreScroll(this, dx, dy, consumed); |
| 28095 |
|
| 28096 |
if (offsetInWindow != null) { |
| 28097 |
getLocationInWindow(offsetInWindow); |
| 28098 |
offsetInWindow[0] -= startX; |
| 28099 |
offsetInWindow[1] -= startY; |
| 28100 |
} |
| 28101 |
return consumed[0] != 0 || consumed[1] != 0; |
| 28102 |
} else if (offsetInWindow != null) { |
| 28103 |
offsetInWindow[0] = 0; |
| 28104 |
offsetInWindow[1] = 0; |
| 28105 |
} |
| 28106 |
} |
| 28107 |
return false; |
| 28108 |
} |
| 28109 |
|
| 28110 |
|
| 28111 |
|
| 28112 |
|
| 28113 |
|
| 28114 |
|
| 28115 |
|
| 28116 |
|
| 28117 |
|
| 28118 |
|
| 28119 |
|
| 28120 |
|
| 28121 |
|
| 28122 |
|
| 28123 |
|
| 28124 |
|
| 28125 |
|
| 28126 |
|
| 28127 |
|
| 28128 |
public boolean dispatchNestedFling(float velocityX, float velocityY, boolean consumed) { |
| 28129 |
if (isNestedScrollingEnabled() && mNestedScrollingParent != null) { |
| 28130 |
return mNestedScrollingParent.onNestedFling(this, velocityX, velocityY, consumed); |
| 28131 |
} |
| 28132 |
return false; |
| 28133 |
} |
| 28134 |
|
| 28135 |
|
| 28136 |
|
| 28137 |
|
| 28138 |
|
| 28139 |
|
| 28140 |
|
| 28141 |
|
| 28142 |
|
| 28143 |
|
| 28144 |
|
| 28145 |
|
| 28146 |
|
| 28147 |
|
| 28148 |
|
| 28149 |
|
| 28150 |
|
| 28151 |
|
| 28152 |
|
| 28153 |
|
| 28154 |
|
| 28155 |
|
| 28156 |
|
| 28157 |
|
| 28158 |
|
| 28159 |
|
| 28160 |
|
| 28161 |
|
| 28162 |
|
| 28163 |
|
| 28164 |
|
| 28165 |
public boolean dispatchNestedPreFling(float velocityX, float velocityY) { |
| 28166 |
if (isNestedScrollingEnabled() && mNestedScrollingParent != null) { |
| 28167 |
return mNestedScrollingParent.onNestedPreFling(this, velocityX, velocityY); |
| 28168 |
} |
| 28169 |
return false; |
| 28170 |
} |
| 28171 |
|
| 28172 |
|
| 28173 |
|
| 28174 |
|
| 28175 |
|
| 28176 |
|
| 28177 |
|
| 28178 |
@UnsupportedAppUsage |
| 28179 |
protected float getVerticalScrollFactor() { |
| 28180 |
if (mVerticalScrollFactor == 0) { |
| 28181 |
TypedValue outValue = new TypedValue(); |
| 28182 |
if (!mContext.getTheme().resolveAttribute( |
| 28183 |
com.android.internal.R.attr.listPreferredItemHeight, outValue, true)) { |
| 28184 |
throw new IllegalStateException( |
| 28185 |
"Expected theme to define listPreferredItemHeight."); |
| 28186 |
} |
| 28187 |
mVerticalScrollFactor = outValue.getDimension( |
| 28188 |
mContext.getResources().getDisplayMetrics()); |
| 28189 |
} |
| 28190 |
return mVerticalScrollFactor; |
| 28191 |
} |
| 28192 |
|
| 28193 |
|
| 28194 |
|
| 28195 |
|
| 28196 |
|
| 28197 |
|
| 28198 |
|
| 28199 |
@UnsupportedAppUsage |
| 28200 |
protected float getHorizontalScrollFactor() { |
| 28201 |
|
| 28202 |
return getVerticalScrollFactor(); |
| 28203 |
} |
| 28204 |
|
| 28205 |
|
| 28206 |
|
| 28207 |
|
| 28208 |
|
| 28209 |
|
| 28210 |
|
| 28211 |
|
| 28212 |
|
| 28213 |
|
| 28214 |
|
| 28215 |
|
| 28216 |
|
| 28217 |
|
| 28218 |
|
| 28219 |
|
| 28220 |
|
| 28221 |
|
| 28222 |
|
| 28223 |
|
| 28224 |
@ViewDebug.ExportedProperty(category = "text", mapping = { |
| 28225 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"), |
| 28226 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_FIRST_STRONG, to = "FIRST_STRONG"), |
| 28227 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_ANY_RTL, to = "ANY_RTL"), |
| 28228 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_LTR, to = "LTR"), |
| 28229 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_RTL, to = "RTL"), |
| 28230 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_LOCALE, to = "LOCALE"), |
| 28231 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_FIRST_STRONG_LTR, to = "FIRST_STRONG_LTR"), |
| 28232 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_FIRST_STRONG_RTL, to = "FIRST_STRONG_RTL") |
| 28233 |
}) |
| 28234 |
@InspectableProperty(hasAttributeId = false, enumMapping = { |
| 28235 |
@EnumEntry(value = TEXT_DIRECTION_INHERIT, name = "inherit"), |
| 28236 |
@EnumEntry(value = TEXT_DIRECTION_LOCALE, name = "locale"), |
| 28237 |
@EnumEntry(value = TEXT_DIRECTION_ANY_RTL, name = "anyRtl"), |
| 28238 |
@EnumEntry(value = TEXT_DIRECTION_LTR, name = "ltr"), |
| 28239 |
@EnumEntry(value = TEXT_DIRECTION_RTL, name = "rtl"), |
| 28240 |
@EnumEntry(value = TEXT_DIRECTION_FIRST_STRONG, name = "firstStrong"), |
| 28241 |
@EnumEntry(value = TEXT_DIRECTION_FIRST_STRONG_LTR, name = "firstStrongLtr"), |
| 28242 |
@EnumEntry(value = TEXT_DIRECTION_FIRST_STRONG_RTL, name = "firstStrongRtl"), |
| 28243 |
}) |
| 28244 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 28245 |
public int getRawTextDirection() { |
| 28246 |
return (mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_MASK) >> PFLAG2_TEXT_DIRECTION_MASK_SHIFT; |
| 28247 |
} |
| 28248 |
|
| 28249 |
|
| 28250 |
|
| 28251 |
|
| 28252 |
|
| 28253 |
|
| 28254 |
|
| 28255 |
|
| 28256 |
|
| 28257 |
|
| 28258 |
|
| 28259 |
|
| 28260 |
|
| 28261 |
|
| 28262 |
|
| 28263 |
|
| 28264 |
|
| 28265 |
|
| 28266 |
|
| 28267 |
|
| 28268 |
|
| 28269 |
public void setTextDirection(int textDirection) { |
| 28270 |
if (getRawTextDirection() != textDirection) { |
| 28271 |
|
| 28272 |
mPrivateFlags2 &= ~PFLAG2_TEXT_DIRECTION_MASK; |
| 28273 |
resetResolvedTextDirection(); |
| 28274 |
|
| 28275 |
mPrivateFlags2 |= ((textDirection << PFLAG2_TEXT_DIRECTION_MASK_SHIFT) & PFLAG2_TEXT_DIRECTION_MASK); |
| 28276 |
|
| 28277 |
resolveTextDirection(); |
| 28278 |
|
| 28279 |
onRtlPropertiesChanged(getLayoutDirection()); |
| 28280 |
|
| 28281 |
requestLayout(); |
| 28282 |
invalidate(true); |
| 28283 |
} |
| 28284 |
} |
| 28285 |
|
| 28286 |
|
| 28287 |
|
| 28288 |
|
| 28289 |
|
| 28290 |
|
| 28291 |
|
| 28292 |
|
| 28293 |
|
| 28294 |
|
| 28295 |
|
| 28296 |
|
| 28297 |
|
| 28298 |
|
| 28299 |
|
| 28300 |
|
| 28301 |
@ViewDebug.ExportedProperty(category = "text", mapping = { |
| 28302 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_INHERIT, to = "INHERIT"), |
| 28303 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_FIRST_STRONG, to = "FIRST_STRONG"), |
| 28304 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_ANY_RTL, to = "ANY_RTL"), |
| 28305 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_LTR, to = "LTR"), |
| 28306 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_RTL, to = "RTL"), |
| 28307 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_LOCALE, to = "LOCALE"), |
| 28308 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_FIRST_STRONG_LTR, to = "FIRST_STRONG_LTR"), |
| 28309 |
@ViewDebug.IntToString(from = TEXT_DIRECTION_FIRST_STRONG_RTL, to = "FIRST_STRONG_RTL") |
| 28310 |
}) |
| 28311 |
@InspectableProperty(hasAttributeId = false, enumMapping = { |
| 28312 |
@EnumEntry(value = TEXT_DIRECTION_LOCALE, name = "locale"), |
| 28313 |
@EnumEntry(value = TEXT_DIRECTION_ANY_RTL, name = "anyRtl"), |
| 28314 |
@EnumEntry(value = TEXT_DIRECTION_LTR, name = "ltr"), |
| 28315 |
@EnumEntry(value = TEXT_DIRECTION_RTL, name = "rtl"), |
| 28316 |
@EnumEntry(value = TEXT_DIRECTION_FIRST_STRONG, name = "firstStrong"), |
| 28317 |
@EnumEntry(value = TEXT_DIRECTION_FIRST_STRONG_LTR, name = "firstStrongLtr"), |
| 28318 |
@EnumEntry(value = TEXT_DIRECTION_FIRST_STRONG_RTL, name = "firstStrongRtl"), |
| 28319 |
}) |
| 28320 |
public int getTextDirection() { |
| 28321 |
return (mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_RESOLVED_MASK) >> PFLAG2_TEXT_DIRECTION_RESOLVED_MASK_SHIFT; |
| 28322 |
} |
| 28323 |
|
| 28324 |
|
| 28325 |
|
| 28326 |
|
| 28327 |
|
| 28328 |
|
| 28329 |
|
| 28330 |
|
| 28331 |
public boolean resolveTextDirection() { |
| 28332 |
|
| 28333 |
mPrivateFlags2 &= ~(PFLAG2_TEXT_DIRECTION_RESOLVED | PFLAG2_TEXT_DIRECTION_RESOLVED_MASK); |
| 28334 |
|
| 28335 |
if (hasRtlSupport()) { |
| 28336 |
|
| 28337 |
final int textDirection = getRawTextDirection(); |
| 28338 |
switch(textDirection) { |
| 28339 |
case TEXT_DIRECTION_INHERIT: |
| 28340 |
if (!canResolveTextDirection()) { |
| 28341 |
|
| 28342 |
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; |
| 28343 |
|
| 28344 |
return false; |
| 28345 |
} |
| 28346 |
|
| 28347 |
|
| 28348 |
try { |
| 28349 |
if (!mParent.isTextDirectionResolved()) { |
| 28350 |
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; |
| 28351 |
|
| 28352 |
return false; |
| 28353 |
} |
| 28354 |
} catch (AbstractMethodError e) { |
| 28355 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 28356 |
" does not fully implement ViewParent", e); |
| 28357 |
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED | |
| 28358 |
PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; |
| 28359 |
return true; |
| 28360 |
} |
| 28361 |
|
| 28362 |
|
| 28363 |
int parentResolvedDirection; |
| 28364 |
try { |
| 28365 |
parentResolvedDirection = mParent.getTextDirection(); |
| 28366 |
} catch (AbstractMethodError e) { |
| 28367 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 28368 |
" does not fully implement ViewParent", e); |
| 28369 |
parentResolvedDirection = TEXT_DIRECTION_LTR; |
| 28370 |
} |
| 28371 |
switch (parentResolvedDirection) { |
| 28372 |
case TEXT_DIRECTION_FIRST_STRONG: |
| 28373 |
case TEXT_DIRECTION_ANY_RTL: |
| 28374 |
case TEXT_DIRECTION_LTR: |
| 28375 |
case TEXT_DIRECTION_RTL: |
| 28376 |
case TEXT_DIRECTION_LOCALE: |
| 28377 |
case TEXT_DIRECTION_FIRST_STRONG_LTR: |
| 28378 |
case TEXT_DIRECTION_FIRST_STRONG_RTL: |
| 28379 |
mPrivateFlags2 |= |
| 28380 |
(parentResolvedDirection << PFLAG2_TEXT_DIRECTION_RESOLVED_MASK_SHIFT); |
| 28381 |
break; |
| 28382 |
default: |
| 28383 |
|
| 28384 |
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; |
| 28385 |
} |
| 28386 |
break; |
| 28387 |
case TEXT_DIRECTION_FIRST_STRONG: |
| 28388 |
case TEXT_DIRECTION_ANY_RTL: |
| 28389 |
case TEXT_DIRECTION_LTR: |
| 28390 |
case TEXT_DIRECTION_RTL: |
| 28391 |
case TEXT_DIRECTION_LOCALE: |
| 28392 |
case TEXT_DIRECTION_FIRST_STRONG_LTR: |
| 28393 |
case TEXT_DIRECTION_FIRST_STRONG_RTL: |
| 28394 |
|
| 28395 |
mPrivateFlags2 |= (textDirection << PFLAG2_TEXT_DIRECTION_RESOLVED_MASK_SHIFT); |
| 28396 |
break; |
| 28397 |
default: |
| 28398 |
|
| 28399 |
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; |
| 28400 |
} |
| 28401 |
} else { |
| 28402 |
|
| 28403 |
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; |
| 28404 |
} |
| 28405 |
|
| 28406 |
|
| 28407 |
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED; |
| 28408 |
return true; |
| 28409 |
} |
| 28410 |
|
| 28411 |
|
| 28412 |
|
| 28413 |
|
| 28414 |
|
| 28415 |
|
| 28416 |
public boolean canResolveTextDirection() { |
| 28417 |
switch (getRawTextDirection()) { |
| 28418 |
case TEXT_DIRECTION_INHERIT: |
| 28419 |
if (mParent != null) { |
| 28420 |
try { |
| 28421 |
return mParent.canResolveTextDirection(); |
| 28422 |
} catch (AbstractMethodError e) { |
| 28423 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 28424 |
" does not fully implement ViewParent", e); |
| 28425 |
} |
| 28426 |
} |
| 28427 |
return false; |
| 28428 |
|
| 28429 |
default: |
| 28430 |
return true; |
| 28431 |
} |
| 28432 |
} |
| 28433 |
|
| 28434 |
|
| 28435 |
|
| 28436 |
|
| 28437 |
|
| 28438 |
|
| 28439 |
|
| 28440 |
@TestApi |
| 28441 |
public void resetResolvedTextDirection() { |
| 28442 |
|
| 28443 |
mPrivateFlags2 &= ~(PFLAG2_TEXT_DIRECTION_RESOLVED | PFLAG2_TEXT_DIRECTION_RESOLVED_MASK); |
| 28444 |
|
| 28445 |
mPrivateFlags2 |= PFLAG2_TEXT_DIRECTION_RESOLVED_DEFAULT; |
| 28446 |
} |
| 28447 |
|
| 28448 |
|
| 28449 |
|
| 28450 |
|
| 28451 |
|
| 28452 |
|
| 28453 |
public boolean isTextDirectionInherited() { |
| 28454 |
return (getRawTextDirection() == TEXT_DIRECTION_INHERIT); |
| 28455 |
} |
| 28456 |
|
| 28457 |
|
| 28458 |
|
| 28459 |
|
| 28460 |
public boolean isTextDirectionResolved() { |
| 28461 |
return (mPrivateFlags2 & PFLAG2_TEXT_DIRECTION_RESOLVED) == PFLAG2_TEXT_DIRECTION_RESOLVED; |
| 28462 |
} |
| 28463 |
|
| 28464 |
|
| 28465 |
|
| 28466 |
|
| 28467 |
|
| 28468 |
|
| 28469 |
|
| 28470 |
|
| 28471 |
|
| 28472 |
|
| 28473 |
|
| 28474 |
|
| 28475 |
|
| 28476 |
|
| 28477 |
|
| 28478 |
|
| 28479 |
|
| 28480 |
|
| 28481 |
|
| 28482 |
@ViewDebug.ExportedProperty(category = "text", mapping = { |
| 28483 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_INHERIT, to = "INHERIT"), |
| 28484 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_GRAVITY, to = "GRAVITY"), |
| 28485 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_TEXT_START, to = "TEXT_START"), |
| 28486 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_TEXT_END, to = "TEXT_END"), |
| 28487 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_CENTER, to = "CENTER"), |
| 28488 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_START, to = "VIEW_START"), |
| 28489 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_END, to = "VIEW_END") |
| 28490 |
}) |
| 28491 |
@InspectableProperty(hasAttributeId = false, enumMapping = { |
| 28492 |
@EnumEntry(value = TEXT_ALIGNMENT_INHERIT, name = "inherit"), |
| 28493 |
@EnumEntry(value = TEXT_ALIGNMENT_GRAVITY, name = "gravity"), |
| 28494 |
@EnumEntry(value = TEXT_ALIGNMENT_TEXT_START, name = "textStart"), |
| 28495 |
@EnumEntry(value = TEXT_ALIGNMENT_TEXT_END, name = "textEnd"), |
| 28496 |
@EnumEntry(value = TEXT_ALIGNMENT_CENTER, name = "center"), |
| 28497 |
@EnumEntry(value = TEXT_ALIGNMENT_VIEW_START, name = "viewStart"), |
| 28498 |
@EnumEntry(value = TEXT_ALIGNMENT_VIEW_END, name = "viewEnd") |
| 28499 |
}) |
| 28500 |
@TextAlignment |
| 28501 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 28502 |
public int getRawTextAlignment() { |
| 28503 |
return (mPrivateFlags2 & PFLAG2_TEXT_ALIGNMENT_MASK) >> PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT; |
| 28504 |
} |
| 28505 |
|
| 28506 |
|
| 28507 |
|
| 28508 |
|
| 28509 |
|
| 28510 |
|
| 28511 |
|
| 28512 |
|
| 28513 |
|
| 28514 |
|
| 28515 |
|
| 28516 |
|
| 28517 |
|
| 28518 |
|
| 28519 |
|
| 28520 |
|
| 28521 |
|
| 28522 |
|
| 28523 |
|
| 28524 |
|
| 28525 |
public void setTextAlignment(@TextAlignment int textAlignment) { |
| 28526 |
if (textAlignment != getRawTextAlignment()) { |
| 28527 |
|
| 28528 |
mPrivateFlags2 &= ~PFLAG2_TEXT_ALIGNMENT_MASK; |
| 28529 |
resetResolvedTextAlignment(); |
| 28530 |
|
| 28531 |
mPrivateFlags2 |= |
| 28532 |
((textAlignment << PFLAG2_TEXT_ALIGNMENT_MASK_SHIFT) & PFLAG2_TEXT_ALIGNMENT_MASK); |
| 28533 |
|
| 28534 |
resolveTextAlignment(); |
| 28535 |
|
| 28536 |
onRtlPropertiesChanged(getLayoutDirection()); |
| 28537 |
|
| 28538 |
requestLayout(); |
| 28539 |
invalidate(true); |
| 28540 |
} |
| 28541 |
} |
| 28542 |
|
| 28543 |
|
| 28544 |
|
| 28545 |
|
| 28546 |
|
| 28547 |
|
| 28548 |
|
| 28549 |
|
| 28550 |
|
| 28551 |
|
| 28552 |
|
| 28553 |
|
| 28554 |
|
| 28555 |
|
| 28556 |
|
| 28557 |
@ViewDebug.ExportedProperty(category = "text", mapping = { |
| 28558 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_INHERIT, to = "INHERIT"), |
| 28559 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_GRAVITY, to = "GRAVITY"), |
| 28560 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_TEXT_START, to = "TEXT_START"), |
| 28561 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_TEXT_END, to = "TEXT_END"), |
| 28562 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_CENTER, to = "CENTER"), |
| 28563 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_START, to = "VIEW_START"), |
| 28564 |
@ViewDebug.IntToString(from = TEXT_ALIGNMENT_VIEW_END, to = "VIEW_END") |
| 28565 |
}) |
| 28566 |
@InspectableProperty(enumMapping = { |
| 28567 |
@EnumEntry(value = TEXT_ALIGNMENT_GRAVITY, name = "gravity"), |
| 28568 |
@EnumEntry(value = TEXT_ALIGNMENT_TEXT_START, name = "textStart"), |
| 28569 |
@EnumEntry(value = TEXT_ALIGNMENT_TEXT_END, name = "textEnd"), |
| 28570 |
@EnumEntry(value = TEXT_ALIGNMENT_CENTER, name = "center"), |
| 28571 |
@EnumEntry(value = TEXT_ALIGNMENT_VIEW_START, name = "viewStart"), |
| 28572 |
@EnumEntry(value = TEXT_ALIGNMENT_VIEW_END, name = "viewEnd") |
| 28573 |
}) |
| 28574 |
@TextAlignment |
| 28575 |
public int getTextAlignment() { |
| 28576 |
return (mPrivateFlags2 & PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK) >> |
| 28577 |
PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT; |
| 28578 |
} |
| 28579 |
|
| 28580 |
|
| 28581 |
|
| 28582 |
|
| 28583 |
|
| 28584 |
|
| 28585 |
|
| 28586 |
|
| 28587 |
public boolean resolveTextAlignment() { |
| 28588 |
|
| 28589 |
mPrivateFlags2 &= ~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK); |
| 28590 |
|
| 28591 |
if (hasRtlSupport()) { |
| 28592 |
|
| 28593 |
final int textAlignment = getRawTextAlignment(); |
| 28594 |
switch (textAlignment) { |
| 28595 |
case TEXT_ALIGNMENT_INHERIT: |
| 28596 |
|
| 28597 |
if (!canResolveTextAlignment()) { |
| 28598 |
|
| 28599 |
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; |
| 28600 |
|
| 28601 |
return false; |
| 28602 |
} |
| 28603 |
|
| 28604 |
|
| 28605 |
try { |
| 28606 |
if (!mParent.isTextAlignmentResolved()) { |
| 28607 |
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; |
| 28608 |
|
| 28609 |
return false; |
| 28610 |
} |
| 28611 |
} catch (AbstractMethodError e) { |
| 28612 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 28613 |
" does not fully implement ViewParent", e); |
| 28614 |
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED | |
| 28615 |
PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; |
| 28616 |
return true; |
| 28617 |
} |
| 28618 |
|
| 28619 |
int parentResolvedTextAlignment; |
| 28620 |
try { |
| 28621 |
parentResolvedTextAlignment = mParent.getTextAlignment(); |
| 28622 |
} catch (AbstractMethodError e) { |
| 28623 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 28624 |
" does not fully implement ViewParent", e); |
| 28625 |
parentResolvedTextAlignment = TEXT_ALIGNMENT_GRAVITY; |
| 28626 |
} |
| 28627 |
switch (parentResolvedTextAlignment) { |
| 28628 |
case TEXT_ALIGNMENT_GRAVITY: |
| 28629 |
case TEXT_ALIGNMENT_TEXT_START: |
| 28630 |
case TEXT_ALIGNMENT_TEXT_END: |
| 28631 |
case TEXT_ALIGNMENT_CENTER: |
| 28632 |
case TEXT_ALIGNMENT_VIEW_START: |
| 28633 |
case TEXT_ALIGNMENT_VIEW_END: |
| 28634 |
|
| 28635 |
|
| 28636 |
mPrivateFlags2 |= |
| 28637 |
(parentResolvedTextAlignment << PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT); |
| 28638 |
break; |
| 28639 |
default: |
| 28640 |
|
| 28641 |
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; |
| 28642 |
} |
| 28643 |
break; |
| 28644 |
case TEXT_ALIGNMENT_GRAVITY: |
| 28645 |
case TEXT_ALIGNMENT_TEXT_START: |
| 28646 |
case TEXT_ALIGNMENT_TEXT_END: |
| 28647 |
case TEXT_ALIGNMENT_CENTER: |
| 28648 |
case TEXT_ALIGNMENT_VIEW_START: |
| 28649 |
case TEXT_ALIGNMENT_VIEW_END: |
| 28650 |
|
| 28651 |
mPrivateFlags2 |= (textAlignment << PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK_SHIFT); |
| 28652 |
break; |
| 28653 |
default: |
| 28654 |
|
| 28655 |
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; |
| 28656 |
} |
| 28657 |
} else { |
| 28658 |
|
| 28659 |
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; |
| 28660 |
} |
| 28661 |
|
| 28662 |
|
| 28663 |
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED; |
| 28664 |
return true; |
| 28665 |
} |
| 28666 |
|
| 28667 |
|
| 28668 |
|
| 28669 |
|
| 28670 |
|
| 28671 |
|
| 28672 |
public boolean canResolveTextAlignment() { |
| 28673 |
switch (getRawTextAlignment()) { |
| 28674 |
case TEXT_DIRECTION_INHERIT: |
| 28675 |
if (mParent != null) { |
| 28676 |
try { |
| 28677 |
return mParent.canResolveTextAlignment(); |
| 28678 |
} catch (AbstractMethodError e) { |
| 28679 |
Log.e(VIEW_LOG_TAG, mParent.getClass().getSimpleName() + |
| 28680 |
" does not fully implement ViewParent", e); |
| 28681 |
} |
| 28682 |
} |
| 28683 |
return false; |
| 28684 |
|
| 28685 |
default: |
| 28686 |
return true; |
| 28687 |
} |
| 28688 |
} |
| 28689 |
|
| 28690 |
|
| 28691 |
|
| 28692 |
|
| 28693 |
|
| 28694 |
|
| 28695 |
|
| 28696 |
@TestApi |
| 28697 |
public void resetResolvedTextAlignment() { |
| 28698 |
|
| 28699 |
mPrivateFlags2 &= ~(PFLAG2_TEXT_ALIGNMENT_RESOLVED | PFLAG2_TEXT_ALIGNMENT_RESOLVED_MASK); |
| 28700 |
|
| 28701 |
mPrivateFlags2 |= PFLAG2_TEXT_ALIGNMENT_RESOLVED_DEFAULT; |
| 28702 |
} |
| 28703 |
|
| 28704 |
|
| 28705 |
|
| 28706 |
|
| 28707 |
|
| 28708 |
|
| 28709 |
public boolean isTextAlignmentInherited() { |
| 28710 |
return (getRawTextAlignment() == TEXT_ALIGNMENT_INHERIT); |
| 28711 |
} |
| 28712 |
|
| 28713 |
|
| 28714 |
|
| 28715 |
|
| 28716 |
public boolean isTextAlignmentResolved() { |
| 28717 |
return (mPrivateFlags2 & PFLAG2_TEXT_ALIGNMENT_RESOLVED) == PFLAG2_TEXT_ALIGNMENT_RESOLVED; |
| 28718 |
} |
| 28719 |
|
| 28720 |
|
| 28721 |
|
| 28722 |
|
| 28723 |
|
| 28724 |
|
| 28725 |
|
| 28726 |
public static int generateViewId() { |
| 28727 |
for (;;) { |
| 28728 |
final int result = sNextGeneratedId.get(); |
| 28729 |
|
| 28730 |
int newValue = result + 1; |
| 28731 |
if (newValue > 0x00FFFFFF) newValue = 1; |
| 28732 |
if (sNextGeneratedId.compareAndSet(result, newValue)) { |
| 28733 |
return result; |
| 28734 |
} |
| 28735 |
} |
| 28736 |
} |
| 28737 |
|
| 28738 |
private static boolean isViewIdGenerated(int id) { |
| 28739 |
return (id & 0xFF000000) == 0 && (id & 0x00FFFFFF) != 0; |
| 28740 |
} |
| 28741 |
|
| 28742 |
|
| 28743 |
|
| 28744 |
|
| 28745 |
|
| 28746 |
|
| 28747 |
|
| 28748 |
|
| 28749 |
public void captureTransitioningViews(List<View> transitioningViews) { |
| 28750 |
if (getVisibility() == View.VISIBLE) { |
| 28751 |
transitioningViews.add(this); |
| 28752 |
} |
| 28753 |
} |
| 28754 |
|
| 28755 |
|
| 28756 |
|
| 28757 |
|
| 28758 |
|
| 28759 |
|
| 28760 |
public void findNamedViews(Map<String, View> namedElements) { |
| 28761 |
if (getVisibility() == VISIBLE || mGhostView != null) { |
| 28762 |
String transitionName = getTransitionName(); |
| 28763 |
if (transitionName != null) { |
| 28764 |
namedElements.put(transitionName, this); |
| 28765 |
} |
| 28766 |
} |
| 28767 |
} |
| 28768 |
|
| 28769 |
|
| 28770 |
|
| 28771 |
|
| 28772 |
|
| 28773 |
|
| 28774 |
|
| 28775 |
|
| 28776 |
|
| 28777 |
|
| 28778 |
public PointerIcon onResolvePointerIcon(MotionEvent event, int pointerIndex) { |
| 28779 |
final float x = event.getX(pointerIndex); |
| 28780 |
final float y = event.getY(pointerIndex); |
| 28781 |
if (isDraggingScrollBar() || isOnScrollbarThumb(x, y)) { |
| 28782 |
return PointerIcon.getSystemIcon(mContext, PointerIcon.TYPE_ARROW); |
| 28783 |
} |
| 28784 |
return mPointerIcon; |
| 28785 |
} |
| 28786 |
|
| 28787 |
|
| 28788 |
|
| 28789 |
|
| 28790 |
|
| 28791 |
|
| 28792 |
public void setPointerIcon(PointerIcon pointerIcon) { |
| 28793 |
mPointerIcon = pointerIcon; |
| 28794 |
if (mAttachInfo == null || mAttachInfo.mHandlingPointerEvent) { |
| 28795 |
return; |
| 28796 |
} |
| 28797 |
try { |
| 28798 |
mAttachInfo.mSession.updatePointerIcon(mAttachInfo.mWindow); |
| 28799 |
} catch (RemoteException e) { |
| 28800 |
} |
| 28801 |
} |
| 28802 |
|
| 28803 |
|
| 28804 |
|
| 28805 |
|
| 28806 |
@InspectableProperty |
| 28807 |
public PointerIcon getPointerIcon() { |
| 28808 |
return mPointerIcon; |
| 28809 |
} |
| 28810 |
|
| 28811 |
|
| 28812 |
|
| 28813 |
|
| 28814 |
|
| 28815 |
|
| 28816 |
|
| 28817 |
|
| 28818 |
public boolean hasPointerCapture() { |
| 28819 |
final ViewRootImpl viewRootImpl = getViewRootImpl(); |
| 28820 |
if (viewRootImpl == null) { |
| 28821 |
return false; |
| 28822 |
} |
| 28823 |
return viewRootImpl.hasPointerCapture(); |
| 28824 |
} |
| 28825 |
|
| 28826 |
|
| 28827 |
|
| 28828 |
|
| 28829 |
|
| 28830 |
|
| 28831 |
|
| 28832 |
|
| 28833 |
|
| 28834 |
|
| 28835 |
|
| 28836 |
|
| 28837 |
|
| 28838 |
|
| 28839 |
|
| 28840 |
|
| 28841 |
|
| 28842 |
|
| 28843 |
|
| 28844 |
|
| 28845 |
|
| 28846 |
|
| 28847 |
|
| 28848 |
|
| 28849 |
|
| 28850 |
|
| 28851 |
|
| 28852 |
|
| 28853 |
|
| 28854 |
|
| 28855 |
|
| 28856 |
|
| 28857 |
|
| 28858 |
|
| 28859 |
|
| 28860 |
|
| 28861 |
|
| 28862 |
|
| 28863 |
|
| 28864 |
|
| 28865 |
|
| 28866 |
public void requestPointerCapture() { |
| 28867 |
final ViewRootImpl viewRootImpl = getViewRootImpl(); |
| 28868 |
if (viewRootImpl != null) { |
| 28869 |
viewRootImpl.requestPointerCapture(true); |
| 28870 |
} |
| 28871 |
} |
| 28872 |
|
| 28873 |
|
| 28874 |
|
| 28875 |
|
| 28876 |
|
| 28877 |
|
| 28878 |
|
| 28879 |
|
| 28880 |
|
| 28881 |
|
| 28882 |
public void releasePointerCapture() { |
| 28883 |
final ViewRootImpl viewRootImpl = getViewRootImpl(); |
| 28884 |
if (viewRootImpl != null) { |
| 28885 |
viewRootImpl.requestPointerCapture(false); |
| 28886 |
} |
| 28887 |
} |
| 28888 |
|
| 28889 |
|
| 28890 |
|
| 28891 |
|
| 28892 |
|
| 28893 |
|
| 28894 |
@CallSuper |
| 28895 |
public void onPointerCaptureChange(boolean hasCapture) { |
| 28896 |
} |
| 28897 |
|
| 28898 |
|
| 28899 |
|
| 28900 |
|
| 28901 |
public void dispatchPointerCaptureChanged(boolean hasCapture) { |
| 28902 |
onPointerCaptureChange(hasCapture); |
| 28903 |
} |
| 28904 |
|
| 28905 |
|
| 28906 |
|
| 28907 |
|
| 28908 |
|
| 28909 |
|
| 28910 |
|
| 28911 |
|
| 28912 |
public boolean onCapturedPointerEvent(MotionEvent event) { |
| 28913 |
return false; |
| 28914 |
} |
| 28915 |
|
| 28916 |
|
| 28917 |
|
| 28918 |
|
| 28919 |
|
| 28920 |
|
| 28921 |
public interface OnCapturedPointerListener { |
| 28922 |
|
| 28923 |
|
| 28924 |
|
| 28925 |
|
| 28926 |
|
| 28927 |
|
| 28928 |
boolean onCapturedPointer(View view, MotionEvent event); |
| 28929 |
} |
| 28930 |
|
| 28931 |
|
| 28932 |
|
| 28933 |
|
| 28934 |
|
| 28935 |
public void setOnCapturedPointerListener(OnCapturedPointerListener l) { |
| 28936 |
getListenerInfo().mOnCapturedPointerListener = l; |
| 28937 |
} |
| 28938 |
|
| 28939 |
|
| 28940 |
|
| 28941 |
|
| 28942 |
|
| 28943 |
|
| 28944 |
|
| 28945 |
public static final Property<View, Float> ALPHA = new FloatProperty<View>("alpha") { |
| 28946 |
@Override |
| 28947 |
public void setValue(View object, float value) { |
| 28948 |
object.setAlpha(value); |
| 28949 |
} |
| 28950 |
|
| 28951 |
@Override |
| 28952 |
public Float get(View object) { |
| 28953 |
return object.getAlpha(); |
| 28954 |
} |
| 28955 |
}; |
| 28956 |
|
| 28957 |
|
| 28958 |
|
| 28959 |
|
| 28960 |
|
| 28961 |
public static final Property<View, Float> TRANSLATION_X = new FloatProperty<View>("translationX") { |
| 28962 |
@Override |
| 28963 |
public void setValue(View object, float value) { |
| 28964 |
object.setTranslationX(value); |
| 28965 |
} |
| 28966 |
|
| 28967 |
@Override |
| 28968 |
public Float get(View object) { |
| 28969 |
return object.getTranslationX(); |
| 28970 |
} |
| 28971 |
}; |
| 28972 |
|
| 28973 |
|
| 28974 |
|
| 28975 |
|
| 28976 |
|
| 28977 |
public static final Property<View, Float> TRANSLATION_Y = new FloatProperty<View>("translationY") { |
| 28978 |
@Override |
| 28979 |
public void setValue(View object, float value) { |
| 28980 |
object.setTranslationY(value); |
| 28981 |
} |
| 28982 |
|
| 28983 |
@Override |
| 28984 |
public Float get(View object) { |
| 28985 |
return object.getTranslationY(); |
| 28986 |
} |
| 28987 |
}; |
| 28988 |
|
| 28989 |
|
| 28990 |
|
| 28991 |
|
| 28992 |
|
| 28993 |
public static final Property<View, Float> TRANSLATION_Z = new FloatProperty<View>("translationZ") { |
| 28994 |
@Override |
| 28995 |
public void setValue(View object, float value) { |
| 28996 |
object.setTranslationZ(value); |
| 28997 |
} |
| 28998 |
|
| 28999 |
@Override |
| 29000 |
public Float get(View object) { |
| 29001 |
return object.getTranslationZ(); |
| 29002 |
} |
| 29003 |
}; |
| 29004 |
|
| 29005 |
|
| 29006 |
|
| 29007 |
|
| 29008 |
|
| 29009 |
public static final Property<View, Float> X = new FloatProperty<View>("x") { |
| 29010 |
@Override |
| 29011 |
public void setValue(View object, float value) { |
| 29012 |
object.setX(value); |
| 29013 |
} |
| 29014 |
|
| 29015 |
@Override |
| 29016 |
public Float get(View object) { |
| 29017 |
return object.getX(); |
| 29018 |
} |
| 29019 |
}; |
| 29020 |
|
| 29021 |
|
| 29022 |
|
| 29023 |
|
| 29024 |
|
| 29025 |
public static final Property<View, Float> Y = new FloatProperty<View>("y") { |
| 29026 |
@Override |
| 29027 |
public void setValue(View object, float value) { |
| 29028 |
object.setY(value); |
| 29029 |
} |
| 29030 |
|
| 29031 |
@Override |
| 29032 |
public Float get(View object) { |
| 29033 |
return object.getY(); |
| 29034 |
} |
| 29035 |
}; |
| 29036 |
|
| 29037 |
|
| 29038 |
|
| 29039 |
|
| 29040 |
|
| 29041 |
public static final Property<View, Float> Z = new FloatProperty<View>("z") { |
| 29042 |
@Override |
| 29043 |
public void setValue(View object, float value) { |
| 29044 |
object.setZ(value); |
| 29045 |
} |
| 29046 |
|
| 29047 |
@Override |
| 29048 |
public Float get(View object) { |
| 29049 |
return object.getZ(); |
| 29050 |
} |
| 29051 |
}; |
| 29052 |
|
| 29053 |
|
| 29054 |
|
| 29055 |
|
| 29056 |
|
| 29057 |
public static final Property<View, Float> ROTATION = new FloatProperty<View>("rotation") { |
| 29058 |
@Override |
| 29059 |
public void setValue(View object, float value) { |
| 29060 |
object.setRotation(value); |
| 29061 |
} |
| 29062 |
|
| 29063 |
@Override |
| 29064 |
public Float get(View object) { |
| 29065 |
return object.getRotation(); |
| 29066 |
} |
| 29067 |
}; |
| 29068 |
|
| 29069 |
|
| 29070 |
|
| 29071 |
|
| 29072 |
|
| 29073 |
public static final Property<View, Float> ROTATION_X = new FloatProperty<View>("rotationX") { |
| 29074 |
@Override |
| 29075 |
public void setValue(View object, float value) { |
| 29076 |
object.setRotationX(value); |
| 29077 |
} |
| 29078 |
|
| 29079 |
@Override |
| 29080 |
public Float get(View object) { |
| 29081 |
return object.getRotationX(); |
| 29082 |
} |
| 29083 |
}; |
| 29084 |
|
| 29085 |
|
| 29086 |
|
| 29087 |
|
| 29088 |
|
| 29089 |
public static final Property<View, Float> ROTATION_Y = new FloatProperty<View>("rotationY") { |
| 29090 |
@Override |
| 29091 |
public void setValue(View object, float value) { |
| 29092 |
object.setRotationY(value); |
| 29093 |
} |
| 29094 |
|
| 29095 |
@Override |
| 29096 |
public Float get(View object) { |
| 29097 |
return object.getRotationY(); |
| 29098 |
} |
| 29099 |
}; |
| 29100 |
|
| 29101 |
|
| 29102 |
|
| 29103 |
|
| 29104 |
|
| 29105 |
public static final Property<View, Float> SCALE_X = new FloatProperty<View>("scaleX") { |
| 29106 |
@Override |
| 29107 |
public void setValue(View object, float value) { |
| 29108 |
object.setScaleX(value); |
| 29109 |
} |
| 29110 |
|
| 29111 |
@Override |
| 29112 |
public Float get(View object) { |
| 29113 |
return object.getScaleX(); |
| 29114 |
} |
| 29115 |
}; |
| 29116 |
|
| 29117 |
|
| 29118 |
|
| 29119 |
|
| 29120 |
|
| 29121 |
public static final Property<View, Float> SCALE_Y = new FloatProperty<View>("scaleY") { |
| 29122 |
@Override |
| 29123 |
public void setValue(View object, float value) { |
| 29124 |
object.setScaleY(value); |
| 29125 |
} |
| 29126 |
|
| 29127 |
@Override |
| 29128 |
public Float get(View object) { |
| 29129 |
return object.getScaleY(); |
| 29130 |
} |
| 29131 |
}; |
| 29132 |
|
| 29133 |
|
| 29134 |
|
| 29135 |
|
| 29136 |
|
| 29137 |
|
| 29138 |
|
| 29139 |
|
| 29140 |
|
| 29141 |
|
| 29142 |
|
| 29143 |
|
| 29144 |
|
| 29145 |
|
| 29146 |
|
| 29147 |
|
| 29148 |
|
| 29149 |
|
| 29150 |
|
| 29151 |
|
| 29152 |
|
| 29153 |
|
| 29154 |
|
| 29155 |
|
| 29156 |
|
| 29157 |
|
| 29158 |
|
| 29159 |
|
| 29160 |
public static class MeasureSpec { |
| 29161 |
private static final int MODE_SHIFT = 30; |
| 29162 |
private static final int MODE_MASK = 0x3 << MODE_SHIFT; |
| 29163 |
|
| 29164 |
|
| 29165 |
@IntDef({UNSPECIFIED, EXACTLY, AT_MOST}) |
| 29166 |
@Retention(RetentionPolicy.SOURCE) |
| 29167 |
public @interface MeasureSpecMode {} |
| 29168 |
|
| 29169 |
|
| 29170 |
|
| 29171 |
|
| 29172 |
|
| 29173 |
public static final int UNSPECIFIED = 0 << MODE_SHIFT; |
| 29174 |
|
| 29175 |
|
| 29176 |
|
| 29177 |
|
| 29178 |
|
| 29179 |
|
| 29180 |
public static final int EXACTLY = 1 << MODE_SHIFT; |
| 29181 |
|
| 29182 |
|
| 29183 |
|
| 29184 |
|
| 29185 |
|
| 29186 |
public static final int AT_MOST = 2 << MODE_SHIFT; |
| 29187 |
|
| 29188 |
|
| 29189 |
|
| 29190 |
|
| 29191 |
|
| 29192 |
|
| 29193 |
|
| 29194 |
|
| 29195 |
|
| 29196 |
|
| 29197 |
|
| 29198 |
|
| 29199 |
|
| 29200 |
|
| 29201 |
|
| 29202 |
|
| 29203 |
|
| 29204 |
|
| 29205 |
|
| 29206 |
|
| 29207 |
|
| 29208 |
|
| 29209 |
public static int makeMeasureSpec(@IntRange(from = 0, to = (1 << MeasureSpec.MODE_SHIFT) - 1) int size, |
| 29210 |
@MeasureSpecMode int mode) { |
| 29211 |
if (sUseBrokenMakeMeasureSpec) { |
| 29212 |
return size + mode; |
| 29213 |
} else { |
| 29214 |
return (size & ~MODE_MASK) | (mode & MODE_MASK); |
| 29215 |
} |
| 29216 |
} |
| 29217 |
|
| 29218 |
|
| 29219 |
|
| 29220 |
|
| 29221 |
|
| 29222 |
|
| 29223 |
|
| 29224 |
@UnsupportedAppUsage |
| 29225 |
public static int makeSafeMeasureSpec(int size, int mode) { |
| 29226 |
if (sUseZeroUnspecifiedMeasureSpec && mode == UNSPECIFIED) { |
| 29227 |
return 0; |
| 29228 |
} |
| 29229 |
return makeMeasureSpec(size, mode); |
| 29230 |
} |
| 29231 |
|
| 29232 |
|
| 29233 |
|
| 29234 |
|
| 29235 |
|
| 29236 |
|
| 29237 |
|
| 29238 |
|
| 29239 |
|
| 29240 |
@MeasureSpecMode |
| 29241 |
public static int getMode(int measureSpec) { |
| 29242 |
|
| 29243 |
return (measureSpec & MODE_MASK); |
| 29244 |
} |
| 29245 |
|
| 29246 |
|
| 29247 |
|
| 29248 |
|
| 29249 |
|
| 29250 |
|
| 29251 |
|
| 29252 |
public static int getSize(int measureSpec) { |
| 29253 |
return (measureSpec & ~MODE_MASK); |
| 29254 |
} |
| 29255 |
|
| 29256 |
static int adjust(int measureSpec, int delta) { |
| 29257 |
final int mode = getMode(measureSpec); |
| 29258 |
int size = getSize(measureSpec); |
| 29259 |
if (mode == UNSPECIFIED) { |
| 29260 |
|
| 29261 |
return makeMeasureSpec(size, UNSPECIFIED); |
| 29262 |
} |
| 29263 |
size += delta; |
| 29264 |
if (size < 0) { |
| 29265 |
Log.e(VIEW_LOG_TAG, "MeasureSpec.adjust: new size would be negative! (" + size + |
| 29266 |
") spec: " + toString(measureSpec) + " delta: " + delta); |
| 29267 |
size = 0; |
| 29268 |
} |
| 29269 |
return makeMeasureSpec(size, mode); |
| 29270 |
} |
| 29271 |
|
| 29272 |
|
| 29273 |
|
| 29274 |
|
| 29275 |
|
| 29276 |
|
| 29277 |
|
| 29278 |
|
| 29279 |
public static String toString(int measureSpec) { |
| 29280 |
int mode = getMode(measureSpec); |
| 29281 |
int size = getSize(measureSpec); |
| 29282 |
|
| 29283 |
StringBuilder sb = new StringBuilder("MeasureSpec: "); |
| 29284 |
|
| 29285 |
if (mode == UNSPECIFIED) |
| 29286 |
sb.append("UNSPECIFIED "); |
| 29287 |
else if (mode == EXACTLY) |
| 29288 |
sb.append("EXACTLY "); |
| 29289 |
else if (mode == AT_MOST) |
| 29290 |
sb.append("AT_MOST "); |
| 29291 |
else |
| 29292 |
sb.append(mode).append(" "); |
| 29293 |
|
| 29294 |
sb.append(size); |
| 29295 |
return sb.toString(); |
| 29296 |
} |
| 29297 |
} |
| 29298 |
|
| 29299 |
private final class CheckForLongPress implements Runnable { |
| 29300 |
private int mOriginalWindowAttachCount; |
| 29301 |
private float mX; |
| 29302 |
private float mY; |
| 29303 |
private boolean mOriginalPressedState; |
| 29304 |
|
| 29305 |
|
| 29306 |
|
| 29307 |
|
| 29308 |
private int mClassification; |
| 29309 |
|
| 29310 |
@UnsupportedAppUsage |
| 29311 |
private CheckForLongPress() { |
| 29312 |
} |
| 29313 |
|
| 29314 |
@Override |
| 29315 |
public void run() { |
| 29316 |
if ((mOriginalPressedState == isPressed()) && (mParent != null) |
| 29317 |
&& mOriginalWindowAttachCount == mWindowAttachCount) { |
| 29318 |
recordGestureClassification(mClassification); |
| 29319 |
if (performLongClick(mX, mY)) { |
| 29320 |
mHasPerformedLongPress = true; |
| 29321 |
} |
| 29322 |
} |
| 29323 |
} |
| 29324 |
|
| 29325 |
public void setAnchor(float x, float y) { |
| 29326 |
mX = x; |
| 29327 |
mY = y; |
| 29328 |
} |
| 29329 |
|
| 29330 |
public void rememberWindowAttachCount() { |
| 29331 |
mOriginalWindowAttachCount = mWindowAttachCount; |
| 29332 |
} |
| 29333 |
|
| 29334 |
public void rememberPressedState() { |
| 29335 |
mOriginalPressedState = isPressed(); |
| 29336 |
} |
| 29337 |
|
| 29338 |
public void setClassification(int classification) { |
| 29339 |
mClassification = classification; |
| 29340 |
} |
| 29341 |
} |
| 29342 |
|
| 29343 |
private final class CheckForTap implements Runnable { |
| 29344 |
public float x; |
| 29345 |
public float y; |
| 29346 |
|
| 29347 |
@Override |
| 29348 |
public void run() { |
| 29349 |
mPrivateFlags &= ~PFLAG_PREPRESSED; |
| 29350 |
setPressed(true, x, y); |
| 29351 |
final long delay = |
| 29352 |
ViewConfiguration.getLongPressTimeout() - ViewConfiguration.getTapTimeout(); |
| 29353 |
checkForLongClick(delay, x, y, TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__LONG_PRESS); |
| 29354 |
} |
| 29355 |
} |
| 29356 |
|
| 29357 |
private final class PerformClick implements Runnable { |
| 29358 |
@Override |
| 29359 |
public void run() { |
| 29360 |
recordGestureClassification(TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__SINGLE_TAP); |
| 29361 |
performClickInternal(); |
| 29362 |
} |
| 29363 |
} |
| 29364 |
|
| 29365 |
|
| 29366 |
private void recordGestureClassification(int classification) { |
| 29367 |
if (classification == TOUCH_GESTURE_CLASSIFIED__CLASSIFICATION__UNKNOWN_CLASSIFICATION) { |
| 29368 |
return; |
| 29369 |
} |
| 29370 |
|
| 29371 |
|
| 29372 |
FrameworkStatsLog.write(FrameworkStatsLog.TOUCH_GESTURE_CLASSIFIED, getClass().getName(), |
| 29373 |
classification); |
| 29374 |
} |
| 29375 |
|
| 29376 |
|
| 29377 |
|
| 29378 |
|
| 29379 |
|
| 29380 |
|
| 29381 |
|
| 29382 |
public ViewPropertyAnimator animate() { |
| 29383 |
if (mAnimator == null) { |
| 29384 |
mAnimator = new ViewPropertyAnimator(this); |
| 29385 |
} |
| 29386 |
return mAnimator; |
| 29387 |
} |
| 29388 |
|
| 29389 |
|
| 29390 |
|
| 29391 |
|
| 29392 |
|
| 29393 |
|
| 29394 |
|
| 29395 |
public final void setTransitionName(String transitionName) { |
| 29396 |
mTransitionName = transitionName; |
| 29397 |
} |
| 29398 |
|
| 29399 |
|
| 29400 |
|
| 29401 |
|
| 29402 |
|
| 29403 |
|
| 29404 |
|
| 29405 |
|
| 29406 |
|
| 29407 |
|
| 29408 |
@ViewDebug.ExportedProperty |
| 29409 |
@InspectableProperty |
| 29410 |
public String getTransitionName() { |
| 29411 |
return mTransitionName; |
| 29412 |
} |
| 29413 |
|
| 29414 |
|
| 29415 |
|
| 29416 |
|
| 29417 |
public void requestKeyboardShortcuts(List<KeyboardShortcutGroup> data, int deviceId) { |
| 29418 |
|
| 29419 |
} |
| 29420 |
|
| 29421 |
|
| 29422 |
|
| 29423 |
|
| 29424 |
|
| 29425 |
|
| 29426 |
|
| 29427 |
public interface OnKeyListener { |
| 29428 |
|
| 29429 |
|
| 29430 |
|
| 29431 |
|
| 29432 |
|
| 29433 |
|
| 29434 |
|
| 29435 |
|
| 29436 |
|
| 29437 |
|
| 29438 |
|
| 29439 |
|
| 29440 |
|
| 29441 |
|
| 29442 |
|
| 29443 |
boolean onKey(View v, int keyCode, KeyEvent event); |
| 29444 |
} |
| 29445 |
|
| 29446 |
|
| 29447 |
|
| 29448 |
|
| 29449 |
|
| 29450 |
public interface OnUnhandledKeyEventListener { |
| 29451 |
|
| 29452 |
|
| 29453 |
|
| 29454 |
|
| 29455 |
|
| 29456 |
|
| 29457 |
|
| 29458 |
|
| 29459 |
boolean onUnhandledKeyEvent(View v, KeyEvent event); |
| 29460 |
} |
| 29461 |
|
| 29462 |
|
| 29463 |
|
| 29464 |
|
| 29465 |
|
| 29466 |
|
| 29467 |
public interface OnTouchListener { |
| 29468 |
|
| 29469 |
|
| 29470 |
|
| 29471 |
|
| 29472 |
|
| 29473 |
|
| 29474 |
|
| 29475 |
|
| 29476 |
|
| 29477 |
boolean onTouch(View v, MotionEvent event); |
| 29478 |
} |
| 29479 |
|
| 29480 |
|
| 29481 |
|
| 29482 |
|
| 29483 |
|
| 29484 |
|
| 29485 |
public interface OnHoverListener { |
| 29486 |
|
| 29487 |
|
| 29488 |
|
| 29489 |
|
| 29490 |
|
| 29491 |
|
| 29492 |
|
| 29493 |
|
| 29494 |
|
| 29495 |
boolean onHover(View v, MotionEvent event); |
| 29496 |
} |
| 29497 |
|
| 29498 |
|
| 29499 |
|
| 29500 |
|
| 29501 |
|
| 29502 |
|
| 29503 |
public interface OnGenericMotionListener { |
| 29504 |
|
| 29505 |
|
| 29506 |
|
| 29507 |
|
| 29508 |
|
| 29509 |
|
| 29510 |
|
| 29511 |
|
| 29512 |
|
| 29513 |
boolean onGenericMotion(View v, MotionEvent event); |
| 29514 |
} |
| 29515 |
|
| 29516 |
|
| 29517 |
|
| 29518 |
|
| 29519 |
public interface OnLongClickListener { |
| 29520 |
|
| 29521 |
|
| 29522 |
|
| 29523 |
|
| 29524 |
|
| 29525 |
|
| 29526 |
|
| 29527 |
boolean onLongClick(View v); |
| 29528 |
} |
| 29529 |
|
| 29530 |
|
| 29531 |
|
| 29532 |
|
| 29533 |
|
| 29534 |
|
| 29535 |
|
| 29536 |
|
| 29537 |
|
| 29538 |
|
| 29539 |
|
| 29540 |
|
| 29541 |
|
| 29542 |
public interface OnDragListener { |
| 29543 |
|
| 29544 |
|
| 29545 |
|
| 29546 |
|
| 29547 |
|
| 29548 |
|
| 29549 |
|
| 29550 |
|
| 29551 |
|
| 29552 |
|
| 29553 |
boolean onDrag(View v, DragEvent event); |
| 29554 |
} |
| 29555 |
|
| 29556 |
|
| 29557 |
|
| 29558 |
|
| 29559 |
|
| 29560 |
public interface OnFocusChangeListener { |
| 29561 |
|
| 29562 |
|
| 29563 |
|
| 29564 |
|
| 29565 |
|
| 29566 |
|
| 29567 |
void onFocusChange(View v, boolean hasFocus); |
| 29568 |
} |
| 29569 |
|
| 29570 |
|
| 29571 |
|
| 29572 |
|
| 29573 |
public interface OnClickListener { |
| 29574 |
|
| 29575 |
|
| 29576 |
|
| 29577 |
|
| 29578 |
|
| 29579 |
void onClick(View v); |
| 29580 |
} |
| 29581 |
|
| 29582 |
|
| 29583 |
|
| 29584 |
|
| 29585 |
public interface OnContextClickListener { |
| 29586 |
|
| 29587 |
|
| 29588 |
|
| 29589 |
|
| 29590 |
|
| 29591 |
|
| 29592 |
boolean onContextClick(View v); |
| 29593 |
} |
| 29594 |
|
| 29595 |
|
| 29596 |
|
| 29597 |
|
| 29598 |
|
| 29599 |
public interface OnCreateContextMenuListener { |
| 29600 |
|
| 29601 |
|
| 29602 |
|
| 29603 |
|
| 29604 |
|
| 29605 |
|
| 29606 |
|
| 29607 |
|
| 29608 |
|
| 29609 |
|
| 29610 |
void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo); |
| 29611 |
} |
| 29612 |
|
| 29613 |
|
| 29614 |
|
| 29615 |
|
| 29616 |
|
| 29617 |
|
| 29618 |
|
| 29619 |
|
| 29620 |
|
| 29621 |
|
| 29622 |
|
| 29623 |
@Deprecated |
| 29624 |
public interface OnSystemUiVisibilityChangeListener { |
| 29625 |
|
| 29626 |
|
| 29627 |
|
| 29628 |
|
| 29629 |
|
| 29630 |
|
| 29631 |
|
| 29632 |
|
| 29633 |
|
| 29634 |
public void onSystemUiVisibilityChange(int visibility); |
| 29635 |
} |
| 29636 |
|
| 29637 |
|
| 29638 |
|
| 29639 |
|
| 29640 |
|
| 29641 |
public interface OnAttachStateChangeListener { |
| 29642 |
|
| 29643 |
|
| 29644 |
|
| 29645 |
|
| 29646 |
public void onViewAttachedToWindow(@NonNull View v); |
| 29647 |
|
| 29648 |
|
| 29649 |
|
| 29650 |
|
| 29651 |
public void onViewDetachedFromWindow(@NonNull View v); |
| 29652 |
} |
| 29653 |
|
| 29654 |
|
| 29655 |
|
| 29656 |
|
| 29657 |
|
| 29658 |
|
| 29659 |
|
| 29660 |
|
| 29661 |
|
| 29662 |
|
| 29663 |
|
| 29664 |
|
| 29665 |
|
| 29666 |
public interface OnApplyWindowInsetsListener { |
| 29667 |
|
| 29668 |
|
| 29669 |
|
| 29670 |
|
| 29671 |
|
| 29672 |
|
| 29673 |
|
| 29674 |
|
| 29675 |
|
| 29676 |
public @NonNull WindowInsets onApplyWindowInsets(@NonNull View v, |
| 29677 |
@NonNull WindowInsets insets); |
| 29678 |
} |
| 29679 |
|
| 29680 |
private final class UnsetPressedState implements Runnable { |
| 29681 |
@Override |
| 29682 |
public void run() { |
| 29683 |
setPressed(false); |
| 29684 |
} |
| 29685 |
} |
| 29686 |
|
| 29687 |
|
| 29688 |
|
| 29689 |
|
| 29690 |
|
| 29691 |
|
| 29692 |
private static class VisibilityChangeForAutofillHandler extends Handler { |
| 29693 |
private final AutofillManager mAfm; |
| 29694 |
private final View mView; |
| 29695 |
|
| 29696 |
private VisibilityChangeForAutofillHandler(@NonNull AutofillManager afm, |
| 29697 |
@NonNull View view) { |
| 29698 |
mAfm = afm; |
| 29699 |
mView = view; |
| 29700 |
} |
| 29701 |
|
| 29702 |
@Override |
| 29703 |
public void handleMessage(Message msg) { |
| 29704 |
mAfm.notifyViewVisibilityChanged(mView, mView.isShown()); |
| 29705 |
} |
| 29706 |
} |
| 29707 |
|
| 29708 |
|
| 29709 |
|
| 29710 |
|
| 29711 |
|
| 29712 |
public static class BaseSavedState extends AbsSavedState { |
| 29713 |
static final int START_ACTIVITY_REQUESTED_WHO_SAVED = 0b1; |
| 29714 |
static final int IS_AUTOFILLED = 0b10; |
| 29715 |
static final int AUTOFILL_ID = 0b100; |
| 29716 |
|
| 29717 |
|
| 29718 |
int mSavedData; |
| 29719 |
String mStartActivityRequestWhoSaved; |
| 29720 |
boolean mIsAutofilled; |
| 29721 |
boolean mHideHighlight; |
| 29722 |
int mAutofillViewId; |
| 29723 |
|
| 29724 |
|
| 29725 |
|
| 29726 |
|
| 29727 |
|
| 29728 |
|
| 29729 |
public BaseSavedState(Parcel source) { |
| 29730 |
this(source, null); |
| 29731 |
} |
| 29732 |
|
| 29733 |
|
| 29734 |
|
| 29735 |
|
| 29736 |
|
| 29737 |
|
| 29738 |
|
| 29739 |
|
| 29740 |
public BaseSavedState(Parcel source, ClassLoader loader) { |
| 29741 |
super(source, loader); |
| 29742 |
mSavedData = source.readInt(); |
| 29743 |
mStartActivityRequestWhoSaved = source.readString(); |
| 29744 |
mIsAutofilled = source.readBoolean(); |
| 29745 |
mHideHighlight = source.readBoolean(); |
| 29746 |
mAutofillViewId = source.readInt(); |
| 29747 |
} |
| 29748 |
|
| 29749 |
|
| 29750 |
|
| 29751 |
|
| 29752 |
|
| 29753 |
|
| 29754 |
public BaseSavedState(Parcelable superState) { |
| 29755 |
super(superState); |
| 29756 |
} |
| 29757 |
|
| 29758 |
@Override |
| 29759 |
public void writeToParcel(Parcel out, int flags) { |
| 29760 |
super.writeToParcel(out, flags); |
| 29761 |
|
| 29762 |
out.writeInt(mSavedData); |
| 29763 |
out.writeString(mStartActivityRequestWhoSaved); |
| 29764 |
out.writeBoolean(mIsAutofilled); |
| 29765 |
out.writeBoolean(mHideHighlight); |
| 29766 |
out.writeInt(mAutofillViewId); |
| 29767 |
} |
| 29768 |
|
| 29769 |
public static final @android.annotation.NonNull Parcelable.Creator<BaseSavedState> CREATOR |
| 29770 |
= new Parcelable.ClassLoaderCreator<BaseSavedState>() { |
| 29771 |
@Override |
| 29772 |
public BaseSavedState createFromParcel(Parcel in) { |
| 29773 |
return new BaseSavedState(in); |
| 29774 |
} |
| 29775 |
|
| 29776 |
@Override |
| 29777 |
public BaseSavedState createFromParcel(Parcel in, ClassLoader loader) { |
| 29778 |
return new BaseSavedState(in, loader); |
| 29779 |
} |
| 29780 |
|
| 29781 |
@Override |
| 29782 |
public BaseSavedState[] newArray(int size) { |
| 29783 |
return new BaseSavedState[size]; |
| 29784 |
} |
| 29785 |
}; |
| 29786 |
} |
| 29787 |
|
| 29788 |
|
| 29789 |
|
| 29790 |
|
| 29791 |
|
| 29792 |
final static class AttachInfo { |
| 29793 |
|
| 29794 |
interface Callbacks { |
| 29795 |
void playSoundEffect(int effectId); |
| 29796 |
boolean performHapticFeedback(int effectId, boolean always); |
| 29797 |
} |
| 29798 |
|
| 29799 |
|
| 29800 |
|
| 29801 |
|
| 29802 |
|
| 29803 |
|
| 29804 |
|
| 29805 |
|
| 29806 |
|
| 29807 |
|
| 29808 |
static class InvalidateInfo { |
| 29809 |
|
| 29810 |
@UnsupportedAppUsage |
| 29811 |
InvalidateInfo() { |
| 29812 |
} |
| 29813 |
|
| 29814 |
private static final int POOL_LIMIT = 10; |
| 29815 |
|
| 29816 |
private static final SynchronizedPool<InvalidateInfo> sPool = |
| 29817 |
new SynchronizedPool<InvalidateInfo>(POOL_LIMIT); |
| 29818 |
|
| 29819 |
@UnsupportedAppUsage |
| 29820 |
View target; |
| 29821 |
|
| 29822 |
@UnsupportedAppUsage |
| 29823 |
int left; |
| 29824 |
@UnsupportedAppUsage |
| 29825 |
int top; |
| 29826 |
@UnsupportedAppUsage |
| 29827 |
int right; |
| 29828 |
@UnsupportedAppUsage |
| 29829 |
int bottom; |
| 29830 |
|
| 29831 |
public static InvalidateInfo obtain() { |
| 29832 |
InvalidateInfo instance = sPool.acquire(); |
| 29833 |
return (instance != null) ? instance : new InvalidateInfo(); |
| 29834 |
} |
| 29835 |
|
| 29836 |
public void recycle() { |
| 29837 |
target = null; |
| 29838 |
sPool.release(this); |
| 29839 |
} |
| 29840 |
} |
| 29841 |
|
| 29842 |
@UnsupportedAppUsage |
| 29843 |
final IWindowSession mSession; |
| 29844 |
|
| 29845 |
@UnsupportedAppUsage |
| 29846 |
final IWindow mWindow; |
| 29847 |
|
| 29848 |
final IBinder mWindowToken; |
| 29849 |
|
| 29850 |
Display mDisplay; |
| 29851 |
|
| 29852 |
final Callbacks mRootCallbacks; |
| 29853 |
|
| 29854 |
IWindowId mIWindowId; |
| 29855 |
WindowId mWindowId; |
| 29856 |
|
| 29857 |
|
| 29858 |
|
| 29859 |
|
| 29860 |
View mRootView; |
| 29861 |
|
| 29862 |
IBinder mPanelParentWindowToken; |
| 29863 |
|
| 29864 |
boolean mHardwareAccelerated; |
| 29865 |
boolean mHardwareAccelerationRequested; |
| 29866 |
ThreadedRenderer mThreadedRenderer; |
| 29867 |
List<RenderNode> mPendingAnimatingRenderNodes; |
| 29868 |
|
| 29869 |
|
| 29870 |
|
| 29871 |
|
| 29872 |
|
| 29873 |
|
| 29874 |
|
| 29875 |
|
| 29876 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 29877 |
int mDisplayState = Display.STATE_UNKNOWN; |
| 29878 |
|
| 29879 |
|
| 29880 |
|
| 29881 |
|
| 29882 |
@UnsupportedAppUsage |
| 29883 |
float mApplicationScale; |
| 29884 |
|
| 29885 |
|
| 29886 |
|
| 29887 |
|
| 29888 |
@UnsupportedAppUsage |
| 29889 |
boolean mScalingRequired; |
| 29890 |
|
| 29891 |
|
| 29892 |
|
| 29893 |
|
| 29894 |
int mWindowLeft; |
| 29895 |
|
| 29896 |
|
| 29897 |
|
| 29898 |
|
| 29899 |
int mWindowTop; |
| 29900 |
|
| 29901 |
|
| 29902 |
|
| 29903 |
|
| 29904 |
boolean mUse32BitDrawingCache; |
| 29905 |
|
| 29906 |
|
| 29907 |
|
| 29908 |
|
| 29909 |
|
| 29910 |
|
| 29911 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, |
| 29912 |
publicAlternatives = "Use {@link WindowInsets#getInsets(int)}") |
| 29913 |
final Rect mContentInsets = new Rect(); |
| 29914 |
|
| 29915 |
|
| 29916 |
|
| 29917 |
|
| 29918 |
|
| 29919 |
|
| 29920 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, |
| 29921 |
publicAlternatives = "Use {@link WindowInsets#getInsets(int)}") |
| 29922 |
final Rect mVisibleInsets = new Rect(); |
| 29923 |
|
| 29924 |
|
| 29925 |
|
| 29926 |
|
| 29927 |
|
| 29928 |
|
| 29929 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.Q, |
| 29930 |
publicAlternatives = "Use {@link WindowInsets#getInsets(int)}") |
| 29931 |
final Rect mStableInsets = new Rect(); |
| 29932 |
|
| 29933 |
|
| 29934 |
|
| 29935 |
|
| 29936 |
final Rect mCaptionInsets = new Rect(); |
| 29937 |
|
| 29938 |
|
| 29939 |
|
| 29940 |
|
| 29941 |
|
| 29942 |
|
| 29943 |
boolean mAlwaysConsumeSystemBars; |
| 29944 |
|
| 29945 |
|
| 29946 |
|
| 29947 |
|
| 29948 |
|
| 29949 |
|
| 29950 |
|
| 29951 |
|
| 29952 |
@UnsupportedAppUsage |
| 29953 |
final ViewTreeObserver.InternalInsetsInfo mGivenInternalInsets |
| 29954 |
= new ViewTreeObserver.InternalInsetsInfo(); |
| 29955 |
|
| 29956 |
|
| 29957 |
|
| 29958 |
|
| 29959 |
boolean mHasNonEmptyGivenInternalInsets; |
| 29960 |
|
| 29961 |
|
| 29962 |
|
| 29963 |
|
| 29964 |
|
| 29965 |
|
| 29966 |
@UnsupportedAppUsage |
| 29967 |
final ArrayList<View> mScrollContainers = new ArrayList<View>(); |
| 29968 |
|
| 29969 |
@UnsupportedAppUsage |
| 29970 |
final KeyEvent.DispatcherState mKeyDispatchState |
| 29971 |
= new KeyEvent.DispatcherState(); |
| 29972 |
|
| 29973 |
|
| 29974 |
|
| 29975 |
|
| 29976 |
@UnsupportedAppUsage |
| 29977 |
boolean mHasWindowFocus; |
| 29978 |
|
| 29979 |
|
| 29980 |
|
| 29981 |
|
| 29982 |
int mWindowVisibility; |
| 29983 |
|
| 29984 |
|
| 29985 |
|
| 29986 |
|
| 29987 |
@UnsupportedAppUsage |
| 29988 |
long mDrawingTime; |
| 29989 |
|
| 29990 |
|
| 29991 |
|
| 29992 |
|
| 29993 |
@UnsupportedAppUsage |
| 29994 |
boolean mInTouchMode; |
| 29995 |
|
| 29996 |
|
| 29997 |
|
| 29998 |
|
| 29999 |
|
| 30000 |
boolean mUnbufferedDispatchRequested; |
| 30001 |
|
| 30002 |
|
| 30003 |
|
| 30004 |
|
| 30005 |
|
| 30006 |
@UnsupportedAppUsage |
| 30007 |
boolean mRecomputeGlobalAttributes; |
| 30008 |
|
| 30009 |
|
| 30010 |
|
| 30011 |
|
| 30012 |
boolean mForceReportNewAttributes; |
| 30013 |
|
| 30014 |
|
| 30015 |
|
| 30016 |
|
| 30017 |
@UnsupportedAppUsage |
| 30018 |
boolean mKeepScreenOn; |
| 30019 |
|
| 30020 |
|
| 30021 |
|
| 30022 |
|
| 30023 |
boolean mNeedsUpdateLightCenter; |
| 30024 |
|
| 30025 |
|
| 30026 |
|
| 30027 |
|
| 30028 |
int mSystemUiVisibility; |
| 30029 |
|
| 30030 |
|
| 30031 |
|
| 30032 |
|
| 30033 |
int mDisabledSystemUiVisibility; |
| 30034 |
|
| 30035 |
|
| 30036 |
|
| 30037 |
|
| 30038 |
|
| 30039 |
boolean mHasSystemUiListeners; |
| 30040 |
|
| 30041 |
|
| 30042 |
|
| 30043 |
|
| 30044 |
@UnsupportedAppUsage |
| 30045 |
boolean mViewVisibilityChanged; |
| 30046 |
|
| 30047 |
|
| 30048 |
|
| 30049 |
|
| 30050 |
@UnsupportedAppUsage |
| 30051 |
boolean mViewScrollChanged; |
| 30052 |
|
| 30053 |
|
| 30054 |
|
| 30055 |
|
| 30056 |
boolean mHandlingPointerEvent; |
| 30057 |
|
| 30058 |
|
| 30059 |
|
| 30060 |
|
| 30061 |
|
| 30062 |
Matrix mWindowMatrixInEmbeddedHierarchy; |
| 30063 |
|
| 30064 |
|
| 30065 |
|
| 30066 |
|
| 30067 |
|
| 30068 |
final int[] mTransparentLocation = new int[2]; |
| 30069 |
|
| 30070 |
|
| 30071 |
|
| 30072 |
|
| 30073 |
|
| 30074 |
final int[] mInvalidateChildLocation = new int[2]; |
| 30075 |
|
| 30076 |
|
| 30077 |
|
| 30078 |
|
| 30079 |
|
| 30080 |
final int[] mTmpLocation = new int[2]; |
| 30081 |
|
| 30082 |
|
| 30083 |
|
| 30084 |
|
| 30085 |
|
| 30086 |
final float[] mTmpTransformLocation = new float[2]; |
| 30087 |
|
| 30088 |
|
| 30089 |
|
| 30090 |
|
| 30091 |
|
| 30092 |
@UnsupportedAppUsage |
| 30093 |
final ViewTreeObserver mTreeObserver; |
| 30094 |
|
| 30095 |
|
| 30096 |
|
| 30097 |
|
| 30098 |
Canvas mCanvas; |
| 30099 |
|
| 30100 |
|
| 30101 |
|
| 30102 |
|
| 30103 |
final ViewRootImpl mViewRootImpl; |
| 30104 |
|
| 30105 |
|
| 30106 |
|
| 30107 |
|
| 30108 |
|
| 30109 |
@UnsupportedAppUsage |
| 30110 |
final Handler mHandler; |
| 30111 |
|
| 30112 |
|
| 30113 |
|
| 30114 |
|
| 30115 |
|
| 30116 |
final Rect mTmpInvalRect = new Rect(); |
| 30117 |
|
| 30118 |
|
| 30119 |
|
| 30120 |
|
| 30121 |
final RectF mTmpTransformRect = new RectF(); |
| 30122 |
|
| 30123 |
|
| 30124 |
|
| 30125 |
|
| 30126 |
final RectF mTmpTransformRect1 = new RectF(); |
| 30127 |
|
| 30128 |
|
| 30129 |
|
| 30130 |
|
| 30131 |
final List<RectF> mTmpRectList = new ArrayList<>(); |
| 30132 |
|
| 30133 |
|
| 30134 |
|
| 30135 |
|
| 30136 |
final Matrix mTmpMatrix = new Matrix(); |
| 30137 |
|
| 30138 |
|
| 30139 |
|
| 30140 |
|
| 30141 |
final Transformation mTmpTransformation = new Transformation(); |
| 30142 |
|
| 30143 |
|
| 30144 |
|
| 30145 |
|
| 30146 |
final Outline mTmpOutline = new Outline(); |
| 30147 |
|
| 30148 |
|
| 30149 |
|
| 30150 |
|
| 30151 |
final ArrayList<View> mTempArrayList = new ArrayList<View>(24); |
| 30152 |
|
| 30153 |
|
| 30154 |
|
| 30155 |
|
| 30156 |
int mAccessibilityWindowId = AccessibilityWindowInfo.UNDEFINED_WINDOW_ID; |
| 30157 |
|
| 30158 |
|
| 30159 |
|
| 30160 |
|
| 30161 |
|
| 30162 |
|
| 30163 |
|
| 30164 |
int mAccessibilityFetchFlags; |
| 30165 |
|
| 30166 |
|
| 30167 |
|
| 30168 |
|
| 30169 |
Drawable mAccessibilityFocusDrawable; |
| 30170 |
|
| 30171 |
|
| 30172 |
|
| 30173 |
|
| 30174 |
|
| 30175 |
|
| 30176 |
Drawable mAutofilledDrawable; |
| 30177 |
|
| 30178 |
|
| 30179 |
|
| 30180 |
|
| 30181 |
boolean mDebugLayout = DisplayProperties.debug_layout().orElse(false); |
| 30182 |
|
| 30183 |
|
| 30184 |
|
| 30185 |
|
| 30186 |
final Point mPoint = new Point(); |
| 30187 |
|
| 30188 |
|
| 30189 |
|
| 30190 |
|
| 30191 |
|
| 30192 |
View mViewRequestingLayout; |
| 30193 |
|
| 30194 |
|
| 30195 |
|
| 30196 |
|
| 30197 |
IBinder mDragToken; |
| 30198 |
|
| 30199 |
|
| 30200 |
|
| 30201 |
|
| 30202 |
public Surface mDragSurface; |
| 30203 |
|
| 30204 |
|
| 30205 |
|
| 30206 |
|
| 30207 |
|
| 30208 |
View mTooltipHost; |
| 30209 |
|
| 30210 |
|
| 30211 |
|
| 30212 |
|
| 30213 |
boolean mReadyForContentCaptureUpdates; |
| 30214 |
|
| 30215 |
|
| 30216 |
|
| 30217 |
|
| 30218 |
|
| 30219 |
|
| 30220 |
SparseArray<ArrayList<Object>> mContentCaptureEvents; |
| 30221 |
|
| 30222 |
|
| 30223 |
|
| 30224 |
|
| 30225 |
ContentCaptureManager mContentCaptureManager; |
| 30226 |
|
| 30227 |
|
| 30228 |
|
| 30229 |
|
| 30230 |
OnContentApplyWindowInsetsListener mContentOnApplyWindowInsetsListener; |
| 30231 |
|
| 30232 |
|
| 30233 |
|
| 30234 |
|
| 30235 |
|
| 30236 |
IBinder mLeashedParentToken; |
| 30237 |
|
| 30238 |
|
| 30239 |
|
| 30240 |
|
| 30241 |
|
| 30242 |
int mLeashedParentAccessibilityViewId; |
| 30243 |
|
| 30244 |
|
| 30245 |
|
| 30246 |
|
| 30247 |
ScrollCaptureInternal mScrollCaptureInternal; |
| 30248 |
|
| 30249 |
|
| 30250 |
|
| 30251 |
|
| 30252 |
|
| 30253 |
|
| 30254 |
|
| 30255 |
AttachInfo(IWindowSession session, IWindow window, Display display, |
| 30256 |
ViewRootImpl viewRootImpl, Handler handler, Callbacks effectPlayer, |
| 30257 |
Context context) { |
| 30258 |
mSession = session; |
| 30259 |
mWindow = window; |
| 30260 |
mWindowToken = window.asBinder(); |
| 30261 |
mDisplay = display; |
| 30262 |
mViewRootImpl = viewRootImpl; |
| 30263 |
mHandler = handler; |
| 30264 |
mRootCallbacks = effectPlayer; |
| 30265 |
mTreeObserver = new ViewTreeObserver(context); |
| 30266 |
} |
| 30267 |
|
| 30268 |
@Nullable |
| 30269 |
ContentCaptureManager getContentCaptureManager(@NonNull Context context) { |
| 30270 |
if (mContentCaptureManager != null) { |
| 30271 |
return mContentCaptureManager; |
| 30272 |
} |
| 30273 |
mContentCaptureManager = context.getSystemService(ContentCaptureManager.class); |
| 30274 |
return mContentCaptureManager; |
| 30275 |
} |
| 30276 |
|
| 30277 |
void delayNotifyContentCaptureInsetsEvent(@NonNull Insets insets) { |
| 30278 |
if (mContentCaptureManager == null) { |
| 30279 |
return; |
| 30280 |
} |
| 30281 |
|
| 30282 |
ArrayList<Object> events = ensureEvents( |
| 30283 |
mContentCaptureManager.getMainContentCaptureSession()); |
| 30284 |
events.add(insets); |
| 30285 |
} |
| 30286 |
|
| 30287 |
private void delayNotifyContentCaptureEvent(@NonNull ContentCaptureSession session, |
| 30288 |
@NonNull View view, boolean appeared) { |
| 30289 |
ArrayList<Object> events = ensureEvents(session); |
| 30290 |
events.add(appeared ? view : view.getAutofillId()); |
| 30291 |
} |
| 30292 |
|
| 30293 |
@NonNull |
| 30294 |
private ArrayList<Object> ensureEvents(@NonNull ContentCaptureSession session) { |
| 30295 |
if (mContentCaptureEvents == null) { |
| 30296 |
|
| 30297 |
mContentCaptureEvents = new SparseArray<>(1); |
| 30298 |
} |
| 30299 |
int sessionId = session.getId(); |
| 30300 |
|
| 30301 |
ArrayList<Object> events = mContentCaptureEvents.get(sessionId); |
| 30302 |
if (events == null) { |
| 30303 |
events = new ArrayList<>(); |
| 30304 |
mContentCaptureEvents.put(sessionId, events); |
| 30305 |
} |
| 30306 |
|
| 30307 |
return events; |
| 30308 |
} |
| 30309 |
|
| 30310 |
@Nullable |
| 30311 |
ScrollCaptureInternal getScrollCaptureInternal() { |
| 30312 |
if (mScrollCaptureInternal != null) { |
| 30313 |
mScrollCaptureInternal = new ScrollCaptureInternal(); |
| 30314 |
} |
| 30315 |
return mScrollCaptureInternal; |
| 30316 |
} |
| 30317 |
|
| 30318 |
AttachedSurfaceControl getRootSurfaceControl() { |
| 30319 |
return mViewRootImpl; |
| 30320 |
} |
| 30321 |
|
| 30322 |
public void dump(String prefix, PrintWriter writer) { |
| 30323 |
String innerPrefix = prefix + " "; |
| 30324 |
writer.println(prefix + "AttachInfo:"); |
| 30325 |
writer.println(innerPrefix + "mHasWindowFocus=" + mHasWindowFocus); |
| 30326 |
writer.println(innerPrefix + "mWindowVisibility=" + mWindowVisibility); |
| 30327 |
writer.println(innerPrefix + "mInTouchMode=" + mInTouchMode); |
| 30328 |
writer.println(innerPrefix + "mUnbufferedDispatchRequested=" |
| 30329 |
+ mUnbufferedDispatchRequested); |
| 30330 |
} |
| 30331 |
} |
| 30332 |
|
| 30333 |
|
| 30334 |
|
| 30335 |
|
| 30336 |
|
| 30337 |
|
| 30338 |
private static class ScrollabilityCache implements Runnable { |
| 30339 |
|
| 30340 |
|
| 30341 |
|
| 30342 |
|
| 30343 |
public static final int OFF = 0; |
| 30344 |
|
| 30345 |
|
| 30346 |
|
| 30347 |
|
| 30348 |
public static final int ON = 1; |
| 30349 |
|
| 30350 |
|
| 30351 |
|
| 30352 |
|
| 30353 |
public static final int FADING = 2; |
| 30354 |
|
| 30355 |
public boolean fadeScrollBars; |
| 30356 |
|
| 30357 |
public int fadingEdgeLength; |
| 30358 |
public int scrollBarDefaultDelayBeforeFade; |
| 30359 |
public int scrollBarFadeDuration; |
| 30360 |
|
| 30361 |
public int scrollBarSize; |
| 30362 |
public int scrollBarMinTouchTarget; |
| 30363 |
@UnsupportedAppUsage |
| 30364 |
public ScrollBarDrawable scrollBar; |
| 30365 |
public float[] interpolatorValues; |
| 30366 |
@UnsupportedAppUsage |
| 30367 |
public View host; |
| 30368 |
|
| 30369 |
public final Paint paint; |
| 30370 |
public final Matrix matrix; |
| 30371 |
public Shader shader; |
| 30372 |
|
| 30373 |
public final Interpolator scrollBarInterpolator = new Interpolator(1, 2); |
| 30374 |
|
| 30375 |
private static final float[] OPAQUE = { 255 }; |
| 30376 |
private static final float[] TRANSPARENT = { 0.0f }; |
| 30377 |
|
| 30378 |
|
| 30379 |
|
| 30380 |
|
| 30381 |
|
| 30382 |
public long fadeStartTime; |
| 30383 |
|
| 30384 |
|
| 30385 |
|
| 30386 |
|
| 30387 |
|
| 30388 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 30389 |
public int state = OFF; |
| 30390 |
|
| 30391 |
private int mLastColor; |
| 30392 |
|
| 30393 |
public final Rect mScrollBarBounds = new Rect(); |
| 30394 |
public final Rect mScrollBarTouchBounds = new Rect(); |
| 30395 |
|
| 30396 |
public static final int NOT_DRAGGING = 0; |
| 30397 |
public static final int DRAGGING_VERTICAL_SCROLL_BAR = 1; |
| 30398 |
public static final int DRAGGING_HORIZONTAL_SCROLL_BAR = 2; |
| 30399 |
public int mScrollBarDraggingState = NOT_DRAGGING; |
| 30400 |
|
| 30401 |
public float mScrollBarDraggingPos = 0; |
| 30402 |
|
| 30403 |
public ScrollabilityCache(ViewConfiguration configuration, View host) { |
| 30404 |
fadingEdgeLength = configuration.getScaledFadingEdgeLength(); |
| 30405 |
scrollBarSize = configuration.getScaledScrollBarSize(); |
| 30406 |
scrollBarMinTouchTarget = configuration.getScaledMinScrollbarTouchTarget(); |
| 30407 |
scrollBarDefaultDelayBeforeFade = ViewConfiguration.getScrollDefaultDelay(); |
| 30408 |
scrollBarFadeDuration = ViewConfiguration.getScrollBarFadeDuration(); |
| 30409 |
|
| 30410 |
paint = new Paint(); |
| 30411 |
matrix = new Matrix(); |
| 30412 |
|
| 30413 |
|
| 30414 |
shader = new LinearGradient(0, 0, 0, 1, 0xFF000000, 0, Shader.TileMode.CLAMP); |
| 30415 |
paint.setShader(shader); |
| 30416 |
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); |
| 30417 |
|
| 30418 |
this.host = host; |
| 30419 |
} |
| 30420 |
|
| 30421 |
public void setFadeColor(int color) { |
| 30422 |
if (color != mLastColor) { |
| 30423 |
mLastColor = color; |
| 30424 |
|
| 30425 |
if (color != 0) { |
| 30426 |
shader = new LinearGradient(0, 0, 0, 1, color | 0xFF000000, |
| 30427 |
color & 0x00FFFFFF, Shader.TileMode.CLAMP); |
| 30428 |
paint.setShader(shader); |
| 30429 |
|
| 30430 |
paint.setXfermode(null); |
| 30431 |
} else { |
| 30432 |
shader = new LinearGradient(0, 0, 0, 1, 0xFF000000, 0, Shader.TileMode.CLAMP); |
| 30433 |
paint.setShader(shader); |
| 30434 |
paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.DST_OUT)); |
| 30435 |
} |
| 30436 |
} |
| 30437 |
} |
| 30438 |
|
| 30439 |
public void run() { |
| 30440 |
long now = AnimationUtils.currentAnimationTimeMillis(); |
| 30441 |
if (now >= fadeStartTime) { |
| 30442 |
|
| 30443 |
|
| 30444 |
|
| 30445 |
|
| 30446 |
int nextFrame = (int) now; |
| 30447 |
int framesCount = 0; |
| 30448 |
|
| 30449 |
Interpolator interpolator = scrollBarInterpolator; |
| 30450 |
|
| 30451 |
|
| 30452 |
interpolator.setKeyFrame(framesCount++, nextFrame, OPAQUE); |
| 30453 |
|
| 30454 |
|
| 30455 |
nextFrame += scrollBarFadeDuration; |
| 30456 |
interpolator.setKeyFrame(framesCount, nextFrame, TRANSPARENT); |
| 30457 |
|
| 30458 |
state = FADING; |
| 30459 |
|
| 30460 |
|
| 30461 |
host.invalidate(true); |
| 30462 |
} |
| 30463 |
} |
| 30464 |
} |
| 30465 |
|
| 30466 |
private class SendAccessibilityEventThrottle implements Runnable { |
| 30467 |
public volatile boolean mIsPending; |
| 30468 |
private AccessibilityEvent mAccessibilityEvent; |
| 30469 |
|
| 30470 |
public void post(AccessibilityEvent accessibilityEvent) { |
| 30471 |
updateWithAccessibilityEvent(accessibilityEvent); |
| 30472 |
if (!mIsPending) { |
| 30473 |
mIsPending = true; |
| 30474 |
postDelayed(this, |
| 30475 |
ViewConfiguration.getSendRecurringAccessibilityEventsInterval()); |
| 30476 |
} |
| 30477 |
} |
| 30478 |
|
| 30479 |
@Override |
| 30480 |
public void run() { |
| 30481 |
if (AccessibilityManager.getInstance(mContext).isEnabled() && isShown()) { |
| 30482 |
requestParentSendAccessibilityEvent(mAccessibilityEvent); |
| 30483 |
} |
| 30484 |
reset(); |
| 30485 |
} |
| 30486 |
|
| 30487 |
public void updateWithAccessibilityEvent(AccessibilityEvent accessibilityEvent) { |
| 30488 |
mAccessibilityEvent = accessibilityEvent; |
| 30489 |
} |
| 30490 |
|
| 30491 |
public void reset() { |
| 30492 |
mIsPending = false; |
| 30493 |
mAccessibilityEvent = null; |
| 30494 |
} |
| 30495 |
|
| 30496 |
} |
| 30497 |
|
| 30498 |
|
| 30499 |
|
| 30500 |
|
| 30501 |
|
| 30502 |
private class SendViewScrolledAccessibilityEvent extends SendAccessibilityEventThrottle { |
| 30503 |
public int mDeltaX; |
| 30504 |
public int mDeltaY; |
| 30505 |
|
| 30506 |
@Override |
| 30507 |
public void updateWithAccessibilityEvent(AccessibilityEvent accessibilityEvent) { |
| 30508 |
super.updateWithAccessibilityEvent(accessibilityEvent); |
| 30509 |
mDeltaX += accessibilityEvent.getScrollDeltaX(); |
| 30510 |
mDeltaY += accessibilityEvent.getScrollDeltaY(); |
| 30511 |
accessibilityEvent.setScrollDeltaX(mDeltaX); |
| 30512 |
accessibilityEvent.setScrollDeltaY(mDeltaY); |
| 30513 |
} |
| 30514 |
|
| 30515 |
@Override |
| 30516 |
public void reset() { |
| 30517 |
super.reset(); |
| 30518 |
mDeltaX = 0; |
| 30519 |
mDeltaY = 0; |
| 30520 |
} |
| 30521 |
} |
| 30522 |
|
| 30523 |
|
| 30524 |
|
| 30525 |
@UnsupportedAppUsage |
| 30526 |
private void cancel(@Nullable SendAccessibilityEventThrottle callback) { |
| 30527 |
if (callback == null || !callback.mIsPending) return; |
| 30528 |
removeCallbacks(callback); |
| 30529 |
callback.reset(); |
| 30530 |
} |
| 30531 |
|
| 30532 |
|
| 30533 |
|
| 30534 |
|
| 30535 |
|
| 30536 |
|
| 30537 |
|
| 30538 |
|
| 30539 |
|
| 30540 |
|
| 30541 |
|
| 30542 |
|
| 30543 |
|
| 30544 |
|
| 30545 |
|
| 30546 |
|
| 30547 |
|
| 30548 |
|
| 30549 |
|
| 30550 |
|
| 30551 |
|
| 30552 |
|
| 30553 |
|
| 30554 |
|
| 30555 |
|
| 30556 |
|
| 30557 |
|
| 30558 |
|
| 30559 |
|
| 30560 |
|
| 30561 |
|
| 30562 |
|
| 30563 |
|
| 30564 |
|
| 30565 |
|
| 30566 |
|
| 30567 |
|
| 30568 |
|
| 30569 |
|
| 30570 |
|
| 30571 |
|
| 30572 |
|
| 30573 |
|
| 30574 |
|
| 30575 |
|
| 30576 |
|
| 30577 |
|
| 30578 |
|
| 30579 |
|
| 30580 |
|
| 30581 |
|
| 30582 |
|
| 30583 |
|
| 30584 |
|
| 30585 |
|
| 30586 |
|
| 30587 |
|
| 30588 |
|
| 30589 |
|
| 30590 |
|
| 30591 |
|
| 30592 |
|
| 30593 |
|
| 30594 |
|
| 30595 |
|
| 30596 |
|
| 30597 |
|
| 30598 |
|
| 30599 |
|
| 30600 |
|
| 30601 |
|
| 30602 |
|
| 30603 |
|
| 30604 |
public static class AccessibilityDelegate { |
| 30605 |
|
| 30606 |
|
| 30607 |
|
| 30608 |
|
| 30609 |
|
| 30610 |
|
| 30611 |
|
| 30612 |
|
| 30613 |
|
| 30614 |
|
| 30615 |
|
| 30616 |
|
| 30617 |
|
| 30618 |
|
| 30619 |
|
| 30620 |
public void sendAccessibilityEvent(@NonNull View host, int eventType) { |
| 30621 |
host.sendAccessibilityEventInternal(eventType); |
| 30622 |
} |
| 30623 |
|
| 30624 |
|
| 30625 |
|
| 30626 |
|
| 30627 |
|
| 30628 |
|
| 30629 |
|
| 30630 |
|
| 30631 |
|
| 30632 |
|
| 30633 |
|
| 30634 |
|
| 30635 |
|
| 30636 |
|
| 30637 |
|
| 30638 |
|
| 30639 |
|
| 30640 |
public boolean performAccessibilityAction(@NonNull View host, int action, |
| 30641 |
@Nullable Bundle args) { |
| 30642 |
return host.performAccessibilityActionInternal(action, args); |
| 30643 |
} |
| 30644 |
|
| 30645 |
|
| 30646 |
|
| 30647 |
|
| 30648 |
|
| 30649 |
|
| 30650 |
|
| 30651 |
|
| 30652 |
|
| 30653 |
|
| 30654 |
|
| 30655 |
|
| 30656 |
|
| 30657 |
|
| 30658 |
|
| 30659 |
|
| 30660 |
|
| 30661 |
|
| 30662 |
|
| 30663 |
public void sendAccessibilityEventUnchecked(@NonNull View host, |
| 30664 |
@NonNull AccessibilityEvent event) { |
| 30665 |
host.sendAccessibilityEventUncheckedInternal(event); |
| 30666 |
} |
| 30667 |
|
| 30668 |
|
| 30669 |
|
| 30670 |
|
| 30671 |
|
| 30672 |
|
| 30673 |
|
| 30674 |
|
| 30675 |
|
| 30676 |
|
| 30677 |
|
| 30678 |
|
| 30679 |
|
| 30680 |
|
| 30681 |
|
| 30682 |
|
| 30683 |
|
| 30684 |
|
| 30685 |
public boolean dispatchPopulateAccessibilityEvent(@NonNull View host, |
| 30686 |
@NonNull AccessibilityEvent event) { |
| 30687 |
return host.dispatchPopulateAccessibilityEventInternal(event); |
| 30688 |
} |
| 30689 |
|
| 30690 |
|
| 30691 |
|
| 30692 |
|
| 30693 |
|
| 30694 |
|
| 30695 |
|
| 30696 |
|
| 30697 |
|
| 30698 |
|
| 30699 |
|
| 30700 |
|
| 30701 |
|
| 30702 |
|
| 30703 |
|
| 30704 |
|
| 30705 |
|
| 30706 |
public void onPopulateAccessibilityEvent(@NonNull View host, |
| 30707 |
@NonNull AccessibilityEvent event) { |
| 30708 |
host.onPopulateAccessibilityEventInternal(event); |
| 30709 |
} |
| 30710 |
|
| 30711 |
|
| 30712 |
|
| 30713 |
|
| 30714 |
|
| 30715 |
|
| 30716 |
|
| 30717 |
|
| 30718 |
|
| 30719 |
|
| 30720 |
|
| 30721 |
|
| 30722 |
|
| 30723 |
|
| 30724 |
|
| 30725 |
|
| 30726 |
|
| 30727 |
public void onInitializeAccessibilityEvent(@NonNull View host, |
| 30728 |
@NonNull AccessibilityEvent event) { |
| 30729 |
host.onInitializeAccessibilityEventInternal(event); |
| 30730 |
} |
| 30731 |
|
| 30732 |
|
| 30733 |
|
| 30734 |
|
| 30735 |
|
| 30736 |
|
| 30737 |
|
| 30738 |
|
| 30739 |
|
| 30740 |
|
| 30741 |
|
| 30742 |
|
| 30743 |
|
| 30744 |
|
| 30745 |
|
| 30746 |
|
| 30747 |
public void onInitializeAccessibilityNodeInfo(@NonNull View host, |
| 30748 |
@NonNull AccessibilityNodeInfo info) { |
| 30749 |
host.onInitializeAccessibilityNodeInfoInternal(info); |
| 30750 |
} |
| 30751 |
|
| 30752 |
|
| 30753 |
|
| 30754 |
|
| 30755 |
|
| 30756 |
|
| 30757 |
|
| 30758 |
|
| 30759 |
|
| 30760 |
|
| 30761 |
|
| 30762 |
|
| 30763 |
|
| 30764 |
|
| 30765 |
|
| 30766 |
|
| 30767 |
|
| 30768 |
|
| 30769 |
|
| 30770 |
|
| 30771 |
|
| 30772 |
|
| 30773 |
|
| 30774 |
|
| 30775 |
public void addExtraDataToAccessibilityNodeInfo(@NonNull View host, |
| 30776 |
@NonNull AccessibilityNodeInfo info, @NonNull String extraDataKey, |
| 30777 |
@Nullable Bundle arguments) { |
| 30778 |
host.addExtraDataToAccessibilityNodeInfo(info, extraDataKey, arguments); |
| 30779 |
} |
| 30780 |
|
| 30781 |
|
| 30782 |
|
| 30783 |
|
| 30784 |
|
| 30785 |
|
| 30786 |
|
| 30787 |
|
| 30788 |
|
| 30789 |
|
| 30790 |
|
| 30791 |
|
| 30792 |
|
| 30793 |
|
| 30794 |
|
| 30795 |
|
| 30796 |
|
| 30797 |
|
| 30798 |
|
| 30799 |
|
| 30800 |
public boolean onRequestSendAccessibilityEvent(@NonNull ViewGroup host, @NonNull View child, |
| 30801 |
@NonNull AccessibilityEvent event) { |
| 30802 |
return host.onRequestSendAccessibilityEventInternal(child, event); |
| 30803 |
} |
| 30804 |
|
| 30805 |
|
| 30806 |
|
| 30807 |
|
| 30808 |
|
| 30809 |
|
| 30810 |
|
| 30811 |
|
| 30812 |
|
| 30813 |
|
| 30814 |
|
| 30815 |
|
| 30816 |
|
| 30817 |
|
| 30818 |
|
| 30819 |
public @Nullable AccessibilityNodeProvider getAccessibilityNodeProvider( |
| 30820 |
@NonNull View host) { |
| 30821 |
return null; |
| 30822 |
} |
| 30823 |
|
| 30824 |
|
| 30825 |
|
| 30826 |
|
| 30827 |
|
| 30828 |
|
| 30829 |
|
| 30830 |
|
| 30831 |
|
| 30832 |
|
| 30833 |
|
| 30834 |
|
| 30835 |
|
| 30836 |
|
| 30837 |
|
| 30838 |
|
| 30839 |
|
| 30840 |
|
| 30841 |
|
| 30842 |
|
| 30843 |
|
| 30844 |
|
| 30845 |
|
| 30846 |
|
| 30847 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 30848 |
public AccessibilityNodeInfo createAccessibilityNodeInfo(@NonNull View host) { |
| 30849 |
return host.createAccessibilityNodeInfoInternal(); |
| 30850 |
} |
| 30851 |
} |
| 30852 |
|
| 30853 |
private static class MatchIdPredicate implements Predicate<View> { |
| 30854 |
public int mId; |
| 30855 |
|
| 30856 |
@Override |
| 30857 |
public boolean test(View view) { |
| 30858 |
return (view.mID == mId); |
| 30859 |
} |
| 30860 |
} |
| 30861 |
|
| 30862 |
private static class MatchLabelForPredicate implements Predicate<View> { |
| 30863 |
private int mLabeledId; |
| 30864 |
|
| 30865 |
@Override |
| 30866 |
public boolean test(View view) { |
| 30867 |
return (view.mLabelForId == mLabeledId); |
| 30868 |
} |
| 30869 |
} |
| 30870 |
|
| 30871 |
|
| 30872 |
|
| 30873 |
|
| 30874 |
|
| 30875 |
|
| 30876 |
|
| 30877 |
@ScrollCaptureHint |
| 30878 |
public int getScrollCaptureHint() { |
| 30879 |
return (mPrivateFlags4 & PFLAG4_SCROLL_CAPTURE_HINT_MASK) |
| 30880 |
>> PFLAG4_SCROLL_CAPTURE_HINT_SHIFT; |
| 30881 |
} |
| 30882 |
|
| 30883 |
|
| 30884 |
|
| 30885 |
|
| 30886 |
|
| 30887 |
|
| 30888 |
|
| 30889 |
public void setScrollCaptureHint(@ScrollCaptureHint int hint) { |
| 30890 |
mPrivateFlags4 &= ~PFLAG4_SCROLL_CAPTURE_HINT_MASK; |
| 30891 |
|
| 30892 |
if ((hint & SCROLL_CAPTURE_HINT_EXCLUDE) != 0) { |
| 30893 |
hint &= ~SCROLL_CAPTURE_HINT_INCLUDE; |
| 30894 |
} |
| 30895 |
mPrivateFlags4 |= ((hint << PFLAG4_SCROLL_CAPTURE_HINT_SHIFT) |
| 30896 |
& PFLAG4_SCROLL_CAPTURE_HINT_MASK); |
| 30897 |
} |
| 30898 |
|
| 30899 |
|
| 30900 |
|
| 30901 |
|
| 30902 |
|
| 30903 |
|
| 30904 |
|
| 30905 |
|
| 30906 |
|
| 30907 |
|
| 30908 |
|
| 30909 |
|
| 30910 |
|
| 30911 |
|
| 30912 |
public final void setScrollCaptureCallback(@Nullable ScrollCaptureCallback callback) { |
| 30913 |
getListenerInfo().mScrollCaptureCallback = callback; |
| 30914 |
} |
| 30915 |
|
| 30916 |
|
| 30917 |
@Nullable |
| 30918 |
public ScrollCaptureCallback createScrollCaptureCallbackInternal(@NonNull Rect localVisibleRect, |
| 30919 |
@NonNull Point windowOffset) { |
| 30920 |
if (mAttachInfo == null) { |
| 30921 |
return null; |
| 30922 |
} |
| 30923 |
if (mAttachInfo.mScrollCaptureInternal == null) { |
| 30924 |
mAttachInfo.mScrollCaptureInternal = new ScrollCaptureInternal(); |
| 30925 |
} |
| 30926 |
return mAttachInfo.mScrollCaptureInternal.requestCallback(this, localVisibleRect, |
| 30927 |
windowOffset); |
| 30928 |
} |
| 30929 |
|
| 30930 |
|
| 30931 |
|
| 30932 |
|
| 30933 |
|
| 30934 |
|
| 30935 |
|
| 30936 |
|
| 30937 |
|
| 30938 |
|
| 30939 |
|
| 30940 |
public void dispatchScrollCaptureSearch( |
| 30941 |
@NonNull Rect localVisibleRect, @NonNull Point windowOffset, |
| 30942 |
@NonNull Consumer<ScrollCaptureTarget> targets) { |
| 30943 |
onScrollCaptureSearch(localVisibleRect, windowOffset, targets); |
| 30944 |
} |
| 30945 |
|
| 30946 |
|
| 30947 |
|
| 30948 |
|
| 30949 |
|
| 30950 |
|
| 30951 |
|
| 30952 |
|
| 30953 |
|
| 30954 |
|
| 30955 |
|
| 30956 |
|
| 30957 |
|
| 30958 |
public void onScrollCaptureSearch(@NonNull Rect localVisibleRect, |
| 30959 |
@NonNull Point windowOffset, @NonNull Consumer<ScrollCaptureTarget> targets) { |
| 30960 |
int hint = getScrollCaptureHint(); |
| 30961 |
if ((hint & SCROLL_CAPTURE_HINT_EXCLUDE) != 0) { |
| 30962 |
return; |
| 30963 |
} |
| 30964 |
boolean rectIsVisible = true; |
| 30965 |
|
| 30966 |
|
| 30967 |
if (mClipBounds != null) { |
| 30968 |
rectIsVisible = localVisibleRect.intersect(mClipBounds); |
| 30969 |
} |
| 30970 |
if (!rectIsVisible) { |
| 30971 |
return; |
| 30972 |
} |
| 30973 |
|
| 30974 |
|
| 30975 |
ScrollCaptureCallback callback = |
| 30976 |
(mListenerInfo == null) ? null : mListenerInfo.mScrollCaptureCallback; |
| 30977 |
|
| 30978 |
|
| 30979 |
if (callback == null) { |
| 30980 |
callback = createScrollCaptureCallbackInternal(localVisibleRect, windowOffset); |
| 30981 |
} |
| 30982 |
|
| 30983 |
|
| 30984 |
if (callback != null) { |
| 30985 |
|
| 30986 |
Point offset = new Point(windowOffset.x, windowOffset.y); |
| 30987 |
Rect rect = new Rect(localVisibleRect); |
| 30988 |
targets.accept(new ScrollCaptureTarget(this, rect, offset, callback)); |
| 30989 |
} |
| 30990 |
} |
| 30991 |
|
| 30992 |
|
| 30993 |
|
| 30994 |
|
| 30995 |
|
| 30996 |
private static void dumpFlags() { |
| 30997 |
final HashMap<String, String> found = Maps.newHashMap(); |
| 30998 |
try { |
| 30999 |
for (Field field : View.class.getDeclaredFields()) { |
| 31000 |
final int modifiers = field.getModifiers(); |
| 31001 |
if (Modifier.isStatic(modifiers) && Modifier.isFinal(modifiers)) { |
| 31002 |
if (field.getType().equals(int.class)) { |
| 31003 |
final int value = field.getInt(null); |
| 31004 |
dumpFlag(found, field.getName(), value); |
| 31005 |
} else if (field.getType().equals(int[].class)) { |
| 31006 |
final int[] values = (int[]) field.get(null); |
| 31007 |
for (int i = 0; i < values.length; i++) { |
| 31008 |
dumpFlag(found, field.getName() + "[" + i + "]", values[i]); |
| 31009 |
} |
| 31010 |
} |
| 31011 |
} |
| 31012 |
} |
| 31013 |
} catch (IllegalAccessException e) { |
| 31014 |
throw new RuntimeException(e); |
| 31015 |
} |
| 31016 |
|
| 31017 |
final ArrayList<String> keys = Lists.newArrayList(); |
| 31018 |
keys.addAll(found.keySet()); |
| 31019 |
Collections.sort(keys); |
| 31020 |
for (String key : keys) { |
| 31021 |
Log.d(VIEW_LOG_TAG, found.get(key)); |
| 31022 |
} |
| 31023 |
} |
| 31024 |
|
| 31025 |
private static void dumpFlag(HashMap<String, String> found, String name, int value) { |
| 31026 |
|
| 31027 |
final String bits = String.format("%32s", Integer.toBinaryString(value)).replace('0', ' '); |
| 31028 |
final int prefix = name.indexOf('_'); |
| 31029 |
final String key = (prefix > 0 ? name.substring(0, prefix) : name) + bits + name; |
| 31030 |
final String output = bits + " " + name; |
| 31031 |
found.put(key, output); |
| 31032 |
} |
| 31033 |
|
| 31034 |
|
| 31035 |
public void encode(@NonNull ViewHierarchyEncoder stream) { |
| 31036 |
stream.beginObject(this); |
| 31037 |
encodeProperties(stream); |
| 31038 |
stream.endObject(); |
| 31039 |
} |
| 31040 |
|
| 31041 |
|
| 31042 |
@CallSuper |
| 31043 |
protected void encodeProperties(@NonNull ViewHierarchyEncoder stream) { |
| 31044 |
Object resolveId = ViewDebug.resolveId(getContext(), mID); |
| 31045 |
if (resolveId instanceof String) { |
| 31046 |
stream.addProperty("id", (String) resolveId); |
| 31047 |
} else { |
| 31048 |
stream.addProperty("id", mID); |
| 31049 |
} |
| 31050 |
|
| 31051 |
stream.addProperty("misc:transformation.alpha", |
| 31052 |
mTransformationInfo != null ? mTransformationInfo.mAlpha : 0); |
| 31053 |
stream.addProperty("misc:transitionName", getTransitionName()); |
| 31054 |
|
| 31055 |
|
| 31056 |
stream.addProperty("layout:left", mLeft); |
| 31057 |
stream.addProperty("layout:right", mRight); |
| 31058 |
stream.addProperty("layout:top", mTop); |
| 31059 |
stream.addProperty("layout:bottom", mBottom); |
| 31060 |
stream.addProperty("layout:width", getWidth()); |
| 31061 |
stream.addProperty("layout:height", getHeight()); |
| 31062 |
stream.addProperty("layout:layoutDirection", getLayoutDirection()); |
| 31063 |
stream.addProperty("layout:layoutRtl", isLayoutRtl()); |
| 31064 |
stream.addProperty("layout:hasTransientState", hasTransientState()); |
| 31065 |
stream.addProperty("layout:baseline", getBaseline()); |
| 31066 |
|
| 31067 |
|
| 31068 |
ViewGroup.LayoutParams layoutParams = getLayoutParams(); |
| 31069 |
if (layoutParams != null) { |
| 31070 |
stream.addPropertyKey("layoutParams"); |
| 31071 |
layoutParams.encode(stream); |
| 31072 |
} |
| 31073 |
|
| 31074 |
|
| 31075 |
stream.addProperty("scrolling:scrollX", mScrollX); |
| 31076 |
stream.addProperty("scrolling:scrollY", mScrollY); |
| 31077 |
|
| 31078 |
|
| 31079 |
stream.addProperty("padding:paddingLeft", mPaddingLeft); |
| 31080 |
stream.addProperty("padding:paddingRight", mPaddingRight); |
| 31081 |
stream.addProperty("padding:paddingTop", mPaddingTop); |
| 31082 |
stream.addProperty("padding:paddingBottom", mPaddingBottom); |
| 31083 |
stream.addProperty("padding:userPaddingRight", mUserPaddingRight); |
| 31084 |
stream.addProperty("padding:userPaddingLeft", mUserPaddingLeft); |
| 31085 |
stream.addProperty("padding:userPaddingBottom", mUserPaddingBottom); |
| 31086 |
stream.addProperty("padding:userPaddingStart", mUserPaddingStart); |
| 31087 |
stream.addProperty("padding:userPaddingEnd", mUserPaddingEnd); |
| 31088 |
|
| 31089 |
|
| 31090 |
stream.addProperty("measurement:minHeight", mMinHeight); |
| 31091 |
stream.addProperty("measurement:minWidth", mMinWidth); |
| 31092 |
stream.addProperty("measurement:measuredWidth", mMeasuredWidth); |
| 31093 |
stream.addProperty("measurement:measuredHeight", mMeasuredHeight); |
| 31094 |
|
| 31095 |
|
| 31096 |
stream.addProperty("drawing:elevation", getElevation()); |
| 31097 |
stream.addProperty("drawing:translationX", getTranslationX()); |
| 31098 |
stream.addProperty("drawing:translationY", getTranslationY()); |
| 31099 |
stream.addProperty("drawing:translationZ", getTranslationZ()); |
| 31100 |
stream.addProperty("drawing:rotation", getRotation()); |
| 31101 |
stream.addProperty("drawing:rotationX", getRotationX()); |
| 31102 |
stream.addProperty("drawing:rotationY", getRotationY()); |
| 31103 |
stream.addProperty("drawing:scaleX", getScaleX()); |
| 31104 |
stream.addProperty("drawing:scaleY", getScaleY()); |
| 31105 |
stream.addProperty("drawing:pivotX", getPivotX()); |
| 31106 |
stream.addProperty("drawing:pivotY", getPivotY()); |
| 31107 |
stream.addProperty("drawing:clipBounds", |
| 31108 |
mClipBounds == null ? null : mClipBounds.toString()); |
| 31109 |
stream.addProperty("drawing:opaque", isOpaque()); |
| 31110 |
stream.addProperty("drawing:alpha", getAlpha()); |
| 31111 |
stream.addProperty("drawing:transitionAlpha", getTransitionAlpha()); |
| 31112 |
stream.addProperty("drawing:shadow", hasShadow()); |
| 31113 |
stream.addProperty("drawing:solidColor", getSolidColor()); |
| 31114 |
stream.addProperty("drawing:layerType", mLayerType); |
| 31115 |
stream.addProperty("drawing:willNotDraw", willNotDraw()); |
| 31116 |
stream.addProperty("drawing:hardwareAccelerated", isHardwareAccelerated()); |
| 31117 |
stream.addProperty("drawing:willNotCacheDrawing", willNotCacheDrawing()); |
| 31118 |
stream.addProperty("drawing:drawingCacheEnabled", isDrawingCacheEnabled()); |
| 31119 |
stream.addProperty("drawing:overlappingRendering", hasOverlappingRendering()); |
| 31120 |
stream.addProperty("drawing:outlineAmbientShadowColor", getOutlineAmbientShadowColor()); |
| 31121 |
stream.addProperty("drawing:outlineSpotShadowColor", getOutlineSpotShadowColor()); |
| 31122 |
|
| 31123 |
|
| 31124 |
stream.addProperty("focus:hasFocus", hasFocus()); |
| 31125 |
stream.addProperty("focus:isFocused", isFocused()); |
| 31126 |
stream.addProperty("focus:focusable", getFocusable()); |
| 31127 |
stream.addProperty("focus:isFocusable", isFocusable()); |
| 31128 |
stream.addProperty("focus:isFocusableInTouchMode", isFocusableInTouchMode()); |
| 31129 |
|
| 31130 |
stream.addProperty("misc:clickable", isClickable()); |
| 31131 |
stream.addProperty("misc:pressed", isPressed()); |
| 31132 |
stream.addProperty("misc:selected", isSelected()); |
| 31133 |
stream.addProperty("misc:touchMode", isInTouchMode()); |
| 31134 |
stream.addProperty("misc:hovered", isHovered()); |
| 31135 |
stream.addProperty("misc:activated", isActivated()); |
| 31136 |
|
| 31137 |
stream.addProperty("misc:visibility", getVisibility()); |
| 31138 |
stream.addProperty("misc:fitsSystemWindows", getFitsSystemWindows()); |
| 31139 |
stream.addProperty("misc:filterTouchesWhenObscured", getFilterTouchesWhenObscured()); |
| 31140 |
|
| 31141 |
stream.addProperty("misc:enabled", isEnabled()); |
| 31142 |
stream.addProperty("misc:soundEffectsEnabled", isSoundEffectsEnabled()); |
| 31143 |
stream.addProperty("misc:hapticFeedbackEnabled", isHapticFeedbackEnabled()); |
| 31144 |
|
| 31145 |
|
| 31146 |
Resources.Theme theme = getContext().getTheme(); |
| 31147 |
if (theme != null) { |
| 31148 |
stream.addPropertyKey("theme"); |
| 31149 |
theme.encode(stream); |
| 31150 |
} |
| 31151 |
|
| 31152 |
|
| 31153 |
int n = mAttributes != null ? mAttributes.length : 0; |
| 31154 |
stream.addProperty("meta:__attrCount__", n/2); |
| 31155 |
for (int i = 0; i < n; i += 2) { |
| 31156 |
stream.addProperty("meta:__attr__" + mAttributes[i], mAttributes[i+1]); |
| 31157 |
} |
| 31158 |
|
| 31159 |
stream.addProperty("misc:scrollBarStyle", getScrollBarStyle()); |
| 31160 |
|
| 31161 |
|
| 31162 |
stream.addProperty("text:textDirection", getTextDirection()); |
| 31163 |
stream.addProperty("text:textAlignment", getTextAlignment()); |
| 31164 |
|
| 31165 |
|
| 31166 |
CharSequence contentDescription = getContentDescription(); |
| 31167 |
stream.addUserProperty("accessibility:contentDescription", |
| 31168 |
contentDescription == null ? "" : contentDescription.toString()); |
| 31169 |
stream.addProperty("accessibility:labelFor", getLabelFor()); |
| 31170 |
stream.addProperty("accessibility:importantForAccessibility", getImportantForAccessibility()); |
| 31171 |
} |
| 31172 |
|
| 31173 |
|
| 31174 |
|
| 31175 |
|
| 31176 |
|
| 31177 |
boolean shouldDrawRoundScrollbar() { |
| 31178 |
if (!mResources.getConfiguration().isScreenRound() || mAttachInfo == null) { |
| 31179 |
return false; |
| 31180 |
} |
| 31181 |
|
| 31182 |
final View rootView = getRootView(); |
| 31183 |
final WindowInsets insets = getRootWindowInsets(); |
| 31184 |
|
| 31185 |
int height = getHeight(); |
| 31186 |
int width = getWidth(); |
| 31187 |
int displayHeight = rootView.getHeight(); |
| 31188 |
int displayWidth = rootView.getWidth(); |
| 31189 |
|
| 31190 |
if (height != displayHeight || width != displayWidth) { |
| 31191 |
return false; |
| 31192 |
} |
| 31193 |
|
| 31194 |
getLocationInWindow(mAttachInfo.mTmpLocation); |
| 31195 |
return mAttachInfo.mTmpLocation[0] == insets.getStableInsetLeft() |
| 31196 |
&& mAttachInfo.mTmpLocation[1] == insets.getStableInsetTop(); |
| 31197 |
} |
| 31198 |
|
| 31199 |
|
| 31200 |
|
| 31201 |
|
| 31202 |
|
| 31203 |
|
| 31204 |
|
| 31205 |
|
| 31206 |
|
| 31207 |
|
| 31208 |
|
| 31209 |
|
| 31210 |
|
| 31211 |
|
| 31212 |
|
| 31213 |
|
| 31214 |
|
| 31215 |
|
| 31216 |
public void setTooltipText(@Nullable CharSequence tooltipText) { |
| 31217 |
if (TextUtils.isEmpty(tooltipText)) { |
| 31218 |
setFlags(0, TOOLTIP); |
| 31219 |
hideTooltip(); |
| 31220 |
mTooltipInfo = null; |
| 31221 |
} else { |
| 31222 |
setFlags(TOOLTIP, TOOLTIP); |
| 31223 |
if (mTooltipInfo == null) { |
| 31224 |
mTooltipInfo = new TooltipInfo(); |
| 31225 |
mTooltipInfo.mShowTooltipRunnable = this::showHoverTooltip; |
| 31226 |
mTooltipInfo.mHideTooltipRunnable = this::hideTooltip; |
| 31227 |
mTooltipInfo.mHoverSlop = ViewConfiguration.get(mContext).getScaledHoverSlop(); |
| 31228 |
mTooltipInfo.clearAnchorPos(); |
| 31229 |
} |
| 31230 |
mTooltipInfo.mTooltipText = tooltipText; |
| 31231 |
} |
| 31232 |
} |
| 31233 |
|
| 31234 |
|
| 31235 |
|
| 31236 |
|
| 31237 |
@UnsupportedAppUsage |
| 31238 |
public void setTooltip(@Nullable CharSequence tooltipText) { |
| 31239 |
setTooltipText(tooltipText); |
| 31240 |
} |
| 31241 |
|
| 31242 |
|
| 31243 |
|
| 31244 |
|
| 31245 |
|
| 31246 |
|
| 31247 |
|
| 31248 |
|
| 31249 |
|
| 31250 |
|
| 31251 |
|
| 31252 |
|
| 31253 |
@InspectableProperty |
| 31254 |
@Nullable |
| 31255 |
public CharSequence getTooltipText() { |
| 31256 |
return mTooltipInfo != null ? mTooltipInfo.mTooltipText : null; |
| 31257 |
} |
| 31258 |
|
| 31259 |
|
| 31260 |
|
| 31261 |
|
| 31262 |
@Nullable |
| 31263 |
public CharSequence getTooltip() { |
| 31264 |
return getTooltipText(); |
| 31265 |
} |
| 31266 |
|
| 31267 |
private boolean showTooltip(int x, int y, boolean fromLongClick) { |
| 31268 |
if (mAttachInfo == null || mTooltipInfo == null) { |
| 31269 |
return false; |
| 31270 |
} |
| 31271 |
if (fromLongClick && (mViewFlags & ENABLED_MASK) != ENABLED) { |
| 31272 |
return false; |
| 31273 |
} |
| 31274 |
if (TextUtils.isEmpty(mTooltipInfo.mTooltipText)) { |
| 31275 |
return false; |
| 31276 |
} |
| 31277 |
hideTooltip(); |
| 31278 |
mTooltipInfo.mTooltipFromLongClick = fromLongClick; |
| 31279 |
mTooltipInfo.mTooltipPopup = new TooltipPopup(getContext()); |
| 31280 |
final boolean fromTouch = (mPrivateFlags3 & PFLAG3_FINGER_DOWN) == PFLAG3_FINGER_DOWN; |
| 31281 |
mTooltipInfo.mTooltipPopup.show(this, x, y, fromTouch, mTooltipInfo.mTooltipText); |
| 31282 |
mAttachInfo.mTooltipHost = this; |
| 31283 |
|
| 31284 |
notifyViewAccessibilityStateChangedIfNeeded(CONTENT_CHANGE_TYPE_UNDEFINED); |
| 31285 |
return true; |
| 31286 |
} |
| 31287 |
|
| 31288 |
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553) |
| 31289 |
void hideTooltip() { |
| 31290 |
if (mTooltipInfo == null) { |
| 31291 |
return; |
| 31292 |
} |
| 31293 |
removeCallbacks(mTooltipInfo.mShowTooltipRunnable); |
| 31294 |
if (mTooltipInfo.mTooltipPopup == null) { |
| 31295 |
return; |
| 31296 |
} |
| 31297 |
mTooltipInfo.mTooltipPopup.hide(); |
| 31298 |
mTooltipInfo.mTooltipPopup = null; |
| 31299 |
mTooltipInfo.mTooltipFromLongClick = false; |
| 31300 |
mTooltipInfo.clearAnchorPos(); |
| 31301 |
if (mAttachInfo != null) { |
| 31302 |
mAttachInfo.mTooltipHost = null; |
| 31303 |
} |
| 31304 |
|
| 31305 |
notifyViewAccessibilityStateChangedIfNeeded(CONTENT_CHANGE_TYPE_UNDEFINED); |
| 31306 |
} |
| 31307 |
|
| 31308 |
private boolean showLongClickTooltip(int x, int y) { |
| 31309 |
removeCallbacks(mTooltipInfo.mShowTooltipRunnable); |
| 31310 |
removeCallbacks(mTooltipInfo.mHideTooltipRunnable); |
| 31311 |
return showTooltip(x, y, true); |
| 31312 |
} |
| 31313 |
|
| 31314 |
private boolean showHoverTooltip() { |
| 31315 |
return showTooltip(mTooltipInfo.mAnchorX, mTooltipInfo.mAnchorY, false); |
| 31316 |
} |
| 31317 |
|
| 31318 |
boolean dispatchTooltipHoverEvent(MotionEvent event) { |
| 31319 |
if (mTooltipInfo == null) { |
| 31320 |
return false; |
| 31321 |
} |
| 31322 |
switch(event.getAction()) { |
| 31323 |
case MotionEvent.ACTION_HOVER_MOVE: |
| 31324 |
if ((mViewFlags & TOOLTIP) != TOOLTIP) { |
| 31325 |
break; |
| 31326 |
} |
| 31327 |
if (!mTooltipInfo.mTooltipFromLongClick && mTooltipInfo.updateAnchorPos(event)) { |
| 31328 |
if (mTooltipInfo.mTooltipPopup == null) { |
| 31329 |
|
| 31330 |
removeCallbacks(mTooltipInfo.mShowTooltipRunnable); |
| 31331 |
postDelayed(mTooltipInfo.mShowTooltipRunnable, |
| 31332 |
ViewConfiguration.getHoverTooltipShowTimeout()); |
| 31333 |
} |
| 31334 |
|
| 31335 |
|
| 31336 |
|
| 31337 |
|
| 31338 |
final int timeout; |
| 31339 |
if ((getWindowSystemUiVisibility() & SYSTEM_UI_FLAG_LOW_PROFILE) |
| 31340 |
== SYSTEM_UI_FLAG_LOW_PROFILE) { |
| 31341 |
timeout = ViewConfiguration.getHoverTooltipHideShortTimeout(); |
| 31342 |
} else { |
| 31343 |
timeout = ViewConfiguration.getHoverTooltipHideTimeout(); |
| 31344 |
} |
| 31345 |
removeCallbacks(mTooltipInfo.mHideTooltipRunnable); |
| 31346 |
postDelayed(mTooltipInfo.mHideTooltipRunnable, timeout); |
| 31347 |
} |
| 31348 |
return true; |
| 31349 |
|
| 31350 |
case MotionEvent.ACTION_HOVER_EXIT: |
| 31351 |
mTooltipInfo.clearAnchorPos(); |
| 31352 |
if (!mTooltipInfo.mTooltipFromLongClick) { |
| 31353 |
hideTooltip(); |
| 31354 |
} |
| 31355 |
break; |
| 31356 |
} |
| 31357 |
return false; |
| 31358 |
} |
| 31359 |
|
| 31360 |
void handleTooltipKey(KeyEvent event) { |
| 31361 |
switch (event.getAction()) { |
| 31362 |
case KeyEvent.ACTION_DOWN: |
| 31363 |
if (event.getRepeatCount() == 0) { |
| 31364 |
hideTooltip(); |
| 31365 |
} |
| 31366 |
break; |
| 31367 |
|
| 31368 |
case KeyEvent.ACTION_UP: |
| 31369 |
handleTooltipUp(); |
| 31370 |
break; |
| 31371 |
} |
| 31372 |
} |
| 31373 |
|
| 31374 |
private void handleTooltipUp() { |
| 31375 |
if (mTooltipInfo == null || mTooltipInfo.mTooltipPopup == null) { |
| 31376 |
return; |
| 31377 |
} |
| 31378 |
removeCallbacks(mTooltipInfo.mHideTooltipRunnable); |
| 31379 |
postDelayed(mTooltipInfo.mHideTooltipRunnable, |
| 31380 |
ViewConfiguration.getLongPressTooltipHideTimeout()); |
| 31381 |
} |
| 31382 |
|
| 31383 |
private int getFocusableAttribute(TypedArray attributes) { |
| 31384 |
TypedValue val = new TypedValue(); |
| 31385 |
if (attributes.getValue(com.android.internal.R.styleable.View_focusable, val)) { |
| 31386 |
if (val.type == TypedValue.TYPE_INT_BOOLEAN) { |
| 31387 |
return (val.data == 0 ? NOT_FOCUSABLE : FOCUSABLE); |
| 31388 |
} else { |
| 31389 |
return val.data; |
| 31390 |
} |
| 31391 |
} else { |
| 31392 |
return FOCUSABLE_AUTO; |
| 31393 |
} |
| 31394 |
} |
| 31395 |
|
| 31396 |
|
| 31397 |
|
| 31398 |
|
| 31399 |
|
| 31400 |
|
| 31401 |
@TestApi |
| 31402 |
public View getTooltipView() { |
| 31403 |
if (mTooltipInfo == null || mTooltipInfo.mTooltipPopup == null) { |
| 31404 |
return null; |
| 31405 |
} |
| 31406 |
return mTooltipInfo.mTooltipPopup.getContentView(); |
| 31407 |
} |
| 31408 |
|
| 31409 |
|
| 31410 |
|
| 31411 |
|
| 31412 |
|
| 31413 |
@TestApi |
| 31414 |
public static boolean isDefaultFocusHighlightEnabled() { |
| 31415 |
return sUseDefaultFocusHighlight; |
| 31416 |
} |
| 31417 |
|
| 31418 |
|
| 31419 |
|
| 31420 |
|
| 31421 |
|
| 31422 |
|
| 31423 |
|
| 31424 |
|
| 31425 |
|
| 31426 |
View dispatchUnhandledKeyEvent(KeyEvent evt) { |
| 31427 |
if (onUnhandledKeyEvent(evt)) { |
| 31428 |
return this; |
| 31429 |
} |
| 31430 |
return null; |
| 31431 |
} |
| 31432 |
|
| 31433 |
|
| 31434 |
|
| 31435 |
|
| 31436 |
|
| 31437 |
|
| 31438 |
|
| 31439 |
|
| 31440 |
|
| 31441 |
|
| 31442 |
|
| 31443 |
|
| 31444 |
boolean onUnhandledKeyEvent(@NonNull KeyEvent event) { |
| 31445 |
if (mListenerInfo != null && mListenerInfo.mUnhandledKeyListeners != null) { |
| 31446 |
for (int i = mListenerInfo.mUnhandledKeyListeners.size() - 1; i >= 0; --i) { |
| 31447 |
if (mListenerInfo.mUnhandledKeyListeners.get(i).onUnhandledKeyEvent(this, event)) { |
| 31448 |
return true; |
| 31449 |
} |
| 31450 |
} |
| 31451 |
} |
| 31452 |
return false; |
| 31453 |
} |
| 31454 |
|
| 31455 |
boolean hasUnhandledKeyListener() { |
| 31456 |
return (mListenerInfo != null && mListenerInfo.mUnhandledKeyListeners != null |
| 31457 |
&& !mListenerInfo.mUnhandledKeyListeners.isEmpty()); |
| 31458 |
} |
| 31459 |
|
| 31460 |
|
| 31461 |
|
| 31462 |
|
| 31463 |
|
| 31464 |
|
| 31465 |
|
| 31466 |
|
| 31467 |
public void addOnUnhandledKeyEventListener(OnUnhandledKeyEventListener listener) { |
| 31468 |
ArrayList<OnUnhandledKeyEventListener> listeners = getListenerInfo().mUnhandledKeyListeners; |
| 31469 |
if (listeners == null) { |
| 31470 |
listeners = new ArrayList<>(); |
| 31471 |
getListenerInfo().mUnhandledKeyListeners = listeners; |
| 31472 |
} |
| 31473 |
listeners.add(listener); |
| 31474 |
if (listeners.size() == 1 && mParent instanceof ViewGroup) { |
| 31475 |
((ViewGroup) mParent).incrementChildUnhandledKeyListeners(); |
| 31476 |
} |
| 31477 |
} |
| 31478 |
|
| 31479 |
|
| 31480 |
|
| 31481 |
|
| 31482 |
|
| 31483 |
|
| 31484 |
|
| 31485 |
|
| 31486 |
public void removeOnUnhandledKeyEventListener(OnUnhandledKeyEventListener listener) { |
| 31487 |
if (mListenerInfo != null) { |
| 31488 |
if (mListenerInfo.mUnhandledKeyListeners != null |
| 31489 |
&& !mListenerInfo.mUnhandledKeyListeners.isEmpty()) { |
| 31490 |
mListenerInfo.mUnhandledKeyListeners.remove(listener); |
| 31491 |
if (mListenerInfo.mUnhandledKeyListeners.isEmpty()) { |
| 31492 |
mListenerInfo.mUnhandledKeyListeners = null; |
| 31493 |
if (mParent instanceof ViewGroup) { |
| 31494 |
((ViewGroup) mParent).decrementChildUnhandledKeyListeners(); |
| 31495 |
} |
| 31496 |
} |
| 31497 |
} |
| 31498 |
} |
| 31499 |
} |
| 31500 |
|
| 31501 |
|
| 31502 |
|
| 31503 |
|
| 31504 |
|
| 31505 |
|
| 31506 |
|
| 31507 |
|
| 31508 |
protected void setDetached(boolean detached) { |
| 31509 |
if (detached) { |
| 31510 |
mPrivateFlags4 |= PFLAG4_DETACHED; |
| 31511 |
} else { |
| 31512 |
mPrivateFlags4 &= ~PFLAG4_DETACHED; |
| 31513 |
} |
| 31514 |
} |
| 31515 |
|
| 31516 |
|
| 31517 |
|
| 31518 |
|
| 31519 |
|
| 31520 |
|
| 31521 |
|
| 31522 |
|
| 31523 |
|
| 31524 |
|
| 31525 |
|
| 31526 |
|
| 31527 |
|
| 31528 |
|
| 31529 |
|
| 31530 |
|
| 31531 |
|
| 31532 |
|
| 31533 |
|
| 31534 |
public void setAutoHandwritingEnabled(boolean enabled) { |
| 31535 |
if (enabled) { |
| 31536 |
mPrivateFlags4 |= PFLAG4_AUTO_HANDWRITING_ENABLED; |
| 31537 |
} else { |
| 31538 |
mPrivateFlags4 &= ~PFLAG4_AUTO_HANDWRITING_ENABLED; |
| 31539 |
} |
| 31540 |
updatePositionUpdateListener(); |
| 31541 |
postUpdate(this::updateHandwritingArea); |
| 31542 |
} |
| 31543 |
|
| 31544 |
|
| 31545 |
|
| 31546 |
|
| 31547 |
|
| 31548 |
|
| 31549 |
public boolean isAutoHandwritingEnabled() { |
| 31550 |
return (mPrivateFlags4 & PFLAG4_AUTO_HANDWRITING_ENABLED) |
| 31551 |
== PFLAG4_AUTO_HANDWRITING_ENABLED; |
| 31552 |
} |
| 31553 |
|
| 31554 |
|
| 31555 |
|
| 31556 |
|
| 31557 |
|
| 31558 |
|
| 31559 |
|
| 31560 |
|
| 31561 |
|
| 31562 |
|
| 31563 |
|
| 31564 |
|
| 31565 |
|
| 31566 |
|
| 31567 |
|
| 31568 |
public void onCreateViewTranslationRequest(@NonNull @DataFormat int[] supportedFormats, |
| 31569 |
@NonNull Consumer<ViewTranslationRequest> requestsCollector) { |
| 31570 |
} |
| 31571 |
|
| 31572 |
|
| 31573 |
|
| 31574 |
|
| 31575 |
|
| 31576 |
|
| 31577 |
|
| 31578 |
|
| 31579 |
|
| 31580 |
|
| 31581 |
|
| 31582 |
|
| 31583 |
|
| 31584 |
|
| 31585 |
|
| 31586 |
|
| 31587 |
|
| 31588 |
|
| 31589 |
|
| 31590 |
@SuppressLint("NullableCollection") |
| 31591 |
public void onCreateVirtualViewTranslationRequests(@NonNull long[] virtualIds, |
| 31592 |
@NonNull @DataFormat int[] supportedFormats, |
| 31593 |
@NonNull Consumer<ViewTranslationRequest> requestsCollector) { |
| 31594 |
|
| 31595 |
} |
| 31596 |
|
| 31597 |
|
| 31598 |
|
| 31599 |
|
| 31600 |
|
| 31601 |
|
| 31602 |
|
| 31603 |
@Nullable |
| 31604 |
public ViewTranslationCallback getViewTranslationCallback() { |
| 31605 |
return mViewTranslationCallback; |
| 31606 |
} |
| 31607 |
|
| 31608 |
|
| 31609 |
|
| 31610 |
|
| 31611 |
|
| 31612 |
|
| 31613 |
|
| 31614 |
|
| 31615 |
|
| 31616 |
public void setViewTranslationCallback(@NonNull ViewTranslationCallback callback) { |
| 31617 |
mViewTranslationCallback = callback; |
| 31618 |
} |
| 31619 |
|
| 31620 |
|
| 31621 |
|
| 31622 |
|
| 31623 |
public void clearViewTranslationCallback() { |
| 31624 |
mViewTranslationCallback = null; |
| 31625 |
} |
| 31626 |
|
| 31627 |
|
| 31628 |
|
| 31629 |
|
| 31630 |
|
| 31631 |
|
| 31632 |
|
| 31633 |
|
| 31634 |
|
| 31635 |
|
| 31636 |
@Nullable |
| 31637 |
public ViewTranslationResponse getViewTranslationResponse() { |
| 31638 |
return mViewTranslationResponse; |
| 31639 |
} |
| 31640 |
|
| 31641 |
|
| 31642 |
|
| 31643 |
|
| 31644 |
|
| 31645 |
|
| 31646 |
|
| 31647 |
|
| 31648 |
|
| 31649 |
|
| 31650 |
|
| 31651 |
|
| 31652 |
|
| 31653 |
public void onViewTranslationResponse(@NonNull ViewTranslationResponse response) { |
| 31654 |
mViewTranslationResponse = response; |
| 31655 |
} |
| 31656 |
|
| 31657 |
|
| 31658 |
|
| 31659 |
|
| 31660 |
|
| 31661 |
|
| 31662 |
|
| 31663 |
public void clearViewTranslationResponse() { |
| 31664 |
mViewTranslationResponse = null; |
| 31665 |
} |
| 31666 |
|
| 31667 |
|
| 31668 |
|
| 31669 |
|
| 31670 |
|
| 31671 |
|
| 31672 |
|
| 31673 |
|
| 31674 |
|
| 31675 |
|
| 31676 |
|
| 31677 |
public void onVirtualViewTranslationResponses( |
| 31678 |
@NonNull LongSparseArray<ViewTranslationResponse> response) { |
| 31679 |
|
| 31680 |
} |
| 31681 |
|
| 31682 |
|
| 31683 |
|
| 31684 |
|
| 31685 |
|
| 31686 |
|
| 31687 |
|
| 31688 |
|
| 31689 |
|
| 31690 |
|
| 31691 |
|
| 31692 |
|
| 31693 |
|
| 31694 |
|
| 31695 |
|
| 31696 |
|
| 31697 |
|
| 31698 |
|
| 31699 |
|
| 31700 |
|
| 31701 |
|
| 31702 |
|
| 31703 |
|
| 31704 |
|
| 31705 |
|
| 31706 |
|
| 31707 |
|
| 31708 |
|
| 31709 |
public void dispatchCreateViewTranslationRequest(@NonNull Map<AutofillId, long[]> viewIds, |
| 31710 |
@NonNull @DataFormat int[] supportedFormats, |
| 31711 |
@NonNull TranslationCapability capability, |
| 31712 |
@NonNull List<ViewTranslationRequest> requests) { |
| 31713 |
AutofillId autofillId = getAutofillId(); |
| 31714 |
if (viewIds.containsKey(autofillId)) { |
| 31715 |
if (viewIds.get(autofillId) == null) { |
| 31716 |
|
| 31717 |
onCreateViewTranslationRequest(supportedFormats, |
| 31718 |
new ViewTranslationRequestConsumer(requests)); |
| 31719 |
} else { |
| 31720 |
onCreateVirtualViewTranslationRequests(viewIds.get(autofillId), supportedFormats, |
| 31721 |
request -> { |
| 31722 |
requests.add(request); |
| 31723 |
}); |
| 31724 |
} |
| 31725 |
} |
| 31726 |
} |
| 31727 |
|
| 31728 |
private class ViewTranslationRequestConsumer implements Consumer<ViewTranslationRequest> { |
| 31729 |
private final List<ViewTranslationRequest> mRequests; |
| 31730 |
private boolean mCalled; |
| 31731 |
|
| 31732 |
ViewTranslationRequestConsumer(List<ViewTranslationRequest> requests) { |
| 31733 |
mRequests = requests; |
| 31734 |
} |
| 31735 |
|
| 31736 |
@Override |
| 31737 |
public void accept(ViewTranslationRequest request) { |
| 31738 |
if (mCalled) { |
| 31739 |
throw new IllegalStateException("The translation Consumer is not reusable."); |
| 31740 |
} |
| 31741 |
mCalled = true; |
| 31742 |
if (request != null && request.getKeys().size() > 0) { |
| 31743 |
mRequests.add(request); |
| 31744 |
if (Log.isLoggable(CONTENT_CAPTURE_LOG_TAG, Log.VERBOSE)) { |
| 31745 |
Log.v(CONTENT_CAPTURE_LOG_TAG, "Calling setHasTransientState(true) for " |
| 31746 |
+ getAutofillId()); |
| 31747 |
} |
| 31748 |
setHasTransientState(true); |
| 31749 |
setHasTranslationTransientState(true); |
| 31750 |
} |
| 31751 |
} |
| 31752 |
} |
| 31753 |
|
| 31754 |
|
| 31755 |
|
| 31756 |
|
| 31757 |
|
| 31758 |
|
| 31759 |
|
| 31760 |
|
| 31761 |
|
| 31762 |
|
| 31763 |
|
| 31764 |
|
| 31765 |
|
| 31766 |
|
| 31767 |
|
| 31768 |
public void generateDisplayHash(@NonNull String hashAlgorithm, |
| 31769 |
@Nullable Rect bounds, @NonNull Executor executor, |
| 31770 |
@NonNull DisplayHashResultCallback callback) { |
| 31771 |
IWindowSession session = getWindowSession(); |
| 31772 |
if (session == null) { |
| 31773 |
callback.onDisplayHashError(DISPLAY_HASH_ERROR_MISSING_WINDOW); |
| 31774 |
return; |
| 31775 |
} |
| 31776 |
IWindow window = getWindow(); |
| 31777 |
if (window == null) { |
| 31778 |
callback.onDisplayHashError(DISPLAY_HASH_ERROR_MISSING_WINDOW); |
| 31779 |
return; |
| 31780 |
} |
| 31781 |
|
| 31782 |
Rect visibleBounds = new Rect(); |
| 31783 |
getGlobalVisibleRect(visibleBounds); |
| 31784 |
|
| 31785 |
if (bounds != null && bounds.isEmpty()) { |
| 31786 |
callback.onDisplayHashError(DISPLAY_HASH_ERROR_INVALID_BOUNDS); |
| 31787 |
return; |
| 31788 |
} |
| 31789 |
|
| 31790 |
if (bounds != null) { |
| 31791 |
bounds.offset(visibleBounds.left, visibleBounds.top); |
| 31792 |
visibleBounds.intersectUnchecked(bounds); |
| 31793 |
} |
| 31794 |
|
| 31795 |
if (visibleBounds.isEmpty()) { |
| 31796 |
callback.onDisplayHashError(DISPLAY_HASH_ERROR_NOT_VISIBLE_ON_SCREEN); |
| 31797 |
return; |
| 31798 |
} |
| 31799 |
|
| 31800 |
RemoteCallback remoteCallback = new RemoteCallback(result -> |
| 31801 |
executor.execute(() -> { |
| 31802 |
DisplayHash displayHash = result.getParcelable(EXTRA_DISPLAY_HASH); |
| 31803 |
int errorCode = result.getInt(EXTRA_DISPLAY_HASH_ERROR_CODE, |
| 31804 |
DISPLAY_HASH_ERROR_UNKNOWN); |
| 31805 |
if (displayHash != null) { |
| 31806 |
callback.onDisplayHashResult(displayHash); |
| 31807 |
} else { |
| 31808 |
callback.onDisplayHashError(errorCode); |
| 31809 |
} |
| 31810 |
})); |
| 31811 |
|
| 31812 |
try { |
| 31813 |
session.generateDisplayHash(window, visibleBounds, hashAlgorithm, remoteCallback); |
| 31814 |
} catch (RemoteException e) { |
| 31815 |
Log.e(VIEW_LOG_TAG, "Failed to call generateDisplayHash"); |
| 31816 |
callback.onDisplayHashError(DISPLAY_HASH_ERROR_UNKNOWN); |
| 31817 |
} |
| 31818 |
} |
| 31819 |
|
| 31820 |
|
| 31821 |
|
| 31822 |
|
| 31823 |
|
| 31824 |
|
| 31825 |
|
| 31826 |
|
| 31827 |
|
| 31828 |
|
| 31829 |
public @Nullable AttachedSurfaceControl getRootSurfaceControl() { |
| 31830 |
if (mAttachInfo != null) { |
| 31831 |
return mAttachInfo.getRootSurfaceControl(); |
| 31832 |
} |
| 31833 |
return null; |
| 31834 |
} |
| 31835 |
} |