Merge "Add thumbnails to the task view." into ub-launcher3-master
diff --git a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java
index 3602508..f4ea9f9 100644
--- a/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java
+++ b/quickstep/recents_ui_overrides/src/com/android/launcher3/uioverrides/OverviewState.java
@@ -18,6 +18,7 @@
import static com.android.launcher3.LauncherAnimUtils.OVERVIEW_TRANSITION_MS;
import static com.android.launcher3.anim.Interpolators.DEACCEL_2;
import static com.android.launcher3.config.FeatureFlags.ENABLE_QUICKSTEP_LIVE_TILE;
+import static com.android.launcher3.logging.LoggerUtils.newContainerTarget;
import static com.android.launcher3.states.RotationHelper.REQUEST_ROTATE;
import android.graphics.Rect;
@@ -30,8 +31,8 @@
import com.android.launcher3.R;
import com.android.launcher3.Workspace;
import com.android.launcher3.allapps.DiscoveryBounce;
+import com.android.launcher3.userevent.nano.LauncherLogProto.Action;
import com.android.launcher3.userevent.nano.LauncherLogProto.ContainerType;
-import com.android.quickstep.RecentsModel;
import com.android.quickstep.views.RecentsView;
import com.android.quickstep.views.TaskView;
@@ -139,6 +140,8 @@
public void onBackPressed(Launcher launcher) {
TaskView taskView = launcher.<RecentsView>getOverviewPanel().getRunningTaskView();
if (taskView != null) {
+ launcher.getUserEventDispatcher().logActionCommand(Action.Command.BACK,
+ newContainerTarget(ContainerType.OVERVIEW));
taskView.launchTask(true);
} else {
super.onBackPressed(launcher);
diff --git a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
index 2583ffb..252a957 100644
--- a/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
+++ b/quickstep/recents_ui_overrides/src/com/android/quickstep/views/RecentsView.java
@@ -1578,7 +1578,9 @@
}
public void updateLiveTileIcon(Drawable icon) {
- mLiveTileOverlay.setIcon(icon);
+ if (mLiveTileOverlay != null) {
+ mLiveTileOverlay.setIcon(icon);
+ }
}
public void finishRecentsAnimation(boolean toRecents, Runnable onFinishComplete) {
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java
index e699500..7036639 100644
--- a/src/com/android/launcher3/Utilities.java
+++ b/src/com/android/launcher3/Utilities.java
@@ -571,9 +571,11 @@
final boolean isFolderIcon = v instanceof FolderIcon;
final Rect rect = new Rect();
+ // Deep shortcut views have their icon drawn in a separate view.
final boolean fromDeepShortcutView = v.getParent() instanceof DeepShortcutView;
- if (fromDeepShortcutView) {
- // Deep shortcut views have their icon drawn in a separate view.
+ if (v instanceof DeepShortcutView) {
+ dragLayer.getDescendantRectRelativeToSelf(((DeepShortcutView) v).getIconView(), rect);
+ } else if (fromDeepShortcutView) {
DeepShortcutView view = (DeepShortcutView) v.getParent();
dragLayer.getDescendantRectRelativeToSelf(view.getIconView(), rect);
} else if ((isBubbleTextView || isFolderIcon) && v.getTag() instanceof ItemInfo
diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java
index 09eb6d9..9427675 100644
--- a/src/com/android/launcher3/Workspace.java
+++ b/src/com/android/launcher3/Workspace.java
@@ -3084,6 +3084,10 @@
}
private boolean mapOverCellLayout(boolean recurse, CellLayout layout, ItemOperator op) {
+ // TODO(b/128460496) Potential race condition where layout is not yet loaded
+ if (layout == null) {
+ return false;
+ }
ShortcutAndWidgetContainer container = layout.getShortcutsAndWidgets();
// map over all the shortcuts on the workspace
final int itemCount = container.getChildCount();
diff --git a/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java b/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java
index 5e41bb7..0c5a1fc 100644
--- a/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java
+++ b/src/com/android/launcher3/dragndrop/FolderAdaptiveIcon.java
@@ -19,11 +19,8 @@
import android.annotation.TargetApi;
import android.graphics.Bitmap;
import android.graphics.Canvas;
-import android.graphics.ColorFilter;
import android.graphics.Matrix;
-import android.graphics.Paint;
import android.graphics.Path;
-import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.drawable.AdaptiveIconDrawable;
import android.graphics.drawable.ColorDrawable;
@@ -49,11 +46,15 @@
private final Drawable mBadge;
private final Path mMask;
+ private final ConstantState mConstantState;
private FolderAdaptiveIcon(Drawable bg, Drawable fg, Drawable badge, Path mask) {
super(bg, fg);
mBadge = badge;
mMask = mask;
+
+ mConstantState = new MyConstantState(bg.getConstantState(), fg.getConstantState(),
+ badge.getConstantState(), mask);
}
@Override
@@ -134,4 +135,35 @@
return new FolderAdaptiveIcon(new ColorDrawable(bg.getBgColor()), foreground, badge, mask);
}
+
+ @Override
+ public ConstantState getConstantState() {
+ return mConstantState;
+ }
+
+ private static class MyConstantState extends ConstantState {
+ private final ConstantState mBg;
+ private final ConstantState mFg;
+ private final ConstantState mBadge;
+ private final Path mMask;
+
+ MyConstantState(ConstantState bg, ConstantState fg, ConstantState badge, Path mask) {
+ mBg = bg;
+ mFg = fg;
+ mBadge = badge;
+ mMask = mask;
+ }
+
+ @Override
+ public Drawable newDrawable() {
+ return new FolderAdaptiveIcon(mBg.newDrawable(), mFg.newDrawable(),
+ mBadge.newDrawable(), mMask);
+ }
+
+ @Override
+ public int getChangingConfigurations() {
+ return mBg.getChangingConfigurations() & mFg.getChangingConfigurations()
+ & mBadge.getChangingConfigurations();
+ }
+ }
}
diff --git a/src/com/android/launcher3/graphics/ShiftedBitmapDrawable.java b/src/com/android/launcher3/graphics/ShiftedBitmapDrawable.java
index 52d45bb..f8583b8 100644
--- a/src/com/android/launcher3/graphics/ShiftedBitmapDrawable.java
+++ b/src/com/android/launcher3/graphics/ShiftedBitmapDrawable.java
@@ -32,10 +32,14 @@
private float mShiftX;
private float mShiftY;
+ private final ConstantState mConstantState;
+
public ShiftedBitmapDrawable(Bitmap bitmap, float shiftX, float shiftY) {
mBitmap = bitmap;
mShiftX = shiftX;
mShiftY = shiftY;
+
+ mConstantState = new MyConstantState(mBitmap, mShiftX, mShiftY);
}
public float getShiftX() {
@@ -71,4 +75,31 @@
public int getOpacity() {
return PixelFormat.TRANSLUCENT;
}
+
+ @Override
+ public ConstantState getConstantState() {
+ return mConstantState;
+ }
+
+ private static class MyConstantState extends ConstantState {
+ private final Bitmap mBitmap;
+ private float mShiftX;
+ private float mShiftY;
+
+ MyConstantState(Bitmap bitmap, float shiftX, float shiftY) {
+ mBitmap = bitmap;
+ mShiftX = shiftX;
+ mShiftY = shiftY;
+ }
+
+ @Override
+ public Drawable newDrawable() {
+ return new ShiftedBitmapDrawable(mBitmap, mShiftX, mShiftY);
+ }
+
+ @Override
+ public int getChangingConfigurations() {
+ return 0;
+ }
+ }
}
\ No newline at end of file
diff --git a/src/com/android/launcher3/touch/WorkspaceTouchListener.java b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
index 4de082e..7801756 100644
--- a/src/com/android/launcher3/touch/WorkspaceTouchListener.java
+++ b/src/com/android/launcher3/touch/WorkspaceTouchListener.java
@@ -29,6 +29,7 @@
import android.view.HapticFeedbackConstants;
import android.view.MotionEvent;
import android.view.View;
+import android.view.GestureDetector;
import android.view.View.OnTouchListener;
import android.view.ViewConfiguration;
@@ -45,7 +46,7 @@
/**
* Helper class to handle touch on empty space in workspace and show options popup on long press
*/
-public class WorkspaceTouchListener implements OnTouchListener, Runnable {
+public class WorkspaceTouchListener extends GestureDetector.SimpleOnGestureListener implements OnTouchListener {
/**
* STATE_PENDING_PARENT_INFORM is the state between longPress performed & the next motionEvent.
@@ -66,16 +67,21 @@
private int mLongPressState = STATE_CANCELLED;
+ private final GestureDetector mGestureDetector;
+
public WorkspaceTouchListener(Launcher launcher, Workspace workspace) {
mLauncher = launcher;
mWorkspace = workspace;
// Use twice the touch slop as we are looking for long press which is more
// likely to cause movement.
mTouchSlop = 2 * ViewConfiguration.get(launcher).getScaledTouchSlop();
+ mGestureDetector = new GestureDetector(workspace.getContext(), this);
}
@Override
public boolean onTouch(View view, MotionEvent ev) {
+ mGestureDetector.onTouchEvent(ev);
+
int action = ev.getActionMasked();
if (action == ACTION_DOWN) {
// Check if we can handle long press.
@@ -97,7 +103,6 @@
if (handleLongPress) {
mLongPressState = STATE_REQUESTED;
mTouchDownPoint.set(ev.getX(), ev.getY());
- mWorkspace.postDelayed(this, getLongPressTimeout());
}
mWorkspace.onTouchEvent(ev);
@@ -155,12 +160,11 @@
}
private void cancelLongPress() {
- mWorkspace.removeCallbacks(this);
mLongPressState = STATE_CANCELLED;
}
@Override
- public void run() {
+ public void onLongPress(MotionEvent event) {
if (mLongPressState == STATE_REQUESTED) {
if (canHandleLongPress()) {
mLongPressState = STATE_PENDING_PARENT_INFORM;
diff --git a/src/com/android/launcher3/views/FloatingIconView.java b/src/com/android/launcher3/views/FloatingIconView.java
index 7af2bd8..e5c70da 100644
--- a/src/com/android/launcher3/views/FloatingIconView.java
+++ b/src/com/android/launcher3/views/FloatingIconView.java
@@ -50,6 +50,7 @@
import com.android.launcher3.graphics.ShiftedBitmapDrawable;
import com.android.launcher3.icons.LauncherIcons;
import com.android.launcher3.popup.SystemShortcut;
+import com.android.launcher3.shortcuts.DeepShortcutView;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
@@ -197,8 +198,14 @@
// Similar to DragView, we simply use the BubbleTextView icon here.
drawable = ((BubbleTextView) v).getIcon();
}
- if (v instanceof ImageView && info instanceof SystemShortcut) {
- drawable = ((ImageView) v).getDrawable();
+ if (info instanceof SystemShortcut) {
+ if (v instanceof ImageView) {
+ drawable = ((ImageView) v).getDrawable();
+ } else if (v instanceof DeepShortcutView) {
+ drawable = ((DeepShortcutView) v).getIconView().getBackground();
+ } else {
+ drawable = v.getBackground();
+ }
}
if (drawable == null) {
drawable = Utilities.getFullDrawable(launcher, info, lp.width, lp.height,