From 738973499224ef09f4bc7d831ff7b7b49685d7cd Mon Sep 17 00:00:00 2001 From: Distopico Vegan Date: Thu, 16 May 2019 12:45:06 -0500 Subject: [PATCH] fix(ui): improve message items view to compact and unread Related: https://framagit.org/dystopia-project/simple-email/issues/30 --- .../org/dystopia/email/AdapterMessage.java | 29 +++++++++++++------ .../main/java/org/dystopia/email/Helper.java | 23 +++++++++++++++ .../org/dystopia/email/MessageHelper.java | 21 ++++++++++++-- .../drawable/item_background_unread_dark.xml | 5 ++++ .../drawable/item_background_unread_light.xml | 5 ++++ .../main/res/layout/item_message_compact.xml | 2 ++ app/src/main/res/values/colors.xml | 2 ++ app/src/main/res/values/styles.xml | 6 ++++ 8 files changed, 81 insertions(+), 12 deletions(-) create mode 100644 app/src/main/res/drawable/item_background_unread_dark.xml create mode 100644 app/src/main/res/drawable/item_background_unread_light.xml diff --git a/app/src/main/java/org/dystopia/email/AdapterMessage.java b/app/src/main/java/org/dystopia/email/AdapterMessage.java index 274546dd..e502a5d6 100644 --- a/app/src/main/java/org/dystopia/email/AdapterMessage.java +++ b/app/src/main/java/org/dystopia/email/AdapterMessage.java @@ -319,18 +319,25 @@ public class AdapterMessage extends PagedListAdapter 0 ? View.VISIBLE : View.GONE); } + Address[] addresses = null; if (EntityFolder.DRAFTS.equals(message.folderType) || EntityFolder.OUTBOX.equals(message.folderType) || EntityFolder.SENT.equals(message.folderType)) { - tvFrom.setText(MessageHelper.getFormattedAddresses(message.to, show_expanded)); + addresses = message.to; tvTime.setText( DateUtils.getRelativeTimeSpanString( context, message.sent == null ? message.received : message.sent)); } else { - tvFrom.setText(MessageHelper.getFormattedAddresses(message.from, show_expanded)); + addresses = message.from; tvTime.setText(DateUtils.getRelativeTimeSpanString(context, message.received)); } + if (compact && show_expanded) { + tvFrom.setText(MessageHelper.getFormattedAddresses(addresses, false, false)); + } else { + tvFrom.setText(MessageHelper.getFormattedAddresses(addresses, show_expanded, true)); + } + tvSize.setText( message.size == null ? null : Helper.humanReadableByteCount(message.size, true)); tvSize.setAlpha(message.content ? 1.0f : 0.5f); @@ -360,13 +367,13 @@ public class AdapterMessage extends PagedListAdapterAddress + * @param full true render the full format + * @param displayName true display name instead of email when is not 'full' + * @return email addresses as string + */ + static String getFormattedAddresses(Address[] addresses, boolean full, boolean displayName) { if (addresses == null || addresses.length == 0) { return ""; } @@ -432,11 +440,14 @@ public class MessageHelper { if (TextUtils.isEmpty(personal)) { formatted.add(address.toString()); } else { + String email = a.getAddress(); personal = personal.replaceAll("[\\,\\<\\>]", ""); if (full) { - formatted.add(personal + " <" + a.getAddress() + ">"); - } else { + formatted.add(personal + " <" + email + ">"); + } else if (displayName) { formatted.add(personal); + } else { + formatted.add(email); } } } else { @@ -446,6 +457,10 @@ public class MessageHelper { return TextUtils.join(", ", formatted); } + static String getFormattedAddresses(Address[] addresses, boolean full) { + return getFormattedAddresses(addresses, full, true); + } + String getHtml() throws MessagingException, IOException { return getHtml(imessage); } diff --git a/app/src/main/res/drawable/item_background_unread_dark.xml b/app/src/main/res/drawable/item_background_unread_dark.xml new file mode 100644 index 00000000..d43d4d77 --- /dev/null +++ b/app/src/main/res/drawable/item_background_unread_dark.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/drawable/item_background_unread_light.xml b/app/src/main/res/drawable/item_background_unread_light.xml new file mode 100644 index 00000000..6025c0e1 --- /dev/null +++ b/app/src/main/res/drawable/item_background_unread_light.xml @@ -0,0 +1,5 @@ + + + + + diff --git a/app/src/main/res/layout/item_message_compact.xml b/app/src/main/res/layout/item_message_compact.xml index 9f309d28..6d471591 100644 --- a/app/src/main/res/layout/item_message_compact.xml +++ b/app/src/main/res/layout/item_message_compact.xml @@ -67,6 +67,7 @@ android:layout_marginEnd="20dp" android:fontFamily="sans-serif-light" android:text="@string/default_from" + android:ellipsize="end" android:textAppearance="@style/TextAppearance.AppCompat.Medium" app:layout_constraintEnd_toStartOf="@id/tvTime" app:layout_constraintStart_toEndOf="@id/ivAvatar" @@ -112,6 +113,7 @@ android:layout_marginEnd="@dimen/margin_sm" android:fontFamily="sans-serif-light" android:minLines="1" + android:ellipsize="end" android:text="@string/default_subject" android:textAppearance="@style/TextAppearance.AppCompat.Small" app:layout_constraintEnd_toStartOf="@id/paddingEnd" diff --git a/app/src/main/res/values/colors.xml b/app/src/main/res/values/colors.xml index 5ae46190..b463a2e3 100644 --- a/app/src/main/res/values/colors.xml +++ b/app/src/main/res/values/colors.xml @@ -17,6 +17,7 @@ #99000000 #111 #eee + #efefef #fff #555 @@ -25,6 +26,7 @@ #997f7f7f #fff #222 + #191919 #ff000000 diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml index 3de993a6..0bf3d331 100644 --- a/app/src/main/res/values/styles.xml +++ b/app/src/main/res/values/styles.xml @@ -5,7 +5,9 @@ + +