Commit 73010a93 authored by Boris Sazonov's avatar Boris Sazonov Committed by Commit Bot

[Signin][Android] Show 'Not signed in' in Settings if signin was disabled

Shows 'Not signed in' in SignInPreference if 'Allow Chrome sign-in'
toggle has been turned off.
Screenshot: https://crbug.com/1133780#c1.

Bug: 1133780
Change-Id: Iea5ad78e1fd6ce42c4244821bdfdf2651d0a7e3e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2440757
Auto-Submit: Boris Sazonov <bsazonov@chromium.org>
Commit-Queue: Tanmoy Mollik <triploblastic@chromium.org>
Reviewed-by: default avatarTanmoy Mollik <triploblastic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#812613}
parent e009dc37
...@@ -18,6 +18,7 @@ import org.chromium.chrome.R; ...@@ -18,6 +18,7 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.firstrun.FirstRunSignInProcessor; import org.chromium.chrome.browser.firstrun.FirstRunSignInProcessor;
import org.chromium.chrome.browser.flags.ChromeFeatureList; import org.chromium.chrome.browser.flags.ChromeFeatureList;
import org.chromium.chrome.browser.preferences.ChromePreferenceKeys; import org.chromium.chrome.browser.preferences.ChromePreferenceKeys;
import org.chromium.chrome.browser.preferences.Pref;
import org.chromium.chrome.browser.preferences.SharedPreferencesManager; import org.chromium.chrome.browser.preferences.SharedPreferencesManager;
import org.chromium.chrome.browser.profiles.Profile; import org.chromium.chrome.browser.profiles.Profile;
import org.chromium.chrome.browser.signin.DisplayableProfileData; import org.chromium.chrome.browser.signin.DisplayableProfileData;
...@@ -32,12 +33,14 @@ import org.chromium.chrome.browser.sync.AndroidSyncSettings; ...@@ -32,12 +33,14 @@ import org.chromium.chrome.browser.sync.AndroidSyncSettings;
import org.chromium.chrome.browser.sync.ProfileSyncService; import org.chromium.chrome.browser.sync.ProfileSyncService;
import org.chromium.chrome.browser.sync.ProfileSyncService.SyncStateChangedListener; import org.chromium.chrome.browser.sync.ProfileSyncService.SyncStateChangedListener;
import org.chromium.components.browser_ui.settings.ManagedPreferencesUtils; import org.chromium.components.browser_ui.settings.ManagedPreferencesUtils;
import org.chromium.components.prefs.PrefService;
import org.chromium.components.signin.AccountManagerFacade; import org.chromium.components.signin.AccountManagerFacade;
import org.chromium.components.signin.AccountManagerFacadeProvider; import org.chromium.components.signin.AccountManagerFacadeProvider;
import org.chromium.components.signin.AccountsChangeObserver; import org.chromium.components.signin.AccountsChangeObserver;
import org.chromium.components.signin.base.CoreAccountInfo; import org.chromium.components.signin.base.CoreAccountInfo;
import org.chromium.components.signin.identitymanager.ConsentLevel; import org.chromium.components.signin.identitymanager.ConsentLevel;
import org.chromium.components.signin.metrics.SigninAccessPoint; import org.chromium.components.signin.metrics.SigninAccessPoint;
import org.chromium.components.user_prefs.UserPrefs;
import org.chromium.ui.base.ViewUtils; import org.chromium.ui.base.ViewUtils;
import java.lang.annotation.Retention; import java.lang.annotation.Retention;
...@@ -53,15 +56,18 @@ public class SignInPreference ...@@ -53,15 +56,18 @@ public class SignInPreference
extends Preference implements SignInAllowedObserver, ProfileDataCache.Observer, extends Preference implements SignInAllowedObserver, ProfileDataCache.Observer,
AndroidSyncSettings.AndroidSyncSettingsObserver, AndroidSyncSettings.AndroidSyncSettingsObserver,
SyncStateChangedListener, AccountsChangeObserver { SyncStateChangedListener, AccountsChangeObserver {
@IntDef({State.SIGNIN_DISABLED, State.GENERIC_PROMO, State.PERSONALIZED_PROMO, State.SIGNED_IN}) @IntDef({State.SIGNIN_DISABLED_BY_POLICY, State.SIGNIN_DISALLOWED, State.GENERIC_PROMO,
State.PERSONALIZED_PROMO, State.SIGNED_IN})
@Retention(RetentionPolicy.SOURCE) @Retention(RetentionPolicy.SOURCE)
public @interface State { public @interface State {
int SIGNIN_DISABLED = 0; int SIGNIN_DISABLED_BY_POLICY = 0;
int GENERIC_PROMO = 1; int SIGNIN_DISALLOWED = 1;
int PERSONALIZED_PROMO = 2; int GENERIC_PROMO = 2;
int SIGNED_IN = 3; int PERSONALIZED_PROMO = 3;
int SIGNED_IN = 4;
} }
private final PrefService mPrefService;
private boolean mPersonalizedPromoEnabled = true; private boolean mPersonalizedPromoEnabled = true;
private boolean mWasGenericSigninPromoDisplayed; private boolean mWasGenericSigninPromoDisplayed;
private boolean mViewEnabled; private boolean mViewEnabled;
...@@ -78,6 +84,8 @@ public class SignInPreference ...@@ -78,6 +84,8 @@ public class SignInPreference
public SignInPreference(Context context, AttributeSet attrs) { public SignInPreference(Context context, AttributeSet attrs) {
super(context, attrs); super(context, attrs);
mPrefService = UserPrefs.get(Profile.getLastUsedRegularProfile());
int imageSize = context.getResources().getDimensionPixelSize(R.dimen.user_picture_size); int imageSize = context.getResources().getDimensionPixelSize(R.dimen.user_picture_size);
mProfileDataCache = new ProfileDataCache(context, imageSize); mProfileDataCache = new ProfileDataCache(context, imageSize);
mAccountManagerFacade = AccountManagerFacadeProvider.getInstance(); mAccountManagerFacade = AccountManagerFacadeProvider.getInstance();
...@@ -166,7 +174,12 @@ public class SignInPreference ...@@ -166,7 +174,12 @@ public class SignInPreference
if (IdentityServicesProvider.get() if (IdentityServicesProvider.get()
.getSigninManager(Profile.getLastUsedRegularProfile()) .getSigninManager(Profile.getLastUsedRegularProfile())
.isSigninDisabledByPolicy()) { .isSigninDisabledByPolicy()) {
setupSigninDisabled(); // TODO(https://crbug.com/1133739): Clean up after revising isSigninDisabledByPolicy.
if (mPrefService.isManagedPreference(Pref.SIGNIN_ALLOWED)) {
setupSigninDisabledByPolicy();
} else {
setupSigninDisallowed();
}
return; return;
} }
...@@ -205,8 +218,8 @@ public class SignInPreference ...@@ -205,8 +218,8 @@ public class SignInPreference
setupGenericPromo(); setupGenericPromo();
} }
private void setupSigninDisabled() { private void setupSigninDisabledByPolicy() {
setState(State.SIGNIN_DISABLED); setState(State.SIGNIN_DISABLED_BY_POLICY);
setLayoutResource(R.layout.account_management_account_row); setLayoutResource(R.layout.account_management_account_row);
setTitle(R.string.sign_in_to_chrome); setTitle(R.string.sign_in_to_chrome);
setSummary(R.string.sign_in_to_chrome_disabled_summary); setSummary(R.string.sign_in_to_chrome_disabled_summary);
...@@ -222,6 +235,21 @@ public class SignInPreference ...@@ -222,6 +235,21 @@ public class SignInPreference
mWasGenericSigninPromoDisplayed = false; mWasGenericSigninPromoDisplayed = false;
} }
private void setupSigninDisallowed() {
// TODO(https://crbug.com/1133743): Revise the preference behavior.
setState(State.SIGNIN_DISALLOWED);
setLayoutResource(R.layout.account_management_account_row);
setTitle(R.string.signin_pref_disallowed_title);
setSummary(null);
setFragment(null);
setIcon(AppCompatResources.getDrawable(getContext(), R.drawable.logo_avatar_anonymous));
setWidgetLayoutResource(0);
setViewEnabled(false);
setOnPreferenceClickListener(null);
mSigninPromoController = null;
mWasGenericSigninPromoDisplayed = false;
}
private void setupPersonalizedPromo() { private void setupPersonalizedPromo() {
setState(State.PERSONALIZED_PROMO); setState(State.PERSONALIZED_PROMO);
setLayoutResource(R.layout.personalized_signin_promo_view_settings); setLayoutResource(R.layout.personalized_signin_promo_view_settings);
......
...@@ -275,6 +275,9 @@ CHAR-LIMIT guidelines: ...@@ -275,6 +275,9 @@ CHAR-LIMIT guidelines:
<message name="IDS_PREFS_SYNC_AND_SERVICES_CONTENT_DESCRIPTION" desc="The accessibility text to read when the 'Sync and Google services' Settings page is opened from the sign-in page. This text is attached to the 'Navigate Up' button shown at the top of the screen. The first two sentences describe the screen that is currently shown to the user, while 'Navigate up' is a description for the button this text is attached to. 'Navigate up' should match TC ID 6794660482873516081."> <message name="IDS_PREFS_SYNC_AND_SERVICES_CONTENT_DESCRIPTION" desc="The accessibility text to read when the 'Sync and Google services' Settings page is opened from the sign-in page. This text is attached to the 'Navigate Up' button shown at the top of the screen. The first two sentences describe the screen that is currently shown to the user, while 'Navigate up' is a description for the button this text is attached to. 'Navigate up' should match TC ID 6794660482873516081.">
You are currently customizing your Sync and Google service settings. To finish turning on sync, tap the Confirm button near the bottom of the screen. Navigate up You are currently customizing your Sync and Google service settings. To finish turning on sync, tap the Confirm button near the bottom of the screen. Navigate up
</message> </message>
<message name="IDS_SIGNIN_PREF_DISALLOWED_TITLE" desc="Title for the signin entry in Settings when signin is disallowed.">
Not signed in
</message>
<message name="IDS_SIGNIN_PREF_SUMMARY" desc="Summary for the entry in Settings to sign in to Chrome, explaining benefits of signing in."> <message name="IDS_SIGNIN_PREF_SUMMARY" desc="Summary for the entry in Settings to sign in to Chrome, explaining benefits of signing in.">
Sync and personalize across devices Sync and personalize across devices
</message> </message>
......
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