Added auto delete for junk folder

This commit is contained in:
M66B 2022-02-22 13:00:01 +01:00
parent 89361fffa6
commit 083a7fa49c
4 changed files with 2731 additions and 3 deletions

File diff suppressed because it is too large Load Diff

View File

@ -3194,7 +3194,8 @@ class Core {
for (Long tbd : tbds) {
EntityMessage message = db.message().getMessage(tbd);
if (message != null && trash != null)
if (EntityFolder.TRASH.equals(folder.type))
if (EntityFolder.TRASH.equals(folder.type) ||
EntityFolder.JUNK.equals(folder.type))
EntityOperation.queue(context, message, EntityOperation.DELETE);
else
EntityOperation.queue(context, message, EntityOperation.MOVE, trash.id);

View File

@ -71,7 +71,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
// https://developer.android.com/topic/libraries/architecture/room.html
@Database(
version = 224,
version = 225,
entities = {
EntityIdentity.class,
EntityAccount.class,
@ -2266,6 +2266,14 @@ public abstract class DB extends RoomDatabase {
logMigration(startVersion, endVersion);
db.execSQL("ALTER TABLE `attachment` ADD COLUMN `media_uri` TEXT");
}
}).addMigrations(new Migration(224, 225) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {
logMigration(startVersion, endVersion);
db.execSQL("UPDATE folder" +
" SET auto_delete = 0" +
" WHERE type ='" + EntityFolder.JUNK + "'");
}
}).addMigrations(new Migration(998, 999) {
@Override
public void migrate(@NonNull SupportSQLiteDatabase db) {

View File

@ -346,7 +346,9 @@ public class FragmentFolder extends FragmentBase {
tvAutoClassifyPro.setVisibility(canAutoClassify && !pro ? View.VISIBLE : View.GONE);
etKeepDays.setEnabled(!cbKeepAll.isChecked());
cbAutoDelete.setEnabled(!cbKeepAll.isChecked());
cbAutoDelete.setText(folder != null && EntityFolder.TRASH.equals(folder.type)
cbAutoDelete.setText(folder != null &&
(EntityFolder.TRASH.equals(folder.type) ||
EntityFolder.JUNK.equals(folder.type))
? R.string.title_auto_delete : R.string.title_auto_trash);
grpAutoDelete.setVisibility(canAutoDelete ? View.VISIBLE : View.GONE);
tvAutoDeleteArchiveHint.setVisibility(canAutoDelete && isArchive ? View.VISIBLE : View.GONE);