hide last taken video icon during video recording

- remove unused methods in MainActivity
- fade out/in the toggle_camera and last_photo_video_preview buttons when video recording is started/stopped
This commit is contained in:
darthpaul 2022-10-08 03:58:47 +01:00
parent 9536995b79
commit 2608822169
3 changed files with 37 additions and 51 deletions

View File

@ -27,6 +27,8 @@ import com.google.android.material.tabs.TabLayout
import com.simplemobiletools.camera.BuildConfig
import com.simplemobiletools.camera.R
import com.simplemobiletools.camera.extensions.config
import com.simplemobiletools.camera.extensions.fadeIn
import com.simplemobiletools.camera.extensions.fadeOut
import com.simplemobiletools.camera.extensions.toFlashModeId
import com.simplemobiletools.camera.helpers.*
import com.simplemobiletools.camera.implementations.CameraXInitializer
@ -37,10 +39,16 @@ import com.simplemobiletools.camera.views.FocusCircleView
import com.simplemobiletools.commons.extensions.*
import com.simplemobiletools.commons.helpers.*
import com.simplemobiletools.commons.models.Release
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.layout_flash.*
import kotlinx.android.synthetic.main.layout_top.*
import java.util.concurrent.TimeUnit
import kotlinx.android.synthetic.main.activity_main.*
import kotlinx.android.synthetic.main.layout_flash.flash_auto
import kotlinx.android.synthetic.main.layout_flash.flash_off
import kotlinx.android.synthetic.main.layout_flash.flash_on
import kotlinx.android.synthetic.main.layout_flash.flash_toggle_group
import kotlinx.android.synthetic.main.layout_top.change_resolution
import kotlinx.android.synthetic.main.layout_top.default_icons
import kotlinx.android.synthetic.main.layout_top.settings
import kotlinx.android.synthetic.main.layout_top.toggle_flash
class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, CameraXPreviewListener {
private companion object {
@ -524,11 +532,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
}
private fun showTimer() {
video_rec_curr_timer.beVisible()
setupTimer()
}
private fun hideTimer() {
video_rec_curr_timer.text = 0.getFormattedDuration()
video_rec_curr_timer.beGone()
@ -536,15 +539,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
mTimerHandler.removeCallbacksAndMessages(null)
}
private fun setupTimer() {
runOnUiThread(object : Runnable {
override fun run() {
video_rec_curr_timer.text = mCurrVideoRecTimer++.getFormattedDuration()
mTimerHandler.postDelayed(this, 1000L)
}
})
}
private fun resumeCameraItems() {
if (!mIsInPhotoMode) {
initVideoButtons()
@ -681,21 +675,28 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
override fun onVideoRecordingStarted() {
camera_mode_tab.beInvisible()
shutter.isSelected = true
toggle_camera.beInvisible()
video_rec_curr_timer.beVisible()
toggle_camera.fadeOut()
last_photo_video_preview.fadeOut()
change_resolution.isEnabled = false
settings.isEnabled = false
video_rec_curr_timer.beVisible()
shutter.isSelected = true
}
override fun onVideoRecordingStopped() {
camera_mode_tab.beVisible()
shutter.isSelected = false
toggle_camera.fadeIn()
last_photo_video_preview.fadeIn()
video_rec_curr_timer.text = 0.getFormattedDuration()
video_rec_curr_timer.beGone()
shutter.isSelected = false
change_resolution.isEnabled = true
settings.isEnabled = true
toggle_camera.beVisible()
}
override fun onVideoDurationChanged(durationNanos: Long) {
@ -820,33 +821,6 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
button.iconTint = ColorStateList(states, iconColors)
}
fun setRecordingState(isRecording: Boolean) {
runOnUiThread {
if (isRecording) {
shutter.isSelected = true
toggle_camera.beInvisible()
showTimer()
} else {
shutter.isSelected = false
hideTimer()
}
}
}
fun videoSaved(uri: Uri) {
setupPreviewImage(false)
if (isVideoCaptureIntent()) {
Intent().apply {
data = uri
flags = Intent.FLAG_GRANT_READ_URI_PERMISSION
setResult(Activity.RESULT_OK, this)
}
finish()
}
}
fun drawFocusCircle(x: Float, y: Float) = mFocusCircleView.drawFocusCircle(x, y)
override fun mediaSaved(path: String) {
rescanPaths(arrayListOf(path)) {
setupPreviewImage(true)

View File

@ -0,0 +1,12 @@
package com.simplemobiletools.camera.extensions
import android.view.View
import com.simplemobiletools.commons.helpers.SHORT_ANIMATION_DURATION
fun View.fadeIn() {
animate().alpha(1f).setDuration(SHORT_ANIMATION_DURATION).withStartAction { isClickable = true }.start()
}
fun View.fadeOut() {
animate().alpha(0f).setDuration(SHORT_ANIMATION_DURATION).withEndAction { isClickable = false }.start()
}

View File

@ -111,8 +111,8 @@
android:contentDescription="@string/shutter"
android:src="@drawable/ic_shutter_animated"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/last_photo_video_preview"
app:layout_constraintStart_toEndOf="@id/toggle_camera"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintVertical_bias="1" />
<ImageView