Update editing animation.
This commit is contained in:
parent
fa487e1885
commit
bd3ab2cc38
3 changed files with 27 additions and 19 deletions
|
@ -1,8 +1,6 @@
|
|||
package org.thoughtcrime.securesms.components;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.content.Context;
|
||||
import android.os.Build;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.animation.AlphaAnimation;
|
||||
import android.view.animation.Animation;
|
||||
|
@ -26,9 +24,14 @@ public class HidingLinearLayout extends LinearLayout {
|
|||
super(context, attrs, defStyleAttr);
|
||||
}
|
||||
|
||||
public void hide() {
|
||||
public void hide(boolean shouldAnimate) {
|
||||
if (!isEnabled() || getVisibility() == GONE) return;
|
||||
|
||||
if (!shouldAnimate) {
|
||||
setVisibility(GONE);
|
||||
return;
|
||||
}
|
||||
|
||||
AnimationSet animation = new AnimationSet(true);
|
||||
animation.addAnimation(new ScaleAnimation(1, 0.5f, 1, 1, Animation.RELATIVE_TO_SELF, 1f, Animation.RELATIVE_TO_SELF, 0.5f));
|
||||
animation.addAnimation(new AlphaAnimation(1, 0));
|
||||
|
|
|
@ -425,6 +425,7 @@ public class InputPanel extends ConstraintLayout
|
|||
}
|
||||
|
||||
public void enterEditMessageMode(@NonNull RequestManager requestManager, @NonNull ConversationMessage conversationMessageToEdit, boolean fromDraft, boolean clearQuote) {
|
||||
boolean fromEditMessageMode = inEditMessageMode();
|
||||
int originalHeight = composeTextContainer.getMeasuredHeight();
|
||||
SpannableString textToEdit = conversationMessageToEdit.getDisplayBody(getContext());
|
||||
|
||||
|
@ -442,15 +443,20 @@ public class InputPanel extends ConstraintLayout
|
|||
}
|
||||
|
||||
this.messageToEdit = conversationMessageToEdit.getMessageRecord();
|
||||
|
||||
updateEditModeUi();
|
||||
updateEditModeThumbnail(requestManager);
|
||||
|
||||
int maxWidth = composeContainer.getWidth();
|
||||
if (composeContainer.getLayoutParams() instanceof MarginLayoutParams) {
|
||||
MarginLayoutParams layoutParams = (MarginLayoutParams) composeContainer.getLayoutParams();
|
||||
maxWidth -= layoutParams.leftMargin + layoutParams.rightMargin;
|
||||
int maxWidth = composeContainer.getWidth() - mediaKeyboard.getWidth();
|
||||
if (!fromEditMessageMode) {
|
||||
maxWidth -= editMessageCancel.getWidth();
|
||||
if (editMessageCancel.getLayoutParams() instanceof MarginLayoutParams) {
|
||||
MarginLayoutParams layoutParams = (MarginLayoutParams) editMessageCancel.getLayoutParams();
|
||||
maxWidth -= layoutParams.leftMargin;
|
||||
}
|
||||
}
|
||||
composeTextContainer.measure(MeasureSpec.makeMeasureSpec(maxWidth, MeasureSpec.AT_MOST), MeasureSpec.UNSPECIFIED);
|
||||
int finalHeight = (inEditMessageMode()) ? composeTextContainer.getMeasuredHeight() : composeTextContainer.getMeasuredHeight() + editMessageTitle.getMeasuredHeight();
|
||||
int finalHeight = composeTextContainer.getMeasuredHeight();
|
||||
|
||||
if (editMessageAnimator != null) {
|
||||
editMessageAnimator.cancel();
|
||||
|
@ -461,7 +467,6 @@ public class InputPanel extends ConstraintLayout
|
|||
ViewGroup.LayoutParams params = composeTextContainer.getLayoutParams();
|
||||
params.height = ViewGroup.LayoutParams.WRAP_CONTENT;
|
||||
composeTextContainer.setLayoutParams(params);
|
||||
updateEditModeUi();
|
||||
}
|
||||
});
|
||||
editMessageAnimator.start();
|
||||
|
|
|
@ -1746,35 +1746,35 @@ class ConversationFragment :
|
|||
inputPanel.isRecordingInLockedMode -> {
|
||||
buttonToggle.display(sendButton)
|
||||
quickAttachment.show()
|
||||
inlineAttachment.hide()
|
||||
inlineAttachment.hide(true)
|
||||
}
|
||||
|
||||
inputPanel.inEditMessageMode() -> {
|
||||
buttonToggle.display(sendEditButton)
|
||||
quickAttachment.hide()
|
||||
inlineAttachment.hide()
|
||||
quickAttachment.hide(false)
|
||||
inlineAttachment.hide(false)
|
||||
}
|
||||
|
||||
draftViewModel.voiceNoteDraft != null -> {
|
||||
buttonToggle.display(sendButton)
|
||||
quickAttachment.hide()
|
||||
inlineAttachment.hide()
|
||||
quickAttachment.hide(true)
|
||||
inlineAttachment.hide(true)
|
||||
}
|
||||
|
||||
composeText.text.isNullOrBlank() && !attachmentManager.isAttachmentPresent -> {
|
||||
buttonToggle.display(binding.conversationInputPanel.attachButton)
|
||||
quickAttachment.show()
|
||||
inlineAttachment.hide()
|
||||
inlineAttachment.hide(true)
|
||||
}
|
||||
|
||||
else -> {
|
||||
buttonToggle.display(sendButton)
|
||||
quickAttachment.hide()
|
||||
quickAttachment.hide(true)
|
||||
|
||||
if (!attachmentManager.isAttachmentPresent && !linkPreviewViewModel.hasLinkPreviewUi) {
|
||||
inlineAttachment.show()
|
||||
} else {
|
||||
inlineAttachment.hide()
|
||||
inlineAttachment.hide(true)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue