summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMichael Jurka <mikejurka@google.com>2011-03-02 17:41:34 -0800
committerMichael Jurka <mikejurka@google.com>2011-03-02 22:12:05 -0800
commit9c6fbed48783dacd9bc6b4ec5f2cc8e59ec7ee37 (patch)
tree8a980b3da908c42c774159d74c4f048d42737e76 /src
parent3cba722d4745b29a47ebc6a472dd921e5c9d7367 (diff)
downloadandroid_packages_apps_Trebuchet-9c6fbed48783dacd9bc6b4ec5f2cc8e59ec7ee37.tar.gz
android_packages_apps_Trebuchet-9c6fbed48783dacd9bc6b4ec5f2cc8e59ec7ee37.tar.bz2
android_packages_apps_Trebuchet-9c6fbed48783dacd9bc6b4ec5f2cc8e59ec7ee37.zip
Further improving performance of All Apps transition
Change-Id: Ie8a2af004acba4c13066dd636842a71793064688
Diffstat (limited to 'src')
-rw-r--r--src/com/android/launcher2/AllAppsBackground.java53
-rw-r--r--src/com/android/launcher2/AllAppsTabbed.java32
-rw-r--r--src/com/android/launcher2/Launcher.java7
-rw-r--r--src/com/android/launcher2/Workspace.java29
4 files changed, 95 insertions, 26 deletions
diff --git a/src/com/android/launcher2/AllAppsBackground.java b/src/com/android/launcher2/AllAppsBackground.java
new file mode 100644
index 000000000..5292d0ad3
--- /dev/null
+++ b/src/com/android/launcher2/AllAppsBackground.java
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2010 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.android.launcher2;
+
+import com.android.launcher.R;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.drawable.Drawable;
+import android.util.AttributeSet;
+import android.view.View;
+
+/**
+ * An implementation of PagedView that populates the pages of the workspace
+ * with all of the user's applications.
+ */
+public class AllAppsBackground extends View {
+ private Drawable mBackground;
+
+ public AllAppsBackground(Context context) {
+ this(context, null);
+ }
+
+ public AllAppsBackground(Context context, AttributeSet attrs) {
+ this(context, attrs, 0);
+ }
+
+ public AllAppsBackground(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ mBackground = getResources().getDrawable(R.drawable.all_apps_bg_gradient);
+ }
+
+ @Override
+ public void onDraw(Canvas canvas) {
+ mBackground.setBounds(mScrollX, 0, mScrollX + getMeasuredWidth(),
+ getMeasuredHeight());
+ mBackground.draw(canvas);
+ }
+}
diff --git a/src/com/android/launcher2/AllAppsTabbed.java b/src/com/android/launcher2/AllAppsTabbed.java
index 36594dd34..66191503c 100644
--- a/src/com/android/launcher2/AllAppsTabbed.java
+++ b/src/com/android/launcher2/AllAppsTabbed.java
@@ -49,7 +49,8 @@ public class AllAppsTabbed extends TabHost implements AllAppsView, LauncherAnima
private static final String TAG_DOWNLOADED = "DOWNLOADED";
private AllAppsPagedView mAllApps;
- private View mTabBar;
+ private AllAppsBackground mBackground;
+ private Launcher mLauncher;
private Context mContext;
private final LayoutInflater mInflater;
private boolean mFirstLayout = true;
@@ -68,8 +69,8 @@ public class AllAppsTabbed extends TabHost implements AllAppsView, LauncherAnima
try {
mAllApps = (AllAppsPagedView) findViewById(R.id.all_apps_paged_view);
if (mAllApps == null) throw new Resources.NotFoundException();
- mTabBar = findViewById(R.id.all_apps_tab_bar);
- if (mTabBar == null) throw new Resources.NotFoundException();
+ mBackground = (AllAppsBackground) findViewById(R.id.all_apps_background);
+ if (mBackground == null) throw new Resources.NotFoundException();
} catch (Resources.NotFoundException e) {
Log.e(TAG, "Can't find necessary layout elements for AllAppsTabbed");
}
@@ -126,6 +127,7 @@ public class AllAppsTabbed extends TabHost implements AllAppsView, LauncherAnima
@Override
public void setLauncher(Launcher launcher) {
mAllApps.setLauncher(launcher);
+ mLauncher = launcher;
}
@Override
@@ -170,25 +172,21 @@ public class AllAppsTabbed extends TabHost implements AllAppsView, LauncherAnima
}
@Override
- public void setFastAlpha(float alpha) {
- final ViewGroup allAppsParent = (ViewGroup) mAllApps.getParent();
- final ViewGroup tabBarParent = (ViewGroup) mAllApps.getParent();
- mAllApps.setFastAlpha(alpha);
- allAppsParent.fastInvalidate();
- mTabBar.setFastAlpha(alpha);
- tabBarParent.fastInvalidate();
- }
-
- @Override
public void onLauncherAnimationStart() {
- mTabBar.setLayerType(LAYER_TYPE_HARDWARE, null);
- mAllApps.setLayerType(LAYER_TYPE_HARDWARE, null);
+ // Turn on hardware layers for performance
+ setLayerType(LAYER_TYPE_HARDWARE, null);
+ // Re-enable the rendering of the dimmed background in All Apps for performance reasons
+ mLauncher.getWorkspace().disableBackground();
+ mBackground.setVisibility(VISIBLE);
}
@Override
public void onLauncherAnimationEnd() {
- mTabBar.setLayerType(LAYER_TYPE_NONE, null);
- mAllApps.setLayerType(LAYER_TYPE_NONE, null);
+ setLayerType(LAYER_TYPE_NONE, null);
+ // Move the rendering of the dimmed background to workspace after the all apps animation
+ // is done, so that the background is not rendered *above* the mini workspace screens
+ mLauncher.getWorkspace().enableBackground();
+ mBackground.setVisibility(GONE);
}
@Override
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 63982ba30..e2bddde82 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -330,7 +330,7 @@ public final class Launcher extends Activity
// share the same customization workspace across all the tabs
mCustomizePagedView = (CustomizePagedView) mInflater.inflate(
- R.layout.customization_drawer, mHomeCustomizationDrawer, false);
+ R.layout.customization_drawer_tab_contents, mHomeCustomizationDrawer, false);
TabContentFactory contentFactory = new TabContentFactory() {
public View createTabContent(String tag) {
return mCustomizePagedView;
@@ -2738,6 +2738,9 @@ public final class Launcher extends Activity
final int duration = toAllApps ?
res.getInteger(R.integer.config_allAppsZoomInTime) :
res.getInteger(R.integer.config_customizeZoomInTime);
+ final int fadeDuration = toAllApps ?
+ res.getInteger(R.integer.config_allAppsFadeInTime) :
+ res.getInteger(R.integer.config_customizeFadeInTime);
final float scale = toAllApps ?
(float) res.getInteger(R.integer.config_allAppsZoomScaleFactor) :
@@ -2768,7 +2771,7 @@ public final class Launcher extends Activity
if (toAllApps) {
toView.setFastAlpha(0f);
- ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
+ ValueAnimator alphaAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(fadeDuration);
alphaAnim.setInterpolator(new DecelerateInterpolator(1.5f));
alphaAnim.addUpdateListener(new AnimatorUpdateListener() {
public void onAnimationUpdate(ValueAnimator animation) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index b1dd08807..263aaad66 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -114,6 +114,7 @@ public class Workspace extends SmoothPagedView
private ValueAnimator mBackgroundFadeOutAnimation;
private Drawable mBackground;
private Drawable mCustomizeTrayBackground;
+ boolean mDrawBackground;
private boolean mDrawCustomizeTrayBackground;
private float mBackgroundAlpha = 0;
private float mOverScrollMaxBackgroundAlpha = 0.0f;
@@ -125,6 +126,7 @@ public class Workspace extends SmoothPagedView
private float[] mCustomizationDrawerTransformedPos = new float[2];
private final WallpaperManager mWallpaperManager;
+ private IBinder mWindowToken;
private int mDefaultPage;
@@ -785,9 +787,8 @@ public class Workspace extends SmoothPagedView
updateNow = keepUpdating = mWallpaperOffset.computeScrollOffset();
}
if (updateNow) {
- IBinder token = getWindowToken();
- if (token != null) {
- mWallpaperManager.setWallpaperOffsets(getWindowToken(),
+ if (mWindowToken != null) {
+ mWallpaperManager.setWallpaperOffsets(mWindowToken,
mWallpaperOffset.getCurrX(), mWallpaperOffset.getCurrY());
}
}
@@ -954,6 +955,13 @@ public class Workspace extends SmoothPagedView
return mChildrenOutlineAlpha;
}
+ void disableBackground() {
+ mDrawBackground = false;
+ }
+ void enableBackground() {
+ mDrawBackground = true;
+ }
+
private void showBackgroundGradientForAllApps() {
showBackgroundGradient();
mDrawCustomizeTrayBackground = false;
@@ -995,8 +1003,10 @@ public class Workspace extends SmoothPagedView
}
public void setBackgroundAlpha(float alpha) {
- mBackgroundAlpha = alpha;
- invalidate();
+ if (alpha != mBackgroundAlpha) {
+ mBackgroundAlpha = alpha;
+ invalidate();
+ }
}
public float getBackgroundAlpha() {
@@ -1090,8 +1100,13 @@ public class Workspace extends SmoothPagedView
protected void onAttachedToWindow() {
super.onAttachedToWindow();
+ mWindowToken = getWindowToken();
computeScroll();
- mDragController.setWindowToken(getWindowToken());
+ mDragController.setWindowToken(mWindowToken);
+ }
+
+ protected void onDetachedFromWindow() {
+ mWindowToken = null;
}
@Override
@@ -1126,7 +1141,7 @@ public class Workspace extends SmoothPagedView
updateWallpaperOffsets();
// Draw the background gradient if necessary
- if (mBackground != null && mBackgroundAlpha > 0.0f) {
+ if (mBackground != null && mBackgroundAlpha > 0.0f && mDrawBackground) {
int alpha = (int) (mBackgroundAlpha * 255);
if (mDrawCustomizeTrayBackground) {
// Find out where to offset the gradient for the customization tray content