diff options
author | Tony Wickham <twickham@google.com> | 2016-04-28 17:39:03 -0700 |
---|---|---|
committer | Tony Wickham <twickham@google.com> | 2016-06-29 17:48:46 -0700 |
commit | 1bce7fd342875be8f7c1f82c8cf21d0199c8d544 (patch) | |
tree | 44871413914606a046e9f4dcf24d3ee3bd1a8756 /src/com/android/launcher3/Utilities.java | |
parent | 3ccedd234acb1534190c596351cf293e8ef4727a (diff) | |
download | android_packages_apps_Trebuchet-1bce7fd342875be8f7c1f82c8cf21d0199c8d544.tar.gz android_packages_apps_Trebuchet-1bce7fd342875be8f7c1f82c8cf21d0199c8d544.tar.bz2 android_packages_apps_Trebuchet-1bce7fd342875be8f7c1f82c8cf21d0199c8d544.zip |
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
Diffstat (limited to 'src/com/android/launcher3/Utilities.java')
-rw-r--r-- | src/com/android/launcher3/Utilities.java | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/src/com/android/launcher3/Utilities.java b/src/com/android/launcher3/Utilities.java index 8b42debcf..cedbe74c7 100644 --- a/src/com/android/launcher3/Utilities.java +++ b/src/com/android/launcher3/Utilities.java @@ -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 |