merge in jb-release history after reset to jb-dev
diff --git a/src/com/android/launcher2/AppsCustomizeTabHost.java b/src/com/android/launcher2/AppsCustomizeTabHost.java
index 7a2c247..d3afc3b 100644
--- a/src/com/android/launcher2/AppsCustomizeTabHost.java
+++ b/src/com/android/launcher2/AppsCustomizeTabHost.java
@@ -471,17 +471,6 @@
// Load the current page synchronously, and the neighboring pages asynchronously
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage(), true);
mAppsCustomizePane.loadAssociatedPages(mAppsCustomizePane.getCurrentPage());
-
- // We had to enable the wallpaper visibility when launching apps from all apps (so that
- // the transitions would be the same as when launching from workspace) so we need to
- // re-disable the wallpaper visibility to ensure performance.
- int duration = getResources().getInteger(android.R.integer.config_shortAnimTime);
- postDelayed(new Runnable() {
- @Override
- public void run() {
- mLauncher.updateWallpaperVisibility(false);
- }
- }, duration);
}
}
diff --git a/src/com/android/launcher2/CellLayout.java b/src/com/android/launcher2/CellLayout.java
index 6f4759d..ba20a76 100644
--- a/src/com/android/launcher2/CellLayout.java
+++ b/src/com/android/launcher2/CellLayout.java
@@ -160,6 +160,9 @@
private static final int INVALID_DIRECTION = -100;
private DropTarget.DragEnforcer mDragEnforcer;
+ private final static PorterDuffXfermode sAddBlendMode =
+ new PorterDuffXfermode(PorterDuff.Mode.ADD);
+
public CellLayout(Context context) {
this(context, null);
}
@@ -506,7 +509,7 @@
if (mForegroundAlpha > 0) {
mOverScrollForegroundDrawable.setBounds(mForegroundRect);
Paint p = ((NinePatchDrawable) mOverScrollForegroundDrawable).getPaint();
- p.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.ADD));
+ p.setXfermode(sAddBlendMode);
mOverScrollForegroundDrawable.draw(canvas);
p.setXfermode(null);
}
diff --git a/src/com/android/launcher2/DragController.java b/src/com/android/launcher2/DragController.java
index b9d7dd4..9b61755 100644
--- a/src/com/android/launcher2/DragController.java
+++ b/src/com/android/launcher2/DragController.java
@@ -381,8 +381,8 @@
if (dragInfo != null &&
dragInfo.intent != null &&
info.intent != null) {
- boolean isSamePackage = dragInfo.intent.getPackage().equals(
- info.intent.getPackage());
+ boolean isSamePackage = info.intent.getComponent().getPackageName().equals(
+ dragInfo.intent.getComponent().getPackageName());
if (isSamePackage) {
cancelDrag();
return;
diff --git a/src/com/android/launcher2/Launcher.java b/src/com/android/launcher2/Launcher.java
index 0d4b0d0..8b6fee9 100644
--- a/src/com/android/launcher2/Launcher.java
+++ b/src/com/android/launcher2/Launcher.java
@@ -33,8 +33,6 @@
import android.appwidget.AppWidgetProviderInfo;
import android.content.ActivityNotFoundException;
import android.content.BroadcastReceiver;
-import android.content.ClipData;
-import android.content.ClipDescription;
import android.content.ComponentCallbacks2;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -144,6 +142,10 @@
private static final String PREFERENCES = "launcher.preferences";
static final String FORCE_ENABLE_ROTATION_PROPERTY = "launcher.force_enable_rotation";
+ // The Intent extra that defines whether to ignore the launch animation
+ static final String INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION =
+ "com.android.launcher.intent.extra.shortcut.INGORE_LAUNCH_ANIMATION";
+
// Type: int
private static final String RUNTIME_STATE_CURRENT_SCREEN = "launcher.current_screen";
// Type: int
@@ -1180,6 +1182,23 @@
// currently shown, because doing that may involve
// some communication back with the app.
mWorkspace.postDelayed(mBuildLayersRunnable, 500);
+
+ // We had to enable the wallpaper visibility when launching apps from all
+ // apps (so that the transitions would be the same as when launching from
+ // workspace) so take this time to see if we need to re-disable the
+ // wallpaper visibility to ensure performance.
+ mWorkspace.post(new Runnable() {
+ @Override
+ public void run() {
+ if (mState == State.APPS_CUSTOMIZE) {
+ if (mAppsCustomizeTabHost != null &&
+ !mAppsCustomizeTabHost.isTransitioning()) {
+ updateWallpaperVisibility(false);
+ }
+ }
+ }
+ });
+
observer.removeOnPreDrawListener(this);
return true;
}
@@ -1890,7 +1909,11 @@
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
try {
- if (v != null) {
+ // Only launch using the new animation if the shortcut has not opted out (this is a
+ // private contract between launcher and may be ignored in the future).
+ boolean useLaunchAnimation = (v != null) &&
+ !intent.hasExtra(INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION);
+ if (useLaunchAnimation) {
ActivityOptions opts = ActivityOptions.makeScaleUpAnimation(v, 0, 0,
v.getMeasuredWidth(), v.getMeasuredHeight());
diff --git a/src/com/android/launcher2/LauncherModel.java b/src/com/android/launcher2/LauncherModel.java
index ff4abc6..bae4c56 100644
--- a/src/com/android/launcher2/LauncherModel.java
+++ b/src/com/android/launcher2/LauncherModel.java
@@ -1684,7 +1684,7 @@
for (ItemInfo i : sWorkspaceItems) {
if (i instanceof ShortcutInfo) {
ShortcutInfo info = (ShortcutInfo) i;
- if (info.intent.getPackage().equals(packageName)) {
+ if (info.intent.getComponent().getPackageName().equals(packageName)) {
infos.add(info);
}
}
diff --git a/src/com/android/launcher2/LauncherProvider.java b/src/com/android/launcher2/LauncherProvider.java
index 5e572a5..4cf87d2 100644
--- a/src/com/android/launcher2/LauncherProvider.java
+++ b/src/com/android/launcher2/LauncherProvider.java
@@ -66,7 +66,7 @@
private static final String DATABASE_NAME = "launcher.db";
- private static final int DATABASE_VERSION = 10;
+ private static final int DATABASE_VERSION = 11;
static final String AUTHORITY = "com.android.launcher2.settings";
@@ -477,12 +477,14 @@
version = 9;
}
- if (version < 10) {
+ // We bumped the version twice during JB, once to update the launch flags, and once to
+ // update the override for the default launch animation.
+ if (version < 11) {
// Contact shortcuts need a different set of flags to be launched now
// The updateContactsShortcuts change is idempotent, so we can keep using it like
// back in the Donut days
updateContactsShortcuts(db);
- version = 10;
+ version = 11;
}
if (version != DATABASE_VERSION) {
@@ -535,7 +537,8 @@
// detail activities.
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK |
Intent.FLAG_ACTIVITY_CLEAR_TASK);
-
+ newIntent.putExtra(
+ Launcher.INTENT_EXTRA_IGNORE_LAUNCH_ANIMATION, true);
newIntent.setData(uri);
final ContentValues values = new ContentValues();
diff --git a/src/com/android/launcher2/PagedView.java b/src/com/android/launcher2/PagedView.java
index adfe0de..b850ce2 100644
--- a/src/com/android/launcher2/PagedView.java
+++ b/src/com/android/launcher2/PagedView.java
@@ -627,7 +627,9 @@
if (isScrollingIndicatorEnabled()) {
updateScrollingIndicator();
}
- if (mFadeInAdjacentScreens) {
+ boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
+
+ if (mFadeInAdjacentScreens && !isInOverscroll) {
for (int i = 0; i < getChildCount(); i++) {
View child = getChildAt(i);
if (child != null) {
diff --git a/src/com/android/launcher2/Workspace.java b/src/com/android/launcher2/Workspace.java
index e946095..3c84805 100644
--- a/src/com/android/launcher2/Workspace.java
+++ b/src/com/android/launcher2/Workspace.java
@@ -182,6 +182,7 @@
private float mOverscrollFade = 0;
private boolean mOverscrollTransformsSet;
public static final int DRAG_BITMAP_PADDING = 2;
+ private boolean mWorkspaceFadeInAdjacentScreens;
// Camera and Matrix used to determine the final position of a neighboring CellLayout
private final Matrix mMatrix = new Matrix();
@@ -247,7 +248,6 @@
private float[] mOldScaleXs;
private float[] mOldScaleYs;
private float[] mOldBackgroundAlphas;
- private float[] mOldBackgroundAlphaMultipliers;
private float[] mOldAlphas;
private float[] mOldRotationYs;
private float[] mNewTranslationXs;
@@ -255,7 +255,6 @@
private float[] mNewScaleXs;
private float[] mNewScaleYs;
private float[] mNewBackgroundAlphas;
- private float[] mNewBackgroundAlphaMultipliers;
private float[] mNewAlphas;
private float[] mNewRotationYs;
private float mTransitionProgress;
@@ -286,7 +285,8 @@
setDataIsReady();
final Resources res = getResources();
- mFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
+ mWorkspaceFadeInAdjacentScreens = res.getBoolean(R.bool.config_workspaceFadeAdjacentScreens);
+ mFadeInAdjacentScreens = false;
mWallpaperManager = WallpaperManager.getInstance(context);
int cellCountX = DEFAULT_CELL_COUNT_X;
@@ -721,7 +721,7 @@
// If we are not fading in adjacent screens, we still need to restore the alpha in case the
// user scrolls while we are transitioning (should not affect dispatchDraw optimizations)
- if (!mFadeInAdjacentScreens) {
+ if (!mWorkspaceFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); ++i) {
((CellLayout) getPageAt(i)).setShortcutAndWidgetAlpha(1f);
}
@@ -1192,55 +1192,26 @@
return Math.min(r / threshold, 1.0f);
}
- private void screenScrolledLargeUI(int screenCenter) {
- if (isSwitchingState()) return;
- boolean isInOverscroll = false;
- for (int i = 0; i < getChildCount(); i++) {
- CellLayout cl = (CellLayout) getChildAt(i);
- if (cl != null) {
- float scrollProgress = getScrollProgress(screenCenter, cl, i);
- float rotation = WORKSPACE_ROTATION * scrollProgress;
- float translationX = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight());
+ @Override
+ protected void screenScrolled(int screenCenter) {
+ super.screenScrolled(screenCenter);
- // If the current page (i) is being over scrolled, we use a different
- // set of rules for setting the background alpha multiplier.
- if (!isSmall()) {
- if ((mOverScrollX < 0 && i == 0) || (mOverScrollX > mMaxScrollX &&
- i == getChildCount() -1)) {
- isInOverscroll = true;
- rotation *= -1;
- cl.setBackgroundAlphaMultiplier(
- overScrollBackgroundAlphaInterpolator(Math.abs(scrollProgress)));
- mOverScrollPageIndex = i;
- cl.setOverScrollAmount(Math.abs(scrollProgress), i == 0);
- if (!mOverscrollTransformsSet) {
- mOverscrollTransformsSet = true;
- cl.setPivotX(cl.getMeasuredWidth() * (i == 0 ? 0.75f : 0.25f));
- cl.setPivotY(cl.getMeasuredHeight() * 0.5f);
- cl.setOverscrollTransformsDirty(true);
- }
- } else if (mOverScrollPageIndex != i) {
- cl.setBackgroundAlphaMultiplier(
- backgroundAlphaInterpolator(Math.abs(scrollProgress)));
- }
- }
- cl.setTranslationX(translationX);
- cl.setRotationY(rotation);
- if (mFadeInAdjacentScreens && !isSmall()) {
+ boolean isInOverscroll = mOverScrollX < 0 || mOverScrollX > mMaxScrollX;
+ if (mWorkspaceFadeInAdjacentScreens &&
+ mState == State.NORMAL &&
+ !mIsSwitchingState &&
+ !isInOverscroll) {
+ for (int i = 0; i < getChildCount(); i++) {
+ CellLayout child = (CellLayout) getChildAt(i);
+ if (child != null) {
+ float scrollProgress = getScrollProgress(screenCenter, child, i);
float alpha = 1 - Math.abs(scrollProgress);
- cl.setShortcutAndWidgetAlpha(alpha);
+ child.getShortcutsAndWidgets().setAlpha(alpha);
}
}
+ invalidate();
}
- if (mOverscrollTransformsSet && !isInOverscroll) {
- mOverscrollTransformsSet = false;
- ((CellLayout) getChildAt(0)).resetOverscrollTransforms();
- ((CellLayout) getChildAt(getChildCount() - 1)).resetOverscrollTransforms();
- }
- invalidate();
- }
- private void screenScrolledStandardUI(int screenCenter) {
if (mOverScrollX < 0 || mOverScrollX > mMaxScrollX) {
int index = mOverScrollX < 0 ? 0 : getChildCount() - 1;
CellLayout cl = (CellLayout) getChildAt(index);
@@ -1269,24 +1240,8 @@
}
@Override
- protected void screenScrolled(int screenCenter) {
- if (LauncherApplication.isScreenLarge()) {
- // We don't call super.screenScrolled() here because we handle the adjacent pages alpha
- // ourselves (for efficiency), and there are no scrolling indicators to update.
- screenScrolledLargeUI(screenCenter);
- } else {
- super.screenScrolled(screenCenter);
- screenScrolledStandardUI(screenCenter);
- }
- }
-
- @Override
protected void overScroll(float amount) {
- if (LauncherApplication.isScreenLarge()) {
- dampedOverScroll(amount);
- } else {
- acceleratedOverScroll(amount);
- }
+ acceleratedOverScroll(amount);
}
protected void onAttachedToWindow() {
@@ -1519,7 +1474,6 @@
mOldScaleXs = new float[childCount];
mOldScaleYs = new float[childCount];
mOldBackgroundAlphas = new float[childCount];
- mOldBackgroundAlphaMultipliers = new float[childCount];
mOldAlphas = new float[childCount];
mOldRotationYs = new float[childCount];
mNewTranslationXs = new float[childCount];
@@ -1527,7 +1481,6 @@
mNewScaleXs = new float[childCount];
mNewScaleYs = new float[childCount];
mNewBackgroundAlphas = new float[childCount];
- mNewBackgroundAlphaMultipliers = new float[childCount];
mNewAlphas = new float[childCount];
mNewRotationYs = new float[childCount];
}
@@ -1582,11 +1535,10 @@
getResources().getInteger(R.integer.config_appsCustomizeWorkspaceShrinkTime);
for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
- float rotation = 0f;
- float initialAlpha = cl.getAlpha();
- float finalAlphaMultiplierValue = 1f;
- float finalAlpha = (!mFadeInAdjacentScreens || stateIsSpringLoaded ||
+ float finalAlpha = (!mWorkspaceFadeInAdjacentScreens || stateIsSpringLoaded ||
(i == mCurrentPage)) ? 1f : 0f;
+ float currentAlpha = cl.getShortcutsAndWidgets().getAlpha();
+ float initialAlpha = currentAlpha;
// Determine the pages alpha during the state transition
if ((oldStateIsSmall && stateIsNormal) ||
@@ -1596,29 +1548,12 @@
// or, if we're in spring-loaded mode
if (i == mCurrentPage || !animated || oldStateIsSpringLoaded) {
finalAlpha = 1f;
- finalAlphaMultiplierValue = 0f;
} else {
initialAlpha = 0f;
finalAlpha = 0f;
}
}
- // Update the rotation of the screen (don't apply rotation on Phone UI)
- if (LauncherApplication.isScreenLarge()) {
- if (i < mCurrentPage) {
- rotation = WORKSPACE_ROTATION;
- } else if (i > mCurrentPage) {
- rotation = -WORKSPACE_ROTATION;
- }
- }
-
- // If the screen is not xlarge, then don't rotate the CellLayouts
- // NOTE: If we don't update the side pages alpha, then we should not hide the side
- // pages. see unshrink().
- if (LauncherApplication.isScreenLarge()) {
- translationX = getOffsetXForRotation(rotation, cl.getWidth(), cl.getHeight());
- }
-
mOldAlphas[i] = initialAlpha;
mNewAlphas[i] = finalAlpha;
if (animated) {
@@ -1627,25 +1562,19 @@
mOldScaleXs[i] = cl.getScaleX();
mOldScaleYs[i] = cl.getScaleY();
mOldBackgroundAlphas[i] = cl.getBackgroundAlpha();
- mOldBackgroundAlphaMultipliers[i] = cl.getBackgroundAlphaMultiplier();
- mOldRotationYs[i] = cl.getRotationY();
mNewTranslationXs[i] = translationX;
mNewTranslationYs[i] = translationY;
mNewScaleXs[i] = finalScaleFactor;
mNewScaleYs[i] = finalScaleFactor;
mNewBackgroundAlphas[i] = finalBackgroundAlpha;
- mNewBackgroundAlphaMultipliers[i] = finalAlphaMultiplierValue;
- mNewRotationYs[i] = rotation;
} else {
cl.setTranslationX(translationX);
cl.setTranslationY(translationY);
cl.setScaleX(finalScaleFactor);
cl.setScaleY(finalScaleFactor);
cl.setBackgroundAlpha(finalBackgroundAlpha);
- cl.setBackgroundAlphaMultiplier(finalAlphaMultiplierValue);
cl.setShortcutAndWidgetAlpha(finalAlpha);
- cl.setRotationY(rotation);
}
}
@@ -1653,13 +1582,13 @@
for (int index = 0; index < getChildCount(); index++) {
final int i = index;
final CellLayout cl = (CellLayout) getChildAt(i);
+ float currentAlpha = cl.getShortcutsAndWidgets().getAlpha();
if (mOldAlphas[i] == 0 && mNewAlphas[i] == 0) {
cl.setTranslationX(mNewTranslationXs[i]);
cl.setTranslationY(mNewTranslationYs[i]);
cl.setScaleX(mNewScaleXs[i]);
cl.setScaleY(mNewScaleYs[i]);
cl.setBackgroundAlpha(mNewBackgroundAlphas[i]);
- cl.setBackgroundAlphaMultiplier(mNewBackgroundAlphaMultipliers[i]);
cl.setShortcutAndWidgetAlpha(mNewAlphas[i]);
cl.setRotationY(mNewRotationYs[i]);
} else {
@@ -1672,7 +1601,7 @@
.setInterpolator(mZoomInInterpolator);
anim.play(a);
- if (mOldAlphas[i] != mNewAlphas[i]) {
+ if (mOldAlphas[i] != mNewAlphas[i] || currentAlpha != mNewAlphas[i]) {
LauncherViewPropertyAnimator alphaAnim =
new LauncherViewPropertyAnimator(cl.getShortcutsAndWidgets());
alphaAnim.alpha(mNewAlphas[i])
@@ -1680,20 +1609,8 @@
.setInterpolator(mZoomInInterpolator);
anim.play(alphaAnim);
}
- 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 * mOldRotationYs[i] + b * mNewRotationYs[i]);
- }
- });
- anim.play(rotate);
- }
if (mOldBackgroundAlphas[i] != 0 ||
- mNewBackgroundAlphas[i] != 0 ||
- mOldBackgroundAlphaMultipliers[i] != 0 ||
- mNewBackgroundAlphaMultipliers[i] != 0) {
+ mNewBackgroundAlphas[i] != 0) {
ValueAnimator bgAnim = ValueAnimator.ofFloat(0f, 1f).setDuration(duration);
bgAnim.setInterpolator(mZoomInInterpolator);
bgAnim.addUpdateListener(new LauncherAnimatorUpdateListener() {
@@ -1701,9 +1618,6 @@
cl.setBackgroundAlpha(
a * mOldBackgroundAlphas[i] +
b * mNewBackgroundAlphas[i]);
- cl.setBackgroundAlphaMultiplier(
- a * mOldBackgroundAlphaMultipliers[i] +
- b * mNewBackgroundAlphaMultipliers[i]);
}
});
anim.play(bgAnim);
@@ -1751,7 +1665,7 @@
// ensure that only the current page is visible during (and subsequently, after) the
// transition animation. If fade adjacent pages is disabled, then re-enable the page
// visibility after the transition animation.
- if (!mFadeInAdjacentScreens) {
+ if (!mWorkspaceFadeInAdjacentScreens) {
for (int i = 0; i < getChildCount(); i++) {
final CellLayout cl = (CellLayout) getChildAt(i);
cl.setShortcutAndWidgetAlpha(1f);
@@ -3708,7 +3622,7 @@
for (String intentStr : newApps) {
try {
Intent intent = Intent.parseUri(intentStr, 0);
- if (packageNames.contains(intent.getPackage())) {
+ if (packageNames.contains(intent.getComponent().getPackageName())) {
newApps.remove(intentStr);
}
} catch (URISyntaxException e) {}