mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 03:19:24 +01:00
Added option to auto go to next
This commit is contained in:
@@ -42,7 +42,7 @@ abstract class ActivityBase extends AppCompatActivity implements SharedPreferenc
|
||||
|
||||
private static String[] restart = new String[]{
|
||||
"unified", "threading", "compact", "avatars", "identicons", "preview", "addresses",
|
||||
"pull", "actionbar", "autoclose", "confirm", "debug"
|
||||
"pull", "actionbar", "autoclose", "autonext", "confirm", "debug"
|
||||
};
|
||||
|
||||
@Override
|
||||
|
||||
@@ -117,6 +117,7 @@ public class FragmentMessages extends FragmentEx {
|
||||
private boolean pull;
|
||||
private boolean actionbar;
|
||||
private boolean autoclose;
|
||||
private boolean autonext;
|
||||
private boolean addresses;
|
||||
|
||||
private long primary = -1;
|
||||
@@ -179,6 +180,7 @@ public class FragmentMessages extends FragmentEx {
|
||||
threading = prefs.getBoolean("threading", true);
|
||||
actionbar = prefs.getBoolean("actionbar", true);
|
||||
autoclose = prefs.getBoolean("autoclose", true);
|
||||
autonext = prefs.getBoolean("autonext", false);
|
||||
addresses = prefs.getBoolean("addresses", true);
|
||||
}
|
||||
|
||||
@@ -1860,8 +1862,9 @@ public class FragmentMessages extends FragmentEx {
|
||||
@Override
|
||||
public void onChanged(@Nullable PagedList<TupleMessageEx> messages) {
|
||||
if (messages == null ||
|
||||
(viewType == AdapterMessage.ViewType.THREAD && messages.size() == 0 && autoclose)) {
|
||||
finish();
|
||||
(viewType == AdapterMessage.ViewType.THREAD && messages.size() == 0 &&
|
||||
(autoclose || autonext))) {
|
||||
autoCloseNext();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1921,7 +1924,7 @@ public class FragmentMessages extends FragmentEx {
|
||||
handleExpand(expand.id);
|
||||
}
|
||||
} else {
|
||||
if (autoCloseCount > 0 && autoclose) {
|
||||
if (autoCloseCount > 0 && (autoclose || autonext)) {
|
||||
int count = 0;
|
||||
for (int i = 0; i < messages.size(); i++) {
|
||||
TupleMessageEx message = messages.get(i);
|
||||
@@ -1933,11 +1936,11 @@ public class FragmentMessages extends FragmentEx {
|
||||
}
|
||||
Log.i("Auto close=" + count);
|
||||
|
||||
// Auto close when:
|
||||
// Auto close/next when:
|
||||
// - no more non archived/trashed/sent messages
|
||||
|
||||
if (count == 0) {
|
||||
finish();
|
||||
autoCloseNext();
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -2025,6 +2028,25 @@ public class FragmentMessages extends FragmentEx {
|
||||
});
|
||||
}
|
||||
|
||||
private void autoCloseNext() {
|
||||
if (autoclose)
|
||||
finish();
|
||||
else if (autonext) {
|
||||
ViewModelMessages model = ViewModelProviders.of(getActivity()).get(ViewModelMessages.class);
|
||||
ViewModelMessages.Target[] pn = model.getPrevNext(thread);
|
||||
if (pn[1] == null)
|
||||
finish();
|
||||
else {
|
||||
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
|
||||
lbm.sendBroadcast(
|
||||
new Intent(ActivityView.ACTION_VIEW_THREAD)
|
||||
.putExtra("account", pn[1].account)
|
||||
.putExtra("thread", pn[1].thread)
|
||||
.putExtra("id", pn[1].id));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void handleExpand(long id) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", id);
|
||||
|
||||
@@ -70,6 +70,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||
private SwitchCompat swSwipe;
|
||||
private SwitchCompat swActionbar;
|
||||
private SwitchCompat swAutoClose;
|
||||
private SwitchCompat swAutoNext;
|
||||
private SwitchCompat swAutoRead;
|
||||
private SwitchCompat swCollapse;
|
||||
private SwitchCompat swAutoMove;
|
||||
@@ -111,6 +112,7 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||
swSwipe = view.findViewById(R.id.swSwipe);
|
||||
swActionbar = view.findViewById(R.id.swActionbar);
|
||||
swAutoClose = view.findViewById(R.id.swAutoClose);
|
||||
swAutoNext = view.findViewById(R.id.swAutoNext);
|
||||
swAutoRead = view.findViewById(R.id.swAutoRead);
|
||||
swCollapse = view.findViewById(R.id.swCollapse);
|
||||
swAutoMove = view.findViewById(R.id.swAutoMove);
|
||||
@@ -293,9 +295,19 @@ public class FragmentOptions extends FragmentEx implements SharedPreferences.OnS
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("autoclose", checked).apply();
|
||||
swAutoNext.setEnabled(!checked);
|
||||
}
|
||||
});
|
||||
|
||||
swAutoNext.setChecked(prefs.getBoolean("autonext", false));
|
||||
swAutoNext.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("autonext", checked).apply();
|
||||
}
|
||||
});
|
||||
swAutoNext.setEnabled(!swAutoClose.isChecked());
|
||||
|
||||
swAutoRead.setChecked(prefs.getBoolean("autoread", false));
|
||||
swAutoRead.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user