From ac718a425dc8cfba61c91a574ddfb8615b797ef7 Mon Sep 17 00:00:00 2001 From: Niels Andriesse Date: Mon, 21 Jun 2021 11:09:30 +1000 Subject: [PATCH] Basic voice message --- .../v2/messages/VisibleMessageContentView.kt | 2 +- .../v2/messages/VoiceMessageView.kt | 18 +++------ app/src/main/res/drawable/circle_tintable.xml | 5 ++- ..._message_duration_text_view_background.xml | 7 ++++ .../main/res/layout/view_voice_message.xml | 39 +++++++++++++++---- 5 files changed, 48 insertions(+), 23 deletions(-) create mode 100644 app/src/main/res/drawable/view_voice_message_duration_text_view_background.xml diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt index 559130eb9e..7e21946d89 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VisibleMessageContentView.kt @@ -103,7 +103,7 @@ class VisibleMessageContentView : LinearLayout { val hPadding = toPx(12, resources) result.setPadding(hPadding, vPadding, hPadding, vPadding) result.text = message.body - result.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.medium_font_size)) + result.setTextSize(TypedValue.COMPLEX_UNIT_PX, resources.getDimension(R.dimen.small_font_size)) val uiMode = UiModeUtilities.getUserSelectedUiMode(context) val colorID = if (message.isOutgoing) { if (uiMode == UiMode.NIGHT) R.color.black else R.color.white diff --git a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VoiceMessageView.kt b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VoiceMessageView.kt index 6a999f30f7..42f9a66b3e 100644 --- a/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VoiceMessageView.kt +++ b/app/src/main/java/org/thoughtcrime/securesms/conversation/v2/messages/VoiceMessageView.kt @@ -11,26 +11,18 @@ import org.thoughtcrime.securesms.database.model.MessageRecord class VoiceMessageView : LinearLayout { // region Lifecycle - constructor(context: Context) : super(context) { - setUpViewHierarchy() - } + constructor(context: Context) : super(context) { initialize() } + constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { initialize() } + constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { initialize() } - constructor(context: Context, attrs: AttributeSet) : super(context, attrs) { - setUpViewHierarchy() - } - - constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) { - setUpViewHierarchy() - } - - private fun setUpViewHierarchy() { + private fun initialize() { LayoutInflater.from(context).inflate(R.layout.view_voice_message, this) } // endregion // region Updating fun bind(message: MessageRecord) { - textView.text = "I'm a voice message" + } fun recycle() { diff --git a/app/src/main/res/drawable/circle_tintable.xml b/app/src/main/res/drawable/circle_tintable.xml index 6c5c360635..60c36468e4 100644 --- a/app/src/main/res/drawable/circle_tintable.xml +++ b/app/src/main/res/drawable/circle_tintable.xml @@ -1,5 +1,6 @@ - + diff --git a/app/src/main/res/drawable/view_voice_message_duration_text_view_background.xml b/app/src/main/res/drawable/view_voice_message_duration_text_view_background.xml new file mode 100644 index 0000000000..78871b9e1e --- /dev/null +++ b/app/src/main/res/drawable/view_voice_message_duration_text_view_background.xml @@ -0,0 +1,7 @@ + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/view_voice_message.xml b/app/src/main/res/layout/view_voice_message.xml index e54f8e930c..ae5768c41d 100644 --- a/app/src/main/res/layout/view_voice_message.xml +++ b/app/src/main/res/layout/view_voice_message.xml @@ -1,16 +1,41 @@ + + + + + + + + + android:layout_width="40dp" + android:layout_height="20dp" + android:text="0:08" + android:gravity="center" + android:textColor="@color/black" + android:textSize="@dimen/small_font_size" + android:background="@drawable/view_voice_message_duration_text_view_background" + android:backgroundTint="@color/white" /> \ No newline at end of file