Aperture: Replace recording chip with fake camera mode button
Change-Id: I5ac64a6ce7ee9a30557abf12ccb1c336bec61fec
diff --git a/app/src/main/java/org/lineageos/aperture/MainActivity.kt b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
index 9005066..f7bdba8 100644
--- a/app/src/main/java/org/lineageos/aperture/MainActivity.kt
+++ b/app/src/main/java/org/lineageos/aperture/MainActivity.kt
@@ -101,12 +101,12 @@
private val micButton by lazy { findViewById<ImageButton>(R.id.micButton) }
private val photoModeButton by lazy { findViewById<MaterialButton>(R.id.photoModeButton) }
private val qrModeButton by lazy { findViewById<MaterialButton>(R.id.qrModeButton) }
- private val recordChip by lazy { findViewById<Chip>(R.id.recordChip) }
private val settingsButton by lazy { findViewById<ImageButton>(R.id.settingsButton) }
private val shutterButton by lazy { findViewById<ImageButton>(R.id.shutterButton) }
private val timerButton by lazy { findViewById<ImageButton>(R.id.timerButton) }
private val timerChip by lazy { findViewById<Chip>(R.id.timerChip) }
private val torchButton by lazy { findViewById<ImageButton>(R.id.torchButton) }
+ private val videoDuration by lazy { findViewById<MaterialButton>(R.id.videoDuration) }
private val videoModeButton by lazy { findViewById<MaterialButton>(R.id.videoModeButton) }
private val videoQualityButton by lazy { findViewById<ToggleButton>(R.id.videoQualityButton) }
private val viewFinder by lazy { findViewById<PreviewView>(R.id.viewFinder) }
@@ -146,11 +146,6 @@
get() = sharedPreferences.videoQuality
private var recording: Recording? = null
private val recordingLock = Mutex()
- private var recordingTime = 0L
- set(value) {
- field = value
- recordChip.text = TimeUtils.convertNanosToString(recordingTime)
- }
private val sharedPreferences by lazy {
PreferenceManager.getDefaultSharedPreferences(this)
@@ -561,15 +556,25 @@
audioConfig,
cameraExecutor
) {
+ val updateRecordingStatus = { enabled: Boolean, duration: Long ->
+ // Hide mode buttons
+ photoModeButton.isInvisible = enabled
+ videoModeButton.isInvisible = enabled
+ qrModeButton.isInvisible = enabled
+
+ // Update duration text and visibility state
+ videoDuration.text = TimeUtils.convertNanosToString(duration)
+ videoDuration.isVisible = enabled
+ }
+
when (it) {
is VideoRecordEvent.Status -> runOnUiThread {
- recordingTime = it.recordingStats.recordedDurationNanos
- recordChip.isVisible = true
+ updateRecordingStatus(true, it.recordingStats.recordedDurationNanos)
}
is VideoRecordEvent.Finalize -> {
runOnUiThread {
startShutterAnimation(ShutterAnimation.VideoEnd)
- recordChip.isVisible = false
+ updateRecordingStatus(false, 0)
}
cameraSoundsUtils.playStopVideoRecording()
if (it.error != VideoRecordEvent.Finalize.ERROR_NO_VALID_DATA) {
diff --git a/app/src/main/res/drawable/ic_record.xml b/app/src/main/res/drawable/ic_record.xml
deleted file mode 100644
index 228a44b..0000000
--- a/app/src/main/res/drawable/ic_record.xml
+++ /dev/null
@@ -1,10 +0,0 @@
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="24dp"
- android:height="24dp"
- android:tint="#FF0000"
- android:viewportWidth="24"
- android:viewportHeight="24">
- <path
- android:fillColor="@android:color/white"
- android:pathData="M12,12m-8,0a8,8 0,1 1,16 0a8,8 0,1 1,-16 0" />
-</vector>
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index d7f018b..3dc2d8a 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -181,21 +181,6 @@
app:layout_constraintTop_toTopOf="@+id/viewFinder" />
<com.google.android.material.chip.Chip
- android:id="@+id/recordChip"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:layout_marginTop="8dp"
- android:layout_marginEnd="16dp"
- android:text="@string/record_chip_default_text"
- android:textColor="@color/white"
- android:visibility="gone"
- app:chipIcon="@drawable/ic_record"
- app:chipSurfaceColor="@color/black"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintTop_toTopOf="@+id/viewFinder"
- app:rippleColor="#00ffffff" />
-
- <com.google.android.material.chip.Chip
android:id="@+id/timerChip"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -343,5 +328,22 @@
app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/videoModeButton"
app:layout_constraintTop_toTopOf="parent" />
+
+ <com.google.android.material.button.MaterialButton
+ android:id="@+id/videoDuration"
+ style="@style/ApertureVideoDurationButton"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:contentDescription="@string/video_mode_button_description"
+ android:enabled="false"
+ android:padding="0dp"
+ android:visibility="gone"
+ app:iconPadding="0dp"
+ app:layout_constraintBottom_toBottomOf="parent"
+ app:layout_constraintEnd_toEndOf="@+id/videoModeButton"
+ app:layout_constraintHorizontal_bias="0.5"
+ app:layout_constraintStart_toStartOf="@+id/videoModeButton"
+ app:layout_constraintTop_toTopOf="parent"
+ tools:text="3:13:37" />
</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 31cb759..70e0d96 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -23,9 +23,6 @@
<string name="select_video">VIDEO</string>
<string name="select_scan">SCAN</string>
- <!-- Record chip -->
- <string translatable="false" name="record_chip_default_text">00:00:00</string>
-
<!-- Permissions toast -->
<string name="app_permissions_toast">Permissions not granted by the user.</string>
diff --git a/app/src/main/res/values/themes.xml b/app/src/main/res/values/themes.xml
index 675fb2b..7a9990a 100644
--- a/app/src/main/res/values/themes.xml
+++ b/app/src/main/res/values/themes.xml
@@ -58,4 +58,9 @@
<style name="ApertureModeSelectorButtonHighlight" parent="@style/ApertureModeSelectorButton">
<item name="android:backgroundTint">@color/camera_mode_selector_icon_highlight</item>
</style>
+
+ <!-- Video duration button theme -->
+ <style name="ApertureVideoDurationButton" parent="@style/ApertureModeSelectorButton">
+ <item name="android:backgroundTint">@color/rec_red</item>
+ </style>
</resources>
\ No newline at end of file