Added optional save raw button

pull/209/head
M66B 3 years ago
parent bf583f11c7
commit 1724a2e6f7

@ -439,6 +439,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private ImageButton ibAnswer;
private ImageButton ibRule;
private ImageButton ibUnsubscribe;
private ImageButton ibRaw;
private ImageButton ibHeaders;
private ImageButton ibPrint;
private ImageButton ibPin;
@ -856,6 +857,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAnswer = vsBody.findViewById(R.id.ibAnswer);
ibRule = vsBody.findViewById(R.id.ibRule);
ibUnsubscribe = vsBody.findViewById(R.id.ibUnsubscribe);
ibRaw = vsBody.findViewById(R.id.ibRaw);
ibHeaders = vsBody.findViewById(R.id.ibHeaders);
ibPrint = vsBody.findViewById(R.id.ibPrint);
ibPin = vsBody.findViewById(R.id.ibPin);
@ -999,6 +1001,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAnswer.setOnClickListener(this);
ibRule.setOnClickListener(this);
ibUnsubscribe.setOnClickListener(this);
ibRaw.setOnClickListener(this);
ibHeaders.setOnClickListener(this);
ibHeaders.setOnLongClickListener(this);
ibPrint.setOnClickListener(this);
@ -1113,6 +1116,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAnswer.setOnClickListener(null);
ibRule.setOnClickListener(null);
ibUnsubscribe.setOnClickListener(null);
ibRaw.setOnClickListener(null);
ibHeaders.setOnClickListener(null);
ibHeaders.setOnLongClickListener(null);
ibPrint.setOnClickListener(null);
@ -1676,6 +1680,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAnswer.setVisibility(View.GONE);
ibRule.setVisibility(View.GONE);
ibUnsubscribe.setVisibility(View.GONE);
ibRaw.setVisibility(View.GONE);
ibHeaders.setVisibility(View.GONE);
ibPrint.setVisibility(View.GONE);
ibPin.setVisibility(View.GONE);
@ -1927,6 +1932,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAnswer.setVisibility(View.GONE);
ibRule.setVisibility(View.GONE);
ibUnsubscribe.setVisibility(View.GONE);
ibRaw.setVisibility(View.GONE);
ibHeaders.setVisibility(View.GONE);
ibPrint.setVisibility(View.GONE);
ibPin.setVisibility(View.GONE);
@ -2114,6 +2120,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean forever = (delete && (!pop || !message.accountLeaveDeleted));
boolean report = (pop ? inInbox : !inJunk && move);
boolean headers = (message.uid != null || (pop && message.headers != null));
boolean raw = (message.uid != null ||
(EntityFolder.INBOX.equals(message.folderType) &&
message.accountProtocol == EntityAccount.TYPE_POP));
evalProperties(message); // TODO: done again in bindBody
@ -2144,6 +2153,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
boolean button_pin = prefs.getBoolean("button_pin", false);
boolean button_print = prefs.getBoolean("button_print", false);
boolean button_headers = prefs.getBoolean("button_headers", false);
boolean button_raw = prefs.getBoolean("button_raw", false);
boolean button_unsubscribe = prefs.getBoolean("button_unsubscribe", true);
boolean button_rule = prefs.getBoolean("button_rule", false);
boolean swipe_reply = prefs.getBoolean("swipe_reply", false);
@ -2163,6 +2173,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
ibAnswer.setVisibility(!tools || outbox || (!expand_all && expand_one) || !threading || swipe_reply ? View.GONE : View.VISIBLE);
ibRule.setVisibility(tools && button_rule && !outbox && !message.folderReadOnly ? View.VISIBLE : View.GONE);
ibUnsubscribe.setVisibility(tools && button_unsubscribe && message.unsubscribe != null ? View.VISIBLE : View.GONE);
ibRaw.setVisibility(tools && button_raw && raw ? View.VISIBLE : View.GONE);
ibHeaders.setVisibility(tools && button_headers && headers ? View.VISIBLE : View.GONE);
ibPrint.setVisibility(tools && !outbox && button_print && hasWebView && message.content && Helper.canPrint(context) ? View.VISIBLE : View.GONE);
ibPin.setVisibility(tools && !outbox && button_pin && pin ? View.VISIBLE : View.GONE);
@ -3900,6 +3911,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
onMenuCreateRule(message);
} else if (id == R.id.ibUnsubscribe) {
onActionUnsubscribe(message);
} else if (id == R.id.ibRaw) {
onMenuRawSave(message);
} else if (id == R.id.ibHeaders) {
onMenuShowHeaders(message);
} else if (id == R.id.ibPrint) {
@ -8438,6 +8451,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
final CheckBox cbPin = dview.findViewById(R.id.cbPin);
final CheckBox cbPrint = dview.findViewById(R.id.cbPrint);
final CheckBox cbHeaders = dview.findViewById(R.id.cbHeaders);
final CheckBox cbRaw = dview.findViewById(R.id.cbRaw);
final CheckBox cbUnsubscribe = dview.findViewById(R.id.cbUnsubscribe);
cbTranslate.setVisibility(DeepL.isAvailable(context) ? View.VISIBLE : View.GONE);
@ -8463,6 +8477,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
cbPin.setChecked(prefs.getBoolean("button_pin", false));
cbPrint.setChecked(prefs.getBoolean("button_print", false));
cbHeaders.setChecked(prefs.getBoolean("button_headers", false));
cbRaw.setChecked(prefs.getBoolean("button_raw", false));
cbUnsubscribe.setChecked(prefs.getBoolean("button_unsubscribe", true));
return new AlertDialog.Builder(getContext())
@ -8491,6 +8506,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
editor.putBoolean("button_pin", cbPin.isChecked());
editor.putBoolean("button_print", cbPrint.isChecked());
editor.putBoolean("button_headers", cbHeaders.isChecked());
editor.putBoolean("button_raw", cbRaw.isChecked());
editor.putBoolean("button_unsubscribe", cbUnsubscribe.isChecked());
editor.apply();
sendResult(Activity.RESULT_OK);

@ -278,6 +278,19 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPrint" />
<CheckBox
android:id="@+id/cbRaw"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:drawableEnd="@drawable/twotone_save_alt_24"
android:drawablePadding="6dp"
android:text="@string/title_raw_save"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbHeaders" />
<CheckBox
android:id="@+id/cbUnsubscribe"
android:layout_width="0dp"
@ -289,7 +302,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbHeaders" />
app:layout_constraintTop_toBottomOf="@id/cbRaw" />
<CheckBox
android:id="@+id/cbRule"

@ -50,7 +50,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="3dp"
app:constraint_referenced_ids="vwEmpty,ibMore,ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibCopy,ibKeywords,ibLabels,ibNotes,ibSeen,ibHide,ibImportance,ibTranslate,ibForceLight,ibSearch,ibSearchText,ibEvent,ibShare,ibPin,ibPrint,ibHeaders,ibUnsubscribe,ibRule,ibAnswer,ibUndo"
app:constraint_referenced_ids="vwEmpty,ibMore,ibInbox,ibJunk,ibTrash,ibArchive,ibMove,ibCopy,ibKeywords,ibLabels,ibNotes,ibSeen,ibHide,ibImportance,ibTranslate,ibForceLight,ibSearch,ibSearchText,ibEvent,ibShare,ibPin,ibPrint,ibHeaders,ibRaw,ibUnsubscribe,ibRule,ibAnswer,ibUndo"
app:flow_horizontalBias="0"
app:flow_horizontalGap="3dp"
app:flow_horizontalStyle="packed"
@ -335,6 +335,18 @@
app:srcCompat="@drawable/twotone_code_24"
tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/ibRaw"
android:layout_width="36dp"
android:layout_height="36dp"
android:background="?android:attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/title_raw_save"
android:padding="6dp"
android:scaleType="fitCenter"
android:tooltipText="@string/title_raw_save"
app:srcCompat="@drawable/twotone_save_alt_24"
tools:ignore="MissingConstraints" />
<ImageButton
android:id="@+id/ibUnsubscribe"
android:layout_width="36dp"

Loading…
Cancel
Save