Don't offer oauth unless we have at least one provider
In the AOSP version of the email app, we don't by default have any oauth providers. We should not display option to set up your account with OAuth. Change-Id: I6fc55ae4852ec76b7c34c09ac58a0e06e89affa7
This commit is contained in:
parent
a516bd820d
commit
9c0463e6b4
|
@ -80,6 +80,7 @@ public class AccountSetupCredentialsFragment extends AccountSetupFragment
|
|||
private boolean mOfferOAuth;
|
||||
private boolean mOfferCerts;
|
||||
private String mProviderId;
|
||||
List<OAuthProvider> mOauthProviders;
|
||||
|
||||
private Context mAppContext;
|
||||
|
||||
|
@ -169,16 +170,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);
|
||||
|
@ -280,13 +287,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);
|
||||
|
|
|
@ -45,6 +45,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;
|
||||
|
@ -55,6 +56,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.
|
||||
|
@ -84,6 +86,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;
|
||||
|
||||
|
@ -342,9 +345,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