hide the resizing frame at clicking on the widget
This commit is contained in:
parent
2a5909573d
commit
ecc0243e60
|
@ -178,6 +178,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
val frameRect = Rect(viewX, viewY, viewX + widgetView.width, viewY + widgetView.height)
|
val frameRect = Rect(viewX, viewY, viewX + widgetView.width, viewY + widgetView.height)
|
||||||
resize_frame.updateFrameCoords(frameRect)
|
resize_frame.updateFrameCoords(frameRect)
|
||||||
resize_frame.beVisible()
|
resize_frame.beVisible()
|
||||||
|
widgetView.ignoreTouches = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,8 +187,9 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
resizedWidget = null
|
|
||||||
resize_frame.beGone()
|
resize_frame.beGone()
|
||||||
|
widgetViews.firstOrNull { it.tag == resizedWidget!!.widgetId }?.ignoreTouches = false
|
||||||
|
resizedWidget = null
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun addAppIcon() {
|
private fun addAppIcon() {
|
||||||
|
@ -387,6 +389,10 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||||
(context as? MainActivity)?.showHomeIconMenu(x, widgetView.y, item, false)
|
(context as? MainActivity)?.showHomeIconMenu(x, widgetView.y, item, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
widgetView.onIgnoreInterceptedListener = {
|
||||||
|
hideResizeLines()
|
||||||
|
}
|
||||||
|
|
||||||
widgetView.x = calculateWidgetX(item.left)
|
widgetView.x = calculateWidgetX(item.left)
|
||||||
widgetView.y = calculateWidgetY(item.top)
|
widgetView.y = calculateWidgetY(item.top)
|
||||||
val widgetWidth = item.widthCells * rowWidth
|
val widgetWidth = item.widthCells * rowWidth
|
||||||
|
|
|
@ -16,9 +16,11 @@ class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) {
|
||||||
var hasLongPressed = false
|
var hasLongPressed = false
|
||||||
var ignoreTouches = false
|
var ignoreTouches = false
|
||||||
var longPressListener: ((x: Float, y: Float) -> Unit)? = null
|
var longPressListener: ((x: Float, y: Float) -> Unit)? = null
|
||||||
|
var onIgnoreInterceptedListener: (() -> Unit)? = null // let the home grid react on swallowed clicks, for example by hiding the widget resize frame
|
||||||
|
|
||||||
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
override fun onTouchEvent(event: MotionEvent?): Boolean {
|
||||||
return if (ignoreTouches) {
|
return if (ignoreTouches) {
|
||||||
|
onIgnoreInterceptedListener?.invoke()
|
||||||
true
|
true
|
||||||
} else {
|
} else {
|
||||||
super.onTouchEvent(event)
|
super.onTouchEvent(event)
|
||||||
|
|
Loading…
Reference in New Issue