diff options
author | Michael Jurka <mikejurka@google.com> | 2010-07-28 11:29:25 -0700 |
---|---|---|
committer | Michael Jurka <mikejurka@google.com> | 2010-07-28 15:11:27 -0700 |
commit | 213d96354e7407dba5c9715eb10d04bebd82c395 (patch) | |
tree | f6127de930fef2dea4076f1a8a734005ac744fee | |
parent | dee0589388ba0f6373912e18bf86243282fb3b9b (diff) | |
download | packages_apps_trebuchet-213d96354e7407dba5c9715eb10d04bebd82c395.zip packages_apps_trebuchet-213d96354e7407dba5c9715eb10d04bebd82c395.tar.gz packages_apps_trebuchet-213d96354e7407dba5c9715eb10d04bebd82c395.tar.bz2 |
Improved support for workspace screen thumbnails
- Shrinking workspace view in All Apps
- Added vertical margin for workspace screen thumnbnails
- Fixed bugs in a few of the Launcher state transitions (e.g. customization to all apps)
Change-Id: I9ad1c8861585d78fdb2e3bc986a614526b3cfe5f
-rw-r--r-- | res/values/dimens.xml | 3 | ||||
-rw-r--r-- | src/com/android/launcher2/Launcher.java | 19 | ||||
-rw-r--r-- | src/com/android/launcher2/Workspace.java | 44 |
3 files changed, 51 insertions, 15 deletions
diff --git a/res/values/dimens.xml b/res/values/dimens.xml index 9bf6cdf..38936ce 100644 --- a/res/values/dimens.xml +++ b/res/values/dimens.xml @@ -41,4 +41,7 @@ <!-- horizontal spacing between mini screen thumbnails ie. in all apps and in customization mode --> <dimen name="smallScreenSpacing">10dip</dimen> + + <!-- vertical spacing between edge of screen and mini screen thumbnails --> + <dimen name="smallScreenVerticalMargin">20dip</dimen> </resources> diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java index be60e98..8102d19 100644 --- a/src/com/android/launcher2/Launcher.java +++ b/src/com/android/launcher2/Launcher.java @@ -1266,7 +1266,7 @@ public final class Launcher extends Activity // Animate the widget chooser up from the bottom of the screen if (!isCustomizationDrawerVisible()) { showCustomizationDrawer(); - mWorkspace.shrink(); + mWorkspace.shrinkToTop(); } } else { showAddDialog(mMenuAddInfo); @@ -2023,7 +2023,8 @@ public final class Launcher extends Activity // AllAppsView.Watcher public void zoomed(float zoom) { - if (zoom == 1.0f) { + // In XLarge view, we zoom down the workspace below all apps so it's still visible + if (zoom == 1.0f && !LauncherApplication.isScreenXLarge()) { mWorkspace.setVisibility(View.GONE); } } @@ -2036,6 +2037,7 @@ public final class Launcher extends Activity mAllAppsGrid.zoom(1.0f, false); Animation anim = AnimationUtils.loadAnimation(this, R.anim.all_apps_zoom_in); ((View) mAllAppsGrid).startAnimation(anim); + mWorkspace.shrinkToBottom(); } else { mAllAppsGrid.zoom(1.0f, animated); } @@ -2099,6 +2101,7 @@ public final class Launcher extends Activity } }); ((View)mAllAppsGrid).startAnimation(anim); + mWorkspace.unshrink(); } else { mAllAppsGrid.zoom(0.0f, animated); } @@ -2128,7 +2131,7 @@ public final class Launcher extends Activity mHomeCustomizationDrawer.startAnimation(AnimationUtils.loadAnimation(this, R.anim.home_customization_drawer_slide_up)); } - void hideCustomizationDrawer() { + private void hideCustomizationDrawer() { if (isCustomizationDrawerVisible()) { Animation slideDownAnimation = AnimationUtils.loadAnimation(this, R.anim.home_customization_drawer_slide_down); slideDownAnimation.setAnimationListener(new Animation.AnimationListener() { @@ -2142,6 +2145,16 @@ public final class Launcher extends Activity } } + void onWorkspaceUnshrink() { + if (isAllAppsVisible()) { + // TODO: Make a smoother transition here + closeAllApps(false); + } + if (isCustomizationDrawerVisible()) { + hideCustomizationDrawer(); + } + } + /** * Displays the shortcut creation dialog and launches, if necessary, the * appropriate activity. diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java index 7fbdd1e..1a2f812 100644 --- a/src/com/android/launcher2/Workspace.java +++ b/src/com/android/launcher2/Workspace.java @@ -548,7 +548,7 @@ public class Workspace extends ViewGroup // this is an intercepted event being forwarded from a cell layout if (mIsSmall) { unshrink((CellLayout)v); - mLauncher.hideCustomizationDrawer(); + mLauncher.onWorkspaceUnshrink(); } return false; } @@ -710,8 +710,9 @@ public class Workspace extends ViewGroup final View child = getChildAt(i); if (child.getVisibility() != View.GONE) { final int childX = child.getX(); - child.layout( - childX, 0, childX + child.getMeasuredWidth(), child.getMeasuredHeight()); + final int childY = child.getY(); + child.layout(childX, childY, + childX + child.getMeasuredWidth(), childY + child.getMeasuredHeight()); } } @@ -1117,16 +1118,30 @@ public class Workspace extends ViewGroup return true; } + void shrinkToTop() { + shrink(true); + } + + void shrinkToBottom() { + shrink(false); + } + // we use this to shrink the workspace for the all apps view and the customize view - void shrink() { + private void shrink(boolean shrinkToTop) { mIsSmall = true; final int screenWidth = getWidth(); - - final int scaledWorkspacePageWidth = (int)(SHRINK_FACTOR*screenWidth); + final int screenHeight = getHeight(); + final int scaledScreenWidth = (int)(SHRINK_FACTOR*screenWidth); + final int scaledScreenHeight = (int)(SHRINK_FACTOR*screenHeight); final float scaledSpacing = getResources().getDimension(R.dimen.smallScreenSpacing); final int screenCount = getChildCount(); - float totalWidth = screenCount * scaledWorkspacePageWidth + (screenCount - 1) * scaledSpacing; + float totalWidth = screenCount * scaledScreenWidth + (screenCount - 1) * scaledSpacing; + + float newY = getResources().getDimension(R.dimen.smallScreenVerticalMargin); + if (!shrinkToTop) { + newY = screenHeight - newY - scaledScreenHeight; + } // We animate all the screens to the centered position in workspace // At the same time, the screens become greyed/dimmed @@ -1136,20 +1151,23 @@ public class Workspace extends ViewGroup Sequencer s = new Sequencer(); for (int i = 0; i < screenCount; i++) { CellLayout cl = (CellLayout) getChildAt(i); - PropertyAnimator translate = new PropertyAnimator( + PropertyAnimator translateX = new PropertyAnimator( 500, cl, "x", cl.getX(), (int) newX); + PropertyAnimator translateY = new PropertyAnimator( + 500, cl, "y", cl.getY(), (int) newY); PropertyAnimator scaleX = new PropertyAnimator( 500, cl, "scaleX", cl.getScaleX(), SHRINK_FACTOR); PropertyAnimator scaleY = new PropertyAnimator( 500, cl, "scaleY", cl.getScaleY(), SHRINK_FACTOR); PropertyAnimator alpha = new PropertyAnimator( 500, cl, "dimmedBitmapAlpha", cl.getDimmedBitmapAlpha(), 1.0f); - Sequencer.Builder b = s.play(translate); + Sequencer.Builder b = s.play(translateX); + b.with(translateY); b.with(scaleX); b.with(scaleY); b.with(alpha); // increment newX for the next screen - newX += scaledWorkspacePageWidth + scaledSpacing; + newX += scaledScreenWidth + scaledSpacing; cl.setOnInterceptTouchListener(this); } setChildrenDrawnWithCacheEnabled(true); @@ -1184,12 +1202,14 @@ public class Workspace extends ViewGroup CellLayout cl = (CellLayout)getChildAt(i); int x = screenWidth * i; - PropertyAnimator translate = new PropertyAnimator(500, cl, "x", cl.getX(), x); + PropertyAnimator translateX = new PropertyAnimator(500, cl, "x", cl.getX(), x); + PropertyAnimator translateY = new PropertyAnimator(500, cl, "y", cl.getY(), 0); PropertyAnimator scaleX = new PropertyAnimator(500, cl, "scaleX", cl.getScaleX(), 1.0f); PropertyAnimator scaleY = new PropertyAnimator(500, cl, "scaleY", cl.getScaleY(), 1.0f); PropertyAnimator alpha = new PropertyAnimator( 500, cl, "dimmedBitmapAlpha", cl.getDimmedBitmapAlpha(), 0.0f); - Sequencer.Builder b = s.play(translate); + Sequencer.Builder b = s.play(translateX); + b.with(translateY); b.with(scaleX); b.with(scaleY); b.with(alpha); |