Allow trying pro features as far as possible

pull/156/head
M66B 6 years ago
parent 1845fe7a4d
commit 401b2d723a

@ -1176,11 +1176,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
private void onColor(final Intent intent) { private void onColor(final Intent intent) {
if (!Helper.isPro(this)) {
onShowPro(null);
return;
}
int color = intent.getIntExtra("color", -1); int color = intent.getIntExtra("color", -1);
int[] colors = getResources().getIntArray(R.array.colorPicker); int[] colors = getResources().getIntArray(R.array.colorPicker);
ColorPickerDialog colorPickerDialog = new ColorPickerDialog(); ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
@ -1188,6 +1183,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
@Override @Override
public void onColorSelected(int color) { public void onColorSelected(int color) {
if (!Helper.isPro(ActivityView.this)) {
onShowPro(null);
return;
}
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putLong("id", intent.getLongExtra("id", -1)); args.putLong("id", intent.getLongExtra("id", -1));
args.putInt("color", color); args.putInt("color", color);
@ -1292,7 +1292,11 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
} }
private void onDecrypt(Intent intent) { private void onDecrypt(Intent intent) {
if (Helper.isPro(this)) { if (!Helper.isPro(this)) {
onShowPro(intent);
return;
}
if (pgpService.isBound()) { if (pgpService.isBound()) {
Intent data = new Intent(); Intent data = new Intent();
data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY); data.setAction(OpenPgpApi.ACTION_DECRYPT_VERIFY);
@ -1309,8 +1313,6 @@ public class ActivityView extends ActivityBilling implements FragmentManager.OnB
}); });
snackbar.show(); snackbar.show();
} }
} else
onShowPro(intent);
} }
private void onShowPro(Intent intent) { private void onShowPro(Intent intent) {

@ -2463,12 +2463,6 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
} }
private void onMenuManageKeywords(ActionData data) { private void onMenuManageKeywords(ActionData data) {
if (!Helper.isPro(context)) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
}
Bundle args = new Bundle(); Bundle args = new Bundle();
args.putSerializable("message", data.message); args.putSerializable("message", data.message);
@ -2510,6 +2504,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (!Helper.isPro(context)) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
}
args.putStringArray("keywords", items.toArray(new String[0])); args.putStringArray("keywords", items.toArray(new String[0]));
args.putBooleanArray("selected", selected); args.putBooleanArray("selected", selected);
args.putBooleanArray("dirty", dirty); args.putBooleanArray("dirty", dirty);
@ -2556,6 +2556,12 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { .setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override @Override
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
if (!Helper.isPro(context)) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
}
String keyword = Helper.sanitizeKeyword(etKeyword.getText().toString()); String keyword = Helper.sanitizeKeyword(etKeyword.getText().toString());
if (!TextUtils.isEmpty(keyword)) { if (!TextUtils.isEmpty(keyword)) {
args.putString("keyword", keyword); args.putString("keyword", keyword);
@ -3195,15 +3201,16 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() { popupMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override @Override
public boolean onMenuItemClick(MenuItem target) { public boolean onMenuItemClick(MenuItem target) {
if (Helper.isPro(context)) if (!Helper.isPro(context)) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return true;
}
context.startActivity(new Intent(context, ActivityCompose.class) context.startActivity(new Intent(context, ActivityCompose.class)
.putExtra("action", "reply") .putExtra("action", "reply")
.putExtra("reference", data.message.id) .putExtra("reference", data.message.id)
.putExtra("answer", (long) target.getItemId())); .putExtra("answer", (long) target.getItemId()));
else {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(context);
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
}
return true; return true;
} }
}); });

@ -1719,6 +1719,7 @@ class Core {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
boolean badge = prefs.getBoolean("badge", true); boolean badge = prefs.getBoolean("badge", true);
boolean pro = Helper.isPro(context);
// Update widget/badge count // Update widget/badge count
if (lastUnseen < 0 || messages.size() != lastUnseen) { if (lastUnseen < 0 || messages.size() != lastUnseen) {
@ -1743,7 +1744,7 @@ class Core {
continue; continue;
} }
String group = Long.toString(message.accountNotify ? message.account : 0); String group = Long.toString(pro && message.accountNotify ? message.account : 0);
if (!groupMessages.containsKey(group)) { if (!groupMessages.containsKey(group)) {
groupMessages.put(group, new ArrayList<TupleMessageEx>()); groupMessages.put(group, new ArrayList<TupleMessageEx>());
if (!groupNotifying.containsKey(group)) if (!groupNotifying.containsKey(group))
@ -1828,8 +1829,8 @@ class Core {
boolean notify_preview = prefs.getBoolean("notify_preview", true); boolean notify_preview = prefs.getBoolean("notify_preview", true);
boolean notify_trash = prefs.getBoolean("notify_trash", true); boolean notify_trash = prefs.getBoolean("notify_trash", true);
boolean notify_archive = prefs.getBoolean("notify_archive", true); boolean notify_archive = prefs.getBoolean("notify_archive", true);
boolean notify_reply = prefs.getBoolean("notify_reply", false); boolean notify_reply = prefs.getBoolean("notify_reply", false) && pro;
boolean notify_flag = prefs.getBoolean("notify_flag", false); boolean notify_flag = prefs.getBoolean("notify_flag", false) && pro;
boolean notify_seen = prefs.getBoolean("notify_seen", true); boolean notify_seen = prefs.getBoolean("notify_seen", true);
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
@ -1931,7 +1932,8 @@ class Core {
channelName = channel.getId(); channelName = channel.getId();
} }
if (channelName == null) if (channelName == null)
channelName = EntityAccount.getNotificationChannelId(message.accountNotify ? message.account : 0); channelName = EntityAccount.getNotificationChannelId(
pro && message.accountNotify ? message.account : 0);
// Get folder name // Get folder name
String folderName = message.folderDisplay == null String folderName = message.folderDisplay == null

@ -324,18 +324,18 @@ public class FragmentAccount extends FragmentBase {
btnColor.setOnClickListener(new View.OnClickListener() { btnColor.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
return;
}
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker); int[] colors = getContext().getResources().getIntArray(R.array.colorPicker);
ColorPickerDialog colorPickerDialog = new ColorPickerDialog(); ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length); colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length);
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
@Override @Override
public void onColorSelected(int color) { public void onColorSelected(int color) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
return;
}
setColor(color); setColor(color);
} }
}); });

@ -184,8 +184,6 @@ public class FragmentCompose extends FragmentBase {
private ContentResolver resolver; private ContentResolver resolver;
private AdapterAttachment adapter; private AdapterAttachment adapter;
private boolean pro;
private boolean prefix_once = false; private boolean prefix_once = false;
private boolean monospaced = false; private boolean monospaced = false;
private boolean style = true; private boolean style = true;
@ -212,7 +210,6 @@ public class FragmentCompose extends FragmentBase {
@Override @Override
public void onCreate(Bundle savedInstanceState) { public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState); super.onCreate(savedInstanceState);
pro = Helper.isPro(getContext());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
prefix_once = prefs.getBoolean("prefix_once", false); prefix_once = prefs.getBoolean("prefix_once", false);
@ -3082,7 +3079,6 @@ public class FragmentCompose extends FragmentBase {
grpExtra.setVisibility(identity != null && identity.sender_extra ? View.VISIBLE : View.GONE); grpExtra.setVisibility(identity != null && identity.sender_extra ? View.VISIBLE : View.GONE);
Spanned signature = null; Spanned signature = null;
if (pro) {
if (identity != null && !TextUtils.isEmpty(identity.signature)) if (identity != null && !TextUtils.isEmpty(identity.signature))
signature = HtmlHelper.fromHtml(identity.signature, new Html.ImageGetter() { signature = HtmlHelper.fromHtml(identity.signature, new Html.ImageGetter() {
@Override @Override
@ -3094,7 +3090,6 @@ public class FragmentCompose extends FragmentBase {
return d; return d;
} }
}, null); }, null);
}
tvSignature.setText(signature); tvSignature.setText(signature);
grpSignature.setVisibility(signature == null ? View.GONE : View.VISIBLE); grpSignature.setVisibility(signature == null ? View.GONE : View.VISIBLE);
} }

@ -277,18 +277,18 @@ public class FragmentIdentity extends FragmentBase {
btnColor.setOnClickListener(new View.OnClickListener() { btnColor.setOnClickListener(new View.OnClickListener() {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
return;
}
int[] colors = getContext().getResources().getIntArray(R.array.colorPicker); int[] colors = getContext().getResources().getIntArray(R.array.colorPicker);
ColorPickerDialog colorPickerDialog = new ColorPickerDialog(); ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length); colorPickerDialog.initialize(R.string.title_account_color, colors, color, 4, colors.length);
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
@Override @Override
public void onColorSelected(int color) { public void onColorSelected(int color) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivitySetup.ACTION_SHOW_PRO));
return;
}
setColor(color); setColor(color);
} }
}); });
@ -608,7 +608,7 @@ public class FragmentIdentity extends FragmentBase {
if (TextUtils.isEmpty(bcc)) if (TextUtils.isEmpty(bcc))
bcc = null; bcc = null;
if (Color.TRANSPARENT == color) if (color == Color.TRANSPARENT || !Helper.isPro(context))
color = null; color = null;
if (TextUtils.isEmpty(signature)) if (TextUtils.isEmpty(signature))
signature = null; signature = null;

@ -1627,18 +1627,18 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
} }
private void onActionFlagColorSelection() { private void onActionFlagColorSelection() {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
}
int[] colors = getResources().getIntArray(R.array.colorPicker); int[] colors = getResources().getIntArray(R.array.colorPicker);
ColorPickerDialog colorPickerDialog = new ColorPickerDialog(); ColorPickerDialog colorPickerDialog = new ColorPickerDialog();
colorPickerDialog.initialize(R.string.title_flag_color, colors, Color.TRANSPARENT, 4, colors.length); colorPickerDialog.initialize(R.string.title_flag_color, colors, Color.TRANSPARENT, 4, colors.length);
colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() { colorPickerDialog.setOnColorSelectedListener(new ColorPickerSwatch.OnColorSelectedListener() {
@Override @Override
public void onColorSelected(int color) { public void onColorSelected(int color) {
if (!Helper.isPro(getContext())) {
LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(getContext());
lbm.sendBroadcast(new Intent(ActivityView.ACTION_SHOW_PRO));
return;
}
onActionFlagSelection(true, color); onActionFlagSelection(true, color);
} }
}); });

@ -201,16 +201,19 @@ public class FragmentOptionsNotifications extends FragmentBase implements Shared
} }
private void setOptions() { private void setOptions() {
boolean pro = Helper.isPro(getContext());
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext()); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
swNotifyGroup.setChecked(prefs.getBoolean("notify_group", true)); swNotifyGroup.setChecked(prefs.getBoolean("notify_group", true));
swNotifyGroup.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? View.VISIBLE : View.GONE); swNotifyGroup.setVisibility(Build.VERSION.SDK_INT >= Build.VERSION_CODES.N ? View.VISIBLE : View.GONE);
swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true)); swNotifyPreview.setChecked(prefs.getBoolean("notify_preview", true));
cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true)); cbNotifyActionTrash.setChecked(prefs.getBoolean("notify_trash", true));
cbNotifyActionArchive.setChecked(prefs.getBoolean("notify_archive", true)); cbNotifyActionArchive.setChecked(prefs.getBoolean("notify_archive", true));
cbNotifyActionReply.setChecked(prefs.getBoolean("notify_reply", false)); cbNotifyActionReply.setChecked(prefs.getBoolean("notify_reply", false) && pro);
cbNotifyActionFlag.setChecked(prefs.getBoolean("notify_flag", false)); cbNotifyActionFlag.setChecked(prefs.getBoolean("notify_flag", false) && pro);
cbNotifyActionSeen.setChecked(prefs.getBoolean("notify_seen", true)); cbNotifyActionSeen.setChecked(prefs.getBoolean("notify_seen", true));
swLight.setChecked(prefs.getBoolean("light", false)); swLight.setChecked(prefs.getBoolean("light", false));
grpNotification.setVisibility(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE); grpNotification.setVisibility(Build.VERSION.SDK_INT < android.os.Build.VERSION_CODES.O ? View.VISIBLE : View.GONE);

Loading…
Cancel
Save