Browse Source

Better error display

main
M66B 6 years ago
parent
commit
097b47ce62
5 changed files with 33 additions and 10 deletions
  1. +8
    -6
      app/src/main/java/eu/faircode/email/FragmentMessage.java
  2. +18
    -2
      app/src/main/res/layout/fragment_message.xml
  3. +2
    -2
      app/src/main/res/layout/item_message.xml
  4. +2
    -0
      app/src/main/res/values/colors.xml
  5. +3
    -0
      app/src/main/res/values/styles.xml

+ 8
- 6
app/src/main/java/eu/faircode/email/FragmentMessage.java View File

@ -105,6 +105,7 @@ public class FragmentMessage extends FragmentEx {
private Group grpHeader; private Group grpHeader;
private Group grpAddresses; private Group grpAddresses;
private Group grpAttachments; private Group grpAttachments;
private Group grpError;
private Group grpMessage; private Group grpMessage;
private TupleMessageEx message = null; private TupleMessageEx message = null;
@ -148,6 +149,7 @@ public class FragmentMessage extends FragmentEx {
grpHeader = view.findViewById(R.id.grpHeader); grpHeader = view.findViewById(R.id.grpHeader);
grpAddresses = view.findViewById(R.id.grpAddresses); grpAddresses = view.findViewById(R.id.grpAddresses);
grpAttachments = view.findViewById(R.id.grpAttachments); grpAttachments = view.findViewById(R.id.grpAttachments);
grpError = view.findViewById(R.id.grpError);
grpMessage = view.findViewById(R.id.grpMessage); grpMessage = view.findViewById(R.id.grpMessage);
setHasOptionsMenu(true); setHasOptionsMenu(true);
@ -219,11 +221,11 @@ public class FragmentMessage extends FragmentEx {
tvCount.setVisibility(View.GONE); tvCount.setVisibility(View.GONE);
grpAddresses.setVisibility(View.GONE); grpAddresses.setVisibility(View.GONE);
grpAttachments.setVisibility(View.GONE); grpAttachments.setVisibility(View.GONE);
tvError.setVisibility(View.GONE);
grpError.setVisibility(View.GONE);
tvCount.setTag(tvCount.getVisibility()); tvCount.setTag(tvCount.getVisibility());
tvCc.setTag(grpAddresses.getVisibility()); tvCc.setTag(grpAddresses.getVisibility());
tvError.setTag(tvError.getVisibility());
tvError.setTag(grpError.getVisibility());
} }
}); });
@ -243,7 +245,7 @@ public class FragmentMessage extends FragmentEx {
tvCount.setVisibility((int) tvCount.getTag()); tvCount.setVisibility((int) tvCount.getTag());
grpAddresses.setVisibility((int) tvCc.getTag()); grpAddresses.setVisibility((int) tvCc.getTag());
grpAttachments.setVisibility(adapter != null && adapter.getItemCount() > 0 ? View.VISIBLE : View.GONE); grpAttachments.setVisibility(adapter != null && adapter.getItemCount() > 0 ? View.VISIBLE : View.GONE);
tvError.setVisibility((int) tvError.getTag());
grpError.setVisibility((int) tvError.getTag());
return true; return true;
} }
@ -284,7 +286,7 @@ public class FragmentMessage extends FragmentEx {
pbBody.setVisibility(View.GONE); pbBody.setVisibility(View.GONE);
bottom_navigation.setVisibility(View.GONE); bottom_navigation.setVisibility(View.GONE);
tvCount.setVisibility(View.GONE); tvCount.setVisibility(View.GONE);
tvError.setVisibility(View.GONE);
grpError.setVisibility(View.GONE);
fab.setVisibility(View.GONE); fab.setVisibility(View.GONE);
pbWait.setVisibility(View.VISIBLE); pbWait.setVisibility(View.VISIBLE);
@ -474,10 +476,10 @@ public class FragmentMessage extends FragmentEx {
if (free) { if (free) {
tvCount.setVisibility((int) tvCount.getTag()); tvCount.setVisibility((int) tvCount.getTag());
grpAddresses.setVisibility((int) tvCc.getTag()); grpAddresses.setVisibility((int) tvCc.getTag());
tvError.setVisibility((int) tvError.getTag());
grpError.setVisibility((int) tvError.getTag());
} else { } else {
tvCount.setVisibility(!free && message.count > 1 ? View.VISIBLE : View.GONE); tvCount.setVisibility(!free && message.count > 1 ? View.VISIBLE : View.GONE);
tvError.setVisibility(free || message.error == null ? View.GONE : View.VISIBLE);
grpError.setVisibility(free || message.error == null ? View.GONE : View.VISIBLE);
} }
// Observe attachments // Observe attachments


+ 18
- 2
app/src/main/res/layout/fragment_message.xml View File

@ -203,19 +203,29 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" /> app:layout_constraintTop_toBottomOf="@+id/vSeparatorAttachments" />
<View
android:id="@+id/vSeparatorError"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginTop="3dp"
android:background="?attr/colorSeparator"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvAttachment" />
<TextView <TextView
android:id="@+id/tvError" android:id="@+id/tvError"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:layout_marginTop="3dp"
android:freezesText="true" android:freezesText="true"
android:text="error" android:text="error"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="bold"
android:textColor="?attr/colorWarning"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/rvAttachment" />
app:layout_constraintTop_toBottomOf="@id/vSeparatorError" />
<View <View
android:id="@+id/vSeparatorBody" android:id="@+id/vSeparatorBody"
@ -330,6 +340,12 @@
android:layout_height="0dp" android:layout_height="0dp"
app:constraint_referenced_ids="vSeparatorAttachments,rvAttachment" /> app:constraint_referenced_ids="vSeparatorAttachments,rvAttachment" />
<androidx.constraintlayout.widget.Group
android:id="@+id/grpError"
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="vSeparatorError,tvError" />
<androidx.constraintlayout.widget.Group <androidx.constraintlayout.widget.Group
android:id="@+id/grpMessage" android:id="@+id/grpMessage"
android:layout_width="0dp" android:layout_width="0dp"


+ 2
- 2
app/src/main/res/layout/item_message.xml View File

@ -93,9 +93,9 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="6dp" android:layout_marginEnd="6dp"
android:layout_marginStart="6dp" android:layout_marginStart="6dp"
android:text="error\ndebug info\noperation 1\n operation 2"
android:text="error"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="bold"
android:textColor="?attr/colorWarning"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSubject" /> app:layout_constraintTop_toBottomOf="@id/tvSubject" />


+ 2
- 0
app/src/main/res/values/colors.xml View File

@ -10,6 +10,7 @@
<color name="lightColorUnread">#000</color> <color name="lightColorUnread">#000</color>
<color name="lightColorItemSelected">#ccc</color> <color name="lightColorItemSelected">#ccc</color>
<color name="lightColorSeparator">#aaa</color> <color name="lightColorSeparator">#aaa</color>
<color name="lightColorWarning">#ffff0000</color>
<color name="lightColorDrawerScrim">#99000000</color> <color name="lightColorDrawerScrim">#99000000</color>
<color name="lightColorDrawerText">#111</color> <color name="lightColorDrawerText">#111</color>
<color name="lightColorDrawerBackground">#eee</color> <color name="lightColorDrawerBackground">#eee</color>
@ -17,6 +18,7 @@
<color name="darkColorUnread">#fff</color> <color name="darkColorUnread">#fff</color>
<color name="darkColorItemSelected">#555</color> <color name="darkColorItemSelected">#555</color>
<color name="darkColorSeparator">#666</color> <color name="darkColorSeparator">#666</color>
<color name="darkColorWarning">#ffffb300</color>
<color name="darkColorDrawerScrim">#997f7f7f</color> <color name="darkColorDrawerScrim">#997f7f7f</color>
<color name="darkColorDrawerText">#fff</color> <color name="darkColorDrawerText">#fff</color>
<color name="darkColorDrawerBackground">#222</color> <color name="darkColorDrawerBackground">#222</color>


+ 3
- 0
app/src/main/res/values/styles.xml View File

@ -1,6 +1,7 @@
<resources> <resources>
<attr name="colorUnread" format="reference" /> <attr name="colorUnread" format="reference" />
<attr name="colorSeparator" format="reference" /> <attr name="colorSeparator" format="reference" />
<attr name="colorWarning" format="reference" />
<attr name="colorDrawerScrim" format="reference" /> <attr name="colorDrawerScrim" format="reference" />
<attr name="colorDrawerText" format="reference" /> <attr name="colorDrawerText" format="reference" />
<attr name="colorDrawerBackground" format="reference" /> <attr name="colorDrawerBackground" format="reference" />
@ -15,6 +16,7 @@
<item name="colorUnread">@color/lightColorUnread</item> <item name="colorUnread">@color/lightColorUnread</item>
<item name="colorSeparator">@color/lightColorSeparator</item> <item name="colorSeparator">@color/lightColorSeparator</item>
<item name="colorWarning">@color/lightColorWarning</item>
<item name="colorDrawerScrim">@color/lightColorDrawerScrim</item> <item name="colorDrawerScrim">@color/lightColorDrawerScrim</item>
<item name="colorDrawerText">@color/lightColorDrawerText</item> <item name="colorDrawerText">@color/lightColorDrawerText</item>
<item name="colorDrawerBackground">@color/lightColorDrawerBackground</item> <item name="colorDrawerBackground">@color/lightColorDrawerBackground</item>
@ -31,6 +33,7 @@
<item name="colorUnread">@color/darkColorUnread</item> <item name="colorUnread">@color/darkColorUnread</item>
<item name="colorSeparator">@color/darkColorSeparator</item> <item name="colorSeparator">@color/darkColorSeparator</item>
<item name="colorWarning">@color/darkColorWarning</item>
<item name="colorDrawerScrim">@color/darkColorDrawerScrim</item> <item name="colorDrawerScrim">@color/darkColorDrawerScrim</item>
<item name="colorDrawerText">@color/darkColorDrawerText</item> <item name="colorDrawerText">@color/darkColorDrawerText</item>
<item name="colorDrawerBackground">@color/darkColorDrawerBackground</item> <item name="colorDrawerBackground">@color/darkColorDrawerBackground</item>


Loading…
Cancel
Save