From 3c38d561e6976ffc54eda61ed669870bbb8ec207 Mon Sep 17 00:00:00 2001 From: Michael Jurka Date: Fri, 18 Feb 2011 19:22:12 -0800 Subject: [PATCH] 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 --- res/layout-xlarge-port/launcher.xml | 212 ------------------ .../launcher.xml | 12 +- res/values-xlarge-land/dimens.xml | 5 + res/values-xlarge-port/dimens.xml | 5 + res/values-xlarge/dimens.xml | 5 - src/com/android/launcher2/Launcher.java | 4 + src/com/android/launcher2/Workspace.java | 20 +- 7 files changed, 36 insertions(+), 227 deletions(-) delete mode 100644 res/layout-xlarge-port/launcher.xml rename res/{layout-xlarge-land => layout-xlarge}/launcher.xml (97%) diff --git a/res/layout-xlarge-port/launcher.xml b/res/layout-xlarge-port/launcher.xml deleted file mode 100644 index 4c83fdabf9..0000000000 --- a/res/layout-xlarge-port/launcher.xml +++ /dev/null @@ -1,212 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/res/layout-xlarge-land/launcher.xml b/res/layout-xlarge/launcher.xml similarity index 97% rename from res/layout-xlarge-land/launcher.xml rename to res/layout-xlarge/launcher.xml index 590787fc73..7f2b8e169c 100644 --- a/res/layout-xlarge-land/launcher.xml +++ b/res/layout-xlarge/launcher.xml @@ -32,7 +32,7 @@ launcher:defaultScreen="2" launcher:cellCountX="8" launcher:cellCountY="7" - launcher:pageSpacing="50dp"> + launcher:pageSpacing="@dimen/workspace_page_spacing"> @@ -70,7 +70,7 @@ android:onClick="onClickSearchButton" android:focusable="true" android:clickable="true" /> - + + android:visibility="gone" /> 32dp 2dp + + 50dp + + 480dp + 952dp \ No newline at end of file diff --git a/res/values-xlarge-port/dimens.xml b/res/values-xlarge-port/dimens.xml index baa31aace6..eca8f44724 100644 --- a/res/values-xlarge-port/dimens.xml +++ b/res/values-xlarge-port/dimens.xml @@ -22,4 +22,9 @@ 0dp 32dp + + 64dp + + 800dp + 700dp \ No newline at end of file diff --git a/res/values-xlarge/dimens.xml b/res/values-xlarge/dimens.xml index c4988e42e8..421c9e3895 100644 --- a/res/values-xlarge/dimens.xml +++ b/res/values-xlarge/dimens.xml @@ -37,11 +37,6 @@ 30dip 60dip - - 90dip - 180dip - 8dip 0dip 4dip diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index 55680f4600..792047287c 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -2427,6 +2427,10 @@ public final class Launcher extends Activity 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 38471df003..fe54ae7b6e 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -23,7 +23,6 @@ import android.animation.Animator; 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.MotionEvent; 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 @@ public class Workspace extends SmoothPagedView 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 @@ public class Workspace extends SmoothPagedView 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;