Remove direct entry points to AccountSettings
b/16240332 Change-Id: I9bc3f9a2e0b7faa4d8875a9ac7d6d585a65d9733
This commit is contained in:
parent
4fb4820223
commit
8c03e2af9f
|
@ -315,7 +315,7 @@
|
|||
<intent-filter>
|
||||
<action android:name="android.intent.action.VIEW" />
|
||||
<category android:name="android.intent.category.DEFAULT" />
|
||||
<data android:host="com.android.email.INCOMING_SETTINGS" />
|
||||
<data android:host="com.android.email.ACCOUNT_SETTINGS" />
|
||||
<data android:scheme="auth"/>
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
|
|
@ -42,38 +42,6 @@ public class AccountServiceProxy extends ServiceProxy implements IAccountService
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyLoginFailed(final long accountId, final String reason) {
|
||||
setTask(new ProxyTask() {
|
||||
@Override
|
||||
public void run() throws RemoteException {
|
||||
mService.notifyLoginFailed(accountId, reason);
|
||||
}
|
||||
}, "notifyLoginFailed");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyLoginSucceeded(final long accountId) {
|
||||
setTask(new ProxyTask() {
|
||||
@Override
|
||||
public void run() throws RemoteException {
|
||||
mService.notifyLoginSucceeded(accountId);
|
||||
}
|
||||
}, "notifyLoginSucceeded");
|
||||
}
|
||||
|
||||
// The following call is synchronous, and should not be made from the UI thread
|
||||
@Override
|
||||
public void reconcileAccounts(final String protocol, final String accountManagerType) {
|
||||
setTask(new ProxyTask() {
|
||||
@Override
|
||||
public void run() throws RemoteException {
|
||||
mService.reconcileAccounts(protocol, accountManagerType);
|
||||
}
|
||||
}, "reconcileAccounts");
|
||||
waitForCompletion();
|
||||
}
|
||||
|
||||
// The following call is synchronous, and should not be made from the UI thread
|
||||
@Override
|
||||
public int getAccountColor(final long accountId) {
|
||||
|
|
|
@ -19,11 +19,6 @@ package com.android.emailcommon.service;
|
|||
import android.os.Bundle;
|
||||
|
||||
interface IAccountService {
|
||||
oneway void notifyLoginFailed(long accountId, String reason);
|
||||
oneway void notifyLoginSucceeded(long accountId);
|
||||
|
||||
void reconcileAccounts(String protocol, String accountManagerType);
|
||||
|
||||
int getAccountColor(long accountId);
|
||||
|
||||
Bundle getConfigurationData(String accountType);
|
||||
|
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2013 Google Inc.
|
||||
Licensed to 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.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android" >
|
||||
|
||||
<item
|
||||
android:id="@+id/add_new_account"
|
||||
android:title="@string/add_account"
|
||||
android:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/clear_picture_approvals_menu_item"
|
||||
android:showAsAction="never"
|
||||
android:title="@string/clear_display_images_whitelist_title"/>
|
||||
<item
|
||||
android:id="@+id/feedback_menu_item"
|
||||
android:icon="@android:drawable/ic_menu_send"
|
||||
android:title="@string/feedback"/>
|
||||
|
||||
<!-- TODO add help menu item, once help support has been moved to UnifiedEmail -->
|
||||
</menu>
|
|
@ -1,32 +0,0 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2013 Google Inc.
|
||||
Licensed to 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.
|
||||
-->
|
||||
|
||||
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<item
|
||||
android:id="@+id/add_new_account"
|
||||
android:title="@string/add_account"
|
||||
android:showAsAction="always" />
|
||||
|
||||
<item
|
||||
android:id="@+id/feedback_menu_item"
|
||||
android:icon="@android:drawable/ic_menu_send"
|
||||
android:title="@string/feedback" />
|
||||
|
||||
<!-- TODO add help menu item, once help support has been moved to UnifiedEmail -->
|
||||
</menu>
|
|
@ -37,7 +37,7 @@ import android.text.TextUtils;
|
|||
import android.text.format.DateUtils;
|
||||
|
||||
import com.android.email.activity.setup.AccountSecurity;
|
||||
import com.android.email.activity.setup.AccountSettings;
|
||||
import com.android.email.activity.setup.HeadlessAccountSettingsLoader;
|
||||
import com.android.email.provider.EmailProvider;
|
||||
import com.android.email.service.EmailServiceUtils;
|
||||
import com.android.emailcommon.provider.Account;
|
||||
|
@ -388,10 +388,10 @@ public class NotificationController {
|
|||
*
|
||||
* NOTE: DO NOT CALL THIS METHOD FROM THE UI THREAD (DATABASE ACCESS)
|
||||
*/
|
||||
public void showDownloadForwardFailedNotification(Attachment attachment) {
|
||||
Message message = Message.restoreMessageWithId(mContext, attachment.mMessageKey);
|
||||
public void showDownloadForwardFailedNotificationSynchronous(Attachment attachment) {
|
||||
final Message message = Message.restoreMessageWithId(mContext, attachment.mMessageKey);
|
||||
if (message == null) return;
|
||||
Mailbox mailbox = Mailbox.restoreMailboxWithId(mContext, message.mMailboxKey);
|
||||
final Mailbox mailbox = Mailbox.restoreMailboxWithId(mContext, message.mMailboxKey);
|
||||
showNotification(mailbox.mAccountKey,
|
||||
mContext.getString(R.string.forward_download_failed_ticker),
|
||||
mContext.getString(R.string.forward_download_failed_title),
|
||||
|
@ -412,22 +412,27 @@ public class NotificationController {
|
|||
*
|
||||
* NOTE: DO NOT CALL THIS METHOD FROM THE UI THREAD (DATABASE ACCESS)
|
||||
*/
|
||||
public void showLoginFailedNotification(long accountId) {
|
||||
showLoginFailedNotification(accountId, null);
|
||||
}
|
||||
|
||||
public void showLoginFailedNotification(long accountId, String reason) {
|
||||
public void showLoginFailedNotificationSynchronous(long accountId, boolean incoming) {
|
||||
final Account account = Account.restoreAccountWithId(mContext, accountId);
|
||||
if (account == null) return;
|
||||
final Mailbox mailbox = Mailbox.restoreMailboxOfType(mContext, account.mId,
|
||||
final Mailbox mailbox = Mailbox.restoreMailboxOfType(mContext, accountId,
|
||||
Mailbox.TYPE_INBOX);
|
||||
if (mailbox == null) return;
|
||||
|
||||
final Intent settingsIntent;
|
||||
if (incoming) {
|
||||
settingsIntent = new Intent(Intent.ACTION_VIEW,
|
||||
HeadlessAccountSettingsLoader.getIncomingSettingsUri(accountId));
|
||||
} else {
|
||||
settingsIntent = new Intent(Intent.ACTION_VIEW,
|
||||
HeadlessAccountSettingsLoader.getOutgoingSettingsUri(accountId));
|
||||
}
|
||||
showNotification(mailbox.mAccountKey,
|
||||
mContext.getString(R.string.login_failed_ticker, account.mDisplayName),
|
||||
mContext.getString(R.string.login_failed_title),
|
||||
account.getDisplayName(),
|
||||
AccountSettings.createAccountSettingsIntent(mContext, accountId,
|
||||
account.mDisplayName, reason), getLoginFailedNotificationId(accountId));
|
||||
settingsIntent,
|
||||
getLoginFailedNotificationId(accountId));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -443,16 +448,16 @@ public class NotificationController {
|
|||
*
|
||||
* NOTE: DO NOT CALL THIS METHOD FROM THE UI THREAD (DATABASE ACCESS)
|
||||
*/
|
||||
public void showPasswordExpiringNotification(long accountId) {
|
||||
Account account = Account.restoreAccountWithId(mContext, accountId);
|
||||
public void showPasswordExpiringNotificationSynchronous(long accountId) {
|
||||
final Account account = Account.restoreAccountWithId(mContext, accountId);
|
||||
if (account == null) return;
|
||||
|
||||
Intent intent = AccountSecurity.actionDevicePasswordExpirationIntent(mContext,
|
||||
final Intent intent = AccountSecurity.actionDevicePasswordExpirationIntent(mContext,
|
||||
accountId, false);
|
||||
String accountName = account.getDisplayName();
|
||||
String ticker =
|
||||
final String accountName = account.getDisplayName();
|
||||
final String ticker =
|
||||
mContext.getString(R.string.password_expire_warning_ticker_fmt, accountName);
|
||||
String title = mContext.getString(R.string.password_expire_warning_content_title);
|
||||
final String title = mContext.getString(R.string.password_expire_warning_content_title);
|
||||
showNotification(accountId, ticker, title, accountName, intent,
|
||||
NOTIFICATION_ID_PASSWORD_EXPIRING);
|
||||
}
|
||||
|
@ -463,15 +468,15 @@ public class NotificationController {
|
|||
*
|
||||
* NOTE: DO NOT CALL THIS METHOD FROM THE UI THREAD (DATABASE ACCESS)
|
||||
*/
|
||||
public void showPasswordExpiredNotification(long accountId) {
|
||||
Account account = Account.restoreAccountWithId(mContext, accountId);
|
||||
public void showPasswordExpiredNotificationSynchronous(long accountId) {
|
||||
final Account account = Account.restoreAccountWithId(mContext, accountId);
|
||||
if (account == null) return;
|
||||
|
||||
Intent intent = AccountSecurity.actionDevicePasswordExpirationIntent(mContext,
|
||||
final Intent intent = AccountSecurity.actionDevicePasswordExpirationIntent(mContext,
|
||||
accountId, true);
|
||||
String accountName = account.getDisplayName();
|
||||
String ticker = mContext.getString(R.string.password_expired_ticker);
|
||||
String title = mContext.getString(R.string.password_expired_content_title);
|
||||
final String accountName = account.getDisplayName();
|
||||
final String ticker = mContext.getString(R.string.password_expired_ticker);
|
||||
final String title = mContext.getString(R.string.password_expired_content_title);
|
||||
showNotification(accountId, ticker, title, accountName, intent,
|
||||
NOTIFICATION_ID_PASSWORD_EXPIRED);
|
||||
}
|
||||
|
@ -503,12 +508,13 @@ public class NotificationController {
|
|||
* account settings screen where he can view the list of enforced policies
|
||||
*/
|
||||
public void showSecurityChangedNotification(Account account) {
|
||||
Intent intent =
|
||||
AccountSettings.createAccountSettingsIntent(mContext, account.mId, null, null);
|
||||
String accountName = account.getDisplayName();
|
||||
String ticker =
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW,
|
||||
HeadlessAccountSettingsLoader.getIncomingSettingsUri(account.getId()));
|
||||
final String accountName = account.getDisplayName();
|
||||
final String ticker =
|
||||
mContext.getString(R.string.security_changed_ticker_fmt, accountName);
|
||||
String title = mContext.getString(R.string.security_notification_content_change_title);
|
||||
final String title =
|
||||
mContext.getString(R.string.security_notification_content_change_title);
|
||||
showNotification(account.mId, ticker, title, accountName, intent,
|
||||
(int)(NOTIFICATION_ID_BASE_SECURITY_CHANGED + account.mId));
|
||||
}
|
||||
|
@ -518,12 +524,13 @@ public class NotificationController {
|
|||
* account settings screen where he can view the list of unsupported policies
|
||||
*/
|
||||
public void showSecurityUnsupportedNotification(Account account) {
|
||||
Intent intent =
|
||||
AccountSettings.createAccountSettingsIntent(mContext, account.mId, null, null);
|
||||
String accountName = account.getDisplayName();
|
||||
String ticker =
|
||||
final Intent intent = new Intent(Intent.ACTION_VIEW,
|
||||
HeadlessAccountSettingsLoader.getIncomingSettingsUri(account.getId()));
|
||||
final String accountName = account.getDisplayName();
|
||||
final String ticker =
|
||||
mContext.getString(R.string.security_unsupported_ticker_fmt, accountName);
|
||||
String title = mContext.getString(R.string.security_notification_content_unsupported_title);
|
||||
final String title =
|
||||
mContext.getString(R.string.security_notification_content_unsupported_title);
|
||||
showNotification(account.mId, ticker, title, accountName, intent,
|
||||
(int)(NOTIFICATION_ID_BASE_SECURITY_NEEDED + account.mId));
|
||||
}
|
||||
|
|
|
@ -758,13 +758,13 @@ public class SecurityPolicy {
|
|||
if (!expired) {
|
||||
// 4. If warning, simply put up a generic notification and report that it came from
|
||||
// the shortest-expiring account.
|
||||
NotificationController.getInstance(mContext).showPasswordExpiringNotification(
|
||||
NotificationController.getInstance(mContext).showPasswordExpiringNotificationSynchronous(
|
||||
nextExpiringAccountId);
|
||||
} else {
|
||||
// 5. Actually expired - find all accounts that expire passwords, and wipe them
|
||||
boolean wiped = wipeExpiredAccounts(context);
|
||||
if (wiped) {
|
||||
NotificationController.getInstance(mContext).showPasswordExpiredNotification(
|
||||
NotificationController.getInstance(mContext).showPasswordExpiredNotificationSynchronous(
|
||||
nextExpiringAccountId);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,7 +18,6 @@ package com.android.email.activity.setup;
|
|||
|
||||
import android.app.ActionBar;
|
||||
import android.app.Fragment;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Bundle;
|
||||
|
@ -53,12 +52,8 @@ public class AccountSettings extends MailPreferenceActivity {
|
|||
|
||||
// Intent extras for our internal activity launch
|
||||
private static final String EXTRA_ENABLE_DEBUG = "AccountSettings.enable_debug";
|
||||
private static final String EXTRA_LOGIN_WARNING_FOR_ACCOUNT = "AccountSettings.for_account";
|
||||
private static final String EXTRA_LOGIN_WARNING_REASON_FOR_ACCOUNT =
|
||||
"AccountSettings.for_account_reason";
|
||||
// STOPSHIP: Do not ship with the debug menu allowed.
|
||||
private static final boolean DEBUG_MENU_ALLOWED = false;
|
||||
public static final String EXTRA_NO_ACCOUNTS = "AccountSettings.no_account";
|
||||
|
||||
// Intent extras for launch directly from system account manager
|
||||
// NOTE: This string must match the one in res/xml/account_preferences.xml
|
||||
|
@ -78,27 +73,6 @@ public class AccountSettings extends MailPreferenceActivity {
|
|||
private Uri mFeedbackUri;
|
||||
private MenuItem mFeedbackMenuItem;
|
||||
|
||||
/**
|
||||
* Create and return an intent to display (and edit) settings for a specific account, or -1
|
||||
* for any/all accounts. If an account name string is provided, a warning dialog will be
|
||||
* displayed as well.
|
||||
*/
|
||||
public static Intent createAccountSettingsIntent(final Context context, final long accountId,
|
||||
final String loginWarningAccountName, final String loginWarningReason) {
|
||||
final Uri.Builder b = IntentUtilities.createActivityIntentUrlBuilder(
|
||||
IntentUtilities.PATH_SETTINGS);
|
||||
IntentUtilities.setAccountId(b, accountId);
|
||||
final Intent i = new Intent(Intent.ACTION_EDIT, b.build());
|
||||
i.setPackage(context.getPackageName());
|
||||
if (loginWarningAccountName != null) {
|
||||
i.putExtra(EXTRA_LOGIN_WARNING_FOR_ACCOUNT, loginWarningAccountName);
|
||||
}
|
||||
if (loginWarningReason != null) {
|
||||
i.putExtra(EXTRA_LOGIN_WARNING_REASON_FOR_ACCOUNT, loginWarningReason);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Intent getIntent() {
|
||||
final Intent intent = super.getIntent();
|
||||
|
@ -116,17 +90,6 @@ public class AccountSettings extends MailPreferenceActivity {
|
|||
return modIntent;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Launch generic settings and pre-enable the debug preferences
|
||||
*/
|
||||
public static void actionSettingsWithDebug(Context fromContext) {
|
||||
final Intent i = new Intent(fromContext, AccountSettings.class);
|
||||
i.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
i.putExtra(EXTRA_ENABLE_DEBUG, true);
|
||||
fromContext.startActivity(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -149,20 +112,11 @@ public class AccountSettings extends MailPreferenceActivity {
|
|||
} else if (i.hasExtra(EditSettingsExtras.EXTRA_FOLDER)) {
|
||||
launchMailboxSettings(i);
|
||||
return;
|
||||
} else if (i.hasExtra(EXTRA_NO_ACCOUNTS)) {
|
||||
final Intent setupIntent = AccountSetupFinal.actionNewAccountWithResultIntent(this);
|
||||
startActivity(setupIntent);
|
||||
finish();
|
||||
return;
|
||||
} else {
|
||||
// Otherwise, we're called from within the Email app and look for our extras
|
||||
final long accountId = IntentUtilities.getAccountIdFromIntent(i);
|
||||
if (accountId != -1) {
|
||||
String loginWarningAccount = i.getStringExtra(EXTRA_LOGIN_WARNING_FOR_ACCOUNT);
|
||||
String loginWarningReason =
|
||||
i.getStringExtra(EXTRA_LOGIN_WARNING_REASON_FOR_ACCOUNT);
|
||||
final Bundle args = AccountSettingsFragment.buildArguments(accountId,
|
||||
loginWarningAccount, loginWarningReason);
|
||||
final Bundle args = AccountSettingsFragment.buildArguments(accountId);
|
||||
startPreferencePanel(AccountSettingsFragment.class.getName(), args,
|
||||
0, null, null, 0);
|
||||
}
|
||||
|
@ -224,9 +178,6 @@ public class AccountSettings extends MailPreferenceActivity {
|
|||
// when necessary.
|
||||
onBackPressed();
|
||||
break;
|
||||
case R.id.add_new_account:
|
||||
onAddNewAccount();
|
||||
break;
|
||||
case R.id.feedback_menu_item:
|
||||
Utils.sendFeedback(this, mFeedbackUri, false /* reportingProblem */);
|
||||
break;
|
||||
|
@ -242,7 +193,6 @@ public class AccountSettings extends MailPreferenceActivity {
|
|||
return true;
|
||||
}
|
||||
|
||||
|
||||
private void launchMailboxSettings(Intent intent) {
|
||||
final Folder folder = intent.getParcelableExtra(EditSettingsExtras.EXTRA_FOLDER);
|
||||
|
||||
|
|
|
@ -17,14 +17,10 @@
|
|||
package com.android.email.activity.setup;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.AlertDialog;
|
||||
import android.app.Dialog;
|
||||
import android.app.DialogFragment;
|
||||
import android.app.LoaderManager;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.ContentValues;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.Loader;
|
||||
import android.content.res.Resources;
|
||||
|
@ -44,13 +40,9 @@ import android.preference.Preference.OnPreferenceClickListener;
|
|||
import android.provider.CalendarContract;
|
||||
import android.provider.ContactsContract;
|
||||
import android.provider.Settings;
|
||||
import android.text.SpannableString;
|
||||
import android.text.TextUtils;
|
||||
import android.text.method.LinkMovementMethod;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuInflater;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.android.email.R;
|
||||
import com.android.email.SecurityPolicy;
|
||||
|
@ -90,9 +82,6 @@ public class AccountSettingsFragment extends MailAccountPrefsFragment
|
|||
implements Preference.OnPreferenceChangeListener {
|
||||
|
||||
private static final String ARG_ACCOUNT_ID = "account_id";
|
||||
private static final String ARG_LOGIN_WARNING_FOR_ACCOUNT = "warning_for_account";
|
||||
private static final String ARG_LOGIN_WARNING_REASON_FOR_ACCOUNT = "warning_for_account_reason";
|
||||
|
||||
|
||||
public static final String PREFERENCE_DESCRIPTION = "account_description";
|
||||
private static final String PREFERENCE_NAME = "account_name";
|
||||
|
@ -162,15 +151,11 @@ public class AccountSettingsFragment extends MailAccountPrefsFragment
|
|||
}
|
||||
|
||||
/**
|
||||
* When launching for the login warning, we don't have the account email address, so we use the
|
||||
* account ID, along with a few strings explaining the warning.
|
||||
* If launching with an account ID, use this method to build the arguments.
|
||||
*/
|
||||
public static Bundle buildArguments(final long accountId, final String warningAccount,
|
||||
final String warningReason) {
|
||||
final Bundle b = new Bundle(3);
|
||||
public static Bundle buildArguments(final long accountId) {
|
||||
final Bundle b = new Bundle(1);
|
||||
b.putLong(ARG_ACCOUNT_ID, accountId);
|
||||
b.putString(ARG_LOGIN_WARNING_FOR_ACCOUNT, warningAccount);
|
||||
b.putString(ARG_LOGIN_WARNING_REASON_FOR_ACCOUNT, warningReason);
|
||||
return b;
|
||||
}
|
||||
|
||||
|
@ -239,19 +224,6 @@ public class AccountSettingsFragment extends MailAccountPrefsFragment
|
|||
getArguments().getLong(ARG_ACCOUNT_ID, -1));
|
||||
}
|
||||
getLoaderManager().initLoader(0, args, new AccountLoaderCallbacks(getActivity()));
|
||||
|
||||
if (savedInstanceState == null) {
|
||||
final String loginWarningAccount =
|
||||
getArguments().getString(ARG_LOGIN_WARNING_FOR_ACCOUNT);
|
||||
final String loginWarningReason =
|
||||
getArguments().getString(ARG_LOGIN_WARNING_REASON_FOR_ACCOUNT);
|
||||
if (loginWarningAccount != null) {
|
||||
// Show dialog (first time only - don't re-show on a rotation)
|
||||
LoginWarningDialog dialog =
|
||||
LoginWarningDialog.newInstance(loginWarningAccount, loginWarningReason);
|
||||
dialog.show(getFragmentManager(), "loginwarning");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -973,72 +945,4 @@ public class AccountSettingsFragment extends MailAccountPrefsFragment
|
|||
AccountServerSettingsActivity.getIntentForOutgoing(getActivity(), account);
|
||||
getActivity().startActivity(intent);
|
||||
}
|
||||
|
||||
/**
|
||||
* Dialog briefly shown in some cases, to indicate the user that login failed. If the user
|
||||
* clicks OK, we simply dismiss the dialog, leaving the user in the account settings for
|
||||
* that account; If the user clicks "cancel", we exit account settings.
|
||||
*/
|
||||
public static class LoginWarningDialog extends DialogFragment
|
||||
implements DialogInterface.OnClickListener {
|
||||
private static final String BUNDLE_KEY_ACCOUNT_NAME = "account_name";
|
||||
private String mReason;
|
||||
|
||||
// Public no-args constructor needed for fragment re-instantiation
|
||||
public LoginWarningDialog() {}
|
||||
|
||||
/**
|
||||
* Create a new dialog.
|
||||
*/
|
||||
public static LoginWarningDialog newInstance(String accountName, String reason) {
|
||||
final LoginWarningDialog dialog = new LoginWarningDialog();
|
||||
final Bundle b = new Bundle(1);
|
||||
b.putString(BUNDLE_KEY_ACCOUNT_NAME, accountName);
|
||||
dialog.setArguments(b);
|
||||
dialog.mReason = reason;
|
||||
return dialog;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
final String accountName = getArguments().getString(BUNDLE_KEY_ACCOUNT_NAME);
|
||||
|
||||
final Context context = getActivity();
|
||||
final Resources res = context.getResources();
|
||||
final AlertDialog.Builder b = new AlertDialog.Builder(context);
|
||||
b.setTitle(R.string.account_settings_login_dialog_title);
|
||||
b.setIconAttribute(android.R.attr.alertDialogIcon);
|
||||
if (mReason != null) {
|
||||
final TextView message = new TextView(context);
|
||||
final String alert = res.getString(
|
||||
R.string.account_settings_login_dialog_reason_fmt, accountName, mReason);
|
||||
SpannableString spannableAlertString = new SpannableString(alert);
|
||||
Linkify.addLinks(spannableAlertString, Linkify.WEB_URLS);
|
||||
message.setText(spannableAlertString);
|
||||
// There must be a better way than specifying size/padding this way
|
||||
// It does work and look right, though
|
||||
final int textSize = res.getDimensionPixelSize(R.dimen.dialog_text_size);
|
||||
message.setTextSize(textSize);
|
||||
final int paddingLeft = res.getDimensionPixelSize(R.dimen.dialog_padding_left);
|
||||
final int paddingOther = res.getDimensionPixelSize(R.dimen.dialog_padding_other);
|
||||
message.setPadding(paddingLeft, paddingOther, paddingOther, paddingOther);
|
||||
message.setMovementMethod(LinkMovementMethod.getInstance());
|
||||
b.setView(message);
|
||||
} else {
|
||||
b.setMessage(res.getString(R.string.account_settings_login_dialog_content_fmt,
|
||||
accountName));
|
||||
}
|
||||
b.setPositiveButton(android.R.string.ok, this);
|
||||
b.setNegativeButton(android.R.string.cancel, this);
|
||||
return b.create();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(DialogInterface dialog, int which) {
|
||||
dismiss();
|
||||
if (which == DialogInterface.BUTTON_NEGATIVE) {
|
||||
getActivity().finish();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,9 +63,6 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||
AccountServerBaseFragment.Callback, AccountSetupCredentialsFragment.Callback,
|
||||
DuplicateAccountDialogFragment.Callback, AccountSetupABFragment.Callback {
|
||||
|
||||
// Set to false before shipping, logs PII
|
||||
private final static boolean ENTER_DEBUG_SCREEN = false;
|
||||
|
||||
/**
|
||||
* Direct access for forcing account creation
|
||||
* For use by continuous automated test system (e.g. in conjunction with monkey tests)
|
||||
|
@ -556,16 +553,6 @@ public class AccountSetupFinal extends AccountSetupActivity
|
|||
} // else fall through
|
||||
case STATE_BASICS_POST:
|
||||
if (shouldDivertToManual()) {
|
||||
// Alternate entry to the debug options screen (for devices without a physical
|
||||
// keyboard):
|
||||
// Username: d@d.d
|
||||
if (ENTER_DEBUG_SCREEN) {
|
||||
if ("d@d.d".equals(mSetupData.getEmail())) {
|
||||
AccountSettings.actionSettingsWithDebug(this);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
mSkipAutoDiscover = true;
|
||||
mIsPreConfiguredProvider = false;
|
||||
mState = STATE_TYPE;
|
||||
|
|
|
@ -1,20 +1,40 @@
|
|||
package com.android.email.activity.setup;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.LoaderManager;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.Loader;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.android.emailcommon.provider.Account;
|
||||
import com.android.emailcommon.provider.EmailContent;
|
||||
import com.android.emailcommon.utility.IntentUtilities;
|
||||
import com.android.mail.ui.MailAsyncTaskLoader;
|
||||
|
||||
/**
|
||||
* This activity is headless. It exists to load the Account object from the given account ID and
|
||||
* then starts the {@link AccountSettings} activity with the appropriate fragment showing in place.
|
||||
* then starts the {@link AccountServerSettingsActivity} activity with the incoming/outgoing
|
||||
* settings fragment
|
||||
*/
|
||||
public class HeadlessAccountSettingsLoader extends Activity {
|
||||
|
||||
public static Uri getIncomingSettingsUri(long accountId) {
|
||||
final Uri.Builder baseUri = Uri.parse("auth://" + EmailContent.EMAIL_PACKAGE_NAME +
|
||||
".ACCOUNT_SETTINGS/incoming/").buildUpon();
|
||||
IntentUtilities.setAccountId(baseUri, accountId);
|
||||
return baseUri.build();
|
||||
}
|
||||
|
||||
public static Uri getOutgoingSettingsUri(long accountId) {
|
||||
final Uri.Builder baseUri = Uri.parse("auth://" + EmailContent.EMAIL_PACKAGE_NAME +
|
||||
".ACCOUNT_SETTINGS/outgoing/").buildUpon();
|
||||
IntentUtilities.setAccountId(baseUri, accountId);
|
||||
return baseUri.build();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
@ -22,8 +42,9 @@ public class HeadlessAccountSettingsLoader extends Activity {
|
|||
final Intent i = getIntent();
|
||||
final long accountID = IntentUtilities.getAccountIdFromIntent(i);
|
||||
|
||||
if ("incoming".equals(i.getData().getLastPathSegment())) {
|
||||
new LoadAccountIncomingSettingsAsyncTask(getApplicationContext())
|
||||
if (savedInstanceState == null) {
|
||||
new LoadAccountIncomingSettingsAsyncTask(getApplicationContext(),
|
||||
"incoming".equals(i.getData().getLastPathSegment()))
|
||||
.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, accountID);
|
||||
}
|
||||
}
|
||||
|
@ -34,9 +55,11 @@ public class HeadlessAccountSettingsLoader extends Activity {
|
|||
*/
|
||||
private class LoadAccountIncomingSettingsAsyncTask extends AsyncTask<Long, Void, Account> {
|
||||
private final Context mContext;
|
||||
private final boolean mIncoming;
|
||||
|
||||
private LoadAccountIncomingSettingsAsyncTask(Context context) {
|
||||
private LoadAccountIncomingSettingsAsyncTask(Context context, boolean incoming) {
|
||||
mContext = context;
|
||||
mIncoming = incoming;
|
||||
}
|
||||
|
||||
protected Account doInBackground(Long... params) {
|
||||
|
@ -45,8 +68,12 @@ public class HeadlessAccountSettingsLoader extends Activity {
|
|||
|
||||
protected void onPostExecute(Account result) {
|
||||
// create an Intent to view a new activity
|
||||
final Intent intent =
|
||||
AccountServerSettingsActivity.getIntentForIncoming(mContext, result);
|
||||
final Intent intent;
|
||||
if (mIncoming) {
|
||||
intent = AccountServerSettingsActivity.getIntentForIncoming(mContext, result);
|
||||
} else {
|
||||
intent = AccountServerSettingsActivity.getIntentForOutgoing(mContext, result);
|
||||
}
|
||||
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
|
||||
mContext.startActivity(intent);
|
||||
|
|
|
@ -68,6 +68,7 @@ import com.android.email.R;
|
|||
import com.android.email.SecurityPolicy;
|
||||
import com.android.email.activity.setup.AccountSettingsFragment;
|
||||
import com.android.email.activity.setup.AccountSettingsUtils;
|
||||
import com.android.email.activity.setup.HeadlessAccountSettingsLoader;
|
||||
import com.android.email.service.AttachmentService;
|
||||
import com.android.email.service.EmailServiceUtils;
|
||||
import com.android.email.service.EmailServiceUtils.EmailServiceInfo;
|
||||
|
@ -182,9 +183,6 @@ public class EmailProvider extends ContentProvider
|
|||
private static final String EMAIL_ATTACHMENT_MIME_TYPE =
|
||||
"vnd.android.cursor.item/email-attachment";
|
||||
|
||||
/** The base of the URI that navigates to the settings page to alter email auth credentials */
|
||||
private static Uri BASE_AUTH_URI;
|
||||
|
||||
/** Appended to the notification URI for delete operations */
|
||||
private static final String NOTIFICATION_OP_DELETE = "delete";
|
||||
/** Appended to the notification URI for insert operations */
|
||||
|
@ -1087,9 +1085,6 @@ public class EmailProvider extends ContentProvider
|
|||
UIPROVIDER_RECENT_FOLDERS_NOTIFIER =
|
||||
Uri.parse("content://" + uiNotificationAuthority + "/uirecentfolders");
|
||||
|
||||
BASE_AUTH_URI = Uri.parse("auth://" + EmailContent.EMAIL_PACKAGE_NAME +
|
||||
".INCOMING_SETTINGS/incoming/");
|
||||
|
||||
// All accounts
|
||||
sURIMatcher.addURI(EmailContent.AUTHORITY, "account", ACCOUNT);
|
||||
// A specific account
|
||||
|
@ -3311,12 +3306,6 @@ public class EmailProvider extends ContentProvider
|
|||
.appendQueryParameter("account", account).build().toString();
|
||||
}
|
||||
|
||||
private static String getExternalUriStringReathentication(long accountId) {
|
||||
final Uri.Builder builder = BASE_AUTH_URI.buildUpon();
|
||||
IntentUtilities.setAccountId(builder, accountId);
|
||||
return builder.build().toString();
|
||||
}
|
||||
|
||||
private static String getBits(int bitField) {
|
||||
StringBuilder sb = new StringBuilder(" ");
|
||||
for (int i = 0; i < 32; i++, bitField >>= 1) {
|
||||
|
@ -3431,7 +3420,8 @@ public class EmailProvider extends ContentProvider
|
|||
}
|
||||
if (projectionColumns.contains(UIProvider.AccountColumns.REAUTHENTICATION_INTENT_URI)) {
|
||||
values.put(UIProvider.AccountColumns.REAUTHENTICATION_INTENT_URI,
|
||||
getExternalUriStringReathentication(accountId));
|
||||
HeadlessAccountSettingsLoader.getIncomingSettingsUri(accountId)
|
||||
.toString());
|
||||
}
|
||||
if (projectionColumns.contains(UIProvider.AccountColumns.MIME_TYPE)) {
|
||||
values.put(UIProvider.AccountColumns.MIME_TYPE, EMAIL_APP_MIME_TYPE);
|
||||
|
|
|
@ -40,22 +40,6 @@ public class AccountService extends Service {
|
|||
|
||||
private final IAccountService.Stub mBinder = new IAccountService.Stub() {
|
||||
|
||||
@Override
|
||||
public void notifyLoginFailed(long accountId, String reason) {
|
||||
NotificationController nc = NotificationController.getInstance(mContext);
|
||||
nc.showLoginFailedNotification(accountId, reason);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyLoginSucceeded(long accountId) {
|
||||
NotificationController.getInstance(mContext).cancelLoginFailedNotification(accountId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reconcileAccounts(String protocol, String accountManagerType) {
|
||||
// TODO: No longer used, delete this.
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getAccountColor(long accountId) {
|
||||
return ResourceHelper.getInstance(mContext).getAccountColor(accountId);
|
||||
|
|
|
@ -1134,7 +1134,7 @@ public class AttachmentService extends Service implements Runnable {
|
|||
EmailContent.delete(this, Attachment.CONTENT_URI, attachment.mId);
|
||||
// TODO: Talk to UX about whether this is even worth doing
|
||||
NotificationController nc = NotificationController.getInstance(this);
|
||||
nc.showDownloadForwardFailedNotification(attachment);
|
||||
nc.showDownloadForwardFailedNotificationSynchronous(attachment);
|
||||
deleted = true;
|
||||
LogUtils.w(LOG_TAG, "Deleting forwarded attachment #%d for message #%d",
|
||||
attachmentId, attachment.mMessageKey);
|
||||
|
|
|
@ -38,7 +38,6 @@ import com.android.email.EmailIntentService;
|
|||
import com.android.email.Preferences;
|
||||
import com.android.email.R;
|
||||
import com.android.email.SecurityPolicy;
|
||||
import com.android.email.activity.setup.AccountSettings;
|
||||
import com.android.email.provider.AccountReconciler;
|
||||
import com.android.emailcommon.Logging;
|
||||
import com.android.emailcommon.VendorPolicyLoader;
|
||||
|
@ -74,10 +73,6 @@ public class EmailBroadcastProcessorService extends IntentService {
|
|||
// Action used for BroadcastReceiver entry point
|
||||
private static final String ACTION_BROADCAST = "broadcast_receiver";
|
||||
|
||||
// Dialing "*#*#36245#*#*" to open the debug screen. "36245" = "email"
|
||||
private static final String ACTION_SECRET_CODE = "android.provider.Telephony.SECRET_CODE";
|
||||
private static final String SECRET_CODE_HOST_DEBUG_SCREEN = "36245";
|
||||
|
||||
// This is a helper used to process DeviceAdminReceiver messages
|
||||
private static final String ACTION_DEVICE_POLICY_ADMIN = "com.android.email.devicepolicy";
|
||||
private static final String EXTRA_DEVICE_POLICY_ADMIN = "message_code";
|
||||
|
@ -133,9 +128,6 @@ public class EmailBroadcastProcessorService extends IntentService {
|
|||
|
||||
if (Intent.ACTION_BOOT_COMPLETED.equals(broadcastAction)) {
|
||||
onBootCompleted();
|
||||
} else if (ACTION_SECRET_CODE.equals(broadcastAction)
|
||||
&& SECRET_CODE_HOST_DEBUG_SCREEN.equals(broadcastIntent.getData().getHost())) {
|
||||
AccountSettings.actionSettingsWithDebug(this);
|
||||
} else if (AccountManager.LOGIN_ACCOUNTS_CHANGED_ACTION.equals(broadcastAction)) {
|
||||
onSystemAccountChanged();
|
||||
} else if (Intent.ACTION_LOCALE_CHANGED.equals(broadcastAction) ||
|
||||
|
|
|
@ -472,7 +472,8 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
|
|||
} catch (MessagingException me) {
|
||||
// report error for this message, but keep trying others
|
||||
if (me instanceof AuthenticationFailedException) {
|
||||
nc.showLoginFailedNotification(account.mId);
|
||||
nc.showLoginFailedNotificationSynchronous(account.mId,
|
||||
false /* incoming */);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
@ -509,7 +510,7 @@ public abstract class EmailServiceStub extends IEmailService.Stub implements IEm
|
|||
nc.cancelLoginFailedNotification(account.mId);
|
||||
} catch (MessagingException me) {
|
||||
if (me instanceof AuthenticationFailedException) {
|
||||
nc.showLoginFailedNotification(account.mId);
|
||||
nc.showLoginFailedNotificationSynchronous(account.mId, false /* incoming */);
|
||||
}
|
||||
} finally {
|
||||
c.close();
|
||||
|
|
|
@ -178,7 +178,7 @@ public class ImapService extends Service {
|
|||
}
|
||||
if (e instanceof AuthenticationFailedException) {
|
||||
// Generate authentication notification
|
||||
nc.showLoginFailedNotification(account.mId);
|
||||
nc.showLoginFailedNotificationSynchronous(account.mId, true /* incoming */);
|
||||
}
|
||||
throw e;
|
||||
} finally {
|
||||
|
|
|
@ -118,7 +118,7 @@ public class Pop3Service extends Service {
|
|||
}
|
||||
if (e instanceof AuthenticationFailedException) {
|
||||
// Generate authentication notification
|
||||
nc.showLoginFailedNotification(account.mId);
|
||||
nc.showLoginFailedNotificationSynchronous(account.mId, true /* incoming */);
|
||||
}
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ import android.content.Intent;
|
|||
import android.net.Uri;
|
||||
|
||||
import com.android.email.R;
|
||||
import com.android.email.activity.setup.AccountSettings;
|
||||
import com.android.email.activity.setup.AccountSetupFinal;
|
||||
|
||||
public class EmailAccountCacheProvider extends MailAppProvider {
|
||||
// Content provider for Email
|
||||
|
@ -42,12 +42,7 @@ public class EmailAccountCacheProvider extends MailAppProvider {
|
|||
|
||||
@Override
|
||||
protected Intent getNoAccountsIntent(Context context) {
|
||||
Intent intent = new Intent();
|
||||
intent.setPackage(context.getPackageName());
|
||||
intent.setAction(Intent.ACTION_EDIT);
|
||||
intent.setData(Uri.parse("content://ui.email.android.com/settings"));
|
||||
intent.putExtra(AccountSettings.EXTRA_NO_ACCOUNTS, true);
|
||||
return intent;
|
||||
return AccountSetupFinal.actionNewAccountWithResultIntent(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -162,8 +162,8 @@ public class AccountSettingsTests extends ActivityInstrumentationTestCase2<Accou
|
|||
mAccount.save(mContext);
|
||||
mAccountId = mAccount.mId;
|
||||
|
||||
// accountId, loginWarningAccountName, loginWarningReason
|
||||
return AccountSettings.createAccountSettingsIntent(mContext, mAccountId, null, null);
|
||||
// TODO: We don't have an intent that takes an account object
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue