Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 72fbec17 authored by Mathew Inwood's avatar Mathew Inwood
Browse files

Add support for initiating a drag from an overlay.

This allows an overlay to create apps and shortcuts on the home screen.

Change-Id: I63ee4ef02db3f4bc89726c394fd55ad26f50452c
parent 97436804
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ import java.io.IOException;
/**
 * Represents an item in the launcher.
 */
class ItemInfo {
public class ItemInfo {
    
    static final int NO_ID = -1;
    
+20 −0
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.content.SharedPreferences;
import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.NameNotFoundException;
import android.content.pm.ResolveInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.database.ContentObserver;
@@ -4502,6 +4503,25 @@ public class Launcher extends Activity
                DISMISS_CLING_DURATION, true);
    }

    public ItemInfo createAppDragInfo(Intent appLaunchIntent) {
        ResolveInfo ri = getPackageManager().resolveActivity(appLaunchIntent, 0);
        if (ri == null) {
            return null;
        }
        return new AppInfo(getPackageManager(), ri, mIconCache, null);
    }

    public ItemInfo createShortcutDragInfo(Intent shortcutIntent, CharSequence caption,
            Bitmap icon) {
        return new ShortcutInfo(shortcutIntent, caption, icon);
    }

    public void startDrag(View dragView, ItemInfo dragInfo, DragSource source) {
        dragView.setTag(dragInfo);
        mWorkspace.onDragStartedWithItem(dragView);
        mWorkspace.beginDragShared(dragView, source);
    }

    /**
     * Prints out out state for debugging.
     */
+8 −1
Original line number Diff line number Diff line
@@ -72,6 +72,13 @@ class ShortcutInfo extends ItemInfo {
        return intent;
    }

    ShortcutInfo(Intent intent, CharSequence title, Bitmap icon) {
        this();
        this.intent = intent;
        this.title = title;
        mIcon = icon;
    }

    public ShortcutInfo(Context context, ShortcutInfo info) {
        super(info);
        title = info.title.toString();
+2 −2
Original line number Diff line number Diff line
@@ -43,7 +43,7 @@ import java.util.ArrayList;
/**
 * Various utilities shared amongst the Launcher's classes.
 */
final class Utilities {
public final class Utilities {
    private static final String TAG = "Launcher.Utilities";

    private static int sIconWidth = -1;
@@ -111,7 +111,7 @@ final class Utilities {
    /**
     * Returns a bitmap suitable for the all apps view.
     */
    static Bitmap createIconBitmap(Drawable icon, Context context) {
    public static Bitmap createIconBitmap(Drawable icon, Context context) {
        synchronized (sCanvas) { // we share the statics :-(
            if (sIconWidth == -1) {
                initStatics(context);