Disambiguate settings intents

b/13325901

Change-Id: I2843a6bfdac4acbabc758ddc44f1d980b7036aef
This commit is contained in:
Tony Mantler 2014-05-22 13:31:44 -07:00
parent 8b801e915c
commit 4ce1fc7669
4 changed files with 10 additions and 6 deletions

View File

@ -426,7 +426,7 @@ public class NotificationController {
mContext.getString(R.string.login_failed_ticker, account.mDisplayName),
mContext.getString(R.string.login_failed_title),
account.getDisplayName(),
AccountSettings.createAccountSettingsIntent(accountId,
AccountSettings.createAccountSettingsIntent(mContext, accountId,
account.mDisplayName, reason), getLoginFailedNotificationId(accountId));
}
@ -503,7 +503,8 @@ public class NotificationController {
* account settings screen where he can view the list of enforced policies
*/
public void showSecurityChangedNotification(Account account) {
Intent intent = AccountSettings.createAccountSettingsIntent(account.mId, null, null);
Intent intent =
AccountSettings.createAccountSettingsIntent(mContext, account.mId, null, null);
String accountName = account.getDisplayName();
String ticker =
mContext.getString(R.string.security_changed_ticker_fmt, accountName);
@ -517,7 +518,8 @@ public class NotificationController {
* account settings screen where he can view the list of unsupported policies
*/
public void showSecurityUnsupportedNotification(Account account) {
Intent intent = AccountSettings.createAccountSettingsIntent(account.mId, null, null);
Intent intent =
AccountSettings.createAccountSettingsIntent(mContext, account.mId, null, null);
String accountName = account.getDisplayName();
String ticker =
mContext.getString(R.string.security_unsupported_ticker_fmt, accountName);

View File

@ -141,12 +141,13 @@ public class AccountSettings extends PreferenceActivity implements
* for any/all accounts. If an account name string is provided, a warning dialog will be
* displayed as well.
*/
public static Intent createAccountSettingsIntent(long accountId,
String loginWarningAccountName, String loginWarningReason) {
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);
}

View File

@ -43,6 +43,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);

View File

@ -163,7 +163,7 @@ public class AccountSettingsTests extends ActivityInstrumentationTestCase2<Accou
mAccountId = mAccount.mId;
// accountId, loginWarningAccountName, loginWarningReason
return AccountSettings.createAccountSettingsIntent(mAccountId, null, null);
return AccountSettings.createAccountSettingsIntent(mContext, mAccountId, null, null);
}
}