From 01f477a58770a38b6d4b981689a52136b0a2c78d Mon Sep 17 00:00:00 2001 From: Cody Henthorne Date: Thu, 16 Feb 2023 11:10:09 -0500 Subject: [PATCH] Fix voice note UX issues. --- .../animation/AnimationCompleteListener.java | 2 +- .../animation/AnimationStartListener.kt | 9 +++++ .../securesms/components/AnimatingToggle.java | 4 +-- .../securesms/components/InputPanel.java | 33 +++++++++++++++++-- .../ConversationParentFragment.java | 2 ++ 5 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 app/src/main/java/org/thoughtcrime/securesms/animation/AnimationStartListener.kt diff --git a/app/src/main/java/org/thoughtcrime/securesms/animation/AnimationCompleteListener.java b/app/src/main/java/org/thoughtcrime/securesms/animation/AnimationCompleteListener.java index 3063a04c91..afcb813d57 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/animation/AnimationCompleteListener.java +++ b/app/src/main/java/org/thoughtcrime/securesms/animation/AnimationCompleteListener.java @@ -11,7 +11,7 @@ public abstract class AnimationCompleteListener implements Animator.AnimatorList public abstract void onAnimationEnd(Animator animation); @Override - public final void onAnimationCancel(Animator animation) {} + public void onAnimationCancel(Animator animation) {} @Override public final void onAnimationRepeat(Animator animation) {} } diff --git a/app/src/main/java/org/thoughtcrime/securesms/animation/AnimationStartListener.kt b/app/src/main/java/org/thoughtcrime/securesms/animation/AnimationStartListener.kt new file mode 100644 index 0000000000..228e0503a5 --- /dev/null +++ b/app/src/main/java/org/thoughtcrime/securesms/animation/AnimationStartListener.kt @@ -0,0 +1,9 @@ +package org.thoughtcrime.securesms.animation + +import android.animation.Animator + +abstract class AnimationStartListener : Animator.AnimatorListener { + override fun onAnimationEnd(animation: Animator) = Unit + override fun onAnimationCancel(animation: Animator) = Unit + override fun onAnimationRepeat(animation: Animator) = Unit +} diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/AnimatingToggle.java b/app/src/main/java/org/thoughtcrime/securesms/components/AnimatingToggle.java index 41676c6a52..c049c07e8d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/AnimatingToggle.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/AnimatingToggle.java @@ -54,7 +54,7 @@ public class AnimatingToggle extends FrameLayout { } public void display(@Nullable View view) { - if (view == current) return; + if (view == current && current.getVisibility() == View.VISIBLE) return; if (current != null) ViewUtil.animateOut(current, outAnimation, View.GONE); if (view != null) ViewUtil.animateIn(view, inAnimation); @@ -62,7 +62,7 @@ public class AnimatingToggle extends FrameLayout { } public void displayQuick(@Nullable View view) { - if (view == current) return; + if (view == current && current.getVisibility() == View.VISIBLE) return; if (current != null) current.setVisibility(View.GONE); if (view != null) view.setVisibility(View.VISIBLE); diff --git a/app/src/main/java/org/thoughtcrime/securesms/components/InputPanel.java b/app/src/main/java/org/thoughtcrime/securesms/components/InputPanel.java index 4f23813225..78e438b60c 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/components/InputPanel.java +++ b/app/src/main/java/org/thoughtcrime/securesms/components/InputPanel.java @@ -33,6 +33,7 @@ import org.signal.core.util.ThreadUtil; import org.signal.core.util.logging.Log; import org.thoughtcrime.securesms.R; import org.thoughtcrime.securesms.animation.AnimationCompleteListener; +import org.thoughtcrime.securesms.animation.AnimationStartListener; import org.thoughtcrime.securesms.audio.AudioRecordingHandler; import org.thoughtcrime.securesms.components.emoji.EmojiEventListener; import org.thoughtcrime.securesms.components.emoji.EmojiToggle; @@ -573,11 +574,39 @@ public class InputPanel extends LinearLayout } private void fadeIn(@NonNull View v) { - v.animate().alpha(1).setDuration(FADE_TIME).start(); + v.animate() + .setListener(new AnimationStartListener() { + @Override + public void onAnimationStart(@NonNull Animator animation) { + v.setVisibility(View.VISIBLE); + } + + @Override + public void onAnimationCancel(@NonNull Animator animation) { + v.setVisibility(View.INVISIBLE); + } + }) + .alpha(1) + .setDuration(FADE_TIME) + .start(); } private void fadeOut(@NonNull View v) { - v.animate().alpha(0).setDuration(FADE_TIME).start(); + v.animate() + .setListener(new AnimationCompleteListener() { + @Override + public void onAnimationEnd(Animator animation) { + v.setVisibility(View.INVISIBLE); + } + + @Override + public void onAnimationCancel(Animator animation) { + v.setVisibility(View.VISIBLE); + } + }) + .alpha(0) + .setDuration(FADE_TIME) + .start(); } private void updateVisibility() { diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationParentFragment.java b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationParentFragment.java index 496629422a..674b28d59d 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationParentFragment.java +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/ConversationParentFragment.java @@ -624,6 +624,8 @@ public class ConversationParentFragment extends Fragment if (SignalStore.rateLimit().needsRecaptcha()) { RecaptchaProofBottomSheetFragment.show(getChildFragmentManager()); } + + updateToggleButtonState(); } @Override