summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2010-07-30 16:36:20 -0700
committerMichael Jurka <mikejurka@google.com>2010-07-30 17:39:39 -0700
commit79212d81361d1ad8c941c48f8323eb526643ca68 (patch)
tree178bbd2158b4bb67b6b89a9e4d8b16d30e07d3ee /src
parent54dd75463d0eb47c2f468e19063bdc4141dfdf74 (diff)
downloadandroid_packages_apps_Trebuchet-79212d81361d1ad8c941c48f8323eb526643ca68.tar.gz
android_packages_apps_Trebuchet-79212d81361d1ad8c941c48f8323eb526643ca68.tar.bz2
android_packages_apps_Trebuchet-79212d81361d1ad8c941c48f8323eb526643ca68.zip
Fixing bugs related to starting in All Apps mode
- fixed bug where Workspace.shrinkToBottom() was not always called in showAllApps - added logic to defer call to Workspace.shrinkToBottom() after first layout call (necessary because shrinkToBottom relies on getWidth() working properly) - added ability to Workspace.shrinkToBottom() without animation Change-Id: I966141a60b6b014cf97e83b4d45725b41b16e55d
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/Launcher.java4
-rw-r--r--src/com/android/launcher2/Workspace.java64
2 files changed, 49 insertions, 19 deletions
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 1de318fc5..feb247e99 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2032,12 +2032,14 @@ public final class Launcher extends Activity
void showAllApps(boolean animated) {
hideCustomizationDrawer();
+ if (LauncherApplication.isScreenXLarge()) {
+ mWorkspace.shrinkToBottom(animated);
+ }
if (LauncherApplication.isScreenXLarge() && animated) {
// Not really a zoom -- this just makes the view visible
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);
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 5200dbc87..536eba81b 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -86,6 +86,7 @@ public class Workspace extends ViewGroup
private int mDefaultScreen;
private boolean mFirstLayout = true;
+ private boolean mWaitingToShrinkToBottom = false;
private int mCurrentScreen;
private int mNextScreen = INVALID_SCREEN;
@@ -726,6 +727,13 @@ public class Workspace extends ViewGroup
}
}
+ // if shrinkToBottom() is called on initialization, it has to be deferred
+ // until after the first call to onLayout so that it has the correct width
+ if (mWaitingToShrinkToBottom) {
+ shrinkToBottom(false);
+ mWaitingToShrinkToBottom = false;
+ }
+
if (LauncherApplication.isInPlaceRotationEnabled()) {
// When the device is rotated, the scroll position of the current screen
// needs to be refreshed
@@ -1135,15 +1143,27 @@ public class Workspace extends ViewGroup
}
void shrinkToTop() {
- shrink(true);
+ shrink(true, true);
}
void shrinkToBottom() {
- shrink(false);
+ shrinkToBottom(true);
+ }
+
+ void shrinkToBottom(boolean animated) {
+ if (mFirstLayout) {
+ // (mFirstLayout == "first layout has not happened yet")
+ // if we get a call to shrink() as part of our initialization (for example, if
+ // Launcher is started in All Apps mode) then we need to wait for a layout call
+ // to get our width so we can layout the mini-screen views correctly
+ mWaitingToShrinkToBottom = true;
+ } else {
+ shrink(false, animated);
+ }
}
// we use this to shrink the workspace for the all apps view and the customize view
- private void shrink(boolean shrinkToTop) {
+ private void shrink(boolean shrinkToTop, boolean animated) {
mIsSmall = true;
final int screenWidth = getWidth();
final int screenHeight = getHeight();
@@ -1167,21 +1187,29 @@ public class Workspace extends ViewGroup
Sequencer s = new Sequencer();
for (int i = 0; i < screenCount; i++) {
CellLayout cl = (CellLayout) getChildAt(i);
- 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(translateX);
- b.with(translateY);
- b.with(scaleX);
- b.with(scaleY);
- b.with(alpha);
+ if (animated) {
+ 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(translateX);
+ b.with(translateY);
+ b.with(scaleX);
+ b.with(scaleY);
+ b.with(alpha);
+ } else {
+ cl.setX((int)newX);
+ cl.setY((int)newY);
+ cl.setScaleX(SHRINK_FACTOR);
+ cl.setScaleY(SHRINK_FACTOR);
+ cl.setDimmedBitmapAlpha(1.0f);
+ }
// increment newX for the next screen
newX += scaledScreenWidth + scaledSpacing;
cl.setOnInterceptTouchListener(this);