Refactoring

pull/212/head
M66B 2 years ago
parent d011265eb3
commit 0d2d084d8e

@ -97,7 +97,7 @@ public class FragmentDialogSwipes extends FragmentDialogBase {
List<EntityAccount> accounts = db.account().getAccounts();
for (EntityAccount account : accounts)
if (account.protocol == EntityAccount.TYPE_IMAP)
setDefaultFolderActions(context, account.id);
setDefaultFolderActions(context, account);
db.setTransactionSuccessful();
} finally {
@ -123,19 +123,20 @@ public class FragmentDialogSwipes extends FragmentDialogBase {
.create();
}
static void setDefaultFolderActions(Context context, long account) {
static void setDefaultFolderActions(Context context, @NonNull EntityAccount account) {
final SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
int leftPos = prefs.getInt("swipe_left_default", 2); // Trash
int rightPos = prefs.getInt("swipe_right_default", 1); // Archive
final int leftPos = prefs.getInt("swipe_left_default", 2); // Trash
final int rightPos = prefs.getInt("swipe_right_default", 1); // Archive
List<EntityFolder> actions = getFolderActions(context);
EntityFolder left = (leftPos < 0 || leftPos >= actions.size() ? null : actions.get(leftPos));
EntityFolder right = (rightPos < 0 || rightPos >= actions.size() ? null : actions.get(rightPos));
account.swipe_left = getAction(context, left == null ? 0 : left.id, account.id);
account.swipe_right = getAction(context, right == null ? 0 : right.id, account.id);
DB db = DB.getInstance(context);
db.account().setAccountSwipes(account,
getAction(context, left == null ? 0 : left.id, account),
getAction(context, right == null ? 0 : right.id, account));
db.account().setAccountSwipes(account.id, account.swipe_left, account.swipe_right);
}
static List<EntityFolder> getFolderActions(Context context) {

@ -558,7 +558,7 @@ public class FragmentGmail extends FragmentBase {
account.swipe_left = EntityMessage.SWIPE_ACTION_DELETE;
account.swipe_right = EntityMessage.SWIPE_ACTION_SEEN;
} else
FragmentDialogSwipes.setDefaultFolderActions(context, account.id);
FragmentDialogSwipes.setDefaultFolderActions(context, account);
db.account().updateAccount(account);

@ -944,7 +944,7 @@ public class FragmentOAuth extends FragmentBase {
account.swipe_left = EntityMessage.SWIPE_ACTION_DELETE;
account.swipe_right = EntityMessage.SWIPE_ACTION_SEEN;
} else
FragmentDialogSwipes.setDefaultFolderActions(context, account.id);
FragmentDialogSwipes.setDefaultFolderActions(context, account);
db.account().updateAccount(account);

@ -622,7 +622,7 @@ public class FragmentQuickSetup extends FragmentBase {
}
// Set swipe left/right folder
FragmentDialogSwipes.setDefaultFolderActions(context, account.id);
FragmentDialogSwipes.setDefaultFolderActions(context, account);
// Create identity
EntityIdentity identity = new EntityIdentity();

Loading…
Cancel
Save