Add RTL support to conversation message bubbles

This commit is contained in:
Torsten Grote
2018-09-11 13:37:59 -03:00
parent b72f6b4fc3
commit 81292967e0
18 changed files with 137 additions and 102 deletions

View File

@@ -1,17 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/layout"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/message_bubble_margin"
android:layout_marginEnd="@dimen/message_bubble_margin_non_tail"
android:layout_marginLeft="@dimen/message_bubble_margin_tail"
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
android:layout_marginStart="@dimen/message_bubble_margin_tail"
android:layout_marginTop="@dimen/message_bubble_margin"
android:background="@drawable/msg_in"
android:elevation="@dimen/message_bubble_elevation"
android:orientation="vertical">
android:elevation="@dimen/message_bubble_elevation">
<com.vanniktech.emoji.EmojiTextView
android:id="@+id/text"
@@ -19,6 +21,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintBottom_toTopOf="@+id/time"
app:layout_constraintEnd_toEndOf="@+id/time"
app:layout_constraintTop_toTopOf="parent"
tools:text="Short message"/>
<TextView
@@ -26,8 +31,9 @@
style="@style/TextMessage.Timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|end"
android:layout_marginTop="@dimen/message_bubble_timestamp_margin"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="Dec 24, 13:37"/>
</LinearLayout>
</android.support.constraint.ConstraintLayout>

View File

@@ -1,19 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
<!-- This is needed to right-align message bubble in RecyclerView -->
<FrameLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical">
android:layout_height="wrap_content">
<RelativeLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/layout"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right|end"
android:layout_marginBottom="@dimen/message_bubble_margin"
android:layout_marginEnd="@dimen/message_bubble_margin_tail"
android:layout_marginLeft="@dimen/message_bubble_margin_non_tail"
android:layout_marginRight="@dimen/message_bubble_margin_tail"
android:layout_marginStart="@dimen/message_bubble_margin_non_tail"
android:layout_marginTop="@dimen/message_bubble_margin"
android:background="@drawable/msg_out"
android:elevation="@dimen/message_bubble_elevation">
@@ -24,6 +27,8 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/briar_text_primary_inverse"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="This is a long long long message that spans over several lines.\n\nIt ends here."/>
<TextView
@@ -31,24 +36,24 @@
style="@style/TextMessage.Timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/text"
android:layout_marginTop="@dimen/message_bubble_timestamp_margin"
android:textColor="@color/private_message_date_inverse"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="Dec 24, 13:37"/>
<ImageView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/time"
android:layout_marginLeft="@dimen/margin_medium"
android:layout_toEndOf="@+id/time"
android:layout_toRightOf="@+id/time"
android:layout_marginStart="@dimen/margin_medium"
app:layout_constraintBottom_toBottomOf="@+id/time"
app:layout_constraintStart_toEndOf="@+id/time"
app:layout_constraintTop_toTopOf="@+id/time"
tools:ignore="ContentDescription"
tools:src="@drawable/message_delivered_white"/>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
</LinearLayout>
</FrameLayout>

View File

@@ -1,9 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/message_bubble_margin"
android:layout_marginEnd="@dimen/message_bubble_margin_non_tail"
android:layout_marginLeft="@dimen/message_bubble_margin_tail"
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
android:layout_marginStart="@dimen/message_bubble_margin_tail"
android:layout_marginTop="@dimen/message_bubble_margin"
android:orientation="vertical">
@@ -12,20 +18,14 @@
style="@style/TextMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="left|start"
android:layout_marginLeft="@dimen/message_bubble_margin_tail"
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
android:background="@drawable/msg_in_top"
android:elevation="@dimen/message_bubble_elevation"
tools:text="Short message"/>
<RelativeLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/message_bubble_margin"
android:layout_marginLeft="@dimen/message_bubble_margin_tail"
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
android:background="@drawable/notice_in_bottom"
android:elevation="@dimen/message_bubble_elevation">
@@ -34,7 +34,8 @@
style="@style/TextMessage.Notice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minWidth="80dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/forum_invitation_received"/>
<TextView
@@ -42,12 +43,11 @@
style="@style/TextMessage.Timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/text"
android:layout_alignRight="@+id/text"
android:layout_below="@+id/text"
android:layout_marginTop="@dimen/message_bubble_timestamp_margin"
app:layout_constraintEnd_toEndOf="@+id/text"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="Dec 24, 13:37"/>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
</LinearLayout>

View File

@@ -5,6 +5,11 @@
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/message_bubble_margin"
android:layout_marginEnd="@dimen/message_bubble_margin_tail"
android:layout_marginLeft="@dimen/message_bubble_margin_non_tail"
android:layout_marginRight="@dimen/message_bubble_margin_tail"
android:layout_marginStart="@dimen/message_bubble_margin_non_tail"
android:layout_marginTop="@dimen/message_bubble_margin"
android:orientation="vertical">
@@ -13,20 +18,15 @@
style="@style/TextMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/message_bubble_margin_non_tail"
android:layout_marginRight="@dimen/message_bubble_margin_tail"
android:background="@drawable/msg_out_top"
android:elevation="@dimen/message_bubble_elevation"
android:textColor="@color/briar_text_primary_inverse"
tools:text="This is a long long long message that spans over several lines.\n\nIt ends here."/>
<RelativeLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/message_bubble_margin"
android:layout_marginLeft="@dimen/message_bubble_margin_non_tail"
android:layout_marginRight="@dimen/message_bubble_margin_tail"
android:background="@drawable/notice_out_bottom"
android:elevation="@dimen/message_bubble_elevation">
@@ -36,6 +36,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/private_message_date_inverse"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/introduction_request_received"/>
<TextView
@@ -43,25 +45,25 @@
style="@style/TextMessage.Timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_below="@+id/text"
android:layout_marginTop="@dimen/message_bubble_timestamp_margin"
android:textColor="@color/private_message_date_inverse"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text"
tools:text="Dec 24, 13:37"/>
<android.support.v7.widget.AppCompatImageView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/time"
android:layout_marginLeft="@dimen/margin_medium"
android:layout_toEndOf="@+id/time"
android:layout_toRightOf="@+id/time"
android:layout_marginStart="@dimen/margin_medium"
app:layout_constraintBottom_toBottomOf="@+id/time"
app:layout_constraintStart_toEndOf="@+id/time"
app:layout_constraintTop_toTopOf="@+id/time"
app:tint="@color/private_message_date_inverse"
tools:ignore="ContentDescription"
tools:src="@drawable/message_delivered"/>
</RelativeLayout>
</android.support.constraint.ConstraintLayout>
</LinearLayout>

View File

@@ -1,9 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/message_bubble_margin"
android:layout_marginEnd="@dimen/message_bubble_margin_non_tail"
android:layout_marginLeft="@dimen/message_bubble_margin_tail"
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
android:layout_marginStart="@dimen/message_bubble_margin_tail"
android:layout_marginTop="@dimen/message_bubble_margin"
android:orientation="vertical">
@@ -12,20 +18,15 @@
style="@style/TextMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/message_bubble_margin_tail"
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
android:background="@drawable/msg_in_top"
android:elevation="@dimen/message_bubble_elevation"
android:textColor="?android:attr/textColorPrimary"
tools:text="Short message"/>
<RelativeLayout
<android.support.constraint.ConstraintLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/message_bubble_margin"
android:layout_marginLeft="@dimen/message_bubble_margin_tail"
android:layout_marginRight="@dimen/message_bubble_margin_non_tail"
android:background="@drawable/notice_in_bottom"
android:elevation="@dimen/message_bubble_elevation">
@@ -34,41 +35,38 @@
style="@style/TextMessage.Notice"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="@string/introduction_request_received"/>
<TextView
android:id="@+id/time"
style="@style/TextMessage.Timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/text"
android:layout_alignRight="@+id/text"
android:layout_below="@+id/acceptButton"
android:layout_marginTop="@dimen/message_bubble_timestamp_margin"
tools:text="Dec 24, 13:37"/>
<Button
android:id="@+id/acceptButton"
style="@style/BriarButtonFlat.Positive"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignEnd="@+id/text"
android:layout_alignRight="@+id/text"
android:layout_below="@+id/text"
android:layout_marginBottom="-10dp"
android:text="@string/accept"/>
android:text="@string/accept"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text"/>
<Button
android:id="@+id/declineButton"
style="@style/BriarButtonFlat.Negative"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/acceptButton"
android:layout_alignTop="@+id/acceptButton"
android:layout_toLeftOf="@+id/acceptButton"
android:layout_toStartOf="@+id/acceptButton"
android:text="@string/decline"/>
android:text="@string/decline"
app:layout_constraintBottom_toBottomOf="@+id/acceptButton"
app:layout_constraintEnd_toStartOf="@+id/acceptButton"
app:layout_constraintTop_toTopOf="@+id/acceptButton"/>
</RelativeLayout>
<TextView
android:id="@+id/time"
style="@style/TextMessage.Timestamp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toBottomOf="@+id/acceptButton"
tools:text="Dec 24, 13:37"/>
</android.support.constraint.ConstraintLayout>
</LinearLayout>