Log swiping and clicking for switching tabs.

If it's a swipe, onPageScrolled() is called several times before onPageScrollStateChanged(SCROLL_STATE_SETTLING) and onPageSelected().
If it's a click, only onPageScrollStateChanged(SCROLL_STATE_SETTLING) is called before onPageSelected().
And onPageScrollStateChanged(SCROLL_STATE_SETTLING) will not be called if user don't switch to a new tab.
We use the difference to tell if user switching tabs by swiping or clicking.

Test: DialtactsActivityTest
PiperOrigin-RevId: 168403148
Change-Id: Iaaf84ab9c4955d0bc2c1e9857ba59fd37b3984af
diff --git a/java/com/android/bubble/Bubble.java b/java/com/android/bubble/Bubble.java
index d83e284..9abfa43 100644
--- a/java/com/android/bubble/Bubble.java
+++ b/java/com/android/bubble/Bubble.java
@@ -99,6 +99,7 @@
   private boolean expanded;
   private boolean textShowing;
   private boolean hideAfterText;
+  private CharSequence textAfterShow;
   private int collapseEndAction;
 
   @VisibleForTesting ViewHolder viewHolder;
@@ -304,7 +305,15 @@
         .setInterpolator(new OvershootInterpolator())
         .scaleX(1)
         .scaleY(1)
-        .withEndAction(() -> visibility = Visibility.SHOWING)
+        .withEndAction(
+            () -> {
+              visibility = Visibility.SHOWING;
+              // Show the queued up text, if available.
+              if (textAfterShow != null) {
+                showText(textAfterShow);
+                textAfterShow = null;
+              }
+            })
         .start();
 
     updatePrimaryIconAnimation();
@@ -380,6 +389,12 @@
       transition.addTarget(startValues.view);
       transition.captureStartValues(startValues);
 
+      // If our view is not laid out yet, postpone showing the text.
+      if (startValues.values.isEmpty()) {
+        textAfterShow = text;
+        return;
+      }
+
       doResize(
           () -> {
             doShowText(text);