- hiding button on 3rd party intent
- disabling option to change resolution when capturing media
This commit is contained in:
darthpaul 2022-08-25 19:09:13 +01:00
parent 0fdb751909
commit 34c0f0bd6a
3 changed files with 19 additions and 11 deletions

View File

@ -261,7 +261,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
private fun checkVideoCaptureIntent() {
if (intent?.action == MediaStore.ACTION_VIDEO_CAPTURE) {
if (isVideoCaptureIntent()) {
mIsInPhotoMode = false
hideIntentButtons()
shutter.setImageResource(R.drawable.ic_video_rec)
@ -386,6 +386,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
private fun handleShutter() {
if (mIsInPhotoMode) {
toggleBottomButtons(true)
change_resolution.isEnabled = true
mPreview?.tryTakePicture()
shutter_animation.alpha = 1.0f
shutter_animation.animate().alpha(0f).setDuration(CAPTURE_ANIMATION_DURATION).start()
@ -607,6 +608,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
override fun onMediaSaved(uri: Uri) {
change_resolution.isEnabled = true
loadLastTakenMedia(uri)
if (isImageCaptureIntent()) {
Intent().apply {
@ -642,6 +644,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
override fun onVideoRecordingStarted() {
shutter.setImageResource(R.drawable.ic_video_stop)
toggle_camera.beInvisible()
change_resolution.isEnabled = false
video_rec_curr_timer.beVisible()
}
@ -649,6 +652,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
shutter.setImageResource(R.drawable.ic_video_rec)
video_rec_curr_timer.text = 0.getFormattedDuration()
video_rec_curr_timer.beGone()
change_resolution.isEnabled = true
toggle_camera.beVisible()
}
@ -680,13 +684,13 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
private fun closeOptions(): Boolean {
if (media_size_toggle_group.isVisible()) {
media_size_toggle_group.beGone()
top_group.beVisible()
showTopIcons()
return true
}
if (flash_toggle_group.isVisible()) {
flash_toggle_group.beGone()
top_group.beVisible()
showTopIcons()
return true
}
return false
@ -739,19 +743,28 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
}
private fun showResolutionOptions() {
top_group.beInvisible()
hideTopIcons()
media_size_toggle_group.beVisible()
media_size_toggle_group.children.map { it as MaterialButton }.forEach(::setButtonColors)
}
override fun showFlashOptions(photoCapture: Boolean) {
flash_auto.beVisibleIf(photoCapture)
top_group.beInvisible()
hideTopIcons()
flash_toggle_group.beVisible()
flash_toggle_group.check(config.flashlightState.toFlashModeId())
flash_toggle_group.children.map { it as MaterialButton }.forEach(::setButtonColors)
}
private fun showTopIcons() {
listOf(toggle_flash, change_resolution).forEach { it.beVisible() }
settings.beVisibleIf(!is3rdPartyIntent())
}
private fun hideTopIcons() {
listOf(toggle_flash, change_resolution, settings).forEach { it.beInvisible() }
}
private fun setButtonColors(button: MaterialButton) {
val primaryColor = getProperPrimaryColor()
val states = arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked))

View File

@ -2,5 +2,6 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:color="@color/color_accent" android:state_selected="true" />
<item android:color="@color/color_accent" android:state_checked="true" />
<item android:color="@color/radiobutton_disabled" android:state_enabled="false" />
<item android:color="@color/md_grey_white" />
</selector>

View File

@ -42,12 +42,6 @@
app:layout_constraintTop_toTopOf="parent"
tools:visibility="visible" />
<androidx.constraintlayout.widget.Group
android:id="@+id/top_group"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:constraint_referenced_ids="settings,change_resolution,toggle_flash" />
<ImageView
android:id="@+id/toggle_flash"
android:layout_width="@dimen/top_icon_size"