Merge "sw600dp pixel perfect tweaks" into jb-dev
diff --git a/res/drawable-hdpi/workspace_bg.9.png b/res/drawable-hdpi/workspace_bg.9.png
index eeed8e7..5bbfa4f 100644
--- a/res/drawable-hdpi/workspace_bg.9.png
+++ b/res/drawable-hdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/drawable-land-hdpi/workspace_bg.9.png b/res/drawable-land-hdpi/workspace_bg.9.png
index 069bb1f..1a58144 100644
--- a/res/drawable-land-hdpi/workspace_bg.9.png
+++ b/res/drawable-land-hdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/drawable-land-mdpi/workspace_bg.9.png b/res/drawable-land-mdpi/workspace_bg.9.png
index 611bd5b..a12519e 100644
--- a/res/drawable-land-mdpi/workspace_bg.9.png
+++ b/res/drawable-land-mdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/drawable-land-xhdpi/workspace_bg.9.png b/res/drawable-land-xhdpi/workspace_bg.9.png
index a1f60c6..ce41454 100644
--- a/res/drawable-land-xhdpi/workspace_bg.9.png
+++ b/res/drawable-land-xhdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/drawable-mdpi/workspace_bg.9.png b/res/drawable-mdpi/workspace_bg.9.png
index a30d992..2856e09 100644
--- a/res/drawable-mdpi/workspace_bg.9.png
+++ b/res/drawable-mdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/drawable-xhdpi/workspace_bg.9.png b/res/drawable-xhdpi/workspace_bg.9.png
index ceac4f2..72269f2 100644
--- a/res/drawable-xhdpi/workspace_bg.9.png
+++ b/res/drawable-xhdpi/workspace_bg.9.png
Binary files differ
diff --git a/res/values-cs/strings.xml b/res/values-cs/strings.xml
index 3daad84..3ad9f9b 100644
--- a/res/values-cs/strings.xml
+++ b/res/values-cs/strings.xml
@@ -20,7 +20,7 @@
 <resources xmlns:android="http://schemas.android.com/apk/res/android"
     xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
     <string name="application_name" msgid="8424725141379931883">"Launcher"</string>
-    <string name="home" msgid="5921706419368316758">"Domovská stránka"</string>
+    <string name="home" msgid="5921706419368316758">"Plocha"</string>
     <string name="uid_name" msgid="3371120195364560632">"Android Core Apps"</string>
     <string name="folder_name" msgid="8551881338202938211"></string>
     <string name="chooser_wallpaper" msgid="6063168087625352235">"Vybrat tapetu z"</string>
diff --git a/res/values-in/strings.xml b/res/values-in/strings.xml
index 4e534ea..77bca53 100644
--- a/res/values-in/strings.xml
+++ b/res/values-in/strings.xml
@@ -87,11 +87,9 @@
     <string name="uninstall_system_app_text" msgid="6429814133777046491">"Ini adalah apl sistem dan tidak dapat dicopot pemasangannya."</string>
     <string name="dream_name" msgid="2847171357608437154">"Rocket Launcher"</string>
     <string name="folder_hint_text" msgid="8633351560105748141">"Folder Tanpa Nama"</string>
-    <!-- no translation found for workspace_description_format (2968608205939373034) -->
-    <skip />
+    <string name="workspace_description_format" msgid="2968608205939373034">"Layar utama %1$d"</string>
     <string name="default_scroll_format" msgid="4057140866420001240">"Laman %1$d dari %2$d"</string>
-    <!-- no translation found for workspace_scroll_format (1704767047951143301) -->
-    <skip />
+    <string name="workspace_scroll_format" msgid="1704767047951143301">"Layar utama %1$d dari %2$d"</string>
     <string name="apps_customize_apps_scroll_format" msgid="5494241912377704885">"Laman apl %1$d dari %2$d"</string>
     <string name="apps_customize_widgets_scroll_format" msgid="5383009742241717437">"Laman widget %1$d dari %2$d"</string>
     <string name="workspace_cling_title" msgid="738396473989890567">"Anggap rumah sendiri"</string>
diff --git a/res/values-ms/strings.xml b/res/values-ms/strings.xml
index 42d6892..1c9a0dc 100644
--- a/res/values-ms/strings.xml
+++ b/res/values-ms/strings.xml
@@ -87,11 +87,9 @@
     <string name="uninstall_system_app_text" msgid="6429814133777046491">"Ini adalah aplikasi sistem dan tidak boleh dinyahpasang."</string>
     <string name="dream_name" msgid="2847171357608437154">"Pelancar Roket"</string>
     <string name="folder_hint_text" msgid="8633351560105748141">"Folder Tanpa Nama"</string>
-    <!-- no translation found for workspace_description_format (2968608205939373034) -->
-    <skip />
+    <string name="workspace_description_format" msgid="2968608205939373034">"Skrin utama %1$d"</string>
     <string name="default_scroll_format" msgid="4057140866420001240">"Halaman %1$d dari %2$d"</string>
-    <!-- no translation found for workspace_scroll_format (1704767047951143301) -->
-    <skip />
+    <string name="workspace_scroll_format" msgid="1704767047951143301">"Skrin utama %1$d dari %2$d"</string>
     <string name="apps_customize_apps_scroll_format" msgid="5494241912377704885">"Halaman apl %1$d dari %2$d"</string>
     <string name="apps_customize_widgets_scroll_format" msgid="5383009742241717437">"Halaman widget %1$d dari %2$d"</string>
     <string name="workspace_cling_title" msgid="738396473989890567">"Buat diri anda seperti di rumah"</string>
diff --git a/res/values-sw720dp/dimens.xml b/res/values-sw720dp/dimens.xml
index c1b1e31..48c729d 100644
--- a/res/values-sw720dp/dimens.xml
+++ b/res/values-sw720dp/dimens.xml
@@ -15,6 +15,7 @@
 -->
 
 <resources>
+    <dimen name="app_icon_size">72dp</dimen>
 <!-- QSB -->
     <dimen name="toolbar_button_vertical_padding">12dip</dimen>
     <dimen name="toolbar_button_horizontal_padding">12dip</dimen>
diff --git a/res/values-zh-rCN/strings.xml b/res/values-zh-rCN/strings.xml
index aa24ae8..4d73486 100644
--- a/res/values-zh-rCN/strings.xml
+++ b/res/values-zh-rCN/strings.xml
@@ -87,11 +87,9 @@
     <string name="uninstall_system_app_text" msgid="6429814133777046491">"这是系统应用,无法卸载。"</string>
     <string name="dream_name" msgid="2847171357608437154">"Rocket Launcher"</string>
     <string name="folder_hint_text" msgid="8633351560105748141">"未命名文件夹"</string>
-    <!-- no translation found for workspace_description_format (2968608205939373034) -->
-    <skip />
+    <string name="workspace_description_format" msgid="2968608205939373034">"主屏幕第 %1$d 页"</string>
     <string name="default_scroll_format" msgid="4057140866420001240">"第 %1$d 页,共 %2$d 页"</string>
-    <!-- no translation found for workspace_scroll_format (1704767047951143301) -->
-    <skip />
+    <string name="workspace_scroll_format" msgid="1704767047951143301">"主屏幕第 %1$d 页,共 %2$d 页"</string>
     <string name="apps_customize_apps_scroll_format" msgid="5494241912377704885">"应用:第 %1$d 页,共 %2$d 页"</string>
     <string name="apps_customize_widgets_scroll_format" msgid="5383009742241717437">"窗口小部件:第 %1$d 页,共 %2$d 页"</string>
     <string name="workspace_cling_title" msgid="738396473989890567">"随意浏览"</string>
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 5bd0ac6..54af080 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -524,6 +524,10 @@
                 mPressedIcon.lockDrawableState();
             }
 
+            // NOTE: We want all transitions from launcher to act as if the wallpaper were enabled
+            // to be consistent.  So re-enable the flag here, and we will re-disable it as necessary
+            // when Launcher resumes and we are still in AllApps.
+            mLauncher.updateWallpaperVisibility(true);
             mLauncher.startActivitySafely(v, appInfo.intent, appInfo);
 
         } else if (v instanceof PagedViewWidget) {
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index d4a2c84..ece1870 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -17,6 +17,8 @@
 package com.android.launcher2;
 
 import android.animation.Animator;
+import android.animation.AnimatorSet;
+import android.animation.ObjectAnimator;
 import android.animation.AnimatorListenerAdapter;
 import android.animation.TimeInterpolator;
 import android.animation.ValueAnimator;
@@ -147,7 +149,7 @@
     static final int LANDSCAPE = 0;
     static final int PORTRAIT = 1;
 
-    private static final float REORDER_HINT_MAGNITUDE = 0.27f;
+    private static final float REORDER_HINT_MAGNITUDE = 0.10f;
     private static final int REORDER_ANIMATION_DURATION = 150;
     private float mReorderHintAnimationMagnitude;
 
@@ -1921,7 +1923,7 @@
         View child;
         float deltaX;
         float deltaY;
-        private static final int DURATION = 140;
+        private static final int DURATION = 300;
         private int repeatCount;
         private boolean cancelOnCycleComplete = false;
         ValueAnimator va;
@@ -1950,6 +1952,8 @@
                     deltaY = (int) (Math.sin(angle) * mReorderHintAnimationMagnitude);
                 }
             }
+            child.setPivotY(child.getMeasuredHeight() * 0.5f);
+            child.setPivotX(child.getMeasuredWidth() * 0.5f);
             this.child = child;
         }
 
@@ -1965,7 +1969,7 @@
             va = ValueAnimator.ofFloat(0f, 1f);
             va.setRepeatMode(ValueAnimator.REVERSE);
             va.setRepeatCount(ValueAnimator.INFINITE);
-            va.setDuration(DURATION);
+            va.setDuration((int) (DURATION * (1.0f + Math.random()*.08f)));
             va.addUpdateListener(new AnimatorUpdateListener() {
                 @Override
                 public void onAnimationUpdate(ValueAnimator animation) {
@@ -1974,6 +1978,10 @@
                     float y = r * deltaY;
                     child.setTranslationX(x);
                     child.setTranslationY(y);
+                    float sf = 4.0f / child.getWidth();
+                    float s = 1.0f - r * sf;
+                    child.setScaleX(s);
+                    child.setScaleY(s);
                 }
             });
             va.addListener(new AnimatorListenerAdapter() {
@@ -1994,6 +2002,21 @@
         private void completeAnimation() {
             cancelOnCycleComplete = true;
         }
+        private void completeAnimationImmediately() {
+            va.cancel();
+
+            AnimatorSet s = new AnimatorSet();
+            s.playTogether(
+                ObjectAnimator.ofFloat(child, "scaleX", 1f),
+                ObjectAnimator.ofFloat(child, "scaleY", 1f),
+                ObjectAnimator.ofFloat(child, "translationX", 0f),
+                ObjectAnimator.ofFloat(child, "translationX", 0f)
+            );
+            s.setDuration(REORDER_ANIMATION_DURATION);
+            s.setInterpolator(new android.view.animation.DecelerateInterpolator(1.5f));
+            s.start();
+        }
+
 
         // Returns the time required to complete the current oscillating animation
         private int completionTime() {
@@ -2007,7 +2030,7 @@
 
     private void completeAndClearReorderHintAnimations() {
         for (ReorderHintAnimation a: mShakeAnimators.values()) {
-            a.completeAnimation();
+            a.completeAnimationImmediately();
         }
         mShakeAnimators.clear();
     }
diff --git a/src/com/android/launcher2/DragLayer.java b/src/com/android/launcher2/DragLayer.java
index b316665..4be1914 100644
--- a/src/com/android/launcher2/DragLayer.java
+++ b/src/com/android/launcher2/DragLayer.java
@@ -462,7 +462,16 @@
         float scale = getDescendantCoordRelativeToSelf((View) child.getParent(), coord);
         int toX = coord[0];
         int toY = coord[1];
-        if (child instanceof FolderIcon) {
+        if (child instanceof TextView) {
+            TextView tv = (TextView) child;
+
+            // The child may be scaled (always about the center of the view) so to account for it,
+            // we have to offset the position by the scaled size.  Once we do that, we can center
+            // the drag view about the scaled child view.
+            toY += Math.round(scale * tv.getPaddingTop());
+            toY -= dragView.getMeasuredHeight() * (1 - scale) / 2;
+            toX -= (dragView.getMeasuredWidth() - Math.round(scale * child.getMeasuredWidth())) / 2;
+        } else if (child instanceof FolderIcon) {
             // Account for holographic blur padding on the drag view
             toY -= Workspace.DRAG_BITMAP_PADDING / 2;
             // Center in the x coordinate about the target's drawable
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 6025c70..74ec6f3 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -1204,12 +1204,7 @@
                         mWorkspace.post(new Runnable() {
                             @Override
                             public void run() {
-                                if (mState == State.APPS_CUSTOMIZE) {
-                                    if (mAppsCustomizeTabHost != null &&
-                                            !mAppsCustomizeTabHost.isTransitioning()) {
-                                        updateWallpaperVisibility(false);
-                                    }
-                                }
+                                disableWallpaperIfInAllApps();
                             }
                         });
 
@@ -1862,7 +1857,7 @@
             if (activityName != null) {
                 intent.setPackage(activityName.getPackageName());
             }
-            startActivitySafely(null, intent, "onClickVoiceButton");
+            startActivity(null, intent, "onClickVoiceButton");
         } catch (ActivityNotFoundException e) {
             Intent intent = new Intent(RecognizerIntent.ACTION_WEB_SEARCH);
             intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK
@@ -1919,7 +1914,7 @@
         }
     }
 
-    boolean startActivitySafely(View v, Intent intent, Object tag) {
+    boolean startActivity(View v, Intent intent, Object tag) {
         intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
 
         try {
@@ -1936,9 +1931,6 @@
                 startActivity(intent);
             }
             return true;
-        } catch (ActivityNotFoundException e) {
-            Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
-            Log.e(TAG, "Unable to launch. tag=" + tag + " intent=" + intent, e);
         } catch (SecurityException e) {
             Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
             Log.e(TAG, "Launcher does not have the permission to launch " + intent +
@@ -1949,6 +1941,17 @@
         return false;
     }
 
+    boolean startActivitySafely(View v, Intent intent, Object tag) {
+        boolean success = false;
+        try {
+            success = startActivity(v, intent, tag);
+        } catch (ActivityNotFoundException e) {
+            Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show();
+            Log.e(TAG, "Unable to launch. tag=" + tag + " intent=" + intent, e);
+        }
+        return success;
+    }
+
     void startActivityForResultSafely(Intent intent, int requestCode) {
         try {
             startActivityForResult(intent, requestCode);
@@ -2183,6 +2186,16 @@
         view.setPivotY(view.getHeight() / 2.0f);
     }
 
+    void disableWallpaperIfInAllApps() {
+        // Only disable it if we are in all apps
+        if (mState == State.APPS_CUSTOMIZE) {
+            if (mAppsCustomizeTabHost != null &&
+                    !mAppsCustomizeTabHost.isTransitioning()) {
+                updateWallpaperVisibility(false);
+            }
+        }
+    }
+
     void updateWallpaperVisibility(boolean visible) {
         int wpflags = visible ? WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER : 0;
         int curflags = getWindow().getAttributes().flags
@@ -2526,6 +2539,18 @@
         }
     }
 
+    @Override
+    public void onWindowFocusChanged(boolean hasFocus) {
+        if (!hasFocus) {
+            // When another window occludes launcher (like the notification shade, or recents),
+            // ensure that we enable the wallpaper flag so that transitions are done correctly.
+            updateWallpaperVisibility(true);
+        } else {
+            // When launcher has focus again, disable the wallpaper if we are in AllApps
+            disableWallpaperIfInAllApps();
+        }
+    }
+
     void showWorkspace(boolean animated) {
         showWorkspace(animated, null);
     }