Improved layout for message status

This commit is contained in:
Moez Bhatti
2017-12-21 16:46:15 -05:00
parent 5080f3d365
commit 5fa6775d19
5 changed files with 38 additions and 42 deletions
@@ -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
}
}
@@ -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" />
</merge>
@@ -34,34 +34,32 @@
android:layout_marginEnd="12dp" />
<LinearLayout
android:layout_width="0dp"
android:id="@+id/messageBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
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">
<com.moez.QKSMS.presentation.common.widget.TightTextView
android:id="@+id/body"
style="@style/TextPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="start"
android:autoLink="all"
android:background="@drawable/message_only"
android:gravity="start|center_vertical"
android:minHeight="36dp"
android:paddingBottom="8dp"
android:paddingEnd="12dp"
android:paddingStart="12dp"
android:paddingTop="8dp"
app:textColor="primaryOnTheme"
tools:backgroundTint="@color/tools_theme"
tools:text="@tools:sample/lorem/random" />
<com.moez.QKSMS.presentation.common.widget.QkTextView
<TextView
android:id="@+id/status"
android:layout_width="0dp"
android:layout_height="0dp"
android:visibility="gone" />
android:layout_height="0dp" />
</LinearLayout>
@@ -27,40 +27,37 @@
android:paddingStart="60dp">
<LinearLayout
android:layout_width="0dp"
android:id="@+id/messageBackground"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:orientation="vertical">
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">
<com.moez.QKSMS.presentation.common.widget.TightTextView
android:id="@+id/body"
style="@style/TextPrimary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="end"
android:autoLink="all"
android:background="@drawable/message_only"
android:gravity="start|center_vertical"
android:minHeight="36dp"
android:paddingBottom="8dp"
android:paddingEnd="12dp"
android:paddingStart="12dp"
android:paddingTop="8dp"
tools:backgroundTint="@color/white"
tools:text="Hey! How's it going?" />
<com.moez.QKSMS.presentation.common.widget.QkTextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:textColor="tertiary"
tools:text="Sending..." />
</LinearLayout>
</LinearLayout>
<com.moez.QKSMS.presentation.common.widget.QkTextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="12dp"
android:paddingTop="4dp"
app:textColor="tertiary"
tools:text="Sending..." />
</LinearLayout>
+1 -1
View File
@@ -2,7 +2,7 @@
<style name="AppThemeLight" parent="Theme.AppCompat.Light.NoActionBar">
<item name="windowActionBar">false</item>
<item name="android:windowBackground">@color/white</item>
<item name="android:windowBackground">@color/backgroundLight</item>
<item name="colorPrimary">@color/white</item>
<item name="colorPrimaryDark">@color/statusBarLight</item>
</style>