Added option to collapse attachments by default

This commit is contained in:
M66B 2023-07-09 07:54:51 +02:00
parent 8cda6ac7a6
commit b5b8f5fe8b
5 changed files with 36 additions and 12 deletions

View File

@ -3503,11 +3503,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
attachments = new ArrayList<>();
properties.setAttachments(message.id, attachments);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean hide_attachments = prefs.getBoolean("hide_attachments", false);
boolean hide_attachments = properties.getValue("hide_attachments", message.id);
boolean show_inline = properties.getValue("inline", message.id);
Log.i("Show inline=" + show_inline);
Log.i("Hide attachments=" + hide_attachments + " Show inline=" + show_inline);
int available = 0;
int unavailable = 0;
@ -3547,14 +3545,14 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
rvAttachment.setVisibility(show.size() > 0 && !hide_attachments ? View.VISIBLE : View.GONE);
vSeparatorAttachments.setVisibility(show.size() > 0 ? View.VISIBLE : View.GONE);
vSeparatorAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
tvAttachments.setText(context.getResources()
.getQuantityString(R.plurals.title_attachments, show.size(), show.size()));
tvAttachments.setVisibility(show.size() > 0 && hide_attachments ? View.VISIBLE : View.GONE);
.getQuantityString(R.plurals.title_attachments, attachments.size(), attachments.size()));
tvAttachments.setVisibility(attachments.size() > 0 && hide_attachments ? View.VISIBLE : View.GONE);
ibExpanderAttachments.setImageLevel(hide_attachments ? 1 /* more */ : 0 /* less */);
ibExpanderAttachments.setVisibility(show.size() > 0 ? View.VISIBLE : View.GONE);
ibExpanderAttachments.setVisibility(attachments.size() > 0 ? View.VISIBLE : View.GONE);
cbInline.setChecked(show_inline);
cbInline.setVisibility(has_inline && !hide_attachments ? View.VISIBLE : View.GONE);
@ -5257,8 +5255,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
}
private void onExpandAttachments(TupleMessageEx message) {
boolean hide_attachments = prefs.getBoolean("hide_attachments", false);
prefs.edit().putBoolean("hide_attachments", !hide_attachments).apply();
boolean hide_attachments = properties.getValue("hide_attachments", message.id);
properties.setValue("hide_attachments", message.id, !hide_attachments);
cowner.restart();
bindAttachments(message, properties.getAttachments(message.id), false);
}

View File

@ -346,6 +346,7 @@ public class FragmentMessages extends FragmentBase
private String onclose;
private boolean quick_scroll;
private boolean addresses;
private boolean hide_attachments;
private boolean auto_hide_answer;
private boolean swipe_reply;
private boolean quick_actions;
@ -499,6 +500,7 @@ public class FragmentMessages extends FragmentBase
onclose = (autoclose ? null : prefs.getString("onclose", null));
quick_scroll = prefs.getBoolean("quick_scroll", true);
addresses = prefs.getBoolean("addresses", false);
hide_attachments = prefs.getBoolean("hide_attachments", false);
auto_hide_answer = prefs.getBoolean("auto_hide_answer", !accessibility);
swipe_reply = prefs.getBoolean("swipe_reply", false);
quick_actions = prefs.getBoolean("quick_actions", true);
@ -2418,6 +2420,8 @@ public class FragmentMessages extends FragmentBase
else {
if ("addresses".equals(name))
return addresses;
else if ("hide_attachments".equals(name))
return hide_attachments;
}
return false;
}

View File

@ -160,6 +160,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
private SwitchCompat swAlignHeader;
private SwitchCompat swAddresses;
private SwitchCompat swHideAttachments;
private TextView tvMessageZoom;
private SeekBar sbMessageZoom;
private SwitchCompat swOverviewMode;
@ -212,7 +213,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
"subject_top", "subject_italic", "highlight_subject", "font_size_subject", "subject_ellipsize",
"keywords_header", "labels_header", "flags", "flags_background",
"preview", "preview_italic", "preview_lines", "align_header",
"addresses",
"addresses", "hide_attachments",
"message_zoom", "overview_mode", "override_width",
"hyphenation", "display_font", "contrast", "monospaced_pre",
"text_separators",
@ -328,6 +329,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
tvPreviewLinesHint = view.findViewById(R.id.tvPreviewLinesHint);
swAlignHeader = view.findViewById(R.id.swAlignHeader);
swAddresses = view.findViewById(R.id.swAddresses);
swHideAttachments = view.findViewById(R.id.swHideAttachments);
tvMessageZoom = view.findViewById(R.id.tvMessageZoom);
sbMessageZoom = view.findViewById(R.id.sbMessageZoom);
swOverviewMode = view.findViewById(R.id.swOverviewMode);
@ -1147,6 +1149,13 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
}
});
swHideAttachments.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("hide_attachments", checked).apply();
}
});
sbMessageZoom.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
@ -1572,6 +1581,7 @@ public class FragmentOptionsDisplay extends FragmentBase implements SharedPrefer
swAlignHeader.setChecked(prefs.getBoolean("align_header", false));
swAddresses.setChecked(prefs.getBoolean("addresses", false));
swHideAttachments.setChecked(prefs.getBoolean("hide_attachments", false));
int message_zoom = prefs.getInt("message_zoom", 100);
tvMessageZoom.setText(getString(R.string.title_advanced_message_text_zoom2, NF.format(message_zoom)));

View File

@ -1698,6 +1698,17 @@
app:layout_constraintTop_toBottomOf="@id/tvCaptionBody"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swHideAttachments"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_hide_attachments"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAddresses"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvMessageZoom"
android:layout_width="0dp"
@ -1708,7 +1719,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAddresses" />
app:layout_constraintTop_toBottomOf="@id/swHideAttachments" />
<SeekBar
android:id="@+id/sbMessageZoom"

View File

@ -608,6 +608,7 @@
<string name="title_advanced_preview_lines">Number of preview lines</string>
<string name="title_advanced_align_header">Vertically align keywords, preview text, and notes</string>
<string name="title_advanced_addresses">Expand address details by default</string>
<string name="title_advanced_hide_attachments">Collapse attachments by default</string>
<string name="title_advanced_unzip">Show contents of compressed attachments</string>
<string name="title_advanced_attachments_alt">Show attachments after the message text</string>
<string name="title_advanced_thumbnails">Show image thumbnails after the message text</string>