Added separate notifications POP3

pull/174/head
M66B 5 years ago
parent b154bcff09
commit a645fb1bd3

@ -242,7 +242,7 @@ public class AdapterAccount extends RecyclerView.Adapter<AdapterAccount.ViewHold
popupMenu.getMenu().add(Menu.NONE, R.string.title_enabled, 1, R.string.title_enabled) popupMenu.getMenu().add(Menu.NONE, R.string.title_enabled, 1, R.string.title_enabled)
.setCheckable(true).setChecked(account.synchronize); .setCheckable(true).setChecked(account.synchronize);
if (account.protocol == EntityAccount.TYPE_IMAP && account.notify && if (account.notify &&
Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) { Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
String channelId = EntityAccount.getNotificationChannelId(account.id); String channelId = EntityAccount.getNotificationChannelId(account.id);
NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE); NotificationManager nm = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);

@ -24,6 +24,7 @@ import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.graphics.Color; import android.graphics.Color;
import android.net.Uri; import android.net.Uri;
import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.os.Handler; import android.os.Handler;
import android.text.Editable; import android.text.Editable;
@ -73,6 +74,8 @@ public class FragmentPop extends FragmentBase {
private TextView tvColorPro; private TextView tvColorPro;
private CheckBox cbSynchronize; private CheckBox cbSynchronize;
private CheckBox cbNotify;
private TextView tvNotifyPro;
private CheckBox cbOnDemand; private CheckBox cbOnDemand;
private CheckBox cbPrimary; private CheckBox cbPrimary;
private CheckBox cbLeaveServer; private CheckBox cbLeaveServer;
@ -126,6 +129,8 @@ public class FragmentPop extends FragmentBase {
cbSynchronize = view.findViewById(R.id.cbSynchronize); cbSynchronize = view.findViewById(R.id.cbSynchronize);
cbOnDemand = view.findViewById(R.id.cbOnDemand); cbOnDemand = view.findViewById(R.id.cbOnDemand);
cbPrimary = view.findViewById(R.id.cbPrimary); cbPrimary = view.findViewById(R.id.cbPrimary);
cbNotify = view.findViewById(R.id.cbNotify);
tvNotifyPro = view.findViewById(R.id.tvNotifyPro);
cbLeaveServer = view.findViewById(R.id.cbLeaveServer); cbLeaveServer = view.findViewById(R.id.cbLeaveServer);
cbLeaveDevice = view.findViewById(R.id.cbLeaveDevice); cbLeaveDevice = view.findViewById(R.id.cbLeaveDevice);
etInterval = view.findViewById(R.id.etInterval); etInterval = view.findViewById(R.id.etInterval);
@ -185,6 +190,13 @@ public class FragmentPop extends FragmentBase {
} }
}); });
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
Helper.hide(cbNotify);
Helper.hide(view.findViewById(R.id.tvNotifyPro));
}
Helper.linkPro(tvNotifyPro);
etInterval.setHint(Integer.toString(EntityAccount.DEFAULT_POLL_INTERVAL)); etInterval.setHint(Integer.toString(EntityAccount.DEFAULT_POLL_INTERVAL));
btnSave.setOnClickListener(new View.OnClickListener() { btnSave.setOnClickListener(new View.OnClickListener() {
@ -221,6 +233,7 @@ public class FragmentPop extends FragmentBase {
args.putBoolean("synchronize", cbSynchronize.isChecked()); args.putBoolean("synchronize", cbSynchronize.isChecked());
args.putBoolean("ondemand", cbOnDemand.isChecked()); args.putBoolean("ondemand", cbOnDemand.isChecked());
args.putBoolean("primary", cbPrimary.isChecked()); args.putBoolean("primary", cbPrimary.isChecked());
args.putBoolean("notify", cbNotify.isChecked());
args.putBoolean("leave_server", cbLeaveServer.isChecked()); args.putBoolean("leave_server", cbLeaveServer.isChecked());
args.putBoolean("leave_device", cbLeaveDevice.isChecked()); args.putBoolean("leave_device", cbLeaveDevice.isChecked());
args.putString("interval", etInterval.getText().toString()); args.putString("interval", etInterval.getText().toString());
@ -259,6 +272,7 @@ public class FragmentPop extends FragmentBase {
boolean synchronize = args.getBoolean("synchronize"); boolean synchronize = args.getBoolean("synchronize");
boolean ondemand = args.getBoolean("ondemand"); boolean ondemand = args.getBoolean("ondemand");
boolean primary = args.getBoolean("primary"); boolean primary = args.getBoolean("primary");
boolean notify = args.getBoolean("notify");
boolean leave_server = args.getBoolean("leave_server"); boolean leave_server = args.getBoolean("leave_server");
boolean leave_device = args.getBoolean("leave_device"); boolean leave_device = args.getBoolean("leave_device");
String interval = args.getString("interval"); String interval = args.getString("interval");
@ -347,6 +361,7 @@ public class FragmentPop extends FragmentBase {
account.synchronize = synchronize; account.synchronize = synchronize;
account.ondemand = ondemand; account.ondemand = ondemand;
account.primary = (account.synchronize && primary); account.primary = (account.synchronize && primary);
account.notify = notify;
account.leave_on_server = leave_server; account.leave_on_server = leave_server;
account.leave_on_device = leave_device; account.leave_on_device = leave_device;
account.poll_interval = Integer.parseInt(interval); account.poll_interval = Integer.parseInt(interval);
@ -367,6 +382,15 @@ public class FragmentPop extends FragmentBase {
account.id = db.account().insertAccount(account); account.id = db.account().insertAccount(account);
EntityLog.log(context, (update ? "Updated" : "Added") + " account=" + account.name); EntityLog.log(context, (update ? "Updated" : "Added") + " account=" + account.name);
// Make sure the channel exists on commit
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
if (account.notify) {
// Add or update notification channel
account.deleteNotificationChannel(context);
account.createNotificationChannel(context);
} else if (!account.synchronize)
account.deleteNotificationChannel(context);
}
EntityFolder inbox = db.folder().getFolderByType(account.id, EntityFolder.INBOX); EntityFolder inbox = db.folder().getFolderByType(account.id, EntityFolder.INBOX);
if (inbox == null) { if (inbox == null) {
@ -490,6 +514,10 @@ public class FragmentPop extends FragmentBase {
etName.setText(account == null ? null : account.name); etName.setText(account == null ? null : account.name);
btnColor.setColor(account == null ? null : account.color); btnColor.setColor(account == null ? null : account.color);
boolean pro = ActivityBilling.isPro(getContext());
cbNotify.setChecked(account != null && account.notify && pro);
cbNotify.setEnabled(pro);
cbSynchronize.setChecked(account == null ? true : account.synchronize); cbSynchronize.setChecked(account == null ? true : account.synchronize);
cbOnDemand.setChecked(account == null ? false : account.ondemand); cbOnDemand.setChecked(account == null ? false : account.ondemand);
cbPrimary.setChecked(account == null ? false : account.primary); cbPrimary.setChecked(account == null ? false : account.primary);

@ -280,6 +280,26 @@
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbOnDemand" /> app:layout_constraintTop_toBottomOf="@id/cbOnDemand" />
<CheckBox
android:id="@+id/cbNotify"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="12dp"
android:text="@string/title_account_notify"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPrimary" />
<TextView
android:id="@+id/tvNotifyPro"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:text="@string/title_pro_feature"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotify" />
<CheckBox <CheckBox
android:id="@+id/cbLeaveServer" android:id="@+id/cbLeaveServer"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -287,7 +307,7 @@
android:layout_marginTop="12dp" android:layout_marginTop="12dp"
android:text="@string/title_leave_on_server" android:text="@string/title_leave_on_server"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPrimary" /> app:layout_constraintTop_toBottomOf="@id/tvNotifyPro" />
<CheckBox <CheckBox
android:id="@+id/cbLeaveDevice" android:id="@+id/cbLeaveDevice"

Loading…
Cancel
Save