From 5fa6775d19ce02752150ae4479f3e167cfa28e2c Mon Sep 17 00:00:00 2001 From: Moez Bhatti Date: Thu, 21 Dec 2017 16:46:15 -0500 Subject: [PATCH] Improved layout for message status --- .../presentation/compose/MessagesAdapter.kt | 12 +++--- qksms/src/main/res/layout/avatar_view.xml | 1 + .../main/res/layout/message_list_item_in.xml | 26 ++++++------- .../main/res/layout/message_list_item_out.xml | 39 +++++++++---------- qksms/src/main/res/values/styles.xml | 2 +- 5 files changed, 38 insertions(+), 42 deletions(-) diff --git a/qksms/src/main/java/com/moez/QKSMS/presentation/compose/MessagesAdapter.kt b/qksms/src/main/java/com/moez/QKSMS/presentation/compose/MessagesAdapter.kt index 1d6ced25..c6202aac 100644 --- a/qksms/src/main/java/com/moez/QKSMS/presentation/compose/MessagesAdapter.kt +++ b/qksms/src/main/java/com/moez/QKSMS/presentation/compose/MessagesAdapter.kt @@ -52,12 +52,12 @@ class MessagesAdapter @Inject constructor( VIEWTYPE_ME -> { view = layoutInflater.inflate(R.layout.message_list_item_out, parent, false) disposables += colors.bubble - .subscribe { color -> view.body.setBackgroundTint(color) } + .subscribe { color -> view.messageBackground.setBackgroundTint(color) } } else -> { view = layoutInflater.inflate(R.layout.message_list_item_in, parent, false) disposables += colors.theme - .subscribe { color -> view.body.setBackgroundTint(color) } + .subscribe { color -> view.messageBackground.setBackgroundTint(color) } } } @@ -114,22 +114,22 @@ class MessagesAdapter @Inject constructor( when { !canGroupWithPrevious && canGroupWithNext -> { view.setPadding(bottom = 2.dpToPx(context)) - view.body.setBackgroundResource(if (sent) R.drawable.message_out_first else R.drawable.message_in_first) + view.messageBackground.setBackgroundResource(if (sent) R.drawable.message_out_first else R.drawable.message_in_first) view.avatar?.visibility = View.INVISIBLE } canGroupWithPrevious && canGroupWithNext -> { view.setPadding(bottom = 2.dpToPx(context)) - view.body.setBackgroundResource(if (sent) R.drawable.message_out_middle else R.drawable.message_in_middle) + view.messageBackground.setBackgroundResource(if (sent) R.drawable.message_out_middle else R.drawable.message_in_middle) view.avatar?.visibility = View.INVISIBLE } canGroupWithPrevious && !canGroupWithNext -> { view.setPadding(bottom = 16.dpToPx(context)) - view.body.setBackgroundResource(if (sent) R.drawable.message_out_last else R.drawable.message_in_last) + view.messageBackground.setBackgroundResource(if (sent) R.drawable.message_out_last else R.drawable.message_in_last) view.avatar?.visibility = View.VISIBLE } else -> { view.setPadding(bottom = 16.dpToPx(context)) - view.body.setBackgroundResource(R.drawable.message_only) + view.messageBackground.setBackgroundResource(R.drawable.message_only) view.avatar?.visibility = View.VISIBLE } } diff --git a/qksms/src/main/res/layout/avatar_view.xml b/qksms/src/main/res/layout/avatar_view.xml index c458a959..5c17d4b8 100644 --- a/qksms/src/main/res/layout/avatar_view.xml +++ b/qksms/src/main/res/layout/avatar_view.xml @@ -31,6 +31,7 @@ android:id="@+id/photo" android:layout_width="match_parent" android:layout_height="match_parent" + tools:src="@tools:sample/avatars" android:scaleType="centerCrop" /> \ No newline at end of file diff --git a/qksms/src/main/res/layout/message_list_item_in.xml b/qksms/src/main/res/layout/message_list_item_in.xml index 4a0c66df..0632881f 100644 --- a/qksms/src/main/res/layout/message_list_item_in.xml +++ b/qksms/src/main/res/layout/message_list_item_in.xml @@ -34,34 +34,32 @@ android:layout_marginEnd="12dp" /> + android:background="@drawable/message_only" + android:minHeight="36dp" + android:orientation="vertical" + android:paddingBottom="8dp" + android:paddingEnd="12dp" + android:paddingStart="12dp" + android:paddingTop="8dp" + tools:backgroundTint="@color/tools_theme"> - + android:layout_height="0dp" /> diff --git a/qksms/src/main/res/layout/message_list_item_out.xml b/qksms/src/main/res/layout/message_list_item_out.xml index 90af8314..f7d4a79e 100644 --- a/qksms/src/main/res/layout/message_list_item_out.xml +++ b/qksms/src/main/res/layout/message_list_item_out.xml @@ -27,40 +27,37 @@ android:paddingStart="60dp"> + android:background="@drawable/message_only" + android:gravity="start" + android:minHeight="36dp" + android:orientation="vertical" + android:paddingBottom="8dp" + android:paddingEnd="12dp" + android:paddingStart="12dp" + android:paddingTop="8dp" + tools:backgroundTint="@color/white"> + + - - \ No newline at end of file diff --git a/qksms/src/main/res/values/styles.xml b/qksms/src/main/res/values/styles.xml index 78f1f904..6f12762a 100644 --- a/qksms/src/main/res/values/styles.xml +++ b/qksms/src/main/res/values/styles.xml @@ -2,7 +2,7 @@