Utilize fast-in-extra-slow-out interpolator.

This commit is contained in:
Alex Hart
2021-09-07 15:02:23 -03:00
committed by Greyson Parrelli
parent 969e763997
commit a805f9b6b4
8 changed files with 47 additions and 49 deletions

View File

@@ -39,6 +39,7 @@ import org.signal.core.util.logging.Log;
import org.thoughtcrime.securesms.LoggingFragment;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.animation.AnimationCompleteListener;
import org.thoughtcrime.securesms.mediasend.v2.MediaAnimations;
import org.thoughtcrime.securesms.mediasend.v2.MediaCountIndicatorButton;
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
import org.thoughtcrime.securesms.mms.GlideApp;
@@ -171,6 +172,7 @@ public class Camera1Fragment extends LoggingFragment implements CameraFragment,
public void fadeOutControls(@NonNull Runnable onEndAction) {
controlsContainer.setEnabled(false);
controlsContainer.animate()
.setInterpolator(MediaAnimations.getInterpolator())
.setDuration(250)
.alpha(0f)
.setListener(new AnimationCompleteListener() {
@@ -186,6 +188,7 @@ public class Camera1Fragment extends LoggingFragment implements CameraFragment,
public void fadeInControls() {
controlsContainer.setEnabled(false);
controlsContainer.animate()
.setInterpolator(MediaAnimations.getInterpolator())
.setDuration(250)
.alpha(1f)
.setListener(new AnimationCompleteListener() {

View File

@@ -41,6 +41,7 @@ import org.thoughtcrime.securesms.animation.AnimationCompleteListener;
import org.thoughtcrime.securesms.components.TooltipPopup;
import org.thoughtcrime.securesms.mediasend.camerax.CameraXFlashToggleView;
import org.thoughtcrime.securesms.mediasend.camerax.CameraXUtil;
import org.thoughtcrime.securesms.mediasend.v2.MediaAnimations;
import org.thoughtcrime.securesms.mediasend.v2.MediaCountIndicatorButton;
import org.thoughtcrime.securesms.mms.DecryptableStreamUriLoader.DecryptableUri;
import org.thoughtcrime.securesms.mms.MediaConstraints;
@@ -169,6 +170,7 @@ public class CameraXFragment extends LoggingFragment implements CameraFragment {
controlsContainer.animate()
.setDuration(250)
.alpha(0f)
.setInterpolator(MediaAnimations.getInterpolator())
.setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {
@@ -184,6 +186,7 @@ public class CameraXFragment extends LoggingFragment implements CameraFragment {
controlsContainer.animate()
.setDuration(250)
.alpha(1f)
.setInterpolator(MediaAnimations.getInterpolator())
.setListener(new AnimationCompleteListener() {
@Override
public void onAnimationEnd(Animator animation) {

View File

@@ -1,44 +1,13 @@
package org.thoughtcrime.securesms.mediasend.v2
import android.animation.Animator
import android.view.View
import org.thoughtcrime.securesms.animation.AnimationCompleteListener
import org.thoughtcrime.securesms.util.visible
import android.view.animation.Interpolator
import androidx.core.graphics.PathParser
import androidx.core.view.animation.PathInterpolatorCompat
object MediaAnimations {
private const val FADE_ANIMATION_DURATION = 150L
fun fadeIn(view: View) {
if (view.visible) {
return
}
view.visible = true
view.animate()
.setDuration(FADE_ANIMATION_DURATION)
.alpha(1f)
}
fun fadeOut(view: View) {
if (!view.visible) {
return
}
view.animate()
.setDuration(FADE_ANIMATION_DURATION)
.setListener(object : AnimationCompleteListener() {
override fun onAnimationEnd(animation: Animator?) {
view.visible = false
}
})
.alpha(0f)
}
fun fade(view: View, fadeIn: Boolean) {
if (fadeIn) {
fadeIn(view)
} else {
fadeOut(view)
}
}
/**
* Fast-In-Extra-Slow-Out Interpolator
*/
@JvmStatic
val interpolator: Interpolator = PathInterpolatorCompat.create(PathParser.createPathFromPathData("M 0,0 C 0.05, 0, 0.133333, 0.06, 0.166666, 0.4 C 0.208333, 0.82, 0.25, 1, 1, 1"))
}

View File

@@ -21,6 +21,7 @@ import org.thoughtcrime.securesms.conversation.mutiselect.forward.MultiselectFor
import org.thoughtcrime.securesms.keyboard.findListener
import org.thoughtcrime.securesms.mediasend.MediaSendActivityResult
import org.thoughtcrime.securesms.mediasend.v2.HudCommand
import org.thoughtcrime.securesms.mediasend.v2.MediaAnimations
import org.thoughtcrime.securesms.mediasend.v2.MediaSelectionNavigator
import org.thoughtcrime.securesms.mediasend.v2.MediaSelectionNavigator.Companion.requestPermissionsForGallery
import org.thoughtcrime.securesms.mediasend.v2.MediaSelectionState
@@ -273,6 +274,7 @@ class MediaReviewFragment : Fragment(R.layout.v2_media_review_fragment) {
val animatorSet = AnimatorSet()
animatorSet.playTogether(animators)
animatorSet.interpolator = MediaAnimations.interpolator
animatorSet.start()
this.animatorSet = animatorSet