UI fixes
- hiding button on 3rd party intent - disabling option to change resolution when capturing media
This commit is contained in:
parent
0fdb751909
commit
34c0f0bd6a
|
@ -261,7 +261,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkVideoCaptureIntent() {
|
private fun checkVideoCaptureIntent() {
|
||||||
if (intent?.action == MediaStore.ACTION_VIDEO_CAPTURE) {
|
if (isVideoCaptureIntent()) {
|
||||||
mIsInPhotoMode = false
|
mIsInPhotoMode = false
|
||||||
hideIntentButtons()
|
hideIntentButtons()
|
||||||
shutter.setImageResource(R.drawable.ic_video_rec)
|
shutter.setImageResource(R.drawable.ic_video_rec)
|
||||||
|
@ -386,6 +386,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
private fun handleShutter() {
|
private fun handleShutter() {
|
||||||
if (mIsInPhotoMode) {
|
if (mIsInPhotoMode) {
|
||||||
toggleBottomButtons(true)
|
toggleBottomButtons(true)
|
||||||
|
change_resolution.isEnabled = true
|
||||||
mPreview?.tryTakePicture()
|
mPreview?.tryTakePicture()
|
||||||
shutter_animation.alpha = 1.0f
|
shutter_animation.alpha = 1.0f
|
||||||
shutter_animation.animate().alpha(0f).setDuration(CAPTURE_ANIMATION_DURATION).start()
|
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) {
|
override fun onMediaSaved(uri: Uri) {
|
||||||
|
change_resolution.isEnabled = true
|
||||||
loadLastTakenMedia(uri)
|
loadLastTakenMedia(uri)
|
||||||
if (isImageCaptureIntent()) {
|
if (isImageCaptureIntent()) {
|
||||||
Intent().apply {
|
Intent().apply {
|
||||||
|
@ -642,6 +644,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
override fun onVideoRecordingStarted() {
|
override fun onVideoRecordingStarted() {
|
||||||
shutter.setImageResource(R.drawable.ic_video_stop)
|
shutter.setImageResource(R.drawable.ic_video_stop)
|
||||||
toggle_camera.beInvisible()
|
toggle_camera.beInvisible()
|
||||||
|
change_resolution.isEnabled = false
|
||||||
video_rec_curr_timer.beVisible()
|
video_rec_curr_timer.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -649,6 +652,7 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
shutter.setImageResource(R.drawable.ic_video_rec)
|
shutter.setImageResource(R.drawable.ic_video_rec)
|
||||||
video_rec_curr_timer.text = 0.getFormattedDuration()
|
video_rec_curr_timer.text = 0.getFormattedDuration()
|
||||||
video_rec_curr_timer.beGone()
|
video_rec_curr_timer.beGone()
|
||||||
|
change_resolution.isEnabled = true
|
||||||
toggle_camera.beVisible()
|
toggle_camera.beVisible()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -680,13 +684,13 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
private fun closeOptions(): Boolean {
|
private fun closeOptions(): Boolean {
|
||||||
if (media_size_toggle_group.isVisible()) {
|
if (media_size_toggle_group.isVisible()) {
|
||||||
media_size_toggle_group.beGone()
|
media_size_toggle_group.beGone()
|
||||||
top_group.beVisible()
|
showTopIcons()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flash_toggle_group.isVisible()) {
|
if (flash_toggle_group.isVisible()) {
|
||||||
flash_toggle_group.beGone()
|
flash_toggle_group.beGone()
|
||||||
top_group.beVisible()
|
showTopIcons()
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
return false
|
return false
|
||||||
|
@ -739,19 +743,28 @@ class MainActivity : SimpleActivity(), PhotoProcessor.MediaSavedListener, Camera
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showResolutionOptions() {
|
private fun showResolutionOptions() {
|
||||||
top_group.beInvisible()
|
hideTopIcons()
|
||||||
media_size_toggle_group.beVisible()
|
media_size_toggle_group.beVisible()
|
||||||
media_size_toggle_group.children.map { it as MaterialButton }.forEach(::setButtonColors)
|
media_size_toggle_group.children.map { it as MaterialButton }.forEach(::setButtonColors)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun showFlashOptions(photoCapture: Boolean) {
|
override fun showFlashOptions(photoCapture: Boolean) {
|
||||||
flash_auto.beVisibleIf(photoCapture)
|
flash_auto.beVisibleIf(photoCapture)
|
||||||
top_group.beInvisible()
|
hideTopIcons()
|
||||||
flash_toggle_group.beVisible()
|
flash_toggle_group.beVisible()
|
||||||
flash_toggle_group.check(config.flashlightState.toFlashModeId())
|
flash_toggle_group.check(config.flashlightState.toFlashModeId())
|
||||||
flash_toggle_group.children.map { it as MaterialButton }.forEach(::setButtonColors)
|
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) {
|
private fun setButtonColors(button: MaterialButton) {
|
||||||
val primaryColor = getProperPrimaryColor()
|
val primaryColor = getProperPrimaryColor()
|
||||||
val states = arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked))
|
val states = arrayOf(intArrayOf(-android.R.attr.state_checked), intArrayOf(android.R.attr.state_checked))
|
||||||
|
|
|
@ -2,5 +2,6 @@
|
||||||
<selector xmlns:android="http://schemas.android.com/apk/res/android">
|
<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_selected="true" />
|
||||||
<item android:color="@color/color_accent" android:state_checked="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" />
|
<item android:color="@color/md_grey_white" />
|
||||||
</selector>
|
</selector>
|
||||||
|
|
|
@ -42,12 +42,6 @@
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
tools:visibility="visible" />
|
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
|
<ImageView
|
||||||
android:id="@+id/toggle_flash"
|
android:id="@+id/toggle_flash"
|
||||||
android:layout_width="@dimen/top_icon_size"
|
android:layout_width="@dimen/top_icon_size"
|
||||||
|
|
Loading…
Reference in New Issue