From e56133348f1a8bcec784a76f40cfbd2da5bb8e02 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sat, 16 May 2020 17:46:21 +0200 Subject: [PATCH] Lazy man's Reverse bubbles Exploit RTL to reverse the layout. PNGs again from AOSP Messaging app --- .../room/detail/timeline/item/MessageTextItem.kt | 14 +++++++++----- .../res/drawable-hdpi/msg_bubble_outgoing.9.png | Bin 0 -> 472 bytes .../msg_bubble_outgoing.9.png | Bin 0 -> 469 bytes .../msg_bubble_outgoing.9.png | Bin 0 -> 339 bytes .../msg_bubble_outgoing.9.png | Bin 0 -> 597 bytes .../msg_bubble_outgoing.9.png | Bin 0 -> 1578 bytes .../msg_bubble_outgoing.9.png | Bin 0 -> 1700 bytes .../res/drawable-mdpi/msg_bubble_outgoing.9.png | Bin 0 -> 344 bytes .../res/drawable-xhdpi/msg_bubble_outgoing.9.png | Bin 0 -> 598 bytes .../drawable-xxhdpi/msg_bubble_outgoing.9.png | Bin 0 -> 1597 bytes .../drawable-xxxhdpi/msg_bubble_outgoing.9.png | Bin 0 -> 1755 bytes .../main/res/layout/item_timeline_event_base.xml | 9 ++++++++- 12 files changed, 17 insertions(+), 6 deletions(-) create mode 100644 vector/src/main/res/drawable-hdpi/msg_bubble_outgoing.9.png create mode 100644 vector/src/main/res/drawable-ldrtl-hdpi/msg_bubble_outgoing.9.png create mode 100644 vector/src/main/res/drawable-ldrtl-mdpi/msg_bubble_outgoing.9.png create mode 100644 vector/src/main/res/drawable-ldrtl-xhdpi/msg_bubble_outgoing.9.png create mode 100644 vector/src/main/res/drawable-ldrtl-xxhdpi/msg_bubble_outgoing.9.png create mode 100644 vector/src/main/res/drawable-ldrtl-xxxhdpi/msg_bubble_outgoing.9.png create mode 100644 vector/src/main/res/drawable-mdpi/msg_bubble_outgoing.9.png create mode 100644 vector/src/main/res/drawable-xhdpi/msg_bubble_outgoing.9.png create mode 100644 vector/src/main/res/drawable-xxhdpi/msg_bubble_outgoing.9.png create mode 100644 vector/src/main/res/drawable-xxxhdpi/msg_bubble_outgoing.9.png diff --git a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MessageTextItem.kt b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MessageTextItem.kt index e544576cfb..bf75f7d8e7 100644 --- a/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MessageTextItem.kt +++ b/vector/src/main/java/im/vector/riotx/features/home/room/detail/timeline/item/MessageTextItem.kt @@ -19,9 +19,10 @@ package im.vector.riotx.features.home.room.detail.timeline.item import android.content.res.ColorStateList import android.text.method.MovementMethod import android.view.Gravity +import android.view.View import android.widget.FrameLayout +import android.widget.RelativeLayout import androidx.appcompat.widget.AppCompatTextView -import androidx.core.content.ContextCompat import androidx.core.text.PrecomputedTextCompat import androidx.core.widget.TextViewCompat import com.airbnb.epoxy.EpoxyAttribute @@ -71,14 +72,15 @@ abstract class MessageTextItem : AbsMessageItem() { null) holder.messageView.setTextFuture(textFuture) - var bubbleStyle = if (incomingMessage || outgoingMessage) BubbleThemeUtils.getBubbleStyle(holder.messageView.context) else BUBBLE_STYLE_NONE + val bubbleStyle = if (incomingMessage || outgoingMessage) BubbleThemeUtils.getBubbleStyle(holder.messageView.context) else BUBBLE_STYLE_NONE + val reverseBubble = outgoingMessage && bubbleStyle == BUBBLE_STYLE_BOTH when (bubbleStyle) { BUBBLE_STYLE_NONE -> { holder.messageView.background = null holder.messageView.setPadding(0, 0, 0, 0) } BUBBLE_STYLE_START, BUBBLE_STYLE_BOTH -> { - holder.messageView.setBackgroundResource(R.drawable.msg_bubble_incoming) + holder.messageView.setBackgroundResource(if (reverseBubble) R.drawable.msg_bubble_outgoing else R.drawable.msg_bubble_incoming) var tintColor = ColorStateList( arrayOf(intArrayOf(0)), intArrayOf(ThemeUtils.getColor(holder.messageView.context, @@ -96,8 +98,10 @@ abstract class MessageTextItem : AbsMessageItem() { } } if (holder.messageView.layoutParams is FrameLayout.LayoutParams) { - (holder.messageView.layoutParams as FrameLayout.LayoutParams).gravity = - if (outgoingMessage && bubbleStyle == BUBBLE_STYLE_BOTH) Gravity.END else Gravity.START + //(holder.messageView.layoutParams as FrameLayout.LayoutParams).gravity = + // if (outgoingMessage && bubbleStyle == BUBBLE_STYLE_BOTH) Gravity.END else Gravity.START + val defaultReverse = holder.messageView.resources.configuration.layoutDirection == View.LAYOUT_DIRECTION_RTL; + (holder.messageView.parent.parent as RelativeLayout).layoutDirection = if (reverseBubble != defaultReverse) View.LAYOUT_DIRECTION_RTL else View.LAYOUT_DIRECTION_LTR } } diff --git a/vector/src/main/res/drawable-hdpi/msg_bubble_outgoing.9.png b/vector/src/main/res/drawable-hdpi/msg_bubble_outgoing.9.png new file mode 100644 index 0000000000000000000000000000000000000000..8e7ccc0cc8127bbede5224fea2b375f9b9376fc2 GIT binary patch literal 472 zcmV;}0Vn>6P) zyu-!80|#-;#T3CobZZP+S_0P=hl2i+wxA}L0>OePqFIO}MF+v4CJAw|Z-aK>kIU=s zy&ibBhxhZoJkJXck#S&_T*IZG-fH=f&F(?dF5&Zid}|;AmyE~HXbzL*2X2QirYzs1 z(-D8bWb(u@jIlOqH8$TYMQJ;N`Tg&xRN~9iAqW%hnA<%@skFUvavXTwCkln#)sz!p zCUa!)D;xk5iBkXu9&a!bxk0}#8fkn%#-35HZ~lUD1OtILRI9Ny7)LOdJ1~K90#)@I zgTcoCfZ^~H8jYYy%qAENzMAYC2higgpaolanOO1++sns(GMn9-`y#p=OE35*^du8)idcY&00000 LNkvXXu0mjfnCZqY literal 0 HcmV?d00001 diff --git a/vector/src/main/res/drawable-ldrtl-mdpi/msg_bubble_outgoing.9.png b/vector/src/main/res/drawable-ldrtl-mdpi/msg_bubble_outgoing.9.png new file mode 100644 index 0000000000000000000000000000000000000000..4e7e464037695828ede0683d70ea9ff43acda8e2 GIT binary patch literal 339 zcmeAS@N?(olHy`uVBq!ia0vp^!ayvb@%|9QiCfi;=VY$r z?bq_n-xBA(-#^E!G_v|NV_pB&pAXLpd0n>FUlUfXKW)R^Ygb>dtvQe^yGW<|>RUUu zgA69KV^7RDuOQKI?D6Xai3YXFK38A43-CCci)B5`U?QV;IPr63{Ml#4K%vVkgBNeK zZk;M7>iV;O2BX%}^WKxTFa8~t%^u>D$&p}k$}lbd#_^AbBhUFixwCZA6VDCd%RetV im{9nEwQ|{oui}mx;bn4-e`A0Fz~JfX=d#Wzp$P!O{EM3a literal 0 HcmV?d00001 diff --git a/vector/src/main/res/drawable-ldrtl-xhdpi/msg_bubble_outgoing.9.png b/vector/src/main/res/drawable-ldrtl-xhdpi/msg_bubble_outgoing.9.png new file mode 100644 index 0000000000000000000000000000000000000000..0661fdba789fa348568b01299482fa29fff2e17d GIT binary patch literal 597 zcmV-b0;>IqP)*P_#)J^)}e`ilTvPBc^3uW4CXX0x&O z^ra<>p-|le)YA-yD~!bsnaioqQRn9~^!pp0qX5!0w|IG}KSw2#pL+sQlqwU6FYVj6 zy1LyHR6PE(J%|(>A3yLM6b#lotvs+)>Sr|i+iO%u5CE`H7^GnoJO;gjN~fo#0s#Qm z))uL%f208c04?j2T%b}Zz`40i`h0g%fSRz$$?tN3(&-^iOq@ys0sxYrX?}AH)MpnY zgaAfIcc7{j+fUjoqqR2}z8wo#-&An*^3M!;^Zz{9@G$q+&iLcDwG9S3zA zQi2?Nf105vHQP18;4J{*&J2aae{I)j+BM)-%QP)xYrLY=U>FDPff9)mghDrO9kv`vj3#7(Kq{ykMuUuaK j*jnTK3VXr#mizt(eh06M7!YU`00000NkvXXu0mjfUCISm literal 0 HcmV?d00001 diff --git a/vector/src/main/res/drawable-ldrtl-xxhdpi/msg_bubble_outgoing.9.png b/vector/src/main/res/drawable-ldrtl-xxhdpi/msg_bubble_outgoing.9.png new file mode 100644 index 0000000000000000000000000000000000000000..009c721919e0b4bb7a9d7656c810bd36ab8560f5 GIT binary patch literal 1578 zcmaJ>X;2eq7>-CKWuV3jtq3klYXfz&M>Zt85^Knz5rZKj(vDU)n+>dx?3%15QmtrB zsn%+3t^MJ_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zjx*`<6ZoSR*p#5dCiG(V=19APMLYM3inQ53*&n~LsiywaPn-YKHy&Jdm38q6Q$9Zy z&C- zHv}^`w^4CrLlmF6WBU5`094+&+%bOt4bthhs(YU+M$=MAr8=rpc!Q$Rp{gUp6(q}d zSXh|+1H&0)81pqSoIozuJ4Q#>kWRNY2PhQU{Re~-sK5UN(P(FLfOLHafCWpQQdWL2 z30Zz1Jw2P0+AN`%j*O-yadFXZvnvivSu8ea6T=v!D7RQziqwH&3>qJwtrNotBnWSq zm{>+8BQys{*S8oz7=d)%L_BVHM^yw-l7G1MaJzFPmlG+aw$iJC?0*<31!D{$q{2b5 z(b1G3N<{J1a;79bvF8w)A0b7_T2A$P?^$aI`JOUO+q2wbMTt8H>g_!us(SkGERW}f zgu};9fC>TAl+o37So4hE-Mx=w(n=Lr2WonH354ymT>hYa0?`Sti=p%Jp8x;=07*qoM6N<$g5MJP2><{9 literal 0 HcmV?d00001 diff --git a/vector/src/main/res/drawable-xxhdpi/msg_bubble_outgoing.9.png b/vector/src/main/res/drawable-xxhdpi/msg_bubble_outgoing.9.png new file mode 100644 index 0000000000000000000000000000000000000000..5b2a2fffc0d62d144d43dbcca0c468fa08a7e85f GIT binary patch literal 1597 zcmbVMYfuwc6b?bD#0L)Q4+84CD8#nOKJwhH5%QEkgEYhzaTGVZ7fB_%akFV6RBKf% zsHhcc)$vhODy`!CQE(g`TeVhk80}PT3)U(lsI60|QtPPQ@UZ>i_@g_sd+)jTeCK@U zwG}zpQ-;dqGKoYo)RAFziK|w8)q`Thul_{3Ph1iNTb_{16$&AW2NDy*c>v__QFDL` zP|W;!=fEV1Bs$=A=LvbvH%XfFsi=sKD(v%%Xo+M}TG&s~bAbSPz#K1Ygzq0a0YhHK z2*0CsqE5dB6nQgBc#vC??WRlS(gXviO@=0gNzs502ox0d6|(^{Y=nF4lHxvcjKENj ziZIs*_mawU=0FyX2ar~!RnjPqL3%=kX*C3fy$<0hrbaLn!3iaXks3XT>7c#`7QOLI zA?dQ(`+SL#5iSx0KZzirP)HS0t2llRf)NCPpg4l#N>M`@n9mASSjh&G`z=^Ofabk^ z!OO8w#3JS4f`Sninf8X@^E;i-4YPs1M2RUw!jvDuR4C%}MdIqw4hSyrFO3&!2i)`h z0C9l;7vyQN9)-#MU@>D#pu@T9nqHDC$vC zG|(tD9yL%J47fq5!8KYPO6v<54DYw|B0OfnG-g7N+6apo!)$6ZN~leQ-lVfxH8!iw z){k|t0fAy^(C^zT`tHT*>@UTV79LOn$GbVMxW5Z>ia3D_6mfpYVu2J+iuSS*d19nS zy&+ox?|lz2cAoP=JxM0LFCajmdVu4AQZhP>5ra4Al?1Lvl|W-K&>n)u8H$Gc@XY^B z9wL%LBAxP|&gnlA+cC0zJ_n-ke3Aewjt?)+iEL+7vP2@C?Xa5M;UDj9+@EEBYvh^Z zat_Tb-&CF9+Gi@tC>|8QLN4|0tsQ6jdC9tE>;8`3R#)@I!==k|E=(K}D^1+ylHrTt zin^Ne?3Uv4_c!hhZSCIFek!4rZ%AuBe%*L`%ieSDXN$P&7nTa^cg2s7UoyO6_oAN` z$d-2w*y=8jHro`{u8)Yx56$R$dqaEvjjp!O+y|yff4es%J?p%YfQ~(p%gTm5NMjDR zd>nlsf9$xbShq9^ZNGbdP4t1hSH8o}4S!HghN+!cMFNQnz$bjzis^W!UWmKbG*Y-!8Eq3{a zk!{o4ch}c<$8X4cG?hrQ)m$c%KJ7eO@WHb^&C^RuyKC>8o-R`Sxy99`)g)!^SnXk$ z#7fV}8`M$u?BJu9H*F4XTWg-#y5q=^8Q&H@QD~ojy?saUHU7%AM-77?v^|)2=Buzj zb>)@P0ZmPDqk?PC22RaPU6cLF{`!Kf6z7=@k5W!bCLGEdefjRa%E%AhVavAeG0$H7 E4@HGb&;S4c literal 0 HcmV?d00001 diff --git a/vector/src/main/res/drawable-xxxhdpi/msg_bubble_outgoing.9.png b/vector/src/main/res/drawable-xxxhdpi/msg_bubble_outgoing.9.png new file mode 100644 index 0000000000000000000000000000000000000000..cf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