Aperture: Fix some Android Studio warnings

Change-Id: Ic43a3e063ba151e98dc7f99d9681a99530711dad
diff --git a/app/src/main/java/androidx/camera/video/RecordingExt.kt b/app/src/main/java/androidx/camera/video/RecordingExt.kt
index 444ce72..282fb2d 100644
--- a/app/src/main/java/androidx/camera/video/RecordingExt.kt
+++ b/app/src/main/java/androidx/camera/video/RecordingExt.kt
@@ -14,6 +14,7 @@
 
 var Recording.muted
     get() = audioSource.muted
+    @Suppress("RestrictedApi")
     set(value) {
         audioSource.mute(value)
     }
diff --git a/app/src/main/java/androidx/camera/video/internal/audio/AudioSourceExt.kt b/app/src/main/java/androidx/camera/video/internal/audio/AudioSourceExt.kt
index a0d6178..3b57ecb 100644
--- a/app/src/main/java/androidx/camera/video/internal/audio/AudioSourceExt.kt
+++ b/app/src/main/java/androidx/camera/video/internal/audio/AudioSourceExt.kt
@@ -6,4 +6,5 @@
 package androidx.camera.video.internal.audio
 
 val AudioSource.muted
+    @Suppress("RestrictedApi")
     get() = mMuted
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
index 7335ce3..adb11bf 100644
--- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
@@ -939,7 +939,7 @@
                     GridMode.OFF -> R.drawable.ic_grid_off
                     GridMode.ON_3 -> R.drawable.ic_grid_on_3
                     GridMode.ON_4 -> R.drawable.ic_grid_on_4
-                    GridMode.ON_GOLDENRATIO -> R.drawable.ic_grid_on_goldenratio
+                    GridMode.ON_GOLDEN_RATIO -> R.drawable.ic_grid_on_goldenratio
                 },
                 0,
                 0
@@ -949,7 +949,7 @@
                     GridMode.OFF -> R.string.grid_off
                     GridMode.ON_3 -> R.string.grid_on_3
                     GridMode.ON_4 -> R.string.grid_on_4
-                    GridMode.ON_GOLDENRATIO -> R.string.grid_on_goldenratio
+                    GridMode.ON_GOLDEN_RATIO -> R.string.grid_on_goldenratio
                 }
             )
         }
diff --git a/app/src/main/java/org/lineageos/aperture/camera/Camera.kt b/app/src/main/java/org/lineageos/aperture/camera/Camera.kt
index be70192..bf6aafb 100644
--- a/app/src/main/java/org/lineageos/aperture/camera/Camera.kt
+++ b/app/src/main/java/org/lineageos/aperture/camera/Camera.kt
@@ -25,7 +25,7 @@
 class Camera(cameraInfo: CameraInfo, cameraManager: CameraManager) {
     val cameraSelector = cameraInfo.cameraSelector
 
-    val camera2CameraInfo = Camera2CameraInfo.from(cameraInfo)
+    private val camera2CameraInfo = Camera2CameraInfo.from(cameraInfo)
     val cameraId = camera2CameraInfo.cameraId
 
     val cameraFacing = when (cameraInfo.lensFacing) {
diff --git a/app/src/main/java/org/lineageos/aperture/camera/CameraManager.kt b/app/src/main/java/org/lineageos/aperture/camera/CameraManager.kt
index 1d9edeb..58a4048 100644
--- a/app/src/main/java/org/lineageos/aperture/camera/CameraManager.kt
+++ b/app/src/main/java/org/lineageos/aperture/camera/CameraManager.kt
@@ -36,26 +36,26 @@
 
                     for (i in it.indices step 3) {
                         val cameraId = it[i]
-                        val frameRates = it[i + 2].split("|").mapNotNull {
-                            FrameRate.fromValue(it.toInt())
+                        val frameRates = it[i + 2].split("|").mapNotNull { frameRate ->
+                            FrameRate.fromValue(frameRate.toInt())
                         }
 
-                        it[i + 1].split("|").mapNotNull {
-                            when (it) {
+                        it[i + 1].split("|").mapNotNull { quality ->
+                            when (quality) {
                                 "sd" -> Quality.SD
                                 "hd" -> Quality.HD
                                 "fhd" -> Quality.FHD
                                 "uhd" -> Quality.UHD
                                 else -> null
                             }
-                        }.distinct().forEach {
+                        }.distinct().forEach { quality ->
                             if (!this.containsKey(cameraId)) {
                                 this[cameraId] = mutableMapOf()
                             }
-                            if (!this[cameraId]!!.containsKey(it)) {
-                                this[cameraId]!![it] = mutableSetOf()
+                            if (!this[cameraId]!!.containsKey(quality)) {
+                                this[cameraId]!![quality] = mutableSetOf()
                             }
-                            this[cameraId]!![it]!!.addAll(frameRates)
+                            this[cameraId]!![quality]!!.addAll(frameRates)
                         }
                     }
                 }
diff --git a/app/src/main/java/org/lineageos/aperture/ext/Bitmap.kt b/app/src/main/java/org/lineageos/aperture/ext/Bitmap.kt
index 13f1fcb..e8849fb 100644
--- a/app/src/main/java/org/lineageos/aperture/ext/Bitmap.kt
+++ b/app/src/main/java/org/lineageos/aperture/ext/Bitmap.kt
@@ -8,6 +8,8 @@
 import android.graphics.Bitmap
 import androidx.core.graphics.scale
 import org.lineageos.aperture.utils.ExifUtils.Transform
+import kotlin.math.abs
+import kotlin.math.max
 import kotlin.math.min
 
 /**
@@ -68,8 +70,7 @@
     var p: Int
     var yp: Int
     var yi: Int
-    var yw: Int
-    val vmin = IntArray(Math.max(width, height))
+    val vmin = IntArray(max(width, height))
 
     var divsum = div + 1 shr 1
     divsum *= divsum
@@ -82,7 +83,8 @@
         }
     }
 
-    yw = 0.also { yi = it }
+    var yw = 0
+    yi = 0
 
     val stack = Array(div) {
         IntArray(
@@ -105,22 +107,22 @@
         y = 0
         while (y < height) {
             bsum = 0
-            gsum = bsum
-            rsum = gsum
-            boutsum = rsum
-            goutsum = boutsum
-            routsum = goutsum
-            binsum = routsum
-            ginsum = binsum
-            rinsum = ginsum
+            gsum = 0
+            rsum = 0
+            boutsum = 0
+            goutsum = 0
+            routsum = 0
+            binsum = 0
+            ginsum = 0
+            rinsum = 0
             i = -radius
             while (i <= radius) {
-                p = pix[yi + Math.min(wm, Math.max(i, 0))]
+                p = pix[yi + min(wm, max(i, 0))]
                 sir = stack[i + radius]
                 sir[0] = p and 0xff0000 shr 16
                 sir[1] = p and 0x00ff00 shr 8
                 sir[2] = p and 0x0000ff
-                rbs = r1 - Math.abs(i)
+                rbs = r1 - abs(i)
                 rsum += sir[0] * rbs
                 gsum += sir[1] * rbs
                 bsum += sir[2] * rbs
@@ -150,7 +152,7 @@
                 goutsum -= sir[1]
                 boutsum -= sir[2]
                 if (y == 0) {
-                    vmin[x] = Math.min(x + radius + 1, wm)
+                    vmin[x] = min(x + radius + 1, wm)
                 }
                 p = pix[yw + vmin[x]]
                 sir[0] = p and 0xff0000 shr 16
@@ -181,23 +183,23 @@
         x = 0
         while (x < width) {
             bsum = 0
-            gsum = bsum
-            rsum = gsum
-            boutsum = rsum
-            goutsum = boutsum
-            routsum = goutsum
-            binsum = routsum
-            ginsum = binsum
-            rinsum = ginsum
+            gsum = 0
+            rsum = 0
+            boutsum = 0
+            goutsum = 0
+            routsum = 0
+            binsum = 0
+            ginsum = 0
+            rinsum = 0
             yp = -radius * width
             i = -radius
             while (i <= radius) {
-                yi = Math.max(0, yp) + x
+                yi = max(0, yp) + x
                 sir = stack[i + radius]
                 sir[0] = r[yi]
                 sir[1] = g[yi]
                 sir[2] = b[yi]
-                rbs = r1 - Math.abs(i)
+                rbs = r1 - abs(i)
                 rsum += r[yi] * rbs
                 gsum += g[yi] * rbs
                 bsum += b[yi] * rbs
@@ -231,7 +233,7 @@
                 goutsum -= sir[1]
                 boutsum -= sir[2]
                 if (x == 0) {
-                    vmin[y] = Math.min(y + r1, hm) * width
+                    vmin[y] = min(y + r1, hm) * width
                 }
                 p = x + vmin[y]
                 sir[0] = r[p]
diff --git a/app/src/main/java/org/lineageos/aperture/ext/SharedPreferences.kt b/app/src/main/java/org/lineageos/aperture/ext/SharedPreferences.kt
index fffb960..c4eac57 100644
--- a/app/src/main/java/org/lineageos/aperture/ext/SharedPreferences.kt
+++ b/app/src/main/java/org/lineageos/aperture/ext/SharedPreferences.kt
@@ -96,7 +96,7 @@
         "off" -> GridMode.OFF
         "on_3" -> GridMode.ON_3
         "on_4" -> GridMode.ON_4
-        "on_goldenratio" -> GridMode.ON_GOLDENRATIO
+        "on_goldenratio" -> GridMode.ON_GOLDEN_RATIO
         // Default to off
         else -> GridMode.OFF
     }
@@ -106,7 +106,7 @@
                 GridMode.OFF -> "off"
                 GridMode.ON_3 -> "on_3"
                 GridMode.ON_4 -> "on_4"
-                GridMode.ON_GOLDENRATIO -> "on_goldenratio"
+                GridMode.ON_GOLDEN_RATIO -> "on_goldenratio"
             }
         )
     }
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 a355e5d..bab6e0a 100644
--- a/app/src/main/java/org/lineageos/aperture/ui/GridView.kt
+++ b/app/src/main/java/org/lineageos/aperture/ui/GridView.kt
@@ -48,7 +48,7 @@
             GridMode.OFF -> 0
             GridMode.ON_3 -> 3
             GridMode.ON_4 -> 4
-            GridMode.ON_GOLDENRATIO -> 3
+            GridMode.ON_GOLDEN_RATIO -> 3
         }
 
         if (size <= 0) {
@@ -65,14 +65,14 @@
         val wOffset = (this.width - width) / 2F
         val hOffset = (this.height - height) / 2F
 
-        val unitDiv = if (mode == GridMode.ON_GOLDENRATIO) GOLDEN_RATIO_UNIT else size.toFloat()
+        val unitDiv = if (mode == GridMode.ON_GOLDEN_RATIO) GOLDEN_RATIO_UNIT else size.toFloat()
 
         val widthSection = width / unitDiv
         val heightSection = height / unitDiv
 
         for (i in size - 1 downTo 1) {
             val position =
-                if (mode == GridMode.ON_GOLDENRATIO && i == 2) 1 + GOLDEN_RATIO
+                if (mode == GridMode.ON_GOLDEN_RATIO && i == 2) 1 + GOLDEN_RATIO
                 else i.toFloat()
 
             canvas.drawLine(
diff --git a/app/src/main/java/org/lineageos/aperture/ui/Slider.kt b/app/src/main/java/org/lineageos/aperture/ui/Slider.kt
index 4119746..6b44210 100644
--- a/app/src/main/java/org/lineageos/aperture/ui/Slider.kt
+++ b/app/src/main/java/org/lineageos/aperture/ui/Slider.kt
@@ -21,6 +21,7 @@
 import org.lineageos.aperture.ext.*
 import org.lineageos.aperture.utils.Rotation
 
+@Suppress("PrivateResource")
 abstract class Slider @JvmOverloads constructor(
     context: Context, attrs: AttributeSet? = null, defStyleAttr: Int = 0
 ) : View(context, attrs, defStyleAttr) {
diff --git a/app/src/main/java/org/lineageos/aperture/utils/GridMode.kt b/app/src/main/java/org/lineageos/aperture/utils/GridMode.kt
index 16d48af..5342f67 100644
--- a/app/src/main/java/org/lineageos/aperture/utils/GridMode.kt
+++ b/app/src/main/java/org/lineageos/aperture/utils/GridMode.kt
@@ -9,5 +9,5 @@
     OFF,
     ON_3,
     ON_4,
-    ON_GOLDENRATIO,
+    ON_GOLDEN_RATIO,
 }