diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-01-25 18:23:36 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-01-27 15:09:10 -0800 |
commit | dec3a908bfa395095e80e4a532cff98612b624de (patch) | |
tree | 77ea2c951253ef5ca2d63655dcd7071f328b41ed /src/com/android/launcher3/compat/LauncherAppsCompat.java | |
parent | 5cfd1158ec1e4a19689217e9fbddd0fd795b2611 (diff) | |
download | android_packages_apps_Trebuchet-dec3a908bfa395095e80e4a532cff98612b624de.tar.gz android_packages_apps_Trebuchet-dec3a908bfa395095e80e4a532cff98612b624de.tar.bz2 android_packages_apps_Trebuchet-dec3a908bfa395095e80e4a532cff98612b624de.zip |
Updating the preview generation logic so that it aligns better with
the drag source image
> Using common code for pending item drag (WidgetContainerView and PinItemDragListener)
> Adding a shortcut-circuit in Workspace when a pendingItem can create a shortcut
directly. Previously the multi-window drop was routing through onActivityResult which
was causing some state information to be lost.
Bug: 33584624
Change-Id: I0259870032185713caa9bff27092dbae6ce91199
Diffstat (limited to 'src/com/android/launcher3/compat/LauncherAppsCompat.java')
-rw-r--r-- | src/com/android/launcher3/compat/LauncherAppsCompat.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/com/android/launcher3/compat/LauncherAppsCompat.java b/src/com/android/launcher3/compat/LauncherAppsCompat.java index 281069af0..b9142ed16 100644 --- a/src/com/android/launcher3/compat/LauncherAppsCompat.java +++ b/src/com/android/launcher3/compat/LauncherAppsCompat.java @@ -23,8 +23,12 @@ import android.content.pm.LauncherActivityInfo; import android.graphics.Rect; import android.os.Bundle; import android.os.UserHandle; +import android.support.annotation.Nullable; +import com.android.launcher3.LauncherAppState; +import com.android.launcher3.ShortcutInfo; import com.android.launcher3.Utilities; +import com.android.launcher3.graphics.LauncherIcons; import com.android.launcher3.shortcuts.ShortcutInfoCompat; import java.util.List; @@ -75,4 +79,38 @@ public abstract class LauncherAppsCompat { public abstract boolean isActivityEnabledForProfile(ComponentName component, UserHandle user); public abstract List<ShortcutConfigActivityInfo> getCustomShortcutActivityList(); + + /** + * request.accept() will initiate the following flow: + * -> go-to-system-process for actual processing (a) + * -> callback-to-launcher on UI thread (b) + * -> post callback on the worker thread (c) + * -> Update model and unpin (in system) any shortcut not in out model. (d) + * + * Note that (b) will take at-least one frame as it involves posting callback from binder + * thread to UI thread. + * If (d) happens before we add this shortcut to our model, we will end up unpinning + * the shortcut in the system. + * Here its the caller's responsibility to add the newly created ShortcutInfo immediately + * to the model (which may involves a single post-to-worker-thread). That will guarantee + * that (d) happens after model is updated. + */ + @Nullable + public static ShortcutInfo createShortcutInfoFromPinItemRequest( + Context context, PinItemRequestCompat request) { + if (request != null && + request.getRequestType() == PinItemRequestCompat.REQUEST_TYPE_SHORTCUT && + request.isValid() && request.accept()) { + ShortcutInfoCompat compat = new ShortcutInfoCompat(request.getShortcutInfo()); + ShortcutInfo info = new ShortcutInfo(compat, context); + // Apply the unbadged icon and fetch the actual icon asynchronously. + info.iconBitmap = LauncherIcons + .createShortcutIcon(compat, context, false /* badged */); + LauncherAppState.getInstance(context).getModel() + .updateAndBindShortcutInfo(info, compat); + return info; + } else { + return null; + } + } } |