Simplification

pull/157/head
M66B 5 years ago
parent 51606f2763
commit 2e429e4f8e

@ -120,6 +120,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
private void bindTo(TupleAccountEx account) {
view.setActivated(account.tbd != null);
vwColor.setBackgroundColor(account.color == null ? Color.TRANSPARENT : account.color);
vwColor.setVisibility(Helper.isPro(context) ? View.VISIBLE : View.INVISIBLE);
ivSync.setImageResource(account.synchronize ? R.drawable.baseline_sync_24 : R.drawable.baseline_sync_disabled_24);

@ -103,6 +103,7 @@ public class AdapterIdentity extends RecyclerView.Adapter<AdapterIdentity.ViewHo
private void bindTo(TupleIdentityEx identity) {
view.setActivated(identity.tbd != null);
vwColor.setBackgroundColor(identity.color == null ? Color.TRANSPARENT : identity.color);
vwColor.setVisibility(Helper.isPro(context) ? View.VISIBLE : View.INVISIBLE);
ivSync.setImageResource(identity.synchronize ? R.drawable.baseline_sync_24 : R.drawable.baseline_sync_disabled_24);

@ -833,8 +833,8 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
int flagged = (message.count - message.unflagged);
ivFlagged.setImageResource(flagged > 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);
}

@ -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<TupleMessageEx, ContactInfo> messageContact = new HashMap<>();

@ -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);

@ -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;

@ -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 {

@ -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));

@ -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() +

@ -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)));

@ -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);

Loading…
Cancel
Save