From 34342bc96b0d7f781e7f59bba5bd019a3e20ffde Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 14 May 2024 08:08:44 +0200 Subject: [PATCH] Summarize: show duration --- .../email/FragmentDialogSummarize.java | 10 +++++++++ app/src/main/res/layout/dialog_summarize.xml | 22 +++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogSummarize.java b/app/src/main/java/eu/faircode/email/FragmentDialogSummarize.java index f9b3e7e998..cb6b5fbe0b 100644 --- a/app/src/main/java/eu/faircode/email/FragmentDialogSummarize.java +++ b/app/src/main/java/eu/faircode/email/FragmentDialogSummarize.java @@ -38,6 +38,7 @@ import org.jsoup.nodes.Document; import java.io.File; import java.util.ArrayList; +import java.util.Date; import java.util.List; public class FragmentDialogSummarize extends FragmentDialogBase { @@ -47,6 +48,7 @@ public class FragmentDialogSummarize extends FragmentDialogBase { final Context context = getContext(); final View view = LayoutInflater.from(context).inflate(R.layout.dialog_summarize, null); final TextView tvSummary = view.findViewById(R.id.tvSummary); + final TextView tvElapsed = view.findViewById(R.id.tvElapsed); final ContentLoadingProgressBar pbWait = view.findViewById(R.id.pbWait); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); @@ -62,12 +64,16 @@ public class FragmentDialogSummarize extends FragmentDialogBase { new SimpleTask() { @Override protected void onPreExecute(Bundle args) { + tvSummary.setVisibility(View.GONE); + tvElapsed.setVisibility(View.GONE); pbWait.setVisibility(View.VISIBLE); + args.putLong("start", new Date().getTime()); } @Override protected void onPostExecute(Bundle args) { pbWait.setVisibility(View.GONE); + args.putLong("elapsed", new Date().getTime() - args.getLong("start")); } @Override @@ -123,11 +129,15 @@ public class FragmentDialogSummarize extends FragmentDialogBase { @Override protected void onExecuted(Bundle args, String text) { tvSummary.setText(text); + tvSummary.setVisibility(View.VISIBLE); + tvElapsed.setText(Helper.formatDuration(args.getLong("elapsed"))); + tvElapsed.setVisibility(View.VISIBLE); } @Override protected void onException(Bundle args, Throwable ex) { tvSummary.setText(new ThrowableWrapper(ex).toSafeString()); + tvSummary.setVisibility(View.VISIBLE); } }.execute(this, getArguments(), "message:summarize"); diff --git a/app/src/main/res/layout/dialog_summarize.xml b/app/src/main/res/layout/dialog_summarize.xml index a37bfdcdca..530ba83bc6 100644 --- a/app/src/main/res/layout/dialog_summarize.xml +++ b/app/src/main/res/layout/dialog_summarize.xml @@ -28,8 +28,6 @@ android:layout_width="0dp" android:layout_height="wrap_content" android:layout_marginTop="24dp" - android:focusable="false" - android:minHeight="60dp" android:text="Text" android:textAppearance="@style/TextAppearance.AppCompat.Medium" android:textIsSelectable="true" @@ -37,17 +35,27 @@ app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@id/tvCaption" /> + + \ No newline at end of file