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

@ -73,7 +73,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private TextView tvFtsPro; private TextView tvFtsPro;
private SwitchCompat swEnglish; private SwitchCompat swEnglish;
private SwitchCompat swWatchdog; private SwitchCompat swWatchdog;
private SwitchCompat swOptimize;
private SwitchCompat swUpdates; private SwitchCompat swUpdates;
private SwitchCompat swExperiments; private SwitchCompat swExperiments;
private TextView tvExperimentsHint; private TextView tvExperimentsHint;
@ -98,7 +97,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private Group grpDebug; private Group grpDebug;
private final static String[] RESET_OPTIONS = new String[]{ private final static String[] RESET_OPTIONS = new String[]{
"shortcuts", "fts", "english", "watchdog", "auto_optimize", "updates", "shortcuts", "fts", "english", "watchdog", "updates",
"experiments", "crash_reports", "debug", "auth_sasl", "cleanup_attachments" "experiments", "crash_reports", "debug", "auth_sasl", "cleanup_attachments"
}; };
@ -129,7 +128,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvFtsPro = view.findViewById(R.id.tvFtsPro); tvFtsPro = view.findViewById(R.id.tvFtsPro);
swEnglish = view.findViewById(R.id.swEnglish); swEnglish = view.findViewById(R.id.swEnglish);
swWatchdog = view.findViewById(R.id.swWatchdog); swWatchdog = view.findViewById(R.id.swWatchdog);
swOptimize = view.findViewById(R.id.swOptimize);
swUpdates = view.findViewById(R.id.swUpdates); swUpdates = view.findViewById(R.id.swUpdates);
swExperiments = view.findViewById(R.id.swExperiments); swExperiments = view.findViewById(R.id.swExperiments);
tvExperimentsHint = view.findViewById(R.id.tvExperimentsHint); tvExperimentsHint = view.findViewById(R.id.tvExperimentsHint);
@ -235,14 +233,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
} }
}); });
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");
}
});
swUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swUpdates.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -542,7 +532,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swFts.setChecked(prefs.getBoolean("fts", false)); swFts.setChecked(prefs.getBoolean("fts", false));
swEnglish.setChecked(prefs.getBoolean("english", false)); swEnglish.setChecked(prefs.getBoolean("english", false));
swWatchdog.setChecked(prefs.getBoolean("watchdog", true)); swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
swOptimize.setChecked(prefs.getBoolean("auto_optimize", false));
swUpdates.setChecked(prefs.getBoolean("updates", true)); swUpdates.setChecked(prefs.getBoolean("updates", true));
swUpdates.setVisibility( swUpdates.setVisibility(
Helper.isPlayStoreInstall() || !Helper.hasValidFingerprint(getContext()) Helper.isPlayStoreInstall() || !Helper.hasValidFingerprint(getContext())

View File

@ -62,6 +62,7 @@ import java.util.Objects;
public class FragmentOptionsSynchronize extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener { public class FragmentOptionsSynchronize extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
private SwitchCompat swEnabled; private SwitchCompat swEnabled;
private Spinner spPollInterval; private Spinner spPollInterval;
private SwitchCompat swOptimize;
private RecyclerView rvExempted; private RecyclerView rvExempted;
private SwitchCompat swSchedule; private SwitchCompat swSchedule;
private TextView tvSchedulePro; private TextView tvSchedulePro;
@ -86,7 +87,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
private AdapterAccountExempted adapter; private AdapterAccountExempted adapter;
private final static String[] RESET_OPTIONS = new String[]{ 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_nodate", "sync_unseen", "sync_flagged", "delete_unseen", "sync_kept", "gmail_thread_id",
"sync_folders", "sync_shared_folders", "subscriptions", "sync_folders", "sync_shared_folders", "subscriptions",
"check_mx", "check_reply", "tune_keep_alive" "check_mx", "check_reply", "tune_keep_alive"
@ -104,6 +105,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
swEnabled = view.findViewById(R.id.swEnabled); swEnabled = view.findViewById(R.id.swEnabled);
spPollInterval = view.findViewById(R.id.spPollInterval); spPollInterval = view.findViewById(R.id.spPollInterval);
swOptimize = view.findViewById(R.id.swOptimize);
swSchedule = view.findViewById(R.id.swSchedule); swSchedule = view.findViewById(R.id.swSchedule);
rvExempted = view.findViewById(R.id.rvExempted); rvExempted = view.findViewById(R.id.rvExempted);
tvSchedulePro = view.findViewById(R.id.tvSchedulePro); 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); rvExempted.setHasFixedSize(false);
LinearLayoutManager llm = new LinearLayoutManager(getContext()); LinearLayoutManager llm = new LinearLayoutManager(getContext());
rvExempted.setLayoutManager(llm); rvExempted.setLayoutManager(llm);
@ -384,6 +394,8 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr
spPollInterval.setSelection(pos); spPollInterval.setSelection(pos);
break; break;
} }
swOptimize.setChecked(prefs.getBoolean("auto_optimize", false));
grpExempted.setVisibility(pollInterval == 0 ? View.GONE : View.VISIBLE); grpExempted.setVisibility(pollInterval == 0 ? View.GONE : View.VISIBLE);
swSchedule.setChecked(prefs.getBoolean("schedule", false) && pro); swSchedule.setChecked(prefs.getBoolean("schedule", false) && pro);

View File

@ -146,30 +146,6 @@
app:layout_constraintTop_toBottomOf="@id/tvEnglishHint" app:layout_constraintTop_toBottomOf="@id/tvEnglishHint"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat
android:id="@+id/swOptimize"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:checked="true"
android:text="@string/title_advanced_optimize"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/swWatchdog"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView
android:id="@+id/tvOptimizeHint"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginEnd="48dp"
android:text="@string/title_advanced_optimize_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/swOptimize" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swUpdates" android:id="@+id/swUpdates"
android:layout_width="0dp" android:layout_width="0dp"
@ -179,7 +155,7 @@
android:text="@string/title_advanced_updates" android:text="@string/title_advanced_updates"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOptimizeHint" app:layout_constraintTop_toBottomOf="@id/swWatchdog"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

View File

@ -99,18 +99,17 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/spPollInterval" /> app:layout_constraintTop_toBottomOf="@id/spPollInterval" />
<eu.faircode.email.FixedTextView <androidx.appcompat.widget.SwitchCompat
android:id="@+id/tvOptimizedHint" android:id="@+id/swOptimize"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginEnd="48dp" android:layout_marginTop="12dp"
android:text="@string/title_advanced_optimized_hint" android:checked="true"
android:textAppearance="@style/TextAppearance.AppCompat.Small" android:text="@string/title_advanced_optimize"
android:textColor="?attr/colorWarning"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvPollHint" /> app:layout_constraintTop_toBottomOf="@id/tvPollHint"
app:switchPadding="12dp" />
<eu.faircode.email.FixedTextView <eu.faircode.email.FixedTextView
android:id="@+id/tvExempted" android:id="@+id/tvExempted"
@ -123,7 +122,7 @@
android:textColor="?android:attr/textColorPrimary" android:textColor="?android:attr/textColorPrimary"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOptimizedHint" /> app:layout_constraintTop_toBottomOf="@id/swOptimize" />
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
android:id="@+id/rvExempted" android:id="@+id/rvExempted"

View File

@ -460,7 +460,7 @@
<string name="title_advanced_english">Use US country settings</string> <string name="title_advanced_english">Use US country settings</string>
<string name="title_advanced_watchdog">Periodically check if FairEmail is still active</string> <string name="title_advanced_watchdog">Periodically check if FairEmail is still active</string>
<string name="title_advanced_auth_sasl" translatable="false">SASL</string> <string name="title_advanced_auth_sasl" translatable="false">SASL</string>
<string name="title_advanced_optimize">Automatically optimize settings</string> <string name="title_advanced_optimize">Automatically optimize</string>
<string name="title_advanced_updates">Check for updates</string> <string name="title_advanced_updates">Check for updates</string>
<string name="title_advanced_experiments">Try experimental features</string> <string name="title_advanced_experiments">Try experimental features</string>
<string name="title_advanced_crash_reports">Send error reports</string> <string name="title_advanced_crash_reports">Send error reports</string>
@ -479,7 +479,6 @@
<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.</string> <string name="title_advanced_manual_hint">If synchronization is disabled, it is still possible to synchronize manually by pulling down the message list.</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 monitoring 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 monitoring for changes only.</string>
<string name="title_advanced_optimized_hint">This option can be optimized automatically (miscellaneous settings)</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_no_date_hint">Some providers store messages with an unknown, invalid or future date as messages without date</string> <string name="title_advanced_no_date_hint">Some providers store messages with an unknown, invalid or future date as messages without date</string>
<string name="title_advanced_unseen_hint">Some providers don\'t support this properly, which may cause synchronizing none or all messages</string> <string name="title_advanced_unseen_hint">Some providers don\'t support this properly, which may cause synchronizing none or all messages</string>
@ -541,7 +540,6 @@
<string name="title_advanced_fts_hint">Enabling this improves search performance, but also increases battery and storage space usage</string> <string name="title_advanced_fts_hint">Enabling this improves search performance, but also increases battery and storage space usage</string>
<string name="title_advanced_english_hint">This will restart the app</string> <string name="title_advanced_english_hint">This will restart the app</string>
<string name="title_advanced_optimize_hint">Enabling this can automatically change the receive settings to reduce battery usage</string>
<string name="title_advanced_experiments_hint">List of current experimental features</string> <string name="title_advanced_experiments_hint">List of current experimental features</string>
<string name="title_advanced_debug_hint">Enable extra logging and show debug information at various places</string> <string name="title_advanced_debug_hint">Enable extra logging and show debug information at various places</string>
<string name="title_advanced_cleanup_attachments_hint">When manually cleaning, this will remove attachments from messages that are no longer synchronized</string> <string name="title_advanced_cleanup_attachments_hint">When manually cleaning, this will remove attachments from messages that are no longer synchronized</string>