From be158eccc1555f6a2613b7dd9c178423a917fa1f Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Fri, 18 Jun 2021 11:05:14 +1000 Subject: [PATCH] Animate the mention candidates view --- .../conversation/v2/ConversationActivityV2.kt | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt index 28dc19f167..70b9ae9f54 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/ConversationActivityV2.kt @@ -44,6 +44,7 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe private var actionMode: ActionMode? = null private var isLockViewExpanded = false private var isShowingAttachmentOptions = false + private var mentionCandidatesView: MentionCandidatesView? = null // TODO: Selected message background color // TODO: Overflow menu background + text color @@ -173,6 +174,8 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe // TODO: Work this out further if (newContent.contains("@")) { showMentionCandidates() + } else { + hideMentionCandidates() } } @@ -182,7 +185,26 @@ class ConversationActivityV2 : PassphraseRequiredActionBarActivity(), InputBarDe mentionCandidatesView.glide = glide inputBarAdditionalContentContainer.addView(mentionCandidatesView) val mentionCandidates = MentionsManager.getMentionCandidates("", threadID, thread.isOpenGroupRecipient) + this.mentionCandidatesView = mentionCandidatesView mentionCandidatesView.show(mentionCandidates, threadID) + mentionCandidatesView.alpha = 0.0f + val animation = ValueAnimator.ofObject(FloatEvaluator(), mentionCandidatesView.alpha, 1.0f) + animation.duration = 250L + animation.addUpdateListener { animator -> + mentionCandidatesView.alpha = animator.animatedValue as Float + } + animation.start() + } + + private fun hideMentionCandidates() { + val mentionCandidatesView = mentionCandidatesView ?: return + val animation = ValueAnimator.ofObject(FloatEvaluator(), mentionCandidatesView.alpha, 0.0f) + animation.duration = 250L + animation.addUpdateListener { animator -> + mentionCandidatesView.alpha = animator.animatedValue as Float + if (animator.animatedFraction == 1.0f) { inputBarAdditionalContentContainer.removeAllViews() } + } + animation.start() } override fun toggleAttachmentOptions() {