mirror of
https://github.com/ArcaneChat/android.git
synced 2026-07-03 14:05:24 +02:00
select previous account when rolling back account creation
This commit is contained in:
@@ -25,6 +25,7 @@ import java.lang.ref.WeakReference;
|
||||
public class AccountManager {
|
||||
|
||||
private static final String TAG = AccountManager.class.getSimpleName();
|
||||
private static final String LAST_ACCOUNT_ID = "last_account_id";
|
||||
private static AccountManager self;
|
||||
|
||||
private void resetDcContext(Context context) {
|
||||
@@ -85,7 +86,13 @@ public class AccountManager {
|
||||
// add accounts
|
||||
|
||||
public int beginAccountCreation(Context context) {
|
||||
int id = DcHelper.getAccounts(context).addAccount();
|
||||
DcAccounts accounts = DcHelper.getAccounts(context);
|
||||
DcContext selectedAccount = accounts.getSelectedAccount();
|
||||
if (selectedAccount.isOk()) {
|
||||
PreferenceManager.getDefaultSharedPreferences(context).edit().putInt(LAST_ACCOUNT_ID, selectedAccount.getAccountId()).apply();
|
||||
}
|
||||
|
||||
int id = accounts.addAccount();
|
||||
resetDcContext(context);
|
||||
return id;
|
||||
}
|
||||
@@ -102,7 +109,8 @@ public class AccountManager {
|
||||
accounts.removeAccount(selectedAccount.getAccountId());
|
||||
}
|
||||
|
||||
new SwitchAccountAsyncTask(activity, R.string.switching_account, accounts.getSelectedAccount().getAccountId(), null).execute();
|
||||
int lastAccountId = PreferenceManager.getDefaultSharedPreferences(activity).getInt(LAST_ACCOUNT_ID, accounts.getSelectedAccount().getAccountId());
|
||||
new SwitchAccountAsyncTask(activity, R.string.switching_account, lastAccountId, null).execute();
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user