mirror of
https://github.com/SimpleMobileTools/Simple-Launcher.git
synced 2025-02-16 19:40:41 +01:00
draw 4 dots at the widget resizing frame
This commit is contained in:
parent
288fd804ab
commit
30c5dec1be
@ -179,6 +179,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel
|
||||
val frameRect = Rect(viewX, viewY, viewX + widgetView.width, viewY + widgetView.height)
|
||||
resize_frame.updateFrameCoords(frameRect)
|
||||
resize_frame.beVisible()
|
||||
resize_frame.z = 1f // make sure the frame isnt behind the widget itself
|
||||
resize_frame.onClickListener = {
|
||||
hideResizeLines()
|
||||
}
|
||||
|
@ -10,7 +10,6 @@ import com.simplemobiletools.commons.extensions.performHapticFeedback
|
||||
import com.simplemobiletools.launcher.helpers.MAX_ALLOWED_MOVE_PX
|
||||
|
||||
class MyAppWidgetHostView(context: Context) : AppWidgetHostView(context) {
|
||||
private var MAX_CLICK_DURATION = 150
|
||||
private var longPressHandler = Handler()
|
||||
private var actionDownCoords = PointF()
|
||||
private var currentCoords = PointF()
|
||||
|
@ -15,9 +15,11 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
||||
constructor(context: Context, attrs: AttributeSet) : this(context, attrs, 0)
|
||||
|
||||
private var resizeWidgetLinePaint: Paint
|
||||
private var resizeWidgetLineDotPaint: Paint
|
||||
private var actionDownCoords = PointF()
|
||||
private var actionDownMS = 0L
|
||||
private var MAX_CLICK_DURATION = 150
|
||||
private val lineDotRadius = context.resources.getDimension(R.dimen.resize_frame_dot_radius)
|
||||
var onClickListener: (() -> Unit)? = null
|
||||
|
||||
init {
|
||||
@ -28,6 +30,10 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
||||
strokeWidth = context.resources.getDimension(R.dimen.tiny_margin)
|
||||
style = Paint.Style.STROKE
|
||||
}
|
||||
|
||||
resizeWidgetLineDotPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
|
||||
color = Color.WHITE
|
||||
}
|
||||
}
|
||||
|
||||
fun updateFrameCoords(coords: Rect) {
|
||||
@ -65,7 +71,11 @@ class MyAppWidgetResizeFrame(context: Context, attrs: AttributeSet, defStyle: In
|
||||
override fun onDraw(canvas: Canvas) {
|
||||
super.onDraw(canvas)
|
||||
if (x != 0f || y != 0f) {
|
||||
canvas.drawRect(0f, 0f, width.toFloat(), height.toFloat(), resizeWidgetLinePaint)
|
||||
canvas.drawRect(lineDotRadius, lineDotRadius, width.toFloat() - lineDotRadius, height.toFloat() - lineDotRadius, resizeWidgetLinePaint)
|
||||
canvas.drawCircle(lineDotRadius, height / 2f, lineDotRadius, resizeWidgetLineDotPaint)
|
||||
canvas.drawCircle(width / 2f, lineDotRadius, lineDotRadius, resizeWidgetLineDotPaint)
|
||||
canvas.drawCircle(width - lineDotRadius, height / 2f, lineDotRadius, resizeWidgetLineDotPaint)
|
||||
canvas.drawCircle(width / 2f, height - lineDotRadius, lineDotRadius, resizeWidgetLineDotPaint)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4,4 +4,5 @@
|
||||
<dimen name="long_press_anchor_button_offset_y">50dp</dimen>
|
||||
<dimen name="widget_preview_size">140dp</dimen>
|
||||
<dimen name="icon_side_margin">10dp</dimen>
|
||||
<dimen name="resize_frame_dot_radius">8dp</dimen>
|
||||
</resources>
|
||||
|
Loading…
x
Reference in New Issue
Block a user