diff --git a/app/src/main/java/eu/faircode/email/FragmentDialogQuickActions.java b/app/src/main/java/eu/faircode/email/FragmentDialogQuickActions.java
index 39f3fe9fe8..40a76a9859 100644
--- a/app/src/main/java/eu/faircode/email/FragmentDialogQuickActions.java
+++ b/app/src/main/java/eu/faircode/email/FragmentDialogQuickActions.java
@@ -47,6 +47,7 @@ public class FragmentDialogQuickActions extends FragmentDialogBase {
final View dview = LayoutInflater.from(context).inflate(R.layout.dialog_quick_actions, null);
final TextView tvHint = dview.findViewById(R.id.tvHint);
final CheckBox cbAnswer = dview.findViewById(R.id.cbAnswer);
+ final CheckBox cbSummarize = dview.findViewById(R.id.cbSummarize);
final CheckBox cbSeen = dview.findViewById(R.id.cbSeen);
final CheckBox cbUnseen = dview.findViewById(R.id.cbUnseen);
final CheckBox cbSnooze = dview.findViewById(R.id.cbSnooze);
@@ -64,8 +65,13 @@ public class FragmentDialogQuickActions extends FragmentDialogBase {
final CheckBox cbInbox = dview.findViewById(R.id.cbInbox);
final CheckBox cbClear = dview.findViewById(R.id.cbClear);
+ boolean hasAi = (OpenAI.isAvailable(context) || Gemini.isAvailable(context));
+ cbSummarize.setVisibility(hasAi ? View.VISIBLE : View.GONE);
+
tvHint.setText(getString(R.string.title_quick_actions_hint, MAX_QUICK_ACTIONS));
+
cbAnswer.setChecked(prefs.getBoolean("more_answer", false));
+ cbSummarize.setChecked(prefs.getBoolean("more_summarize", false));
cbSeen.setChecked(prefs.getBoolean("more_seen", true));
cbUnseen.setChecked(prefs.getBoolean("more_unseen", false));
cbSnooze.setChecked(prefs.getBoolean("more_snooze", false));
@@ -90,6 +96,7 @@ public class FragmentDialogQuickActions extends FragmentDialogBase {
public void onClick(DialogInterface dialog, int which) {
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("more_answer", cbAnswer.isChecked());
+ editor.putBoolean("more_summarize", cbSummarize.isChecked());
editor.putBoolean("more_seen", cbSeen.isChecked());
editor.putBoolean("more_unseen", cbUnseen.isChecked());
editor.putBoolean("more_snooze", cbSnooze.isChecked());
diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java
index f1d45a7dac..74720fcca3 100644
--- a/app/src/main/java/eu/faircode/email/FragmentMessages.java
+++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java
@@ -26,6 +26,8 @@ import static android.text.format.DateUtils.FORMAT_SHOW_DATE;
import static android.text.format.DateUtils.FORMAT_SHOW_WEEKDAY;
import static android.view.KeyEvent.ACTION_DOWN;
import static android.view.KeyEvent.ACTION_UP;
+import static android.view.View.GONE;
+import static android.view.View.VISIBLE;
import static androidx.recyclerview.widget.RecyclerView.NO_POSITION;
import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_KEY_MISSING;
import static org.openintents.openpgp.OpenPgpSignatureResult.RESULT_NO_SIGNATURE;
@@ -291,6 +293,7 @@ public class FragmentMessages extends FragmentBase
private TextView tvSelectedCount;
private CardView cardMore;
private ImageButton ibAnswer;
+ private ImageButton ibSummarize;
private ImageButton ibBatchSeen;
private ImageButton ibBatchUnseen;
private ImageButton ibBatchSnooze;
@@ -620,6 +623,7 @@ public class FragmentMessages extends FragmentBase
tvSelectedCount = view.findViewById(R.id.tvSelectedCount);
cardMore = view.findViewById(R.id.cardMore);
ibAnswer = view.findViewById(R.id.ibAnswer);
+ ibSummarize = view.findViewById(R.id.ibSummarize);
ibBatchSeen = view.findViewById(R.id.ibBatchSeen);
ibBatchUnseen = view.findViewById(R.id.ibBatchUnseen);
ibBatchSnooze = view.findViewById(R.id.ibBatchSnooze);
@@ -1624,6 +1628,22 @@ public class FragmentMessages extends FragmentBase
}
});
+ ibSummarize.setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View v) {
+ MoreResult result = (MoreResult) cardMore.getTag();
+ if (result == null || result.single == null || !result.single.content)
+ return;
+
+ Bundle args = new Bundle();
+ args.putLong("id", result.single.id);
+
+ FragmentDialogSummarize fragment = new FragmentDialogSummarize();
+ fragment.setArguments(args);
+ fragment.show(getParentFragmentManager(), "message:summary");
+ }
+ });
+
ibBatchSeen.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@@ -6972,6 +6992,7 @@ public class FragmentMessages extends FragmentBase
boolean more_importance_high = prefs.getBoolean("more_importance_high", false);
boolean more_importance_normal = prefs.getBoolean("more_importance_normal", false);
boolean more_importance_low = prefs.getBoolean("more_importance_low", false);
+ boolean more_summarize = prefs.getBoolean("more_summarize", false);
boolean more_inbox = prefs.getBoolean("more_inbox", true);
boolean more_archive = prefs.getBoolean("more_archive", true);
boolean more_junk = prefs.getBoolean("more_junk", true);
@@ -7057,6 +7078,11 @@ public class FragmentMessages extends FragmentBase
if (seen)
count++;
+ boolean summarize = (more_summarize && count < FragmentDialogQuickActions.MAX_QUICK_ACTIONS &&
+ result.single != null && result.single.content);
+ if (summarize)
+ count++;
+
boolean answer = (more_answer && count < FragmentDialogQuickActions.MAX_QUICK_ACTIONS &&
result.single != null && result.single.content);
@@ -7064,6 +7090,7 @@ public class FragmentMessages extends FragmentBase
ibInbox.setImageResource(inJunk ? R.drawable.twotone_report_off_24 : R.drawable.twotone_inbox_24);
ibAnswer.setVisibility(answer ? View.VISIBLE : View.GONE);
+ ibSummarize.setVisibility(summarize ? VISIBLE : GONE);
ibBatchSeen.setVisibility(seen ? View.VISIBLE : View.GONE);
ibBatchUnseen.setVisibility(unseen ? View.VISIBLE : View.GONE);
ibBatchSnooze.setVisibility(snooze ? View.VISIBLE : View.GONE);
diff --git a/app/src/main/res/layout/dialog_quick_actions.xml b/app/src/main/res/layout/dialog_quick_actions.xml
index 2598afa685..29f6561c3e 100644
--- a/app/src/main/res/layout/dialog_quick_actions.xml
+++ b/app/src/main/res/layout/dialog_quick_actions.xml
@@ -44,6 +44,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvHint" />
+
+
+ app:layout_constraintTop_toBottomOf="@id/cbSummarize" />
+
+