mirror of
https://github.com/libre-tube/LibreTube.git
synced 2024-12-14 06:10:31 +05:30
Move the bitmap scaling logic to the ImageHelper
This commit is contained in:
parent
fe42714c52
commit
a52bd6247c
@ -88,4 +88,20 @@ object ImageHelper {
|
||||
}
|
||||
return null
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a squared bitmap with the same width and height from a bitmap
|
||||
* @param bitmap The bitmap to resize
|
||||
*/
|
||||
fun getSquareBitmap(bitmap: Bitmap?): Bitmap? {
|
||||
bitmap ?: return null
|
||||
val newSize = minOf(bitmap.width, bitmap.height)
|
||||
return Bitmap.createBitmap(
|
||||
bitmap,
|
||||
(bitmap.width - newSize) / 2,
|
||||
(bitmap.height - newSize) / 2,
|
||||
newSize,
|
||||
newSize
|
||||
)
|
||||
}
|
||||
}
|
||||
|
@ -118,22 +118,12 @@ class NowPlayingNotification(
|
||||
ImageHelper.imageLoader.enqueue(request)
|
||||
|
||||
// returns the bitmap on Android 13+, for everything below scaled down to a square
|
||||
return if (Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU) getSquareBitmap(bitmap) else bitmap
|
||||
return if (
|
||||
Build.VERSION.SDK_INT < Build.VERSION_CODES.TIRAMISU
|
||||
) ImageHelper.getSquareBitmap(bitmap) else bitmap
|
||||
}
|
||||
}
|
||||
|
||||
private fun getSquareBitmap(bitmap: Bitmap?): Bitmap? {
|
||||
bitmap ?: return null
|
||||
val newSize = minOf(bitmap.width, bitmap.height)
|
||||
return Bitmap.createBitmap(
|
||||
bitmap,
|
||||
(bitmap.width - newSize) / 2,
|
||||
(bitmap.height - newSize) / 2,
|
||||
newSize,
|
||||
newSize
|
||||
)
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a [MediaSessionCompat] amd a [MediaSessionConnector] for the player
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user