diff options
-rw-r--r-- | src/com/android/launcher3/BubbleTextView.java | 10 | ||||
-rw-r--r-- | src/com/android/launcher3/ButtonDropTarget.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/DropTarget.java | 3 | ||||
-rw-r--r-- | src/com/android/launcher3/InfoDropTarget.java | 35 | ||||
-rw-r--r-- | src/com/android/launcher3/Launcher.java | 59 | ||||
-rw-r--r-- | src/com/android/launcher3/UninstallDropTarget.java | 158 | ||||
-rw-r--r-- | src/com/android/launcher3/Workspace.java | 44 | ||||
-rw-r--r-- | src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragController.java | 2 | ||||
-rw-r--r-- | src/com/android/launcher3/dragndrop/DragOptions.java | 6 | ||||
-rw-r--r-- | src/com/android/launcher3/folder/Folder.java | 45 | ||||
-rw-r--r-- | src/com/android/launcher3/popup/SystemShortcut.java | 2 |
12 files changed, 163 insertions, 205 deletions
diff --git a/src/com/android/launcher3/BubbleTextView.java b/src/com/android/launcher3/BubbleTextView.java index 485125e03..cd72fbace 100644 --- a/src/com/android/launcher3/BubbleTextView.java +++ b/src/com/android/launcher3/BubbleTextView.java @@ -42,6 +42,7 @@ import android.widget.TextView; import com.android.launcher3.IconCache.IconLoadRequest; import com.android.launcher3.IconCache.ItemInfoUpdateReceiver; +import com.android.launcher3.Launcher.OnResumeCallback; import com.android.launcher3.badge.BadgeInfo; import com.android.launcher3.badge.BadgeRenderer; import com.android.launcher3.folder.FolderIcon; @@ -59,7 +60,7 @@ import java.text.NumberFormat; * because we want to make the bubble taller than the text and TextView's clip is * too aggressive. */ -public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { +public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver, OnResumeCallback { private static final int DISPLAY_WORKSPACE = 0; private static final int DISPLAY_ALL_APPS = 1; @@ -330,6 +331,13 @@ public class BubbleTextView extends TextView implements ItemInfoUpdateReceiver { refreshDrawableState(); } + @Override + public void onLauncherResume() { + // Reset the pressed state of icon that was locked in the press state while activity + // was launching + setStayPressed(false); + } + void clearPressedBackground() { setPressed(false); setStayPressed(false); diff --git a/src/com/android/launcher3/ButtonDropTarget.java b/src/com/android/launcher3/ButtonDropTarget.java index 375930062..ffc2b02e2 100644 --- a/src/com/android/launcher3/ButtonDropTarget.java +++ b/src/com/android/launcher3/ButtonDropTarget.java @@ -215,7 +215,7 @@ public abstract class ButtonDropTarget extends TextView * On drop animate the dropView to the icon. */ @Override - public void onDrop(final DragObject d) { + public void onDrop(final DragObject d, final DragOptions options) { final DragLayer dragLayer = mLauncher.getDragLayer(); final Rect from = new Rect(); dragLayer.getViewRectRelativeToSelf(d.dragView, from); diff --git a/src/com/android/launcher3/DropTarget.java b/src/com/android/launcher3/DropTarget.java index 7d047d748..2307b8924 100644 --- a/src/com/android/launcher3/DropTarget.java +++ b/src/com/android/launcher3/DropTarget.java @@ -19,6 +19,7 @@ package com.android.launcher3; import android.graphics.Rect; import com.android.launcher3.accessibility.DragViewStateAnnouncer; +import com.android.launcher3.dragndrop.DragOptions; import com.android.launcher3.dragndrop.DragView; /** @@ -106,7 +107,7 @@ public interface DropTarget { /** * Handle an object being dropped on the DropTarget */ - void onDrop(DragObject dragObject); + void onDrop(DragObject dragObject, DragOptions options); void onDragEnter(DragObject dragObject); diff --git a/src/com/android/launcher3/InfoDropTarget.java b/src/com/android/launcher3/InfoDropTarget.java index eb6a7045e..f78cde5b8 100644 --- a/src/com/android/launcher3/InfoDropTarget.java +++ b/src/com/android/launcher3/InfoDropTarget.java @@ -49,28 +49,29 @@ public class InfoDropTarget extends UninstallDropTarget { } @Override - public void completeDrop(DragObject d) { - DropTargetResultCallback callback = d.dragSource instanceof DropTargetResultCallback - ? (DropTargetResultCallback) d.dragSource : null; - startDetailsActivityForInfo(d.dragInfo, mLauncher, callback); + protected ComponentName performDropAction(DragObject d) { + return performDropAction(mLauncher, d.dragInfo, null, null); } /** * @return Whether the activity was started. */ public static boolean startDetailsActivityForInfo( - ItemInfo info, Launcher launcher, DropTargetResultCallback callback) { - return startDetailsActivityForInfo(info, launcher, callback, null, null); + ItemInfo info, Launcher launcher, Rect sourceBounds, Bundle opts) { + return performDropAction(launcher, info, sourceBounds, opts) != null; } - public static boolean startDetailsActivityForInfo(ItemInfo info, Launcher launcher, - DropTargetResultCallback callback, Rect sourceBounds, Bundle opts) { + /** + * Performs the drop action and returns the target component for the dragObject or null if + * the action was not performed. + */ + private static ComponentName performDropAction(Context context, ItemInfo info, + Rect sourceBounds, Bundle opts) { if (info instanceof PromiseAppInfo) { PromiseAppInfo promiseAppInfo = (PromiseAppInfo) info; - launcher.startActivity(promiseAppInfo.getMarketIntent()); - return true; + context.startActivity(promiseAppInfo.getMarketIntent()); + return null; } - boolean result = false; ComponentName componentName = null; if (info instanceof AppInfo) { componentName = ((AppInfo) info).componentName; @@ -83,19 +84,15 @@ public class InfoDropTarget extends UninstallDropTarget { } if (componentName != null) { try { - LauncherAppsCompat.getInstance(launcher) + LauncherAppsCompat.getInstance(context) .showAppDetailsForProfile(componentName, info.user, sourceBounds, opts); - result = true; + return componentName; } catch (SecurityException | ActivityNotFoundException e) { - Toast.makeText(launcher, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); + Toast.makeText(context, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); Log.e(TAG, "Unable to launch settings", e); } } - - if (callback != null) { - sendUninstallResult(launcher, result, componentName, info.user, callback); - } - return result; + return null; } @Override diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java index ba31926c2..1e3626d75 100644 --- a/src/com/android/launcher3/Launcher.java +++ b/src/com/android/launcher3/Launcher.java @@ -263,7 +263,8 @@ public class Launcher extends BaseActivity private boolean mOnResumeNeedsLoad; private final ArrayList<Runnable> mBindOnResumeCallbacks = new ArrayList<>(); - private final ArrayList<Runnable> mOnResumeCallbacks = new ArrayList<>(); + private OnResumeCallback mOnResumeCallback; + private ViewOnDrawExecutor mPendingExecutor; private LauncherModel mModel; @@ -288,11 +289,6 @@ public class Launcher extends BaseActivity // it from the context. private SharedPreferences mSharedPrefs; - // This is set to the view that launched the activity that navigated the user away from - // launcher. Since there is no callback for when the activity has finished launching, enable - // the press state and keep this reference to reset the press state when we return to launcher. - private BubbleTextView mWaitingForResume; - // Exiting spring loaded mode happens with a delay. This runnable object triggers the // state transition. If another state transition happened during this delay, // simply unregister this runnable. @@ -887,19 +883,8 @@ public class Launcher extends BaseActivity } mBindOnResumeCallbacks.clear(); } - if (mOnResumeCallbacks.size() > 0) { - for (int i = 0; i < mOnResumeCallbacks.size(); i++) { - mOnResumeCallbacks.get(i).run(); - } - mOnResumeCallbacks.clear(); - } - // Reset the pressed state of icons that were locked in the press state while activities - // were launching - if (mWaitingForResume != null) { - // Resets the previous workspace icon press state - mWaitingForResume.setStayPressed(false); - } + setOnResumeCallback(null); updateInteraction(Workspace.State.NORMAL, mWorkspace.getState()); @@ -2127,11 +2112,7 @@ public class Launcher extends BaseActivity private void startMarketIntentForPackage(View v, String packageName) { ItemInfo item = (ItemInfo) v.getTag(); Intent intent = PackageManagerHelper.getMarketIntent(packageName); - boolean success = startActivitySafely(v, intent, item); - if (success && v instanceof BubbleTextView) { - mWaitingForResume = (BubbleTextView) v; - mWaitingForResume.setStayPressed(true); - } + startActivitySafely(v, intent, item); } /** @@ -2201,13 +2182,8 @@ public class Launcher extends BaseActivity if (intent == null) { throw new IllegalArgumentException("Input must have a valid intent"); } - boolean success = startActivitySafely(v, intent, item); + startActivitySafely(v, intent, item); getUserEventDispatcher().logAppLaunch(v, intent); // TODO for discovered apps b/35802115 - - if (success && v instanceof BubbleTextView) { - mWaitingForResume = (BubbleTextView) v; - mWaitingForResume.setStayPressed(true); - } } /** @@ -2438,6 +2414,16 @@ public class Launcher extends BaseActivity LauncherAppsCompat.getInstance(this).startActivityForProfile( intent.getComponent(), user, intent.getSourceBounds(), optsBundle); } + + if (v instanceof BubbleTextView) { + // This is set to the view that launched the activity that navigated the user away + // from launcher. Since there is no callback for when the activity has finished + // launching, enable the press state and keep this reference to reset the press + // state when we return to launcher. + BubbleTextView btv = (BubbleTextView) v; + btv.setStayPressed(true); + setOnResumeCallback(btv); + } return true; } catch (ActivityNotFoundException|SecurityException e) { Toast.makeText(this, R.string.activity_not_found, Toast.LENGTH_SHORT).show(); @@ -2831,8 +2817,11 @@ public class Launcher extends BaseActivity } } - public void addOnResumeCallback(Runnable run) { - mOnResumeCallbacks.add(run); + public void setOnResumeCallback(OnResumeCallback callback) { + if (mOnResumeCallback != null) { + mOnResumeCallback.onLauncherResume(); + } + mOnResumeCallback = callback; } /** @@ -3710,4 +3699,12 @@ public class Launcher extends BaseActivity } } } + + /** + * Callback for listening for onResume + */ + public interface OnResumeCallback { + + void onLauncherResume(); + } } diff --git a/src/com/android/launcher3/UninstallDropTarget.java b/src/com/android/launcher3/UninstallDropTarget.java index 3f7de0604..e8c452877 100644 --- a/src/com/android/launcher3/UninstallDropTarget.java +++ b/src/com/android/launcher3/UninstallDropTarget.java @@ -12,9 +12,13 @@ import android.os.UserHandle; import android.os.UserManager; import android.util.AttributeSet; import android.util.Log; +import android.view.View; import android.widget.Toast; +import com.android.launcher3.Launcher.OnResumeCallback; import com.android.launcher3.compat.LauncherAppsCompat; +import com.android.launcher3.dragndrop.DragOptions; +import com.android.launcher3.userevent.nano.LauncherLogProto.Target; import java.net.URISyntaxException; @@ -91,98 +95,110 @@ public class UninstallDropTarget extends ButtonDropTarget { } @Override - public void onDrop(DragObject d) { - // Differ item deletion - if (d.dragSource instanceof DropTargetSource) { - ((DropTargetSource) d.dragSource).deferCompleteDropAfterUninstallActivity(); + public void onDrop(DragObject d, DragOptions options) { + // Defer onComplete + if (options.deferCompleteForUninstall) { + d.dragSource = new DeferredOnComplete(d.dragSource, getContext()); } - super.onDrop(d); + super.onDrop(d, options); } @Override public void completeDrop(final DragObject d) { - DropTargetResultCallback callback = d.dragSource instanceof DropTargetResultCallback - ? (DropTargetResultCallback) d.dragSource : null; - startUninstallActivity(mLauncher, d.dragInfo, callback); + ComponentName target = performDropAction(d); + if (d.dragSource instanceof DeferredOnComplete) { + DeferredOnComplete deferred = (DeferredOnComplete) d.dragSource; + if (target != null) { + deferred.mPackageName = target.getPackageName(); + mLauncher.setOnResumeCallback(deferred); + } else { + deferred.sendFailure(); + } + } } - public static boolean startUninstallActivity(Launcher launcher, ItemInfo info) { - return startUninstallActivity(launcher, info, null); + /** + * Performs the drop action and returns the target component for the dragObject or null if + * the action was not performed. + */ + protected ComponentName performDropAction(DragObject d) { + return performDropAction(mLauncher, d.dragInfo); } - public static boolean startUninstallActivity( - final Launcher launcher, ItemInfo info, DropTargetResultCallback callback) { - final ComponentName cn = getUninstallTarget(launcher, info); - - boolean canUninstall; + /** + * Performs the drop action and returns the target component for the dragObject or null if + * the action was not performed. + */ + private static ComponentName performDropAction(Context context, ItemInfo info) { + ComponentName cn = getUninstallTarget(context, info); if (cn == null) { // System applications cannot be installed. For now, show a toast explaining that. // We may give them the option of disabling apps this way. - Toast.makeText(launcher, R.string.uninstall_system_app_text, Toast.LENGTH_SHORT).show(); - canUninstall = false; - } else { - try { - Intent i = Intent.parseUri(launcher.getString(R.string.delete_package_intent), 0) - .setData(Uri.fromParts("package", cn.getPackageName(), cn.getClassName())) - .putExtra(Intent.EXTRA_USER, info.user); - launcher.startActivity(i); - canUninstall = true; - } catch (URISyntaxException e) { - Log.e(TAG, "Failed to parse intent to start uninstall activity for item=" + info); - canUninstall = false; - } + Toast.makeText(context, R.string.uninstall_system_app_text, Toast.LENGTH_SHORT).show(); + return null; } - if (callback != null) { - sendUninstallResult(launcher, canUninstall, cn, info.user, callback); + try { + Intent i = Intent.parseUri(context.getString(R.string.delete_package_intent), 0) + .setData(Uri.fromParts("package", cn.getPackageName(), cn.getClassName())) + .putExtra(Intent.EXTRA_USER, info.user); + context.startActivity(i); + return cn; + } catch (URISyntaxException e) { + Log.e(TAG, "Failed to parse intent to start uninstall activity for item=" + info); + return null; } - return canUninstall; + } + + public static boolean startUninstallActivity(Launcher launcher, ItemInfo info) { + return performDropAction(launcher, info) != null; } /** - * Notifies the {@param callback} whether the uninstall was successful or not. - * - * Since there is no direct callback for an uninstall request, we check the package existence - * when the launch resumes next time. This assumes that the uninstall activity will finish only - * after the task is completed + * A wrapper around {@link DragSource} which delays the {@link #onDropCompleted} action until + * {@link #onLauncherResume} */ - protected static void sendUninstallResult( - final Launcher launcher, boolean activityStarted, - final ComponentName cn, final UserHandle user, - final DropTargetResultCallback callback) { - if (activityStarted) { - final Runnable checkIfUninstallWasSuccess = new Runnable() { - @Override - public void run() { - // We use MATCH_UNINSTALLED_PACKAGES as the app can be on SD card as well. - boolean uninstallSuccessful = LauncherAppsCompat.getInstance(launcher) - .getApplicationInfo(cn.getPackageName(), - PackageManager.MATCH_UNINSTALLED_PACKAGES, user) == null; - callback.onDragObjectRemoved(uninstallSuccessful); - } - }; - launcher.addOnResumeCallback(checkIfUninstallWasSuccess); - } else { - callback.onDragObjectRemoved(false); + private class DeferredOnComplete implements DragSource, OnResumeCallback { + + private final DragSource mOriginal; + private final Context mContext; + + private String mPackageName; + private DragObject mDragObject; + + public DeferredOnComplete(DragSource original, Context context) { + mOriginal = original; + mContext = context; } - } - public interface DropTargetResultCallback { - /** - * A drag operation was complete. - * @param isRemoved true if the drag object should be removed, false otherwise. - */ - void onDragObjectRemoved(boolean isRemoved); - } + @Override + public void onDropCompleted(View target, DragObject d, boolean isFlingToDelete, + boolean success) { + mDragObject = d; + } - /** - * Interface defining an object that can provide uninstallable drag objects. - */ - public interface DropTargetSource extends DropTargetResultCallback { + @Override + public void fillInLogContainerData(View v, ItemInfo info, Target target, + Target targetParent) { + mOriginal.fillInLogContainerData(v, info, target, targetParent); + } + + @Override + public void onLauncherResume() { + // We use MATCH_UNINSTALLED_PACKAGES as the app can be on SD card as well. + if (LauncherAppsCompat.getInstance(mContext) + .getApplicationInfo(mPackageName, PackageManager.MATCH_UNINSTALLED_PACKAGES, + mDragObject.dragInfo.user) == null) { + mDragObject.dragSource = mOriginal; + mOriginal.onDropCompleted(UninstallDropTarget.this, mDragObject, false, true); + } else { + sendFailure(); + } + } - /** - * Indicates that an uninstall request are made and the actual result may come - * after some time. - */ - void deferCompleteDropAfterUninstallActivity(); + public void sendFailure() { + mDragObject.dragSource = mOriginal; + mDragObject.cancelled = true; + mOriginal.onDropCompleted(UninstallDropTarget.this, mDragObject, false, false); + } } } diff --git a/src/com/android/launcher3/Workspace.java b/src/com/android/launcher3/Workspace.java index fff075ef1..9794e31bf 100644 --- a/src/com/android/launcher3/Workspace.java +++ b/src/com/android/launcher3/Workspace.java @@ -55,7 +55,6 @@ import android.widget.Toast; import com.android.launcher3.Launcher.LauncherOverlay; import com.android.launcher3.LauncherAppWidgetHost.ProviderChangedListener; -import com.android.launcher3.UninstallDropTarget.DropTargetSource; import com.android.launcher3.accessibility.AccessibleDragListenerAdapter; import com.android.launcher3.accessibility.OverviewAccessibilityDelegate; import com.android.launcher3.accessibility.OverviewScreenAccessibilityDelegate; @@ -99,7 +98,7 @@ import java.util.Set; public class Workspace extends PagedView implements DropTarget, DragSource, View.OnTouchListener, DragController.DragListener, ViewGroup.OnHierarchyChangeListener, - Insettable, DropTargetSource { + Insettable { private static final String TAG = "Launcher.Workspace"; /** The value that {@link #mTransitionProgress} must be greater than for @@ -280,10 +279,6 @@ public class Workspace extends PagedView private float mCurrentScale; private float mTransitionProgress; - @Thunk Runnable mDeferredAction; - private boolean mDeferDropAfterUninstall; - private boolean mUninstallSuccessful; - // State related to Launcher Overlay LauncherOverlay mLauncherOverlay; boolean mScrollInteractionBegan; @@ -466,7 +461,6 @@ public class Workspace extends PagedView InstallShortcutReceiver.FLAG_DRAG_AND_DROP, getContext()); mOutlineProvider = null; - mDragInfo = null; mDragSourceInternal = null; mLauncher.onInteractionEnd(); } @@ -1752,6 +1746,7 @@ public class Workspace extends PagedView } }); } + options.deferCompleteForUninstall = true; beginDragShared(child, this, options); } @@ -2050,7 +2045,7 @@ public class Workspace extends PagedView @Override public void prepareAccessibilityDrop() { } - public void onDrop(final DragObject d) { + public void onDrop(final DragObject d, DragOptions options) { mDragViewVisualCenter = d.getVisualCenter(mDragViewVisualCenter); CellLayout dropTargetLayout = mDropToLayout; @@ -3093,21 +3088,8 @@ public class Workspace extends PagedView */ public void onDropCompleted(final View target, final DragObject d, final boolean isFlingToDelete, final boolean success) { - if (mDeferDropAfterUninstall) { - final CellLayout.CellInfo dragInfo = mDragInfo; - mDeferredAction = new Runnable() { - public void run() { - mDragInfo = dragInfo; // Restore the drag info that was cleared in onDragEnd() - onDropCompleted(target, d, isFlingToDelete, success); - mDeferredAction = null; - } - }; - return; - } - - boolean beingCalledAfterUninstall = mDeferredAction != null; - if (success && !(beingCalledAfterUninstall && !mUninstallSuccessful)) { + if (success) { if (target != this && mDragInfo != null) { removeWorkspaceItem(mDragInfo.cell); } @@ -3121,8 +3103,7 @@ public class Workspace extends PagedView + "Workspace#onDropCompleted. Please file a bug. "); } } - if ((d.cancelled || (beingCalledAfterUninstall && !mUninstallSuccessful)) - && mDragInfo != null && mDragInfo.cell != null) { + if (d.cancelled && mDragInfo != null && mDragInfo.cell != null) { mDragInfo.cell.setVisibility(VISIBLE); } mDragInfo = null; @@ -3169,21 +3150,6 @@ public class Workspace extends PagedView }); } - @Override - public void deferCompleteDropAfterUninstallActivity() { - mDeferDropAfterUninstall = true; - } - - /// maybe move this into a smaller part - @Override - public void onDragObjectRemoved(boolean success) { - mDeferDropAfterUninstall = false; - mUninstallSuccessful = success; - if (mDeferredAction != null) { - mDeferredAction.run(); - } - } - public boolean isDropEnabled() { return true; } diff --git a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java index c695758b2..583492e5a 100644 --- a/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java +++ b/src/com/android/launcher3/accessibility/LauncherAccessibilityDelegate.java @@ -152,7 +152,7 @@ public class LauncherAccessibilityDelegate extends AccessibilityDelegate impleme DeleteDropTarget.removeWorkspaceOrFolderItem(mLauncher, item, host); return true; } else if (action == INFO) { - InfoDropTarget.startDetailsActivityForInfo(item, mLauncher, null); + InfoDropTarget.startDetailsActivityForInfo(item, mLauncher, null, null); return true; } else if (action == UNINSTALL) { return UninstallDropTarget.startUninstallActivity(mLauncher, item); diff --git a/src/com/android/launcher3/dragndrop/DragController.java b/src/com/android/launcher3/dragndrop/DragController.java index a7ed87fb6..db8f903af 100644 --- a/src/com/android/launcher3/dragndrop/DragController.java +++ b/src/com/android/launcher3/dragndrop/DragController.java @@ -575,7 +575,7 @@ public class DragController implements DragDriver.EventListener, TouchController if (flingAnimation != null) { flingAnimation.run(); } else if (!mIsInPreDrag) { - dropTarget.onDrop(mDragObject); + dropTarget.onDrop(mDragObject, mOptions); } accepted = true; } diff --git a/src/com/android/launcher3/dragndrop/DragOptions.java b/src/com/android/launcher3/dragndrop/DragOptions.java index f108f8b53..550f94830 100644 --- a/src/com/android/launcher3/dragndrop/DragOptions.java +++ b/src/com/android/launcher3/dragndrop/DragOptions.java @@ -38,6 +38,12 @@ public class DragOptions { public float intrinsicIconScaleFactor = 1f; /** + * Whether or not to defer {@link com.android.launcher3.DragSource#onDropCompleted} until + * uninstall result is available when dropped on uninstall drop target. + */ + public boolean deferCompleteForUninstall = false; + + /** * Specifies a condition that must be met before DragListener#onDragStart() is called. * By default, there is no condition and onDragStart() is called immediately following * DragController#startDrag(). diff --git a/src/com/android/launcher3/folder/Folder.java b/src/com/android/launcher3/folder/Folder.java index e182da140..8d75db4f9 100644 --- a/src/com/android/launcher3/folder/Folder.java +++ b/src/com/android/launcher3/folder/Folder.java @@ -58,7 +58,6 @@ import com.android.launcher3.OnAlarmListener; import com.android.launcher3.PagedView; import com.android.launcher3.R; import com.android.launcher3.ShortcutInfo; -import com.android.launcher3.UninstallDropTarget.DropTargetSource; import com.android.launcher3.Utilities; import com.android.launcher3.Workspace.ItemOperator; import com.android.launcher3.accessibility.AccessibleDragListenerAdapter; @@ -84,8 +83,7 @@ import java.util.List; */ public class Folder extends AbstractFloatingView implements DragSource, View.OnClickListener, View.OnLongClickListener, DropTarget, FolderListener, TextView.OnEditorActionListener, - View.OnFocusChangeListener, DragListener, DropTargetSource, - ExtendedEditText.OnBackKeyListener { + View.OnFocusChangeListener, DragListener, ExtendedEditText.OnBackKeyListener { private static final String TAG = "Launcher.Folder"; /** @@ -172,10 +170,6 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC @ViewDebug.ExportedProperty(category = "launcher") private boolean mDestroyed; - @Thunk Runnable mDeferredAction; - private boolean mDeferDropAfterUninstall; - private boolean mUninstallSuccessful; - // Folder scrolling private int mScrollAreaOffset; @@ -289,6 +283,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC } }); } + options.deferCompleteForUninstall = true; mLauncher.getWorkspace().beginDragShared(v, this, options); } @@ -856,22 +851,8 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC public void onDropCompleted(final View target, final DragObject d, final boolean isFlingToDelete, final boolean success) { - if (mDeferDropAfterUninstall) { - Log.d(TAG, "Deferred handling drop because waiting for uninstall."); - mDeferredAction = new Runnable() { - public void run() { - onDropCompleted(target, d, isFlingToDelete, success); - mDeferredAction = null; - } - }; - return; - } - - boolean beingCalledAfterUninstall = mDeferredAction != null; - boolean successfulDrop = - success && (!beingCalledAfterUninstall || mUninstallSuccessful); - if (successfulDrop) { + if (success) { if (mDeleteFolderOnDropCompleted && !mItemAddedBackToSelfViaIcon && target != this) { replaceFolderWithFinalItem(); } @@ -893,7 +874,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC if (target != this) { if (mOnExitAlarm.alarmPending()) { mOnExitAlarm.cancelAlarm(); - if (!successfulDrop) { + if (!success) { mSuppressFolderDeletion = true; } mScrollPauseAlarm.cancelAlarm(); @@ -920,25 +901,11 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC if (!isFlingToDelete) { // Fling to delete already exits spring loaded mode after the animation finishes. - mLauncher.exitSpringLoadedDragModeDelayed(successfulDrop, + mLauncher.exitSpringLoadedDragModeDelayed(success, Launcher.EXIT_SPRINGLOADED_MODE_SHORT_TIMEOUT, null); } } - @Override - public void deferCompleteDropAfterUninstallActivity() { - mDeferDropAfterUninstall = true; - } - - @Override - public void onDragObjectRemoved(boolean success) { - mDeferDropAfterUninstall = false; - mUninstallSuccessful = success; - if (mDeferredAction != null) { - mDeferredAction.run(); - } - } - private void updateItemLocationsInDatabaseBatch() { ArrayList<View> list = getItemsInReadingOrder(); ArrayList<ItemInfo> items = new ArrayList<ItemInfo>(); @@ -1190,7 +1157,7 @@ public class Folder extends AbstractFloatingView implements DragSource, View.OnC } } - public void onDrop(DragObject d) { + public void onDrop(DragObject d, DragOptions options) { Runnable cleanUpRunnable = null; // If we are coming from All Apps space, we defer removing the extra empty screen diff --git a/src/com/android/launcher3/popup/SystemShortcut.java b/src/com/android/launcher3/popup/SystemShortcut.java index a34250076..3f7bf4214 100644 --- a/src/com/android/launcher3/popup/SystemShortcut.java +++ b/src/com/android/launcher3/popup/SystemShortcut.java @@ -92,7 +92,7 @@ public abstract class SystemShortcut extends ItemInfo { public void onClick(View view) { Rect sourceBounds = launcher.getViewBounds(view); Bundle opts = launcher.getActivityLaunchOptions(view); - InfoDropTarget.startDetailsActivityForInfo(itemInfo, launcher, null, sourceBounds, opts); + InfoDropTarget.startDetailsActivityForInfo(itemInfo, launcher, sourceBounds, opts); launcher.getUserEventDispatcher().logActionOnControl(Action.Touch.TAP, ControlType.APPINFO_TARGET, view); } |