Made schedule a pro feature

pull/147/head
M66B 6 years ago
parent 8da3032eef
commit 957a9bd8d7

@ -57,6 +57,7 @@ import androidx.appcompat.widget.SwitchCompat;
import androidx.constraintlayout.widget.Group; import androidx.constraintlayout.widget.Group;
import androidx.fragment.app.DialogFragment; import androidx.fragment.app.DialogFragment;
import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentActivity;
import androidx.fragment.app.FragmentTransaction;
import androidx.lifecycle.Lifecycle; import androidx.lifecycle.Lifecycle;
import static android.app.Activity.RESULT_OK; import static android.app.Activity.RESULT_OK;
@ -190,11 +191,21 @@ public class FragmentOptions extends FragmentBase implements SharedPreferences.O
swSchedule.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { swSchedule.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { public void onCheckedChanged(CompoundButton compoundButton, boolean checked) {
prefs.edit().putBoolean("schedule", checked).apply(); if (checked) {
if (checked) if (Helper.isPro(getContext())) {
ServiceSynchronize.schedule(getContext()); prefs.edit().putBoolean("schedule", true).apply();
else { ServiceSynchronize.schedule(getContext());
prefs.edit().putBoolean("enabled", true).apply(); } else {
swSchedule.setChecked(false);
FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction();
fragmentTransaction.replace(R.id.content_frame, new FragmentPro()).addToBackStack("pro");
fragmentTransaction.commit();
}
} else {
SharedPreferences.Editor editor = prefs.edit();
editor.putBoolean("schedule", false);
editor.putBoolean("enabled", true);
editor.apply();
ServiceSynchronize.reload(getContext(), "schedule=" + checked); ServiceSynchronize.reload(getContext(), "schedule=" + checked);
} }
} }

@ -27,6 +27,9 @@ public class ServiceExternal extends IntentService {
if (intent == null) if (intent == null)
return; return;
if (!Helper.isPro(this))
return;
Boolean enabled = null; Boolean enabled = null;
if (ACTION_ENABLE.equals(intent.getAction())) if (ACTION_ENABLE.equals(intent.getAction()))
enabled = true; enabled = true;

Loading…
Cancel
Save