Loading bliss/src/foundation/e/bliss/blur/BlurWallpaperProvider.kt +10 −14 Original line number Diff line number Diff line Loading @@ -21,11 +21,10 @@ import android.annotation.SuppressLint import android.app.WallpaperManager import android.content.Context import android.graphics.* import android.util.DisplayMetrics import android.view.WindowManager import android.widget.Toast import androidx.core.graphics.drawable.toBitmap import com.android.launcher3.Utilities import com.android.launcher3.util.DisplayController import com.android.launcher3.util.Executors import com.android.launcher3.util.MainThreadInitializedObject import com.android.launcher3.util.SafeCloseable Loading @@ -38,9 +37,8 @@ import kotlin.math.ceil class BlurWallpaperProvider(val context: Context) : SafeCloseable { private val mWallpaperManager: WallpaperManager = WallpaperManager.getInstance(context) private val mWindowManager by lazy { context.getSystemService(WindowManager::class.java) } private val mListeners = ArrayList<Listener>() private val mDisplayMetrics = DisplayMetrics() private val mDisplaySize = DisplayController.INSTANCE.get(context).info.currentSize var wallpapers: BlurSizes? = null private set(value) { Loading Loading @@ -87,10 +85,8 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { return } val display = mWindowManager.defaultDisplay display.getRealMetrics(mDisplayMetrics) val width = mDisplayMetrics.widthPixels val height = mDisplayMetrics.heightPixels val width = mDisplaySize.x val height = mDisplaySize.y // Prepare a placeholder before hand so that it can be used in case wallpaper is null placeholder = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) Loading Loading @@ -118,9 +114,9 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { if (wallpaper == null) return mWallpaperWidth = wallpaper.width var offsetY = 0f val offsetY: Float if (wallpaper.height > height) { offsetY = (wallpaper.height - display.height) * 0.5f offsetY = (wallpaper.height - height) * 0.5f mListeners.forEach { it.onOffsetChanged(offsetY) } } Loading Loading @@ -174,8 +170,8 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { } private fun scaleAndCropToScreenSize(wallpaper: Bitmap): Bitmap { val width = mDisplayMetrics.widthPixels val height = mDisplayMetrics.heightPixels val width = mDisplaySize.x val height = mDisplaySize.y val widthFactor = width.toFloat() / wallpaper.width val heightFactor = height.toFloat() / wallpaper.height Loading Loading @@ -205,7 +201,7 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { if (!isEnabled) return if (wallpapers == null) return val availableWidth = mDisplayMetrics.widthPixels - mWallpaperWidth val availableWidth = mDisplaySize.x - mWallpaperWidth var xPixels = availableWidth / 2 if (availableWidth < 0) { xPixels += (availableWidth * (offset - .5f) + .5f).toInt() Loading @@ -215,7 +211,7 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { Utilities.boundToRange( (-xPixels).toFloat(), 0f, (mWallpaperWidth - mDisplayMetrics.widthPixels).toFloat() (mWallpaperWidth - mDisplaySize.x).toFloat() ) runOnMainThread { mListeners.forEach { it.onScrollOffsetChanged(scrollOffset) } } Loading Loading
bliss/src/foundation/e/bliss/blur/BlurWallpaperProvider.kt +10 −14 Original line number Diff line number Diff line Loading @@ -21,11 +21,10 @@ import android.annotation.SuppressLint import android.app.WallpaperManager import android.content.Context import android.graphics.* import android.util.DisplayMetrics import android.view.WindowManager import android.widget.Toast import androidx.core.graphics.drawable.toBitmap import com.android.launcher3.Utilities import com.android.launcher3.util.DisplayController import com.android.launcher3.util.Executors import com.android.launcher3.util.MainThreadInitializedObject import com.android.launcher3.util.SafeCloseable Loading @@ -38,9 +37,8 @@ import kotlin.math.ceil class BlurWallpaperProvider(val context: Context) : SafeCloseable { private val mWallpaperManager: WallpaperManager = WallpaperManager.getInstance(context) private val mWindowManager by lazy { context.getSystemService(WindowManager::class.java) } private val mListeners = ArrayList<Listener>() private val mDisplayMetrics = DisplayMetrics() private val mDisplaySize = DisplayController.INSTANCE.get(context).info.currentSize var wallpapers: BlurSizes? = null private set(value) { Loading Loading @@ -87,10 +85,8 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { return } val display = mWindowManager.defaultDisplay display.getRealMetrics(mDisplayMetrics) val width = mDisplayMetrics.widthPixels val height = mDisplayMetrics.heightPixels val width = mDisplaySize.x val height = mDisplaySize.y // Prepare a placeholder before hand so that it can be used in case wallpaper is null placeholder = Bitmap.createBitmap(width, height, Bitmap.Config.ARGB_8888) Loading Loading @@ -118,9 +114,9 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { if (wallpaper == null) return mWallpaperWidth = wallpaper.width var offsetY = 0f val offsetY: Float if (wallpaper.height > height) { offsetY = (wallpaper.height - display.height) * 0.5f offsetY = (wallpaper.height - height) * 0.5f mListeners.forEach { it.onOffsetChanged(offsetY) } } Loading Loading @@ -174,8 +170,8 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { } private fun scaleAndCropToScreenSize(wallpaper: Bitmap): Bitmap { val width = mDisplayMetrics.widthPixels val height = mDisplayMetrics.heightPixels val width = mDisplaySize.x val height = mDisplaySize.y val widthFactor = width.toFloat() / wallpaper.width val heightFactor = height.toFloat() / wallpaper.height Loading Loading @@ -205,7 +201,7 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { if (!isEnabled) return if (wallpapers == null) return val availableWidth = mDisplayMetrics.widthPixels - mWallpaperWidth val availableWidth = mDisplaySize.x - mWallpaperWidth var xPixels = availableWidth / 2 if (availableWidth < 0) { xPixels += (availableWidth * (offset - .5f) + .5f).toInt() Loading @@ -215,7 +211,7 @@ class BlurWallpaperProvider(val context: Context) : SafeCloseable { Utilities.boundToRange( (-xPixels).toFloat(), 0f, (mWallpaperWidth - mDisplayMetrics.widthPixels).toFloat() (mWallpaperWidth - mDisplaySize.x).toFloat() ) runOnMainThread { mListeners.forEach { it.onScrollOffsetChanged(scrollOffset) } } Loading