diff --git a/app/src/foss/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA14.kt b/app/src/foss/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA14.kt index 7a588848b..32b73fbe3 100644 --- a/app/src/foss/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA14.kt +++ b/app/src/foss/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA14.kt @@ -27,7 +27,7 @@ import com.drdisagree.iconify.R import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_FAILURE import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_SUBJECT import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_SUCCESS -import com.drdisagree.iconify.data.common.Const.ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY +import com.drdisagree.iconify.xposed.modules.lockscreen.AlbumArt.Companion.addAlbumArtVisibilityListener import com.drdisagree.iconify.data.common.Const.AI_PLUGIN_PACKAGE import com.drdisagree.iconify.data.common.Const.SYSTEMUI_PACKAGE import com.drdisagree.iconify.data.common.Preferences.CUSTOM_DEPTH_WALLPAPER_SWITCH @@ -89,14 +89,7 @@ class DepthWallpaperA14(context: Context) : ModPack(context) { private var wallpaperProcessorThread: Thread? = null private var shouldShowForeground = true - private var mBroadcastRegistered = false - private val mReceiver: BroadcastReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context?, intent: Intent?) { - if (intent?.action == ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) { - updateForegroundVisibility() - } - } - } + private var mAlbumArtListenerRegistered = false override fun updatePrefs(vararg key: String) { Xprefs.apply { @@ -131,26 +124,12 @@ class DepthWallpaperA14(context: Context) : ModPack(context) { @SuppressLint("UnspecifiedRegisterReceiverFlag", "NewApi") override fun handleLoadPackage(loadPackageParam: LoadPackageParam) { - // Receiver to handle foreground visibility - if (!mBroadcastRegistered) { - val intentFilter = IntentFilter().apply { - addAction(ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - mContext.registerReceiver( - mReceiver, - intentFilter, - Context.RECEIVER_EXPORTED - ) - } else { - mContext.registerReceiver( - mReceiver, - intentFilter - ) + // Listen for album art visibility changes directly (in-process) + if (!mAlbumArtListenerRegistered) { + addAlbumArtVisibilityListener { + updateForegroundVisibility() } - - mBroadcastRegistered = true + mAlbumArtListenerRegistered = true } mPluginReceiver = object : BroadcastReceiver() { diff --git a/app/src/foss/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA15.kt b/app/src/foss/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA15.kt index f4e46ebd2..cd99295ca 100644 --- a/app/src/foss/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA15.kt +++ b/app/src/foss/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA15.kt @@ -28,7 +28,7 @@ import com.drdisagree.iconify.R import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_FAILURE import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_SUBJECT import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_SUCCESS -import com.drdisagree.iconify.data.common.Const.ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY +import com.drdisagree.iconify.xposed.modules.lockscreen.AlbumArt.Companion.addAlbumArtVisibilityListener import com.drdisagree.iconify.data.common.Const.AI_PLUGIN_PACKAGE import com.drdisagree.iconify.data.common.Const.SYSTEMUI_PACKAGE import com.drdisagree.iconify.data.common.Preferences.CUSTOM_DEPTH_WALLPAPER_SWITCH @@ -103,14 +103,7 @@ class DepthWallpaperA15(context: Context) : ModPack(context) { ) private var shouldShowForeground = true - private var mBroadcastRegistered = false - private val mReceiver: BroadcastReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context?, intent: Intent?) { - if (intent?.action == ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) { - updateForegroundVisibility() - } - } - } + private var mAlbumArtListenerRegistered = false override fun updatePrefs(vararg key: String) { Xprefs.apply { @@ -145,26 +138,12 @@ class DepthWallpaperA15(context: Context) : ModPack(context) { @SuppressLint("UnspecifiedRegisterReceiverFlag", "NewApi") override fun handleLoadPackage(loadPackageParam: LoadPackageParam) { - // Receiver to handle foreground visibility - if (!mBroadcastRegistered) { - val intentFilter = IntentFilter().apply { - addAction(ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - mContext.registerReceiver( - mReceiver, - intentFilter, - Context.RECEIVER_EXPORTED - ) - } else { - mContext.registerReceiver( - mReceiver, - intentFilter - ) + // Listen for album art visibility changes directly (in-process) + if (!mAlbumArtListenerRegistered) { + addAlbumArtVisibilityListener { + updateForegroundVisibility() } - - mBroadcastRegistered = true + mAlbumArtListenerRegistered = true } mPluginReceiver = object : BroadcastReceiver() { diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/modules/lockscreen/AlbumArt.kt b/app/src/main/java/com/drdisagree/iconify/xposed/modules/lockscreen/AlbumArt.kt index 4405fc018..8e480845a 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/modules/lockscreen/AlbumArt.kt +++ b/app/src/main/java/com/drdisagree/iconify/xposed/modules/lockscreen/AlbumArt.kt @@ -2,7 +2,6 @@ package com.drdisagree.iconify.xposed.modules.lockscreen import android.annotation.SuppressLint import android.content.Context -import android.content.Intent import android.graphics.drawable.Drawable import android.graphics.drawable.Icon import android.media.session.PlaybackState @@ -10,7 +9,6 @@ import android.view.View import android.view.ViewGroup import android.widget.FrameLayout import android.widget.ImageView -import com.drdisagree.iconify.data.common.Const.ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY import com.drdisagree.iconify.data.common.Const.SYSTEMUI_PACKAGE import com.drdisagree.iconify.data.common.Preferences.ALBUM_ART_ON_LOCKSCREEN import com.drdisagree.iconify.data.common.Preferences.ALBUM_ART_ON_LOCKSCREEN_BLUR @@ -168,13 +166,7 @@ class AlbumArt(context: Context) : ModPack(context) { } private fun broadcastAlbumArtUpdate() { - Thread { - mContext.sendBroadcast( - Intent(ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY).apply { - setFlags(Intent.FLAG_RECEIVER_FOREGROUND) - } - ) - }.start() + albumArtListeners.forEach { it.onAlbumArtVisibilityChanged() } } private fun updateAlbumArtState() { @@ -248,8 +240,18 @@ class AlbumArt(context: Context) : ModPack(context) { } } + fun interface AlbumArtVisibilityListener { + fun onAlbumArtVisibilityChanged() + } + companion object { private var showAlbumArt: Boolean = false val shouldShowAlbumArt: Boolean get() = showAlbumArt + + private val albumArtListeners = mutableListOf() + + fun addAlbumArtVisibilityListener(listener: AlbumArtVisibilityListener) { + albumArtListeners.add(listener) + } } } \ No newline at end of file diff --git a/app/src/main/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaper.kt b/app/src/main/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaper.kt index 30c3720dd..a28c97566 100644 --- a/app/src/main/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaper.kt +++ b/app/src/main/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaper.kt @@ -1,10 +1,7 @@ package com.drdisagree.iconify.xposed.modules.lockscreen.depthwallpaper import android.annotation.SuppressLint -import android.content.BroadcastReceiver import android.content.Context -import android.content.Intent -import android.content.IntentFilter import android.graphics.ImageDecoder import android.graphics.drawable.AnimatedImageDrawable import android.graphics.drawable.Drawable @@ -20,8 +17,8 @@ import android.widget.FrameLayout import android.widget.ImageView import android.widget.LinearLayout import android.widget.TextView -import com.drdisagree.iconify.data.common.Const.ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY import com.drdisagree.iconify.data.common.Const.SYSTEMUI_PACKAGE +import com.drdisagree.iconify.xposed.modules.lockscreen.AlbumArt.Companion.addAlbumArtVisibilityListener import com.drdisagree.iconify.data.common.Preferences.DEPTH_WALLPAPER_BACKGROUND_MOVEMENT_MULTIPLIER import com.drdisagree.iconify.data.common.Preferences.DEPTH_WALLPAPER_CHANGED import com.drdisagree.iconify.data.common.Preferences.DEPTH_WALLPAPER_FADE_ANIMATION @@ -62,19 +59,7 @@ class DepthWallpaper(context: Context) : ModPack(context) { private var unzoomWallpaper = false private var foregroundAlpha = 1.0f - private var mBroadcastRegistered = false - private val mReceiver: BroadcastReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context?, intent: Intent?) { - if (intent?.action == ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) { - // Hide foreground when album art is showing - if (showDepthWallpaper && !shouldShowAlbumArt) { - mDepthWallpaperForeground?.visibility = View.VISIBLE - } else { - mDepthWallpaperForeground?.visibility = View.GONE - } - } - } - } + private var mAlbumArtListenerRegistered = false override fun updatePrefs(vararg key: String) { Xprefs.apply { @@ -104,26 +89,16 @@ class DepthWallpaper(context: Context) : ModPack(context) { @SuppressLint("UnspecifiedRegisterReceiverFlag") override fun handleLoadPackage(loadPackageParam: LoadPackageParam) { - // Receiver to handle foreground visibility - if (!mBroadcastRegistered) { - val intentFilter = IntentFilter().apply { - addAction(ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - mContext.registerReceiver( - mReceiver, - intentFilter, - Context.RECEIVER_EXPORTED - ) - } else { - mContext.registerReceiver( - mReceiver, - intentFilter - ) + // Listen for album art visibility changes directly (in-process) + if (!mAlbumArtListenerRegistered) { + addAlbumArtVisibilityListener { + if (showDepthWallpaper && !shouldShowAlbumArt) { + mDepthWallpaperForeground?.visibility = View.VISIBLE + } else { + mDepthWallpaperForeground?.visibility = View.GONE + } } - - mBroadcastRegistered = true + mAlbumArtListenerRegistered = true } val keyguardBottomAreaViewClass = diff --git a/app/src/standard/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA14.kt b/app/src/standard/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA14.kt index ff067bba0..b9d8ffc26 100644 --- a/app/src/standard/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA14.kt +++ b/app/src/standard/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA14.kt @@ -28,7 +28,7 @@ import com.drdisagree.iconify.R import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_FAILURE import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_SUBJECT import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_SUCCESS -import com.drdisagree.iconify.data.common.Const.ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY +import com.drdisagree.iconify.xposed.modules.lockscreen.AlbumArt.Companion.addAlbumArtVisibilityListener import com.drdisagree.iconify.data.common.Const.AI_PLUGIN_PACKAGE import com.drdisagree.iconify.data.common.Const.SYSTEMUI_PACKAGE import com.drdisagree.iconify.data.common.Preferences.CUSTOM_DEPTH_WALLPAPER_SWITCH @@ -91,14 +91,7 @@ class DepthWallpaperA14(context: Context) : ModPack(context) { private var wallpaperProcessorThread: Thread? = null private var shouldShowForeground = true - private var mBroadcastRegistered = false - private val mReceiver: BroadcastReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context?, intent: Intent?) { - if (intent?.action == ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) { - updateForegroundVisibility() - } - } - } + private var mAlbumArtListenerRegistered = false override fun updatePrefs(vararg key: String) { Xprefs.apply { @@ -133,26 +126,12 @@ class DepthWallpaperA14(context: Context) : ModPack(context) { @SuppressLint("UnspecifiedRegisterReceiverFlag", "NewApi") override fun handleLoadPackage(loadPackageParam: LoadPackageParam) { - // Receiver to handle foreground visibility - if (!mBroadcastRegistered) { - val intentFilter = IntentFilter().apply { - addAction(ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - mContext.registerReceiver( - mReceiver, - intentFilter, - Context.RECEIVER_EXPORTED - ) - } else { - mContext.registerReceiver( - mReceiver, - intentFilter - ) + // Listen for album art visibility changes directly (in-process) + if (!mAlbumArtListenerRegistered) { + addAlbumArtVisibilityListener { + updateForegroundVisibility() } - - mBroadcastRegistered = true + mAlbumArtListenerRegistered = true } mPluginReceiver = object : BroadcastReceiver() { diff --git a/app/src/standard/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA15.kt b/app/src/standard/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA15.kt index 959d4cdd4..de2538b63 100644 --- a/app/src/standard/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA15.kt +++ b/app/src/standard/java/com/drdisagree/iconify/xposed/modules/lockscreen/depthwallpaper/DepthWallpaperA15.kt @@ -29,7 +29,7 @@ import com.drdisagree.iconify.R import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_FAILURE import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_SUBJECT import com.drdisagree.iconify.data.common.Const.ACTION_EXTRACT_SUCCESS -import com.drdisagree.iconify.data.common.Const.ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY +import com.drdisagree.iconify.xposed.modules.lockscreen.AlbumArt.Companion.addAlbumArtVisibilityListener import com.drdisagree.iconify.data.common.Const.AI_PLUGIN_PACKAGE import com.drdisagree.iconify.data.common.Const.SYSTEMUI_PACKAGE import com.drdisagree.iconify.data.common.Preferences.CUSTOM_DEPTH_WALLPAPER_SWITCH @@ -105,14 +105,7 @@ class DepthWallpaperA15(context: Context) : ModPack(context) { ) private var shouldShowForeground = true - private var mBroadcastRegistered = false - private val mReceiver: BroadcastReceiver = object : BroadcastReceiver() { - override fun onReceive(context: Context?, intent: Intent?) { - if (intent?.action == ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) { - updateForegroundVisibility() - } - } - } + private var mAlbumArtListenerRegistered = false override fun updatePrefs(vararg key: String) { Xprefs.apply { @@ -147,26 +140,12 @@ class DepthWallpaperA15(context: Context) : ModPack(context) { @SuppressLint("UnspecifiedRegisterReceiverFlag", "NewApi") override fun handleLoadPackage(loadPackageParam: LoadPackageParam) { - // Receiver to handle foreground visibility - if (!mBroadcastRegistered) { - val intentFilter = IntentFilter().apply { - addAction(ACTION_UPDATE_DEPTH_WALLPAPER_FOREGROUND_VISIBILITY) - } - - if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) { - mContext.registerReceiver( - mReceiver, - intentFilter, - Context.RECEIVER_EXPORTED - ) - } else { - mContext.registerReceiver( - mReceiver, - intentFilter - ) + // Listen for album art visibility changes directly (in-process) + if (!mAlbumArtListenerRegistered) { + addAlbumArtVisibilityListener { + updateForegroundVisibility() } - - mBroadcastRegistered = true + mAlbumArtListenerRegistered = true } mPluginReceiver = object : BroadcastReceiver() {