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 SwitchCompat swEnglish;
private SwitchCompat swWatchdog;
private SwitchCompat swOptimize;
private SwitchCompat swUpdates;
private SwitchCompat swExperiments;
private TextView tvExperimentsHint;
@ -98,7 +97,7 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
private Group grpDebug;
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"
};
@ -129,7 +128,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
tvFtsPro = view.findViewById(R.id.tvFtsPro);
swEnglish = view.findViewById(R.id.swEnglish);
swWatchdog = view.findViewById(R.id.swWatchdog);
swOptimize = view.findViewById(R.id.swOptimize);
swUpdates = view.findViewById(R.id.swUpdates);
swExperiments = view.findViewById(R.id.swExperiments);
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() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
@ -542,7 +532,6 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc
swFts.setChecked(prefs.getBoolean("fts", false));
swEnglish.setChecked(prefs.getBoolean("english", false));
swWatchdog.setChecked(prefs.getBoolean("watchdog", true));
swOptimize.setChecked(prefs.getBoolean("auto_optimize", false));
swUpdates.setChecked(prefs.getBoolean("updates", true));
swUpdates.setVisibility(
Helper.isPlayStoreInstall() || !Helper.hasValidFingerprint(getContext())

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);

View File

@ -146,30 +146,6 @@
app:layout_constraintTop_toBottomOf="@id/tvEnglishHint"
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
android:id="@+id/swUpdates"
android:layout_width="0dp"
@ -179,7 +155,7 @@
android:text="@string/title_advanced_updates"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvOptimizeHint"
app:layout_constraintTop_toBottomOf="@id/swWatchdog"
app:switchPadding="12dp" />
<androidx.appcompat.widget.SwitchCompat

View File

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

View File

@ -460,7 +460,7 @@
<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_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_experiments">Try experimental features</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_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_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_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>
@ -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_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_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>