fixing some haptic feedback

This commit is contained in:
tibbi 2022-10-01 22:10:43 +02:00
parent 3c85d89dad
commit 21a1367fc2
3 changed files with 10 additions and 1 deletions

View File

@ -271,12 +271,17 @@ class MainActivity : SimpleActivity(), FlingListener {
mIgnoreMoveEvents = true
val clickedGridItem = home_screen_grid.isClickingGridItem(x.toInt(), y.toInt())
if (clickedGridItem != null) {
if (clickedGridItem.type == ITEM_TYPE_ICON) {
main_holder.performHapticFeedback()
}
val yOffset = resources.getDimension(R.dimen.long_press_anchor_button_offset_y)
val anchorY = home_screen_grid.sideMargins.top + (clickedGridItem.top * home_screen_grid.rowHeight.toFloat()) - yOffset
showHomeIconMenu(x, anchorY, clickedGridItem, false)
return
}
main_holder.performHapticFeedback()
showMainLongPressMenu(x, y)
}

View File

@ -142,6 +142,10 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
// figure out at which cell was the item dropped, if it is empty
fun itemDraggingStopped() {
widgetViews.forEach {
it.hasLongPressed = false
}
if (draggedItem == null) {
return
}

View File

@ -10,8 +10,8 @@ import com.simplemobiletools.commons.extensions.performHapticFeedback
class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) {
private var longPressHandler = Handler()
private var hasLongPressed = false
private var actionDownCoords = PointF()
var hasLongPressed = false
var longPressListener: ((x: Float, y: Float) -> Unit)? = null
override fun onInterceptTouchEvent(event: MotionEvent): Boolean {