Add disambiguation screen when user protocol choice differs from providers.xml
b/13640868 Change-Id: I75116f30e9c12d2e8b6757bf208e1519e438aed9
This commit is contained in:
parent
ca7df3f234
commit
296cde5603
50
res/layout/account_setup_ab_fragment.xml
Normal file
50
res/layout/account_setup_ab_fragment.xml
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2014 The Android Open Source Project
|
||||||
|
|
||||||
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
you may not use this file except in compliance with the License.
|
||||||
|
You may obtain a copy of the License at
|
||||||
|
|
||||||
|
http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
|
||||||
|
Unless required by applicable law or agreed to in writing, software
|
||||||
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
See the License for the specific language governing permissions and
|
||||||
|
limitations under the License.
|
||||||
|
-->
|
||||||
|
|
||||||
|
<!-- Fragment use to disambiguate between the user selecting protocol A and providers.xml
|
||||||
|
indicating otherwise -->
|
||||||
|
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:orientation="vertical"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent">
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/ab_instructions"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="@string/account_setup_ab_instructions_format"
|
||||||
|
style="@style/account_setup_info_text" />
|
||||||
|
<!-- Spacer -->
|
||||||
|
<View
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_weight="1" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/ab_button_a"
|
||||||
|
android:layout_height="@dimen/setup_account_ab_button_height"
|
||||||
|
android:layout_width="@dimen/setup_account_ab_button_width"
|
||||||
|
android:layout_marginTop="@dimen/setup_account_ab_button_vertical_spacing"
|
||||||
|
android:minWidth="@dimen/setup_account_ab_button_min_width"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
/>
|
||||||
|
<Button
|
||||||
|
android:id="@+id/ab_button_b"
|
||||||
|
android:layout_height="@dimen/setup_account_ab_button_height"
|
||||||
|
android:layout_width="@dimen/setup_account_ab_button_width"
|
||||||
|
android:layout_marginTop="@dimen/setup_account_ab_button_vertical_spacing"
|
||||||
|
android:minWidth="@dimen/setup_account_ab_button_min_width"
|
||||||
|
android:layout_gravity="center_horizontal"
|
||||||
|
/>
|
||||||
|
</LinearLayout>
|
@ -26,6 +26,12 @@
|
|||||||
<dimen name="setup_account_type_buttons_width">212sp</dimen>
|
<dimen name="setup_account_type_buttons_width">212sp</dimen>
|
||||||
<dimen name="setup_account_type_buttons_height">54dp</dimen>
|
<dimen name="setup_account_type_buttons_height">54dp</dimen>
|
||||||
|
|
||||||
|
<!-- Account setup ab screen buttons -->
|
||||||
|
<dimen name="setup_account_ab_button_min_width">100sp</dimen>
|
||||||
|
<dimen name="setup_account_ab_button_vertical_spacing">16dp</dimen>
|
||||||
|
<dimen name="setup_account_ab_button_width">212sp</dimen>
|
||||||
|
<dimen name="setup_account_ab_button_height">54dp</dimen>
|
||||||
|
|
||||||
<!-- Account settings fragments -->
|
<!-- Account settings fragments -->
|
||||||
<dimen name="settings_fragment_padding_top">16dp</dimen>
|
<dimen name="settings_fragment_padding_top">16dp</dimen>
|
||||||
<dimen name="settings_fragment_padding_side">16dp</dimen>
|
<dimen name="settings_fragment_padding_side">16dp</dimen>
|
||||||
|
@ -256,6 +256,11 @@
|
|||||||
<string name="account_setup_creating_account_msg">
|
<string name="account_setup_creating_account_msg">
|
||||||
Creating account\u2026</string>
|
Creating account\u2026</string>
|
||||||
|
|
||||||
|
<!-- Headline text that appears on "Confirm account type" screen [CHAR LIMIT=none] -->
|
||||||
|
<string name="account_setup_ab_headline">Confirm account type</string>
|
||||||
|
<!-- Explanatory text that appears on the "Confirm account type" screen [CHAR LIMIT=none] -->
|
||||||
|
<string name="account_setup_ab_instructions_format">You indicated <xliff:g id="email">%1$s</xliff:g> uses <xliff:g id="userProtocol">%2$s</xliff:g>, but the account may use <xliff:g id="providerProtocol">%3$s</xliff:g></string>
|
||||||
|
|
||||||
<!-- Title of "Set up email" screen after success [CHAR LIMIT=45] -->
|
<!-- Title of "Set up email" screen after success [CHAR LIMIT=45] -->
|
||||||
<string name="account_setup_names_title">Account setup</string>
|
<string name="account_setup_names_title">Account setup</string>
|
||||||
<!-- Text that appears on "Set up email" screen after successfully setting up an account
|
<!-- Text that appears on "Set up email" screen after successfully setting up an account
|
||||||
|
120
src/com/android/email/activity/setup/AccountSetupABFragment.java
Normal file
120
src/com/android/email/activity/setup/AccountSetupABFragment.java
Normal file
@ -0,0 +1,120 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2014 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package com.android.email.activity.setup;
|
||||||
|
|
||||||
|
import android.content.Context;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.LayoutInflater;
|
||||||
|
import android.view.View;
|
||||||
|
import android.view.ViewGroup;
|
||||||
|
import android.widget.Button;
|
||||||
|
import android.widget.TextView;
|
||||||
|
|
||||||
|
import com.android.email.R;
|
||||||
|
import com.android.email.activity.UiUtilities;
|
||||||
|
import com.android.email.service.EmailServiceUtils;
|
||||||
|
|
||||||
|
public class AccountSetupABFragment extends AccountSetupFragment {
|
||||||
|
|
||||||
|
private static final String ACCOUNT_EMAIL_ARG = "accountEmail";
|
||||||
|
private static final String USER_PROTOCOL_ARG = "userProtocol";
|
||||||
|
private static final String PROVIDER_PROTOCOL_ARG = "providerProtocol";
|
||||||
|
|
||||||
|
private String mAccountEmail;
|
||||||
|
private String mUserProtocol;
|
||||||
|
private String mProviderProtocol;
|
||||||
|
|
||||||
|
public interface Callback extends AccountSetupFragment.Callback {
|
||||||
|
void onABProtocolDisambiguated(String chosenProtocol);
|
||||||
|
}
|
||||||
|
|
||||||
|
public AccountSetupABFragment() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setup flow fragment for disambiguating the user's choice of protocol (when launched from the
|
||||||
|
* system account manager) and what is indicated in providers.xml
|
||||||
|
*
|
||||||
|
* @param accountEmail Email address of account being set up
|
||||||
|
* @param userProtocol Protocol that the user initiated account creation for
|
||||||
|
* @param providerProtocol Protocol indicated in providers.xml
|
||||||
|
* @return Fresh ready-to-use disambiguation fragment
|
||||||
|
*/
|
||||||
|
public static AccountSetupABFragment newInstance(final String accountEmail,
|
||||||
|
final String userProtocol, final String providerProtocol) {
|
||||||
|
final Bundle b = new Bundle(3);
|
||||||
|
b.putString(ACCOUNT_EMAIL_ARG, accountEmail);
|
||||||
|
b.putString(USER_PROTOCOL_ARG, userProtocol);
|
||||||
|
b.putString(PROVIDER_PROTOCOL_ARG, providerProtocol);
|
||||||
|
final AccountSetupABFragment f = new AccountSetupABFragment();
|
||||||
|
f.setArguments(b);
|
||||||
|
return f;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
|
final Bundle b = getArguments();
|
||||||
|
mAccountEmail = b.getString(ACCOUNT_EMAIL_ARG);
|
||||||
|
mUserProtocol = b.getString(USER_PROTOCOL_ARG);
|
||||||
|
mProviderProtocol = b.getString(PROVIDER_PROTOCOL_ARG);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
||||||
|
Bundle savedInstanceState) {
|
||||||
|
final Context context = inflater.getContext();
|
||||||
|
|
||||||
|
final String userProtocolName =
|
||||||
|
EmailServiceUtils.getServiceInfo(context, mUserProtocol).name;
|
||||||
|
final String providerProtocolName =
|
||||||
|
EmailServiceUtils.getServiceInfo(context, mProviderProtocol).name;
|
||||||
|
|
||||||
|
final View view = inflateTemplatedView(inflater, container,
|
||||||
|
R.layout.account_setup_ab_fragment, R.string.account_setup_ab_headline);
|
||||||
|
|
||||||
|
final TextView abInstructions = UiUtilities.getView(view, R.id.ab_instructions);
|
||||||
|
abInstructions.setText(context.getString(R.string.account_setup_ab_instructions_format,
|
||||||
|
mAccountEmail, userProtocolName, providerProtocolName));
|
||||||
|
|
||||||
|
final View nextButton = UiUtilities.getView(view, R.id.next);
|
||||||
|
nextButton.setVisibility(View.INVISIBLE);
|
||||||
|
|
||||||
|
final Button abButtonA = UiUtilities.getView(view, R.id.ab_button_a);
|
||||||
|
abButtonA.setOnClickListener(this);
|
||||||
|
abButtonA.setText(userProtocolName);
|
||||||
|
|
||||||
|
final Button abButtonB = UiUtilities.getView(view, R.id.ab_button_b);
|
||||||
|
abButtonB.setOnClickListener(this);
|
||||||
|
abButtonB.setText(providerProtocolName);
|
||||||
|
|
||||||
|
return view;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onClick(View v) {
|
||||||
|
final int viewId = v.getId();
|
||||||
|
final Callback callback = (Callback) getActivity();
|
||||||
|
if (viewId == R.id.ab_button_a) {
|
||||||
|
callback.onABProtocolDisambiguated(mUserProtocol);
|
||||||
|
} else if (viewId == R.id.ab_button_b) {
|
||||||
|
callback.onABProtocolDisambiguated(mProviderProtocol);
|
||||||
|
} else {
|
||||||
|
super.onClick(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -59,7 +59,7 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||||||
AccountSetupTypeFragment.Callback, AccountSetupNamesFragment.Callback,
|
AccountSetupTypeFragment.Callback, AccountSetupNamesFragment.Callback,
|
||||||
AccountSetupOptionsFragment.Callback, AccountSetupBasicsFragment.Callback,
|
AccountSetupOptionsFragment.Callback, AccountSetupBasicsFragment.Callback,
|
||||||
AccountServerBaseFragment.Callback, AccountSetupCredentialsFragment.Callback,
|
AccountServerBaseFragment.Callback, AccountSetupCredentialsFragment.Callback,
|
||||||
DuplicateAccountDialogFragment.Callback {
|
DuplicateAccountDialogFragment.Callback, AccountSetupABFragment.Callback {
|
||||||
|
|
||||||
// STOPSHIP: Set to false before shipping, logs PII
|
// STOPSHIP: Set to false before shipping, logs PII
|
||||||
private final static boolean ENTER_DEBUG_SCREEN = true;
|
private final static boolean ENTER_DEBUG_SCREEN = true;
|
||||||
@ -127,10 +127,12 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||||||
private static final int STATE_BASICS_POST = 1;
|
private static final int STATE_BASICS_POST = 1;
|
||||||
// Account is not pre-configured, query user for account type
|
// Account is not pre-configured, query user for account type
|
||||||
private static final int STATE_TYPE = 2;
|
private static final int STATE_TYPE = 2;
|
||||||
|
// Account is pre-configured, but the user picked a different protocol
|
||||||
|
private static final int STATE_AB = 3;
|
||||||
// Collect initial password or oauth token
|
// Collect initial password or oauth token
|
||||||
private static final int STATE_CREDENTIALS = 3;
|
private static final int STATE_CREDENTIALS = 4;
|
||||||
// Account is a pre-configured account, run the checker
|
// Account is a pre-configured account, run the checker
|
||||||
private static final int STATE_CHECKING_PRECONFIGURED = 4;
|
private static final int STATE_CHECKING_PRECONFIGURED = 5;
|
||||||
// Auto-discovering exchange account info, possibly other protocols later
|
// Auto-discovering exchange account info, possibly other protocols later
|
||||||
private static final int STATE_AUTO_DISCOVER = 6;
|
private static final int STATE_AUTO_DISCOVER = 6;
|
||||||
// User is entering incoming settings
|
// User is entering incoming settings
|
||||||
@ -446,6 +448,10 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||||||
case STATE_TYPE:
|
case STATE_TYPE:
|
||||||
f = AccountSetupTypeFragment.newInstance();
|
f = AccountSetupTypeFragment.newInstance();
|
||||||
break;
|
break;
|
||||||
|
case STATE_AB:
|
||||||
|
f = AccountSetupABFragment.newInstance(mSetupData.getEmail(),
|
||||||
|
mSetupData.getAmProtocol(), mSetupData.getIncomingProtocol(this));
|
||||||
|
break;
|
||||||
case STATE_CREDENTIALS:
|
case STATE_CREDENTIALS:
|
||||||
f = AccountSetupCredentialsFragment.newInstance(mSetupData.getEmail(),
|
f = AccountSetupCredentialsFragment.newInstance(mSetupData.getEmail(),
|
||||||
mSetupData.getIncomingProtocol(this), mSetupData.getClientCert(this),
|
mSetupData.getIncomingProtocol(this), mSetupData.getClientCert(this),
|
||||||
@ -537,8 +543,12 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||||||
} else {
|
} else {
|
||||||
mSkipAutoDiscover = false;
|
mSkipAutoDiscover = false;
|
||||||
if (mIsPreConfiguredProvider) {
|
if (mIsPreConfiguredProvider) {
|
||||||
// TODO: check for mismatch between providers.xml and amProtocol
|
if (!TextUtils.equals(mSetupData.getAmProtocol(),
|
||||||
mState = STATE_CREDENTIALS;
|
mSetupData.getIncomingProtocol(this))) {
|
||||||
|
mState = STATE_AB;
|
||||||
|
} else {
|
||||||
|
mState = STATE_CREDENTIALS;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
final String amProtocol = mSetupData.getAmProtocol();
|
final String amProtocol = mSetupData.getAmProtocol();
|
||||||
if (!TextUtils.isEmpty(amProtocol)) {
|
if (!TextUtils.isEmpty(amProtocol)) {
|
||||||
@ -558,6 +568,10 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||||||
mState = STATE_CREDENTIALS;
|
mState = STATE_CREDENTIALS;
|
||||||
updateContentFragment(true /* addToBackstack */);
|
updateContentFragment(true /* addToBackstack */);
|
||||||
break;
|
break;
|
||||||
|
case STATE_AB:
|
||||||
|
mState = STATE_CREDENTIALS;
|
||||||
|
updateContentFragment(true /* addToBackstack */);
|
||||||
|
break;
|
||||||
case STATE_CREDENTIALS:
|
case STATE_CREDENTIALS:
|
||||||
collectCredentials();
|
collectCredentials();
|
||||||
if (mIsPreConfiguredProvider) {
|
if (mIsPreConfiguredProvider) {
|
||||||
@ -698,6 +712,9 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||||||
final AccountSetupBasicsFragment f = (AccountSetupBasicsFragment) getContentFragment();
|
final AccountSetupBasicsFragment f = (AccountSetupBasicsFragment) getContentFragment();
|
||||||
final String email = f.getEmail();
|
final String email = f.getEmail();
|
||||||
|
|
||||||
|
// Reset the protocol choice in case the user has back-navigated here
|
||||||
|
mSetupData.setIncomingProtocol(this, null);
|
||||||
|
|
||||||
if (!TextUtils.equals(email, mSetupData.getEmail())) {
|
if (!TextUtils.equals(email, mSetupData.getEmail())) {
|
||||||
// If the user changes their email address, clear the password failed state
|
// If the user changes their email address, clear the password failed state
|
||||||
mPasswordFailed = false;
|
mPasswordFailed = false;
|
||||||
@ -1000,6 +1017,17 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||||||
proceed();
|
proceed();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onABProtocolDisambiguated(String chosenProtocol) {
|
||||||
|
if (!TextUtils.equals(mSetupData.getIncomingProtocol(this), chosenProtocol)) {
|
||||||
|
mIsPreConfiguredProvider = false;
|
||||||
|
mSetupData.setIncomingProtocol(this, chosenProtocol);
|
||||||
|
final Account account = mSetupData.getAccount();
|
||||||
|
setDefaultsForProtocol(account);
|
||||||
|
}
|
||||||
|
proceed();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Ths is called when the user clicks the "done" button.
|
* Ths is called when the user clicks the "done" button.
|
||||||
* It collects the data from the UI, updates the setup account record, and launches a fragment
|
* It collects the data from the UI, updates the setup account record, and launches a fragment
|
||||||
|
Loading…
Reference in New Issue
Block a user