mirror of https://github.com/M66B/FairEmail.git
Added summarize quick action
This commit is contained in:
parent
caef8803f2
commit
0b66c0a45e
|
@ -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());
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -44,6 +44,19 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvHint" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbSummarize"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:drawableEnd="@drawable/twotone_smart_toy_24"
|
||||
android:drawablePadding="6dp"
|
||||
android:text="@string/title_summarize"
|
||||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbAnswer" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbSeen"
|
||||
android:layout_width="0dp"
|
||||
|
@ -55,7 +68,7 @@
|
|||
android:textAppearance="@style/TextAppearance.AppCompat.Small"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/cbAnswer" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cbSummarize" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbUnseen"
|
||||
|
|
|
@ -669,6 +669,20 @@
|
|||
app:srcCompat="@drawable/twotone_reply_24_options"
|
||||
app:tint="@color/action_foreground" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibSummarize"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:background="?android:attr/selectableItemBackgroundBorderless"
|
||||
android:contentDescription="@string/title_summarize"
|
||||
android:padding="6dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:tooltipText="@string/title_summarize"
|
||||
app:layout_constraintEnd_toStartOf="@id/ibAnswer"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/twotone_smart_toy_24"
|
||||
app:tint="@color/action_foreground" />
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/ibBatchSeen"
|
||||
android:layout_width="48dp"
|
||||
|
@ -678,7 +692,7 @@
|
|||
android:padding="6dp"
|
||||
android:scaleType="fitCenter"
|
||||
android:tooltipText="@string/title_seen"
|
||||
app:layout_constraintEnd_toStartOf="@id/ibAnswer"
|
||||
app:layout_constraintEnd_toStartOf="@id/ibSummarize"
|
||||
app:layout_constraintTop_toTopOf="parent"
|
||||
app:srcCompat="@drawable/twotone_drafts_24"
|
||||
app:tint="@color/action_foreground" />
|
||||
|
|
Loading…
Reference in New Issue