diff --git a/app/src/main/java/eu/faircode/email/ApplicationEx.java b/app/src/main/java/eu/faircode/email/ApplicationEx.java
index 0cf4feaf0a..207817fab4 100644
--- a/app/src/main/java/eu/faircode/email/ApplicationEx.java
+++ b/app/src/main/java/eu/faircode/email/ApplicationEx.java
@@ -260,12 +260,12 @@ public class ApplicationEx extends Application {
static void upgrade(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
+ int version = prefs.getInt("version", BuildConfig.VERSION_CODE);
+ Log.i("Upgrading from " + version + " to " + BuildConfig.VERSION_CODE);
+
SharedPreferences.Editor editor = prefs.edit();
- int version = prefs.getInt("version", BuildConfig.VERSION_CODE);
if (version < 468) {
- Log.i("Upgrading from " + version + " to " + BuildConfig.VERSION_CODE);
-
editor.remove("notify_trash");
editor.remove("notify_archive");
editor.remove("notify_reply");
@@ -273,12 +273,16 @@ public class ApplicationEx extends Application {
editor.remove("notify_seen");
} else if (version < 601) {
- Log.i("Upgrading from " + version + " to " + BuildConfig.VERSION_CODE);
-
editor.putBoolean("contact_images", prefs.getBoolean("autoimages", true));
editor.remove("autoimages");
+
+ } else if (version < 612) {
+ if (prefs.getBoolean("autonext", false))
+ editor.putString("onclose", "next");
+ editor.remove("autonext");
}
+
if (BuildConfig.DEBUG && false) {
editor.remove("app_support");
editor.remove("notify_archive");
diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java
index 474d65134b..a6c9e70ac5 100644
--- a/app/src/main/java/eu/faircode/email/FragmentMessages.java
+++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java
@@ -199,7 +199,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private boolean actionbar;
private boolean autoexpand;
private boolean autoclose;
- private boolean autonext;
+ private String onclose;
private boolean addresses;
private int colorPrimary;
@@ -224,7 +224,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private Long previous = null;
private Long next = null;
- private Long closeNext = null;
+ private Long closeId = null;
private int autoCloseCount = 0;
private boolean autoExpanded = true;
private Map> values = new HashMap<>();
@@ -317,7 +317,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
actionbar = prefs.getBoolean("actionbar", true);
autoexpand = prefs.getBoolean("autoexpand", true);
autoclose = prefs.getBoolean("autoclose", true);
- autonext = (!autoclose && prefs.getBoolean("autonext", false));
+ onclose = (autoclose ? null : prefs.getString("onclose", null));
addresses = prefs.getBoolean("addresses", false);
colorPrimary = Helper.resolveColor(getContext(), R.attr.colorPrimary);
@@ -2684,31 +2684,36 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
private void loadMessages(final boolean top) {
- if (viewType == AdapterMessage.ViewType.THREAD && autonext) {
+ if (viewType == AdapterMessage.ViewType.THREAD && onclose != null) {
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
model.observePrevNext(getViewLifecycleOwner(), id, new ViewModelMessages.IPrevNext() {
boolean once = false;
@Override
public void onPrevious(boolean exists, Long id) {
- // Do nothing
+ onData(false, exists, id);
}
@Override
public void onNext(boolean exists, Long id) {
- if (!exists || id != null) {
- closeNext = id;
- if (!once) {
- once = true;
- loadMessagesNext(top);
- }
- }
+ onData(true, exists, id);
}
@Override
public void onFound(int position, int size) {
// Do nothing
}
+
+ private void onData(boolean next, boolean exists, Long id) {
+ if ((next ? "next" : "previous").equals(onclose))
+ if (!exists || id != null) {
+ closeId = id;
+ if (!once) {
+ once = true;
+ loadMessagesNext(top);
+ }
+ }
+ }
});
} else if (viewType == AdapterMessage.ViewType.SEARCH && !reset) {
new SimpleTask() {
@@ -2825,7 +2830,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private boolean handleThreadActions(@NonNull PagedList messages) {
// Auto close / next
- if (messages.size() == 0 && (autoclose || autonext)) {
+ if (messages.size() == 0 && (autoclose || onclose != null)) {
handleAutoClose();
return true;
}
@@ -2912,7 +2917,7 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
}
}
} else {
- if (autoCloseCount > 0 && (autoclose || autonext)) {
+ if (autoCloseCount > 0 && (autoclose || onclose != null)) {
int count = 0;
for (int i = 0; i < messages.size(); i++) {
TupleMessageEx message = messages.get(i);
@@ -3058,12 +3063,12 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
private void handleAutoClose() {
if (autoclose)
finish();
- else if (autonext) {
- if (closeNext == null)
+ else if (onclose != null) {
+ if (closeId == null)
finish();
else {
- Log.i("Navigating to last next=" + closeNext);
- navigate(closeNext, false);
+ Log.i("Navigating to id=" + closeId);
+ navigate(closeId, false);
}
}
}
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptions.java b/app/src/main/java/eu/faircode/email/FragmentOptions.java
index ecde3c6f84..5c90424f41 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptions.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptions.java
@@ -40,7 +40,7 @@ public class FragmentOptions extends FragmentBase {
static String[] OPTIONS_RESTART = new String[]{
"startup", "date", "threading", "avatars", "generated_icons", "identicons", "circular", "name_email", "subject_italic", "flags", "preview",
"addresses", "attachments_alt", "contrast", "monospaced", "inline_images", "contact_images", "all_images", "collapse_quotes", "autocontent", "actionbar",
- "autoscroll", "swipenav", "autoexpand", "autoclose", "autonext",
+ "autoscroll", "swipenav", "autoexpand", "autoclose", "onclose",
"subscriptions", "debug",
"biometrics"
};
diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java
index cc98a77149..f1d53038f3 100644
--- a/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java
+++ b/app/src/main/java/eu/faircode/email/FragmentOptionsBehavior.java
@@ -21,13 +21,16 @@ package eu.faircode.email;
import android.content.SharedPreferences;
import android.os.Bundle;
+import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
+import android.widget.AdapterView;
import android.widget.CompoundButton;
+import android.widget.Spinner;
import android.widget.Toast;
import androidx.annotation.NonNull;
@@ -42,7 +45,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
private SwitchCompat swDoubleTap;
private SwitchCompat swAutoExpand;
private SwitchCompat swAutoClose;
- private SwitchCompat swAutoNext;
+ private Spinner spOnClose;
private SwitchCompat swCollapse;
private SwitchCompat swAutoRead;
private SwitchCompat swAutoMove;
@@ -50,7 +53,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", "autonext",
+ "pull", "autoscroll", "swipenav", "doubletap", "autoexpand", "autoclose", "onclose",
"collapse", "autoread", "automove", "authentication", "disable_tracking"
};
@@ -70,7 +73,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swDoubleTap = view.findViewById(R.id.swDoubleTap);
swAutoExpand = view.findViewById(R.id.swAutoExpand);
swAutoClose = view.findViewById(R.id.swAutoClose);
- swAutoNext = view.findViewById(R.id.swAutoNext);
+ spOnClose = view.findViewById(R.id.spOnClose);
swCollapse = view.findViewById(R.id.swCollapse);
swAutoRead = view.findViewById(R.id.swAutoRead);
swAutoMove = view.findViewById(R.id.swAutoMove);
@@ -122,14 +125,24 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("autoclose", checked).apply();
- swAutoNext.setEnabled(!checked);
+ spOnClose.setEnabled(!checked);
}
});
- swAutoNext.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
+ spOnClose.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
@Override
- public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
- prefs.edit().putBoolean("autonext", checked).apply();
+ public void onItemSelected(AdapterView> adapterView, View view, int position, long id) {
+ String[] values = getResources().getStringArray(R.array.onCloseValues);
+ String value = values[position];
+ if (TextUtils.isEmpty(value))
+ prefs.edit().remove("onclose").apply();
+ else
+ prefs.edit().putString("onclose", value).apply();
+ }
+
+ @Override
+ public void onNothingSelected(AdapterView> parent) {
+ prefs.edit().remove("onclose").apply();
}
});
@@ -219,8 +232,17 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
swDoubleTap.setChecked(prefs.getBoolean("doubletap", false));
swAutoExpand.setChecked(prefs.getBoolean("autoexpand", true));
swAutoClose.setChecked(prefs.getBoolean("autoclose", true));
- swAutoNext.setChecked(prefs.getBoolean("autonext", false));
- swAutoNext.setEnabled(!swAutoClose.isChecked());
+
+ String onClose = prefs.getString("onclose", "");
+ String[] onCloseValues = getResources().getStringArray(R.array.onCloseValues);
+ for (int pos = 0; pos < onCloseValues.length; pos++)
+ if (onCloseValues[pos].equals(onClose)) {
+ spOnClose.setSelection(pos);
+ break;
+ }
+
+ spOnClose.setEnabled(!swAutoClose.isChecked());
+
swCollapse.setChecked(prefs.getBoolean("collapse", false));
swAutoRead.setChecked(prefs.getBoolean("autoread", false));
swAutoMove.setChecked(!prefs.getBoolean("automove", false));
diff --git a/app/src/main/res/layout/fragment_options_behavior.xml b/app/src/main/res/layout/fragment_options_behavior.xml
index 74de4c67e7..96469f0189 100644
--- a/app/src/main/res/layout/fragment_options_behavior.xml
+++ b/app/src/main/res/layout/fragment_options_behavior.xml
@@ -135,17 +135,27 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swAutoClose" />
-
+ app:layout_constraintTop_toBottomOf="@id/tvAutoCloseHint" />
+
+
Automatically expand messages
Collapse messages in conversations on \'back\'
Automatically close conversations
- Automatically go to next conversation on close conversation
+ On closing a conversation
Automatically mark messages read on moving messages
Confirm moving messages
Show a warning when the receiving server could not authenticate the message
@@ -865,6 +865,18 @@
- 0
+
+ - Do nothing
+ - Go to previous conversation
+ - Go to next conversation
+
+
+
+
+ - previous
+ - next
+
+
- Small
- Medium