2010-07-08 17:08:47 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2010 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;
|
|
|
|
|
2011-01-26 19:16:56 +00:00
|
|
|
import android.accounts.AccountAuthenticatorResponse;
|
2010-07-08 17:08:47 +00:00
|
|
|
import android.os.Bundle;
|
|
|
|
import android.os.Parcel;
|
|
|
|
import android.os.Parcelable;
|
|
|
|
|
2012-06-28 17:40:46 +00:00
|
|
|
import com.android.emailcommon.provider.Account;
|
|
|
|
import com.android.emailcommon.provider.Policy;
|
|
|
|
|
2010-07-08 17:08:47 +00:00
|
|
|
public class SetupData implements Parcelable {
|
|
|
|
// The "extra" name for the Bundle saved with SetupData
|
|
|
|
public static final String EXTRA_SETUP_DATA = "com.android.email.setupdata";
|
|
|
|
|
|
|
|
// NORMAL is the standard entry from the Email app; EAS and POP_IMAP are used when entering via
|
|
|
|
// Settings -> Accounts
|
2011-10-20 21:08:20 +00:00
|
|
|
public static final int FLOW_MODE_UNSPECIFIED = -1;
|
2010-07-08 17:08:47 +00:00
|
|
|
public static final int FLOW_MODE_NORMAL = 0;
|
2012-06-28 17:40:46 +00:00
|
|
|
public static final int FLOW_MODE_ACCOUNT_MANAGER = 1;
|
2010-07-08 17:08:47 +00:00
|
|
|
public static final int FLOW_MODE_EDIT = 3;
|
2010-12-05 06:53:59 +00:00
|
|
|
public static final int FLOW_MODE_FORCE_CREATE = 4;
|
2010-07-08 17:08:47 +00:00
|
|
|
// The following two modes are used to "pop the stack" and return from the setup flow. We
|
|
|
|
// either return to the caller (if we're in an account type flow) or go to the message list
|
2010-12-05 06:53:59 +00:00
|
|
|
public static final int FLOW_MODE_RETURN_TO_CALLER = 5;
|
|
|
|
public static final int FLOW_MODE_RETURN_TO_MESSAGE_LIST = 6;
|
2012-06-28 17:40:46 +00:00
|
|
|
public static final int FLOW_MODE_RETURN_NO_ACCOUNTS_RESULT = 7;
|
|
|
|
public static final int FLOW_MODE_NO_ACCOUNTS = 8;
|
2010-07-08 17:08:47 +00:00
|
|
|
|
|
|
|
// Mode bits for AccountSetupCheckSettings, indicating the type of check requested
|
|
|
|
public static final int CHECK_INCOMING = 1;
|
|
|
|
public static final int CHECK_OUTGOING = 2;
|
|
|
|
public static final int CHECK_AUTODISCOVER = 4;
|
|
|
|
|
|
|
|
// All access will be through getters/setters
|
|
|
|
private int mFlowMode = FLOW_MODE_NORMAL;
|
2012-06-28 17:40:46 +00:00
|
|
|
private String mFlowAccountType;
|
2010-07-08 17:08:47 +00:00
|
|
|
private Account mAccount;
|
|
|
|
private String mUsername;
|
|
|
|
private String mPassword;
|
|
|
|
private int mCheckSettingsMode = 0;
|
|
|
|
private boolean mAllowAutodiscover = true;
|
2011-04-28 00:12:06 +00:00
|
|
|
private Policy mPolicy;
|
2011-01-26 19:16:56 +00:00
|
|
|
private AccountAuthenticatorResponse mAccountAuthenticatorResponse = null;
|
2010-07-08 17:08:47 +00:00
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public interface SetupDataContainer {
|
|
|
|
public SetupData getSetupData();
|
|
|
|
public void setSetupData(SetupData setupData);
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public SetupData() {
|
|
|
|
mPolicy = null;
|
|
|
|
mAllowAutodiscover = true;
|
|
|
|
mCheckSettingsMode = 0;
|
|
|
|
mAccount = new Account();
|
|
|
|
mUsername = null;
|
|
|
|
mPassword = null;
|
|
|
|
mAccountAuthenticatorResponse = null;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public SetupData(int flowMode) {
|
|
|
|
this();
|
|
|
|
mFlowMode = flowMode;
|
2012-06-28 17:40:46 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public SetupData(int flowMode, String accountType) {
|
|
|
|
this(flowMode);
|
|
|
|
mFlowAccountType = accountType;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public SetupData(int flowMode, Account account) {
|
|
|
|
this(flowMode);
|
|
|
|
mAccount = account;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public int getFlowMode() {
|
|
|
|
return mFlowMode;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public String getFlowAccountType() {
|
|
|
|
return mFlowAccountType;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public void setFlowMode(int flowMode) {
|
|
|
|
mFlowMode = flowMode;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public Account getAccount() {
|
|
|
|
return mAccount;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public void setAccount(Account account) {
|
|
|
|
mAccount = account;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public String getUsername() {
|
|
|
|
return mUsername;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public void setUsername(String username) {
|
|
|
|
mUsername = username;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public String getPassword() {
|
|
|
|
return mPassword;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public void setPassword(String password) {
|
|
|
|
mPassword = password;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public void setCheckSettingsMode(int checkSettingsMode) {
|
|
|
|
mCheckSettingsMode = checkSettingsMode;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public boolean isCheckIncoming() {
|
|
|
|
return (mCheckSettingsMode & CHECK_INCOMING) != 0;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public boolean isCheckOutgoing() {
|
|
|
|
return (mCheckSettingsMode & CHECK_OUTGOING) != 0;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
2013-08-30 22:48:35 +00:00
|
|
|
public boolean isCheckAutodiscover() {
|
|
|
|
return (mCheckSettingsMode & CHECK_AUTODISCOVER) != 0;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
2013-08-30 22:48:35 +00:00
|
|
|
public boolean isAllowAutodiscover() {
|
|
|
|
return mAllowAutodiscover;
|
2011-01-26 19:16:56 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public void setAllowAutodiscover(boolean mAllowAutodiscover) {
|
|
|
|
mAllowAutodiscover = mAllowAutodiscover;
|
2011-01-26 19:16:56 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public Policy getPolicy() {
|
|
|
|
return mPolicy;
|
2012-08-17 23:04:05 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public void setPolicy(Policy policy) {
|
|
|
|
mPolicy = policy;
|
|
|
|
mAccount.mPolicy = policy;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public AccountAuthenticatorResponse getAccountAuthenticatorResponse() {
|
|
|
|
return mAccountAuthenticatorResponse;
|
2012-06-28 17:40:46 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public void setAccountAuthenticatorResponse(AccountAuthenticatorResponse response) {
|
|
|
|
mAccountAuthenticatorResponse = response;
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Parcelable methods
|
2012-06-28 17:40:46 +00:00
|
|
|
@Override
|
2010-07-08 17:08:47 +00:00
|
|
|
public int describeContents() {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public static final Parcelable.Creator<SetupData> CREATOR =
|
|
|
|
new Parcelable.Creator<SetupData>() {
|
2012-06-28 17:40:46 +00:00
|
|
|
@Override
|
2010-07-08 17:08:47 +00:00
|
|
|
public SetupData createFromParcel(Parcel in) {
|
|
|
|
return new SetupData(in);
|
|
|
|
}
|
|
|
|
|
2012-06-28 17:40:46 +00:00
|
|
|
@Override
|
2010-07-08 17:08:47 +00:00
|
|
|
public SetupData[] newArray(int size) {
|
|
|
|
return new SetupData[size];
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2012-06-28 17:40:46 +00:00
|
|
|
@Override
|
2010-07-08 17:08:47 +00:00
|
|
|
public void writeToParcel(Parcel dest, int flags) {
|
|
|
|
dest.writeInt(mFlowMode);
|
|
|
|
dest.writeParcelable(mAccount, 0);
|
|
|
|
dest.writeString(mUsername);
|
|
|
|
dest.writeString(mPassword);
|
|
|
|
dest.writeInt(mCheckSettingsMode);
|
|
|
|
dest.writeInt(mAllowAutodiscover ? 1 : 0);
|
2011-04-28 00:12:06 +00:00
|
|
|
dest.writeParcelable(mPolicy, 0);
|
2011-01-26 19:16:56 +00:00
|
|
|
dest.writeParcelable(mAccountAuthenticatorResponse, 0);
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public SetupData(Parcel in) {
|
2013-08-30 22:48:35 +00:00
|
|
|
final ClassLoader loader = getClass().getClassLoader();
|
2010-07-08 17:08:47 +00:00
|
|
|
mFlowMode = in.readInt();
|
2010-11-01 20:36:42 +00:00
|
|
|
mAccount = in.readParcelable(loader);
|
2010-07-08 17:08:47 +00:00
|
|
|
mUsername = in.readString();
|
|
|
|
mPassword = in.readString();
|
|
|
|
mCheckSettingsMode = in.readInt();
|
|
|
|
mAllowAutodiscover = in.readInt() == 1;
|
2011-04-28 00:12:06 +00:00
|
|
|
mPolicy = in.readParcelable(loader);
|
2011-01-26 19:16:56 +00:00
|
|
|
mAccountAuthenticatorResponse = in.readParcelable(loader);
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
|
|
|
|
2013-08-30 22:48:35 +00:00
|
|
|
public String debugString() {
|
|
|
|
final StringBuilder sb = new StringBuilder("SetupData");
|
|
|
|
sb.append(":acct=");
|
|
|
|
sb.append(mAccount == null ? "none" :mAccount.mId);
|
|
|
|
if (mUsername != null) {
|
|
|
|
sb.append(":user=");
|
|
|
|
sb.append(mUsername);
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
2013-08-30 22:48:35 +00:00
|
|
|
if (mPassword != null) {
|
|
|
|
sb.append(":pass=");
|
|
|
|
sb.append(mPassword);
|
2010-07-08 17:08:47 +00:00
|
|
|
}
|
2013-08-30 22:48:35 +00:00
|
|
|
sb.append(":a/d=");
|
|
|
|
sb.append(mAllowAutodiscover);
|
2010-07-08 17:08:47 +00:00
|
|
|
sb.append(":check=");
|
2013-08-30 22:48:35 +00:00
|
|
|
if (isCheckIncoming()) sb.append("in+");
|
|
|
|
if (isCheckOutgoing()) sb.append("out+");
|
|
|
|
if (isCheckAutodiscover()) sb.append("a/d");
|
|
|
|
sb.append(":policy=");
|
|
|
|
sb.append(mPolicy == null ? "none" : "exists");
|
2010-07-08 17:08:47 +00:00
|
|
|
return sb.toString();
|
|
|
|
}
|
|
|
|
}
|