summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--res/values-vi/strings.xml2
-rw-r--r--src/com/android/launcher2/AppsCustomizeTabHost.java2
-rw-r--r--src/com/android/launcher2/CachedTextView.java182
-rw-r--r--src/com/android/launcher2/Launcher.java73
-rw-r--r--src/com/android/launcher2/PagedView.java4
-rw-r--r--src/com/android/launcher2/PagedViewCellLayout.java4
-rw-r--r--src/com/android/launcher2/PagedViewIcon.java11
-rw-r--r--src/com/android/launcher2/Workspace.java63
8 files changed, 69 insertions, 272 deletions
diff --git a/res/values-vi/strings.xml b/res/values-vi/strings.xml
index 5ad3af9f4..164f1e16c 100644
--- a/res/values-vi/strings.xml
+++ b/res/values-vi/strings.xml
@@ -32,7 +32,7 @@
<string name="external_drop_widget_error" msgid="127440783198670829">"Không thể thả mục vào Màn hình chính này."</string>
<string name="external_drop_widget_pick_title" msgid="7040647073452295370">"Chọn tiện ích con để tạo"</string>
<string name="rename_folder_label" msgid="5646236631298452787">"Tên thư mục"</string>
- <string name="rename_folder_title" msgid="4544573104191526550">"Đổi tên thư mục"</string>
+ <string name="rename_folder_title" msgid="4544573104191526550">"Đổi tên thư mục"</string>
<string name="rename_action" msgid="6016003384693240896">"OK"</string>
<string name="cancel_action" msgid="3811860427489435048">"Hủy"</string>
<string name="menu_item_add_item" msgid="6233177331075781114">"Thêm vào Màn hình chính"</string>
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 334b3691a..07e662525 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -171,7 +171,7 @@ public class AppsCustomizeTabHost extends TabHost implements LauncherTransitiona
private void reloadCurrentPage() {
if (!LauncherApplication.isScreenLarge()) {
- mAppsCustomizePane.flashScrollingIndicator();
+ mAppsCustomizePane.flashScrollingIndicator(true);
}
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
mAppsCustomizePane.requestFocus();
diff --git a/src/com/android/launcher2/CachedTextView.java b/src/com/android/launcher2/CachedTextView.java
deleted file mode 100644
index f9f68a0d4..000000000
--- a/src/com/android/launcher2/CachedTextView.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * 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 android.content.Context;
-import android.graphics.Bitmap;
-import android.graphics.Bitmap.Config;
-import android.graphics.Canvas;
-import android.graphics.Paint;
-import android.graphics.PorterDuff.Mode;
-import android.graphics.drawable.Drawable;
-import android.text.Layout;
-import android.util.AttributeSet;
-import android.widget.TextView;
-
-/*
- * This class is a bit of a hack, designed to speed up long text labels in Launcher. It caches the
- * text in a TextView to a bitmap and then just draws that Bitmap instead afterward, speeding up
- * rendering. Marquee scrolling is not currently supported.
- *
- */
-public class CachedTextView extends TextView {
- private Bitmap mCache;
- private final Paint mCachePaint = new Paint();
- private final Canvas mCacheCanvas = new Canvas();
-
- private int mPrevAlpha = -1;
- private boolean mIsBuildingCache;
- boolean mIsTextCacheDirty;
- float mTextCacheLeft;
- float mTextCacheTop;
- float mTextCacheScrollX;
- float mRectLeft, mRectTop;
- private float mPaddingH = 0;
- private float mPaddingV = 0;
- private CharSequence mText;
- private boolean mEnabled = true;
-
- public CachedTextView(Context context) {
- super(context);
- }
-
- public CachedTextView(Context context, AttributeSet attrs) {
- super(context, attrs);
- }
-
- public CachedTextView(Context context, AttributeSet attrs, int defStyle) {
- super(context, attrs, defStyle);
- }
-
- protected int getCacheTopPadding() {
- return 0;
- }
- protected int getCacheLeftPadding() {
- return 0;
- }
- protected int getCacheRightPadding() {
- return 0;
- }
- protected int getCacheBottomPadding() {
- return 0;
- }
-
- public void disableCache() {
- mEnabled = false;
- }
-
- public void setText(CharSequence text, BufferType type) {
- super.setText(text, type);
- mIsTextCacheDirty = true;
- }
-
- private void buildAndUpdateCache() {
- final Layout layout = getLayout();
- final int left = getCompoundPaddingLeft();
- final int top = getExtendedPaddingTop();
- final float prevAlpha = getAlpha();
-
- mTextCacheLeft = layout.getLineLeft(0) - getCacheLeftPadding();
- mTextCacheTop = top + layout.getLineTop(0) - mPaddingV - getCacheTopPadding();
-
- mRectLeft = mScrollX + getLeft();
- mRectTop = 0;
- mTextCacheScrollX = mScrollX;
-
- final float textCacheRight =
- Math.min(left + layout.getLineRight(0) + mPaddingH, mScrollX + mRight - mLeft) +
- getCacheRightPadding();
- final float textCacheBottom = top + layout.getLineBottom(0) + mPaddingV +
- getCacheBottomPadding();
- final float xCharWidth = getPaint().measureText("x");
-
- int width = (int) (textCacheRight - mTextCacheLeft + (2 * xCharWidth));
- int height = (int) (textCacheBottom - mTextCacheTop);
-
- if (width > 0 && height > 0) {
- if (mCache != null) {
- if (mCache.getWidth() != width || mCache.getHeight() != height) {
- mCache.recycle();
- mCache = null;
- }
- }
- if (mCache == null) {
- mCache = Bitmap.createBitmap(width, height, Config.ARGB_8888);
- mCacheCanvas.setBitmap(mCache);
- } else {
- mCacheCanvas.drawColor(0, Mode.CLEAR);
- }
-
- mCacheCanvas.save();
- mCacheCanvas.translate(-mTextCacheLeft, -mTextCacheTop);
-
- mIsBuildingCache = true;
- setAlpha(1.0f);
- draw(mCacheCanvas);
- setAlpha(prevAlpha);
- mIsBuildingCache = false;
- mCacheCanvas.restore();
- mCacheCanvas.setBitmap(null);
-
- // A hack-- we set the text to be one space (we don't make it empty just to avoid any
- // potential issues with text measurement, like line height, etc.) so that the text view
- // doesn't draw it anymore, since it's been cached.
- mText = getText();
- setText(" ");
- }
- }
-
- public CharSequence getText() {
- return (mText == null) ? super.getText() : mText;
- }
-
- public void draw(Canvas canvas) {
- if (mEnabled && mIsTextCacheDirty && !mIsBuildingCache) {
- buildAndUpdateCache();
- mIsTextCacheDirty = false;
- }
- if (mCache != null && !mIsBuildingCache) {
- canvas.drawBitmap(mCache, mTextCacheLeft - mTextCacheScrollX + mScrollX,
- mTextCacheTop, mCachePaint);
- }
- super.draw(canvas);
- }
-
- protected boolean isBuildingCache() {
- return mIsBuildingCache;
- }
-
- @Override
- protected boolean onSetAlpha(int alpha) {
- if (mPrevAlpha != alpha) {
- mPrevAlpha = alpha;
- mCachePaint.setAlpha(alpha);
-
- // We manually update the drawables alpha since the default TextView implementation may
- // not do this if there is a background set (which we may due to the focus bg)
- final Drawable[] dr = getCompoundDrawables();
- for (int i = 0; i < dr.length; ++i) {
- if (dr[i] != null) {
- dr[i].mutate().setAlpha(alpha);
- }
- }
-
- super.onSetAlpha(alpha);
- }
- return true;
- }
-}
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 7ee03fc3b..43510c226 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -78,6 +78,7 @@ import android.view.Surface;
import android.view.View;
import android.view.View.OnLongClickListener;
import android.view.ViewGroup;
+import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.view.accessibility.AccessibilityEvent;
import android.view.animation.AccelerateDecelerateInterpolator;
@@ -161,6 +162,7 @@ public final class Launcher extends Activity
private enum State { WORKSPACE, APPS_CUSTOMIZE, APPS_CUSTOMIZE_SPRING_LOADED };
private State mState = State.WORKSPACE;
private AnimatorSet mStateAnimation;
+ private AnimatorSet mDividerAnimator;
static final int APPWIDGET_HOST_ID = 1024;
private static final int EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT = 300;
@@ -177,8 +179,11 @@ public final class Launcher extends Activity
private LayoutInflater mInflater;
- private DragController mDragController;
private Workspace mWorkspace;
+ private View mQsbDivider;
+ private View mDockDivider;
+ private DragLayer mDragLayer;
+ private DragController mDragController;
private AppWidgetManager mAppWidgetManager;
private LauncherAppWidgetHost mAppWidgetHost;
@@ -241,7 +246,6 @@ public final class Launcher extends Activity
static final ArrayList<String> sDumpLogs = new ArrayList<String>();
- private DragLayer mDragLayer;
private BubbleTextView mWaitingForResume;
@@ -560,7 +564,24 @@ public final class Launcher extends Activity
// market intent, so refresh the icon
updateAppMarketIcon();
if (!mWorkspaceLoading) {
- mWorkspace.post(mBuildLayersRunnable);
+ final ViewTreeObserver observer = mWorkspace.getViewTreeObserver();
+ final Workspace workspace = mWorkspace;
+ // We want to let Launcher draw itself at least once before we force it to build
+ // layers on all the workspace pages, so that transitioning to Launcher from other
+ // apps is nice and speedy. Usually the first call to preDraw doesn't correspond to
+ // a true draw so we wait until the second preDraw call to be safe
+ observer.addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
+ boolean mFirstTime = true;
+ public boolean onPreDraw() {
+ if (mFirstTime) {
+ mFirstTime = false;
+ } else {
+ workspace.post(mBuildLayersRunnable);
+ observer.removeOnPreDrawListener(this);
+ }
+ return true;
+ }
+ });
}
clearTypedText();
}
@@ -726,6 +747,8 @@ public final class Launcher extends Activity
mDragLayer = (DragLayer) findViewById(R.id.drag_layer);
mWorkspace = (Workspace) mDragLayer.findViewById(R.id.workspace);
+ mQsbDivider = (ImageView) findViewById(R.id.qsb_divider);
+ mDockDivider = (ImageView) findViewById(R.id.dock_divider);
// Setup the drag layer
mDragLayer.setup(this, dragController);
@@ -2252,7 +2275,7 @@ public final class Launcher extends Activity
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
- mWorkspace.hideDockDivider(true);
+ hideDockDivider();
}
if (!animationCancelled) {
updateWallpaperVisibility(false);
@@ -2294,7 +2317,7 @@ public final class Launcher extends Activity
if (!springLoaded && !LauncherApplication.isScreenLarge()) {
// Hide the workspace scrollbar
mWorkspace.hideScrollingIndicator(true);
- mWorkspace.hideDockDivider(true);
+ hideDockDivider();
}
}
updateWallpaperVisibility(false);
@@ -2306,7 +2329,7 @@ public final class Launcher extends Activity
* This is the opposite of showAppsCustomizeHelper.
* @param animated If true, the transition will be animated.
*/
- private void hideAppsCustomizeHelper(boolean animated) {
+ private void hideAppsCustomizeHelper(boolean animated, final boolean springLoaded) {
if (mStateAnimation != null) {
mStateAnimation.cancel();
mStateAnimation = null;
@@ -2370,6 +2393,7 @@ public final class Launcher extends Activity
((LauncherTransitionable) fromView).onLauncherTransitionStart(instance, null, true);
((LauncherTransitionable) fromView).onLauncherTransitionEnd(instance, null, true);
}
+ mWorkspace.hideScrollingIndicator(false);
}
}
@@ -2380,10 +2404,12 @@ public final class Launcher extends Activity
mWorkspace.changeState(Workspace.State.NORMAL, animated, stagger);
if (mState != State.WORKSPACE) {
mWorkspace.setVisibility(View.VISIBLE);
- hideAppsCustomizeHelper(animated);
+ hideAppsCustomizeHelper(animated, false);
// Show the search bar and hotseat
mSearchDropTargetBar.showSearchBar(animated);
+ // We only need to animate in the dock divider if we're going from spring loaded mode
+ showDockDivider(animated && mState == State.APPS_CUSTOMIZE_SPRING_LOADED);
// Set focus to the AppsCustomize button
if (mAllAppsButton != null) {
@@ -2391,8 +2417,7 @@ public final class Launcher extends Activity
}
}
- mWorkspace.showDockDivider(!animated);
- mWorkspace.flashScrollingIndicator();
+ mWorkspace.flashScrollingIndicator(animated);
// Change the state *after* we've called all the transition code
mState = State.WORKSPACE;
@@ -2429,7 +2454,8 @@ public final class Launcher extends Activity
void enterSpringLoadedDragMode() {
if (mState == State.APPS_CUSTOMIZE) {
mWorkspace.changeState(Workspace.State.SPRING_LOADED);
- hideAppsCustomizeHelper(true);
+ hideAppsCustomizeHelper(true, true);
+ hideDockDivider();
mState = State.APPS_CUSTOMIZE_SPRING_LOADED;
}
}
@@ -2466,6 +2492,33 @@ public final class Launcher extends Activity
// Otherwise, we are not in spring loaded mode, so don't do anything.
}
+ void hideDockDivider() {
+ if (mQsbDivider != null && mDockDivider != null) {
+ mQsbDivider.setVisibility(View.INVISIBLE);
+ mDockDivider.setVisibility(View.INVISIBLE);
+ }
+ }
+
+ void showDockDivider(boolean animated) {
+ if (mQsbDivider != null && mDockDivider != null) {
+ mQsbDivider.setVisibility(View.VISIBLE);
+ mDockDivider.setVisibility(View.VISIBLE);
+ if (mDividerAnimator != null) {
+ mDividerAnimator.cancel();
+ mQsbDivider.setAlpha(1f);
+ mDockDivider.setAlpha(1f);
+ mDividerAnimator = null;
+ }
+ if (animated) {
+ mDividerAnimator = new AnimatorSet();
+ mDividerAnimator.playTogether(ObjectAnimator.ofFloat(mQsbDivider, "alpha", 1f),
+ ObjectAnimator.ofFloat(mDockDivider, "alpha", 1f));
+ mDividerAnimator.setDuration(mSearchDropTargetBar.getTransitionInDuration());
+ mDividerAnimator.start();
+ }
+ }
+ }
+
void lockAllApps() {
// TODO
}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index 935d26df9..2f66537ac 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -1766,9 +1766,9 @@ public abstract class PagedView extends ViewGroup {
hideScrollingIndicator(false);
}
};
- protected void flashScrollingIndicator() {
+ protected void flashScrollingIndicator(boolean animated) {
removeCallbacks(hideScrollingIndicatorRunnable);
- showScrollingIndicator(false);
+ showScrollingIndicator(!animated);
postDelayed(hideScrollingIndicatorRunnable, sScrollIndicatorFlashDuration);
}
diff --git a/src/com/android/launcher2/PagedViewCellLayout.java b/src/com/android/launcher2/PagedViewCellLayout.java
index ef3981346..c29e50d6f 100644
--- a/src/com/android/launcher2/PagedViewCellLayout.java
+++ b/src/com/android/launcher2/PagedViewCellLayout.java
@@ -131,10 +131,6 @@ public class PagedViewCellLayout extends ViewGroup implements Page {
child.setId(childId);
mChildren.addView(child, index, lp);
- if (child instanceof PagedViewIcon) {
- PagedViewIcon pagedViewIcon = (PagedViewIcon) child;
- pagedViewIcon.disableCache();
- }
return true;
}
return false;
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index b03d867cd..af10f189c 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -17,21 +17,14 @@
package com.android.launcher2;
import android.animation.ObjectAnimator;
-import android.content.ComponentName;
import android.content.Context;
-import android.content.pm.PackageManager;
-import android.content.pm.ResolveInfo;
import android.content.res.Resources;
-import android.content.res.TypedArray;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
-import android.os.Handler;
-import android.os.HandlerThread;
-import android.os.Message;
import android.util.AttributeSet;
-import android.view.KeyEvent;
import android.widget.Checkable;
+import android.widget.TextView;
import com.android.launcher.R;
@@ -40,7 +33,7 @@ import com.android.launcher.R;
* An icon on a PagedView, specifically for items in the launcher's paged view (with compound
* drawables on the top).
*/
-public class PagedViewIcon extends CachedTextView implements Checkable {
+public class PagedViewIcon extends TextView implements Checkable {
private static final String TAG = "PagedViewIcon";
// holographic outline
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 8ac5248b1..8c5734970 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -107,7 +107,6 @@ public class Workspace extends SmoothPagedView
private float mBackgroundAlpha = 0;
private float mOverScrollMaxBackgroundAlpha = 0.0f;
private int mOverScrollPageIndex = -1;
- private AnimatorSet mDividerAnimator;
private float mWallpaperScrollRatio = 1.0f;
@@ -3493,30 +3492,6 @@ public class Workspace extends SmoothPagedView
mLauncher.getDragLayer().getLocationInDragLayer(this, loc);
}
- void showDockDivider(boolean immediately) {
- final ViewGroup parent = (ViewGroup) getParent();
- final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider));
- final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider));
- if (qsbDivider != null && dockDivider != null) {
- qsbDivider.setVisibility(View.VISIBLE);
- dockDivider.setVisibility(View.VISIBLE);
- if (mDividerAnimator != null) {
- mDividerAnimator.cancel();
- mDividerAnimator = null;
- }
- if (immediately) {
- qsbDivider.setAlpha(1f);
- dockDivider.setAlpha(1f);
- } else {
- mDividerAnimator = new AnimatorSet();
- mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 1f),
- ObjectAnimator.ofFloat(dockDivider, "alpha", 1f));
- mDividerAnimator.setDuration(sScrollIndicatorFadeInDuration);
- mDividerAnimator.start();
- }
- }
- }
-
void setFadeForOverScroll(float fade) {
if (!isScrollingIndicatorEnabled()) return;
@@ -3530,42 +3505,4 @@ public class Workspace extends SmoothPagedView
dockDivider.setAlpha(reducedFade);
scrollIndicator.setAlpha(1 - fade);
}
-
- void hideDockDivider(boolean immediately) {
- final ViewGroup parent = (ViewGroup) getParent();
- final View qsbDivider = (ImageView) (parent.findViewById(R.id.qsb_divider));
- final View dockDivider = (ImageView) (parent.findViewById(R.id.dock_divider));
- if (qsbDivider != null && dockDivider != null) {
- if (mDividerAnimator != null) {
- mDividerAnimator.cancel();
- mDividerAnimator = null;
- }
- if (immediately) {
- qsbDivider.setVisibility(View.GONE);
- dockDivider.setVisibility(View.GONE);
- qsbDivider.setAlpha(0f);
- dockDivider.setAlpha(0f);
- } else {
- mDividerAnimator = new AnimatorSet();
- mDividerAnimator.playTogether(ObjectAnimator.ofFloat(qsbDivider, "alpha", 0f),
- ObjectAnimator.ofFloat(dockDivider, "alpha", 0f));
- mDividerAnimator.addListener(new AnimatorListenerAdapter() {
- private boolean cancelled = false;
- @Override
- public void onAnimationCancel(android.animation.Animator animation) {
- cancelled = true;
- }
- @Override
- public void onAnimationEnd(android.animation.Animator animation) {
- if (!cancelled) {
- qsbDivider.setVisibility(View.GONE);
- dockDivider.setVisibility(View.GONE);
- }
- }
- });
- mDividerAnimator.setDuration(sScrollIndicatorFadeOutDuration);
- mDividerAnimator.start();
- }
- }
- }
}