Aperture: Clamp grid size to preview view size

* Surface might be bigger than the view

Change-Id: I7bea17bde72d8fb6daf98aa72b9f5ffd9db78ec6
diff --git a/app/src/main/java/org/lineageos/aperture/ui/GridView.kt b/app/src/main/java/org/lineageos/aperture/ui/GridView.kt
index b6bbdfe..4862c18 100644
--- a/app/src/main/java/org/lineageos/aperture/ui/GridView.kt
+++ b/app/src/main/java/org/lineageos/aperture/ui/GridView.kt
@@ -63,8 +63,8 @@
             it is TextureView || it is SurfaceView
         } ?: throw Exception("Unable to get preview image surface!")
 
-        val width = (surface.scaleX * surface.width).roundToInt()
-        val height = (surface.scaleY * surface.height).roundToInt()
+        val width = (surface.scaleX * surface.width).roundToInt().coerceIn(0, previewView.width)
+        val height = (surface.scaleY * surface.height).roundToInt().coerceIn(0, previewView.height)
 
         val wOffset = (this.width - width) / 2F
         val hOffset = (this.height - height) / 2F