am 9c0463e6
: Don\'t offer oauth unless we have at least one provider
* commit '9c0463e6b485b3b50d9c6f110a9ece650cd4a692': Don't offer oauth unless we have at least one provider
This commit is contained in:
commit
b63b39d03e
@ -79,6 +79,7 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment
|
||||
private boolean mOfferOAuth;
|
||||
private boolean mOfferCerts;
|
||||
private String mProviderId;
|
||||
List<OAuthProvider> mOauthProviders;
|
||||
|
||||
private Context mAppContext;
|
||||
|
||||
@ -168,16 +169,22 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment
|
||||
mAppContext = getActivity().getApplicationContext();
|
||||
mEmailAddress = getArguments().getString(EXTRA_EMAIL);
|
||||
final String protocol = getArguments().getString(EXTRA_PROTOCOL);
|
||||
// TODO: for now, we might not know what protocol we're using, so just default to
|
||||
// offering oauth
|
||||
mOfferOAuth = true;
|
||||
mOauthProviders = AccountSettingsUtils.getAllOAuthProviders(mAppContext);
|
||||
mOfferCerts = true;
|
||||
if (protocol != null) {
|
||||
final EmailServiceInfo info = EmailServiceUtils.getServiceInfo(mAppContext, protocol);
|
||||
if (info != null) {
|
||||
mOfferOAuth = info.offerOAuth;
|
||||
if (mOauthProviders.size() > 0) {
|
||||
mOfferOAuth = info.offerOAuth;
|
||||
}
|
||||
mOfferCerts = info.offerCerts;
|
||||
}
|
||||
} else {
|
||||
// For now, we might not know what protocol we're using, so just default to
|
||||
// offering oauth
|
||||
if (mOauthProviders.size() > 0) {
|
||||
mOfferOAuth = true;
|
||||
}
|
||||
}
|
||||
mOAuthGroup.setVisibility(mOfferOAuth ? View.VISIBLE : View.GONE);
|
||||
mRegularPasswordText.setVisibility(mOfferOAuth ? View.GONE : View.VISIBLE);
|
||||
@ -279,13 +286,11 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment
|
||||
public void onClick(final View view) {
|
||||
final int viewId = view.getId();
|
||||
if (viewId == R.id.sign_in_with_oauth) {
|
||||
List<OAuthProvider> oauthProviders = AccountSettingsUtils.getAllOAuthProviders(
|
||||
mAppContext);
|
||||
// TODO currently the only oauth provider we support is google.
|
||||
// If we ever have more than 1 oauth provider, then we need to implement some sort
|
||||
// of picker UI. For now, just always take the first oauth provider.
|
||||
if (oauthProviders.size() > 0) {
|
||||
mProviderId = oauthProviders.get(0).id;
|
||||
if (mOauthProviders.size() > 0) {
|
||||
mProviderId = mOauthProviders.get(0).id;
|
||||
final Intent i = new Intent(getActivity(), OAuthAuthenticationActivity.class);
|
||||
i.putExtra(OAuthAuthenticationActivity.EXTRA_EMAIL_ADDRESS, mEmailAddress);
|
||||
i.putExtra(OAuthAuthenticationActivity.EXTRA_PROVIDER, mProviderId);
|
||||
|
@ -44,6 +44,7 @@ import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
|
||||
import com.android.email.view.CertificateSelector;
|
||||
import com.android.email.view.CertificateSelector.HostCallback;
|
||||
import com.android.emailcommon.Device;
|
||||
import com.android.emailcommon.VendorPolicyLoader;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.Credential;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
@ -54,6 +55,7 @@ import com.android.mail.utils.LogUtils;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides UI for IMAP/POP account settings.
|
||||
@ -83,6 +85,7 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment
|
||||
private View mDeviceIdSection;
|
||||
private View mImapPathPrefixSectionView;
|
||||
private EditText mImapPathPrefixView;
|
||||
private boolean mOAuthProviderPresent;
|
||||
// Delete policy as loaded from the device
|
||||
private int mLoadedDeletePolicy;
|
||||
|
||||
@ -337,9 +340,13 @@ public class AccountSetupIncomingFragment extends AccountServerBaseFragment
|
||||
final Account account = mSetupData.getAccount();
|
||||
final HostAuth recvAuth = account.getOrCreateHostAuthRecv(mAppContext);
|
||||
mServiceInfo = mSetupData.getIncomingServiceInfo(getActivity());
|
||||
mAuthenticationView.setAuthInfo(mServiceInfo.offerOAuth, recvAuth);
|
||||
final List<VendorPolicyLoader.OAuthProvider> oauthProviders =
|
||||
AccountSettingsUtils.getAllOAuthProviders(getActivity());
|
||||
final boolean offerOAuth = (mServiceInfo.offerOAuth && oauthProviders.size() > 0);
|
||||
|
||||
mAuthenticationView.setAuthInfo(offerOAuth, recvAuth);
|
||||
if (mAuthenticationLabel != null) {
|
||||
if (mServiceInfo.offerOAuth) {
|
||||
if (offerOAuth) {
|
||||
mAuthenticationLabel.setText(R.string.authentication_label);
|
||||
} else {
|
||||
mAuthenticationLabel.setText(R.string.account_setup_basics_password_label);
|
||||
|
@ -42,6 +42,7 @@ import com.android.email.R;
|
||||
import com.android.email.activity.UiUtilities;
|
||||
import com.android.email.activity.setup.AuthenticationView.AuthenticationCallback;
|
||||
import com.android.email.provider.AccountBackupRestore;
|
||||
import com.android.emailcommon.VendorPolicyLoader;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.Credential;
|
||||
import com.android.emailcommon.provider.HostAuth;
|
||||
@ -49,6 +50,8 @@ import com.android.emailcommon.utility.Utility;
|
||||
import com.android.mail.ui.MailAsyncTaskLoader;
|
||||
import com.android.mail.utils.LogUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Provides UI for SMTP account settings (for IMAP/POP accounts).
|
||||
*
|
||||
@ -236,7 +239,9 @@ public class AccountSetupOutgoingFragment extends AccountServerBaseFragment
|
||||
mRequireLoginView.setChecked(true);
|
||||
}
|
||||
|
||||
mAuthenticationView.setAuthInfo(true, sendAuth);
|
||||
final List<VendorPolicyLoader.OAuthProvider> oauthProviders =
|
||||
AccountSettingsUtils.getAllOAuthProviders(getActivity());
|
||||
mAuthenticationView.setAuthInfo(oauthProviders.size() > 0, sendAuth);
|
||||
if (mAuthenticationLabel != null) {
|
||||
mAuthenticationLabel.setText(R.string.authentication_label);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user