Added auto optimize setting

pull/174/head
M66B 6 years ago
parent d0032d2d5d
commit 341701ff3f

@ -55,6 +55,7 @@ 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;
@ -73,7 +74,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[]{
"fts", "english", "watchdog", "updates", "experiments", "crash_reports", "debug" "fts", "english", "watchdog", "auto_optimize", "updates", "experiments", "crash_reports", "debug"
}; };
private final static String[] RESET_QUESTIONS = new String[]{ private final static String[] RESET_QUESTIONS = new String[]{
@ -99,6 +100,7 @@ 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);
@ -185,6 +187,13 @@ 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();
}
});
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) {
@ -360,6 +369,7 @@ 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", true));
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())

@ -828,6 +828,10 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
if (now - start > STILL_THERE_DELAY) if (now - start > STILL_THERE_DELAY)
return; return;
boolean auto_optimize = prefs.getBoolean("auto_optimize", true);
if (!auto_optimize)
return;
int pollInterval = prefs.getInt("poll_interval", 0); int pollInterval = prefs.getInt("poll_interval", 0);
if (pollInterval == 0) { if (pollInterval == 0) {
prefs.edit().putInt("poll_interval", 30).apply(); prefs.edit().putInt("poll_interval", 30).apply();

@ -106,6 +106,18 @@
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" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat
android:id="@+id/swUpdates" android:id="@+id/swUpdates"
android:layout_width="0dp" android:layout_width="0dp"
@ -115,7 +127,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/swWatchdog" app:layout_constraintTop_toBottomOf="@id/swOptimize"
app:switchPadding="12dp" /> app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat <androidx.appcompat.widget.SwitchCompat

@ -409,6 +409,7 @@
<string name="title_advanced_fts_indexed">%1$d / %2$d messages indexed (%3$s)</string> <string name="title_advanced_fts_indexed">%1$d / %2$d messages indexed (%3$s)</string>
<string name="title_advanced_english">Force English language</string> <string name="title_advanced_english">Force English language</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_optimize">Automatically optimize settings</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>

Loading…
Cancel
Save