Fixes for landscape AllApps3D

Change-Id: Ib4cbe475d81a0b857d5560592c3db4ba09ec9319
diff --git a/src/com/android/launcher2/AllApps3D.java b/src/com/android/launcher2/AllApps3D.java
index 4990254..0e512c6 100644
--- a/src/com/android/launcher2/AllApps3D.java
+++ b/src/com/android/launcher2/AllApps3D.java
@@ -155,13 +155,6 @@
             setRenderScriptGL(sRS);
         }
 
-        final DisplayMetrics metrics = getResources().getDisplayMetrics();
-        final boolean isPortrait = metrics.widthPixels < metrics.heightPixels;
-        mColumnsPerPage = isPortrait ? Defines.COLUMNS_PER_PAGE_PORTRAIT :
-                Defines.COLUMNS_PER_PAGE_LANDSCAPE;
-        mRowsPerPage = isPortrait ? Defines.ROWS_PER_PAGE_PORTRAIT :
-                Defines.ROWS_PER_PAGE_LANDSCAPE;
-
         if (sRollo != null) {
             sRollo.mAllApps = this;
             sRollo.mRes = getResources();
@@ -233,6 +226,12 @@
 
         super.surfaceChanged(holder, format, w, h);
 
+        final boolean isPortrait = w < h;
+        mColumnsPerPage = isPortrait ? Defines.COLUMNS_PER_PAGE_PORTRAIT :
+                Defines.COLUMNS_PER_PAGE_LANDSCAPE;
+        mRowsPerPage = isPortrait ? Defines.ROWS_PER_PAGE_PORTRAIT :
+                Defines.ROWS_PER_PAGE_LANDSCAPE;
+
         if (mSurrendered) return;
 
         mHaveSurface = true;
@@ -1046,13 +1045,16 @@
                 i.ScaleOffset.x = (2.f / 480.f);
                 i.ScaleOffset.y = 0;
                 i.ScaleOffset.z = -((float)w / 2) - 0.25f;
-                i.ScaleOffset.w = -380.25f;
-                i.BendPos.x = 120.f;
-                i.BendPos.y = 680.f;
-                if (w > h) {
-                    i.ScaleOffset.z = 40.f;
-                    i.ScaleOffset.w = h - 40.f;
-                    i.BendPos.y = 1.f;
+                if (w < h) {
+                    // portrait
+                    i.ScaleOffset.w = -380.25f;
+                    i.BendPos.x = 120.f;        // bottom of screen
+                    i.BendPos.y = h - 82.f;     // top of screen
+                } else {
+                    // landscape
+                    i.ScaleOffset.w = -206.25f;
+                    i.BendPos.x = 50.f;
+                    i.BendPos.y = h - 30.f;
                 }
                 mUniformAlloc.set(i, 0, true);
             }
@@ -1092,7 +1094,7 @@
                     "  float aDy = cos(bendAngle);\n" +
                     "  float aDz = sin(bendAngle);\n" +
 
-                    "  float scale = (2.0 / 480.0);\n" +
+                    "  float scale = (2.0 / " + mWidth + ".0);\n" +
                     "  float x = UNI_Position.x + UNI_ImgSize.x * (1.0 - ani) * (ATTRIB_position.x - 0.5);\n" +
                     "  float ys= UNI_Position.y + UNI_ImgSize.y * (1.0 - ani) * ATTRIB_position.y;\n" +
                     "  float y = 0.0;\n" +