diff --git a/app/src/main/kotlin/com/w2sv/autocrop/activities/main/fragments/flowfield/FlowFieldFragment.kt b/app/src/main/kotlin/com/w2sv/autocrop/activities/main/fragments/flowfield/FlowFieldFragment.kt index aac470e7..391187f7 100644 --- a/app/src/main/kotlin/com/w2sv/autocrop/activities/main/fragments/flowfield/FlowFieldFragment.kt +++ b/app/src/main/kotlin/com/w2sv/autocrop/activities/main/fragments/flowfield/FlowFieldFragment.kt @@ -20,6 +20,7 @@ import androidx.lifecycle.SavedStateHandle import androidx.lifecycle.lifecycleScope import androidx.lifecycle.viewModelScope import com.daimajia.androidanimations.library.Techniques +import com.daimajia.androidanimations.library.YoYo import com.w2sv.androidutils.BackPressListener import com.w2sv.androidutils.extensions.getColoredIcon import com.w2sv.androidutils.extensions.getLong @@ -30,6 +31,7 @@ import com.w2sv.androidutils.extensions.launchDelayed import com.w2sv.androidutils.extensions.postValue import com.w2sv.androidutils.extensions.show import com.w2sv.androidutils.extensions.showSystemBars +import com.w2sv.androidutils.extensions.toggle import com.w2sv.androidutils.extensions.uris import com.w2sv.autocrop.R import com.w2sv.autocrop.activities.ApplicationFragment @@ -118,7 +120,11 @@ class FlowFieldFragment : val liveCropSaveDirIdentifier: LiveData = MutableLiveData(cropSaveDirPreferences.pathIdentifier) - var liveShowingFlowField: LiveData = MutableLiveData(false) + var hideForegroundLive: LiveData = MutableLiveData(false) + val hideForegroundTogglingEnabled: Boolean + get() = foregroundToggleAnimation?.let { !it.isStarted } + ?: true + var foregroundToggleAnimation: YoYo.YoYoString? = null val backPressHandler = BackPressListener( viewModelScope, @@ -166,35 +172,34 @@ class FlowFieldFragment : } private fun ViewModel.setLiveDataObservers() { - liveShowingFlowField.observe(viewLifecycleOwner) { + hideForegroundLive.observe(viewLifecycleOwner) { if (it) { requireActivity().hideSystemBars() with(binding.foregroundLayout) { if (lifecycle.currentState == Lifecycle.State.STARTED) hide() else - fadeOut() + foregroundToggleAnimation = fadeOut() } } else { requireActivity().showSystemBars() - binding.foregroundLayout.fadeIn() + foregroundToggleAnimation = binding.foregroundLayout.fadeIn() } } } private fun showLayoutElements() { - val fadeInButtons: List = listOf( - binding.navigationViewToggleButton, - binding.imageSelectionButton - ) val savedAnyCrops: Boolean = viewModel.ioResults?.let { it.nSavedCrops != 0 } ?: false if (!viewModel.fadedInButtons) { - fadeInButtons.forEach { - it.fadeIn(resources.getLong(R.integer.duration_flowfield_buttons_fade_in)) - } + fadeIn( + binding.navigationViewToggleButton, + binding.imageSelectionButton, + binding.foregroundToggleButton, + duration = resources.getLong(R.integer.duration_flowfield_buttons_fade_in) + ) if (savedAnyCrops) lifecycleScope.launchDelayed(resources.getLong(R.integer.duration_flowfield_buttons_half_faded_in)) { @@ -229,14 +234,9 @@ class FlowFieldFragment : ) ) } - showFlowfieldButton.setOnClickListener { - viewModel.liveShowingFlowField.postValue(true) - } - relativeLayout.setOnClickListener { - with(viewModel.liveShowingFlowField) { - if (value == true) - postValue(false) - } + foregroundToggleButton.setOnClickListener { + if (viewModel.hideForegroundTogglingEnabled) + viewModel.hideForegroundLive.toggle() } } diff --git a/app/src/main/kotlin/com/w2sv/autocrop/activities/main/fragments/flowfield/views/FlowFieldDrawerLayout.kt b/app/src/main/kotlin/com/w2sv/autocrop/activities/main/fragments/flowfield/views/FlowFieldDrawerLayout.kt index f364135f..8df55668 100644 --- a/app/src/main/kotlin/com/w2sv/autocrop/activities/main/fragments/flowfield/views/FlowFieldDrawerLayout.kt +++ b/app/src/main/kotlin/com/w2sv/autocrop/activities/main/fragments/flowfield/views/FlowFieldDrawerLayout.kt @@ -29,7 +29,7 @@ class FlowFieldDrawerLayout(context: Context, attributeSet: AttributeSet) : Draw val alphaOverlaidButtons = 1 - slideOffset imageSelectionButton.alpha = alphaOverlaidButtons shareCropsButton.alpha = alphaOverlaidButtons - showFlowfieldButton.alpha = alphaOverlaidButtons + foregroundToggleButton.alpha = alphaOverlaidButtons } } ) diff --git a/app/src/main/kotlin/com/w2sv/autocrop/ui/ViewAnimations.kt b/app/src/main/kotlin/com/w2sv/autocrop/ui/ViewAnimations.kt index 5230bcef..0fcd23bb 100644 --- a/app/src/main/kotlin/com/w2sv/autocrop/ui/ViewAnimations.kt +++ b/app/src/main/kotlin/com/w2sv/autocrop/ui/ViewAnimations.kt @@ -4,24 +4,22 @@ import android.view.View import com.daimajia.androidanimations.library.Techniques import com.daimajia.androidanimations.library.YoYo import com.w2sv.androidutils.extensions.getLong +import com.w2sv.androidutils.extensions.hide import com.w2sv.androidutils.extensions.show import com.w2sv.autocrop.R fun View.animate( technique: Techniques, - duration: Long? = null, - delay: Long = 0L + duration: Long? = null ): YoYo.YoYoString = - animationComposer(technique, duration, delay) + animationComposer(technique, duration) .playOn(this) fun View.animationComposer( technique: Techniques, - duration: Long? = null, - delay: Long = 0L + duration: Long? = null ): YoYo.AnimationComposer = YoYo.with(technique) - .delay(delay) .duration( duration ?: resources.getLong(R.integer.duration_view_animation) @@ -32,13 +30,13 @@ fun crossFade(fadeOut: View, fadeIn: View, duration: Long? = null) { fadeIn.fadeIn(duration) } -fun fadeIn(vararg view: View, duration: Long? = null){ +fun fadeIn(vararg view: View, duration: Long? = null) { view.forEach { it.fadeIn(duration) } } -fun fadeOut(vararg view: View, duration: Long? = null){ +fun fadeOut(vararg view: View, duration: Long? = null) { view.forEach { it.fadeOut(duration) } @@ -48,11 +46,13 @@ fun View.fadeIn(duration: Long? = null): YoYo.YoYoString = apply { show() } - .animate(Techniques.FadeIn, duration) + .animationComposer(Techniques.FadeIn, duration) + .playOn(this) -fun View.fadeOut(duration: Long? = null, delay: Long = 0, onEndVisibility: Int = View.GONE): YoYo.YoYoString = - animationComposer(Techniques.FadeOut, duration, delay) +fun View.fadeOut(duration: Long? = null, delay: Long = 0): YoYo.YoYoString = + animationComposer(Techniques.FadeOut, duration) + .delay(delay) .onEnd { - visibility = onEndVisibility + hide() } .playOn(this) \ No newline at end of file diff --git a/app/src/main/res/layout-land/fragment_flowfield.xml b/app/src/main/res/layout-land/fragment_flowfield.xml new file mode 100644 index 00000000..6181c73a --- /dev/null +++ b/app/src/main/res/layout-land/fragment_flowfield.xml @@ -0,0 +1,110 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/app/src/main/res/layout/fragment_flowfield.xml b/app/src/main/res/layout/fragment_flowfield.xml index d271ade2..283d4de3 100644 --- a/app/src/main/res/layout/fragment_flowfield.xml +++ b/app/src/main/res/layout/fragment_flowfield.xml @@ -16,10 +16,21 @@ android:layout_height="match_parent"> + + - - #656565 + #809B9B9B + #1C1C1E #BC275E #911945