mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-28 20:06:29 +01:00
Simplify leave deleted
This commit is contained in:
2508
app/schemas/eu.faircode.email.DB/207.json
Normal file
2508
app/schemas/eu.faircode.email.DB/207.json
Normal file
File diff suppressed because it is too large
Load Diff
@@ -4351,53 +4351,30 @@ public class AdapterMessage extends RecyclerView.Adapter<AdapterMessage.ViewHold
|
||||
}
|
||||
|
||||
private void onActionDelete(TupleMessageEx message) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("account", message.account == null ? -1 : message.account);
|
||||
Bundle aargs = new Bundle();
|
||||
aargs.putString("question", context.getString(R.string.title_ask_delete));
|
||||
aargs.putString("remark", message.getRemark());
|
||||
aargs.putLong("id", message.id);
|
||||
aargs.putInt("faq", 160);
|
||||
aargs.putString("notagain", "delete_asked");
|
||||
aargs.putString("accept", context.getString(R.string.title_ask_delete_accept));
|
||||
aargs.putBoolean("warning", true);
|
||||
|
||||
new SimpleTask<EntityAccount>() {
|
||||
@Override
|
||||
protected EntityAccount onExecute(Context context, Bundle args) throws Throwable {
|
||||
long aid = args.getLong("account");
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean delete_asked = prefs.getBoolean("delete_asked", false);
|
||||
if (delete_asked ||
|
||||
(message.accountProtocol == EntityAccount.TYPE_POP &&
|
||||
message.accountLeaveDeleted)) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra("args", aargs);
|
||||
parentFragment.onActivityResult(FragmentMessages.REQUEST_MESSAGE_DELETE, RESULT_OK, data);
|
||||
return;
|
||||
}
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
return db.account().getAccount(aid);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, EntityAccount account) {
|
||||
boolean leave_deleted = (account != null &&
|
||||
account.protocol == EntityAccount.TYPE_POP &&
|
||||
account.leave_deleted);
|
||||
|
||||
Bundle aargs = new Bundle();
|
||||
aargs.putString("question", context.getString(R.string.title_ask_delete));
|
||||
aargs.putString("remark", message.getRemark());
|
||||
aargs.putLong("id", message.id);
|
||||
aargs.putInt("faq", 160);
|
||||
aargs.putString("notagain", "delete_asked");
|
||||
aargs.putString("accept", context.getString(R.string.title_ask_delete_accept));
|
||||
aargs.putBoolean("warning", true);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
|
||||
boolean delete_asked = prefs.getBoolean("delete_asked", false);
|
||||
if (delete_asked || leave_deleted) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra("args", aargs);
|
||||
parentFragment.onActivityResult(FragmentMessages.REQUEST_MESSAGE_DELETE, RESULT_OK, data);
|
||||
return;
|
||||
}
|
||||
|
||||
FragmentDialogAsk ask = new FragmentDialogAsk();
|
||||
ask.setArguments(aargs);
|
||||
ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_MESSAGE_DELETE);
|
||||
ask.show(parentFragment.getParentFragmentManager(), "message:delete");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(parentFragment.getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(context, owner, args, "message:delete");
|
||||
FragmentDialogAsk ask = new FragmentDialogAsk();
|
||||
ask.setArguments(aargs);
|
||||
ask.setTargetFragment(parentFragment, FragmentMessages.REQUEST_MESSAGE_DELETE);
|
||||
ask.show(parentFragment.getParentFragmentManager(), "message:delete");
|
||||
}
|
||||
|
||||
private void onActionJunk(TupleMessageEx message) {
|
||||
|
||||
@@ -66,7 +66,7 @@ import io.requery.android.database.sqlite.SQLiteDatabase;
|
||||
// https://developer.android.com/topic/libraries/architecture/room.html
|
||||
|
||||
@Database(
|
||||
version = 206,
|
||||
version = 207,
|
||||
entities = {
|
||||
EntityIdentity.class,
|
||||
EntityAccount.class,
|
||||
@@ -2091,6 +2091,13 @@ public abstract class DB extends RoomDatabase {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("ALTER TABLE `account` ADD COLUMN `capabilities` TEXT");
|
||||
}
|
||||
}).addMigrations(new Migration(206, 207) {
|
||||
@Override
|
||||
public void migrate(@NonNull SupportSQLiteDatabase db) {
|
||||
Log.i("DB migration from version " + startVersion + " to " + endVersion);
|
||||
db.execSQL("DROP VIEW `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) {
|
||||
|
||||
@@ -47,7 +47,7 @@ public interface DaoMessage {
|
||||
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
|
||||
@Query("SELECT message.*" +
|
||||
", account.pop AS accountProtocol, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
|
||||
", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" +
|
||||
", account.notify AS accountNotify, 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, 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" +
|
||||
@@ -125,7 +125,7 @@ public interface DaoMessage {
|
||||
@SuppressWarnings(RoomWarnings.CURSOR_MISMATCH)
|
||||
@Query("SELECT message.*" +
|
||||
", account.pop AS accountProtocol, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
|
||||
", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" +
|
||||
", account.notify AS accountNotify, 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, 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" +
|
||||
@@ -194,7 +194,7 @@ public interface DaoMessage {
|
||||
@Transaction
|
||||
@Query("SELECT message.*" +
|
||||
", account.pop AS accountProtocol, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
|
||||
", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" +
|
||||
", account.notify AS accountNotify, 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, 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" +
|
||||
@@ -435,7 +435,7 @@ public interface DaoMessage {
|
||||
|
||||
@Query("SELECT message.*" +
|
||||
", account.pop AS accountProtocol, account.name AS accountName, identity.color AS accountColor" +
|
||||
", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" +
|
||||
", account.notify AS accountNotify, 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, 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" +
|
||||
@@ -467,7 +467,7 @@ public interface DaoMessage {
|
||||
@Transaction
|
||||
@Query("SELECT message.*" +
|
||||
", account.pop AS accountProtocol, account.name AS accountName, COALESCE(identity.color, folder.color, account.color) AS accountColor" +
|
||||
", account.notify AS accountNotify, account.auto_seen AS accountAutoSeen" +
|
||||
", account.notify AS accountNotify, 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, 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" +
|
||||
|
||||
@@ -2436,53 +2436,30 @@ public class FragmentMessages extends FragmentBase implements SharedPreferences.
|
||||
}
|
||||
|
||||
private void onSwipeDelete(@NonNull TupleMessageEx message) {
|
||||
Bundle args = new Bundle();
|
||||
args.putLong("account", message.account == null ? -1 : message.account);
|
||||
Bundle aargs = new Bundle();
|
||||
aargs.putString("question", getString(R.string.title_ask_delete));
|
||||
aargs.putString("remark", message.getRemark());
|
||||
aargs.putLong("id", message.id);
|
||||
aargs.putInt("faq", 160);
|
||||
aargs.putString("notagain", "delete_asked");
|
||||
aargs.putString("accept", getString(R.string.title_ask_delete_accept));
|
||||
aargs.putBoolean("warning", true);
|
||||
|
||||
new SimpleTask<EntityAccount>() {
|
||||
@Override
|
||||
protected EntityAccount onExecute(Context context, Bundle args) throws Throwable {
|
||||
long aid = args.getLong("account");
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean delete_asked = prefs.getBoolean("delete_asked", false);
|
||||
if (delete_asked ||
|
||||
(message.accountProtocol == EntityAccount.TYPE_POP &&
|
||||
message.accountLeaveDeleted)) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra("args", aargs);
|
||||
onActivityResult(REQUEST_MESSAGE_DELETE, RESULT_OK, data);
|
||||
return;
|
||||
}
|
||||
|
||||
DB db = DB.getInstance(context);
|
||||
return db.account().getAccount(aid);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onExecuted(Bundle args, EntityAccount account) {
|
||||
boolean leave_deleted = (account != null &&
|
||||
account.protocol == EntityAccount.TYPE_POP &&
|
||||
account.leave_deleted);
|
||||
|
||||
Bundle aargs = new Bundle();
|
||||
aargs.putString("question", getString(R.string.title_ask_delete));
|
||||
aargs.putString("remark", message.getRemark());
|
||||
aargs.putLong("id", message.id);
|
||||
aargs.putInt("faq", 160);
|
||||
aargs.putString("notagain", "delete_asked");
|
||||
aargs.putString("accept", getString(R.string.title_ask_delete_accept));
|
||||
aargs.putBoolean("warning", true);
|
||||
|
||||
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getContext());
|
||||
boolean delete_asked = prefs.getBoolean("delete_asked", false);
|
||||
if (delete_asked || leave_deleted) {
|
||||
Intent data = new Intent();
|
||||
data.putExtra("args", aargs);
|
||||
onActivityResult(REQUEST_MESSAGE_DELETE, RESULT_OK, data);
|
||||
return;
|
||||
}
|
||||
|
||||
FragmentDialogAsk ask = new FragmentDialogAsk();
|
||||
ask.setArguments(aargs);
|
||||
ask.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGE_DELETE);
|
||||
ask.show(getParentFragmentManager(), "swipe:delete");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onException(Bundle args, Throwable ex) {
|
||||
Log.unexpectedError(getParentFragmentManager(), ex);
|
||||
}
|
||||
}.execute(FragmentMessages.this, args, "message:delete");
|
||||
FragmentDialogAsk ask = new FragmentDialogAsk();
|
||||
ask.setArguments(aargs);
|
||||
ask.setTargetFragment(FragmentMessages.this, REQUEST_MESSAGE_DELETE);
|
||||
ask.show(getParentFragmentManager(), "swipe:delete");
|
||||
}
|
||||
|
||||
private void swipeFolder(@NonNull TupleMessageEx message, @NonNull Long target) {
|
||||
|
||||
@@ -31,7 +31,7 @@ import java.util.Objects;
|
||||
value = TupleAccountView.query
|
||||
)
|
||||
public class TupleAccountView {
|
||||
static final String query = "SELECT id, pop, name, color, synchronize, notify, auto_seen, created FROM account";
|
||||
static final String query = "SELECT id, pop, name, color, synchronize, notify, leave_deleted, auto_seen, created FROM account";
|
||||
|
||||
@NonNull
|
||||
public Long id;
|
||||
@@ -45,6 +45,8 @@ public class TupleAccountView {
|
||||
@NonNull
|
||||
public Boolean notify = false;
|
||||
@NonNull
|
||||
public Boolean leave_deleted = false;
|
||||
@NonNull
|
||||
public Boolean auto_seen = true;
|
||||
public Long created;
|
||||
|
||||
@@ -58,6 +60,7 @@ public class TupleAccountView {
|
||||
Objects.equals(this.color, other.color) &&
|
||||
this.synchronize.equals(other.synchronize) &&
|
||||
this.notify.equals(other.notify) &&
|
||||
this.leave_deleted.equals(other.leave_deleted) &&
|
||||
this.auto_seen.equals(other.auto_seen) &&
|
||||
Objects.equals(this.created, other.created));
|
||||
} else
|
||||
|
||||
@@ -38,6 +38,7 @@ public class TupleMessageEx extends EntityMessage {
|
||||
public String accountName;
|
||||
public Integer accountColor;
|
||||
public boolean accountNotify;
|
||||
public boolean accountLeaveDeleted;
|
||||
public boolean accountAutoSeen;
|
||||
public String folderName;
|
||||
public Integer folderColor;
|
||||
@@ -123,6 +124,7 @@ public class TupleMessageEx extends EntityMessage {
|
||||
Objects.equals(this.accountName, other.accountName) &&
|
||||
Objects.equals(this.accountColor, other.accountColor) &&
|
||||
this.accountNotify == other.accountNotify &&
|
||||
this.accountLeaveDeleted == other.accountLeaveDeleted &&
|
||||
this.accountAutoSeen == other.accountAutoSeen &&
|
||||
this.folderName.equals(other.folderName) &&
|
||||
Objects.equals(this.folderDisplay, other.folderDisplay) &&
|
||||
|
||||
Reference in New Issue
Block a user