diff options
Diffstat (limited to 'src/com/android/launcher3/Hotseat.java')
-rw-r--r-- | src/com/android/launcher3/Hotseat.java | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/src/com/android/launcher3/Hotseat.java b/src/com/android/launcher3/Hotseat.java index 986a89b5d..1f876fd6b 100644 --- a/src/com/android/launcher3/Hotseat.java +++ b/src/com/android/launcher3/Hotseat.java @@ -20,12 +20,11 @@ import android.content.ComponentName; import android.content.Context; import android.content.res.Configuration; import android.content.res.Resources; -import android.graphics.Bitmap; +import android.graphics.Rect; import android.graphics.drawable.Drawable; import android.util.AttributeSet; import android.util.Log; import android.view.LayoutInflater; -import android.view.MotionEvent; import android.view.View; import android.widget.FrameLayout; import android.widget.TextView; @@ -102,6 +101,25 @@ public class Hotseat extends FrameLayout { } } + /** This returns the coordinates of an app in a given cell, relative to the DragLayer */ + Rect getCellCoordinates(int cellX, int cellY) { + Rect coords = new Rect(); + mContent.cellToRect(cellX, cellY, 1, 1, coords); + int[] hotseatInParent = new int[2]; + Utilities.getDescendantCoordRelativeToParent(this, mLauncher.getDragLayer(), + hotseatInParent, false); + coords.offset(hotseatInParent[0], hotseatInParent[1]); + + // Center the icon + int cWidth = mContent.getShortcutsAndWidgets().getCellContentWidth(); + int cHeight = mContent.getShortcutsAndWidgets().getCellContentHeight(); + int cellPaddingX = (int) Math.max(0, ((coords.width() - cWidth) / 2f)); + int cellPaddingY = (int) Math.max(0, ((coords.height() - cHeight) / 2f)); + coords.offset(cellPaddingX, cellPaddingY); + + return coords; + } + @Override protected void onFinishInflate() { super.onFinishInflate(); |