diff --git a/app/src/main/java/eu/faircode/email/AdapterAccount.java b/app/src/main/java/eu/faircode/email/AdapterAccount.java index 0f8d12e869..6d4b8a07e2 100644 --- a/app/src/main/java/eu/faircode/email/AdapterAccount.java +++ b/app/src/main/java/eu/faircode/email/AdapterAccount.java @@ -120,6 +120,7 @@ public class AdapterAccount extends RecyclerView.Adapter 0 ? R.drawable.baseline_star_24 : R.drawable.baseline_star_border_24); ivFlagged.setImageTintList(ColorStateList.valueOf(flagged > 0 - ? message.color == null ? colorAccent : message.color - : textColorSecondary)); + ? message.color == null || !Helper.isPro(context) + ? colorAccent : message.color : textColorSecondary)); ivFlagged.setVisibility(flags ? (message.uid == null ? View.INVISIBLE : View.VISIBLE) : View.GONE); } diff --git a/app/src/main/java/eu/faircode/email/Core.java b/app/src/main/java/eu/faircode/email/Core.java index 8d7213a9c0..3f27eb2581 100644 --- a/app/src/main/java/eu/faircode/email/Core.java +++ b/app/src/main/java/eu/faircode/email/Core.java @@ -1838,11 +1838,11 @@ class Core { SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); boolean flags = prefs.getBoolean("flags", true); boolean notify_preview = prefs.getBoolean("notify_preview", true); - boolean notify_trash = prefs.getBoolean("notify_trash", true); - boolean notify_archive = prefs.getBoolean("notify_archive", true); - boolean notify_reply = prefs.getBoolean("notify_reply", false) && pro; - boolean notify_flag = prefs.getBoolean("notify_flag", false) && pro; - boolean notify_seen = prefs.getBoolean("notify_seen", true); + boolean notify_trash = (prefs.getBoolean("notify_trash", true) || !pro); + boolean notify_archive = (prefs.getBoolean("notify_archive", true) || !pro); + boolean notify_reply = (prefs.getBoolean("notify_reply", false) && pro); + boolean notify_flag = (prefs.getBoolean("notify_flag", false) && pro); + boolean notify_seen = (prefs.getBoolean("notify_seen", true) || !pro); // Get contact info Map messageContact = new HashMap<>(); diff --git a/app/src/main/java/eu/faircode/email/FragmentAccount.java b/app/src/main/java/eu/faircode/email/FragmentAccount.java index 628ee28287..e47ef7e338 100644 --- a/app/src/main/java/eu/faircode/email/FragmentAccount.java +++ b/app/src/main/java/eu/faircode/email/FragmentAccount.java @@ -334,18 +334,6 @@ public class FragmentAccount extends FragmentBase { } }); - cbNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { - @Override - public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { - if (isChecked && !Helper.isPro(getContext())) { - cbNotify.setChecked(false); - - LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); - lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO)); - } - } - }); - if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) { Helper.hide(cbNotify); Helper.hide(view.findViewById(R.id.tvNotifyPro)); @@ -755,6 +743,7 @@ public class FragmentAccount extends FragmentBase { EntityFolder left = (EntityFolder) args.getSerializable("left"); EntityFolder right = (EntityFolder) args.getSerializable("right"); + boolean pro = Helper.isPro(context); boolean should = args.getBoolean("should"); if (!should && TextUtils.isEmpty(host)) @@ -772,8 +761,10 @@ public class FragmentAccount extends FragmentBase { realm = null; if (TextUtils.isEmpty(name)) name = user; - if (Color.TRANSPARENT == color) + if (color == Color.TRANSPARENT || !pro) color = null; + if (!pro) + notify = false; long now = new Date().getTime(); @@ -932,11 +923,6 @@ public class FragmentAccount extends FragmentBase { if (account.primary) db.account().resetPrimary(); - if (!Helper.isPro(context)) { - account.color = null; - account.notify = false; - } - if (update) db.account().updateAccount(account); else @@ -1165,7 +1151,10 @@ public class FragmentAccount extends FragmentBase { etRealm.setText(account == null ? null : account.realm); etName.setText(account == null ? null : account.name); - cbNotify.setChecked(account != null && account.notify && Helper.isPro(getContext())); + + boolean pro = Helper.isPro(getContext()); + cbNotify.setChecked(account != null && account.notify && pro); + cbNotify.setEnabled(pro); cbSynchronize.setChecked(account == null ? true : account.synchronize); cbPrimary.setChecked(account == null ? false : account.primary); diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index d0e004befd..eb372374c9 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -20,7 +20,6 @@ package eu.faircode.email; */ import android.app.Activity; -import android.app.Dialog; import android.app.PendingIntent; import android.content.BroadcastReceiver; import android.content.Context; @@ -55,7 +54,6 @@ import android.view.Menu; import android.view.MenuInflater; import android.view.MenuItem; import android.view.MotionEvent; -import android.view.SubMenu; import android.view.View; import android.view.ViewGroup; import android.view.animation.Animation; diff --git a/app/src/main/java/eu/faircode/email/FragmentOperations.java b/app/src/main/java/eu/faircode/email/FragmentOperations.java index ec7a46f89f..61e8b6da21 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOperations.java +++ b/app/src/main/java/eu/faircode/email/FragmentOperations.java @@ -41,7 +41,6 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import java.util.ArrayList; -import java.util.Date; import java.util.List; public class FragmentOperations extends FragmentBase { diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java index 59b588a48c..81655f1f97 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsMisc.java @@ -257,8 +257,12 @@ public class FragmentOptionsMisc extends FragmentBase implements SharedPreferenc SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); swBadge.setChecked(prefs.getBoolean("badge", true)); - swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false)); + + boolean pro = Helper.isPro(getContext()); + swSubscriptions.setChecked(prefs.getBoolean("subscriptions", false) && pro); + swSubscriptions.setEnabled(pro); swSubscribedOnly.setChecked(prefs.getBoolean("subscribed_only", false)); + swEnglish.setChecked(prefs.getBoolean("english", false)); swAuthentication.setChecked(prefs.getBoolean("authentication", false)); swParanoid.setChecked(prefs.getBoolean("paranoid", true)); diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java index 91729824f5..3ab0774b28 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsNotifications.java @@ -43,7 +43,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.SwitchCompat; import androidx.constraintlayout.widget.Group; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.PreferenceManager; import static android.app.Activity.RESULT_OK; @@ -106,35 +105,35 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared cbNotifyActionTrash.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean checked) { - setAction(buttonView, "notify_trash", checked); + prefs.edit().putBoolean("notify_trash", checked).apply(); } }); cbNotifyActionArchive.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean checked) { - setAction(buttonView, "notify_archive", checked); + prefs.edit().putBoolean("notify_archive", checked).apply(); } }); cbNotifyActionReply.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean checked) { - setAction(buttonView, "notify_reply", checked); + prefs.edit().putBoolean("notify_reply", checked).apply(); } }); cbNotifyActionFlag.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean checked) { - setAction(buttonView, "notify_flag", checked); + prefs.edit().putBoolean("notify_flag", checked).apply(); } }); cbNotifyActionSeen.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton buttonView, boolean checked) { - setAction(buttonView, "notify_seen", checked); + prefs.edit().putBoolean("notify_seen", checked).apply(); } }); @@ -226,28 +225,23 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true)); - cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true)); - cbNotifyActionArchive.setChecked(prefs.getBoolean("notify_archive", true)); + cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true) || !pro); + cbNotifyActionArchive.setChecked(prefs.getBoolean("notify_archive", true) || !pro); cbNotifyActionReply.setChecked(prefs.getBoolean("notify_reply", false) && pro); cbNotifyActionFlag.setChecked(prefs.getBoolean("notify_flag", false) && pro); - cbNotifyActionSeen.setChecked(prefs.getBoolean("notify_seen", true)); + cbNotifyActionSeen.setChecked(prefs.getBoolean("notify_seen", true) || !pro); + + cbNotifyActionTrash.setEnabled(pro); + cbNotifyActionArchive.setEnabled(pro); + cbNotifyActionReply.setEnabled(pro); + cbNotifyActionFlag.setEnabled(pro); + cbNotifyActionSeen.setEnabled(pro); swLight.setChecked(prefs.getBoolean("light", false)); grpNotification.setVisibility(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE); } - private void setAction(CompoundButton cb, String key, boolean checked) { - SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); - if (Helper.isPro(getContext())) - prefs.edit().putBoolean(key, checked).apply(); - else { - cb.setChecked(!checked); - LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); - lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO)); - } - } - @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { Log.i("Result class=" + this.getClass().getSimpleName() + diff --git a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java index f9bece7eed..3d6bdd289a 100644 --- a/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java +++ b/app/src/main/java/eu/faircode/email/FragmentOptionsSynchronize.java @@ -22,7 +22,6 @@ package eu.faircode.email; import android.app.Dialog; import android.app.TimePickerDialog; import android.content.Context; -import android.content.Intent; import android.content.SharedPreferences; import android.os.Bundle; import android.text.format.DateFormat; @@ -42,7 +41,6 @@ import androidx.annotation.NonNull; import androidx.annotation.Nullable; import androidx.appcompat.widget.SwitchCompat; import androidx.fragment.app.DialogFragment; -import androidx.localbroadcastmanager.content.LocalBroadcastManager; import androidx.preference.PreferenceManager; import java.text.SimpleDateFormat; @@ -124,19 +122,7 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr swSchedule.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton compoundButton, boolean checked) { - if (checked) { - if (Helper.isPro(getContext())) { - prefs.edit().putBoolean("schedule", true).apply(); - ServiceSynchronize.reschedule(getContext()); - } else { - swSchedule.setChecked(false); - LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext()); - lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO)); - } - } else { - prefs.edit().putBoolean("schedule", false).apply(); - ServiceSynchronize.reload(getContext(), "schedule=" + checked); - } + prefs.edit().putBoolean("schedule", checked).apply(); } }); @@ -249,7 +235,9 @@ public class FragmentOptionsSynchronize extends FragmentBase implements SharedPr break; } - swSchedule.setChecked(prefs.getBoolean("schedule", false)); + boolean pro = Helper.isPro(getContext()); + swSchedule.setChecked(prefs.getBoolean("schedule", false) && pro); + swSchedule.setEnabled(pro); tvScheduleStart.setText(formatHour(getContext(), prefs.getInt("schedule_start", 0))); tvScheduleEnd.setText(formatHour(getContext(), prefs.getInt("schedule_end", 0))); diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 56573a9972..560f943fbd 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1418,7 +1418,7 @@ public class ServiceSynchronize extends LifecycleService { am.cancel(piAlarm); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); - if (!prefs.getBoolean("schedule", false)) + if (!prefs.getBoolean("schedule", false) || !Helper.isPro(context)) return; int minuteStart = prefs.getInt("schedule_start", 0);