Merge "Import translations. DO NOT MERGE" into jb-ub-now-indigo-rose
diff --git a/src/com/android/launcher3/CropView.java b/src/com/android/launcher3/CropView.java
index f68f739..c8b974d 100644
--- a/src/com/android/launcher3/CropView.java
+++ b/src/com/android/launcher3/CropView.java
@@ -197,13 +197,14 @@
             float squaredDist = (mFirstX - x) * (mFirstX - x) + (mFirstY - y) * (mFirstY - y);
             float slop = config.getScaledTouchSlop() * config.getScaledTouchSlop();
             long now = System.currentTimeMillis();
-            // only do this if it's a small movement
-            if (mTouchCallback != null &&
-                    squaredDist < slop &&
-                    now < mTouchDownTime + ViewConfiguration.getTapTimeout()) {
-                mTouchCallback.onTap();
+            if (mTouchCallback != null) {
+                // only do this if it's a small movement
+                if (squaredDist < slop &&
+                        now < mTouchDownTime + ViewConfiguration.getTapTimeout()) {
+                    mTouchCallback.onTap();
+                }
+                mTouchCallback.onTouchUp();
             }
-            mTouchCallback.onTouchUp();
         }
 
         if (!mTouchEnabled) {
diff --git a/src/com/android/launcher3/DynamicGrid.java b/src/com/android/launcher3/DynamicGrid.java
index 8a6fbc1..065d7a7 100644
--- a/src/com/android/launcher3/DynamicGrid.java
+++ b/src/com/android/launcher3/DynamicGrid.java
@@ -460,7 +460,7 @@
                 lp = (FrameLayout.LayoutParams) pageIndicator.getLayoutParams();
                 lp.gravity = Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM;
                 lp.width = LayoutParams.WRAP_CONTENT;
-                lp.height = pageIndicatorHeightPx;
+                lp.height = LayoutParams.WRAP_CONTENT;
                 lp.bottomMargin = hotseatBarHeightPx;
                 pageIndicator.setLayoutParams(lp);
             }
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index d330805..cfa5545 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -87,6 +87,7 @@
 import android.view.ViewTreeObserver.OnGlobalLayoutListener;
 import android.view.WindowManager;
 import android.view.accessibility.AccessibilityEvent;
+import android.view.accessibility.AccessibilityManager;
 import android.view.animation.AccelerateDecelerateInterpolator;
 import android.view.animation.DecelerateInterpolator;
 import android.view.inputmethod.InputMethodManager;
@@ -4088,6 +4089,13 @@
         // disable clings when running in a test harness
         if(ActivityManager.isRunningInTestHarness()) return false;
 
+        // Disable clings for accessibility when explore by touch is enabled
+        final AccessibilityManager a11yManager = (AccessibilityManager) getSystemService(
+                ACCESSIBILITY_SERVICE);
+        if (a11yManager.isTouchExplorationEnabled()) {
+            return false;
+        }
+
         // Restricted secondary users (child mode) will potentially have very few apps
         // seeded when they start up for the first time. Clings won't work well with that
 //        boolean supportsLimitedUsers =
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index ef918e9..b9552ea 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -459,7 +459,8 @@
     protected boolean shouldDrawChild(View child) {
         final CellLayout cl = (CellLayout) child;
         return super.shouldDrawChild(child) &&
-            (cl.getShortcutsAndWidgets().getAlpha() > 0 ||
+            (mIsSwitchingState ||
+             cl.getShortcutsAndWidgets().getAlpha() > 0 ||
              cl.getBackgroundAlpha() > 0);
     }
 
@@ -571,6 +572,7 @@
         if (customContent instanceof Insettable) {
             ((Insettable)customContent).setInsets(mInsets);
         }
+        customScreen.removeAllViews();
         customScreen.addViewToCellLayout(customContent, 0, 0, lp, true);
         mCustomContentDescription = description;
 
@@ -1919,7 +1921,8 @@
         float finalSearchBarAlpha = !stateIsNormal ? 0f : 1f;
         float finalWorkspaceTranslationY = stateIsOverview ? getOverviewModeTranslationY() : 0;
 
-        boolean zoomIn = true;
+        boolean workspaceToAllApps = (oldStateIsNormal && stateIsSmall);
+        boolean allAppsToWorkspace = (oldStateIsSmall && stateIsNormal);
         mNewScale = 1.0f;
 
         if (oldStateIsOverview) {
@@ -1936,19 +1939,32 @@
             } else if (stateIsSmall){
                 mNewScale = mOverviewModeShrinkFactor - 0.3f;
             }
-            if (oldStateIsNormal && stateIsSmall) {
-                zoomIn = false;
+            if (workspaceToAllApps) {
                 updateChildrenLayersEnabled(false);
             }
         }
-        final int duration = zoomIn ?
+
+        final int duration = workspaceToAllApps ?
                 getResources().getInteger(R.integer.config_workspaceUnshrinkTime) :
                 getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime);
         for (int i = 0; i < getChildCount(); i++) {
             final CellLayout cl = (CellLayout) getChildAt(i);
-            float finalAlpha = (!mWorkspaceFadeInAdjacentScreens ||
-                    (i == mCurrentPage)) && !stateIsSmall ? 1f : 0f;
+            boolean isCurrentPage = (i == getNextPage());
             float initialAlpha = cl.getShortcutsAndWidgets().getAlpha();
+            float finalAlpha = stateIsSmall ? 0f : 1f;
+
+            // If we are animating to/from the small state, then hide the side pages and fade the
+            // current page in
+            if (!mIsSwitchingState) {
+                if (workspaceToAllApps || allAppsToWorkspace) {
+                    if (allAppsToWorkspace && isCurrentPage) {
+                        initialAlpha = 0f;
+                    } else if (!isCurrentPage) {
+                        initialAlpha = finalAlpha = 0f;
+                    }
+                    cl.setShortcutAndWidgetAlpha(initialAlpha);
+                }
+            }
 
             mOldAlphas[i] = initialAlpha;
             mNewAlphas[i] = finalAlpha;
@@ -2108,6 +2124,10 @@
 
     private void onTransitionPrepare() {
         mIsSwitchingState = true;
+
+        // Invalidate here to ensure that the pages are rendered during the state change transition.
+        invalidate();
+
         updateChildrenLayersEnabled(false);
         hideCustomContentIfNecessary();
     }