Aperture: Show current aspect ratio in UI

Change-Id: I325791975dae6b2dcd8946a2b751a6f992bfc3f5
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 36a053d..272f289 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -30,6 +30,7 @@
 import android.widget.ImageButton
 import android.widget.ImageView
 import android.widget.Toast
+import android.widget.ToggleButton
 import androidx.appcompat.app.AppCompatActivity
 import androidx.camera.core.AspectRatio
 import androidx.camera.core.CameraSelector
@@ -72,7 +73,7 @@
 import java.util.TimerTask
 
 class MainActivity : AppCompatActivity() {
-    private val aspectRatioButton by lazy { findViewById<ImageButton>(R.id.aspectRatioButton) }
+    private val aspectRatioButton by lazy { findViewById<ToggleButton>(R.id.aspectRatioButton) }
     private val effectButton by lazy { findViewById<ImageButton>(R.id.effectButton) }
     private val flashButton by lazy { findViewById<ImageButton>(R.id.flashButton) }
     private val flipCameraButton by lazy { findViewById<ImageButton>(R.id.flipCameraButton) }
@@ -492,6 +493,7 @@
         updateCameraModeButtons()
         toggleRecordingChipVisibility()
         updateTimerModeIcon()
+        updateAspectRatioIcon()
         updatePhotoEffectIcon()
         updateGridIcon()
         updateFlashModeIcon()
@@ -631,6 +633,14 @@
         updateTimerModeIcon()
     }
 
+    private fun updateAspectRatioIcon() {
+        aspectRatioButton.text = when (sharedPreferences.aspectRatio) {
+            AspectRatio.RATIO_4_3 -> "4:3"
+            AspectRatio.RATIO_16_9 -> "16:9"
+            else -> throw Exception("Unknown aspect ratio $sharedPreferences.aspectRatio")
+        }
+    }
+
     /**
      * Update the torch mode button icon based on the value set in camera
      */
diff --git a/app/src/main/res/drawable/ic_crop.xml b/app/src/main/res/drawable/ic_crop.xml
deleted file mode 100644
index 8e91f26..0000000
--- a/app/src/main/res/drawable/ic_crop.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-<vector android:height="24dp" android:tint="#000000"
-    android:viewportHeight="24" android:viewportWidth="24"
-    android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android">
-    <path android:fillColor="@android:color/white" android:pathData="M17,15h2V7c0,-1.1 -0.9,-2 -2,-2H9v2h8v8zM7,17V1H5v4H1v2h4v10c0,1.1 0.9,2 2,2h10v4h2v-4h4v-2H7z"/>
-</vector>
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index f4c38e5..e73bced 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -36,14 +36,13 @@
             app:layout_constraintTop_toTopOf="parent"
             app:layout_constraintVertical_bias="0.0" />
 
-        <ImageButton
+        <ToggleButton
             android:id="@+id/aspectRatioButton"
             style="@style/ApertureTopBarButton"
             android:layout_width="@dimen/top_view_buttons_size"
             android:layout_height="@dimen/top_view_buttons_size"
             android:background="?attr/selectableItemBackgroundBorderless"
             android:contentDescription="@string/aspect_ratio_button_description"
-            android:src="@drawable/ic_crop"
             app:layout_constraintBottom_toBottomOf="parent"
             app:layout_constraintEnd_toStartOf="@+id/effectButton"
             app:layout_constraintHorizontal_bias="0.5"