Refactoring layout of launcher

- Only one layout of launcher for landspace/portrait now
- Programmatically vertically centering the shrunken workspace screens rather than using a custom value

Change-Id: Ib689b4031f122b9a1b2bc1ca711b91320619bebd
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 55680f4..7920472 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2427,6 +2427,10 @@
         return mWorkspace;
     }
 
+    TabHost getCustomizationDrawer() {
+        return mHomeCustomizationDrawer;
+    }
+
     @Override
     protected Dialog onCreateDialog(int id) {
         switch (id) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 38471df..fe54ae7 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -23,7 +23,6 @@
 import android.animation.AnimatorListenerAdapter;
 import android.animation.AnimatorSet;
 import android.animation.ObjectAnimator;
-import android.animation.PropertyValuesHolder;
 import android.animation.TimeInterpolator;
 import android.animation.ValueAnimator;
 import android.animation.Animator.AnimatorListener;
@@ -62,6 +61,8 @@
 import android.view.View;
 import android.view.ViewGroup;
 import android.view.animation.DecelerateInterpolator;
+import android.widget.TabHost;
+import android.widget.TabWidget;
 import android.widget.TextView;
 import android.widget.Toast;
 
@@ -1327,6 +1328,19 @@
         shrink(shrinkState, true);
     }
 
+    private int getCustomizeDrawerHeight() {
+        TabHost customizationDrawer = mLauncher.getCustomizationDrawer();
+        int height = customizationDrawer.getHeight();
+        TabWidget tabWidget = (TabWidget)
+            customizationDrawer.findViewById(com.android.internal.R.id.tabs);
+        if (tabWidget.getTabCount() > 0) {
+            TextView tabText = (TextView) tabWidget.getChildTabViewAt(0);
+            // subtract the empty space above the tab text
+            height -= ((tabWidget.getHeight() - tabText.getLineHeight())) / 2;
+        }
+        return height;
+    }
+
     // we use this to shrink the workspace for the all apps view and the customize view
     public void shrink(ShrinkState shrinkState, boolean animated) {
         // In the launcher interaction model, we're never in the state where we're shrunken and
@@ -1403,9 +1417,7 @@
             y = screenHeight / 2 - scaledPageHeight / 2;
             finalAlpha = 1.0f;
         } else if (shrinkState == ShrinkState.TOP) {
-            y = (isPortrait ?
-                getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginPortrait) :
-                getResources().getDimension(R.dimen.customizeSmallScreenVerticalMarginLandscape));
+            y = (screenHeight - getCustomizeDrawerHeight() - scaledPageHeight) / 2;
         }
 
         int duration;