mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-02-21 10:17:56 +00:00
Utilize fast-in-extra-slow-out interpolator.
This commit is contained in:
committed by
Greyson Parrelli
parent
969e763997
commit
a805f9b6b4
@@ -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() {
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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"))
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -47,6 +47,7 @@ import org.thoughtcrime.securesms.imageeditor.renderers.FaceBlurRenderer;
|
||||
import org.thoughtcrime.securesms.imageeditor.renderers.MultiLineTextRenderer;
|
||||
import org.thoughtcrime.securesms.keyvalue.SignalStore;
|
||||
import org.thoughtcrime.securesms.mediasend.MediaSendPageFragment;
|
||||
import org.thoughtcrime.securesms.mediasend.v2.MediaAnimations;
|
||||
import org.thoughtcrime.securesms.mms.MediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.PushMediaConstraints;
|
||||
import org.thoughtcrime.securesms.mms.SentMediaQuality;
|
||||
@@ -648,6 +649,7 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
|
||||
|
||||
resizeAnimation = new ResizeAnimation(imageEditorView, targetWidth, targetHeight);
|
||||
resizeAnimation.setDuration(250);
|
||||
resizeAnimation.setInterpolator(MediaAnimations.getInterpolator());
|
||||
imageEditorView.startAnimation(resizeAnimation);
|
||||
}
|
||||
|
||||
@@ -668,6 +670,7 @@ public final class ImageEditorFragment extends Fragment implements ImageEditorHu
|
||||
|
||||
resizeAnimation = new ResizeAnimation(imageEditorView, targetWidth, targetHeight);
|
||||
resizeAnimation.setDuration(250);
|
||||
resizeAnimation.setInterpolator(MediaAnimations.getInterpolator());
|
||||
imageEditorView.startAnimation(resizeAnimation);
|
||||
}
|
||||
|
||||
|
||||
@@ -11,7 +11,6 @@ import android.util.AttributeSet
|
||||
import android.view.HapticFeedbackConstants
|
||||
import android.view.MotionEvent
|
||||
import android.view.View
|
||||
import android.view.animation.DecelerateInterpolator
|
||||
import android.widget.FrameLayout
|
||||
import android.widget.ImageView
|
||||
import android.widget.SeekBar
|
||||
@@ -24,6 +23,7 @@ import com.airbnb.lottie.SimpleColorFilter
|
||||
import com.google.android.material.switchmaterial.SwitchMaterial
|
||||
import org.thoughtcrime.securesms.R
|
||||
import org.thoughtcrime.securesms.components.TooltipPopup
|
||||
import org.thoughtcrime.securesms.mediasend.v2.MediaAnimations
|
||||
import org.thoughtcrime.securesms.scribbles.HSVColorSlider.getColor
|
||||
import org.thoughtcrime.securesms.scribbles.HSVColorSlider.setColor
|
||||
import org.thoughtcrime.securesms.scribbles.HSVColorSlider.setUpForColor
|
||||
@@ -180,15 +180,9 @@ class ImageEditorHudV2 @JvmOverloads constructor(
|
||||
|
||||
widthSeekBar.setOnTouchListener { v, event ->
|
||||
if (event.action == MotionEvent.ACTION_DOWN) {
|
||||
v?.animate()
|
||||
?.setDuration(ANIMATION_DURATION)
|
||||
?.setInterpolator(DecelerateInterpolator())
|
||||
?.translationX(ViewUtil.dpToPx(36).toFloat())
|
||||
animateWidthSeekbarIn()
|
||||
} else if (event.action == MotionEvent.ACTION_UP || event.action == MotionEvent.ACTION_CANCEL) {
|
||||
v?.animate()
|
||||
?.setDuration(ANIMATION_DURATION)
|
||||
?.setInterpolator(DecelerateInterpolator())
|
||||
?.translationX(0f)
|
||||
animateWidthSeekbarOut()
|
||||
}
|
||||
|
||||
v.onTouchEvent(event)
|
||||
@@ -197,6 +191,20 @@ class ImageEditorHudV2 @JvmOverloads constructor(
|
||||
widthSeekBar.progress = 20
|
||||
}
|
||||
|
||||
private fun animateWidthSeekbarIn() {
|
||||
widthSeekBar.animate()
|
||||
?.setDuration(ANIMATION_DURATION)
|
||||
?.setInterpolator(MediaAnimations.interpolator)
|
||||
?.translationX(ViewUtil.dpToPx(36).toFloat())
|
||||
}
|
||||
|
||||
private fun animateWidthSeekbarOut() {
|
||||
widthSeekBar.animate()
|
||||
?.setDuration(ANIMATION_DURATION)
|
||||
?.setInterpolator(MediaAnimations.interpolator)
|
||||
?.translationX(0f)
|
||||
}
|
||||
|
||||
fun setUpForAvatarEditing() {
|
||||
isAvatarEdit = true
|
||||
}
|
||||
@@ -292,6 +300,7 @@ class ImageEditorHudV2 @JvmOverloads constructor(
|
||||
ObjectAnimator.ofFloat(deleteBackground, "scaleY", deleteBackground.scaleY, 1.365f),
|
||||
)
|
||||
duration = ANIMATION_DURATION
|
||||
interpolator = MediaAnimations.interpolator
|
||||
start()
|
||||
}
|
||||
}
|
||||
@@ -304,6 +313,7 @@ class ImageEditorHudV2 @JvmOverloads constructor(
|
||||
ObjectAnimator.ofFloat(deleteBackground, "scaleY", deleteBackground.scaleY, 1f),
|
||||
)
|
||||
duration = ANIMATION_DURATION
|
||||
interpolator = MediaAnimations.interpolator
|
||||
start()
|
||||
}
|
||||
}
|
||||
@@ -440,6 +450,7 @@ class ImageEditorHudV2 @JvmOverloads constructor(
|
||||
modeAnimatorSet = AnimatorSet().apply {
|
||||
playTogether(animations)
|
||||
duration = ANIMATION_DURATION
|
||||
interpolator = MediaAnimations.interpolator
|
||||
start()
|
||||
}
|
||||
}
|
||||
@@ -454,6 +465,7 @@ class ImageEditorHudV2 @JvmOverloads constructor(
|
||||
undoAnimatorSet = AnimatorSet().apply {
|
||||
playTogether(animations)
|
||||
duration = ANIMATION_DURATION
|
||||
interpolator = MediaAnimations.interpolator
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user