Added option to expand first message when all read

pull/196/head
M66B 4 years ago
parent e4082dc33a
commit f03480de0c

@ -4930,7 +4930,10 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
autoExpanded = false;
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean expand_first = prefs.getBoolean("expand_first", true);
boolean expand_all = prefs.getBoolean("expand_all", false);
long download = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE);
if (download == 0)
download = Long.MAX_VALUE;
@ -4984,7 +4987,8 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
expand = messages.get(0);
else if (messages.size() > 0) {
TupleMessageEx first = messages.get(adapter.getAscending() ? messages.size() - 1 : 0);
if (first != null && EntityFolder.OUTBOX.equals(first.folderType))
if (first != null &&
((expand_first && unseen == 0) || EntityFolder.OUTBOX.equals(first.folderType)))
expand = first;
}
@ -4994,7 +4998,6 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
// Auto expand all seen messages
boolean expand_all = prefs.getBoolean("expand_all", false);
if (expand_all)
for (TupleMessageEx message : messages)
if (message != null &&

@ -74,6 +74,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swSwipeClose;
private SwitchCompat swSwipeMove;
private SwitchCompat swAutoExpand;
private SwitchCompat swExpandFirst;
private SwitchCompat swExpandAll;
private SwitchCompat swExpandOne;
private SwitchCompat swAutoClose;
@ -92,7 +93,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
"default_snooze",
"pull", "autoscroll", "quick_filter", "quick_scroll",
"doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move",
"autoexpand", "expand_all", "expand_one", "collapse_multiple",
"autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple",
"autoclose", "onclose", "undo_timeout",
"autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance"
};
@ -125,6 +126,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swSwipeClose = view.findViewById(R.id.swSwipeClose);
swSwipeMove = view.findViewById(R.id.swSwipeMove);
swAutoExpand = view.findViewById(R.id.swAutoExpand);
swExpandFirst = view.findViewById(R.id.swExpandFirst);
swExpandAll = view.findViewById(R.id.swExpandAll);
swExpandOne = view.findViewById(R.id.swExpandOne);
swCollapseMultiple = view.findViewById(R.id.swCollapseMultiple);
@ -288,6 +290,14 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("autoexpand", checked).apply();
swExpandFirst.setEnabled(checked);
}
});
swExpandFirst.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("expand_first", checked).apply();
}
});
@ -459,6 +469,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swSwipeMove.setChecked(prefs.getBoolean("swipe_move", false));
swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true));
swExpandFirst.setChecked(prefs.getBoolean("expand_first", true));
swExpandFirst.setEnabled(swAutoExpand.isChecked());
swExpandAll.setChecked(prefs.getBoolean("expand_all", false));
swExpandOne.setChecked(prefs.getBoolean("expand_one", true));
swExpandOne.setEnabled(!swExpandAll.isChecked());

@ -334,6 +334,18 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoExpand" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swExpandFirst"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_expand_first"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAutoExpandHint"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swExpandAll"
android:layout_width="0dp"
@ -342,7 +354,7 @@
android:text="@string/title_advanced_expand_all"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAutoExpandHint"
app:layout_constraintTop_toBottomOf="@id/swExpandFirst"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -429,6 +429,7 @@
<string name="title_advanced_swipe_close">Swipe down to close conversation</string>
<string name="title_advanced_swipe_move">Swipe up to move conversation</string>
<string name="title_advanced_autoexpand">Automatically expand messages</string>
<string name="title_advanced_expand_first">Automatically expand the first message when the conversation is read</string>
<string name="title_advanced_expand_all">Automatically expand all read messages</string>
<string name="title_advanced_expand_one">Expand only one message at a time</string>
<string name="title_advanced_collapse_multiple">Collapse messages in a conversation with multiple messages on \'back\'</string>

Loading…
Cancel
Save