Merge "Adding referrer information when launching market intent" into ub-launcher3-master
diff --git a/quickstep/libs/sysui_shared.jar b/quickstep/libs/sysui_shared.jar
index 18ddeee..85b40d0 100644
--- a/quickstep/libs/sysui_shared.jar
+++ b/quickstep/libs/sysui_shared.jar
Binary files differ
diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
index dd05cfe..d56666a 100644
--- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
+++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java
@@ -29,6 +29,7 @@
import android.graphics.Matrix;
import android.graphics.Rect;
import android.os.Bundle;
+import android.util.Log;
import android.view.Surface;
import android.view.View;
import android.view.ViewGroup;
@@ -49,6 +50,7 @@
*/
public class LauncherAppTransitionManager {
+ private static final String TAG = "LauncherTransition";
private static final int REFRESH_RATE_MS = 16;
private final DragLayer mDragLayer;
@@ -58,6 +60,7 @@
private final float mDragLayerTransY;
private ImageView mFloatingView;
+ private boolean mIsRtl;
public LauncherAppTransitionManager(Launcher launcher) {
mLauncher = launcher;
@@ -66,6 +69,8 @@
mDragLayerTransY =
launcher.getResources().getDimensionPixelSize(R.dimen.drag_layer_trans_y);
+
+ mIsRtl = Utilities.isRtl(launcher.getResources());
}
public Bundle getActivityLauncherOptions(View v) {
@@ -151,21 +156,28 @@
}
private AnimatorSet getAppIconAnimator(View v) {
- // Create a copy of the app icon
+ boolean isBubbleTextView = v instanceof BubbleTextView;
mFloatingView = new ImageView(mLauncher);
- Bitmap iconBitmap = ((FastBitmapDrawable) ((BubbleTextView) v).getIcon()).getBitmap();
- mFloatingView.setImageDrawable(new FastBitmapDrawable(iconBitmap));
+ if (isBubbleTextView) {
+ // Create a copy of the app icon
+ Bitmap iconBitmap = ((FastBitmapDrawable) ((BubbleTextView) v).getIcon()).getBitmap();
+ mFloatingView.setImageDrawable(new FastBitmapDrawable(iconBitmap));
+ }
- // Position the copy of the app icon exactly on top of the original
+ // Position the floating view exactly on top of the original
Rect rect = new Rect();
mDragLayer.getDescendantRectRelativeToSelf(v, rect);
- int viewLocationLeft = rect.left;
+ int viewLocationStart = mIsRtl
+ ? mDeviceProfile.widthPx - rect.right
+ : rect.left;
int viewLocationTop = rect.top;
- ((BubbleTextView) v).getIconBounds(rect);
+ if (isBubbleTextView) {
+ ((BubbleTextView) v).getIconBounds(rect);
+ }
LayoutParams lp = new LayoutParams(rect.width(), rect.height());
lp.ignoreInsets = true;
- lp.leftMargin = viewLocationLeft + rect.left;
+ lp.setMarginStart(viewLocationStart + rect.left);
lp.topMargin = viewLocationTop + rect.top;
mFloatingView.setLayoutParams(lp);
@@ -177,8 +189,13 @@
// Animate the app icon to the center
float centerX = mDeviceProfile.widthPx / 2;
float centerY = mDeviceProfile.heightPx / 2;
- float dX = centerX - lp.leftMargin - (lp.width / 2);
+
+ float xPosition = mIsRtl
+ ? mDeviceProfile.widthPx - lp.getMarginStart() - rect.width()
+ : lp.getMarginStart();
+ float dX = centerX - xPosition - (lp.width / 2);
float dY = centerY - lp.topMargin - (lp.height / 2);
+
ObjectAnimator x = ObjectAnimator.ofFloat(mFloatingView, View.TRANSLATION_X, 0f, dX);
ObjectAnimator y = ObjectAnimator.ofFloat(mFloatingView, View.TRANSLATION_Y, 0f, dY);
@@ -214,8 +231,12 @@
}
private ValueAnimator getAppWindowAnimators(View v, RemoteAnimationTargetCompat[] targets) {
- Rect iconBounds = new Rect();
- ((BubbleTextView) v).getIconBounds(iconBounds);
+ Rect bounds = new Rect();
+ if (v instanceof BubbleTextView) {
+ ((BubbleTextView) v).getIconBounds(bounds);
+ } else {
+ mDragLayer.getDescendantRectRelativeToSelf(v, bounds);
+ }
int[] floatingViewBounds = new int[2];
Rect crop = new Rect();
@@ -228,12 +249,19 @@
@Override
public void onAnimationUpdate(ValueAnimator animation) {
+ final Surface surface = getSurface(mFloatingView);
+ final long frameNumber = surface != null ? getNextFrameNumber(surface) : -1;
+ if (frameNumber == -1) {
+ // Booo, not cool! Our surface got destroyed, so no reason to animate anything.
+ Log.w(TAG, "Failed to animate, surface got destroyed.");
+ return;
+ }
final float percent = animation.getAnimatedFraction();
final float easePercent = Interpolators.AGGRESSIVE_EASE.getInterpolation(percent);
// Calculate app icon size.
- float iconWidth = iconBounds.width() * mFloatingView.getScaleX();
- float iconHeight = iconBounds.height() * mFloatingView.getScaleY();
+ float iconWidth = bounds.width() * mFloatingView.getScaleX();
+ float iconHeight = bounds.height() * mFloatingView.getScaleY();
// Scale the app window to match the icon size.
float scaleX = iconWidth / mDeviceProfile.widthPx;
@@ -273,9 +301,12 @@
for (RemoteAnimationTargetCompat target : targets) {
if (target.mode == RemoteAnimationTargetCompat.MODE_OPENING) {
t.setAlpha(target.leash, alpha);
+
+ // TODO: This isn't correct at the beginning of the animation, but better
+ // than nothing.
+ matrix.postTranslate(target.position.x, target.position.y);
t.setMatrix(target.leash, matrix);
t.setWindowCrop(target.leash, crop);
- Surface surface = getSurface(mFloatingView);
t.deferTransactionUntil(target.leash, surface, getNextFrameNumber(surface));
}
if (isFirstFrame) {
diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java
index 0eb6c7f..d2bcd18 100644
--- a/src/com/android/launcher3/popup/SystemShortcut.java
+++ b/src/com/android/launcher3/popup/SystemShortcut.java
@@ -82,7 +82,7 @@
@Override
public void onClick(View view) {
Rect sourceBounds = launcher.getViewBounds(view);
- Bundle opts = launcher.getActivityLaunchOptions(view, true);
+ Bundle opts = launcher.getActivityLaunchOptions(view, false);
InfoDropTarget.startDetailsActivityForInfo(itemInfo, launcher, sourceBounds, opts);
launcher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP,
ControlType.APPINFO_TARGET, view);