Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

Clarify crop names and remove wallpaper comments

Neeraj Gupta3e18fa57a35a
diff --git a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/Crop.kt b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/Crop.kt
index 67d4819155..5e4adb29d5 100644
--- a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/Crop.kt
+++ b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/Crop.kt
@@ -7,15 +7,14 @@ import android.graphics.Paint
import android.graphics.Point
import android.graphics.RectF
-// The region is normalized to the image after applying EXIF orientation.
-internal data class Crop(val region: RectF, val size: Point) {
- fun render(image: Bitmap): Bitmap {
+internal data class Crop(val normalizedRegion: RectF, val size: Point) {
+ fun render(orientedImage: Bitmap): Bitmap {
val result = Bitmap.createBitmap(size.x, size.y, Bitmap.Config.ARGB_8888)
val canvas = Canvas(result)
canvas.drawColor(Color.BLACK)
- canvas.scale(size.x / (region.width() * image.width), size.y / (region.height() * image.height))
- canvas.translate(-region.left * image.width, -region.top * image.height)
- canvas.drawBitmap(image, 0f, 0f, Paint(Paint.FILTER_BITMAP_FLAG))
+ canvas.scale(size.x / (normalizedRegion.width() * orientedImage.width), size.y / (normalizedRegion.height() * orientedImage.height))
+ canvas.translate(-normalizedRegion.left * orientedImage.width, -normalizedRegion.top * orientedImage.height)
+ canvas.drawBitmap(orientedImage, 0f, 0f, Paint(Paint.FILTER_BITMAP_FLAG))
return result
}
}
diff --git a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/DestinationSheet.kt b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/DestinationSheet.kt
index 5161fdf35e..819b30923a 100644
--- a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/DestinationSheet.kt
+++ b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/DestinationSheet.kt
@@ -28,7 +28,6 @@ internal class DestinationSheet(context: Context, onSelected: (Destination) -> U
val content = LinearLayout(context).apply {
orientation = LinearLayout.VERTICAL
setPadding(dp(20), dp(20), dp(20), dp(20))
- // Matches ente_components' dark backgroundBase and bottomSheet radius.
background = GradientDrawable().apply {
setColor(0xFF161616.toInt())
cornerRadii = floatArrayOf(dp(20).toFloat(), dp(20).toFloat(), dp(20).toFloat(), dp(20).toFloat(), 0f, 0f, 0f, 0f)
diff --git a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/WallpaperService.kt b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/WallpaperService.kt
index af86cc7b08..215c6eab0e 100644
--- a/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/WallpaperService.kt
+++ b/mobile/apps/photos/plugins/ente_photos_platform/android/src/main/kotlin/io/ente/photos/platform/wallpaper/WallpaperService.kt
@@ -46,7 +46,6 @@ internal class WallpaperService(context: Context) {
requireNotNull(BitmapRegionDecoder.newInstance(it, false))
}
} catch (_: IOException) {
- // Formats without a region decoder (for example GIF) keep the preview path.
val image = decode(uri, crop.size)
return try { crop.render(image) } finally { image.recycle() }
}
@@ -57,7 +56,7 @@ internal class WallpaperService(context: Context) {
transform.postTranslate(-unit.left, -unit.top)
val inverse = Matrix()
transform.invert(inverse)
- val storageRegion = RectF(crop.region)
+ val storageRegion = RectF(crop.normalizedRegion)
inverse.mapRect(storageRegion)
storageRegion.set(
storageRegion.left * decoder.width, storageRegion.top * decoder.height,
@@ -82,10 +81,10 @@ internal class WallpaperService(context: Context) {
)
transform.mapRect(available)
val region = RectF(
- (crop.region.left - available.left) / available.width(),
- (crop.region.top - available.top) / available.height(),
- (crop.region.right - available.left) / available.width(),
- (crop.region.bottom - available.top) / available.height(),
+ (crop.normalizedRegion.left - available.left) / available.width(),
+ (crop.normalizedRegion.top - available.top) / available.height(),
+ (crop.normalizedRegion.right - available.left) / available.width(),
+ (crop.normalizedRegion.bottom - available.top) / available.height(),
)
return try { Crop(region, crop.size).render(image) } finally { image.recycle() }
} finally {
@@ -94,7 +93,6 @@ internal class WallpaperService(context: Context) {
}
fun decode(uri: Uri, displaySize: Point): Bitmap {
- // Keep two screen lengths of detail for zooming, without decoding full-resolution photos.
val maxSize = 2 * max(displaySize.x, displaySize.y)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.P) {
return ImageDecoder.decodeBitmap(ImageDecoder.createSource(resolver, uri)) { decoder, info, _ ->