Update in sample calculation for None scaling
This commit is contained in:
1 parent
493e6559df
commit
c3101ea5f6
3 files changed
+16
-11
No files matched your search
@@ -146,14 +146,20 @@ fun retrieveBitmap(
|
||||
context: Context,
|
||||
wallpaper: Uri,
|
||||
width: Int,
|
||||
height: Int
|
||||
height: Int,
|
||||
scaling: ScalingConstants = ScalingConstants.FIT
|
||||
): Bitmap? {
|
||||
val imageSize = wallpaper.getImageDimensions(context) ?: return null
|
||||
if (imageSize.width <= 0 || imageSize.height <= 0) {
|
||||
Log.e("WallpaperUtil", "Invalid image dimensions from URI: $imageSize")
|
||||
return null
|
||||
}
|
||||
val sampleSize = calculateInSampleSize(imageSize, width, height)
|
||||
|
||||
val sampleSize = if (scaling == ScalingConstants.NONE) {
|
||||
1
|
||||
} else {
|
||||
calculateInSampleSize(imageSize, width, height)
|
||||
}
|
||||
|
||||
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
|
||||
try {
|
||||
|
||||
+1
-1
@@ -576,7 +576,7 @@ class HomeWallpaperService: Service() {
|
||||
try {
|
||||
val wallpaperManager = WallpaperManager.getInstance(context)
|
||||
val size = getDeviceScreenSize(context)
|
||||
val bitmap = retrieveBitmap(context, wallpaper, size.width, size.height)
|
||||
val bitmap = retrieveBitmap(context, wallpaper, size.width, size.height, scaling)
|
||||
if (bitmap == null) return false
|
||||
else if (wallpaperManager.isSetWallpaperAllowed) {
|
||||
processBitmap(size.width, size.height, bitmap, darken, darkenPercent, scaling, blur, blurPercent, vignette, vignettePercent, grayscale, grayscalePercent)?.let { image ->
|
||||
|
||||
+7
-8
@@ -286,12 +286,12 @@ class LockWallpaperService: Service() {
|
||||
}
|
||||
}
|
||||
}
|
||||
// Refreshing home wallpaper to keep dynamic theming color based on home screen wallpaper
|
||||
if (homeInterval != lockInterval) {
|
||||
delay(15000)
|
||||
val serviceIntent = Intent(context, HomeWallpaperService::class.java).apply { this.action = HomeWallpaperService.Actions.UPDATE.toString() }
|
||||
context.startService(serviceIntent)
|
||||
}
|
||||
// // Refreshing home wallpaper to keep dynamic theming color based on home screen wallpaper
|
||||
// if (homeInterval != lockInterval) {
|
||||
// delay(15000)
|
||||
// val serviceIntent = Intent(context, HomeWallpaperService::class.java).apply { this.action = HomeWallpaperService.Actions.UPDATE.toString() }
|
||||
// context.startService(serviceIntent)
|
||||
// }
|
||||
}
|
||||
// Case: Set home and lock screen wallpapers using the same album (home screen album)
|
||||
settings.setHome && settings.setLock && !scheduleSeparately -> { /* handled by home wallpaper service */ return }
|
||||
@@ -494,11 +494,10 @@ class LockWallpaperService: Service() {
|
||||
try {
|
||||
val wallpaperManager = WallpaperManager.getInstance(this.applicationContext)
|
||||
val size = getDeviceScreenSize(context)
|
||||
val bitmap = retrieveBitmap(context, wallpaper, size.width, size.height)
|
||||
val bitmap = retrieveBitmap(context, wallpaper, size.width, size.height, scaling)
|
||||
if (bitmap == null) return false
|
||||
else if (wallpaperManager.isSetWallpaperAllowed) {
|
||||
processBitmap(size.width, size.height, bitmap, darken, darkenPercent, scaling, blur, blurPercent, vignette, vignettePercent, grayscale, grayscalePercent)?.let { image ->
|
||||
if (both) setWallpaperSafely(image, WallpaperManager.FLAG_SYSTEM, wallpaperManager)
|
||||
setWallpaperSafely(image, WallpaperManager.FLAG_LOCK, wallpaperManager)
|
||||
image.recycle()
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user