Added setting to disable folder list sync

This commit is contained in:
M66B 2019-06-08 16:33:25 +02:00
parent 78162151f6
commit 0c3f4d1e39
4 changed files with 51 additions and 6 deletions

View File

@ -782,8 +782,7 @@ class Core {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean subscribed_only = prefs.getBoolean("subscribed_only", false);
Log.i("Start sync folders account=" + account.name);
boolean sync_folders = prefs.getBoolean("sync_folders", true);
// Get folder names
List<String> names = new ArrayList<>();
@ -795,16 +794,26 @@ class Core {
ifolder.create(Folder.HOLDS_MESSAGES);
db.folder().resetFolderTbc(folder.id);
names.add(folder.name);
sync_folders = true;
} else if (folder.tbd != null && folder.tbd) {
Log.i(folder.name + " deleting");
Folder ifolder = istore.getFolder(folder.name);
if (ifolder.exists())
ifolder.delete(false);
db.folder().deleteFolder(folder.id);
} else
sync_folders = true;
} else {
names.add(folder.name);
if (folder.initialize)
sync_folders = true;
}
Log.i("Local folder count=" + names.size());
if (!sync_folders)
return;
Log.i("Start sync folders account=" + account.name);
// Get default folder
Folder defaultFolder = istore.getDefaultFolder();
char separator = defaultFolder.getSeparator();

View File

@ -57,9 +57,10 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private SwitchCompat swUnseen;
private SwitchCompat swFlagged;
private SwitchCompat swSyncKept;
private SwitchCompat swSyncFolders;
private final static String[] RESET_OPTIONS = new String[]{
"enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", "sync_unseen", "sync_flagged", "sync_kept"
"enabled", "poll_interval", "schedule", "schedule_start", "schedule_end", "sync_unseen", "sync_flagged", "sync_kept", "sync_folders"
};
@Override
@ -80,6 +81,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swUnseen = view.findViewById(R.id.swUnseen);
swFlagged = view.findViewById(R.id.swFlagged);
swSyncKept = view.findViewById(R.id.swSyncKept);
swSyncFolders = view.findViewById(R.id.swSyncFolders);
setOptions();
@ -184,6 +186,13 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
}
});
swSyncFolders.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("sync_folders", checked).apply();
}
});
PreferenceManager.getDefaultSharedPreferences(getContext()).registerOnSharedPreferenceChangeListener(this);
return view;
@ -247,6 +256,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swUnseen.setChecked(prefs.getBoolean("sync_unseen", false));
swFlagged.setChecked(prefs.getBoolean("sync_flagged", true));
swSyncKept.setChecked(prefs.getBoolean("sync_kept", false));
swSyncFolders.setChecked(prefs.getBoolean("sync_folders", true));
}
private String formatHour(Context context, int minutes) {

View File

@ -158,7 +158,7 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:checked="false"
android:text="@string/title_advanced_unseen"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSchedulePro"
@ -197,6 +197,29 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swSyncKept" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swSyncFolders"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_sync_folders"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvSyncKept"
app:switchPadding="12dp" />
<TextView
android:id="@+id/tvSyncFolders"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_sync_folders_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/swSyncFolders" />
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -168,6 +168,7 @@
<string name="title_advanced_unseen">All unread 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_sync_folders">Synchronize folder list</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>
@ -236,8 +237,10 @@
<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_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 transfer extra data and use 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_sync_kept_hint">This will transfer extra data and use extra battery power, especially if there are a lot of messages kept on the device</string>
<string name="title_advanced_sync_folders_hint">Disabling this will reduce data and battery usage somewhat, but will disable updating the list of folders too</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_rlah_hint">Assuming no roaming within the EU</string>