Added experimental option to use background service

This commit is contained in:
M66B
2020-05-27 09:22:30 +02:00
parent 3e82280408
commit 0ee7e036fe
4 changed files with 87 additions and 21 deletions

View File

@@ -52,6 +52,8 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
private Button btnManage;
private Button btnManageDefault;
private Button btnManageService;
private SwitchCompat swBackground;
private CheckBox cbNotifyActionTrash;
private CheckBox cbNotifyActionJunk;
private CheckBox cbNotifyActionBlockSender;
@@ -106,6 +108,8 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
btnManage = view.findViewById(R.id.btnManage);
btnManageDefault = view.findViewById(R.id.btnManageDefault);
btnManageService = view.findViewById(R.id.btnManageService);
swBackground = view.findViewById(R.id.swBackground);
cbNotifyActionTrash = view.findViewById(R.id.cbNotifyActionTrash);
cbNotifyActionJunk = view.findViewById(R.id.cbNotifyActionJunk);
cbNotifyActionBlockSender = view.findViewById(R.id.cbNotifyActionBlockSender);
@@ -180,6 +184,14 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
}
});
swBackground.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("background_service", checked).apply();
ServiceSynchronize.eval(getContext(), "background=" + checked);
}
});
cbNotifyActionTrash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean checked) {
@@ -406,6 +418,8 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
boolean pro = ActivityBilling.isPro(getContext());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swBackground.setChecked(prefs.getBoolean("background_service", false));
cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true) || !pro);
cbNotifyActionJunk.setChecked(prefs.getBoolean("notify_junk", false) && pro);
cbNotifyActionBlockSender.setChecked(prefs.getBoolean("notify_block_sender", false) && pro);