Merge "Adding workaround to make voice button target area larger (Bug 5653332)"
diff --git a/src/com/android/launcher2/AppsCustomizePagedView.java b/src/com/android/launcher2/AppsCustomizePagedView.java
index 7f0edde..691228d 100644
--- a/src/com/android/launcher2/AppsCustomizePagedView.java
+++ b/src/com/android/launcher2/AppsCustomizePagedView.java
@@ -75,8 +75,7 @@
*/
class AsyncTaskPageData {
enum Type {
- LoadWidgetPreviewData,
- LoadHolographicIconsData
+ LoadWidgetPreviewData
}
AsyncTaskPageData(int p, ArrayList<Object> l, ArrayList<Bitmap> si, AsyncTaskCallback bgR,
@@ -226,7 +225,6 @@
// Previews & outlines
ArrayList<AppsCustomizeAsyncTask> mRunningTasks;
- private HolographicOutlineHelper mHolographicOutlineHelper;
private static final int sPageSleepDelay = 200;
public AppsCustomizePagedView(Context context, AttributeSet attrs) {
@@ -236,7 +234,6 @@
mApps = new ArrayList<ApplicationInfo>();
mWidgets = new ArrayList<Object>();
mIconCache = ((LauncherApplication) context.getApplicationContext()).getIconCache();
- mHolographicOutlineHelper = new HolographicOutlineHelper();
mCanvas = new Canvas();
mRunningTasks = new ArrayList<AppsCustomizeAsyncTask>();
@@ -495,12 +492,7 @@
if (v instanceof PagedViewIcon) {
// Animate some feedback to the click
final ApplicationInfo appInfo = (ApplicationInfo) v.getTag();
- animateClickFeedback(v, new Runnable() {
- @Override
- public void run() {
- mLauncher.startActivitySafely(appInfo.intent, appInfo);
- }
- });
+ mLauncher.startActivitySafely(appInfo.intent, appInfo);
} else if (v instanceof PagedViewWidget) {
// Let the user know that they have to long press to add a widget
Toast.makeText(getContext(), R.string.long_press_widget_to_add,
@@ -759,7 +751,7 @@
ApplicationInfo info = mApps.get(i);
PagedViewIcon icon = (PagedViewIcon) mLayoutInflater.inflate(
R.layout.apps_customize_application, layout, false);
- icon.applyFromApplicationInfo(info, true, mHolographicOutlineHelper);
+ icon.applyFromApplicationInfo(info, true);
icon.setOnClickListener(this);
icon.setOnLongClickListener(this);
icon.setOnTouchListener(this);
@@ -775,12 +767,6 @@
}
layout.createHardwareLayers();
-
- /* TEMPORARILY DISABLE HOLOGRAPHIC ICONS
- if (mFadeInAdjacentScreens) {
- prepareGenerateHoloOutlinesTask(page, items, images);
- }
- */
}
/**
@@ -883,79 +869,6 @@
t.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, pageData);
mRunningTasks.add(t);
}
- /**
- * Creates and executes a new AsyncTask to load the outlines for a page of content.
- */
- private void prepareGenerateHoloOutlinesTask(int page, ArrayList<Object> items,
- ArrayList<Bitmap> images) {
- // Prune old tasks for this page
- Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
- while (iter.hasNext()) {
- AppsCustomizeAsyncTask task = (AppsCustomizeAsyncTask) iter.next();
- int taskPage = task.page;
- if ((taskPage == page) &&
- (task.dataType == AsyncTaskPageData.Type.LoadHolographicIconsData)) {
- task.cancel(false);
- iter.remove();
- }
- }
-
- AsyncTaskPageData pageData = new AsyncTaskPageData(page, items, images,
- new AsyncTaskCallback() {
- @Override
- public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) {
- try {
- // Ensure that this task starts running at the correct priority
- task.syncThreadPriority();
-
- ArrayList<Bitmap> images = data.generatedImages;
- ArrayList<Bitmap> srcImages = data.sourceImages;
- int count = srcImages.size();
- Canvas c = new Canvas();
- for (int i = 0; i < count && !task.isCancelled(); ++i) {
- // Before work on each item, ensure that this task is running at the correct
- // priority
- task.syncThreadPriority();
-
- Bitmap b = srcImages.get(i);
- Bitmap outline = Bitmap.createBitmap(b.getWidth(), b.getHeight(),
- Bitmap.Config.ARGB_8888);
-
- c.setBitmap(outline);
- c.save();
- c.drawBitmap(b, 0, 0, null);
- c.restore();
- c.setBitmap(null);
-
- images.add(outline);
- }
- } finally {
- if (task.isCancelled()) {
- data.cleanup(true);
- }
- }
- }
- },
- new AsyncTaskCallback() {
- @Override
- public void run(AppsCustomizeAsyncTask task, AsyncTaskPageData data) {
- try {
- mRunningTasks.remove(task);
- if (task.isCancelled()) return;
- onHolographicPageItemsLoaded(data);
- } finally {
- data.cleanup(task.isCancelled());
- }
- }
- });
-
- // Ensure that the outline task always runs in the background, serially
- AppsCustomizeAsyncTask t =
- new AppsCustomizeAsyncTask(page, AsyncTaskPageData.Type.LoadHolographicIconsData);
- t.setThreadPriority(Process.THREAD_PRIORITY_BACKGROUND);
- t.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR, pageData);
- mRunningTasks.add(t);
- }
/*
* Widgets PagedView implementation
@@ -1120,8 +1033,7 @@
AppWidgetProviderInfo info = (AppWidgetProviderInfo) rawInfo;
createItemInfo = new PendingAddWidgetInfo(info, null, null);
int[] cellSpans = mLauncher.getSpanForWidget(info, null);
- widget.applyFromAppWidgetProviderInfo(info, -1, cellSpans,
- mHolographicOutlineHelper);
+ widget.applyFromAppWidgetProviderInfo(info, -1, cellSpans);
widget.setTag(createItemInfo);
} else if (rawInfo instanceof ResolveInfo) {
// Fill in the shortcuts information
@@ -1130,7 +1042,7 @@
createItemInfo.itemType = LauncherSettings.Favorites.ITEM_TYPE_SHORTCUT;
createItemInfo.componentName = new ComponentName(info.activityInfo.packageName,
info.activityInfo.name);
- widget.applyFromResolveInfo(mPackageManager, info, mHolographicOutlineHelper);
+ widget.applyFromResolveInfo(mPackageManager, info);
widget.setTag(createItemInfo);
}
widget.setOnClickListener(this);
@@ -1231,12 +1143,6 @@
layout.createHardwareLayer();
invalidate();
- /* TEMPORARILY DISABLE HOLOGRAPHIC ICONS
- if (mFadeInAdjacentScreens) {
- prepareGenerateHoloOutlinesTask(data.page, data.items, data.generatedImages);
- }
- */
-
// Update all thread priorities
Iterator<AppsCustomizeAsyncTask> iter = mRunningTasks.iterator();
while (iter.hasNext()) {
@@ -1245,29 +1151,6 @@
task.setThreadPriority(getThreadPriorityForPage(pageIndex));
}
}
- private void onHolographicPageItemsLoaded(AsyncTaskPageData data) {
- // Invalidate early to short-circuit children invalidates
- invalidate();
-
- int page = data.page;
- ViewGroup layout = (ViewGroup) getPageAt(page);
- if (layout instanceof PagedViewCellLayout) {
- PagedViewCellLayout cl = (PagedViewCellLayout) layout;
- int count = cl.getPageChildCount();
- if (count != data.generatedImages.size()) return;
- for (int i = 0; i < count; ++i) {
- PagedViewIcon icon = (PagedViewIcon) cl.getChildOnPageAt(i);
- icon.setHolographicOutline(data.generatedImages.get(i));
- }
- } else {
- int count = layout.getChildCount();
- if (count != data.generatedImages.size()) return;
- for (int i = 0; i < count; ++i) {
- View v = layout.getChildAt(i);
- ((PagedViewWidget) v).setHolographicOutline(data.generatedImages.get(i));
- }
- }
- }
@Override
public void syncPages() {
@@ -1490,6 +1373,9 @@
@Override
public void reset() {
+ // If we have reset, then we should not continue to restore the previous state
+ mSaveInstanceStateItemIndex = -1;
+
AppsCustomizeTabHost tabHost = getTabHost();
String tag = tabHost.getCurrentTabTag();
if (tag != null) {
@@ -1497,6 +1383,7 @@
tabHost.setCurrentTabFromContent(ContentType.Applications);
}
}
+
if (mCurrentPage != 0) {
invalidatePageData(0);
}
diff --git a/src/com/android/launcher2/HolographicPagedViewIcon.java b/src/com/android/launcher2/HolographicPagedViewIcon.java
deleted file mode 100644
index dda233e..0000000
--- a/src/com/android/launcher2/HolographicPagedViewIcon.java
+++ /dev/null
@@ -1,55 +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.Canvas;
-import android.graphics.Paint;
-import android.widget.TextView;
-
-
-
-/**
- * An icon on a PagedView, specifically for items in the launcher's paged view (with compound
- * drawables on the top).
- */
-public class HolographicPagedViewIcon extends TextView {
- PagedViewIcon mOriginalIcon;
- Paint mPaint;
-
- public HolographicPagedViewIcon(Context context, PagedViewIcon original) {
- super(context);
- mOriginalIcon = original;
- mPaint = new Paint();
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- Bitmap overlay = mOriginalIcon.getHolographicOutline();
- if (overlay != null) {
- final int offset = getScrollX();
- final int compoundPaddingLeft = getCompoundPaddingLeft();
- final int compoundPaddingRight = getCompoundPaddingRight();
- int hspace = getWidth() - compoundPaddingRight - compoundPaddingLeft;
- canvas.drawBitmap(overlay,
- offset + compoundPaddingLeft + (hspace - overlay.getWidth()) / 2,
- mOriginalIcon.getPaddingTop(),
- mPaint);
- }
- }
-}
diff --git a/src/com/android/launcher2/InstallShortcutReceiver.java b/src/com/android/launcher2/InstallShortcutReceiver.java
index ed8f299..3cb37a7 100644
--- a/src/com/android/launcher2/InstallShortcutReceiver.java
+++ b/src/com/android/launcher2/InstallShortcutReceiver.java
@@ -16,8 +16,6 @@
package com.android.launcher2;
-import java.util.ArrayList;
-
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -25,6 +23,8 @@
import com.android.launcher.R;
+import java.util.ArrayList;
+
public class InstallShortcutReceiver extends BroadcastReceiver {
public static final String ACTION_INSTALL_SHORTCUT =
"com.android.launcher.action.INSTALL_SHORTCUT";
@@ -41,16 +41,21 @@
}
int screen = Launcher.getScreen();
-
- if (!installShortcut(context, data, screen)) {
+ String[] errorMsgs = {""};
+ if (!installShortcut(context, data, screen, errorMsgs)) {
// The target screen is full, let's try the other screens
for (int i = 0; i < Launcher.SCREEN_COUNT; i++) {
- if (i != screen && installShortcut(context, data, i)) break;
+ if (i != screen && installShortcut(context, data, i, errorMsgs)) break;
}
}
+
+ if (!errorMsgs[0].isEmpty()) {
+ Toast.makeText(context, errorMsgs[0],
+ Toast.LENGTH_SHORT).show();
+ }
}
- private boolean installShortcut(Context context, Intent data, int screen) {
+ private boolean installShortcut(Context context, Intent data, int screen, String[] errorMsgs) {
String name = data.getStringExtra(Intent.EXTRA_SHORTCUT_NAME);
if (findEmptyCell(context, mCoordinates, screen)) {
@@ -69,21 +74,18 @@
LauncherSettings.Favorites.CONTAINER_DESKTOP, screen, mCoordinates[0],
mCoordinates[1], true);
if (info != null) {
- Toast.makeText(context, context.getString(R.string.shortcut_installed, name),
- Toast.LENGTH_SHORT).show();
+ errorMsgs[0] = context.getString(R.string.shortcut_installed, name);
} else {
return false;
}
} else {
- Toast.makeText(context, context.getString(R.string.shortcut_duplicate, name),
- Toast.LENGTH_SHORT).show();
+ errorMsgs[0] = context.getString(R.string.shortcut_duplicate, name);
}
return true;
}
} else {
- Toast.makeText(context, context.getString(R.string.out_of_space),
- Toast.LENGTH_SHORT).show();
+ errorMsgs[0] = context.getString(R.string.out_of_space);
}
return false;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 5abfa28..33ca887 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -2226,14 +2226,13 @@
mWorkspace.getChangeStateAnimation(Workspace.State.SMALL, animated);
if (animated) {
- final ValueAnimator scaleAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
- scaleAnim.setInterpolator(new Workspace.ZoomOutInterpolator());
- scaleAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
- public void onAnimationUpdate(float a, float b) {
- toView.setScaleX(a * scale + b * 1f);
- toView.setScaleY(a * scale + b * 1f);
- }
- });
+ toView.setScaleX(scale);
+ toView.setScaleY(scale);
+ final LauncherViewPropertyAnimator scaleAnim = new LauncherViewPropertyAnimator(toView);
+ scaleAnim.
+ scaleX(1f).scaleY(1f).
+ setDuration(duration).
+ setInterpolator(new Workspace.ZoomOutInterpolator());
toView.setVisibility(View.VISIBLE);
toView.setAlpha(0f);
@@ -2248,8 +2247,8 @@
// toView should appear right at the end of the workspace shrink
// animation
mStateAnimation = new AnimatorSet();
- mStateAnimation.play(alphaAnim).after(startDelay);
mStateAnimation.play(scaleAnim).after(startDelay);
+ mStateAnimation.play(alphaAnim).after(startDelay);
mStateAnimation.addListener(new AnimatorListenerAdapter() {
boolean animationCancelled = false;
@@ -2313,13 +2312,18 @@
}
if (delayAnim) {
+ final AnimatorSet stateAnimation = mStateAnimation;
final OnGlobalLayoutListener delayedStart = new OnGlobalLayoutListener() {
public void onGlobalLayout() {
mWorkspace.post(new Runnable() {
public void run() {
- // Need to update pivots for zoom if layout changed
- setPivotsForZoom(toView, scale);
- mStateAnimation.start();
+ // Check that mStateAnimation hasn't changed while
+ // we waited for a layout pass
+ if (mStateAnimation == stateAnimation) {
+ // Need to update pivots for zoom if layout changed
+ setPivotsForZoom(toView, scale);
+ mStateAnimation.start();
+ }
}
});
observer.removeGlobalOnLayoutListener(this);
@@ -2579,8 +2583,10 @@
void showHotseat(boolean animated) {
if (!LauncherApplication.isScreenLarge()) {
if (animated) {
- int duration = mSearchDropTargetBar.getTransitionInDuration();
- mHotseat.animate().alpha(1f).setDuration(duration);
+ if (mHotseat.getAlpha() != 1f) {
+ int duration = mSearchDropTargetBar.getTransitionInDuration();
+ mHotseat.animate().alpha(1f).setDuration(duration);
+ }
} else {
mHotseat.setAlpha(1f);
}
@@ -2593,8 +2599,10 @@
void hideHotseat(boolean animated) {
if (!LauncherApplication.isScreenLarge()) {
if (animated) {
- int duration = mSearchDropTargetBar.getTransitionOutDuration();
- mHotseat.animate().alpha(0f).setDuration(duration);
+ if (mHotseat.getAlpha() != 0f) {
+ int duration = mSearchDropTargetBar.getTransitionOutDuration();
+ mHotseat.animate().alpha(0f).setDuration(duration);
+ }
} else {
mHotseat.setAlpha(0f);
}
diff --git a/src/com/android/launcher2/LauncherViewPropertyAnimator.java b/src/com/android/launcher2/LauncherViewPropertyAnimator.java
new file mode 100644
index 0000000..b31179d
--- /dev/null
+++ b/src/com/android/launcher2/LauncherViewPropertyAnimator.java
@@ -0,0 +1,257 @@
+/*
+ * Copyright (C) 2012 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.animation.Animator;
+import android.animation.Animator.AnimatorListener;
+import android.animation.TimeInterpolator;
+import android.view.ViewPropertyAnimator;
+import android.view.View;
+
+import java.util.ArrayList;
+import java.util.EnumSet;
+
+public class LauncherViewPropertyAnimator extends Animator implements AnimatorListener {
+ enum Properties {
+ TRANSLATION_X,
+ TRANSLATION_Y,
+ SCALE_X,
+ SCALE_Y,
+ ROTATION_Y,
+ ALPHA,
+ START_DELAY,
+ DURATION,
+ INTERPOLATOR
+ }
+ EnumSet<Properties> mPropertiesToSet = EnumSet.noneOf(Properties.class);
+ ViewPropertyAnimator mViewPropertyAnimator;
+ View mTarget;
+
+ float mTranslationX;
+ float mTranslationY;
+ float mScaleX;
+ float mScaleY;
+ float mRotationY;
+ float mAlpha;
+ long mStartDelay;
+ long mDuration;
+ TimeInterpolator mInterpolator;
+ Animator.AnimatorListener mListener;
+ boolean mRunning = false;
+
+ public LauncherViewPropertyAnimator(View target) {
+ mTarget = target;
+ }
+
+ @Override
+ public void addListener(Animator.AnimatorListener listener) {
+ if (mListener != null) {
+ throw new RuntimeException("Only one listener supported");
+ }
+ mListener = listener;
+ }
+
+ @Override
+ public void cancel() {
+ if (mViewPropertyAnimator != null) {
+ mViewPropertyAnimator.cancel();
+ }
+ }
+
+ @Override
+ public Animator clone() {
+ throw new RuntimeException("Not implemented");
+ }
+
+ @Override
+ public void end() {
+ throw new RuntimeException("Not implemented");
+ }
+
+ @Override
+ public long getDuration() {
+ return mDuration;
+ }
+
+ @Override
+ public ArrayList<Animator.AnimatorListener> getListeners() {
+ return null;
+ }
+
+ @Override
+ public long getStartDelay() {
+ return mStartDelay;
+ }
+
+ @Override
+ public void onAnimationCancel(Animator animation) {
+ if (mListener != null) {
+ mListener.onAnimationCancel(this);
+ }
+ mRunning = false;
+ }
+
+ @Override
+ public void onAnimationEnd(Animator animation) {
+ if (mListener != null) {
+ mListener.onAnimationEnd(this);
+ }
+ mRunning = false;
+ }
+
+ @Override
+ public void onAnimationRepeat(Animator animation) {
+ if (mListener != null) {
+ mListener.onAnimationRepeat(this);
+ }
+ }
+
+ @Override
+ public void onAnimationStart(Animator animation) {
+ if (mListener != null) {
+ mListener.onAnimationStart(this);
+ }
+ mRunning = true;
+ }
+
+ @Override
+ public boolean isRunning() {
+ return mRunning;
+ }
+
+ @Override
+ public boolean isStarted() {
+ return mViewPropertyAnimator != null;
+ }
+
+ @Override
+ public void removeAllListeners() {
+ mListener = null;
+ }
+
+ @Override
+ public void removeListener(Animator.AnimatorListener listener) {
+ if (mListener == listener) {
+ mListener = null;
+ } else {
+ throw new RuntimeException("Removing listener that wasn't set");
+ }
+ }
+
+ @Override
+ public Animator setDuration(long duration) {
+ mPropertiesToSet.add(Properties.DURATION);
+ mDuration = duration;
+ return this;
+ }
+
+ @Override
+ public void setInterpolator(TimeInterpolator value) {
+ mPropertiesToSet.add(Properties.INTERPOLATOR);
+ mInterpolator = value;
+ }
+
+ @Override
+ public void setStartDelay(long startDelay) {
+ mPropertiesToSet.add(Properties.START_DELAY);
+ mStartDelay = startDelay;
+ }
+
+ @Override
+ public void setTarget(Object target) {
+ throw new RuntimeException("Not implemented");
+ }
+
+ @Override
+ public void setupEndValues() {
+
+ }
+
+ @Override
+ public void setupStartValues() {
+ }
+
+ @Override
+ public void start() {
+ mViewPropertyAnimator = mTarget.animate();
+ if (mPropertiesToSet.contains(Properties.TRANSLATION_X)) {
+ mViewPropertyAnimator.translationX(mTranslationX);
+ }
+ if (mPropertiesToSet.contains(Properties.TRANSLATION_Y)) {
+ mViewPropertyAnimator.translationY(mTranslationY);
+ }
+ if (mPropertiesToSet.contains(Properties.SCALE_X)) {
+ mViewPropertyAnimator.scaleX(mScaleX);
+ }
+ if (mPropertiesToSet.contains(Properties.ROTATION_Y)) {
+ mViewPropertyAnimator.rotationY(mRotationY);
+ }
+ if (mPropertiesToSet.contains(Properties.SCALE_Y)) {
+ mViewPropertyAnimator.scaleY(mScaleY);
+ }
+ if (mPropertiesToSet.contains(Properties.ALPHA)) {
+ mViewPropertyAnimator.alpha(mAlpha);
+ }
+ if (mPropertiesToSet.contains(Properties.START_DELAY)) {
+ mViewPropertyAnimator.setStartDelay(mStartDelay);
+ }
+ if (mPropertiesToSet.contains(Properties.DURATION)) {
+ mViewPropertyAnimator.setDuration(mDuration);
+ }
+ if (mPropertiesToSet.contains(Properties.INTERPOLATOR)) {
+ mViewPropertyAnimator.setInterpolator(mInterpolator);
+ }
+ mViewPropertyAnimator.setListener(this);
+ mViewPropertyAnimator.start();
+ }
+
+ public LauncherViewPropertyAnimator translationX(float value) {
+ mPropertiesToSet.add(Properties.TRANSLATION_X);
+ mTranslationX = value;
+ return this;
+ }
+
+ public LauncherViewPropertyAnimator translationY(float value) {
+ mPropertiesToSet.add(Properties.TRANSLATION_Y);
+ mTranslationY = value;
+ return this;
+ }
+
+ public LauncherViewPropertyAnimator scaleX(float value) {
+ mPropertiesToSet.add(Properties.SCALE_X);
+ mScaleX = value;
+ return this;
+ }
+
+ public LauncherViewPropertyAnimator scaleY(float value) {
+ mPropertiesToSet.add(Properties.SCALE_Y);
+ mScaleY = value;
+ return this;
+ }
+
+ public LauncherViewPropertyAnimator rotationY(float value) {
+ mPropertiesToSet.add(Properties.ROTATION_Y);
+ mRotationY = value;
+ return this;
+ }
+
+ public LauncherViewPropertyAnimator alpha(float value) {
+ mPropertiesToSet.add(Properties.ALPHA);
+ mAlpha = value;
+ return this;
+ }
+}
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index ef36042..c72fdcc 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -151,15 +151,6 @@
protected ArrayList<Boolean> mDirtyPageContent;
- // choice modes
- protected static final int CHOICE_MODE_NONE = 0;
- protected static final int CHOICE_MODE_SINGLE = 1;
- // Multiple selection mode is not supported by all Launcher actions atm
- protected static final int CHOICE_MODE_MULTIPLE = 2;
-
- protected int mChoiceMode;
- private ActionMode mActionMode;
-
// If true, syncPages and syncPageItems will be called to refresh pages
protected boolean mContentIsRefreshable = true;
@@ -206,7 +197,6 @@
public PagedView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- mChoiceMode = CHOICE_MODE_NONE;
TypedArray a = context.obtainStyledAttributes(attrs,
R.styleable.PagedView, defStyle, 0);
@@ -1007,19 +997,6 @@
return mTouchState != TOUCH_STATE_REST;
}
- protected void animateClickFeedback(View v, final Runnable r) {
- // animate the view slightly to show click feedback running some logic after it is "pressed"
- ObjectAnimator anim = (ObjectAnimator) AnimatorInflater.
- loadAnimator(mContext, R.anim.paged_view_click_feedback);
- anim.setTarget(v);
- anim.addListener(new AnimatorListenerAdapter() {
- public void onAnimationRepeat(Animator animation) {
- r.run();
- }
- });
- anim.start();
- }
-
protected void determineScrollingStart(MotionEvent ev) {
determineScrollingStart(ev, 1.0f);
}
@@ -1645,72 +1622,6 @@
return Math.min(page + 1, count - 1);
}
- protected void startChoiceMode(int mode, ActionMode.Callback callback) {
- if (isChoiceMode(CHOICE_MODE_NONE)) {
- mChoiceMode = mode;
- mActionMode = startActionMode(callback);
- }
- }
-
- public void endChoiceMode() {
- if (!isChoiceMode(CHOICE_MODE_NONE)) {
- mChoiceMode = CHOICE_MODE_NONE;
- resetCheckedGrandchildren();
- if (mActionMode != null) mActionMode.finish();
- mActionMode = null;
- }
- }
-
- protected boolean isChoiceMode(int mode) {
- return mChoiceMode == mode;
- }
-
- protected ArrayList<Checkable> getCheckedGrandchildren() {
- ArrayList<Checkable> checked = new ArrayList<Checkable>();
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; ++i) {
- Page layout = (Page) getPageAt(i);
- final int grandChildCount = layout.getPageChildCount();
- for (int j = 0; j < grandChildCount; ++j) {
- final View v = layout.getChildOnPageAt(j);
- if (v instanceof Checkable && ((Checkable) v).isChecked()) {
- checked.add((Checkable) v);
- }
- }
- }
- return checked;
- }
-
- /**
- * If in CHOICE_MODE_SINGLE and an item is checked, returns that item.
- * Otherwise, returns null.
- */
- protected Checkable getSingleCheckedGrandchild() {
- if (mChoiceMode != CHOICE_MODE_MULTIPLE) {
- final int childCount = getChildCount();
- for (int i = 0; i < childCount; ++i) {
- Page layout = (Page) getPageAt(i);
- final int grandChildCount = layout.getPageChildCount();
- for (int j = 0; j < grandChildCount; ++j) {
- final View v = layout.getChildOnPageAt(j);
- if (v instanceof Checkable && ((Checkable) v).isChecked()) {
- return (Checkable) v;
- }
- }
- }
- }
- return null;
- }
-
- protected void resetCheckedGrandchildren() {
- // loop through children, and set all of their children to _not_ be checked
- final ArrayList<Checkable> checked = getCheckedGrandchildren();
- for (int i = 0; i < checked.size(); ++i) {
- final Checkable c = checked.get(i);
- c.setChecked(false);
- }
- }
-
/**
* This method is called ONLY to synchronize the number of pages that the paged view has.
* To actually fill the pages with information, implement syncPageItems() below. It is
diff --git a/src/com/android/launcher2/PagedViewIcon.java b/src/com/android/launcher2/PagedViewIcon.java
index af10f18..b0288dc 100644
--- a/src/com/android/launcher2/PagedViewIcon.java
+++ b/src/com/android/launcher2/PagedViewIcon.java
@@ -23,37 +23,19 @@
import android.graphics.Canvas;
import android.graphics.Paint;
import android.util.AttributeSet;
-import android.widget.Checkable;
import android.widget.TextView;
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 TextView implements Checkable {
+public class PagedViewIcon extends TextView {
private static final String TAG = "PagedViewIcon";
- // holographic outline
- private final Paint mPaint = new Paint();
- private Bitmap mCheckedOutline;
- private Bitmap mHolographicOutline;
private Bitmap mIcon;
- private int mAlpha = 255;
- private int mHolographicAlpha;
-
- private boolean mIsChecked;
- private ObjectAnimator mCheckedAlphaAnimator;
- private float mCheckedAlpha = 1.0f;
- private int mCheckedFadeInDuration;
- private int mCheckedFadeOutDuration;
-
- HolographicPagedViewIcon mHolographicOutlineView;
- private HolographicOutlineHelper mHolographicOutlineHelper;
-
public PagedViewIcon(Context context) {
this(context, null);
}
@@ -64,131 +46,25 @@
public PagedViewIcon(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
-
- // Set up fade in/out constants
- final Resources r = context.getResources();
- final int alpha = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeAlpha);
- if (alpha > 0) {
- mCheckedAlpha = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeAlpha) / 256.0f;
- mCheckedFadeInDuration =
- r.getInteger(R.integer.config_dragAppsCustomizeIconFadeInDuration);
- mCheckedFadeOutDuration =
- r.getInteger(R.integer.config_dragAppsCustomizeIconFadeOutDuration);
- }
-
- mHolographicOutlineView = new HolographicPagedViewIcon(context, this);
}
- protected HolographicPagedViewIcon getHolographicOutlineView() {
- return mHolographicOutlineView;
- }
-
- protected Bitmap getHolographicOutline() {
- return mHolographicOutline;
- }
-
- public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp,
- HolographicOutlineHelper holoOutlineHelper) {
- mHolographicOutlineHelper = holoOutlineHelper;
+ public void applyFromApplicationInfo(ApplicationInfo info, boolean scaleUp) {
mIcon = info.iconBitmap;
setCompoundDrawablesWithIntrinsicBounds(null, new FastBitmapDrawable(mIcon), null, null);
setText(info.title);
setTag(info);
}
- public void setHolographicOutline(Bitmap holoOutline) {
- mHolographicOutline = holoOutline;
- getHolographicOutlineView().invalidate();
- }
-
- @Override
- public void setAlpha(float alpha) {
- final float viewAlpha = HolographicOutlineHelper.viewAlphaInterpolator(alpha);
- final float holographicAlpha = HolographicOutlineHelper.highlightAlphaInterpolator(alpha);
- int newViewAlpha = (int) (viewAlpha * 255);
- int newHolographicAlpha = (int) (holographicAlpha * 255);
- if ((mAlpha != newViewAlpha) || (mHolographicAlpha != newHolographicAlpha)) {
- mAlpha = newViewAlpha;
- mHolographicAlpha = newHolographicAlpha;
- super.setAlpha(viewAlpha);
- }
- }
-
- public void invalidateCheckedImage() {
- if (mCheckedOutline != null) {
- mCheckedOutline.recycle();
- mCheckedOutline = null;
- }
- }
-
- @Override
- protected void onDraw(Canvas canvas) {
- if (mAlpha > 0) {
- super.onDraw(canvas);
- }
-
- Bitmap overlay = null;
-
- // draw any blended overlays
- if (mCheckedOutline != null) {
- mPaint.setAlpha(255);
- overlay = mCheckedOutline;
- }
-
- if (overlay != null) {
- final int offset = getScrollX();
- final int compoundPaddingLeft = getCompoundPaddingLeft();
- final int compoundPaddingRight = getCompoundPaddingRight();
- int hspace = getWidth() - compoundPaddingRight - compoundPaddingLeft;
- canvas.drawBitmap(overlay,
- offset + compoundPaddingLeft + (hspace - overlay.getWidth()) / 2,
- mPaddingTop,
- mPaint);
- }
- }
-
- @Override
- public boolean isChecked() {
- return mIsChecked;
- }
-
- void setChecked(boolean checked, boolean animate) {
- if (mIsChecked != checked) {
- mIsChecked = checked;
-
- float alpha;
- int duration;
- if (mIsChecked) {
- alpha = mCheckedAlpha;
- duration = mCheckedFadeInDuration;
- } else {
- alpha = 1.0f;
- duration = mCheckedFadeOutDuration;
+ protected void drawableStateChanged() {
+ if (isPressed()) {
+ if (getAlpha() != 0.5f) {
+ setAlpha(0.5f);
}
-
- // Initialize the animator
- if (mCheckedAlphaAnimator != null) {
- mCheckedAlphaAnimator.cancel();
+ } else {
+ if (getAlpha() != 1f) {
+ setAlpha(1f);
}
- if (animate) {
- mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), alpha);
- mCheckedAlphaAnimator.setDuration(duration);
- mCheckedAlphaAnimator.start();
- } else {
- setAlpha(alpha);
- }
-
- invalidate();
}
- }
-
- @Override
- public void setChecked(boolean checked) {
- setChecked(checked, true);
- }
-
- @Override
- public void toggle() {
- setChecked(!mIsChecked);
+ super.drawableStateChanged();
}
}
diff --git a/src/com/android/launcher2/PagedViewWidget.java b/src/com/android/launcher2/PagedViewWidget.java
index 8fcfa8f..e2b02a3 100644
--- a/src/com/android/launcher2/PagedViewWidget.java
+++ b/src/com/android/launcher2/PagedViewWidget.java
@@ -29,7 +29,6 @@
import android.util.AttributeSet;
import android.view.KeyEvent;
import android.view.MotionEvent;
-import android.widget.Checkable;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
@@ -39,28 +38,17 @@
/**
* The linear layout used strictly for the widget/wallpaper tab of the customization tray
*/
-public class PagedViewWidget extends LinearLayout implements Checkable {
+public class PagedViewWidget extends LinearLayout {
static final String TAG = "PagedViewWidgetLayout";
private static boolean sDeletePreviewsWhenDetachedFromWindow = true;
private final Paint mPaint = new Paint();
- private Bitmap mHolographicOutline;
- private HolographicOutlineHelper mHolographicOutlineHelper;
private ImageView mPreviewImageView;
private final RectF mTmpScaleRect = new RectF();
private String mDimensionsFormatString;
- private int mAlpha = 255;
- private int mHolographicAlpha;
-
- private boolean mIsChecked;
- private ObjectAnimator mCheckedAlphaAnimator;
- private float mCheckedAlpha = 1.0f;
- private int mCheckedFadeInDuration;
- private int mCheckedFadeOutDuration;
-
public PagedViewWidget(Context context) {
this(context, null);
}
@@ -72,16 +60,7 @@
public PagedViewWidget(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
- // Set up fade in/out constants
final Resources r = context.getResources();
- final int alpha = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeAlpha);
- if (alpha > 0) {
- mCheckedAlpha = r.getInteger(R.integer.config_dragAppsCustomizeIconFadeAlpha) / 256.0f;
- mCheckedFadeInDuration =
- r.getInteger(R.integer.config_dragAppsCustomizeIconFadeInDuration);
- mCheckedFadeOutDuration =
- r.getInteger(R.integer.config_dragAppsCustomizeIconFadeOutDuration);
- }
mDimensionsFormatString = r.getString(R.string.widget_dims_format);
setWillNotDraw(false);
@@ -109,8 +88,7 @@
}
public void applyFromAppWidgetProviderInfo(AppWidgetProviderInfo info,
- int maxWidth, int[] cellSpan, HolographicOutlineHelper holoOutlineHelper) {
- mHolographicOutlineHelper = holoOutlineHelper;
+ int maxWidth, int[] cellSpan) {
final ImageView image = (ImageView) findViewById(R.id.widget_preview);
if (maxWidth > -1) {
image.setMaxWidth(maxWidth);
@@ -125,9 +103,7 @@
}
}
- public void applyFromResolveInfo(PackageManager pm, ResolveInfo info,
- HolographicOutlineHelper holoOutlineHelper) {
- mHolographicOutlineHelper = holoOutlineHelper;
+ public void applyFromResolveInfo(PackageManager pm, ResolveInfo info) {
CharSequence label = info.loadLabel(pm);
final ImageView image = (ImageView) findViewById(R.id.widget_preview);
image.setContentDescription(label);
@@ -159,11 +135,6 @@
}
}
- public void setHolographicOutline(Bitmap holoOutline) {
- mHolographicOutline = holoOutline;
- invalidate();
- }
-
@Override
public boolean onTouchEvent(MotionEvent event) {
// We eat up the touch events here, since the PagedView (which uses the same swiping
@@ -177,27 +148,6 @@
}
@Override
- protected void onDraw(Canvas canvas) {
- if (mAlpha > 0) {
- super.onDraw(canvas);
- }
-
- // draw any blended overlays
- if (mHolographicOutline != null && mHolographicAlpha > 0) {
- // Calculate how much to scale the holographic preview
- mTmpScaleRect.set(0,0,1,1);
- mPreviewImageView.getImageMatrix().mapRect(mTmpScaleRect);
-
- mPaint.setAlpha(mHolographicAlpha);
- canvas.save();
- canvas.scale(mTmpScaleRect.right, mTmpScaleRect.bottom);
- canvas.drawBitmap(mHolographicOutline, mPreviewImageView.getLeft(),
- mPreviewImageView.getTop(), mPaint);
- canvas.restore();
- }
- }
-
- @Override
protected boolean onSetAlpha(int alpha) {
return true;
}
@@ -208,62 +158,4 @@
getChildAt(i).setAlpha(alpha);
}
}
- @Override
- public void setAlpha(float alpha) {
- final float viewAlpha = mHolographicOutlineHelper.viewAlphaInterpolator(alpha);
- final float holographicAlpha = mHolographicOutlineHelper.highlightAlphaInterpolator(alpha);
- int newViewAlpha = (int) (viewAlpha * 255);
- int newHolographicAlpha = (int) (holographicAlpha * 255);
- if ((mAlpha != newViewAlpha) || (mHolographicAlpha != newHolographicAlpha)) {
- mAlpha = newViewAlpha;
- mHolographicAlpha = newHolographicAlpha;
- setChildrenAlpha(viewAlpha);
- super.setAlpha(viewAlpha);
- }
- }
-
- void setChecked(boolean checked, boolean animate) {
- if (mIsChecked != checked) {
- mIsChecked = checked;
-
- float alpha;
- int duration;
- if (mIsChecked) {
- alpha = mCheckedAlpha;
- duration = mCheckedFadeInDuration;
- } else {
- alpha = 1.0f;
- duration = mCheckedFadeOutDuration;
- }
-
- // Initialize the animator
- if (mCheckedAlphaAnimator != null) {
- mCheckedAlphaAnimator.cancel();
- }
- if (animate) {
- mCheckedAlphaAnimator = ObjectAnimator.ofFloat(this, "alpha", getAlpha(), alpha);
- mCheckedAlphaAnimator.setDuration(duration);
- mCheckedAlphaAnimator.start();
- } else {
- setAlpha(alpha);
- }
-
- invalidate();
- }
- }
-
- @Override
- public void setChecked(boolean checked) {
- setChecked(checked, true);
- }
-
- @Override
- public boolean isChecked() {
- return mIsChecked;
- }
-
- @Override
- public void toggle() {
- setChecked(!mIsChecked);
- }
}
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index 148c1ba..7d61f62 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -57,7 +57,6 @@
import android.view.DragEvent;
import android.view.MotionEvent;
import android.view.View;
-import android.view.ViewConfiguration;
import android.view.ViewGroup;
import android.view.animation.DecelerateInterpolator;
import android.widget.ImageView;
@@ -1635,14 +1634,7 @@
}
if (animated) {
- ValueAnimator animWithInterpolator =
- ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
-
- if (zoomIn) {
- animWithInterpolator.setInterpolator(mZoomInInterpolator);
- }
-
- animWithInterpolator.addListener(new AnimatorListenerAdapter() {
+ anim.addListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(android.animation.Animator animation) {
// The above code to determine initialAlpha and finalAlpha will ensure that only
@@ -1657,10 +1649,11 @@
}
}
});
- for (int i = 0; i < getChildCount(); i++) {
+ for (int index = 0; index < getChildCount(); index++) {
+ final int i = index;
+ final CellLayout cl = (CellLayout) getChildAt(i);
invalidate();
if (mOldAlphas[i] == 0 && mNewAlphas[i] == 0) {
- final CellLayout cl = (CellLayout) getChildAt(i);
cl.fastInvalidate();
cl.setFastTranslationX(mNewTranslationXs[i]);
cl.setFastTranslationY(mNewTranslationYs[i]);
@@ -1669,60 +1662,48 @@
cl.setFastBackgroundAlpha(mNewBackgroundAlphas[i]);
cl.setBackgroundAlphaMultiplier(mNewBackgroundAlphaMultipliers[i]);
cl.setFastAlpha(mNewAlphas[i]);
+ } else {
+ LauncherViewPropertyAnimator a = new LauncherViewPropertyAnimator(cl);
+ a.translationX(mNewTranslationXs[i])
+ .translationY(mNewTranslationYs[i])
+ .scaleX(mNewScaleXs[i])
+ .scaleY(mNewScaleYs[i])
+ .setDuration(duration)
+ .setInterpolator(mZoomInInterpolator);
+ if (mOldAlphas[i] != mNewAlphas[i]) {
+ a.alpha(mNewAlphas[i]);
+ }
+ anim.play(a);
+ if (mOldRotationYs[i] != 0 || mNewRotationYs[i] != 0) {
+ ValueAnimator rotate = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
+ rotate.setInterpolator(new DecelerateInterpolator(2.0f));
+ rotate.addUpdateListener(new LauncherAnimatorUpdateListener() {
+ public void onAnimationUpdate(float a, float b) {
+ cl.setRotationY(a * 0f + b * 1f);
+ }
+ });
+ anim.play(rotate);
+ }
+ if (mOldBackgroundAlphas[i] != 0 ||
+ mNewBackgroundAlphas[i] != 0 ||
+ mOldBackgroundAlphaMultipliers[i] != 0 ||
+ mNewBackgroundAlphaMultipliers[i] != 0) {
+ ValueAnimator bgAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
+ bgAnim.setInterpolator(mZoomInInterpolator);
+ bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
+ public void onAnimationUpdate(float a, float b) {
+ cl.setFastBackgroundAlpha(
+ a * mOldBackgroundAlphas[i] +
+ b * mNewBackgroundAlphas[i]);
+ cl.setBackgroundAlphaMultiplier(
+ a * mOldBackgroundAlphaMultipliers[i] +
+ b * mNewBackgroundAlphaMultipliers[i]);
+ }
+ });
+ anim.play(bgAnim);
+ }
}
}
-
- animWithInterpolator.addUpdateListener(new LauncherAnimatorUpdateListener() {
- public void onAnimationUpdate(float a, float b) {
- mTransitionProgress = b;
- if (b == 0f) {
- // an optimization, but not required
- return;
- }
- invalidate();
- for (int i = 0; i < getChildCount(); i++) {
- if (mOldAlphas[i] != 0 || mNewAlphas[i] != 0) {
- final CellLayout cl = (CellLayout) getChildAt(i);
- cl.fastInvalidate();
- cl.setFastTranslationX(
- a * mOldTranslationXs[i] + b * mNewTranslationXs[i]);
- cl.setFastTranslationY(
- a * mOldTranslationYs[i] + b * mNewTranslationYs[i]);
- cl.setFastScaleX(a * mOldScaleXs[i] + b * mNewScaleXs[i]);
- cl.setFastScaleY(a * mOldScaleYs[i] + b * mNewScaleYs[i]);
- cl.setFastBackgroundAlpha(
- a * mOldBackgroundAlphas[i] + b * mNewBackgroundAlphas[i]);
- cl.setBackgroundAlphaMultiplier(a * mOldBackgroundAlphaMultipliers[i] +
- b * mNewBackgroundAlphaMultipliers[i]);
- cl.setFastAlpha(a * mOldAlphas[i] + b * mNewAlphas[i]);
- if (mOldAlphas[i] != mNewAlphas[i]) {
- cl.setAlpha(a * mOldAlphas[i] + b * mNewAlphas[i]);
- }
- }
- }
- }
- });
-
- ValueAnimator rotationAnim =
- ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
- rotationAnim.setInterpolator(new DecelerateInterpolator(2.0f));
- rotationAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
- public void onAnimationUpdate(float a, float b) {
- if (b == 0f) {
- // an optimization, but not required
- return;
- }
- for (int i = 0; i < getChildCount(); i++) {
- if (mOldAlphas[i] != 0 || mNewAlphas[i] != 0 ||
- mOldRotationYs[i] != 0 || mNewRotationYs[i] != 0) {
- final CellLayout cl = (CellLayout) getChildAt(i);
- cl.setFastRotationY(a * mOldRotationYs[i] + b * mNewRotationYs[i]);
- }
- }
- }
- });
-
- anim.playTogether(animWithInterpolator, rotationAnim);
anim.setStartDelay(delay);
// If we call this when we're not animated, onAnimationEnd is never called on
// the listener; make sure we only use the listener when we're actually animating