Added settings to enable sync kept removed

pull/156/head
M66B 6 years ago
parent ef9f68d222
commit 5ed2a43633

@ -941,9 +941,10 @@ class Core {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean sync_unseen = prefs.getBoolean("sync_unseen", false); boolean sync_unseen = prefs.getBoolean("sync_unseen", false);
boolean sync_flagged = prefs.getBoolean("sync_flagged", true); boolean sync_flagged = prefs.getBoolean("sync_flagged", true);
boolean sync_kept = prefs.getBoolean("sync_kept", false);
Log.i(folder.name + " start sync after=" + sync_days + "/" + keep_days + Log.i(folder.name + " start sync after=" + sync_days + "/" + keep_days +
" unseen=" + sync_unseen + " sync_flagged=" + sync_flagged); "sync unseen=" + sync_unseen + " flagged=" + sync_flagged + " kept=" + sync_kept);
db.folder().setFolderSyncState(folder.id, "syncing"); db.folder().setFolderSyncState(folder.id, "syncing");
@ -987,7 +988,7 @@ class Core {
} }
// Get list of local uids // Get list of local uids
final List<Long> uids = db.message().getUids(folder.id, null); final List<Long> uids = db.message().getUids(folder.id, sync_kept ? null : sync_time);
Log.i(folder.name + " local count=" + uids.size()); Log.i(folder.name + " local count=" + uids.size());
// Reduce list of local uids // Reduce list of local uids

@ -56,9 +56,10 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private TextView tvScheduleEnd; private TextView tvScheduleEnd;
private SwitchCompat swUnseen; private SwitchCompat swUnseen;
private SwitchCompat swFlagged; private SwitchCompat swFlagged;
private SwitchCompat swSyncKept;
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", "sync_unseen", "sync_flagged" "enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", "sync_unseen", "sync_flagged", "sync_kept"
}; };
@Override @Override
@ -78,6 +79,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
tvScheduleEnd = view.findViewById(R.id.tvScheduleEnd); tvScheduleEnd = view.findViewById(R.id.tvScheduleEnd);
swUnseen = view.findViewById(R.id.swUnseen); swUnseen = view.findViewById(R.id.swUnseen);
swFlagged = view.findViewById(R.id.swFlagged); swFlagged = view.findViewById(R.id.swFlagged);
swSyncKept = view.findViewById(R.id.swSyncKept);
setOptions(); setOptions();
@ -174,6 +176,14 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
} }
}); });
swSyncKept.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("sync_kept", checked).apply();
ServiceSynchronize.reload(getContext(), false, "sync_kept=" + checked);
}
});
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this); PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view; return view;
@ -236,6 +246,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swUnseen.setChecked(prefs.getBoolean("sync_unseen", false)); swUnseen.setChecked(prefs.getBoolean("sync_unseen", false));
swFlagged.setChecked(prefs.getBoolean("sync_flagged", true)); swFlagged.setChecked(prefs.getBoolean("sync_flagged", true));
swSyncKept.setChecked(prefs.getBoolean("sync_kept", false));
} }
private String formatHour(Context context, int minutes) { private String formatHour(Context context, int minutes) {

@ -174,6 +174,29 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swUnseen" app:layout_constraintTop_toBottomOf="@id/swUnseen"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSyncKept"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="false"
android:text="@string/title_advanced_kept_removed"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swFlagged"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvSyncKept"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_sync_kept_hint"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSyncKept" />
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView> </ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout> </androidx.constraintlayout.widget.ConstraintLayout>

@ -167,6 +167,7 @@
<string name="title_advanced_schedule">Schedule</string> <string name="title_advanced_schedule">Schedule</string>
<string name="title_advanced_unseen">All unread messages</string> <string name="title_advanced_unseen">All unread messages</string>
<string name="title_advanced_flagged">All starred messages</string> <string name="title_advanced_flagged">All starred messages</string>
<string name="title_advanced_kept_removed">Check if old messages were removed from the server</string>
<string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string> <string name="title_advanced_prefix_once">Prefix subject only once on replying or forwarding</string>
<string name="title_advanced_autoresize">Automatically resize attached and embedded images</string> <string name="title_advanced_autoresize">Automatically resize attached and embedded images</string>
@ -235,6 +236,7 @@
<string name="title_advanced_enabled_hint">Globally disable or enable receiving of messages</string> <string name="title_advanced_enabled_hint">Globally disable or enable receiving of messages</string>
<string name="title_advanced_manual_hint">If synchronization is disabled, it is still possible to synchronize manually by pulling down the message list. This will synchronize messages and execute operations for a limited time.</string> <string name="title_advanced_manual_hint">If synchronization is disabled, it is still possible to synchronize manually by pulling down the message list. This will synchronize messages and execute operations for a limited time.</string>
<string name="title_advanced_poll_hint">Synchronizing periodically will compare local and remote messages each and every time, which is an expensive operation possibly resulting in extra battery usage, especially when there are a lot of messages to synchronize. Always synchronizing will avoid this by continuous listening for changes only.</string> <string name="title_advanced_poll_hint">Synchronizing periodically will compare local and remote messages each and every time, which is an expensive operation possibly resulting in extra battery usage, especially when there are a lot of messages to synchronize. Always synchronizing will avoid this by continuous listening for changes only.</string>
<string name="title_advanced_sync_kept_hint">This will use extra data and extra battery power, especially if there are a lot of messages kept on the device</string>
<string name="title_advanced_schedule_hint">Tap on a time to set a time</string> <string name="title_advanced_schedule_hint">Tap on a time to set a time</string>
<string name="title_advanced_metered_hint">Metered connections are generally mobile connections or paid Wi-Fi hotspots</string> <string name="title_advanced_metered_hint">Metered connections are generally mobile connections or paid Wi-Fi hotspots</string>
<string name="title_advanced_metered_warning">Disabling this option will disable receiving and sending messages on mobile internet connections</string> <string name="title_advanced_metered_warning">Disabling this option will disable receiving and sending messages on mobile internet connections</string>

Loading…
Cancel
Save