mirror of
https://github.com/M66B/FairEmail.git
synced 2025-01-01 04:35:57 +00:00
Added main enable/disable in advanced settings
This commit is contained in:
parent
74349ed1cf
commit
2fa0d298cf
4 changed files with 31 additions and 2 deletions
|
@ -32,6 +32,7 @@ import androidx.annotation.NonNull;
|
|||
import androidx.annotation.Nullable;
|
||||
|
||||
public class FragmentOptions extends FragmentEx {
|
||||
private CheckBox cbEnabled;
|
||||
private CheckBox cbAvatars;
|
||||
private CheckBox cbLight;
|
||||
private CheckBox cbBrowse;
|
||||
|
@ -45,6 +46,7 @@ public class FragmentOptions extends FragmentEx {
|
|||
View view = inflater.inflate(R.layout.fragment_options, container, false);
|
||||
|
||||
// Get controls
|
||||
cbEnabled = view.findViewById(R.id.cbEnabled);
|
||||
cbAvatars = view.findViewById(R.id.cbAvatars);
|
||||
cbLight = view.findViewById(R.id.cbLight);
|
||||
cbBrowse = view.findViewById(R.id.cbBrowse);
|
||||
|
@ -54,6 +56,15 @@ public class FragmentOptions extends FragmentEx {
|
|||
|
||||
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
|
||||
cbEnabled.setChecked(prefs.getBoolean("enabled", true));
|
||||
cbEnabled.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
|
||||
prefs.edit().putBoolean("enabled", checked).apply();
|
||||
ServiceSynchronize.reload(getContext(), "enabled");
|
||||
}
|
||||
});
|
||||
|
||||
cbAvatars.setChecked(prefs.getBoolean("avatars", true));
|
||||
cbAvatars.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
|
|
|
@ -984,7 +984,7 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
public void onReceive(Context context, Intent intent) {
|
||||
// Receiver runs on main thread
|
||||
// Receiver has a wake lock for ~10 seconds
|
||||
EntityLog.log(context, account.name + " keep alive");
|
||||
EntityLog.log(context, account.name + " keep alive wake lock=" + wl.isHeld());
|
||||
state.thread.interrupt();
|
||||
yieldWakelock();
|
||||
}
|
||||
|
@ -1939,6 +1939,13 @@ public class ServiceSynchronize extends LifecycleService {
|
|||
private void start() {
|
||||
EntityLog.log(ServiceSynchronize.this, "Main start");
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ServiceSynchronize.this);
|
||||
if (!prefs.getBoolean("enabled", true)) {
|
||||
EntityLog.log(ServiceSynchronize.this, "Not enabled, halt");
|
||||
stopSelf();
|
||||
return;
|
||||
}
|
||||
|
||||
state = new ServiceState();
|
||||
state.thread = new Thread(new Runnable() {
|
||||
private List<ServiceState> threadState = new ArrayList<>();
|
||||
|
|
|
@ -11,6 +11,16 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbEnabled"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="12dp"
|
||||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_enabled"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbAvatars"
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -19,7 +29,7 @@
|
|||
android:layout_marginTop="12dp"
|
||||
android:text="@string/title_advanced_avatars"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cbEnabled" />
|
||||
|
||||
<CheckBox
|
||||
android:id="@+id/cbLight"
|
||||
|
|
|
@ -79,6 +79,7 @@
|
|||
<string name="title_setup_dark_theme">Dark theme</string>
|
||||
|
||||
<string name="title_advanced">Advanced options</string>
|
||||
<string name="title_advanced_enabled">Enabled</string>
|
||||
<string name="title_advanced_avatars">Show contact photos</string>
|
||||
<string name="title_advanced_light">Use notification light</string>
|
||||
<string name="title_advanced_browse">Browse messages on the server</string>
|
||||
|
|
Loading…
Reference in a new issue