Silence old/unshown notifications

pull/194/head
M66B 4 years ago
parent 041261e469
commit 8b3302020f

File diff suppressed because it is too large Load Diff

@ -135,7 +135,7 @@ import static androidx.core.app.NotificationCompat.DEFAULT_SOUND;
import static javax.mail.Folder.READ_WRITE;
class Core {
private static final int MAX_NOTIFICATION_DISPLAY = 25; // per group
private static final int MAX_NOTIFICATION_DISPLAY = 7; // per group
private static final int MAX_NOTIFICATION_COUNT = 100; // per group
private static final int SYNC_CHUNCK_SIZE = 200;
private static final int SYNC_BATCH_SIZE = 20;
@ -3729,8 +3729,13 @@ class Core {
List<Long> add = new ArrayList<>();
List<Long> update = new ArrayList<>();
List<Long> remove = new ArrayList<>(groupNotifying.get(group));
for (int m = 0; m < groupMessages.get(group).size() && m < MAX_NOTIFICATION_DISPLAY; m++) {
for (int m = 0; m < groupMessages.get(group).size(); m++) {
TupleMessageEx message = groupMessages.get(group).get(m);
if (m >= MAX_NOTIFICATION_DISPLAY) {
db.message().setMessageUiSilent(message.id, true);
continue;
}
long id = (message.content ? message.id : -message.id);
if (remove.contains(id)) {
remove.remove(id);
@ -4068,6 +4073,11 @@ class Core {
.setOnlyAlertOnce(alert_once)
.setAllowSystemGeneratedContextualActions(false);
if (message.ui_silent) {
mbuilder.setSilent(true);
Log.i("Notify silent=" + message.id);
}
if (notify_messaging) {
// https://developer.android.com/training/cars/messaging
String meName = MessageHelper.formatAddresses(message.to, name_email, false);

@ -64,7 +64,7 @@ import static eu.faircode.email.ServiceAuthenticator.AUTH_TYPE_PASSWORD;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 187,
version = 188,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -1831,6 +1831,13 @@ public abstract class DB extends RoomDatabase {
db.execSQL("ALTER TABLE `message` ADD COLUMN `deleted` INTEGER NOT NULL DEFAULT 0");
db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_deleted` INTEGER NOT NULL DEFAULT 0");
}
})
.addMigrations(new Migration(187, 188) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
Log.i("DB migration from version " + startVersion + " to " + endVersion);
db.execSQL("ALTER TABLE `message` ADD COLUMN `ui_silent` INTEGER NOT NULL DEFAULT 0");
}
});
}

@ -661,6 +661,9 @@ public interface DaoMessage {
@Query("UPDATE message SET ui_ignored = :ui_ignored WHERE id = :id AND NOT (ui_ignored IS :ui_ignored)")
int setMessageUiIgnored(long id, boolean ui_ignored);
@Query("UPDATE message SET ui_silent = :ui_silent WHERE id = :id AND NOT (ui_silent IS :ui_silent)")
int setMessageUiSilent(long id, boolean ui_silent);
@Query("UPDATE message SET ui_busy = :busy WHERE id = :id AND NOT (ui_busy IS :busy)")
int setMessageUiBusy(long id, Long busy);

@ -214,6 +214,8 @@ public class EntityMessage implements Serializable {
@NonNull
public Boolean ui_ignored = false;
@NonNull
public Boolean ui_silent = false;
@NonNull
public Boolean ui_browsed = false;
public Long ui_busy;
public Long ui_snoozed;

Loading…
Cancel
Save