diff --git a/app/src/main/java/eu/faircode/email/ActivityBase.java b/app/src/main/java/eu/faircode/email/ActivityBase.java index f3c503c883..ef672dc03f 100644 --- a/app/src/main/java/eu/faircode/email/ActivityBase.java +++ b/app/src/main/java/eu/faircode/email/ActivityBase.java @@ -82,7 +82,11 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc if (this.getClass().equals(ActivitySetup.class)) startActivity(getIntent()); } else if (!this.getClass().equals(ActivitySetup.class) && - ("avatars".equals(key) || "identicons".equals(key) || "compact".equals(key) || "debug".equals(key))) + ("compact".equals(key) || + "avatars".equals(key) || + "identicons".equals(key) || + "preview".equals(key) || + "debug".equals(key))) finish(); } diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index dd8cdd0ecd..d92d9b8340 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -66,6 +66,7 @@ import android.widget.Toast; import com.google.android.material.bottomnavigation.BottomNavigationView; import com.google.android.material.snackbar.Snackbar; +import org.jsoup.Jsoup; import org.xml.sax.XMLReader; import java.io.File; @@ -111,10 +112,11 @@ public class AdapterMessage extends PagedListAdapter 0 ? View.VISIBLE : View.GONE); tvSubject.setText(message.subject); + tvPreview.setText(null); + tvPreview.setVisibility(preview && message.content ? View.VISIBLE : View.GONE); + if (message.content) { + Bundle args = new Bundle(); + args.putSerializable("message", message); + + new SimpleTask() { + @Override + protected void onInit(Bundle args) { + tvPreview.setHasTransientState(true); + } + + @Override + protected String onLoad(Context context, Bundle args) throws Throwable { + TupleMessageEx message = (TupleMessageEx) args.getSerializable("message"); + String body = message.read(context); + return Jsoup.parse(body).text(); + } + + @Override + protected void onLoaded(Bundle args, String preview) { + tvPreview.setText(preview); + tvPreview.setHasTransientState(false); + } + + @Override + protected void onException(Bundle args, Throwable ex) { + tvPreview.setHasTransientState(false); + Helper.unexpectedError(context, ex); + } + }.load(context, owner, args); + } + if (viewType == ViewType.UNIFIED) tvFolder.setText(message.accountName); else { @@ -1405,11 +1444,12 @@ public class AdapterMessage extends PagedListAdapter EXPORT_SETTINGS = Arrays.asList( "enabled", + "compact", "avatars", "identicons", + "preview", "light", "browse", "swipe", - "compat", "navigation", "insecure", "sort" diff --git a/app/src/main/res/layout/fragment_options.xml b/app/src/main/res/layout/fragment_options.xml index b425008e12..cd1a69897b 100644 --- a/app/src/main/res/layout/fragment_options.xml +++ b/app/src/main/res/layout/fragment_options.xml @@ -20,6 +20,15 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toTopOf="parent" /> + + + app:layout_constraintTop_toBottomOf="@id/swCompact" /> + + + app:layout_constraintTop_toBottomOf="@id/swPreview" /> - - + app:layout_constraintTop_toBottomOf="@id/swSwipe" /> + + + app:layout_constraintTop_toBottomOf="@id/tvPreview" /> + + + app:layout_constraintTop_toBottomOf="@id/tvPreview" /> Advanced options Enabled + Compact message view Show contact photos Show identicons + Show message preview Use notification light Browse messages on the server Swipe actions - Compact message view Previous/next navigation Debug mode