Added advanced account option for summary only notifications

This commit is contained in:
M66B 2023-04-11 08:36:48 +02:00
parent 18dc1b6f93
commit 9d716427ba
15 changed files with 3094 additions and 22 deletions

View File

@ -6,6 +6,10 @@ For support you can use [the contact form](https://contact.faircode.eu/?product=
### [Saltopus](https://en.wikipedia.org/wiki/Saltopus)
### Next version
* Added advanced account option for summary only notifications
### 1.2061 - 2023-04-10
* Added filter rule groups (stop processing per group)

File diff suppressed because it is too large Load Diff

View File

@ -6,6 +6,10 @@ For support you can use [the contact form](https://contact.faircode.eu/?product=
### [Saltopus](https://en.wikipedia.org/wiki/Saltopus)
### Next version
* Added advanced account option for summary only notifications
### 1.2061 - 2023-04-10
* Added filter rule groups (stop processing per group)

View File

@ -7978,6 +7978,7 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
log("accountColor changed", next.id);
}
// accountNotify
// accountSummary
// accountAutoSeen
if (!prev.folderName.equals(next.folderName)) {
same = false;

View File

@ -5331,10 +5331,15 @@ class Core {
continue;
}
boolean summary = (notify_summary ||
(group != 0 &&
groupMessages.get(group).size() > 0 &&
groupMessages.get(group).get(0).accountSummary));
// Build notifications
List<NotificationCompat.Builder> notifications = getNotificationUnseen(context,
group, groupMessages.get(group),
notify_summary, current - prev, current,
summary, current - prev, current,
redacted);
Log.i("Notify group=" + group +
@ -5373,7 +5378,7 @@ class Core {
if ((id == 0 && !prev.equals(current)) || add.contains(id)) {
// https://developer.android.com/training/wearables/notifications/bridger#non-bridged
if (id == 0) {
if (!notify_summary)
if (!summary)
builder.setLocalOnly(true);
} else {
if (wearable_preview ? id < 0 : update.contains(id))
@ -5537,6 +5542,9 @@ class Core {
.setVisibility(NotificationCompat.VISIBILITY_PUBLIC)
.setAllowSystemGeneratedContextualActions(false);
if (group != 0 && messages.size() > 0)
builder.setSubText(messages.get(0).accountName);
if (notify_summary) {
builder.setOnlyAlertOnce(new_messages <= 0);

View File

@ -68,7 +68,7 @@ import javax.mail.internet.InternetAddress;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 278,
version = 279,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2297,8 +2297,8 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
db.execSQL("CREATE INDEX `index_account_synchronize` ON `account` (`synchronize`)");
db.execSQL("CREATE INDEX `index_account_category` ON `account` (`category`)");
db.execSQL("DROP VIEW IF EXISTS `account_view`");
db.execSQL("CREATE VIEW IF NOT EXISTS `account_view` AS " + TupleAccountView.query);
//db.execSQL("DROP VIEW IF EXISTS `account_view`");
//db.execSQL("CREATE VIEW IF NOT EXISTS `account_view` AS " + TupleAccountView.query);
}
}).addMigrations(new Migration(214, 215) {
@Override
@ -2805,6 +2805,14 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `rule` ADD COLUMN `group` TEXT");
}
}).addMigrations(new Migration(278, 279) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `account` ADD COLUMN `summary` INTEGER NOT NULL DEFAULT 0");
db.execSQL("DROP VIEW IF EXISTS `account_view`");
db.execSQL("CREATE VIEW IF NOT EXISTS `account_view` AS " + TupleAccountView.query);
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

View File

@ -48,7 +48,7 @@ public interface DaoMessage {
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", account.notify AS accountNotify, account.summary AS accountSummary, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, NULL AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", '[' || group_concat(message.`from`, ',') || ']' AS senders" +
@ -127,7 +127,7 @@ public interface DaoMessage {
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", account.notify AS accountNotify, account.summary AS accountSummary, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, f.inherited_type AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", '[' || group_concat(message.`from`, ',') || ']' AS senders" +
@ -199,7 +199,7 @@ public interface DaoMessage {
@Transaction
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", account.notify AS accountNotify, account.summary AS accountSummary, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, NULL AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", message.`from` AS senders" +
@ -505,7 +505,7 @@ public interface DaoMessage {
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, identity.color AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", account.notify AS accountNotify, account.summary AS accountSummary, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, NULL AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", message.`from` AS senders" +
@ -536,7 +536,7 @@ public interface DaoMessage {
@Transaction
@Query("SELECT message.*" +
", account.pop AS accountProtocol, account.name AS accountName, account.category AS accountCategory, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
", account.notify AS accountNotify, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", account.notify AS accountNotify, account.summary AS accountSummary, account.leave_deleted AS accountLeaveDeleted, account.auto_seen AS accountAutoSeen" +
", folder.name AS folderName, folder.color AS folderColor, folder.display AS folderDisplay, folder.type AS folderType, NULL AS folderInheritedType, folder.unified AS folderUnified, folder.read_only AS folderReadOnly" +
", IFNULL(identity.display, identity.name) AS identityName, identity.email AS identityEmail, identity.color AS identityColor, identity.synchronize AS identitySynchronize" +
", message.`from` AS senders" +

View File

@ -112,6 +112,8 @@ public class EntityAccount extends EntityOrder implements Serializable {
@NonNull
public Boolean notify = false;
@NonNull
public Boolean summary = false;
@NonNull
public Boolean browse = true;
@NonNull
public Boolean leave_on_server = true;

View File

@ -123,6 +123,7 @@ public class FragmentAccount extends FragmentBase {
private CheckBox cbPrimary;
private CheckBox cbNotify;
private TextView tvNotifyRemark;
private CheckBox cbSummary;
private TextView tvNotifyPro;
private CheckBox cbBrowse;
private CheckBox cbAutoSeen;
@ -243,6 +244,7 @@ public class FragmentAccount extends FragmentBase {
cbPrimary = view.findViewById(R.id.cbPrimary);
cbNotify = view.findViewById(R.id.cbNotify);
tvNotifyRemark = view.findViewById(R.id.tvNotifyRemark);
cbSummary = view.findViewById(R.id.cbSummary);
tvNotifyPro = view.findViewById(R.id.tvNotifyPro);
cbBrowse = view.findViewById(R.id.cbBrowse);
cbAutoSeen = view.findViewById(R.id.cbAutoSeen);
@ -503,6 +505,13 @@ public class FragmentAccount extends FragmentBase {
Helper.hide(view.findViewById(R.id.tvNotifyPro));
}
cbNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cbSummary.setEnabled(cbNotify.isEnabled() && isChecked);
}
});
tvNotifyRemark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
@ -938,6 +947,7 @@ public class FragmentAccount extends FragmentBase {
args.putBoolean("ondemand", cbOnDemand.isChecked());
args.putBoolean("primary", cbPrimary.isChecked());
args.putBoolean("notify", cbNotify.isChecked());
args.putBoolean("summary", cbSummary.isChecked());
args.putBoolean("browse", cbBrowse.isChecked());
args.putBoolean("auto_seen", cbAutoSeen.isChecked());
args.putString("interval", etInterval.getText().toString());
@ -1014,6 +1024,7 @@ public class FragmentAccount extends FragmentBase {
boolean ondemand = args.getBoolean("ondemand");
boolean primary = args.getBoolean("primary");
boolean notify = args.getBoolean("notify");
boolean summary = args.getBoolean("summary");
boolean browse = args.getBoolean("browse");
boolean auto_seen = args.getBoolean("auto_seen");
String interval = args.getString("interval");
@ -1062,8 +1073,10 @@ public class FragmentAccount extends FragmentBase {
category = null;
if (color == Color.TRANSPARENT || !pro)
color = null;
if (!pro)
if (!pro) {
notify = false;
summary = false;
}
long now = new Date().getTime();
@ -1120,6 +1133,8 @@ public class FragmentAccount extends FragmentBase {
return true;
if (!Objects.equals(account.notify, notify))
return true;
if (!Objects.equals(account.summary, summary))
return true;
if (!Objects.equals(account.browse, browse))
return true;
if (!Objects.equals(account.auto_seen, auto_seen))
@ -1271,6 +1286,7 @@ public class FragmentAccount extends FragmentBase {
account.ondemand = ondemand;
account.primary = (account.synchronize && primary);
account.notify = notify;
account.summary = summary;
account.browse = browse;
account.auto_seen = auto_seen;
@ -1647,9 +1663,8 @@ public class FragmentAccount extends FragmentBase {
etCategory.setText(account == null ? null : account.category);
btnColor.setColor(account == null ? null : account.color);
boolean pro = ActivityBilling.isPro(context);
cbNotify.setChecked(account != null && account.notify && pro);
cbNotify.setEnabled(pro);
cbNotify.setChecked(account != null && account.notify);
cbSummary.setChecked(account != null && account.summary);
cbSynchronize.setChecked(account == null ? true : account.synchronize);
cbIgnoreSchedule.setChecked(jcondition.optBoolean("ignore_schedule"));
@ -1710,6 +1725,9 @@ public class FragmentAccount extends FragmentBase {
}
Helper.setViewsEnabled(view, true);
boolean pro = ActivityBilling.isPro(context);
cbNotify.setEnabled(pro);
cbSummary.setEnabled(pro && cbNotify.isChecked());
if (auth != AUTH_TYPE_PASSWORD) {
etUser.setEnabled(false);

View File

@ -93,6 +93,8 @@ public class FragmentPop extends FragmentBase {
private CheckBox cbOnDemand;
private CheckBox cbPrimary;
private CheckBox cbNotify;
private TextView tvNotifyRemark;
private CheckBox cbSummary;
private TextView tvNotifyPro;
private CheckBox cbAutoSeen;
private CheckBox cbLeaveServer;
@ -169,6 +171,8 @@ public class FragmentPop extends FragmentBase {
cbOnDemand = view.findViewById(R.id.cbOnDemand);
cbPrimary = view.findViewById(R.id.cbPrimary);
cbNotify = view.findViewById(R.id.cbNotify);
tvNotifyRemark = view.findViewById(R.id.tvNotifyRemark);
cbSummary = view.findViewById(R.id.cbSummary);
tvNotifyPro = view.findViewById(R.id.tvNotifyPro);
cbAutoSeen = view.findViewById(R.id.cbAutoSeen);
cbLeaveServer = view.findViewById(R.id.cbLeaveServer);
@ -288,11 +292,26 @@ public class FragmentPop extends FragmentBase {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.O) {
Helper.hide(cbNotify);
Helper.hide(tvNotifyRemark);
Helper.hide(view.findViewById(R.id.tvNotifyPro));
}
tvNotifyRemark.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
Helper.viewFAQ(v.getContext(), 145);
}
});
Helper.linkPro(tvNotifyPro);
cbNotify.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
cbSummary.setEnabled(cbNotify.isEnabled() && isChecked);
}
});
cbLeaveServer.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
@ -369,6 +388,7 @@ public class FragmentPop extends FragmentBase {
args.putBoolean("ondemand", cbOnDemand.isChecked());
args.putBoolean("primary", cbPrimary.isChecked());
args.putBoolean("notify", cbNotify.isChecked());
args.putBoolean("summary", cbSummary.isChecked());
args.putBoolean("auto_seen", cbAutoSeen.isChecked());
args.putBoolean("leave_server", cbLeaveServer.isChecked());
@ -425,6 +445,7 @@ public class FragmentPop extends FragmentBase {
boolean ondemand = args.getBoolean("ondemand");
boolean primary = args.getBoolean("primary");
boolean notify = args.getBoolean("notify");
boolean summary = args.getBoolean("summary");
boolean auto_seen = args.getBoolean("auto_seen");
boolean leave_server = args.getBoolean("leave_server");
boolean client_delete = args.getBoolean("client_delete");
@ -466,8 +487,10 @@ public class FragmentPop extends FragmentBase {
category = null;
if (color == Color.TRANSPARENT || !pro)
color = null;
if (!pro)
if (!pro) {
notify = false;
summary = false;
}
long now = new Date().getTime();
@ -516,6 +539,8 @@ public class FragmentPop extends FragmentBase {
return true;
if (!Objects.equals(account.notify, notify))
return true;
if (!Objects.equals(account.summary, summary))
return true;
if (!Objects.equals(account.auto_seen, auto_seen))
return true;
if (!Objects.equals(account.leave_on_server, leave_server))
@ -608,6 +633,7 @@ public class FragmentPop extends FragmentBase {
account.ondemand = ondemand;
account.primary = (account.synchronize && primary);
account.notify = notify;
account.summary = summary;
account.auto_seen = auto_seen;
account.leave_on_server = leave_server;
account.client_delete = client_delete;
@ -799,9 +825,8 @@ public class FragmentPop extends FragmentBase {
cbOnDemand.setChecked(account == null ? false : account.ondemand);
cbPrimary.setChecked(account == null ? false : account.primary);
boolean pro = ActivityBilling.isPro(getContext());
cbNotify.setChecked(account != null && account.notify && pro);
cbNotify.setEnabled(pro);
cbNotify.setChecked(account != null && account.notify);
cbSummary.setChecked(account != null && account.summary);
cbAutoSeen.setChecked(account == null ? true : account.auto_seen);
@ -863,6 +888,9 @@ public class FragmentPop extends FragmentBase {
}
Helper.setViewsEnabled(view, true);
boolean pro = ActivityBilling.isPro(getContext());
cbNotify.setEnabled(pro);
cbSummary.setEnabled(pro && cbNotify.isChecked());
if (auth != AUTH_TYPE_PASSWORD) {
etUser.setEnabled(false);

View File

@ -31,7 +31,7 @@ import java.util.Objects;
value = TupleAccountView.query
)
public class TupleAccountView {
static final String query = "SELECT id, pop, name, category, color, synchronize, notify, leave_deleted, auto_seen, created FROM account";
static final String query = "SELECT id, pop, name, category, color, synchronize, notify, summary, leave_deleted, auto_seen, created FROM account";
@NonNull
public Long id;
@ -46,6 +46,8 @@ public class TupleAccountView {
@NonNull
public Boolean notify = false;
@NonNull
public Boolean summary = false;
@NonNull
public Boolean leave_deleted = false;
@NonNull
public Boolean auto_seen = true;
@ -61,6 +63,7 @@ public class TupleAccountView {
Objects.equals(this.color, other.color) &&
this.synchronize.equals(other.synchronize) &&
this.notify.equals(other.notify) &&
this.summary.equals(other.summary) &&
this.leave_deleted.equals(other.leave_deleted) &&
this.auto_seen.equals(other.auto_seen) &&
Objects.equals(this.created, other.created));

View File

@ -39,6 +39,7 @@ public class TupleMessageEx extends EntityMessage {
public String accountCategory;
public Integer accountColor;
public boolean accountNotify;
public boolean accountSummary;
public boolean accountLeaveDeleted;
public boolean accountAutoSeen;
public String folderName;
@ -146,6 +147,7 @@ public class TupleMessageEx extends EntityMessage {
Objects.equals(this.accountCategory, other.accountCategory) &&
Objects.equals(this.accountColor, other.accountColor) &&
this.accountNotify == other.accountNotify &&
this.accountSummary == other.accountSummary &&
this.accountLeaveDeleted == other.accountLeaveDeleted &&
this.accountAutoSeen == other.accountAutoSeen &&
this.folderName.equals(other.folderName) &&

View File

@ -572,6 +572,16 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotify" />
<CheckBox
android:id="@+id/cbSummary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:text="@string/title_advanced_notify_summary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyRemark" />
<TextView
android:id="@+id/tvNotifyPro"
android:layout_width="wrap_content"
@ -581,7 +591,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyRemark" />
app:layout_constraintTop_toBottomOf="@id/cbSummary" />
<CheckBox
android:id="@+id/cbBrowse"
@ -1176,7 +1186,7 @@
android:layout_width="0dp"
android:layout_height="0dp"
app:constraint_referenced_ids="
cbNotify,tvNotifyRemark,tvNotifyPro,
cbNotify,tvNotifyRemark,cbSummary,tvNotifyPro,
cbSynchronize,cbIgnoreSchedule,cbOnDemand,tvLeave,cbPrimary,
cbBrowse,tvBrowseHint,
cbAutoSeen,

View File

@ -407,6 +407,31 @@
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbPrimary" />
<TextView
android:id="@+id/tvNotifyRemark"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginTop="6dp"
android:drawableEnd="@drawable/twotone_info_24"
android:drawablePadding="6dp"
android:text="@string/title_notify_remark"
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textStyle="italic"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotify" />
<CheckBox
android:id="@+id/cbSummary"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="6dp"
android:tag="ignore"
android:text="@string/title_advanced_notify_summary"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/tvNotifyRemark" />
<TextView
android:id="@+id/tvNotifyPro"
android:layout_width="wrap_content"
@ -416,7 +441,7 @@
android:textAppearance="@style/TextAppearance.AppCompat.Small"
android:textColor="?android:attr/textColorLink"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/cbNotify" />
app:layout_constraintTop_toBottomOf="@id/cbSummary" />
<CheckBox
android:id="@+id/cbAutoSeen"

View File

@ -6,6 +6,10 @@ For support you can use the contact form.
Saltopus
Next version
* Added advanced account option for summary only notifications
1.2061 - 2023-04-10
* Added filter rule groups (stop processing per group)