Added option to auto close on mark unseen

pull/201/head
M66B 4 years ago
parent c088c49631
commit 1ed6fe621d

@ -279,6 +279,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private boolean authentication;
private boolean authentication_indicator;
private boolean autoclose_unseen;
private boolean language_detection;
private List<String> languages;
private static boolean debug;
@ -4807,7 +4809,10 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
message.ui_seen = args.getBoolean("seen");
message.unseen = (message.ui_seen ? 0 : message.count);
properties.setExpanded(message, false, false);
if (!message.ui_seen && autoclose_unseen)
properties.finish();
else
properties.setExpanded(message, false, false);
}
@Override
@ -5721,6 +5726,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
this.authentication_indicator = (this.authentication &&
prefs.getBoolean("authentication_indicator", false));
this.language_detection = prefs.getBoolean("language_detection", false);
this.autoclose_unseen = prefs.getBoolean("autoclose_unseen", false);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N) {
languages = new ArrayList<>();

@ -83,6 +83,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private TextView tvAutoSeenHint;
private TextView tvOnClose;
private Spinner spOnClose;
private SwitchCompat swAutoCloseUnseen;
private Spinner spUndoTimeout;
private SwitchCompat swCollapseMultiple;
private SwitchCompat swAutoRead;
@ -100,7 +101,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
"pull", "autoscroll", "quick_filter", "quick_scroll", "swipe_sensitivity",
"doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move",
"autoexpand", "expand_first", "expand_all", "expand_one", "collapse_multiple",
"autoclose", "onclose", "undo_timeout",
"autoclose", "onclose", "autoclose_unseen",
"undo_timeout",
"autoread", "flag_snoozed", "autounflag", "auto_important", "reset_importance"
};
@ -141,6 +143,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoClose = view.findViewById(R.id.swAutoClose);
tvOnClose = view.findViewById(R.id.tvOnClose);
spOnClose = view.findViewById(R.id.spOnClose);
swAutoCloseUnseen = view.findViewById(R.id.swAutoCloseUnseen);
spUndoTimeout = view.findViewById(R.id.spUndoTimeout);
swAutoRead = view.findViewById(R.id.swAutoRead);
swFlagSnoozed = view.findViewById(R.id.swFlagSnoozed);
@ -386,6 +389,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
swAutoCloseUnseen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("autoclose_unseen", checked).apply();
}
});
spUndoTimeout.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
@ -524,6 +534,8 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
tvOnClose.setEnabled(!swAutoClose.isChecked());
spOnClose.setEnabled(!swAutoClose.isChecked());
swAutoCloseUnseen.setChecked(prefs.getBoolean("autoclose_unseen", false));
int undo_timeout = prefs.getInt("undo_timeout", 5000);
int[] undoValues = getResources().getIntArray(R.array.undoValues);
for (int pos = 0; pos < undoValues.length; pos++)

@ -529,6 +529,17 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOnClose" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoCloseUnseen"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_advanced_autoclose_unread"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spOnClose"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvUndoTimeout"
android:layout_width="0dp"
@ -540,7 +551,7 @@
android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spOnClose" />
app:layout_constraintTop_toBottomOf="@id/swAutoCloseUnseen" />
<Spinner
android:id="@+id/spUndoTimeout"

@ -489,6 +489,7 @@
<string name="title_advanced_collapse_multiple">Collapse messages in a conversation with multiple messages on \'back\'</string>
<string name="title_advanced_autoclose">Automatically close conversations</string>
<string name="title_advanced_onclose">On closing a conversation</string>
<string name="title_advanced_autoclose_unread">Close conversations on marking messages as unread</string>
<string name="title_advanced_undo">Undo timeout</string>
<string name="title_advanced_quick_filter">Show non-obtrusive quick filter icons</string>
<string name="title_advanced_quick_scroll">Show non-obtrusive quick scroll up/down icons</string>

Loading…
Cancel
Save