mirror of
https://github.com/LawnchairLauncher/lawnchair.git
synced 2026-03-05 18:36:49 +00:00
Long-press on an app to reveal its shortcuts.
- Add ShortcutsContainerListener to icons on workspace, folders, and all apps. This handles long-press and forwards following touches to the DeepShortcutsContainer that is created. - Drag over shortcut before lifting finger to launch it. - Shortcuts are rendered in pill-shaped DeepShortcutViews, which are inside DeepShortcutContainer on DragLayer. - The shortcut container orients above or below the icon, and left or right-aligns with it. Biases for above + left-align. - Long press a DeepShortcutPill to drag and pin it to the workspace. Bug: 28980830 Change-Id: I08658d13ae51fe53064644e8d8f7b42f150fdd7d
This commit is contained in:
@@ -47,7 +47,6 @@ import android.os.Build;
|
||||
import android.os.Build.VERSION;
|
||||
import android.os.Bundle;
|
||||
import android.os.PowerManager;
|
||||
import android.support.v4.os.BuildCompat;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
@@ -57,7 +56,9 @@ import android.util.Log;
|
||||
import android.util.Pair;
|
||||
import android.util.SparseArray;
|
||||
import android.util.TypedValue;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.widget.Toast;
|
||||
|
||||
import com.android.launcher3.compat.UserHandleCompat;
|
||||
@@ -68,8 +69,10 @@ import com.android.launcher3.util.IconNormalizer;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Locale;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executor;
|
||||
@@ -425,6 +428,30 @@ public final class Utilities {
|
||||
localY < (v.getHeight() + slop);
|
||||
}
|
||||
|
||||
/** Translates MotionEvents from src's coordinate system to dst's. */
|
||||
public static void translateEventCoordinates(View src, View dst, MotionEvent dstEvent) {
|
||||
toGlobalMotionEvent(src, dstEvent);
|
||||
toLocalMotionEvent(dst, dstEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emulates View.toGlobalMotionEvent(). This implementation does not handle transformations
|
||||
* (scaleX, scaleY, etc).
|
||||
*/
|
||||
private static void toGlobalMotionEvent(View view, MotionEvent event) {
|
||||
view.getLocationOnScreen(sLoc0);
|
||||
event.offsetLocation(sLoc0[0], sLoc0[1]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Emulates View.toLocalMotionEvent(). This implementation does not handle transformations
|
||||
* (scaleX, scaleY, etc).
|
||||
*/
|
||||
private static void toLocalMotionEvent(View view, MotionEvent event) {
|
||||
view.getLocationOnScreen(sLoc0);
|
||||
event.offsetLocation(-sLoc0[0], -sLoc0[1]);
|
||||
}
|
||||
|
||||
public static int[] getCenterDeltaInScreenSpace(View v0, View v1, int[] delta) {
|
||||
v0.getLocationInWindow(sLoc0);
|
||||
v1.getLocationInWindow(sLoc1);
|
||||
@@ -819,6 +846,11 @@ public final class Utilities {
|
||||
return true;
|
||||
}
|
||||
|
||||
/** Returns whether the collection is null or empty. */
|
||||
public static boolean isEmpty(Collection c) {
|
||||
return c == null || c.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* An extension of {@link BitmapDrawable} which returns the bitmap pixel size as intrinsic size.
|
||||
* This allows the badging to be done based on the action bitmap size rather than
|
||||
|
||||
Reference in New Issue
Block a user