Moved auto optimize to sync settings

This commit is contained in:
M66B
2020-06-12 19:08:08 +02:00
parent e69f29abda
commit 0912c78430
5 changed files with 24 additions and 50 deletions

View File

@@ -62,6 +62,7 @@ import java.util.Objects;
public class FragmentOptionsSynchronize extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swEnabled;
private Spinner spPollInterval;
private SwitchCompat swOptimize;
private RecyclerView rvExempted;
private SwitchCompat swSchedule;
private TextView tvSchedulePro;
@@ -86,7 +87,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private AdapterAccountExempted adapter;
private final static String[] RESET_OPTIONS = new String[]{
"enabled", "poll_interval", "schedule", "schedule_start", "schedule_end",
"enabled", "poll_interval", "auto_optimize", "schedule", "schedule_start", "schedule_end",
"sync_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "gmail_thread_id",
"sync_folders", "sync_shared_folders", "subscriptions",
"check_mx", "check_reply", "tune_keep_alive"
@@ -104,6 +105,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swEnabled = view.findViewById(R.id.swEnabled);
spPollInterval = view.findViewById(R.id.spPollInterval);
swOptimize = view.findViewById(R.id.swOptimize);
swSchedule = view.findViewById(R.id.swSchedule);
rvExempted = view.findViewById(R.id.rvExempted);
tvSchedulePro = view.findViewById(R.id.tvSchedulePro);
@@ -171,6 +173,14 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
}
});
swOptimize.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("auto_optimize", checked).apply();
ServiceSynchronize.reload(getContext(), null, false, "optimize");
}
});
rvExempted.setHasFixedSize(false);
LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvExempted.setLayoutManager(llm);
@@ -384,6 +394,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
spPollInterval.setSelection(pos);
break;
}
swOptimize.setChecked(prefs.getBoolean("auto_optimize", false));
grpExempted.setVisibility(pollInterval == 0 ? View.GONE : View.VISIBLE);
swSchedule.setChecked(prefs.getBoolean("schedule", false) && pro);