rework the placement of widget menu after long pressing

This commit is contained in:
tibbi 2022-10-01 14:46:27 +02:00
parent 833a3f0529
commit d4b4edd6eb
3 changed files with 3 additions and 6 deletions

View File

@ -316,10 +316,6 @@ class MainActivity : SimpleActivity(), FlingListener {
}
private fun handleGridItemPopupMenu(anchorView: View, gridItem: HomeScreenGridItem, isOnAllAppsFragment: Boolean): PopupMenu {
if (gridItem.type == ITEM_TYPE_WIDGET) {
anchorView.y -= resources.getDimension(R.dimen.home_long_press_anchor_offset_y)
}
val contextTheme = ContextThemeWrapper(this, getPopupMenuTheme())
return PopupMenu(contextTheme, anchorView, Gravity.TOP or Gravity.END).apply {
inflate(R.menu.menu_app_icon)

View File

@ -317,7 +317,8 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
widgetView.tag = appWidgetId
widgetView.setAppWidget(appWidgetId, appWidgetProviderInfo)
widgetView.longPressListener = { x, y ->
(context as? MainActivity)?.showHomeIconMenu(x, y, item, false)
val yOffset = resources.getDimension(R.dimen.home_long_press_anchor_offset_y)
(context as? MainActivity)?.showHomeIconMenu(x, widgetView.y - yOffset, item, false)
}
widgetView.x = item.left * rowWidth + sideMargins.left.toFloat()

View File

@ -1,7 +1,7 @@
<resources>
<dimen name="launcher_icon_size">55dp</dimen>
<dimen name="icon_long_press_anchor_offset_y">150dp</dimen>
<dimen name="home_long_press_anchor_offset_y">50dp</dimen>
<dimen name="home_long_press_anchor_offset_y">40dp</dimen>
<dimen name="widget_preview_size">140dp</dimen>
<dimen name="icon_side_margin">10dp</dimen>
</resources>