Added setting to expand all read

pull/162/head
M66B 5 years ago
parent 888d4b6ad9
commit ee426df7f3

@ -1216,8 +1216,9 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
if ("expanded".equals(name)) {
// Collapse other messages
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
boolean expand_all = prefs.getBoolean("expand_all", false);
boolean expand_one = prefs.getBoolean("expand_one", true);
if (expand_one) {
if (!expand_all && expand_one) {
for (Long other : new ArrayList<>(values.get(name)))
if (!other.equals(id)) {
values.get(name).remove(other);
@ -3162,6 +3163,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
iProperties.setValue("expanded", expand.id, true);
}
boolean expand_all = prefs.getBoolean("expand_all", false);
if (expand_all)
for (TupleMessageEx message : messages)
if (message != null && message.ui_seen)
iProperties.setValue("expanded", message.id, true);
}
} else {
if (autoCloseCount > 0 && (autoclose || onclose != null)) {

@ -46,6 +46,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swSwipeNav;
private SwitchCompat swReversed;
private SwitchCompat swAutoExpand;
private SwitchCompat swExpandAll;
private SwitchCompat swExpandOne;
private SwitchCompat swAutoClose;
private Spinner spOnClose;
@ -57,7 +58,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swDiscardDelete;
private final static String[] RESET_OPTIONS = new String[]{
"pull", "autoscroll", "doubletap", "swipenav", "reversed", "autoexpand", "expand_one", "autoclose", "onclose",
"pull", "autoscroll", "doubletap", "swipenav", "reversed", "autoexpand", "expand_all", "expand_one", "autoclose", "onclose",
"collapse_single", "collapse_multiple", "autoread", "autounflag", "automove", "discard_delete"
};
@ -77,6 +78,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swSwipeNav = view.findViewById(R.id.swSwipeNav);
swReversed = view.findViewById(R.id.swReversed);
swAutoExpand = view.findViewById(R.id.swAutoExpand);
swExpandAll = view.findViewById(R.id.swExpandAll);
swExpandOne = view.findViewById(R.id.swExpandOne);
swAutoClose = view.findViewById(R.id.swAutoClose);
spOnClose = view.findViewById(R.id.spOnClose);
@ -135,6 +137,14 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
swExpandAll.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("expand_all", checked).apply();
swExpandOne.setEnabled(!checked);
}
});
swExpandOne.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -261,7 +271,9 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swSwipeNav.setChecked(prefs.getBoolean("swipenav", true));
swReversed.setChecked(prefs.getBoolean("reversed", false));
swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true));
swExpandAll.setChecked(prefs.getBoolean("expand_all", false));
swExpandOne.setChecked(prefs.getBoolean("expand_one", true));
swExpandOne.setEnabled(!swExpandAll.isChecked());
swAutoClose.setChecked(prefs.getBoolean("autoclose", true));
String onClose = prefs.getString("onclose", "");

@ -93,6 +93,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoExpand" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swExpandAll"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_expand_all"
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/swExpandOne"
android:layout_width="0dp"
@ -101,7 +112,7 @@
android:text="@string/title_advanced_expand_one"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvAutoExpandHint"
app:layout_constraintTop_toBottomOf="@id/swExpandAll"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

@ -275,6 +275,7 @@
<string name="title_advanced_swipenav">Swipe left/right to go to next/previous conversation</string>
<string name="title_advanced_reversed">Reverse navigation direction</string>
<string name="title_advanced_autoexpand">Automatically expand messages</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_single">Collapse single message in a conversation on \'back\'</string>
<string name="title_advanced_collapse_multiple">Collapse multiple messages in a conversation on \'back\'</string>

Loading…
Cancel
Save