aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java30
-rw-r--r--src/main/res/layout/conversation_list_row.xml17
-rw-r--r--src/main/res/values-v21/themes.xml1
-rw-r--r--src/main/res/values/attrs.xml1
-rw-r--r--src/main/res/values/themes.xml1
5 files changed, 41 insertions, 9 deletions
diff --git a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
index 773e0ac98..75053740f 100644
--- a/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
+++ b/src/main/java/de/pixart/messenger/ui/adapter/ConversationAdapter.java
@@ -87,6 +87,7 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
convName.setText(conversation.getJid().toBareJid().toString());
}
TextView mLastMessage = (TextView) view.findViewById(R.id.conversation_lastmsg);
+ ImageView mLastMessageImage = (ImageView) view.findViewById(R.id.conversation_lastmsg_img);
TextView mTimestamp = (TextView) view.findViewById(R.id.conversation_lastupdate);
TextView mSenderName = (TextView) view.findViewById(R.id.sender_name);
ImageView imagePreview = (ImageView) view.findViewById(R.id.conversation_lastimage);
@@ -126,13 +127,36 @@ public class ConversationAdapter extends ArrayAdapter<Conversation> {
|| message.getTransferable().getStatus() != Transferable.STATUS_DELETED)) {
mSenderName.setVisibility(View.GONE);
mLastMessage.setVisibility(View.GONE);
+ mLastMessageImage.setVisibility(View.GONE);
imagePreview.setVisibility(View.VISIBLE);
activity.loadBitmap(message, imagePreview);
} else {
- Pair<String, Boolean> preview = UIHelper.getMessagePreview(activity, message);
- mLastMessage.setVisibility(View.VISIBLE);
+ final boolean showPreviewText;
+ if (message.getFileParams().runtime > 0) {
+ showPreviewText = false;
+ mLastMessageImage.setImageResource(activity.getThemeResource(R.attr.ic_attach_record, R.drawable.ic_attach_record));
+ mLastMessageImage.setVisibility(View.VISIBLE);
+ } else if (message.getType() == Message.TYPE_FILE) {
+ showPreviewText = true;
+ mLastMessageImage.setImageResource(activity.getThemeResource(R.attr.ic_attach_document, R.drawable.ic_attach_document));
+ mLastMessageImage.setVisibility(View.VISIBLE);
+ } else if (message.isGeoUri()) {
+ showPreviewText = false;
+ mLastMessageImage.setImageResource(activity.getThemeResource(R.attr.ic_attach_location, R.drawable.ic_attach_location));
+ mLastMessageImage.setVisibility(View.VISIBLE);
+ } else {
+ showPreviewText = true;
+ mLastMessageImage.setVisibility(View.GONE);
+ }
+
+ final Pair<String, Boolean> preview = UIHelper.getMessagePreview(activity, message);
+ if (showPreviewText) {
+ mLastMessage.setText(preview.first);
+ } else {
+ mLastMessageImage.setContentDescription(preview.first);
+ }
+ mLastMessage.setVisibility(showPreviewText ? View.VISIBLE : View.GONE);
imagePreview.setVisibility(View.GONE);
- mLastMessage.setText(preview.first);
if (preview.second) {
if (conversation.isRead()) {
mLastMessage.setTypeface(null, Typeface.ITALIC);
diff --git a/src/main/res/layout/conversation_list_row.xml b/src/main/res/layout/conversation_list_row.xml
index c551f9dc2..480d84eba 100644
--- a/src/main/res/layout/conversation_list_row.xml
+++ b/src/main/res/layout/conversation_list_row.xml
@@ -48,8 +48,8 @@
android:layout_alignLeft="@+id/conversation_lastwrapper"
android:layout_toLeftOf="@+id/conversation_failed"
android:paddingRight="4dp"
- android:singleLine="true"
- android:text="Awesome groupchat"
+ android:ellipsize="end"
+ android:maxLines="1"
android:textAppearance="@style/TextAppearance.AppCompat"
android:textColor="@color/black87"
android:textSize="?attr/TextSizeHeadline" />
@@ -81,7 +81,13 @@
android:layout_centerVertical="true"
android:layout_toLeftOf="@+id/indicators"
android:layout_toRightOf="@+id/sender_name"
- android:orientation="vertical">
+ android:orientation="horizontal">
+
+ <ImageView
+ android:id="@+id/conversation_lastmsg_img"
+ android:layout_width="?attr/IconSize"
+ android:layout_height="?attr/IconSize"
+ android:layout_marginRight="?attr/TextSeparation"/>/>
<com.vanniktech.emoji.EmojiTextView
android:id="@+id/conversation_lastmsg"
@@ -90,8 +96,8 @@
android:gravity="center_vertical"
android:minHeight="?attr/IconSize"
android:scrollHorizontally="false"
- android:singleLine="true"
- android:text="This is a placeholder text to show the last messages"
+ android:maxLines="1"
+ android:ellipsize="end"
android:textColor="@color/black87"
android:textSize="?attr/TextSizeBody" />
@@ -186,7 +192,6 @@
android:layout_alignBaseline="@+id/conversation_name"
android:paddingLeft="4dp"
android:gravity="right"
- android:text="23:42"
android:textColor="@color/black54"
android:textSize="?attr/TextSizeInfo" />
</RelativeLayout>
diff --git a/src/main/res/values-v21/themes.xml b/src/main/res/values-v21/themes.xml
index b1a679258..86346775f 100644
--- a/src/main/res/values-v21/themes.xml
+++ b/src/main/res/values-v21/themes.xml
@@ -14,6 +14,7 @@
<item name="TextSizeBody">14sp</item>
<item name="IconSize">16sp</item>
<item name="TextSizeHeadline">18sp</item>
+ <item name="TextSeparation">5sp</item>
<item name="attr/dialog_horizontal_padding">24dp</item>
<item name="attr/dialog_vertical_padding">16dp</item>
diff --git a/src/main/res/values/attrs.xml b/src/main/res/values/attrs.xml
index bce8c7c6e..a315ab796 100644
--- a/src/main/res/values/attrs.xml
+++ b/src/main/res/values/attrs.xml
@@ -4,6 +4,7 @@
<attr name="TextSizeInfo" format="dimension" />
<attr name="TextSizeBody" format="dimension" />
<attr name="TextSizeHeadline" format="dimension" />
+ <attr name="TextSeparation" format="dimension"/>
<attr name="IconSize" format="dimension" />
<attr name="icon_add_group" format="reference" />
diff --git a/src/main/res/values/themes.xml b/src/main/res/values/themes.xml
index 4e53b26e2..61ffc19ae 100644
--- a/src/main/res/values/themes.xml
+++ b/src/main/res/values/themes.xml
@@ -10,6 +10,7 @@
<item name="TextSizeBody">14sp</item>
<item name="IconSize">16sp</item>
<item name="TextSizeHeadline">18sp</item>
+ <item name="TextSeparation">5sp</item>
<item name="attr/icon_add_group">@drawable/ic_group_add_white_24dp</item>
<item name="attr/icon_add_person">@drawable/ic_person_add_white_24dp</item>