Merge "Fixing issue where overview->normal workspace mode cannot be done by tapping b/31458165" into ub-launcher3-calgary-polish
diff --git a/res/drawable/ic_setting.xml b/res/drawable/ic_setting.xml
index 256d24c..8a50c0c 100644
--- a/res/drawable/ic_setting.xml
+++ b/res/drawable/ic_setting.xml
@@ -20,5 +20,5 @@
         android:viewportHeight="48.0">
     <path
         android:fillColor="#FFFFFFFF"
-        android:pathData="M38.86 25.95c.08-.64.14-1.29.14-1.95s-.06-1.31-.14-1.95l4.23-3.31c.38-.3.49-.84.24-1.28l-4-6.93c-.25-.43-.77-.61-1.22-.43l-4.98 2.01c-1.03-.79-2.16-1.46-3.38-1.97L29 4.84c-.09-.47-.5-.84-1-.84h-8c-.5 0-.91.37-.99.84l-.75 5.3c-1.22.51-2.35 1.17-3.38 1.97L9.9 10.1c-.45-.17-.97 0-1.22.43l-4 6.93c-.25.43-.14.97.24 1.28l4.22 3.31C9.06 22.69 9 23.34 9 24s.06 1.31.14 1.95l-4.22 3.31c-.38.3-.49.84-.24 1.28l4 6.93c.25.43.77.61 1.22.43l4.98-2.01c1.03.79 2.16 1.46 3.38 1.97l.75 5.3c.08.47.49.84.99.84h8c.5 0 .91-.37.99-.84l.75-5.3c1.22-.51 2.35-1.17 3.38-1.97l4.98 2.01c.45.17.97 0 1.22-.43l4-6.93c.25-.43.14-.97-.24-1.28l-4.22-3.31zM24 31c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"/>
+        android:pathData="M38.86 25.95c.08-.64 .14-1.29 .14-1.95s-.06-1.31-.14-1.95l4.23-3.31c.38-.3 .49-.84 .24-1.28l-4-6.93c-.25-.43-.77-.61-1.22-.43l-4.98 2.01c-1.03-.79-2.16-1.46-3.38-1.97L29 4.84c-.09-.47-.5-.84-1-.84h-8c-.5 0-.91 .37-.99 .84l-.75 5.3c-1.22 .51-2.35 1.17-3.38 1.97L9.9 10.1c-.45-.17-.97 0-1.22 .43l-4 6.93c-.25 .43-.14 .97 .24 1.28l4.22 3.31C9.06 22.69 9 23.34 9 24s.06 1.31 .14 1.95l-4.22 3.31c-.38 .3-.49 .84-.24 1.28l4 6.93c.25 .43 .77 .61 1.22 .43l4.98-2.01c1.03 .79 2.16 1.46 3.38 1.97l.75 5.3c.08 .47 .49 .84 .99 .84h8c.5 0 .91-.37 .99-.84l.75-5.3c1.22-.51 2.35-1.17 3.38-1.97l4.98 2.01c.45 .17 .97 0 1.22-.43l4-6.93c.25-.43 .14-.97-.24-1.28l-4.22-3.31zM24 31c-3.87 0-7-3.13-7-7s3.13-7 7-7 7 3.13 7 7-3.13 7-7 7z"/>
 </vector>
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java
index c738480..f9424d4 100644
--- a/src/com/android/launcher3/Hotseat.java
+++ b/src/com/android/launcher3/Hotseat.java
@@ -25,6 +25,7 @@
 import android.graphics.Rect;
 import android.graphics.drawable.ColorDrawable;
 import android.graphics.drawable.Drawable;
+import android.support.v4.content.ContextCompat;
 import android.support.v4.graphics.ColorUtils;
 import android.util.AttributeSet;
 import android.view.LayoutInflater;
@@ -69,7 +70,7 @@
         mLauncher = (Launcher) context;
         mHasVerticalHotseat = mLauncher.getDeviceProfile().isVerticalBarLayout();
         mBackgroundColor = ColorUtils.setAlphaComponent(
-                context.getColor(R.color.all_apps_container_color), 0);
+                ContextCompat.getColor(context, R.color.all_apps_container_color), 0);
         mBackground = new ColorDrawable(mBackgroundColor);
         setBackground(mBackground);
     }
diff --git a/src/com/android/launcher3/allapps/AllAppsContainerView.java b/src/com/android/launcher3/allapps/AllAppsContainerView.java
index 0a71a69..290accb 100644
--- a/src/com/android/launcher3/allapps/AllAppsContainerView.java
+++ b/src/com/android/launcher3/allapps/AllAppsContainerView.java
@@ -278,6 +278,12 @@
         if (mAppsRecyclerView.getScrollBar().isNearThumb(point[0], point[1])) {
             return false;
         }
+
+        // IF a shortcuts container is open, container should not be pulled down.
+        if (mLauncher.getOpenShortcutsContainer() != null) {
+            return false;
+        }
+
         // IF scroller is at the very top OR there is no scroll bar because there is probably not
         // enough items to scroll, THEN it's okay for the container to be pulled down.
         if (mAppsRecyclerView.getScrollBar().getThumbOffset().y <= 0) {
diff --git a/src/com/android/launcher3/allapps/AllAppsTransitionController.java b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
index 5888230..9fcc6a4 100644
--- a/src/com/android/launcher3/allapps/AllAppsTransitionController.java
+++ b/src/com/android/launcher3/allapps/AllAppsTransitionController.java
@@ -6,6 +6,7 @@
 import android.animation.AnimatorSet;
 import android.animation.ArgbEvaluator;
 import android.animation.ObjectAnimator;
+import android.support.v4.content.ContextCompat;
 import android.support.v4.view.animation.FastOutSlowInInterpolator;
 import android.util.Log;
 import android.view.MotionEvent;
@@ -101,7 +102,7 @@
                 R.dimen.all_apps_bezel_swipe_height);
 
         mEvaluator = new ArgbEvaluator();
-        mAllAppsBackgroundColor = l.getColor(R.color.all_apps_container_color);
+        mAllAppsBackgroundColor = ContextCompat.getColor(l, R.color.all_apps_container_color);
     }
 
     @Override
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
index 747c21b..fb9d2f7 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorDots.java
@@ -226,11 +226,6 @@
     public void setActiveMarker(int activePage) {
         if (mActivePage != activePage) {
             mActivePage = activePage;
-
-            // Simulate a scroll change
-            int totalScroll = mNumPages - 1;
-            int currentScroll = mIsRtl ? (totalScroll - mActivePage) : mActivePage;
-            setScroll(currentScroll, totalScroll);
         }
     }
 
diff --git a/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
index ca3a2dd..350bc8a 100644
--- a/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
+++ b/src/com/android/launcher3/pageindicators/PageIndicatorLineCaret.java
@@ -159,6 +159,11 @@
     }
 
     @Override
+    public void setContentDescription(CharSequence contentDescription) {
+        mAllAppsHandle.setContentDescription(contentDescription);
+    }
+
+    @Override
     public void setScroll(int currentScroll, int totalScroll) {
         if (getAlpha() == 0) {
             return;
diff --git a/src/com/android/launcher3/util/TransformingTouchDelegate.java b/src/com/android/launcher3/util/TransformingTouchDelegate.java
index da1de5e..3197ba9 100644
--- a/src/com/android/launcher3/util/TransformingTouchDelegate.java
+++ b/src/com/android/launcher3/util/TransformingTouchDelegate.java
@@ -33,6 +33,10 @@
 
     private final RectF mBounds;
 
+    private final RectF mTouchCheckBounds;
+    private float mTouchExtension;
+    private boolean mWasTouchOutsideBounds;
+
     private View mDelegateView;
     private boolean mDelegateTargeted;
 
@@ -41,10 +45,22 @@
 
         mDelegateView = delegateView;
         mBounds = new RectF();
+        mTouchCheckBounds = new RectF();
     }
 
     public void setBounds(int left, int top, int right, int bottom) {
         mBounds.set(left, top, right, bottom);
+        updateTouchBounds();
+    }
+
+    public void extendTouchBounds(float extension) {
+        mTouchExtension = extension;
+        updateTouchBounds();
+    }
+
+    private void updateTouchBounds() {
+        mTouchCheckBounds.set(mBounds);
+        mTouchCheckBounds.inset(-mTouchExtension, -mTouchExtension);
     }
 
     public void setDelegateView(View view) {
@@ -62,8 +78,9 @@
         boolean sendToDelegate = false;
         switch (event.getAction()) {
             case MotionEvent.ACTION_DOWN:
-                mDelegateTargeted = mBounds.contains(event.getX(), event.getY());
+                mDelegateTargeted = mTouchCheckBounds.contains(event.getX(), event.getY());
                 if (mDelegateTargeted) {
+                    mWasTouchOutsideBounds = !mBounds.contains(event.getX(), event.getY());
                     sendToDelegate = true;
                 }
                 break;
@@ -78,9 +95,15 @@
         }
         boolean handled = false;
         if (sendToDelegate) {
-            event.offsetLocation(-mBounds.left, -mBounds.top);
+            float x = event.getX();
+            float y = event.getY();
+            if (mWasTouchOutsideBounds) {
+                event.setLocation(mBounds.centerX(), mBounds.centerY());
+            } else {
+                event.offsetLocation(-mBounds.left, -mBounds.top);
+            }
             handled = mDelegateView.dispatchTouchEvent(event);
-            event.offsetLocation(mBounds.left, mBounds.top);
+            event.setLocation(x, y);
         }
         return handled;
     }