mirror of
https://github.com/jrpie/Launcher.git
synced 2025-05-18 00:11:48 +02:00
fix #156 - show popup over widget
This commit is contained in:
parent
b5b65a4c42
commit
1ba7479469
1 changed files with 9 additions and 3 deletions
|
@ -2,11 +2,13 @@ package de.jrpie.android.launcher.ui.widgets.manage
|
||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.graphics.Canvas
|
import android.graphics.Canvas
|
||||||
|
import android.graphics.Color
|
||||||
import android.graphics.Paint
|
import android.graphics.Paint
|
||||||
import android.graphics.Rect
|
import android.graphics.Rect
|
||||||
import android.graphics.drawable.Drawable
|
import android.graphics.drawable.Drawable
|
||||||
import android.util.AttributeSet
|
import android.util.AttributeSet
|
||||||
import android.view.View
|
import android.view.View
|
||||||
|
import android.view.ViewGroup
|
||||||
import android.widget.PopupMenu
|
import android.widget.PopupMenu
|
||||||
import androidx.core.graphics.toRectF
|
import androidx.core.graphics.toRectF
|
||||||
import de.jrpie.android.launcher.R
|
import de.jrpie.android.launcher.R
|
||||||
|
@ -20,8 +22,9 @@ private const val HANDLE_EDGE_SIZE = (1.2 * HANDLE_SIZE).toInt()
|
||||||
/**
|
/**
|
||||||
* An overlay to show configuration options for a widget in [WidgetManagerView]
|
* An overlay to show configuration options for a widget in [WidgetManagerView]
|
||||||
*/
|
*/
|
||||||
class WidgetOverlayView : View {
|
class WidgetOverlayView : ViewGroup {
|
||||||
|
|
||||||
|
private val popupAnchor = View(context)
|
||||||
|
|
||||||
val paint = Paint()
|
val paint = Paint()
|
||||||
val handlePaint = Paint()
|
val handlePaint = Paint()
|
||||||
|
@ -29,6 +32,8 @@ class WidgetOverlayView : View {
|
||||||
var mode: WidgetManagerView.EditMode? = null
|
var mode: WidgetManagerView.EditMode? = null
|
||||||
class Handle(val mode: WidgetManagerView.EditMode, val position: Rect)
|
class Handle(val mode: WidgetManagerView.EditMode, val position: Rect)
|
||||||
init {
|
init {
|
||||||
|
addView(popupAnchor)
|
||||||
|
setWillNotDraw(false)
|
||||||
handlePaint.style = Paint.Style.STROKE
|
handlePaint.style = Paint.Style.STROKE
|
||||||
handlePaint.setARGB(255, 255, 255, 255)
|
handlePaint.setARGB(255, 255, 255, 255)
|
||||||
|
|
||||||
|
@ -84,12 +89,13 @@ class WidgetOverlayView : View {
|
||||||
//preview?.bounds = bounds
|
//preview?.bounds = bounds
|
||||||
//preview?.draw(canvas)
|
//preview?.draw(canvas)
|
||||||
|
|
||||||
|
override fun onLayout(changed: Boolean, l: Int, t: Int, r: Int, b: Int) {
|
||||||
|
popupAnchor.layout(0,0,0,0)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun showPopupMenu() {
|
fun showPopupMenu() {
|
||||||
val widget = Widget.byId(context, widgetId)?: return
|
val widget = Widget.byId(context, widgetId)?: return
|
||||||
val menu = PopupMenu(context, this)
|
val menu = PopupMenu(context, popupAnchor)
|
||||||
menu.menu.let {
|
menu.menu.let {
|
||||||
it.add(
|
it.add(
|
||||||
context.getString(R.string.widget_menu_remove)
|
context.getString(R.string.widget_menu_remove)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue