From 988c3148ac6a36fddc0f9f5cfeb65fbaf886e069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 21 Sep 2023 10:09:40 +0200 Subject: [PATCH] Draw home screen grid over widgets This closes #131 --- .../launcher/views/HomeScreenGrid.kt | 5 ++--- .../launcher/views/HomeScreenGridDrawingArea.kt | 16 ++++++++++++++++ app/src/main/res/layout/home_screen_grid.xml | 7 +++++++ 3 files changed, 25 insertions(+), 3 deletions(-) create mode 100644 app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGridDrawingArea.kt diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt index df7c7a6..9746f9f 100644 --- a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGrid.kt @@ -920,6 +920,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel post { setWillNotDraw(false) invalidate() + binding.drawingArea.invalidate() } } @@ -927,9 +928,7 @@ class HomeScreenGrid(context: Context, attrs: AttributeSet, defStyle: Int) : Rel private fun getFakeHeight() = height - sideMargins.top - sideMargins.bottom - @SuppressLint("DrawAllocation") - override fun onDraw(canvas: Canvas) { - super.onDraw(canvas) + fun drawInto(canvas: Canvas) { if (cells.isEmpty()) { fillCellSizes() } diff --git a/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGridDrawingArea.kt b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGridDrawingArea.kt new file mode 100644 index 0000000..9186435 --- /dev/null +++ b/app/src/main/kotlin/com/simplemobiletools/launcher/views/HomeScreenGridDrawingArea.kt @@ -0,0 +1,16 @@ +package com.simplemobiletools.launcher.views + +import android.content.Context +import android.graphics.Canvas +import android.util.AttributeSet +import android.view.View + +class HomeScreenGridDrawingArea @JvmOverloads constructor( + context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0 +) : View(context, attrs, defStyleAttr) { + + override fun onDraw(canvas: Canvas) { + super.onDraw(canvas) + (parent as HomeScreenGrid).drawInto(canvas) + } +} diff --git a/app/src/main/res/layout/home_screen_grid.xml b/app/src/main/res/layout/home_screen_grid.xml index c4fb843..7cab991 100644 --- a/app/src/main/res/layout/home_screen_grid.xml +++ b/app/src/main/res/layout/home_screen_grid.xml @@ -4,6 +4,13 @@ android:layout_width="match_parent" android:layout_height="match_parent"> + + +