Adding support for overriding long-press menu in Launcher
Bug: 188222480
Test: Manual
Change-Id: Ic0b425fafde8beedc15a5aa42a8897b9143a3309
diff --git a/src/com/android/launcher3/Launcher.java b/src/com/android/launcher3/Launcher.java
index 07c2113..8249887 100644
--- a/src/com/android/launcher3/Launcher.java
+++ b/src/com/android/launcher3/Launcher.java
@@ -80,6 +80,7 @@
import android.database.sqlite.SQLiteDatabase;
import android.graphics.Bitmap;
import android.graphics.Rect;
+import android.graphics.RectF;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
@@ -2870,13 +2871,26 @@
if (Utilities.IS_RUNNING_IN_TEST_HARNESS) {
Log.d(TestProtocol.PERMANENT_DIAG_TAG, "Opening options popup on key up");
}
- OptionsPopupView.showDefaultOptions(this, -1, -1);
+ showDefaultOptions(-1, -1);
}
return true;
}
return super.onKeyUp(keyCode, event);
}
+ /**
+ * Shows the default options popup
+ */
+ public void showDefaultOptions(float x, float y) {
+ float halfSize = getResources().getDimension(R.dimen.options_menu_thumb_size) / 2;
+ if (x < 0 || y < 0) {
+ x = mDragLayer.getWidth() / 2;
+ y = mDragLayer.getHeight() / 2;
+ }
+ RectF target = new RectF(x - halfSize, y - halfSize, x + halfSize, y + halfSize);
+ OptionsPopupView.show(this, target, OptionsPopupView.getOptions(this), false);
+ }
+
@Override
protected void collectStateHandlers(List<StateHandler> out) {
out.add(getAllAppsController());