mirror of
https://github.com/M66B/FairEmail.git
synced 2025-02-22 22:21:18 +00:00
Added option to auto unflag on move
This commit is contained in:
parent
f87e71558e
commit
2d6e35a028
6 changed files with 43 additions and 12 deletions
|
@ -564,7 +564,7 @@ class Core {
|
|||
|
||||
if (!ifolder.getPermanentFlags().contains(Flags.Flag.FLAGGED)) {
|
||||
db.message().setMessageFlagged(message.id, false);
|
||||
db.message().setMessageUiFlagged(message.id, false);
|
||||
db.message().setMessageUiFlagged(message.id, false, null);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -760,6 +760,8 @@ class Core {
|
|||
// Get arguments
|
||||
long id = jargs.getLong(0);
|
||||
boolean autoread = jargs.optBoolean(1, false);
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean autounflag = prefs.getBoolean("autounflag", false);
|
||||
Flags flags = ifolder.getPermanentFlags();
|
||||
|
||||
// Get target folder
|
||||
|
@ -806,6 +808,11 @@ class Core {
|
|||
if (autoread && flags.contains(Flags.Flag.SEEN))
|
||||
icopy.setFlag(Flags.Flag.SEEN, true);
|
||||
|
||||
// Auto unflag
|
||||
if (autounflag && flags.contains(Flags.Flag.FLAGGED))
|
||||
icopy.setFlag(Flags.Flag.FLAGGED, false);
|
||||
|
||||
// Answered fix
|
||||
if (message.ui_answered && flags.contains(Flags.Flag.ANSWERED))
|
||||
icopy.setFlag(Flags.Flag.ANSWERED, true);
|
||||
|
||||
|
@ -824,6 +831,11 @@ class Core {
|
|||
if (autoread && flags.contains(Flags.Flag.SEEN))
|
||||
imessage.setFlag(Flags.Flag.SEEN, true);
|
||||
|
||||
// Auto unflag
|
||||
if (autounflag && flags.contains(Flags.Flag.FLAGGED))
|
||||
imessage.setFlag(Flags.Flag.FLAGGED, false);
|
||||
|
||||
// Answered fix
|
||||
if (message.ui_answered && flags.contains(Flags.Flag.ANSWERED))
|
||||
imessage.setFlag(Flags.Flag.ANSWERED, true);
|
||||
}
|
||||
|
@ -2182,6 +2194,8 @@ class Core {
|
|||
update = true;
|
||||
message.flagged = flagged;
|
||||
message.ui_flagged = flagged;
|
||||
if (!flagged)
|
||||
message.color = null;
|
||||
Log.i(folder.name + " updated id=" + message.id + " uid=" + message.uid + " flagged=" + flagged);
|
||||
}
|
||||
|
||||
|
|
|
@ -380,8 +380,8 @@ public interface DaoMessage {
|
|||
@Query("UPDATE message SET ui_seen = :ui_seen WHERE id = :id")
|
||||
int setMessageUiSeen(long id, boolean ui_seen);
|
||||
|
||||
@Query("UPDATE message SET ui_flagged = :ui_flagged WHERE id = :id")
|
||||
int setMessageUiFlagged(long id, boolean ui_flagged);
|
||||
@Query("UPDATE message SET ui_flagged = :ui_flagged, color = :color WHERE id = :id")
|
||||
int setMessageUiFlagged(long id, boolean ui_flagged, Integer color);
|
||||
|
||||
@Query("UPDATE message SET ui_answered = :ui_answered WHERE id = :id")
|
||||
int setMessageUiAnswered(long id, boolean ui_answered);
|
||||
|
@ -392,9 +392,6 @@ public interface DaoMessage {
|
|||
@Query("UPDATE message SET ui_ignored = :ui_ignored WHERE id = :id")
|
||||
int setMessageUiIgnored(long id, boolean ui_ignored);
|
||||
|
||||
@Query("UPDATE message SET color = :color WHERE id = :id")
|
||||
int setMessageColor(long id, Integer color);
|
||||
|
||||
@Query("UPDATE message SET received = :sent, sent = :sent WHERE id = :id")
|
||||
int setMessageSent(long id, Long sent);
|
||||
|
||||
|
|
|
@ -130,10 +130,8 @@ public class EntityOperation {
|
|||
} else if (FLAG.equals(name)) {
|
||||
boolean flagged = jargs.getBoolean(0);
|
||||
Integer color = (jargs.length() > 1 && !jargs.isNull(1) ? jargs.getInt(1) : null);
|
||||
for (EntityMessage similar : db.message().getMessageByMsgId(message.account, message.msgid)) {
|
||||
db.message().setMessageUiFlagged(similar.id, flagged);
|
||||
db.message().setMessageColor(similar.id, flagged ? color : null);
|
||||
}
|
||||
for (EntityMessage similar : db.message().getMessageByMsgId(message.account, message.msgid))
|
||||
db.message().setMessageUiFlagged(similar.id, flagged, flagged ? color : null);
|
||||
|
||||
} else if (ANSWERED.equals(name))
|
||||
for (EntityMessage similar : db.message().getMessageByMsgId(message.account, message.msgid))
|
||||
|
|
|
@ -51,13 +51,14 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
private Spinner spOnClose;
|
||||
private SwitchCompat swCollapse;
|
||||
private SwitchCompat swAutoRead;
|
||||
private SwitchCompat swAutoUnflag;
|
||||
private SwitchCompat swAutoMove;
|
||||
private SwitchCompat swDiscardDelete;
|
||||
private SwitchCompat swDisableTracking;
|
||||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"pull", "autoscroll", "swipenav", "reversed", "doubletap", "autoexpand", "expand_one", "autoclose", "onclose",
|
||||
"collapse", "autoread", "automove", "discard_delete", "disable_tracking"
|
||||
"collapse", "autoread", "autounflag", "automove", "discard_delete", "disable_tracking"
|
||||
};
|
||||
|
||||
@Override
|
||||
|
@ -81,6 +82,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
spOnClose = view.findViewById(R.id.spOnClose);
|
||||
swCollapse = view.findViewById(R.id.swCollapse);
|
||||
swAutoRead = view.findViewById(R.id.swAutoRead);
|
||||
swAutoUnflag = view.findViewById(R.id.swAutoUnflag);
|
||||
swAutoMove = view.findViewById(R.id.swAutoMove);
|
||||
swDiscardDelete = view.findViewById(R.id.swDiscardDelete);
|
||||
swDisableTracking = view.findViewById(R.id.swDisableTracking);
|
||||
|
@ -179,6 +181,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
}
|
||||
});
|
||||
|
||||
swAutoUnflag.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("autounflag", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swAutoMove.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -267,6 +276,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
|
||||
swCollapse.setChecked(prefs.getBoolean("collapse", false));
|
||||
swAutoRead.setChecked(prefs.getBoolean("autoread", false));
|
||||
swAutoUnflag.setChecked(prefs.getBoolean("autounflag", false));
|
||||
swAutoMove.setChecked(!prefs.getBoolean("automove", false));
|
||||
swDiscardDelete.setChecked(prefs.getBoolean("discard_delete", false));
|
||||
swDisableTracking.setChecked(prefs.getBoolean("disable_tracking", true));
|
||||
|
|
|
@ -184,6 +184,17 @@
|
|||
app:layout_constraintTop_toBottomOf="@id/spOnClose"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoUnflag"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_autounstar"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAutoRead"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swAutoMove"
|
||||
android:layout_width="0dp"
|
||||
|
@ -192,7 +203,7 @@
|
|||
android:text="@string/title_advanced_automove"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAutoRead"
|
||||
app:layout_constraintTop_toBottomOf="@id/swAutoUnflag"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -276,6 +276,7 @@
|
|||
<string name="title_advanced_autoclose">Automatically close conversations</string>
|
||||
<string name="title_advanced_onclose">On closing a conversation</string>
|
||||
<string name="title_advanced_autoread">Automatically mark messages read on moving messages</string>
|
||||
<string name="title_advanced_autounstar">Automatically remove star from messages on moving messages</string>
|
||||
<string name="title_advanced_automove">Confirm moving messages</string>
|
||||
<string name="title_advanced_discard_delete">On discard draft permanently delete draft</string>
|
||||
<string name="title_advanced_tracking">Automatically recognize and disable tracking images</string>
|
||||
|
|
Loading…
Reference in a new issue