Aperture: Make sure grant results is not empty

When app is clean installed dialog permission appears but since we don't
really check if any grant results are there it shows wrong toast saying
permission not granted and closes the app.

Also request permission in onResume instead of onCreate this ensures
every launch has proper permissions.

Change-Id: Ibd5d4e79c47ce6688402331fed607120e1d4229b
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
index 2e4c7a9..6b583fc 100644
--- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
@@ -290,13 +290,15 @@
     private val requestMultiplePermissions = registerForActivityResult(
         ActivityResultContracts.RequestMultiplePermissions()
     ) {
-        if (!allPermissionsGranted()) {
-            Toast.makeText(
-                this, getString(R.string.app_permissions_toast), Toast.LENGTH_SHORT
-            ).show()
-            finish()
+        if (it.isNotEmpty()) {
+            if (!allPermissionsGranted()) {
+                Toast.makeText(
+                    this, getString(R.string.app_permissions_toast), Toast.LENGTH_SHORT
+                ).show()
+                finish()
+            }
+            sharedPreferences.saveLocation = allLocationPermissionsGranted()
         }
-        sharedPreferences.saveLocation = allLocationPermissionsGranted()
     }
 
     enum class ShutterAnimation(val resourceId: Int) {
@@ -369,13 +371,6 @@
         // Register shortcuts
         ShortcutsUtils.registerShortcuts(this)
 
-        // Request camera permissions
-        if (!allPermissionsGranted() || !allLocationPermissionsGranted()) {
-            requestMultiplePermissions.launch(
-                REQUIRED_PERMISSIONS + REQUIRED_PERMISSIONS_LOCATION
-            )
-        }
-
         // Initialize camera manager
         cameraManager = CameraManager(this)
 
@@ -621,6 +616,13 @@
     override fun onResume() {
         super.onResume()
 
+        // Request camera permissions
+        if (!allPermissionsGranted() || !allLocationPermissionsGranted()) {
+            requestMultiplePermissions.launch(
+                REQUIRED_PERMISSIONS + REQUIRED_PERMISSIONS_LOCATION
+            )
+        }
+
         // Set bright screen
         setBrightScreen(sharedPreferences.brightScreen)