Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1f0ec709 authored by Kshitij's avatar Kshitij
Browse files

fix: Recalculate wallpaper offset on rotate

parent e6105232
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ class BlurViewDelegate(

    private val context = view.context
    private val blurWallpaperProvider by lazy { BlurWallpaperProvider.getInstanceNoCreate() }
    private var orientation: Int = -1

    private var fullBlurDrawable: BlurDrawable? = null
    var blurAlpha = 255
@@ -222,6 +223,11 @@ class BlurViewDelegate(
    }

    private fun updateOffsets() {
        val newOrientation = context.resources.configuration.orientation
        if (orientation != newOrientation) {
            BlurWallpaperProvider.getInstanceNoCreate().setWallpaperOffset(null)
            orientation = newOrientation
        }
        fullBlurDrawable?.setOffsets(
            previousScrollX.toFloat() + parentOffsetX,
            previousScrollY.toFloat() + parentOffsetY
+6 −1
Original line number Diff line number Diff line
@@ -63,6 +63,8 @@ class BlurWallpaperProvider(val context: Context) {

    private var isLiveWallpaper = false

    private var lastOffset = 0.5f

    init {
        isEnabled = getEnabledStatus()
        updateAsync()
@@ -214,7 +216,10 @@ class BlurWallpaperProvider(val context: Context) {

    fun createBlurDrawable(config: BlurConfig = blurConfigDock) = BlurDrawable(this, config)

    fun setWallpaperOffset(offset: Float) {
    fun setWallpaperOffset(inputOffset: Float?) {
        val offset = inputOffset ?: lastOffset
        lastOffset = offset

        if (!isEnabled) return
        if (wallpapers == null) return