mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 17:57:16 +00:00
Added option for sync on launch
This commit is contained in:
parent
8e8c002b8e
commit
bb0c845232
4 changed files with 29 additions and 4 deletions
|
@ -49,6 +49,7 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
|
|||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
|
||||
boolean eula = prefs.getBoolean("eula", false);
|
||||
boolean sync_on_launch = prefs.getBoolean("sync_on_launch", false);
|
||||
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
|
||||
|
@ -91,9 +92,11 @@ public class ActivityMain extends ActivityBase implements FragmentManager.OnBack
|
|||
view.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
Intent saved = args.getParcelable("intent");
|
||||
if (saved == null)
|
||||
if (saved == null) {
|
||||
startActivity(view);
|
||||
else
|
||||
if (sync_on_launch)
|
||||
ServiceUI.sync(ActivityMain.this, null);
|
||||
} else
|
||||
try {
|
||||
startActivity(saved);
|
||||
} catch (SecurityException ex) {
|
||||
|
|
|
@ -54,6 +54,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
public class FragmentOptionsBehavior extends FragmentBase implements SharedPreferences.OnSharedPreferenceChangeListener {
|
||||
private SwitchCompat swSyncOnlaunch;
|
||||
private SwitchCompat swDoubleBack;
|
||||
private SwitchCompat swConversationActions;
|
||||
private SwitchCompat swConversationActionsReplies;
|
||||
|
@ -85,7 +86,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
private Group grpConversationActions;
|
||||
|
||||
private final static String[] RESET_OPTIONS = new String[]{
|
||||
"double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
|
||||
"sync_on_launch", "double_back", "conversation_actions", "conversation_actions_replies", "language_detection",
|
||||
"default_snooze",
|
||||
"pull", "autoscroll", "quick_filter", "quick_scroll",
|
||||
"doubletap", "swipenav", "volumenav", "reversed", "swipe_close", "swipe_move",
|
||||
|
@ -104,6 +105,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
|
||||
// Get controls
|
||||
|
||||
swSyncOnlaunch = view.findViewById(R.id.swSyncOnlaunch);
|
||||
swDoubleBack = view.findViewById(R.id.swDoubleBack);
|
||||
swConversationActions = view.findViewById(R.id.swConversationActions);
|
||||
swConversationActionsReplies = view.findViewById(R.id.swConversationActionsReplies);
|
||||
|
@ -147,6 +149,13 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
}
|
||||
});
|
||||
|
||||
swSyncOnlaunch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("sync_on_launch", checked).apply();
|
||||
}
|
||||
});
|
||||
|
||||
swConversationActions.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
|
@ -425,6 +434,7 @@ public class FragmentOptionsBehavior extends FragmentBase implements SharedPrefe
|
|||
private void setOptions() {
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
swSyncOnlaunch.setChecked(prefs.getBoolean("sync_on_launch", false));
|
||||
swDoubleBack.setChecked(prefs.getBoolean("double_back", true));
|
||||
swConversationActions.setChecked(prefs.getBoolean("conversation_actions", true));
|
||||
swConversationActionsReplies.setChecked(prefs.getBoolean("conversation_actions_replies", true));
|
||||
|
|
|
@ -29,6 +29,17 @@
|
|||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swSyncOnlaunch"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_sync_on_launch"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCaptionGeneral"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
android:id="@+id/swDoubleBack"
|
||||
android:layout_width="0dp"
|
||||
|
@ -38,7 +49,7 @@
|
|||
android:text="@string/title_advanced_double_back"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toBottomOf="@id/tvCaptionGeneral"
|
||||
app:layout_constraintTop_toBottomOf="@id/swSyncOnlaunch"
|
||||
app:switchPadding="12dp" />
|
||||
|
||||
<androidx.appcompat.widget.SwitchCompat
|
||||
|
|
|
@ -410,6 +410,7 @@
|
|||
<string name="title_advanced_parse_classes">Parse style sheets</string>
|
||||
<string name="title_advanced_authentication">Show a warning when the receiving server could not authenticate the message</string>
|
||||
|
||||
<string name="title_advanced_sync_on_launch">Synchronize on start</string>
|
||||
<string name="title_advanced_double_back">Double \'back\' to exit</string>
|
||||
<string name="title_advanced_pull_refresh">Pull down to refresh</string>
|
||||
<string name="title_advanced_autoscroll">Scroll to top on receiving new messages</string>
|
||||
|
|
Loading…
Reference in a new issue