Basic voice message

This commit is contained in:
Niels Andriesse 2021-06-21 11:09:30 +10:00
parent ce5f923b25
commit ac718a425d
5 changed files with 48 additions and 23 deletions

View File

@ -103,7 +103,7 @@ class VisibleMessageContentView : LinearLayout {
val hPadding = toPx(12, resources) val hPadding = toPx(12, resources)
result.setPadding(hPadding, vPadding, hPadding, vPadding) result.setPadding(hPadding, vPadding, hPadding, vPadding)
result.text = message.body 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 uiMode = UiModeUtilities.getUserSelectedUiMode(context)
val colorID = if (message.isOutgoing) { val colorID = if (message.isOutgoing) {
if (uiMode == UiMode.NIGHT) R.color.black else R.color.white if (uiMode == UiMode.NIGHT) R.color.black else R.color.white

View File

@ -11,26 +11,18 @@ import org.thoughtcrime.securesms.database.model.MessageRecord
class VoiceMessageView : LinearLayout { class VoiceMessageView : LinearLayout {
// region Lifecycle // region Lifecycle
constructor(context: Context) : super(context) { constructor(context: Context) : super(context) { initialize() }
setUpViewHierarchy() 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) { private fun initialize() {
setUpViewHierarchy()
}
constructor(context: Context, attrs: AttributeSet, defStyleAttr: Int) : super(context, attrs, defStyleAttr) {
setUpViewHierarchy()
}
private fun setUpViewHierarchy() {
LayoutInflater.from(context).inflate(R.layout.view_voice_message, this) LayoutInflater.from(context).inflate(R.layout.view_voice_message, this)
} }
// endregion // endregion
// region Updating // region Updating
fun bind(message: MessageRecord) { fun bind(message: MessageRecord) {
textView.text = "I'm a voice message"
} }
fun recycle() { fun recycle() {

View File

@ -1,5 +1,6 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android" <shape
android:shape="oval"> xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval">
<solid android:color="@color/white" /> <solid android:color="@color/white" />
</shape> </shape>

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:radius="10dp"/>
<solid android:color="@color/white" />
</shape>

View File

@ -1,16 +1,41 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<LinearLayout <LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android" xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent" xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_height="wrap_content" android:layout_width="160dp"
android:layout_height="36dp"
android:orientation="horizontal" android:orientation="horizontal"
android:padding="@dimen/small_spacing"
android:gravity="center"> android:gravity="center">
<RelativeLayout
android:layout_width="20dp"
android:layout_height="20dp"
android:background="@drawable/circle_tintable"
android:backgroundTint="@color/white">
<ImageView
android:layout_width="16dp"
android:layout_height="16dp"
android:src="@drawable/exo_icon_play"
android:layout_centerInParent="true"
app:tint="@color/black" />
</RelativeLayout>
<View
android:layout_width="84dp"
android:layout_height="1dp"
android:background="@color/white" />
<TextView <TextView
android:id="@+id/textView" android:layout_width="40dp"
android:layout_width="match_parent" android:layout_height="20dp"
android:layout_height="wrap_content" android:text="0:08"
android:textSize="@dimen/medium_font_size" android:gravity="center"
android:textColor="@color/text" /> android:textColor="@color/black"
android:textSize="@dimen/small_font_size"
android:background="@drawable/view_voice_message_duration_text_view_background"
android:backgroundTint="@color/white" />
</LinearLayout> </LinearLayout>