diff options
author | Sunny Goyal <sunnygoyal@google.com> | 2017-01-20 19:32:31 -0800 |
---|---|---|
committer | Sunny Goyal <sunnygoyal@google.com> | 2017-01-24 22:24:54 -0800 |
commit | b38fab75735c601b61765ecae61494c8637aaef4 (patch) | |
tree | 02ccb88b0137bf2f5a93db052ae0f4f11983bdf9 /src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java | |
parent | 658058b960ef029fc70f0f3e131057a6ba0d10e2 (diff) | |
download | android_packages_apps_Trebuchet-b38fab75735c601b61765ecae61494c8637aaef4.tar.gz android_packages_apps_Trebuchet-b38fab75735c601b61765ecae61494c8637aaef4.tar.bz2 android_packages_apps_Trebuchet-b38fab75735c601b61765ecae61494c8637aaef4.zip |
Adding support for drag and drop for requestPinItem.
On long pressing, the confirmation activity starts a system
drag-n-drop and focuses the launcher activity. We then drive
the launcher drag controller using the system drag event
Caveats:
> We use a transparent preview for system drag and drop and use
a view inside launcher for actual preview. This gives us better
control over various animations.
> The parameters for drag operation are passed to the Launcher
activity using the intent. Since onNewIntent and onDragEvent
come at different times and are not associated, a random uuid
is used as mime-type to match the drag event with intent params
> If the workspace is locked (eg, loader is running) the drag
operation is simply dropped. Will be imporved in follow up cls
Bug: 33584624
Change-Id: I0bb5b25b690f86b6af31a14e11beb669fcb3a281
Diffstat (limited to 'src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java')
-rw-r--r-- | src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java index d1f878a17..2121b438a 100644 --- a/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java +++ b/src/com/android/launcher3/dragndrop/PinShortcutRequestActivityInfo.java @@ -26,7 +26,9 @@ import android.graphics.drawable.Drawable; import android.os.Build; import com.android.launcher3.IconCache; +import com.android.launcher3.Launcher; import com.android.launcher3.LauncherAppState; +import com.android.launcher3.compat.PinItemRequestCompat; import com.android.launcher3.compat.ShortcutConfigActivityInfo; /** @@ -40,12 +42,15 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo { // actual existing class. private static final String DUMMY_COMPONENT_CLASS = "pinned-shortcut"; + private final PinItemRequestCompat mRequest; private final ShortcutInfo mInfo; private final Context mContext; - public PinShortcutRequestActivityInfo(ShortcutInfo info, Context context) { - super(new ComponentName(info.getPackage(), DUMMY_COMPONENT_CLASS), info.getUserHandle()); - mInfo = info; + public PinShortcutRequestActivityInfo(PinItemRequestCompat request, Context context) { + super(new ComponentName(request.getShortcutInfo().getPackage(), DUMMY_COMPONENT_CLASS), + request.getShortcutInfo().getUserHandle()); + mRequest = request; + mInfo = request.getShortcutInfo(); mContext = context; } @@ -61,8 +66,9 @@ class PinShortcutRequestActivityInfo extends ShortcutConfigActivityInfo { } @Override - public boolean startConfigActivity(Activity activity, int requestCode) { - throw new RuntimeException("Not supported"); + public boolean startConfigActivity(Launcher activity, int requestCode) { + activity.onActivityResult(requestCode, Activity.RESULT_OK, mRequest.toIntent()); + return true; } @Override |