1
0
Fork 0
mirror of https://github.com/M66B/FairEmail.git synced 2024-12-24 08:44:26 +00:00

Silence old/unshown notifications

This commit is contained in:
M66B 2021-02-15 08:58:05 +01:00
parent 041261e469
commit 8b3302020f
5 changed files with 2407 additions and 3 deletions

File diff suppressed because it is too large Load diff

View file

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

View file

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

View file

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

View file

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