From cc8da82d02fe7d69f1865fab94427a5260e0ce56 Mon Sep 17 00:00:00 2001 From: Onuray Sahin Date: Thu, 30 Dec 2021 16:28:50 +0300 Subject: [PATCH 1/3] New attachment picker implemented. --- changelog.d/3444.bugfix | 1 + .../attachments/AttachmentTypeSelectorView.kt | 71 ++--- .../home/room/detail/RoomDetailFragment.kt | 2 +- .../ic_attachment_stickers_white_24dp.png | Bin 595 -> 0 bytes .../ic_attachment_stickers_white_24dp.png | Bin 421 -> 0 bytes .../ic_attachment_stickers_white_24dp.png | Bin 734 -> 0 bytes .../ic_attachment_stickers_white_24dp.png | Bin 1142 -> 0 bytes .../ic_attachment_stickers_white_24dp.png | Bin 1521 -> 0 bytes .../res/drawable/ic_attachment_camera.xml | 13 + .../ic_attachment_camera_white_24dp.xml | 4 - .../main/res/drawable/ic_attachment_close.xml | 15 + .../main/res/drawable/ic_attachment_file.xml | 13 + .../ic_attachment_file_white_24dp.xml | 4 - .../res/drawable/ic_attachment_gallery.xml | 12 + .../ic_attachment_gallery_white_24dp.xml | 4 - .../res/drawable/ic_attachment_location.xml | 9 + ..._white_24dp.xml => ic_attachment_poll.xml} | 2 +- .../res/drawable/ic_attachment_sticker.xml | 13 + .../layout/view_attachment_type_selector.xml | 268 ++++++------------ 19 files changed, 185 insertions(+), 246 deletions(-) create mode 100644 changelog.d/3444.bugfix delete mode 100644 vector/src/main/res/drawable-hdpi/ic_attachment_stickers_white_24dp.png delete mode 100644 vector/src/main/res/drawable-mdpi/ic_attachment_stickers_white_24dp.png delete mode 100644 vector/src/main/res/drawable-xhdpi/ic_attachment_stickers_white_24dp.png delete mode 100644 vector/src/main/res/drawable-xxhdpi/ic_attachment_stickers_white_24dp.png delete mode 100644 vector/src/main/res/drawable-xxxhdpi/ic_attachment_stickers_white_24dp.png create mode 100644 vector/src/main/res/drawable/ic_attachment_camera.xml delete mode 100644 vector/src/main/res/drawable/ic_attachment_camera_white_24dp.xml create mode 100644 vector/src/main/res/drawable/ic_attachment_close.xml create mode 100644 vector/src/main/res/drawable/ic_attachment_file.xml delete mode 100644 vector/src/main/res/drawable/ic_attachment_file_white_24dp.xml create mode 100644 vector/src/main/res/drawable/ic_attachment_gallery.xml delete mode 100644 vector/src/main/res/drawable/ic_attachment_gallery_white_24dp.xml create mode 100644 vector/src/main/res/drawable/ic_attachment_location.xml rename vector/src/main/res/drawable/{ic_attachment_poll_white_24dp.xml => ic_attachment_poll.xml} (93%) create mode 100644 vector/src/main/res/drawable/ic_attachment_sticker.xml diff --git a/changelog.d/3444.bugfix b/changelog.d/3444.bugfix new file mode 100644 index 0000000000..bf397da5b7 --- /dev/null +++ b/changelog.d/3444.bugfix @@ -0,0 +1 @@ +Attachment picker UI improvements \ No newline at end of file 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 ccc07ef118..f1aca2cb15 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 @@ -26,24 +26,18 @@ import android.view.LayoutInflater import android.view.View import android.view.ViewAnimationUtils import android.view.animation.Animation -import android.view.animation.AnimationSet -import android.view.animation.OvershootInterpolator -import android.view.animation.ScaleAnimation import android.view.animation.TranslateAnimation import android.widget.ImageButton import android.widget.LinearLayout import android.widget.PopupWindow import androidx.core.view.doOnNextLayout import androidx.core.view.isVisible -import com.amulyakhare.textdrawable.TextDrawable -import com.amulyakhare.textdrawable.util.ColorGenerator import im.vector.app.R -import im.vector.app.core.extensions.getMeasurements +import im.vector.app.core.epoxy.onClick import im.vector.app.core.utils.PERMISSIONS_EMPTY import im.vector.app.core.utils.PERMISSIONS_FOR_PICKING_CONTACT import im.vector.app.core.utils.PERMISSIONS_FOR_TAKING_PHOTO import im.vector.app.databinding.ViewAttachmentTypeSelectorBinding -import im.vector.app.features.attachments.AttachmentTypeSelectorView.Callback import kotlin.math.max private const val ANIMATION_DURATION = 250 @@ -52,17 +46,16 @@ private const val ANIMATION_DURATION = 250 * This class is the view presenting choices for picking attachments. * It will return result through [Callback]. */ + class AttachmentTypeSelectorView(context: Context, inflater: LayoutInflater, - var callback: Callback?) : - PopupWindow(context) { + var callback: Callback? +) : PopupWindow(context) { interface Callback { fun onTypeSelected(type: Type) } - private val iconColorGenerator = ColorGenerator.MATERIAL - private val views: ViewAttachmentTypeSelectorBinding private var anchor: View? = null @@ -85,32 +78,21 @@ class AttachmentTypeSelectorView(context: Context, inputMethodMode = INPUT_METHOD_NOT_NEEDED isFocusable = true isTouchable = true + + views.attachmentCloseButton.onClick { + dismiss() + } } - fun show(anchor: View, isKeyboardOpen: Boolean) { + fun show(anchor: View) { this.anchor = anchor val anchorCoordinates = IntArray(2) anchor.getLocationOnScreen(anchorCoordinates) - if (isKeyboardOpen) { - showAtLocation(anchor, Gravity.NO_GRAVITY, 0, anchorCoordinates[1] + anchor.height) - } else { - val contentViewHeight = if (contentView.height == 0) { - contentView.getMeasurements().second - } else { - contentView.height - } - showAtLocation(anchor, Gravity.NO_GRAVITY, 0, anchorCoordinates[1] - contentViewHeight) - } + showAtLocation(anchor, Gravity.NO_GRAVITY, 0, anchorCoordinates[1]) + contentView.doOnNextLayout { animateWindowInCircular(anchor, contentView) } - animateButtonIn(views.attachmentGalleryButton, ANIMATION_DURATION / 2) - animateButtonIn(views.attachmentCameraButton, ANIMATION_DURATION / 4) - animateButtonIn(views.attachmentFileButton, ANIMATION_DURATION / 2) - animateButtonIn(views.attachmentAudioButton, 0) - animateButtonIn(views.attachmentContactButton, ANIMATION_DURATION / 4) - animateButtonIn(views.attachmentStickersButton, ANIMATION_DURATION / 2) - animateButtonIn(views.attachmentPollButton, ANIMATION_DURATION / 4) } override fun dismiss() { @@ -124,28 +106,18 @@ class AttachmentTypeSelectorView(context: Context, fun setAttachmentVisibility(type: Type, isVisible: Boolean) { when (type) { - Type.CAMERA -> views.attachmentCameraButtonContainer - Type.GALLERY -> views.attachmentGalleryButtonContainer - Type.FILE -> views.attachmentFileButtonContainer - Type.STICKER -> views.attachmentStickersButtonContainer - Type.AUDIO -> views.attachmentAudioButtonContainer - Type.CONTACT -> views.attachmentContactButtonContainer - Type.POLL -> views.attachmentPollButtonContainer + Type.CAMERA -> views.attachmentCameraButton + Type.GALLERY -> views.attachmentGalleryButton + Type.FILE -> views.attachmentFileButton + Type.STICKER -> views.attachmentStickersButton + Type.AUDIO -> views.attachmentAudioButton + Type.CONTACT -> views.attachmentContactButton + Type.POLL -> views.attachmentPollButton }.let { it.isVisible = isVisible } } - private fun animateButtonIn(button: View, delay: Int) { - val animation = AnimationSet(true) - val scale = ScaleAnimation(0.0f, 1.0f, 0.0f, 1.0f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.0f) - animation.addAnimation(scale) - animation.interpolator = OvershootInterpolator(1f) - animation.duration = ANIMATION_DURATION.toLong() - animation.startOffset = delay.toLong() - button.startAnimation(animation) - } - private fun animateWindowInCircular(anchor: View, contentView: View) { val coordinates = getClickCoordinates(anchor, contentView) val animator = ViewAnimationUtils.createCircularReveal(contentView, @@ -157,12 +129,6 @@ class AttachmentTypeSelectorView(context: Context, animator.start() } - private fun animateWindowInTranslate(contentView: View) { - val animation = TranslateAnimation(0f, 0f, contentView.height.toFloat(), 0f) - animation.duration = ANIMATION_DURATION.toLong() - getContentView().startAnimation(animation) - } - private fun animateWindowOutCircular(anchor: View, contentView: View) { val coordinates = getClickCoordinates(anchor, contentView) val animator = ViewAnimationUtils.createCircularReveal(getContentView(), @@ -207,7 +173,6 @@ class AttachmentTypeSelectorView(context: Context, } private fun ImageButton.configure(type: Type): ImageButton { - this.background = TextDrawable.builder().buildRound("", iconColorGenerator.getColor(type.ordinal)) this.setOnClickListener(TypeClickListener(type)) return this } diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt index a77899a8b0..35f33e4f75 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/RoomDetailFragment.kt @@ -1367,7 +1367,7 @@ class RoomDetailFragment @Inject constructor( attachmentTypeSelector = AttachmentTypeSelectorView(vectorBaseActivity, vectorBaseActivity.layoutInflater, this@RoomDetailFragment) attachmentTypeSelector.setAttachmentVisibility(AttachmentTypeSelectorView.Type.POLL, vectorPreferences.labsEnablePolls()) } - attachmentTypeSelector.show(views.composerLayout.views.attachmentButton, keyboardStateUtils.isKeyboardShowing) + attachmentTypeSelector.show(views.composerLayout.views.attachmentButton) } override fun onSendMessage(text: CharSequence) { diff --git a/vector/src/main/res/drawable-hdpi/ic_attachment_stickers_white_24dp.png b/vector/src/main/res/drawable-hdpi/ic_attachment_stickers_white_24dp.png deleted file mode 100644 index d27e8f406eece350e1ec4ce11e373b3da684a24f..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 595 zcmV-Z0<8UsP){SMQWR`6i12^#Xd=rZx|9bLs3v%Fr3Qv$)Im2 z={(Ym&)gLHf|9MUKUUBcO0vQJ*+5&c-x+d=pE2q*!{J#peShLHl+jBGW~mPemyc&E z8&|jC!6TmDz!1Z=Z4snIvwS7EG?b`w2+Wmgh9*jqT}`_dbjzBqM44POwGK^yrouOo zMhtZA`f#7A7m#^`c&|K3{APHBF%806e5WJgTor+KR0qPhr;^tgg4hSnC*(U hmZR^sa_7#i`2~9``8a)2aIF9U002ovPDHLkV1h5}|0Mtb diff --git a/vector/src/main/res/drawable-mdpi/ic_attachment_stickers_white_24dp.png b/vector/src/main/res/drawable-mdpi/ic_attachment_stickers_white_24dp.png deleted file mode 100644 index 40d78cf9e26325bf4a88435bcac1bb9793fa44d8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 421 zcmV;W0b2fvP)a{vy813&?X0&oBh00qSXpdchHK(0$+8+_t-_rKkeH0heQ z1NdqX(UXRxB`M&8t=I<86&jqAj`*6;x)2SRV0+4@$xH0cZ)Do3ol#%;|~m z&-#KCbF2l2Fldrk;5*>`V5orZ!77`P)t67XD2eEU5*TyQW)!1XI z$-2PENKz_)E^E%}D|=~-8(0NA+Ls&OOIae`y0e0gi%&8i^Ci^bEx94><^6}mvDOwX zsK3?$ycbDsy#|b-2^@&+nL-<|x>-Ym#N4+Wx*~;m3+vMy#Kyl<4`0m%BXl(H@R diff --git a/vector/src/main/res/drawable-xhdpi/ic_attachment_stickers_white_24dp.png b/vector/src/main/res/drawable-xhdpi/ic_attachment_stickers_white_24dp.png deleted file mode 100644 index 46e23b9cdcf20f54962a792bbd0e6233fd3f1fb0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 734 zcmV<40wMj0P)l z!Y~Yml}LNGG67U^aja{z?}^xztJI#Dv^6-<>Xm zM6zu8sSx$_{BI%(1b~Duk1TQ>vJ9*UN0z;n9ZMQTQA)RlogT1ESq|{Wuq;_(Y8&hL z9N}2DRuL{}jCw6zg<%=dH9^=`FJexiLDpq9XpgOwNujU?+h(Kj?M~smgmg&llb~sL zVgv8EJ(DsYqY~$1zDO8jx-GH@KJdbKbUiHVLNmI(^MVZKY0*Px1Z?XY>K6B|C=^9t zM%}|X7K$qHL^}2?&)hN+$v1m{4IN>udW*YH;xR*vYUqv{l$YfFbwwZ{J)gPz?`oA= zIw$_DN3IGyQg=!6f4C|Tlb(EwyjH8!(m7GxxbWL58i2jEd?*H!fjxvHJFV3@@EF)rm)L@C z@>u8nbw%Kds@d^a+RG2S!SdM>5dCf^j@E|UrwYC5MGv~A{eaw=)wZHh=t{I=N4Xl^ zgfu`G&Uu0EJKSAr!!j$-(PTUH+j}VpI;JHyWNb(@hbYM~Aj|A&SdvEt2GBF5n!qp5 z6#Li~;|mYt2HO5f=W*sUbLm_Eq7aFKZwhh4GGZAz?8zV>!#_c0P&aSNiW4-$z;CnW zqFKHaeqAXv3km_+&5NGcYJAh~MrEb-Ir=pvWqGF1pq=g%rrVTMLRMOX@W_lep*BD^ zC9V(-iEOy<0W~UO;E%NUtf}LnKeLKR<{-9m`I%KjCW4f*?RZK(Jw1*20fl%e$_<`M QTmS$707*qoM6N<$f{e{Y5dZ)H diff --git a/vector/src/main/res/drawable-xxhdpi/ic_attachment_stickers_white_24dp.png b/vector/src/main/res/drawable-xxhdpi/ic_attachment_stickers_white_24dp.png deleted file mode 100644 index 4058b25495a1a24a145a2968c0abc9ffb1754991..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1142 zcmV-+1d02JP)T2dyFj4}^zU6IUU_b0TX%9| z2Y>I~%OiH=S~CE4`6Xw2&9?7N-peYdmfjxO?%5V>%blH_ zN7^<-6t*eb9Cqex7i<{~9sUtH(uh(gR!&1>4Z>6@*xpm$;V+r3S(qwU=Nh3Zkya#?Km!uz ziIVL=6J)+39XB)_afFO*?p;C@(E@qr*H@oYhkWNLbqR}ehT-!u<~O(YK^UIj2_b&y zpsmx68DcXUzBq#Tp{uqhx9UOMdydID=50cz{zcPCZ3QZ5J9^J^7A(+F(@Bj(3@)9J z(e{y}MXIEY59)Sm+$@d1t#*j{nX4chGHYD>*9p0FtAz#IExBGjA$#xMQ>SqyW`K(t+=s=x7IlUa-gbvgR^p6zlKD@UrEm|iUs;qN3o(UiC0oqeiT>{gz|fL&@l_?(1j1WuD;>7SWYM% zp90%9+C}Rkbl{cdLk+A9-27_%oa~%)TbALpiX~})F3%!EX}6}$edv}41?qD`+GU3> zVdgKYO^@C*w43?1ixzD?_;Ys~+SFtzg{ZCQ>P0PC#a6o^eBLqJXSm)fPPSmX@$cnm zQIP@L0yrZJu%$CQ-!d|aqaR++zJMlwycUs+;s`mV0QRK#90|*Fk*3`EJEa2lUL=UK zox&g#{@v1$BIrD(lptM!cmY@N-8#()_YV@MohlknTmIs|WX3OdlqiGeDai$C_w;|{ zE&|FOL3!e9%2Mc^r8GDQ>|4=&pxY{ZxUN1_qO0$t>!i{D>iQ6OJgg2WlIWDHFBOr> ztdfR<_?-`=K$Vjom`En4tWMhd3yMg(RKa?XS@*D$87l_#&vE~TyG1Kycwhsr3ctYS z`3Xx3qf6k{NZP!N73nqKFoe6I;c`3$*29x9ISmbTfA{k+g{cBJ^e&L@!2*pb*i>xl z(G(Je=j1B8o*qk)RZcC*?d~qUN%_oTD<4fUGBPqUGSUfu0FsYR!(D(Ood5s;07*qo IM6N<$g8rEc>i_@% diff --git a/vector/src/main/res/drawable-xxxhdpi/ic_attachment_stickers_white_24dp.png b/vector/src/main/res/drawable-xxxhdpi/ic_attachment_stickers_white_24dp.png deleted file mode 100644 index c5b243564685da7e357d929374378d4aeaec6529..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1521 zcmV@~0drDELIAGL9O(c600d`2O+f$vv5yPVW%Xb=wTb3)V8M)h8-jAsC zV>B#pSqiKLnug*JX;|K4>2N12*V(Dku)M|6;7%1RHO&W^j|waS?#Mfu)^HPwT=RUr zf$UiSk><}wBqYgm09p6FhkbZj0uL;2`1!#=8Fd3V<=4=Ah?)w9oF@>>j) zji6?L6)3;OK+y;)23V2uTMU$ppk;usSk8nSicHLxu^W58AriMtTbuF)>2vhv;OdLq{V)4?L0=Cj zk(J+tOvt^wpsxqyvER=ld%#8L$-y2#HjSe|#)kx=%FvVh3_+=uolkozEEjy|Y~0TV z`i#|%@D7@g4KJqPzN5`M(qpW4S|pyV_mIl}?27bhx-OEe(KUkk%}DJW@)`kz4nZk~ zpKaH2&He2L^J(Xh%aD^o4e&Sg`7hv{JH#_qJBI{$fOi?{-1j?_aTB2z@nu9XRy!xS z@I91;c)%KiEn0X-jt~QsNB{+-{_#1{#viMl6TI}D5MqD=X{Z9u(NIhka84=%{E1j7 zT~cl5TAA$fu%URyYUdcWPro4^kSgjW|FhlaBQJ zxJR+DxZ}eIr00Wc>lB}$$Aj+#uK`>{ z$3TY*Pg`5)D&UYC*G3mnuN>`RLQ)h%m!V&vgLmJZFSDL6Zt?2;<@?hQZ^rh1R{POXX?f{HQq4~m<0iXAEnwpdvZWxNlq#`opU-?vZ!mzl7VCJ#bCqo@}{R{r1}+^C?utCN%B^`5zK6Qg_~x@4IfcV#|U+lw4B z7rjCx(P=4eLX-)}U_BVvK1ZWcv`?U1wsH_^1`t+Y1cRv-Zf#kx5eyQPE>=%XbQdTu zDSI;lW<*;f)IgaexuJ5QZiTRfC93oxiSkFm?ZwRX0}esK{K-Q$rki5_Jry-A@ykk- zKjJeD$Od&9nhrAD^vu^!zbT38rYi zv|->r)uu9lZ+7_@um-e`i**l8J!_(6zZKtI0OeT}bWHOmdCX@LA XAosu+GI>6S00000NkvXXu0mjf!1}un diff --git a/vector/src/main/res/drawable/ic_attachment_camera.xml b/vector/src/main/res/drawable/ic_attachment_camera.xml new file mode 100644 index 0000000000..8c7bedb3cf --- /dev/null +++ b/vector/src/main/res/drawable/ic_attachment_camera.xml @@ -0,0 +1,13 @@ + + + + diff --git a/vector/src/main/res/drawable/ic_attachment_camera_white_24dp.xml b/vector/src/main/res/drawable/ic_attachment_camera_white_24dp.xml deleted file mode 100644 index 5c2920d252..0000000000 --- a/vector/src/main/res/drawable/ic_attachment_camera_white_24dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/vector/src/main/res/drawable/ic_attachment_close.xml b/vector/src/main/res/drawable/ic_attachment_close.xml new file mode 100644 index 0000000000..76f0d3d064 --- /dev/null +++ b/vector/src/main/res/drawable/ic_attachment_close.xml @@ -0,0 +1,15 @@ + + + + diff --git a/vector/src/main/res/drawable/ic_attachment_file.xml b/vector/src/main/res/drawable/ic_attachment_file.xml new file mode 100644 index 0000000000..b3545e54a6 --- /dev/null +++ b/vector/src/main/res/drawable/ic_attachment_file.xml @@ -0,0 +1,13 @@ + + + diff --git a/vector/src/main/res/drawable/ic_attachment_file_white_24dp.xml b/vector/src/main/res/drawable/ic_attachment_file_white_24dp.xml deleted file mode 100644 index 4e6b9458f8..0000000000 --- a/vector/src/main/res/drawable/ic_attachment_file_white_24dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/vector/src/main/res/drawable/ic_attachment_gallery.xml b/vector/src/main/res/drawable/ic_attachment_gallery.xml new file mode 100644 index 0000000000..0f3432544f --- /dev/null +++ b/vector/src/main/res/drawable/ic_attachment_gallery.xml @@ -0,0 +1,12 @@ + + + diff --git a/vector/src/main/res/drawable/ic_attachment_gallery_white_24dp.xml b/vector/src/main/res/drawable/ic_attachment_gallery_white_24dp.xml deleted file mode 100644 index d4e68f125b..0000000000 --- a/vector/src/main/res/drawable/ic_attachment_gallery_white_24dp.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/vector/src/main/res/drawable/ic_attachment_location.xml b/vector/src/main/res/drawable/ic_attachment_location.xml new file mode 100644 index 0000000000..c2c8093e1d --- /dev/null +++ b/vector/src/main/res/drawable/ic_attachment_location.xml @@ -0,0 +1,9 @@ + + + diff --git a/vector/src/main/res/drawable/ic_attachment_poll_white_24dp.xml b/vector/src/main/res/drawable/ic_attachment_poll.xml similarity index 93% rename from vector/src/main/res/drawable/ic_attachment_poll_white_24dp.xml rename to vector/src/main/res/drawable/ic_attachment_poll.xml index 8cbcc6e47c..320dccb7fc 100644 --- a/vector/src/main/res/drawable/ic_attachment_poll_white_24dp.xml +++ b/vector/src/main/res/drawable/ic_attachment_poll.xml @@ -5,6 +5,6 @@ android:viewportHeight="24"> diff --git a/vector/src/main/res/drawable/ic_attachment_sticker.xml b/vector/src/main/res/drawable/ic_attachment_sticker.xml new file mode 100644 index 0000000000..eb59eaa75d --- /dev/null +++ b/vector/src/main/res/drawable/ic_attachment_sticker.xml @@ -0,0 +1,13 @@ + + + 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 4cd5e1910d..3724affdd2 100644 --- a/vector/src/main/res/layout/view_attachment_type_selector.xml +++ b/vector/src/main/res/layout/view_attachment_type_selector.xml @@ -1,199 +1,109 @@ - + android:background="?android:colorBackground" + android:paddingTop="12dp" + android:paddingBottom="12dp"> - + android:layout_marginStart="12dp" + android:background="@drawable/circle" + android:contentDescription="@string/action_close" + android:src="@drawable/ic_attachment_close" + app:layout_constraintBottom_toBottomOf="parent" + app:layout_constraintStart_toStartOf="parent" + app:layout_constraintTop_toTopOf="parent" /> + + + android:layout_width="wrap_content" + android:layout_height="wrap_content" + android:layout_gravity="center_vertical" + android:gravity="center_vertical" + android:orientation="horizontal"> - + android:background="?android:attr/selectableItemBackground" + android:contentDescription="@string/attachment_type_gallery" + android:src="@drawable/ic_attachment_gallery" /> - - - - - - - + android:layout_marginStart="24dp" + android:background="?android:attr/selectableItemBackground" + android:contentDescription="@string/attachment_type_sticker" + android:src="@drawable/ic_attachment_sticker" /> - - - - - - - + android:layout_marginStart="24dp" + android:background="?android:attr/selectableItemBackground" + android:contentDescription="@string/attachment_type_file" + android:src="@drawable/ic_attachment_file" /> - + - + - + + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + From 464ac3bce22224c224263cda93063ddda5ba8ced Mon Sep 17 00:00:00 2001 From: Benoit Marty Date: Thu, 30 Dec 2021 16:36:36 +0100 Subject: [PATCH 2/3] Fix blink effect when opening the attachment popup, and improve clickability of the buttons --- .../ui-styles/src/main/res/values/dimens.xml | 5 ++ ...composer_layout_constraint_set_compact.xml | 8 +- ...omposer_layout_constraint_set_expanded.xml | 8 +- .../layout/view_attachment_type_selector.xml | 75 ++++++++++--------- .../layout/view_voice_message_recorder.xml | 4 +- 5 files changed, 53 insertions(+), 47 deletions(-) diff --git a/library/ui-styles/src/main/res/values/dimens.xml b/library/ui-styles/src/main/res/values/dimens.xml index 864f3d3d7f..9fbf8958da 100644 --- a/library/ui-styles/src/main/res/values/dimens.xml +++ b/library/ui-styles/src/main/res/values/dimens.xml @@ -42,4 +42,9 @@ 8dp + + + 56dp + 52dp + 1dp \ No newline at end of file diff --git a/vector/src/main/res/layout/composer_layout_constraint_set_compact.xml b/vector/src/main/res/layout/composer_layout_constraint_set_compact.xml index 3378878ac6..7e926b860c 100644 --- a/vector/src/main/res/layout/composer_layout_constraint_set_compact.xml +++ b/vector/src/main/res/layout/composer_layout_constraint_set_compact.xml @@ -108,9 +108,9 @@ + android:layout_height="@dimen/composer_min_height" + android:background="?android:colorBackground"> + android:src="@drawable/ic_attachment_sticker" + app:tint="?colorPrimary" /> + android:src="@drawable/ic_attachment_file" + app:tint="?colorPrimary" /> + android:src="@drawable/ic_attachment_poll" + app:tint="?colorPrimary" /> + android:src="@drawable/ic_attachment_camera" + app:tint="?colorPrimary" /> - + - + + diff --git a/vector/src/main/res/layout/view_voice_message_recorder.xml b/vector/src/main/res/layout/view_voice_message_recorder.xml index 53be4f07f6..9f8e58d724 100644 --- a/vector/src/main/res/layout/view_voice_message_recorder.xml +++ b/vector/src/main/res/layout/view_voice_message_recorder.xml @@ -34,7 +34,7 @@ Date: Thu, 30 Dec 2021 16:52:58 +0100 Subject: [PATCH 3/3] 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" />