Aperture: Update camera mode buttons on UI thread

Change-Id: I1bdd6c659563e4bce155996b3549b22957ea6424
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index e5a9a18..6fcbd1e 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -844,25 +844,27 @@
      * Update the camera mode buttons reflecting the current mode
      */
     private fun updateCameraModeButtons() {
-        cameraMode.let {
-            qrModeButton.isEnabled = it != CameraMode.QR
-            photoModeButton.isEnabled = it != CameraMode.PHOTO
-            videoModeButton.isEnabled = it != CameraMode.VIDEO
-        }
+        runOnUiThread {
+            cameraMode.let {
+                qrModeButton.isEnabled = it != CameraMode.QR
+                photoModeButton.isEnabled = it != CameraMode.PHOTO
+                videoModeButton.isEnabled = it != CameraMode.VIDEO
+            }
 
-        // Animate camera mode change
-        (cameraModeHighlight.parent as View).doOnLayout {
-            ValueAnimator.ofFloat(
-                cameraModeHighlight.x, when (cameraMode) {
-                    CameraMode.QR -> qrModeButton.x
-                    CameraMode.PHOTO -> photoModeButton.x
-                    CameraMode.VIDEO -> videoModeButton.x
-                }
-            ).apply {
-                addUpdateListener {
-                    cameraModeHighlight.x = it.animatedValue as Float
-                }
-            }.start()
+            // Animate camera mode change
+            (cameraModeHighlight.parent as View).doOnLayout {
+                ValueAnimator.ofFloat(
+                    cameraModeHighlight.x, when (cameraMode) {
+                        CameraMode.QR -> qrModeButton.x
+                        CameraMode.PHOTO -> photoModeButton.x
+                        CameraMode.VIDEO -> videoModeButton.x
+                    }
+                ).apply {
+                    addUpdateListener {
+                        cameraModeHighlight.x = it.animatedValue as Float
+                    }
+                }.start()
+            }
         }
     }