Browse Source

improve the changes on message list

main
Distopico Vegan 6 years ago
parent
commit
3e39a7ff77
5 changed files with 91 additions and 77 deletions
  1. +17
    -16
      app/src/main/java/org/dystopia/email/AdapterMessage.java
  2. +39
    -35
      app/src/main/res/layout/item_message_compact.xml
  3. +25
    -23
      app/src/main/res/layout/item_message_normal.xml
  4. +1
    -1
      app/src/main/res/layout/widget.xml
  5. +9
    -2
      app/src/main/res/values/dimens.xml

+ 17
- 16
app/src/main/java/org/dystopia/email/AdapterMessage.java View File

@ -334,7 +334,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
tvSize.setText(
message.size == null ? null : Helper.humanReadableByteCount(message.size, true));
tvSize.setAlpha(message.content ? 1.0f : 0.5f);
tvSize.setVisibility(compact && !show_expanded ? View.GONE : View.VISIBLE);
ivAttachments.setVisibility(message.attachments > 0 ? View.VISIBLE : View.GONE);
tvSubject.setText(message.subject);
@ -342,17 +341,14 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
tvFolder.setVisibility(View.GONE);
tvAccount.setVisibility(View.GONE);
if (!compact || show_expanded) {
if (viewType == ViewType.UNIFIED || viewType == ViewType.FOLDER) {
tvAccount.setText(message.accountName);
tvAccount.setVisibility(View.VISIBLE);
} else {
tvFolder.setText(
message.folderDisplay == null
? Helper.localizeFolderName(context, message.folderName)
: message.folderDisplay);
tvFolder.setVisibility(View.VISIBLE);
}
if (viewType == ViewType.UNIFIED || viewType == ViewType.FOLDER) {
tvAccount.setText(message.accountName);
tvAccount.setVisibility(View.VISIBLE);
} else {
tvFolder.setText(message.folderDisplay == null
? Helper.localizeFolderName(context, message.folderName)
: message.folderDisplay);
tvFolder.setVisibility(View.VISIBLE);
}
if (viewType == ViewType.THREAD || message.count == 1) {
@ -364,9 +360,13 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
ivThread.setVisibility(View.VISIBLE);
}
if (!compact) {
tvFrom.setMaxLines(show_expanded ? Integer.MAX_VALUE : 1);
tvSubject.setMaxLines(show_expanded ? Integer.MAX_VALUE : 1);
}
tvSummary.setVisibility(View.GONE);
if (message.content && !show_expanded)
{
if (message.content && !show_expanded) {
try {
String body = message.read(context);
Document doc = Jsoup.parse(body);
@ -374,7 +374,9 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
int limit = compact ? 60 : 120;
tvSummary.setText(plainText.substring(0, Math.min(plainText.length(), limit)) + "...");
tvSummary.setVisibility(View.VISIBLE);
} catch(IOException e) { }
} catch(IOException ex) {
Log.e(Helper.TAG, ex + "\n" + Log.getStackTraceString(ex));
}
}
if (debug) {
@ -733,7 +735,6 @@ public class AdapterMessage extends PagedListAdapter<TupleMessageEx, AdapterMess
}
};
private Spanned decodeHtml(final EntityMessage message, String body) {
return Html.fromHtml(
HtmlHelper.sanitize(body),


+ 39
- 35
app/src/main/res/layout/item_message_compact.xml View File

@ -52,7 +52,7 @@
android:id="@+id/ivAvatar"
android:layout_width="0dp"
android:layout_height="24dp"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:src="@drawable/baseline_person_24"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintDimensionRatio="1:1"
@ -63,7 +63,7 @@
android:id="@+id/tvFrom"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:layout_marginEnd="20dp"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
@ -78,7 +78,7 @@
android:id="@+id/tvTime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="6dp"
android:layout_marginEnd="@dimen/margin_sm"
android:maxLines="1"
android:text="Time"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
@ -100,7 +100,7 @@
android:id="@+id/ivAttachments"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:src="@drawable/baseline_attachment_24"
app:layout_constraintBottom_toBottomOf="@id/tvSubject"
app:layout_constraintStart_toEndOf="@id/paddingStart"
@ -110,7 +110,8 @@
android:id="@+id/tvSubject"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:layout_marginEnd="@dimen/margin_sm"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:maxLines="1"
@ -125,7 +126,7 @@
android:id="@+id/tvAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:maxLines="1"
android:text="account"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
@ -136,7 +137,7 @@
android:id="@+id/tvFolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:background="@color/colorAccent"
android:maxLines="1"
android:paddingLeft="10dp"
@ -147,32 +148,32 @@
app:layout_constraintStart_toEndOf="@id/tvAccount"
app:layout_constraintTop_toBottomOf="@id/tvSummary" />
<TextView
android:id="@+id/tvCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="3"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@id/ivThread"
app:layout_constraintTop_toTopOf="@+id/tvTime" />
<ImageView
android:id="@+id/ivThread"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="6dp"
android:paddingStart="2dp"
android:src="@drawable/baseline_message_24"
app:layout_constraintEnd_toStartOf="@id/tvTime"
app:layout_constraintTop_toTopOf="@id/tvTime" />
<TextView
android:id="@+id/tvCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/margin_sm"
android:maxLines="1"
android:text="3"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintTop_toBottomOf="@id/tvSummary"
app:layout_constraintStart_toEndOf="@id/tvFolder" />
<ImageView
android:id="@+id/ivThread"
android:layout_width="@dimen/icon_xxs"
android:layout_height="@dimen/icon_xxs"
android:layout_marginStart="@dimen/padding_xs"
android:src="@drawable/baseline_message_24"
app:layout_constraintBottom_toBottomOf="@id/tvCount"
app:layout_constraintStart_toEndOf="@id/tvCount"
app:layout_constraintTop_toTopOf="@id/tvCount" />
<TextView
android:id="@+id/tvSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:layout_marginEnd="@dimen/margin_sm"
android:maxLines="1"
android:text="123 KB"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
@ -184,10 +185,12 @@
android:id="@+id/tvSummary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginStart="@dimen/margin_md"
android:layout_marginEnd="@dimen/margin_md"
android:fontFamily="sans-serif-light"
android:maxLines="1"
android:minLines="1"
android:ellipsize="end"
android:text="Summary"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="@id/paddingEnd"
@ -198,8 +201,8 @@
android:id="@+id/tvError"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginEnd="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:layout_marginEnd="@dimen/margin_sm"
android:text="error"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
@ -471,11 +474,12 @@
<TextView
android:id="@+id/tvBody"
android:layout_width="0dp"
android:layout_width="@dimen/no_size"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="6dp"
android:layout_marginTop="@dimen/margin_sm"
android:layout_marginStart="@dimen/content_margin"
android:layout_marginEnd="@dimen/content_margin"
android:padding="@dimen/padding_xs"
android:minHeight="60dp"
android:text="Body"
android:textAppearance="@style/TextAppearance.AppCompat.Small"


+ 25
- 23
app/src/main/res/layout/item_message_normal.xml View File

@ -50,7 +50,7 @@
android:id="@+id/ivAvatar"
android:layout_width="0dp"
android:layout_height="24dp"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:src="@drawable/baseline_person_24"
app:layout_constraintBottom_toBottomOf="@+id/tvFrom"
app:layout_constraintDimensionRatio="1:1"
@ -64,8 +64,6 @@
android:layout_marginStart="6dp"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:maxLines="1"
android:minLines="1"
android:text="Subject"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toStartOf="@id/paddingEnd"
@ -80,7 +78,6 @@
android:layout_marginEnd="6dp"
android:ellipsize="end"
android:fontFamily="sans-serif-light"
android:maxLines="1"
android:text="From"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"
app:layout_constraintEnd_toStartOf="@+id/tvTime"
@ -114,7 +111,7 @@
android:id="@+id/ivAttachments"
android:layout_width="21dp"
android:layout_height="21dp"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:src="@drawable/baseline_attachment_24"
app:layout_constraintBottom_toBottomOf="@id/tvSubject"
app:layout_constraintStart_toEndOf="@id/paddingStart"
@ -124,7 +121,8 @@
android:id="@+id/tvAccount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="@dimen/margin_xs"
android:layout_marginStart="@dimen/margin_sm"
android:maxLines="1"
android:text="account"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
@ -135,7 +133,8 @@
android:id="@+id/tvFolder"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="@dimen/margin_xs"
android:layout_marginStart="@dimen/margin_sm"
android:background="@color/colorAccent"
android:maxLines="1"
android:paddingLeft="10dp"
@ -150,28 +149,29 @@
android:id="@+id/tvCount"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="28dp"
android:layout_marginTop="@dimen/margin_xs"
android:layout_marginStart="@dimen/margin_sm"
android:maxLines="1"
android:text="3"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintStart_toEndOf="@id/tvFolder"
app:layout_constraintTop_toTopOf="@id/tvFolder" />
app:layout_constraintTop_toBottomOf="@id/tvSummary"
app:layout_constraintStart_toEndOf="@id/tvFolder" />
<ImageView
android:id="@+id/ivThread"
android:layout_width="15dp"
android:layout_height="15dp"
android:layout_marginTop="2dp"
android:paddingStart="2dp"
android:layout_width="@dimen/icon_xs"
android:layout_height="@dimen/icon_xs"
android:layout_marginStart="@dimen/padding_xs"
android:src="@drawable/baseline_message_24"
app:layout_constraintBottom_toBottomOf="@id/tvCount"
app:layout_constraintStart_toEndOf="@id/tvCount"
app:layout_constraintTop_toTopOf="@id/tvFolder" />
app:layout_constraintTop_toTopOf="@id/tvCount" />
<TextView
android:id="@+id/tvSize"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="4dp"
android:layout_marginEnd="@dimen/margin_sm"
android:maxLines="1"
android:text="123 KB"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
@ -182,10 +182,12 @@
android:id="@+id/tvSummary"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:layout_marginStart="@dimen/margin_lg"
android:layout_marginEnd="@dimen/margin_md"
android:fontFamily="sans-serif-light"
android:maxLines="2"
android:minLines="1"
android:ellipsize="end"
android:text="Summary"
android:textStyle="italic"
app:layout_constraintEnd_toStartOf="@id/paddingEnd"
@ -196,9 +198,8 @@
android:id="@+id/tvError"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginStart="@dimen/margin_sm"
android:layout_marginTop="6dp"
android:layout_marginEnd="6dp"
android:text="error"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?attr/colorWarning"
@ -468,11 +469,12 @@
<TextView
android:id="@+id/tvBody"
android:layout_width="0dp"
android:layout_width="@dimen/no_size"
android:layout_height="wrap_content"
android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="6dp"
android:layout_marginTop="@dimen/margin_sm"
android:layout_marginStart="@dimen/content_margin"
android:layout_marginEnd="@dimen/content_margin"
android:padding="@dimen/padding_xs"
android:minHeight="60dp"
android:text="Body"
android:textAppearance="@style/TextAppearance.AppCompat.Medium"


+ 1
- 1
app/src/main/res/layout/widget.xml View File

@ -11,7 +11,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingStart="@dimen/padding_xs"
android:paddingEnd="@dimen/padding_md"
android:paddingEnd="@dimen/padding_sm"
android:layout_gravity="center_horizontal"
android:src="@drawable/ic_action_name"
android:tint="@color/colorWidgetForeground" />


+ 9
- 2
app/src/main/res/values/dimens.xml View File

@ -1,10 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="no_size">0dp</dimen>
<dimen name="base_margin">12dp</dimen>
<dimen name="padding_xs">3dp</dimen>
<dimen name="padding_md">6dp</dimen>
<dimen name="padding_sm">6dp</dimen>
<dimen name="margin_xs">3dp</dimen>
<dimen name="margin_sm">6dp</dimen>
<dimen name="margin_md">12dp</dimen>
<dimen name="margin_lg">16dp</dimen>
<dimen name="icon_xxs">12dp</dimen>
<dimen name="icon_xs">14dp</dimen>
<dimen name="layout_margin">12dp</dimen>
<dimen name="content_margin">6dp</dimen>
<dimen name="content_margin">8dp</dimen>
<dimen name="compose_padding">6dp</dimen>
<dimen name="input_height">40dp</dimen>
<dimen name="color_pick">24dp</dimen>


Loading…
Cancel
Save