From 3959a838d1a9a627f0b1b616cd08ccbb375c4908 Mon Sep 17 00:00:00 2001 From: SpiritCroc Date: Sun, 1 Aug 2021 09:57:01 +0200 Subject: [PATCH] [merge-features] Fix voice messsage bubble layout + SC themes Change-Id: Idd2dddc8c8f6333ca90fa5411c69e084e3a4cdcf --- .../ui-styles/src/main/res/values/attrs_sc.xml | 1 + .../src/main/res/values/theme_dark.xml | 1 + .../src/main/res/values/theme_light.xml | 1 + .../ui-styles/src/main/res/values/theme_sc.xml | 1 + .../src/main/res/values/theme_sc_light.xml | 1 + .../detail/timeline/item/MessageVoiceItem.kt | 18 ++++++++++++++++++ .../res/layout/item_timeline_event_base.xml | 3 +-- .../layout/item_timeline_event_voice_stub.xml | 5 +++-- vector/src/main/res/values/dimens_sc.xml | 5 ++++- 9 files changed, 31 insertions(+), 5 deletions(-) diff --git a/library/ui-styles/src/main/res/values/attrs_sc.xml b/library/ui-styles/src/main/res/values/attrs_sc.xml index 4ccf77fa79..2b3cb892f1 100644 --- a/library/ui-styles/src/main/res/values/attrs_sc.xml +++ b/library/ui-styles/src/main/res/values/attrs_sc.xml @@ -18,6 +18,7 @@ + diff --git a/library/ui-styles/src/main/res/values/theme_dark.xml b/library/ui-styles/src/main/res/values/theme_dark.xml index 0a0a714e61..d634263c9a 100644 --- a/library/ui-styles/src/main/res/values/theme_dark.xml +++ b/library/ui-styles/src/main/res/values/theme_dark.xml @@ -133,6 +133,7 @@ @color/user_color_element_pl_51 @color/user_color_element_pl_95 @color/user_color_element_pl_100 + ?vctr_content_quinary @color/android_status_bar_background_dark @color/android_navigation_bar_background_dark diff --git a/library/ui-styles/src/main/res/values/theme_light.xml b/library/ui-styles/src/main/res/values/theme_light.xml index 36ae2a1884..8c0a9d9ff6 100644 --- a/library/ui-styles/src/main/res/values/theme_light.xml +++ b/library/ui-styles/src/main/res/values/theme_light.xml @@ -133,6 +133,7 @@ @color/user_color_element_pl_51 @color/user_color_element_pl_95 @color/user_color_element_pl_100 + ?vctr_content_quinary @color/android_status_bar_background_dark diff --git a/library/ui-styles/src/main/res/values/theme_sc.xml b/library/ui-styles/src/main/res/values/theme_sc.xml index 4ae5942b2c..fc5bca2865 100644 --- a/library/ui-styles/src/main/res/values/theme_sc.xml +++ b/library/ui-styles/src/main/res/values/theme_sc.xml @@ -94,6 +94,7 @@ @color/user_color_sc_pl_51 @color/user_color_sc_pl_95 @color/user_color_sc_pl_100 + #1fffffff @color/background_black_sc @color/background_black_sc diff --git a/library/ui-styles/src/main/res/values/theme_sc_light.xml b/library/ui-styles/src/main/res/values/theme_sc_light.xml index 61a0da6bfe..a7a472537b 100644 --- a/library/ui-styles/src/main/res/values/theme_sc_light.xml +++ b/library/ui-styles/src/main/res/values/theme_sc_light.xml @@ -94,6 +94,7 @@ @color/user_color_sc_pl_51 @color/user_color_sc_pl_95 @color/user_color_sc_pl_100 + #1f000000 @color/background_black_sc @color/background_black_sc diff --git a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt index dc204da291..d733085e70 100644 --- a/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt +++ b/vector/src/main/java/im/vector/app/features/home/room/detail/timeline/item/MessageVoiceItem.kt @@ -16,10 +16,12 @@ package im.vector.app.features.home.room.detail.timeline.item +import android.content.Context import android.text.format.DateUtils import android.view.ViewGroup import android.widget.ImageButton import android.widget.TextView +import androidx.constraintlayout.widget.ConstraintLayout import androidx.core.view.isVisible import com.airbnb.epoxy.EpoxyAttribute import com.airbnb.epoxy.EpoxyModelClass @@ -29,6 +31,7 @@ import im.vector.app.core.epoxy.ClickListener import im.vector.app.features.home.room.detail.timeline.helper.ContentDownloadStateTrackerBinder import im.vector.app.features.home.room.detail.timeline.helper.ContentUploadStateTrackerBinder import im.vector.app.features.home.room.detail.timeline.helper.VoiceMessagePlaybackTracker +import im.vector.app.features.themes.BubbleThemeUtils @EpoxyModelClass(layout = R.layout.item_timeline_event_base) abstract class MessageVoiceItem : AbsMessageItem() { @@ -128,9 +131,24 @@ abstract class MessageVoiceItem : AbsMessageItem() { val voicePlaybackTime by bind(R.id.voicePlaybackTime) val voicePlaybackWaveform by bind(R.id.voicePlaybackWaveform) val progressLayout by bind(R.id.messageFileUploadProgressLayout) + val voicePlaybackLayout by bind(R.id.voicePlaybackLayout) } companion object { private const val STUB_ID = R.id.messageContentVoiceStub } + + override fun messageBubbleAllowed(context: Context): Boolean { + return true + } + + override fun setBubbleLayout(holder: Holder, bubbleStyle: String, bubbleStyleSetting: String, reverseBubble: Boolean) { + super.setBubbleLayout(holder, bubbleStyle, bubbleStyleSetting, reverseBubble) + + if (BubbleThemeUtils.drawsActualBubbles(bubbleStyle)) { + (holder.voiceLayout.layoutParams as ViewGroup.MarginLayoutParams).marginEnd = 0 + } else { + (holder.voiceLayout.layoutParams as ViewGroup.MarginLayoutParams).marginEnd = holder.voiceLayout.resources.getDimensionPixelSize(R.dimen.no_bubble_margin_end) + } + } } diff --git a/vector/src/main/res/layout/item_timeline_event_base.xml b/vector/src/main/res/layout/item_timeline_event_base.xml index 24574990d7..d07bce48a2 100644 --- a/vector/src/main/res/layout/item_timeline_event_base.xml +++ b/vector/src/main/res/layout/item_timeline_event_base.xml @@ -189,9 +189,8 @@ + tools:visibility="gone" /> diff --git a/vector/src/main/res/layout/item_timeline_event_voice_stub.xml b/vector/src/main/res/layout/item_timeline_event_voice_stub.xml index 21705566e9..9512e198a7 100644 --- a/vector/src/main/res/layout/item_timeline_event_voice_stub.xml +++ b/vector/src/main/res/layout/item_timeline_event_voice_stub.xml @@ -4,6 +4,7 @@ xmlns:tools="http://schemas.android.com/tools" android:id="@+id/voiceLayout" android:layout_width="match_parent" + android:minWidth="999999dp" android:layout_height="wrap_content"> - \ No newline at end of file + diff --git a/vector/src/main/res/values/dimens_sc.xml b/vector/src/main/res/values/dimens_sc.xml index c4ba638b17..f4e9df2f7e 100644 --- a/vector/src/main/res/values/dimens_sc.xml +++ b/vector/src/main/res/values/dimens_sc.xml @@ -6,4 +6,7 @@ 8dp - \ No newline at end of file + + 56dp + +