Clean up warnings, finals, dead and useless code
Change-Id: I8225a78c3b1712479bb5752161e3585a2bc2be2e
This commit is contained in:
parent
21b95c1071
commit
ed4accb24f
|
@ -146,24 +146,6 @@ public class Utility {
|
||||||
}
|
}
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
public static String base64Decode(String encoded) {
|
|
||||||
if (encoded == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
byte[] decoded = Base64.decode(encoded, Base64.DEFAULT);
|
|
||||||
return new String(decoded);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static String base64Encode(String s) {
|
|
||||||
if (s == null) {
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
return Base64.encodeToString(s.getBytes(), Base64.NO_WRAP);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isTextViewNotEmpty(TextView view) {
|
|
||||||
return !TextUtils.isEmpty(view.getText());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean isPortFieldValid(TextView view) {
|
public static boolean isPortFieldValid(TextView view) {
|
||||||
CharSequence chars = view.getText();
|
CharSequence chars = view.getText();
|
||||||
|
|
|
@ -58,14 +58,6 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
|
|
||||||
public final static String TAG = "AccountCheckSettingsFragment";
|
public final static String TAG = "AccountCheckSettingsFragment";
|
||||||
|
|
||||||
// Debugging flags - for debugging the UI
|
|
||||||
// If true, use a "fake" account check cycle
|
|
||||||
private static final boolean DEBUG_FAKE_CHECK_CYCLE = false; // DO NOT CHECK IN TRUE
|
|
||||||
// If true, use fake check cycle, return failure
|
|
||||||
private static final boolean DEBUG_FAKE_CHECK_ERR = false; // DO NOT CHECK IN TRUE
|
|
||||||
// If true, use fake check cycle, return "security required"
|
|
||||||
private static final boolean DEBUG_FORCE_SECURITY_REQUIRED = false; // DO NOT CHECK IN TRUE
|
|
||||||
|
|
||||||
// State
|
// State
|
||||||
private final static int STATE_START = 0;
|
private final static int STATE_START = 0;
|
||||||
private final static int STATE_CHECK_AUTODISCOVER = 1;
|
private final static int STATE_CHECK_AUTODISCOVER = 1;
|
||||||
|
@ -131,7 +123,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
* @param mode incoming or outgoing
|
* @param mode incoming or outgoing
|
||||||
*/
|
*/
|
||||||
public static AccountCheckSettingsFragment newInstance(int mode, Fragment parentFragment) {
|
public static AccountCheckSettingsFragment newInstance(int mode, Fragment parentFragment) {
|
||||||
AccountCheckSettingsFragment f = new AccountCheckSettingsFragment();
|
final AccountCheckSettingsFragment f = new AccountCheckSettingsFragment();
|
||||||
f.setTargetFragment(parentFragment, mode);
|
f.setTargetFragment(parentFragment, mode);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -159,8 +151,8 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
|
|
||||||
// If this is the first time, start the AsyncTask
|
// If this is the first time, start the AsyncTask
|
||||||
if (mAccountCheckTask == null) {
|
if (mAccountCheckTask == null) {
|
||||||
int checkMode = getTargetRequestCode();
|
final int checkMode = getTargetRequestCode();
|
||||||
Account checkAccount = SetupData.getAccount();
|
final Account checkAccount = SetupData.getAccount();
|
||||||
mAccountCheckTask = (AccountCheckTask)
|
mAccountCheckTask = (AccountCheckTask)
|
||||||
new AccountCheckTask(checkMode, checkAccount)
|
new AccountCheckTask(checkMode, checkAccount)
|
||||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
@ -221,7 +213,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
|
|
||||||
// If we are attached, create, recover, and/or update the dialog
|
// If we are attached, create, recover, and/or update the dialog
|
||||||
if (mAttached && !mPaused) {
|
if (mAttached && !mPaused) {
|
||||||
FragmentManager fm = getFragmentManager();
|
final FragmentManager fm = getFragmentManager();
|
||||||
|
|
||||||
switch (newState) {
|
switch (newState) {
|
||||||
case STATE_CHECK_OK:
|
case STATE_CHECK_OK:
|
||||||
|
@ -263,7 +255,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_AUTODISCOVER_RESULT:
|
case STATE_AUTODISCOVER_RESULT:
|
||||||
HostAuth autoDiscoverResult = ((AutoDiscoverResults) ex).mHostAuth;
|
final HostAuth autoDiscoverResult = ((AutoDiscoverResults) ex).mHostAuth;
|
||||||
// 1. get rid of progress dialog (if any)
|
// 1. get rid of progress dialog (if any)
|
||||||
recoverAndDismissCheckingDialog();
|
recoverAndDismissCheckingDialog();
|
||||||
// 2. exit self
|
// 2. exit self
|
||||||
|
@ -293,7 +285,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
* Find the callback target, either a target fragment or the activity
|
* Find the callback target, either a target fragment or the activity
|
||||||
*/
|
*/
|
||||||
private Callbacks getCallbackTarget() {
|
private Callbacks getCallbackTarget() {
|
||||||
Fragment target = getTargetFragment();
|
final Fragment target = getTargetFragment();
|
||||||
if (target instanceof Callbacks) {
|
if (target instanceof Callbacks) {
|
||||||
return (Callbacks) target;
|
return (Callbacks) target;
|
||||||
}
|
}
|
||||||
|
@ -344,7 +336,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
*/
|
*/
|
||||||
private void onErrorDialogEditButton() {
|
private void onErrorDialogEditButton() {
|
||||||
// 1. handle "edit" - notify callback that we had a problem with the test
|
// 1. handle "edit" - notify callback that we had a problem with the test
|
||||||
Callbacks callbackTarget = getCallbackTarget();
|
final Callbacks callbackTarget = getCallbackTarget();
|
||||||
if (mState == STATE_AUTODISCOVER_AUTH_DIALOG) {
|
if (mState == STATE_AUTODISCOVER_AUTH_DIALOG) {
|
||||||
// report auth error to target fragment or activity
|
// report auth error to target fragment or activity
|
||||||
callbackTarget.onAutoDiscoverComplete(AUTODISCOVER_AUTHENTICATION);
|
callbackTarget.onAutoDiscoverComplete(AUTODISCOVER_AUTHENTICATION);
|
||||||
|
@ -357,7 +349,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
|
|
||||||
/** Kill self if not already killed. */
|
/** Kill self if not already killed. */
|
||||||
private void finish() {
|
private void finish() {
|
||||||
FragmentManager fm = getFragmentManager();
|
final FragmentManager fm = getFragmentManager();
|
||||||
if (fm != null) {
|
if (fm != null) {
|
||||||
fm.popBackStack();
|
fm.popBackStack();
|
||||||
}
|
}
|
||||||
|
@ -369,12 +361,12 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
*/
|
*/
|
||||||
private void onSecurityRequiredDialogResultOk(boolean okPressed) {
|
private void onSecurityRequiredDialogResultOk(boolean okPressed) {
|
||||||
// 1. handle OK/cancel - notify that security is OK and we can proceed
|
// 1. handle OK/cancel - notify that security is OK and we can proceed
|
||||||
Callbacks callbackTarget = getCallbackTarget();
|
final Callbacks callbackTarget = getCallbackTarget();
|
||||||
callbackTarget.onCheckSettingsComplete(
|
callbackTarget.onCheckSettingsComplete(
|
||||||
okPressed ? CHECK_SETTINGS_OK : CHECK_SETTINGS_SECURITY_USER_DENY);
|
okPressed ? CHECK_SETTINGS_OK : CHECK_SETTINGS_SECURITY_USER_DENY);
|
||||||
|
|
||||||
// 2. kill self if not already killed by callback
|
// 2. kill self if not already killed by callback
|
||||||
FragmentManager fm = getFragmentManager();
|
final FragmentManager fm = getFragmentManager();
|
||||||
if (fm != null) {
|
if (fm != null) {
|
||||||
fm.popBackStack();
|
fm.popBackStack();
|
||||||
}
|
}
|
||||||
|
@ -432,17 +424,13 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected MessagingException doInBackground(Void... params) {
|
protected MessagingException doInBackground(Void... params) {
|
||||||
if (DEBUG_FAKE_CHECK_CYCLE) {
|
|
||||||
return fakeChecker();
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
if ((mMode & SetupData.CHECK_AUTODISCOVER) != 0) {
|
if ((mMode & SetupData.CHECK_AUTODISCOVER) != 0) {
|
||||||
if (isCancelled()) return null;
|
if (isCancelled()) return null;
|
||||||
publishProgress(STATE_CHECK_AUTODISCOVER);
|
publishProgress(STATE_CHECK_AUTODISCOVER);
|
||||||
LogUtils.d(Logging.LOG_TAG, "Begin auto-discover for " + mCheckEmail);
|
LogUtils.d(Logging.LOG_TAG, "Begin auto-discover for " + mCheckEmail);
|
||||||
Store store = Store.getInstance(mAccount, mContext);
|
final Store store = Store.getInstance(mAccount, mContext);
|
||||||
Bundle result = store.autoDiscover(mContext, mCheckEmail, mCheckPassword);
|
final Bundle result = store.autoDiscover(mContext, mCheckEmail, mCheckPassword);
|
||||||
// Result will be one of:
|
// Result will be one of:
|
||||||
// null: remote exception - proceed to manual setup
|
// null: remote exception - proceed to manual setup
|
||||||
// MessagingException.AUTHENTICATION_FAILED: username/password rejected
|
// MessagingException.AUTHENTICATION_FAILED: username/password rejected
|
||||||
|
@ -458,7 +446,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
} else if (errorCode != MessagingException.NO_ERROR) {
|
} else if (errorCode != MessagingException.NO_ERROR) {
|
||||||
return new AutoDiscoverResults(false, null);
|
return new AutoDiscoverResults(false, null);
|
||||||
} else {
|
} else {
|
||||||
HostAuth serverInfo = (HostAuth)
|
HostAuth serverInfo =
|
||||||
result.getParcelable(EmailServiceProxy.AUTO_DISCOVER_BUNDLE_HOST_AUTH);
|
result.getParcelable(EmailServiceProxy.AUTO_DISCOVER_BUNDLE_HOST_AUTH);
|
||||||
return new AutoDiscoverResults(false, serverInfo);
|
return new AutoDiscoverResults(false, serverInfo);
|
||||||
}
|
}
|
||||||
|
@ -469,51 +457,52 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
if (isCancelled()) return null;
|
if (isCancelled()) return null;
|
||||||
LogUtils.d(Logging.LOG_TAG, "Begin check of incoming email settings");
|
LogUtils.d(Logging.LOG_TAG, "Begin check of incoming email settings");
|
||||||
publishProgress(STATE_CHECK_INCOMING);
|
publishProgress(STATE_CHECK_INCOMING);
|
||||||
Store store = Store.getInstance(mAccount, mContext);
|
final Store store = Store.getInstance(mAccount, mContext);
|
||||||
Bundle bundle = store.checkSettings();
|
final Bundle bundle = store.checkSettings();
|
||||||
int resultCode = MessagingException.UNSPECIFIED_EXCEPTION;
|
if (bundle == null) {
|
||||||
if (bundle != null) {
|
return new MessagingException(MessagingException.UNSPECIFIED_EXCEPTION);
|
||||||
mAccount.mProtocolVersion = bundle.getString(
|
}
|
||||||
EmailServiceProxy.VALIDATE_BUNDLE_PROTOCOL_VERSION);
|
mAccount.mProtocolVersion = bundle.getString(
|
||||||
resultCode = bundle.getInt(
|
EmailServiceProxy.VALIDATE_BUNDLE_PROTOCOL_VERSION);
|
||||||
EmailServiceProxy.VALIDATE_BUNDLE_RESULT_CODE);
|
int resultCode = bundle.getInt(EmailServiceProxy.VALIDATE_BUNDLE_RESULT_CODE);
|
||||||
final String redirectAddress = bundle.getString(
|
final String redirectAddress = bundle.getString(
|
||||||
EmailServiceProxy.VALIDATE_BUNDLE_REDIRECT_ADDRESS, null);
|
EmailServiceProxy.VALIDATE_BUNDLE_REDIRECT_ADDRESS, null);
|
||||||
if (redirectAddress != null) {
|
if (redirectAddress != null) {
|
||||||
mAccount.mHostAuthRecv.mAddress = redirectAddress;
|
mAccount.mHostAuthRecv.mAddress = redirectAddress;
|
||||||
}
|
}
|
||||||
// Only show "policies required" if this is a new account setup
|
// Only show "policies required" if this is a new account setup
|
||||||
if (resultCode == MessagingException.SECURITY_POLICIES_REQUIRED &&
|
if (resultCode == MessagingException.SECURITY_POLICIES_REQUIRED &&
|
||||||
mAccount.isSaved()) {
|
mAccount.isSaved()) {
|
||||||
resultCode = MessagingException.NO_ERROR;
|
resultCode = MessagingException.NO_ERROR;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (resultCode == MessagingException.SECURITY_POLICIES_REQUIRED) {
|
if (resultCode == MessagingException.SECURITY_POLICIES_REQUIRED) {
|
||||||
SetupData.setPolicy((Policy)bundle.getParcelable(
|
SetupData.setPolicy((Policy)bundle.getParcelable(
|
||||||
EmailServiceProxy.VALIDATE_BUNDLE_POLICY_SET));
|
EmailServiceProxy.VALIDATE_BUNDLE_POLICY_SET));
|
||||||
return new MessagingException(resultCode, mStoreHost);
|
return new MessagingException(resultCode, mStoreHost);
|
||||||
} else if (resultCode == MessagingException.SECURITY_POLICIES_UNSUPPORTED) {
|
} else if (resultCode == MessagingException.SECURITY_POLICIES_UNSUPPORTED) {
|
||||||
Policy policy = (Policy)bundle.getParcelable(
|
final Policy policy = bundle.getParcelable(
|
||||||
EmailServiceProxy.VALIDATE_BUNDLE_POLICY_SET);
|
EmailServiceProxy.VALIDATE_BUNDLE_POLICY_SET);
|
||||||
String unsupported = policy.mProtocolPoliciesUnsupported;
|
final String unsupported = policy.mProtocolPoliciesUnsupported;
|
||||||
String[] data = unsupported.split("" + Policy.POLICY_STRING_DELIMITER);
|
final String[] data =
|
||||||
|
unsupported.split("" + Policy.POLICY_STRING_DELIMITER);
|
||||||
return new MessagingException(resultCode, mStoreHost, data);
|
return new MessagingException(resultCode, mStoreHost, data);
|
||||||
} else if (resultCode != MessagingException.NO_ERROR) {
|
} else if (resultCode != MessagingException.NO_ERROR) {
|
||||||
String errorMessage =
|
final String errorMessage;
|
||||||
bundle.getString(EmailServiceProxy.VALIDATE_BUNDLE_ERROR_MESSAGE);
|
errorMessage = bundle.getString(
|
||||||
|
EmailServiceProxy.VALIDATE_BUNDLE_ERROR_MESSAGE);
|
||||||
return new MessagingException(resultCode, errorMessage);
|
return new MessagingException(resultCode, errorMessage);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
String protocol = mAccount.mHostAuthRecv.mProtocol;
|
final String protocol = mAccount.mHostAuthRecv.mProtocol;
|
||||||
EmailServiceInfo info = EmailServiceUtils.getServiceInfo(mContext, protocol);
|
final EmailServiceInfo info = EmailServiceUtils.getServiceInfo(mContext, protocol);
|
||||||
|
|
||||||
// Check Outgoing Settings
|
// Check Outgoing Settings
|
||||||
if (info.usesSmtp && (mMode & SetupData.CHECK_OUTGOING) != 0) {
|
if (info.usesSmtp && (mMode & SetupData.CHECK_OUTGOING) != 0) {
|
||||||
if (isCancelled()) return null;
|
if (isCancelled()) return null;
|
||||||
LogUtils.d(Logging.LOG_TAG, "Begin check of outgoing email settings");
|
LogUtils.d(Logging.LOG_TAG, "Begin check of outgoing email settings");
|
||||||
publishProgress(STATE_CHECK_OUTGOING);
|
publishProgress(STATE_CHECK_OUTGOING);
|
||||||
Sender sender = Sender.getInstance(mContext, mAccount);
|
final Sender sender = Sender.getInstance(mContext, mAccount);
|
||||||
sender.close();
|
sender.close();
|
||||||
sender.open();
|
sender.open();
|
||||||
sender.close();
|
sender.close();
|
||||||
|
@ -528,53 +517,6 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Dummy background worker, for testing UI only.
|
|
||||||
*/
|
|
||||||
private MessagingException fakeChecker() {
|
|
||||||
// Dummy: Publish a series of progress setups, 2 sec delays between them;
|
|
||||||
// then return "ok" (null)
|
|
||||||
final int DELAY = 2*1000;
|
|
||||||
if (isCancelled()) return null;
|
|
||||||
if ((mMode & SetupData.CHECK_AUTODISCOVER) != 0) {
|
|
||||||
publishProgress(STATE_CHECK_AUTODISCOVER);
|
|
||||||
try {
|
|
||||||
Thread.sleep(DELAY);
|
|
||||||
} catch (InterruptedException e) { }
|
|
||||||
if (DEBUG_FAKE_CHECK_ERR) {
|
|
||||||
return new MessagingException(MessagingException.AUTHENTICATION_FAILED);
|
|
||||||
}
|
|
||||||
// Return "real" AD results
|
|
||||||
HostAuth auth = new HostAuth();
|
|
||||||
auth.setLogin("user", "password");
|
|
||||||
auth.setConnection("eas", "testserver.com", 0);
|
|
||||||
return new AutoDiscoverResults(false, auth);
|
|
||||||
}
|
|
||||||
if (isCancelled()) return null;
|
|
||||||
if ((mMode & SetupData.CHECK_INCOMING) != 0) {
|
|
||||||
publishProgress(STATE_CHECK_INCOMING);
|
|
||||||
try {
|
|
||||||
Thread.sleep(DELAY);
|
|
||||||
} catch (InterruptedException e) { }
|
|
||||||
if (DEBUG_FAKE_CHECK_ERR) {
|
|
||||||
return new MessagingException(MessagingException.IOERROR);
|
|
||||||
} else if (DEBUG_FORCE_SECURITY_REQUIRED) {
|
|
||||||
return new MessagingException(MessagingException.SECURITY_POLICIES_REQUIRED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (isCancelled()) return null;
|
|
||||||
if ((mMode & SetupData.CHECK_OUTGOING) != 0) {
|
|
||||||
publishProgress(STATE_CHECK_OUTGOING);
|
|
||||||
try {
|
|
||||||
Thread.sleep(DELAY);
|
|
||||||
} catch (InterruptedException e) { }
|
|
||||||
if (DEBUG_FAKE_CHECK_ERR) {
|
|
||||||
return new MessagingException(MessagingException.TLS_REQUIRED);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Progress reports (runs in UI thread). This should be used for real progress only
|
* Progress reports (runs in UI thread). This should be used for real progress only
|
||||||
* (not for errors).
|
* (not for errors).
|
||||||
|
@ -601,7 +543,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
reportProgress(STATE_CHECK_OK, null);
|
reportProgress(STATE_CHECK_OK, null);
|
||||||
} else {
|
} else {
|
||||||
int progressState = STATE_CHECK_ERROR;
|
int progressState = STATE_CHECK_ERROR;
|
||||||
int exceptionType = result.getExceptionType();
|
final int exceptionType = result.getExceptionType();
|
||||||
|
|
||||||
switch (exceptionType) {
|
switch (exceptionType) {
|
||||||
// NOTE: AutoDiscover reports have their own reporting state, handle differently
|
// NOTE: AutoDiscover reports have their own reporting state, handle differently
|
||||||
|
@ -664,7 +606,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// Build a string, concatenating policies we don't support
|
// Build a string, concatenating policies we don't support
|
||||||
StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
boolean first = true;
|
boolean first = true;
|
||||||
for (String policyName: unsupportedPolicies) {
|
for (String policyName: unsupportedPolicies) {
|
||||||
if (first) {
|
if (first) {
|
||||||
|
@ -726,7 +668,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
*/
|
*/
|
||||||
public static CheckingDialog newInstance(AccountCheckSettingsFragment parentFragment,
|
public static CheckingDialog newInstance(AccountCheckSettingsFragment parentFragment,
|
||||||
int progress) {
|
int progress) {
|
||||||
CheckingDialog f = new CheckingDialog();
|
final CheckingDialog f = new CheckingDialog();
|
||||||
f.setTargetFragment(parentFragment, progress);
|
f.setTargetFragment(parentFragment, progress);
|
||||||
return f;
|
return f;
|
||||||
}
|
}
|
||||||
|
@ -737,7 +679,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
*/
|
*/
|
||||||
public void updateProgress(int progress) {
|
public void updateProgress(int progress) {
|
||||||
mProgressString = getProgressString(progress);
|
mProgressString = getProgressString(progress);
|
||||||
AlertDialog dialog = (AlertDialog) getDialog();
|
final AlertDialog dialog = (AlertDialog) getDialog();
|
||||||
if (dialog != null && mProgressString != null) {
|
if (dialog != null && mProgressString != null) {
|
||||||
dialog.setMessage(mProgressString);
|
dialog.setMessage(mProgressString);
|
||||||
}
|
}
|
||||||
|
@ -745,7 +687,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
Context context = getActivity();
|
final Context context = getActivity();
|
||||||
if (savedInstanceState != null) {
|
if (savedInstanceState != null) {
|
||||||
mProgressString = savedInstanceState.getString(EXTRA_PROGRESS_STRING);
|
mProgressString = savedInstanceState.getString(EXTRA_PROGRESS_STRING);
|
||||||
}
|
}
|
||||||
|
@ -755,7 +697,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
final AccountCheckSettingsFragment target =
|
final AccountCheckSettingsFragment target =
|
||||||
(AccountCheckSettingsFragment) getTargetFragment();
|
(AccountCheckSettingsFragment) getTargetFragment();
|
||||||
|
|
||||||
ProgressDialog dialog = new ProgressDialog(context);
|
final ProgressDialog dialog = new ProgressDialog(context);
|
||||||
dialog.setIndeterminate(true);
|
dialog.setIndeterminate(true);
|
||||||
dialog.setMessage(mProgressString);
|
dialog.setMessage(mProgressString);
|
||||||
dialog.setButton(DialogInterface.BUTTON_NEGATIVE,
|
dialog.setButton(DialogInterface.BUTTON_NEGATIVE,
|
||||||
|
@ -776,7 +718,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
AccountCheckSettingsFragment target =
|
final AccountCheckSettingsFragment target =
|
||||||
(AccountCheckSettingsFragment) getTargetFragment();
|
(AccountCheckSettingsFragment) getTargetFragment();
|
||||||
target.onCheckingDialogCancel();
|
target.onCheckingDialogCancel();
|
||||||
super.onCancel(dialog);
|
super.onCancel(dialog);
|
||||||
|
@ -829,8 +771,8 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
|
|
||||||
public static ErrorDialog newInstance(Context context, AccountCheckSettingsFragment target,
|
public static ErrorDialog newInstance(Context context, AccountCheckSettingsFragment target,
|
||||||
MessagingException ex) {
|
MessagingException ex) {
|
||||||
ErrorDialog fragment = new ErrorDialog();
|
final ErrorDialog fragment = new ErrorDialog();
|
||||||
Bundle arguments = new Bundle();
|
final Bundle arguments = new Bundle(2);
|
||||||
arguments.putString(ARGS_MESSAGE, getErrorString(context, ex));
|
arguments.putString(ARGS_MESSAGE, getErrorString(context, ex));
|
||||||
arguments.putInt(ARGS_EXCEPTION_ID, ex.getExceptionType());
|
arguments.putInt(ARGS_EXCEPTION_ID, ex.getExceptionType());
|
||||||
fragment.setArguments(arguments);
|
fragment.setArguments(arguments);
|
||||||
|
@ -847,7 +789,7 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
final AccountCheckSettingsFragment target =
|
final AccountCheckSettingsFragment target =
|
||||||
(AccountCheckSettingsFragment) getTargetFragment();
|
(AccountCheckSettingsFragment) getTargetFragment();
|
||||||
|
|
||||||
AlertDialog.Builder builder = new AlertDialog.Builder(context)
|
final AlertDialog.Builder builder = new AlertDialog.Builder(context)
|
||||||
.setIconAttribute(android.R.attr.alertDialogIcon)
|
.setIconAttribute(android.R.attr.alertDialogIcon)
|
||||||
.setTitle(context.getString(R.string.account_setup_failed_dlg_title))
|
.setTitle(context.getString(R.string.account_setup_failed_dlg_title))
|
||||||
.setMessage(message)
|
.setMessage(message)
|
||||||
|
@ -915,8 +857,8 @@ public class AccountCheckSettingsFragment extends Fragment {
|
||||||
|
|
||||||
public static SecurityRequiredDialog newInstance(AccountCheckSettingsFragment target,
|
public static SecurityRequiredDialog newInstance(AccountCheckSettingsFragment target,
|
||||||
String hostName) {
|
String hostName) {
|
||||||
SecurityRequiredDialog fragment = new SecurityRequiredDialog();
|
final SecurityRequiredDialog fragment = new SecurityRequiredDialog();
|
||||||
Bundle arguments = new Bundle();
|
final Bundle arguments = new Bundle(1);
|
||||||
arguments.putString(ARGS_HOST_NAME, hostName);
|
arguments.putString(ARGS_HOST_NAME, hostName);
|
||||||
fragment.setArguments(arguments);
|
fragment.setArguments(arguments);
|
||||||
fragment.setTargetFragment(target, 0);
|
fragment.setTargetFragment(target, 0);
|
||||||
|
|
|
@ -51,6 +51,7 @@ import com.android.emailcommon.provider.Account;
|
||||||
import com.android.emailcommon.provider.EmailContent;
|
import com.android.emailcommon.provider.EmailContent;
|
||||||
import com.android.emailcommon.provider.HostAuth;
|
import com.android.emailcommon.provider.HostAuth;
|
||||||
import com.android.emailcommon.service.ServiceProxy;
|
import com.android.emailcommon.service.ServiceProxy;
|
||||||
|
import com.android.emailcommon.utility.EmailAsyncTask;
|
||||||
import com.android.emailcommon.utility.Utility;
|
import com.android.emailcommon.utility.Utility;
|
||||||
import com.android.mail.utils.LogUtils;
|
import com.android.mail.utils.LogUtils;
|
||||||
|
|
||||||
|
@ -123,13 +124,13 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
FutureTask<String> mOwnerLookupTask;
|
FutureTask<String> mOwnerLookupTask;
|
||||||
|
|
||||||
public static void actionNewAccount(Activity fromActivity) {
|
public static void actionNewAccount(Activity fromActivity) {
|
||||||
Intent i = new Intent(fromActivity, AccountSetupBasics.class);
|
final Intent i = new Intent(fromActivity, AccountSetupBasics.class);
|
||||||
i.putExtra(EXTRA_FLOW_MODE, SetupData.FLOW_MODE_NORMAL);
|
i.putExtra(EXTRA_FLOW_MODE, SetupData.FLOW_MODE_NORMAL);
|
||||||
fromActivity.startActivity(i);
|
fromActivity.startActivity(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void actionNewAccountWithResult(Activity fromActivity) {
|
public static void actionNewAccountWithResult(Activity fromActivity) {
|
||||||
Intent i = new ForwardingIntent(fromActivity, AccountSetupBasics.class);
|
final Intent i = new ForwardingIntent(fromActivity, AccountSetupBasics.class);
|
||||||
i.putExtra(EXTRA_FLOW_MODE, SetupData.FLOW_MODE_NO_ACCOUNTS);
|
i.putExtra(EXTRA_FLOW_MODE, SetupData.FLOW_MODE_NO_ACCOUNTS);
|
||||||
fromActivity.startActivity(i);
|
fromActivity.startActivity(i);
|
||||||
}
|
}
|
||||||
|
@ -139,7 +140,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
* for exchange accounts.
|
* for exchange accounts.
|
||||||
*/
|
*/
|
||||||
public static Intent actionGetCreateAccountIntent(Context context, String accountManagerType) {
|
public static Intent actionGetCreateAccountIntent(Context context, String accountManagerType) {
|
||||||
Intent i = new Intent(context, AccountSetupBasics.class);
|
final Intent i = new Intent(context, AccountSetupBasics.class);
|
||||||
i.putExtra(EXTRA_FLOW_MODE, SetupData.FLOW_MODE_ACCOUNT_MANAGER);
|
i.putExtra(EXTRA_FLOW_MODE, SetupData.FLOW_MODE_ACCOUNT_MANAGER);
|
||||||
i.putExtra(EXTRA_FLOW_ACCOUNT_TYPE, accountManagerType);
|
i.putExtra(EXTRA_FLOW_ACCOUNT_TYPE, accountManagerType);
|
||||||
return i;
|
return i;
|
||||||
|
@ -150,7 +151,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
// is not safe, since it's not guaranteed that an Activity will run with the Intent, and
|
// is not safe, since it's not guaranteed that an Activity will run with the Intent, and
|
||||||
// information can get lost.
|
// information can get lost.
|
||||||
|
|
||||||
Intent i= new ForwardingIntent(fromActivity, AccountSetupBasics.class);
|
final Intent i= new ForwardingIntent(fromActivity, AccountSetupBasics.class);
|
||||||
// If we're in the "account flow" (from AccountManager), we want to return to the caller
|
// If we're in the "account flow" (from AccountManager), we want to return to the caller
|
||||||
// (in the settings app)
|
// (in the settings app)
|
||||||
SetupData.init(SetupData.FLOW_MODE_RETURN_TO_CALLER);
|
SetupData.init(SetupData.FLOW_MODE_RETURN_TO_CALLER);
|
||||||
|
@ -163,27 +164,20 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
// is not safe, since it's not guaranteed that an Activity will run with the Intent, and
|
// is not safe, since it's not guaranteed that an Activity will run with the Intent, and
|
||||||
// information can get lost.
|
// information can get lost.
|
||||||
|
|
||||||
Intent i= new ForwardingIntent(fromActivity, AccountSetupBasics.class);
|
final Intent i= new ForwardingIntent(fromActivity, AccountSetupBasics.class);
|
||||||
// If we're in the "no accounts" flow, we want to return to the caller with a result
|
// If we're in the "no accounts" flow, we want to return to the caller with a result
|
||||||
SetupData.init(SetupData.FLOW_MODE_RETURN_NO_ACCOUNTS_RESULT);
|
SetupData.init(SetupData.FLOW_MODE_RETURN_NO_ACCOUNTS_RESULT);
|
||||||
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
i.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
fromActivity.startActivity(i);
|
fromActivity.startActivity(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("deprecation")
|
public static void actionAccountCreateFinished(final Activity fromActivity, Account account) {
|
||||||
public static void actionAccountCreateFinished(final Activity fromActivity,
|
final Intent i = new Intent(fromActivity, AccountSetupBasics.class);
|
||||||
final long accountId) {
|
// If we're not in the "account flow" (from AccountManager), we want to show the
|
||||||
Utility.runAsync(new Runnable() {
|
// message list for the new inbox
|
||||||
@Override
|
SetupData.init(SetupData.FLOW_MODE_RETURN_TO_MESSAGE_LIST, account);
|
||||||
public void run() {
|
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
||||||
Intent i = new Intent(fromActivity, AccountSetupBasics.class);
|
fromActivity.startActivity(i);
|
||||||
// If we're not in the "account flow" (from AccountManager), we want to show the
|
|
||||||
// message list for the new inbox
|
|
||||||
Account account = Account.restoreAccountWithId(fromActivity, accountId);
|
|
||||||
SetupData.init(SetupData.FLOW_MODE_RETURN_TO_MESSAGE_LIST, account);
|
|
||||||
i.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
|
|
||||||
fromActivity.startActivity(i);
|
|
||||||
}});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -193,28 +187,27 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
|
|
||||||
// Check for forced account creation first, as it comes from an externally-generated
|
// Check for forced account creation first, as it comes from an externally-generated
|
||||||
// intent and won't have any SetupData prepared.
|
// intent and won't have any SetupData prepared.
|
||||||
Intent intent = getIntent();
|
final Intent intent = getIntent();
|
||||||
String action = intent.getAction();
|
final String action = intent.getAction();
|
||||||
|
|
||||||
SetupData intentData = null;
|
|
||||||
// See if we have SetupData to restore; if so, use it
|
// See if we have SetupData to restore; if so, use it
|
||||||
if (savedInstanceState != null) {
|
final SetupData intentData = (SetupData) ((savedInstanceState != null)
|
||||||
intentData = savedInstanceState.getParcelable(STATE_KEY_SETUP_DATA);
|
? savedInstanceState.getParcelable(STATE_KEY_SETUP_DATA)
|
||||||
}
|
: null);
|
||||||
if (intentData != null) {
|
if (intentData != null) {
|
||||||
SetupData.init(intentData);
|
SetupData.init(intentData);
|
||||||
} else if (ServiceProxy.getIntentStringForEmailPackage(
|
} else if (ServiceProxy.getIntentStringForEmailPackage(
|
||||||
this, ACTION_CREATE_ACCOUNT).equals(action)) {
|
this, ACTION_CREATE_ACCOUNT).equals(action)) {
|
||||||
SetupData.init(SetupData.FLOW_MODE_FORCE_CREATE);
|
SetupData.init(SetupData.FLOW_MODE_FORCE_CREATE);
|
||||||
} else {
|
} else {
|
||||||
int intentFlowMode =
|
final int intentFlowMode =
|
||||||
intent.getIntExtra(EXTRA_FLOW_MODE, SetupData.FLOW_MODE_UNSPECIFIED);
|
intent.getIntExtra(EXTRA_FLOW_MODE, SetupData.FLOW_MODE_UNSPECIFIED);
|
||||||
if (intentFlowMode != SetupData.FLOW_MODE_UNSPECIFIED) {
|
if (intentFlowMode != SetupData.FLOW_MODE_UNSPECIFIED) {
|
||||||
SetupData.init(intentFlowMode, intent.getStringExtra(EXTRA_FLOW_ACCOUNT_TYPE));
|
SetupData.init(intentFlowMode, intent.getStringExtra(EXTRA_FLOW_ACCOUNT_TYPE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int flowMode = SetupData.getFlowMode();
|
final int flowMode = SetupData.getFlowMode();
|
||||||
if (flowMode == SetupData.FLOW_MODE_RETURN_TO_CALLER) {
|
if (flowMode == SetupData.FLOW_MODE_RETURN_TO_CALLER) {
|
||||||
// Return to the caller who initiated account creation
|
// Return to the caller who initiated account creation
|
||||||
finish();
|
finish();
|
||||||
|
@ -228,7 +221,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
} else if (flowMode == SetupData.FLOW_MODE_RETURN_TO_MESSAGE_LIST) {
|
} else if (flowMode == SetupData.FLOW_MODE_RETURN_TO_MESSAGE_LIST) {
|
||||||
Account account = SetupData.getAccount();
|
final Account account = SetupData.getAccount();
|
||||||
if (account != null && account.mId >= 0) {
|
if (account != null && account.mId >= 0) {
|
||||||
// Show the message list for the new account
|
// Show the message list for the new account
|
||||||
//***
|
//***
|
||||||
|
@ -240,18 +233,16 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
|
|
||||||
setContentView(R.layout.account_setup_basics);
|
setContentView(R.layout.account_setup_basics);
|
||||||
|
|
||||||
mEmailView = (EditText) UiUtilities.getView(this, R.id.account_email);
|
mEmailView = UiUtilities.getView(this, R.id.account_email);
|
||||||
mPasswordView = (EditText) UiUtilities.getView(this, R.id.account_password);
|
mPasswordView = UiUtilities.getView(this, R.id.account_password);
|
||||||
|
|
||||||
mEmailView.addTextChangedListener(this);
|
mEmailView.addTextChangedListener(this);
|
||||||
mPasswordView.addTextChangedListener(this);
|
mPasswordView.addTextChangedListener(this);
|
||||||
|
|
||||||
boolean manualButtonDisplayed = true;
|
|
||||||
|
|
||||||
// Configure buttons
|
// Configure buttons
|
||||||
mManualButton = (Button) UiUtilities.getView(this, R.id.manual_setup);
|
mManualButton = UiUtilities.getView(this, R.id.manual_setup);
|
||||||
mNextButton = (Button) UiUtilities.getView(this, R.id.next);
|
mNextButton = UiUtilities.getView(this, R.id.next);
|
||||||
mManualButton.setVisibility(manualButtonDisplayed ? View.VISIBLE : View.INVISIBLE);
|
mManualButton.setVisibility(View.VISIBLE);
|
||||||
mManualButton.setOnClickListener(this);
|
mManualButton.setOnClickListener(this);
|
||||||
mNextButton.setOnClickListener(this);
|
mNextButton.setOnClickListener(this);
|
||||||
// Force disabled until validator notifies otherwise
|
// Force disabled until validator notifies otherwise
|
||||||
|
@ -260,7 +251,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
mNextButtonInhibit = false;
|
mNextButtonInhibit = false;
|
||||||
|
|
||||||
// Set aside incoming AccountAuthenticatorResponse, if there was any
|
// Set aside incoming AccountAuthenticatorResponse, if there was any
|
||||||
AccountAuthenticatorResponse authenticatorResponse =
|
final AccountAuthenticatorResponse authenticatorResponse =
|
||||||
getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
|
getIntent().getParcelableExtra(AccountManager.KEY_ACCOUNT_AUTHENTICATOR_RESPONSE);
|
||||||
SetupData.setAccountAuthenticatorResponse(authenticatorResponse);
|
SetupData.setAccountAuthenticatorResponse(authenticatorResponse);
|
||||||
if (authenticatorResponse != null) {
|
if (authenticatorResponse != null) {
|
||||||
|
@ -273,12 +264,12 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load fields, but only once
|
// Load fields, but only once
|
||||||
String userName = SetupData.getUsername();
|
final String userName = SetupData.getUsername();
|
||||||
if (userName != null) {
|
if (userName != null) {
|
||||||
mEmailView.setText(userName);
|
mEmailView.setText(userName);
|
||||||
SetupData.setUsername(null);
|
SetupData.setUsername(null);
|
||||||
}
|
}
|
||||||
String password = SetupData.getPassword();
|
final String password = SetupData.getPassword();
|
||||||
if (userName != null) {
|
if (userName != null) {
|
||||||
mPasswordView.setText(password);
|
mPasswordView.setText(password);
|
||||||
SetupData.setPassword(null);
|
SetupData.setPassword(null);
|
||||||
|
@ -294,10 +285,10 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
finish();
|
finish();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String email = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_EMAIL);
|
final String email = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_EMAIL);
|
||||||
String user = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_USER);
|
final String user = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_USER);
|
||||||
String incoming = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_INCOMING);
|
final String incoming = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_INCOMING);
|
||||||
String outgoing = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_OUTGOING);
|
final String outgoing = intent.getStringExtra(EXTRA_CREATE_ACCOUNT_OUTGOING);
|
||||||
if (TextUtils.isEmpty(email) || TextUtils.isEmpty(user) ||
|
if (TextUtils.isEmpty(email) || TextUtils.isEmpty(user) ||
|
||||||
TextUtils.isEmpty(incoming) || TextUtils.isEmpty(outgoing)) {
|
TextUtils.isEmpty(incoming) || TextUtils.isEmpty(outgoing)) {
|
||||||
LogUtils.e(Logging.LOG_TAG, "ERROR: Force account create requires extras EMAIL, " +
|
LogUtils.e(Logging.LOG_TAG, "ERROR: Force account create requires extras EMAIL, " +
|
||||||
|
@ -317,7 +308,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
// Launch a worker to look up the owner name. It should be ready well in advance of
|
// Launch a worker to look up the owner name. It should be ready well in advance of
|
||||||
// the time the user clicks next or manual.
|
// the time the user clicks next or manual.
|
||||||
mOwnerLookupTask = new FutureTask<String>(mOwnerLookupCallable);
|
mOwnerLookupTask = new FutureTask<String>(mOwnerLookupCallable);
|
||||||
Utility.runAsync(mOwnerLookupTask);
|
EmailAsyncTask.runAsyncParallel(mOwnerLookupTask);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -337,7 +328,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
// If the account manager initiated the creation, and success was not reported,
|
// If the account manager initiated the creation, and success was not reported,
|
||||||
// then we assume that we're giving up (for any reason) - report failure.
|
// then we assume that we're giving up (for any reason) - report failure.
|
||||||
if (mReportAccountAuthenticatorError) {
|
if (mReportAccountAuthenticatorError) {
|
||||||
AccountAuthenticatorResponse authenticatorResponse =
|
final AccountAuthenticatorResponse authenticatorResponse =
|
||||||
SetupData.getAccountAuthenticatorResponse();
|
SetupData.getAccountAuthenticatorResponse();
|
||||||
if (authenticatorResponse != null) {
|
if (authenticatorResponse != null) {
|
||||||
authenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED, "canceled");
|
authenticatorResponse.onError(AccountManager.ERROR_CODE_CANCELED, "canceled");
|
||||||
|
@ -399,8 +390,8 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateFields() {
|
private void validateFields() {
|
||||||
boolean valid = Utility.isTextViewNotEmpty(mEmailView)
|
final boolean valid = !TextUtils.isEmpty(mEmailView.getText())
|
||||||
&& Utility.isTextViewNotEmpty(mPasswordView)
|
&& !TextUtils.isEmpty(mPasswordView.getText())
|
||||||
&& mEmailValidator.isValid(mEmailView.getText().toString().trim());
|
&& mEmailValidator.isValid(mEmailView.getText().toString().trim());
|
||||||
onEnableProceedButtons(valid);
|
onEnableProceedButtons(valid);
|
||||||
|
|
||||||
|
@ -412,13 +403,13 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
* Return an existing username if found, or null. This is the result of the Callable (below).
|
* Return an existing username if found, or null. This is the result of the Callable (below).
|
||||||
*/
|
*/
|
||||||
private String getOwnerName() {
|
private String getOwnerName() {
|
||||||
String result = null;
|
|
||||||
try {
|
try {
|
||||||
result = mOwnerLookupTask.get();
|
return mOwnerLookupTask.get();
|
||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
|
return null;
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -448,22 +439,22 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
* Finish the auto setup process, in some cases after showing a warning dialog.
|
* Finish the auto setup process, in some cases after showing a warning dialog.
|
||||||
*/
|
*/
|
||||||
private void finishAutoSetup() {
|
private void finishAutoSetup() {
|
||||||
String email = mEmailView.getText().toString().trim();
|
final String email = mEmailView.getText().toString().trim();
|
||||||
String password = mPasswordView.getText().toString();
|
final String password = mPasswordView.getText().toString();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
mProvider.expandTemplates(email);
|
mProvider.expandTemplates(email);
|
||||||
|
|
||||||
Account account = SetupData.getAccount();
|
final Account account = SetupData.getAccount();
|
||||||
HostAuth recvAuth = account.getOrCreateHostAuthRecv(this);
|
final HostAuth recvAuth = account.getOrCreateHostAuthRecv(this);
|
||||||
HostAuth.setHostAuthFromString(recvAuth, mProvider.incomingUri);
|
HostAuth.setHostAuthFromString(recvAuth, mProvider.incomingUri);
|
||||||
|
|
||||||
recvAuth.setLogin(mProvider.incomingUsername, password);
|
recvAuth.setLogin(mProvider.incomingUsername, password);
|
||||||
EmailServiceInfo info = EmailServiceUtils.getServiceInfo(this, recvAuth.mProtocol);
|
final EmailServiceInfo info = EmailServiceUtils.getServiceInfo(this, recvAuth.mProtocol);
|
||||||
recvAuth.mPort =
|
recvAuth.mPort =
|
||||||
((recvAuth.mFlags & HostAuth.FLAG_SSL) != 0) ? info.portSsl : info.port;
|
((recvAuth.mFlags & HostAuth.FLAG_SSL) != 0) ? info.portSsl : info.port;
|
||||||
|
|
||||||
HostAuth sendAuth = account.getOrCreateHostAuthSend(this);
|
final HostAuth sendAuth = account.getOrCreateHostAuthSend(this);
|
||||||
HostAuth.setHostAuthFromString(sendAuth, mProvider.outgoingUri);
|
HostAuth.setHostAuthFromString(sendAuth, mProvider.outgoingUri);
|
||||||
sendAuth.setLogin(mProvider.outgoingUsername, password);
|
sendAuth.setLogin(mProvider.outgoingUsername, password);
|
||||||
|
|
||||||
|
@ -504,9 +495,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Account doInBackground(Void... params) {
|
protected Account doInBackground(Void... params) {
|
||||||
Account account = Utility.findExistingAccount(mContext, -1,
|
return Utility.findExistingAccount(mContext, -1, mCheckHost, mCheckLogin);
|
||||||
mCheckHost, mCheckLogin);
|
|
||||||
return account;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -516,15 +505,14 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
if (mPaused) return;
|
if (mPaused) return;
|
||||||
// Show duplicate account warning, or proceed
|
// Show duplicate account warning, or proceed
|
||||||
if (duplicateAccount != null) {
|
if (duplicateAccount != null) {
|
||||||
DuplicateAccountDialogFragment dialogFragment =
|
final DuplicateAccountDialogFragment dialogFragment =
|
||||||
DuplicateAccountDialogFragment.newInstance(duplicateAccount.mDisplayName);
|
DuplicateAccountDialogFragment.newInstance(duplicateAccount.mDisplayName);
|
||||||
dialogFragment.show(getFragmentManager(), DuplicateAccountDialogFragment.TAG);
|
dialogFragment.show(getFragmentManager(), DuplicateAccountDialogFragment.TAG);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
AccountCheckSettingsFragment checkerFragment =
|
final AccountCheckSettingsFragment checkerFragment =
|
||||||
AccountCheckSettingsFragment.newInstance(
|
AccountCheckSettingsFragment.newInstance(
|
||||||
SetupData.CHECK_INCOMING | SetupData.CHECK_OUTGOING, null);
|
SetupData.CHECK_INCOMING | SetupData.CHECK_OUTGOING, null);
|
||||||
FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
final FragmentTransaction transaction = getFragmentManager().beginTransaction();
|
||||||
transaction.add(checkerFragment, AccountCheckSettingsFragment.TAG);
|
transaction.add(checkerFragment, AccountCheckSettingsFragment.TAG);
|
||||||
transaction.addToBackStack("back");
|
transaction.addToBackStack("back");
|
||||||
transaction.commit();
|
transaction.commit();
|
||||||
|
@ -537,14 +525,14 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
*/
|
*/
|
||||||
private void onNext() {
|
private void onNext() {
|
||||||
// Try auto-configuration from XML providers (unless in EAS mode, we can skip it)
|
// Try auto-configuration from XML providers (unless in EAS mode, we can skip it)
|
||||||
String email = mEmailView.getText().toString().trim();
|
final String email = mEmailView.getText().toString().trim();
|
||||||
String[] emailParts = email.split("@");
|
final String[] emailParts = email.split("@");
|
||||||
String domain = emailParts[1].trim();
|
final String domain = emailParts[1].trim();
|
||||||
mProvider = AccountSettingsUtils.findProviderForDomain(this, domain);
|
mProvider = AccountSettingsUtils.findProviderForDomain(this, domain);
|
||||||
if (mProvider != null) {
|
if (mProvider != null) {
|
||||||
mProvider.expandTemplates(email);
|
mProvider.expandTemplates(email);
|
||||||
if (mProvider.note != null) {
|
if (mProvider.note != null) {
|
||||||
NoteDialogFragment dialogFragment =
|
final NoteDialogFragment dialogFragment =
|
||||||
NoteDialogFragment.newInstance(mProvider.note);
|
NoteDialogFragment.newInstance(mProvider.note);
|
||||||
dialogFragment.show(getFragmentManager(), NoteDialogFragment.TAG);
|
dialogFragment.show(getFragmentManager(), NoteDialogFragment.TAG);
|
||||||
} else {
|
} else {
|
||||||
|
@ -564,11 +552,11 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
* Ignored for IMAP & POP accounts.
|
* Ignored for IMAP & POP accounts.
|
||||||
*/
|
*/
|
||||||
private void onManualSetup(boolean allowAutoDiscover) {
|
private void onManualSetup(boolean allowAutoDiscover) {
|
||||||
String email = mEmailView.getText().toString().trim();
|
final String email = mEmailView.getText().toString().trim();
|
||||||
String password = mPasswordView.getText().toString();
|
final String password = mPasswordView.getText().toString();
|
||||||
String[] emailParts = email.split("@");
|
final String[] emailParts = email.split("@");
|
||||||
String user = emailParts[0].trim();
|
final String user = emailParts[0].trim();
|
||||||
String domain = emailParts[1].trim();
|
final String domain = emailParts[1].trim();
|
||||||
|
|
||||||
// Alternate entry to the debug options screen (for devices without a physical keyboard:
|
// Alternate entry to the debug options screen (for devices without a physical keyboard:
|
||||||
// Username: d@d.d
|
// Username: d@d.d
|
||||||
|
@ -580,12 +568,12 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Account account = SetupData.getAccount();
|
final Account account = SetupData.getAccount();
|
||||||
HostAuth recvAuth = account.getOrCreateHostAuthRecv(this);
|
final HostAuth recvAuth = account.getOrCreateHostAuthRecv(this);
|
||||||
recvAuth.setLogin(user, password);
|
recvAuth.setLogin(user, password);
|
||||||
recvAuth.setConnection(null, domain, HostAuth.PORT_UNKNOWN, HostAuth.FLAG_NONE);
|
recvAuth.setConnection(null, domain, HostAuth.PORT_UNKNOWN, HostAuth.FLAG_NONE);
|
||||||
|
|
||||||
HostAuth sendAuth = account.getOrCreateHostAuthSend(this);
|
final HostAuth sendAuth = account.getOrCreateHostAuthSend(this);
|
||||||
sendAuth.setLogin(user, password);
|
sendAuth.setLogin(user, password);
|
||||||
sendAuth.setConnection(null, domain, HostAuth.PORT_UNKNOWN, HostAuth.FLAG_NONE);
|
sendAuth.setConnection(null, domain, HostAuth.PORT_UNKNOWN, HostAuth.FLAG_NONE);
|
||||||
|
|
||||||
|
@ -609,10 +597,10 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
private void forceCreateAccount(String email, String user, String incoming, String outgoing) {
|
private void forceCreateAccount(String email, String user, String incoming, String outgoing) {
|
||||||
Account account = SetupData.getAccount();
|
Account account = SetupData.getAccount();
|
||||||
try {
|
try {
|
||||||
HostAuth recvAuth = account.getOrCreateHostAuthRecv(this);
|
final HostAuth recvAuth = account.getOrCreateHostAuthRecv(this);
|
||||||
HostAuth.setHostAuthFromString(recvAuth, incoming);
|
HostAuth.setHostAuthFromString(recvAuth, incoming);
|
||||||
|
|
||||||
HostAuth sendAuth = account.getOrCreateHostAuthSend(this);
|
final HostAuth sendAuth = account.getOrCreateHostAuthSend(this);
|
||||||
HostAuth.setHostAuthFromString(sendAuth, outgoing);
|
HostAuth.setHostAuthFromString(sendAuth, outgoing);
|
||||||
|
|
||||||
populateSetupData(user, email);
|
populateSetupData(user, email);
|
||||||
|
@ -624,9 +612,9 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setDefaultsForProtocol(Context context, Account account) {
|
public static void setDefaultsForProtocol(Context context, Account account) {
|
||||||
String protocol = account.mHostAuthRecv.mProtocol;
|
final String protocol = account.mHostAuthRecv.mProtocol;
|
||||||
if (protocol == null) return;
|
if (protocol == null) return;
|
||||||
EmailServiceInfo info = EmailServiceUtils.getServiceInfo(context, protocol);
|
final EmailServiceInfo info = EmailServiceUtils.getServiceInfo(context, protocol);
|
||||||
account.mSyncInterval = info.defaultSyncInterval;
|
account.mSyncInterval = info.defaultSyncInterval;
|
||||||
account.mSyncLookback = info.defaultLookback;
|
account.mSyncLookback = info.defaultLookback;
|
||||||
if (info.offerLocalDeletes) {
|
if (info.offerLocalDeletes) {
|
||||||
|
@ -638,7 +626,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
* Populate SetupData's account with complete setup info.
|
* Populate SetupData's account with complete setup info.
|
||||||
*/
|
*/
|
||||||
private void populateSetupData(String senderName, String senderEmail) {
|
private void populateSetupData(String senderName, String senderEmail) {
|
||||||
Account account = SetupData.getAccount();
|
final Account account = SetupData.getAccount();
|
||||||
account.setSenderName(senderName);
|
account.setSenderName(senderName);
|
||||||
account.setEmailAddress(senderEmail);
|
account.setEmailAddress(senderEmail);
|
||||||
account.setDisplayName(senderEmail);
|
account.setDisplayName(senderEmail);
|
||||||
|
@ -692,8 +680,8 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
* Create the dialog with parameters
|
* Create the dialog with parameters
|
||||||
*/
|
*/
|
||||||
public static NoteDialogFragment newInstance(String note) {
|
public static NoteDialogFragment newInstance(String note) {
|
||||||
NoteDialogFragment f = new NoteDialogFragment();
|
final NoteDialogFragment f = new NoteDialogFragment();
|
||||||
Bundle b = new Bundle();
|
final Bundle b = new Bundle(1);
|
||||||
b.putString(BUNDLE_KEY_NOTE, note);
|
b.putString(BUNDLE_KEY_NOTE, note);
|
||||||
f.setArguments(b);
|
f.setArguments(b);
|
||||||
return f;
|
return f;
|
||||||
|
@ -701,7 +689,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||||
Context context = getActivity();
|
final Context context = getActivity();
|
||||||
final String note = getArguments().getString(BUNDLE_KEY_NOTE);
|
final String note = getArguments().getString(BUNDLE_KEY_NOTE);
|
||||||
|
|
||||||
return new AlertDialog.Builder(context)
|
return new AlertDialog.Builder(context)
|
||||||
|
@ -713,7 +701,7 @@ public class AccountSetupBasics extends AccountSetupActivity
|
||||||
new DialogInterface.OnClickListener() {
|
new DialogInterface.OnClickListener() {
|
||||||
@Override
|
@Override
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
Activity a = getActivity();
|
final Activity a = getActivity();
|
||||||
if (a instanceof AccountSetupBasics) {
|
if (a instanceof AccountSetupBasics) {
|
||||||
((AccountSetupBasics)a).finishAutoSetup();
|
((AccountSetupBasics)a).finishAutoSetup();
|
||||||
}
|
}
|
||||||
|
|
|
@ -409,8 +409,8 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment
|
||||||
*/
|
*/
|
||||||
private void validateFields() {
|
private void validateFields() {
|
||||||
if (!mLoaded) return;
|
if (!mLoaded) return;
|
||||||
boolean enabled = Utility.isTextViewNotEmpty(mUsernameView)
|
final boolean enabled = !TextUtils.isEmpty(mUsernameView.getText())
|
||||||
&& Utility.isTextViewNotEmpty(mPasswordView)
|
&& !TextUtils.isEmpty(mPasswordView.getText())
|
||||||
&& Utility.isServerNameValid(mServerView)
|
&& Utility.isServerNameValid(mServerView)
|
||||||
&& Utility.isPortFieldValid(mPortView);
|
&& Utility.isPortFieldValid(mPortView);
|
||||||
enableNextButton(enabled);
|
enableNextButton(enabled);
|
||||||
|
|
|
@ -67,10 +67,10 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
ActivityHelper.debugSetWindowFlags(this);
|
ActivityHelper.debugSetWindowFlags(this);
|
||||||
setContentView(R.layout.account_setup_names);
|
setContentView(R.layout.account_setup_names);
|
||||||
mDescription = (EditText) UiUtilities.getView(this, R.id.account_description);
|
mDescription = UiUtilities.getView(this, R.id.account_description);
|
||||||
mName = (EditText) UiUtilities.getView(this, R.id.account_name);
|
mName = UiUtilities.getView(this, R.id.account_name);
|
||||||
View accountNameLabel = UiUtilities.getView(this, R.id.account_name_label);
|
View accountNameLabel = UiUtilities.getView(this, R.id.account_name_label);
|
||||||
mNextButton = (Button) UiUtilities.getView(this, R.id.next);
|
mNextButton = UiUtilities.getView(this, R.id.next);
|
||||||
mNextButton.setOnClickListener(this);
|
mNextButton.setOnClickListener(this);
|
||||||
|
|
||||||
TextWatcher validationTextWatcher = new TextWatcher() {
|
TextWatcher validationTextWatcher = new TextWatcher() {
|
||||||
|
@ -199,7 +199,7 @@ public class AccountSetupNames extends AccountSetupActivity implements OnClickLi
|
||||||
} else {
|
} else {
|
||||||
Account account = SetupData.getAccount();
|
Account account = SetupData.getAccount();
|
||||||
if (account != null) {
|
if (account != null) {
|
||||||
AccountSetupBasics.actionAccountCreateFinished(this, account.mId);
|
AccountSetupBasics.actionAccountCreateFinished(this, account);
|
||||||
} else {
|
} else {
|
||||||
// Safety check here; If mAccount is null (due to external issues or bugs)
|
// Safety check here; If mAccount is null (due to external issues or bugs)
|
||||||
// just rewind back to Welcome, which can handle any configuration of accounts
|
// just rewind back to Welcome, which can handle any configuration of accounts
|
||||||
|
|
|
@ -20,6 +20,7 @@ import android.app.Activity;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.text.Editable;
|
import android.text.Editable;
|
||||||
|
import android.text.TextUtils;
|
||||||
import android.text.TextWatcher;
|
import android.text.TextWatcher;
|
||||||
import android.text.method.DigitsKeyListener;
|
import android.text.method.DigitsKeyListener;
|
||||||
import android.view.LayoutInflater;
|
import android.view.LayoutInflater;
|
||||||
|
@ -307,8 +308,8 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
|
||||||
Utility.isServerNameValid(mServerView) && Utility.isPortFieldValid(mPortView);
|
Utility.isServerNameValid(mServerView) && Utility.isPortFieldValid(mPortView);
|
||||||
|
|
||||||
if (enabled && mRequireLoginView.isChecked()) {
|
if (enabled && mRequireLoginView.isChecked()) {
|
||||||
enabled = (Utility.isTextViewNotEmpty(mUsernameView)
|
enabled = !TextUtils.isEmpty(mUsernameView.getText())
|
||||||
&& Utility.isTextViewNotEmpty(mPasswordView));
|
&& !TextUtils.isEmpty(mPasswordView.getText());
|
||||||
}
|
}
|
||||||
enableNextButton(enabled);
|
enableNextButton(enabled);
|
||||||
// Warn (but don't prevent) if password has leading/trailing spaces
|
// Warn (but don't prevent) if password has leading/trailing spaces
|
||||||
|
|
Loading…
Reference in New Issue