From 6586b54ded5eea67a84ae40b660299d4be1e83db Mon Sep 17 00:00:00 2001 From: Jon Miranda Date: Mon, 22 Jan 2018 13:55:58 -0800 Subject: [PATCH] Fix crash for apps launched through non-BubbleTextView views. * Same transition/animation, except we don't create a visual copy of the View. Bug: 72314029 Bug: 70220260 Change-Id: I79898be1cae7160b5dc35cc1ea8ba3dc5b2db05c --- .../LauncherAppTransitionManager.java | 27 ++++++++++++------- .../launcher3/popup/SystemShortcut.java | 2 +- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java index e221102bc0..d56666ab32 100644 --- a/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java +++ b/quickstep/src/com/android/launcher3/LauncherAppTransitionManager.java @@ -156,12 +156,15 @@ public class LauncherAppTransitionManager { } 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 viewLocationStart = mIsRtl @@ -169,7 +172,9 @@ public class LauncherAppTransitionManager { : 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.setMarginStart(viewLocationStart + rect.left); @@ -226,8 +231,12 @@ public class LauncherAppTransitionManager { } 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(); @@ -251,8 +260,8 @@ public class LauncherAppTransitionManager { 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; diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index 83cbf59587..05ae0213e9 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -82,7 +82,7 @@ public abstract class SystemShortcut extends ItemInfo { @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);