Aperture: Move flash button to secondary bottom bar
Change-Id: I0a584f5a72d5d3fb9eb09084dbf6f6fa0f76cbb8
diff --git a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
index 42be464..80505b4 100644
--- a/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/CameraActivity.kt
@@ -100,7 +100,7 @@
private val countDownView by lazy { findViewById<CountDownView>(R.id.countDownView) }
private val effectButton by lazy { findViewById<Button>(R.id.effectButton) }
private val exposureLevel by lazy { findViewById<VerticalSlider>(R.id.exposureLevel) }
- private val flashButton by lazy { findViewById<Button>(R.id.flashButton) }
+ private val flashButton by lazy { findViewById<ImageButton>(R.id.flashButton) }
private val flipCameraButton by lazy { findViewById<ImageButton>(R.id.flipCameraButton) }
private val galleryButton by lazy { findViewById<ImageView>(R.id.galleryButton) }
private val galleryButtonCardView by lazy { findViewById<CardView>(R.id.galleryButtonCardView) }
@@ -352,7 +352,6 @@
effectButton.setOnClickListener { cyclePhotoEffects() }
gridButton.setOnClickListener { cycleGridMode() }
timerButton.setOnClickListener { toggleTimerMode() }
- flashButton.setOnClickListener { cycleFlashMode() }
micButton.setOnClickListener { toggleMicrophoneMode() }
settingsButton.setOnClickListener { openSettings() }
@@ -360,6 +359,7 @@
proButton.setOnClickListener {
secondaryTopBarLayout.isVisible = !secondaryTopBarLayout.isVisible
}
+ flashButton.setOnClickListener { cycleFlashMode() }
// Initialize camera mode highlight position
(cameraModeHighlight.parent as View).doOnLayout {
@@ -1225,24 +1225,16 @@
flashButton.isVisible = camera.hasFlashUnit
cameraController.flashMode.let {
- flashButton.setCompoundDrawablesWithIntrinsicBounds(
- 0,
- when (it) {
- FlashMode.OFF -> R.drawable.ic_flash_off
- FlashMode.AUTO -> R.drawable.ic_flash_auto
- FlashMode.ON -> R.drawable.ic_flash_on
- FlashMode.TORCH -> R.drawable.ic_flash_torch
- },
- 0,
- 0
- )
- flashButton.text = resources.getText(
- when (it) {
- FlashMode.OFF -> R.string.flash_off
- FlashMode.AUTO -> R.string.flash_auto
- FlashMode.ON -> R.string.flash_on
- FlashMode.TORCH -> R.string.flash_torch
- }
+ flashButton.setImageDrawable(
+ ContextCompat.getDrawable(
+ this,
+ when (it) {
+ FlashMode.OFF -> R.drawable.ic_flash_off
+ FlashMode.AUTO -> R.drawable.ic_flash_auto
+ FlashMode.ON -> R.drawable.ic_flash_on
+ FlashMode.TORCH -> R.drawable.ic_flash_torch
+ }
+ )
)
}
}
diff --git a/app/src/main/res/layout/activity_camera.xml b/app/src/main/res/layout/activity_camera.xml
index c5a7b2f..725aad3 100644
--- a/app/src/main/res/layout/activity_camera.xml
+++ b/app/src/main/res/layout/activity_camera.xml
@@ -155,22 +155,12 @@
app:layout_constraintTop_toTopOf="parent" />
<Button
- android:id="@+id/flashButton"
- style="@style/Theme.Aperture.Camera.SecondaryTopBarButton"
- android:drawableTop="@drawable/ic_flash_off"
- android:text="@string/flash_off"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintStart_toEndOf="@+id/gridButton"
- app:layout_constraintTop_toTopOf="parent"
- app:layout_constraintVertical_bias="0.0" />
-
- <Button
android:id="@+id/micButton"
style="@style/Theme.Aperture.Camera.SecondaryTopBarButton"
android:drawableTop="@drawable/ic_mic_off"
android:text="@string/mic_off"
app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintStart_toEndOf="@+id/flashButton"
+ app:layout_constraintStart_toEndOf="@+id/gridButton"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.0" />
@@ -214,6 +204,15 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
+
+ <ImageButton
+ android:id="@+id/flashButton"
+ style="@style/Theme.Aperture.Camera.SecondaryBottomBarButton"
+ android:layout_marginEnd="40dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="parent"
+ app:layout_constraintTop_toTopOf="parent"
+ app:srcCompat="@drawable/ic_flash_off" />
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index cd542ad..aa9d121 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -38,11 +38,6 @@
<string name="grid_on_4">GRID 4x4</string>
<string name="grid_on_goldenratio">GRID φ</string>
- <string name="flash_off">FLASH OFF</string>
- <string name="flash_auto">FLASH AUTO</string>
- <string name="flash_on">FLASH ON</string>
- <string name="flash_torch">FLASH TORCH</string>
-
<string name="mic_off">MIC OFF</string>
<string name="mic_on">MIC ON</string>