Commit 117c4f95 authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Android] Fix account bundling while opening settings page

This CL changes the way an account is bundled into an intent that opens
the settings page for this account: instead of bundling just the name of
the account, the whole account object is bundled now. This is necessary
because Settings app expects the whole account object in the bundle.

Bug: 863370
Change-Id: I95a5ae901183c3cdd96bffd38906cb767a3afef3
Reviewed-on: https://chromium-review.googlesource.com/1152924Reviewed-by: default avatarTed Choc <tedchoc@chromium.org>
Commit-Queue: Boris Sazonov <bsazonov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#579003}
parent d9cbbaa8
...@@ -91,9 +91,6 @@ public class AccountManagementFragment extends PreferenceFragment ...@@ -91,9 +91,6 @@ public class AccountManagementFragment extends PreferenceFragment
public static final String PREF_SIGN_OUT = "sign_out"; public static final String PREF_SIGN_OUT = "sign_out";
public static final String PREF_SIGN_OUT_DIVIDER = "sign_out_divider"; public static final String PREF_SIGN_OUT_DIVIDER = "sign_out_divider";
private static final String ACCOUNT_SETTINGS_ACTION = "android.settings.ACCOUNT_SYNC_SETTINGS";
private static final String ACCOUNT_SETTINGS_ACCOUNT_KEY = "account";
private int mGaiaServiceType; private int mGaiaServiceType;
private Profile mProfile; private Profile mProfile;
...@@ -353,7 +350,7 @@ public class AccountManagementFragment extends PreferenceFragment ...@@ -353,7 +350,7 @@ public class AccountManagementFragment extends PreferenceFragment
pref.setIcon(mProfileDataCache.getProfileDataOrDefault(account.name).getImage()); pref.setIcon(mProfileDataCache.getProfileDataOrDefault(account.name).getImage());
pref.setOnPreferenceClickListener( pref.setOnPreferenceClickListener(
preference -> SigninUtils.openAccountSettingsPage(getActivity(), account.name)); preference -> SigninUtils.openAccountSettingsPage(getActivity(), account));
accountsCategory.addPreference(pref); accountsCategory.addPreference(pref);
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
package org.chromium.chrome.browser.signin; package org.chromium.chrome.browser.signin;
import android.accounts.Account;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
...@@ -21,13 +22,13 @@ public class SigninUtils { ...@@ -21,13 +22,13 @@ public class SigninUtils {
/** /**
* Opens account management page in Settings for a specific account. * Opens account management page in Settings for a specific account.
* @param context Context to use when starting the Activity. * @param context Context to use when starting the Activity.
* @param accountName The account name for which the Settings page should be opened. * @param account The account for which the Settings page should be opened.
* @return Whether or not Android accepted the Intent. * @return Whether or not Android accepted the Intent.
*/ */
public static boolean openAccountSettingsPage(Context context, String accountName) { public static boolean openAccountSettingsPage(Context context, Account account) {
// TODO(https://crbug.com/814441): Fix this on Android O+. // TODO(https://crbug.com/814441): Fix this on Android O+.
Intent intent = new Intent(ACCOUNT_SETTINGS_ACTION); Intent intent = new Intent(ACCOUNT_SETTINGS_ACTION);
intent.putExtra(ACCOUNT_SETTINGS_ACCOUNT_KEY, accountName); intent.putExtra(ACCOUNT_SETTINGS_ACCOUNT_KEY, account);
return IntentUtils.safeStartActivity(context, intent); return IntentUtils.safeStartActivity(context, intent);
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment