From 5eebc995ff255d0dbbca6fe37eb98a030e905de5 Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 30 Dec 2021 16:52:58 +0100 Subject: [PATCH] Animate the attachment open/close button --- .../attachments/AttachmentTypeSelectorView.kt | 16 ++++++++++++++++ .../main/res/drawable/ic_attachment_close.xml | 15 --------------- .../res/layout/view_attachment_type_selector.xml | 6 ++++-- 3 files changed, 20 insertions(+), 17 deletions(-) delete mode 100644 vector/src/main/res/drawable/ic_attachment_close.xml diff --git a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt index f1aca2cb15..c56b3ac832 100644 --- a/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt +++ b/vector/src/main/java/im/vector/app/features/attachments/AttachmentTypeSelectorView.kt @@ -84,7 +84,21 @@ class AttachmentTypeSelectorView(context: Context, } } + private fun animateOpen() { + views.attachmentCloseButton.animate() + .setDuration(200) + .rotation(135f) + } + + private fun animateClose() { + views.attachmentCloseButton.animate() + .setDuration(200) + .rotation(0f) + } + fun show(anchor: View) { + animateOpen() + this.anchor = anchor val anchorCoordinates = IntArray(2) anchor.getLocationOnScreen(anchorCoordinates) @@ -96,6 +110,8 @@ class AttachmentTypeSelectorView(context: Context, } override fun dismiss() { + animateClose() + val capturedAnchor = anchor if (capturedAnchor != null) { animateWindowOutCircular(capturedAnchor, contentView) diff --git a/vector/src/main/res/drawable/ic_attachment_close.xml b/vector/src/main/res/drawable/ic_attachment_close.xml deleted file mode 100644 index 76f0d3d064..0000000000 --- a/vector/src/main/res/drawable/ic_attachment_close.xml +++ /dev/null @@ -1,15 +0,0 @@ - - - - diff --git a/vector/src/main/res/layout/view_attachment_type_selector.xml b/vector/src/main/res/layout/view_attachment_type_selector.xml index 72b95c98db..463d05d95d 100644 --- a/vector/src/main/res/layout/view_attachment_type_selector.xml +++ b/vector/src/main/res/layout/view_attachment_type_selector.xml @@ -1,6 +1,7 @@ @@ -12,10 +13,11 @@ android:layout_margin="@dimen/composer_attachment_margin" android:background="@null" android:contentDescription="@string/action_close" - android:src="@drawable/ic_attachment_close" + android:src="@drawable/ic_attachment" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" - app:layout_constraintTop_toTopOf="parent" /> + app:layout_constraintTop_toTopOf="parent" + tools:rotation="135" />