mirror of
https://github.com/M66B/FairEmail.git
synced 2026-01-03 11:28:41 +01:00
@@ -54,6 +54,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
TextView tvName;
|
||||
TextView tvMessages;
|
||||
TextView tvType;
|
||||
ImageView ivUnified;
|
||||
TextView tvAfter;
|
||||
ImageView ivSync;
|
||||
ImageView ivState;
|
||||
@@ -67,6 +68,7 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
tvName = itemView.findViewById(R.id.tvName);
|
||||
tvMessages = itemView.findViewById(R.id.tvMessages);
|
||||
tvType = itemView.findViewById(R.id.tvType);
|
||||
ivUnified = itemView.findViewById(R.id.ivUnified);
|
||||
tvAfter = itemView.findViewById(R.id.tvAfter);
|
||||
ivSync = itemView.findViewById(R.id.ivSync);
|
||||
tvError = itemView.findViewById(R.id.tvError);
|
||||
@@ -106,6 +108,8 @@ public class AdapterFolder extends RecyclerView.Adapter<AdapterFolder.ViewHolder
|
||||
context.getPackageName());
|
||||
tvType.setText(resid > 0 ? context.getString(resid) : folder.type);
|
||||
|
||||
ivUnified.setVisibility(folder.unified ? View.VISIBLE : View.GONE);
|
||||
|
||||
tvAfter.setText(Integer.toString(folder.after));
|
||||
ivSync.setVisibility(folder.synchronize ? View.VISIBLE : View.INVISIBLE);
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ import androidx.sqlite.db.SupportSQLiteDatabase;
|
||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 9,
|
||||
version = 10,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
@@ -175,6 +175,15 @@ public abstract class DB extends RoomDatabase {
|
||||
db.execSQL("ALTER TABLE `message` ADD COLUMN `headers` TEXT");
|
||||
}
|
||||
})
|
||||
.addMigrations(new Migration(9, 10) {
|
||||
@Override
|
||||
public void migrate(SupportSQLiteDatabase db) {
|
||||
Log.i(Helper.TAG, "DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `folder` ADD COLUMN `unified` INTEGER NOT NULL DEFAULT 0");
|
||||
db.execSQL("CREATE INDEX `index_folder_unified` ON `folder` (`unified`)");
|
||||
db.execSQL("UPDATE `folder` SET unified = 1 WHERE type = '" + EntityFolder.INBOX + "'");
|
||||
}
|
||||
})
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -61,7 +61,7 @@ public interface DaoFolder {
|
||||
" JOIN account ON account.id = folder.account" +
|
||||
" JOIN message ON message.folder = folder.id AND NOT message.ui_hide" +
|
||||
" WHERE account.`synchronize`" +
|
||||
" AND folder.type = '" + EntityFolder.INBOX + "'" +
|
||||
" AND folder.unified" +
|
||||
" GROUP BY folder.id")
|
||||
LiveData<List<TupleFolderEx>> liveUnified();
|
||||
|
||||
@@ -114,8 +114,8 @@ public interface DaoFolder {
|
||||
" AND type = :type")
|
||||
int setFolderUser(long account, String type);
|
||||
|
||||
@Query("UPDATE folder SET synchronize = :synchronize, after = :after WHERE id = :id")
|
||||
int setFolderProperties(long id, boolean synchronize, int after);
|
||||
@Query("UPDATE folder SET synchronize = :synchronize, unified = :unified, after = :after WHERE id = :id")
|
||||
int setFolderProperties(long id, boolean synchronize, boolean unified, int after);
|
||||
|
||||
@Query("DELETE FROM folder WHERE account= :account AND name = :name")
|
||||
void deleteFolder(Long account, String name);
|
||||
|
||||
@@ -39,14 +39,14 @@ public interface DaoMessage {
|
||||
", COUNT(message.id) as count" +
|
||||
", SUM(CASE WHEN message.ui_seen THEN 0 ELSE 1 END) as unseen" +
|
||||
", (SELECT COUNT(a.id) FROM attachment a WHERE a.message = message.id) AS attachments" +
|
||||
", MAX(CASE WHEN folder.type = '" + EntityFolder.INBOX + "' THEN message.id ELSE 0 END) as dummy" +
|
||||
", MAX(CASE WHEN folder.unified THEN message.id ELSE 0 END) as dummy" +
|
||||
" FROM message" +
|
||||
" JOIN account ON account.id = message.account" +
|
||||
" JOIN folder ON folder.id = message.folder" +
|
||||
" WHERE account.`synchronize`" +
|
||||
" AND (NOT message.ui_hide OR :debug)" +
|
||||
" GROUP BY CASE WHEN message.thread IS NULL THEN message.id ELSE message.thread END" +
|
||||
" HAVING SUM(CASE WHEN folder.type = '" + EntityFolder.INBOX + "' THEN 1 ELSE 0 END) > 0" +
|
||||
" HAVING SUM(unified) > 0" +
|
||||
" ORDER BY message.received DESC")
|
||||
DataSource.Factory<Integer, TupleMessageEx> pagedUnifiedInbox(boolean debug);
|
||||
|
||||
@@ -127,7 +127,7 @@ public interface DaoMessage {
|
||||
" JOIN account ON account.id = message.account" +
|
||||
" JOIN folder ON folder.id = message.folder" +
|
||||
" WHERE account.`synchronize`" +
|
||||
" AND folder.type = '" + EntityFolder.INBOX + "'" +
|
||||
" AND folder.unified" +
|
||||
" AND NOT message.ui_seen AND NOT message.ui_hide" +
|
||||
" AND (account.seen_until IS NULL OR message.stored > account.seen_until)" +
|
||||
" ORDER BY message.received")
|
||||
|
||||
@@ -42,9 +42,11 @@ import static androidx.room.ForeignKey.CASCADE;
|
||||
@Index(value = {"account", "name"}, unique = true),
|
||||
@Index(value = {"account"}),
|
||||
@Index(value = {"name"}),
|
||||
@Index(value = {"type"})
|
||||
@Index(value = {"type"}),
|
||||
@Index(value = {"unified"})
|
||||
}
|
||||
)
|
||||
|
||||
public class EntityFolder implements Parcelable {
|
||||
static final String TABLE_NAME = "folder";
|
||||
|
||||
@@ -56,6 +58,8 @@ public class EntityFolder implements Parcelable {
|
||||
@NonNull
|
||||
public String type;
|
||||
@NonNull
|
||||
public Boolean unified = false;
|
||||
@NonNull
|
||||
public Boolean synchronize;
|
||||
@NonNull
|
||||
public Integer after; // days
|
||||
|
||||
@@ -556,6 +556,7 @@ public class FragmentAccount extends FragmentEx {
|
||||
inbox.name = "INBOX";
|
||||
inbox.type = EntityFolder.INBOX;
|
||||
inbox.synchronize = true;
|
||||
inbox.unified = true;
|
||||
inbox.after = EntityFolder.DEFAULT_INBOX_SYNC;
|
||||
|
||||
folders.add(inbox);
|
||||
|
||||
@@ -38,6 +38,7 @@ import androidx.lifecycle.Observer;
|
||||
public class FragmentFolder extends FragmentEx {
|
||||
private ViewGroup view;
|
||||
private CheckBox cbSynchronize;
|
||||
private CheckBox cbUnified;
|
||||
private EditText etAfter;
|
||||
private Button btnSave;
|
||||
private ProgressBar pbSave;
|
||||
@@ -63,6 +64,7 @@ public class FragmentFolder extends FragmentEx {
|
||||
|
||||
// Get controls
|
||||
cbSynchronize = view.findViewById(R.id.cbSynchronize);
|
||||
cbUnified = view.findViewById(R.id.cbUnified);
|
||||
etAfter = view.findViewById(R.id.etAfter);
|
||||
pbSave = view.findViewById(R.id.pbSave);
|
||||
btnSave = view.findViewById(R.id.btnSave);
|
||||
@@ -78,6 +80,7 @@ public class FragmentFolder extends FragmentEx {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("id", id);
|
||||
args.putBoolean("synchronize", cbSynchronize.isChecked());
|
||||
args.putBoolean("unified", cbUnified.isChecked());
|
||||
args.putString("after", etAfter.getText().toString());
|
||||
|
||||
new SimpleTask<Void>() {
|
||||
@@ -85,6 +88,7 @@ public class FragmentFolder extends FragmentEx {
|
||||
protected Void onLoad(Context context, Bundle args) {
|
||||
long id = args.getLong("id");
|
||||
boolean synchronize = args.getBoolean("synchronize");
|
||||
boolean unified = args.getBoolean("unified");
|
||||
String after = args.getString("after");
|
||||
int days = (TextUtils.isEmpty(after) ? 7 : Integer.parseInt(after));
|
||||
|
||||
@@ -92,7 +96,7 @@ public class FragmentFolder extends FragmentEx {
|
||||
try {
|
||||
db.beginTransaction();
|
||||
|
||||
db.folder().setFolderProperties(id, synchronize, days);
|
||||
db.folder().setFolderProperties(id, synchronize, unified, days);
|
||||
if (!synchronize)
|
||||
db.folder().setFolderError(id, null);
|
||||
|
||||
@@ -157,6 +161,7 @@ public class FragmentFolder extends FragmentEx {
|
||||
once = true;
|
||||
|
||||
cbSynchronize.setChecked(folder.synchronize);
|
||||
cbUnified.setChecked(folder.unified);
|
||||
etAfter.setText(Integer.toString(folder.after));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user