* commit 'b043233486ab845291d76aa9878378cd1e3368b1': Match dup accounts against all accounts, not just Email
This commit is contained in:
commit
831bb0abfe
@ -35,6 +35,7 @@ import android.content.Loader;
|
||||
import android.database.Cursor;
|
||||
import android.os.Bundle;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
@ -44,9 +45,10 @@ import com.android.email.R;
|
||||
import com.android.email.service.EmailServiceUtils;
|
||||
import com.android.emailcommon.VendorPolicyLoader;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.EmailContent.AccountColumns;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
import com.android.emailcommon.service.SyncWindow;
|
||||
import com.android.mail.providers.MailAppProvider;
|
||||
import com.android.mail.providers.UIProvider;
|
||||
import com.android.mail.utils.LogUtils;
|
||||
|
||||
import java.net.URISyntaxException;
|
||||
@ -368,8 +370,15 @@ public class AccountSetupFinal extends AccountSetupActivity
|
||||
|
||||
// Launch a loader to look up the owner name. It should be ready well in advance of
|
||||
// the time the user clicks next or manual.
|
||||
getLoaderManager().initLoader(OWNER_NAME_LOADER_ID, null,
|
||||
new LoaderManager.LoaderCallbacks<Cursor>() {
|
||||
getLoaderManager().initLoader(OWNER_NAME_LOADER_ID, null, new OwnerNameLoaderCallbacks());
|
||||
|
||||
// Launch a loader to cache some info about existing accounts so we can dupe-check against
|
||||
// them.
|
||||
getLoaderManager().initLoader(EXISTING_ACCOUNTS_LOADER_ID, null,
|
||||
new ExistingAccountsLoaderCallbacks());
|
||||
}
|
||||
|
||||
private class OwnerNameLoaderCallbacks implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
|
||||
return new CursorLoader(AccountSetupFinal.this,
|
||||
@ -388,47 +397,43 @@ public class AccountSetupFinal extends AccountSetupActivity
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(final Loader<Cursor> loader) {}
|
||||
});
|
||||
}
|
||||
|
||||
// Launch a loader to cache some info about existing accounts so we can dupe-check against
|
||||
// them.
|
||||
getLoaderManager().initLoader(EXISTING_ACCOUNTS_LOADER_ID, null,
|
||||
new LoaderManager.LoaderCallbacks<Cursor> () {
|
||||
private class ExistingAccountsLoaderCallbacks implements LoaderManager.LoaderCallbacks<Cursor> {
|
||||
@Override
|
||||
public Loader<Cursor> onCreateLoader(int id, Bundle args) {
|
||||
return new CursorLoader(AccountSetupFinal.this, Account.CONTENT_URI,
|
||||
new String[] {AccountColumns.EMAIL_ADDRESS,
|
||||
AccountColumns.DISPLAY_NAME},
|
||||
public Loader<Cursor> onCreateLoader(final int id, final Bundle args) {
|
||||
return new CursorLoader(AccountSetupFinal.this, MailAppProvider.getAccountsUri(),
|
||||
new String[] {UIProvider.AccountColumns.ACCOUNT_MANAGER_NAME,
|
||||
UIProvider.AccountColumns.NAME},
|
||||
null, null, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoadFinished(Loader<Cursor> loader, Cursor data) {
|
||||
if (data == null) {
|
||||
public void onLoadFinished(final Loader<Cursor> loader, final Cursor data) {
|
||||
if (data == null || !data.moveToFirst()) {
|
||||
mExistingAccountsMap = null;
|
||||
return;
|
||||
}
|
||||
|
||||
mExistingAccountsMap = new HashMap<String, String>();
|
||||
mExistingAccountsMap = new HashMap<>();
|
||||
|
||||
final int emailColumnIndex = data.getColumnIndex(
|
||||
AccountColumns.EMAIL_ADDRESS);
|
||||
UIProvider.AccountColumns.ACCOUNT_MANAGER_NAME);
|
||||
final int displayNameColumnIndex =
|
||||
data.getColumnIndex(AccountColumns.DISPLAY_NAME);
|
||||
data.getColumnIndex(UIProvider.AccountColumns.NAME);
|
||||
|
||||
while (data.moveToNext()) {
|
||||
do {
|
||||
final String email = data.getString(emailColumnIndex);
|
||||
final String displayName = data.getString(displayNameColumnIndex);
|
||||
mExistingAccountsMap.put(email,
|
||||
TextUtils.isEmpty(displayName) ? email : displayName);
|
||||
}
|
||||
} while (data.moveToNext());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onLoaderReset(Loader<Cursor> loader) {
|
||||
public void onLoaderReset(final Loader<Cursor> loader) {
|
||||
mExistingAccountsMap = null;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -445,7 +450,7 @@ public class AccountSetupFinal extends AccountSetupActivity
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSaveInstanceState(Bundle outState) {
|
||||
public void onSaveInstanceState(@NonNull Bundle outState) {
|
||||
super.onSaveInstanceState(outState);
|
||||
outState.putBoolean(SAVESTATE_KEY_IS_PROCESSING, mIsProcessing);
|
||||
outState.putInt(SAVESTATE_KEY_STATE, mState);
|
||||
|
Loading…
Reference in New Issue
Block a user