Added option to not mark messages seen on expanding

This commit is contained in:
M66B 2019-08-29 19:34:10 +02:00
parent db5d54ead2
commit 4a6805c2f1
5 changed files with 34 additions and 5 deletions

View File

@ -2291,6 +2291,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.getMenu().findItem(R.id.menu_editasnew).setEnabled(message.content);
popupMenu.getMenu().findItem(R.id.menu_unseen).setTitle(message.ui_seen ? R.string.title_unseen : R.string.title_seen);
popupMenu.getMenu().findItem(R.id.menu_unseen).setEnabled(message.uid != null && !message.folderReadOnly);
popupMenu.getMenu().findItem(R.id.menu_flag_color).setEnabled(message.uid != null && !message.folderReadOnly);
@ -2635,11 +2636,13 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
private void onMenuUnseen(final TupleMessageEx message) {
Bundle args = new Bundle();
args.putLong("id", message.id);
args.putBoolean("seen", !message.ui_seen);
new SimpleTask<Void>() {
@Override
protected Void onExecute(Context context, Bundle args) {
long id = args.getLong("id");
boolean seen = args.getBoolean("seen");
DB db = DB.getInstance(context);
try {
@ -2649,7 +2652,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
if (message == null)
return null;
EntityOperation.queue(context, message, EntityOperation.SEEN, false);
EntityOperation.queue(context, message, EntityOperation.SEEN, seen);
db.setTransactionSuccessful();
} finally {
@ -2661,7 +2664,9 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
@Override
protected void onExecuted(Bundle args, Void ignored) {
properties.setValue("expanded", message.id, false);
boolean seen = args.getBoolean("seen");
if (!seen)
properties.setValue("expanded", message.id, false);
notifyDataSetChanged();
}

View File

@ -3098,6 +3098,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
long id = args.getLong("id");
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean expand_read = prefs.getBoolean("expand_read", true);
boolean inline_images = prefs.getBoolean("inline_images", false);
DB db = DB.getInstance(context);
@ -3123,7 +3124,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
EntityOperation.queue(context, message, EntityOperation.ATTACHMENT, attachment.id);
}
if (!message.ui_seen && !folder.read_only)
if (expand_read && !message.ui_seen && !folder.read_only)
EntityOperation.queue(context, message, EntityOperation.SEEN, true);
}

View File

@ -43,6 +43,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swAutoScroll;
private SwitchCompat swSwipeNav;
private SwitchCompat swDoubleTap;
private SwitchCompat swExpandRead;
private SwitchCompat swAutoExpand;
private SwitchCompat swAutoClose;
private Spinner spOnClose;
@ -54,7 +55,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swDisableTracking;
private final static String[] RESET_OPTIONS = new String[]{
"pull", "autoscroll", "swipenav", "doubletap", "autoexpand", "autoclose", "onclose",
"pull", "autoscroll", "swipenav", "doubletap", "expand_read", "autoexpand", "autoclose", "onclose",
"collapse", "autoread", "automove", "discard_delete", "authentication", "disable_tracking"
};
@ -72,6 +73,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoScroll = view.findViewById(R.id.swAutoScroll);
swSwipeNav = view.findViewById(R.id.swSwipeNav);
swDoubleTap = view.findViewById(R.id.swDoubleTap);
swExpandRead = view.findViewById(R.id.swExpandRead);
swAutoExpand = view.findViewById(R.id.swAutoExpand);
swAutoClose = view.findViewById(R.id.swAutoClose);
spOnClose = view.findViewById(R.id.spOnClose);
@ -116,6 +118,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
}
});
swExpandRead.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("expand_read", checked).apply();
}
});
swAutoExpand.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -239,6 +248,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swAutoScroll.setChecked(prefs.getBoolean("autoscroll", false));
swSwipeNav.setChecked(prefs.getBoolean("swipenav", true));
swDoubleTap.setChecked(prefs.getBoolean("doubletap", false));
swExpandRead.setChecked(prefs.getBoolean("expand_read", true));
swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true));
swAutoClose.setChecked(prefs.getBoolean("autoclose", true));

View File

@ -64,6 +64,18 @@
app:layout_constraintTop_toBottomOf="@id/swSwipeNav"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swExpandRead"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_expand_read"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDoubleTap"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swAutoExpand"
android:layout_width="0dp"
@ -73,7 +85,7 @@
android:text="@string/title_advanced_autoexpand"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swDoubleTap"
app:layout_constraintTop_toBottomOf="@id/swExpandRead"
app:switchPadding="12dp" />
<TextView

View File

@ -258,6 +258,7 @@
<string name="title_advanced_autoscroll">Scroll to top on receiving new messages</string>
<string name="title_advanced_swipenav">Swipe left/right to go to next/previous conversation</string>
<string name="title_advanced_double_tap">Double tap to mark message read/unread</string>
<string name="title_advanced_expand_read">Mark messages read on expanding</string>
<string name="title_advanced_autoexpand">Automatically expand messages</string>
<string name="title_advanced_collapse">Collapse messages in conversations on \'back\'</string>
<string name="title_advanced_autoclose">Automatically close conversations</string>