use of org.chromium.components.signin.ChromeSigninController in project AndroidChromium by JackyAndroid.
the class AccountManagementFragment method update.
public void update() {
final Context context = getActivity();
if (context == null)
return;
if (getPreferenceScreen() != null)
getPreferenceScreen().removeAll();
ChromeSigninController signInController = ChromeSigninController.get(context);
if (!signInController.isSignedIn()) {
// The AccountManagementFragment can only be shown when the user is signed in. If the
// user is signed out, exit the fragment.
getActivity().finish();
return;
}
addPreferencesFromResource(R.xml.account_management_preferences);
String signedInAccountName = ChromeSigninController.get(getActivity()).getSignedInAccountName();
String fullName = getCachedUserName(signedInAccountName);
if (TextUtils.isEmpty(fullName)) {
fullName = ProfileDownloader.getCachedFullName(Profile.getLastUsedProfile());
}
if (TextUtils.isEmpty(fullName))
fullName = signedInAccountName;
getActivity().setTitle(fullName);
configureSignOutSwitch();
configureAddAccountPreference();
configureChildAccountPreferences();
configureSyncSettings();
configureGoogleActivityControls();
updateAccountsList();
}
use of org.chromium.components.signin.ChromeSigninController in project AndroidChromium by JackyAndroid.
the class SignInPreference method update.
/**
* Updates the title, summary, and image based on the current sign-in state.
*/
private void update() {
String title;
String summary;
String fragment;
Account account = ChromeSigninController.get(getContext()).getSignedInUser();
if (account == null) {
title = getContext().getString(R.string.sign_in_to_chrome);
summary = getContext().getString(R.string.sign_in_to_chrome_summary);
fragment = null;
} else {
summary = SyncPreference.getSyncStatusSummary(getContext());
fragment = AccountManagementFragment.class.getName();
title = AccountManagementFragment.getCachedUserName(account.name);
if (title == null) {
final Profile profile = Profile.getLastUsedProfile();
String cachedName = ProfileDownloader.getCachedFullName(profile);
Bitmap cachedBitmap = ProfileDownloader.getCachedAvatar(profile);
if (TextUtils.isEmpty(cachedName) || cachedBitmap == null) {
AccountManagementFragment.startFetchingAccountInformation(getContext(), profile, account.name);
}
title = TextUtils.isEmpty(cachedName) ? account.name : cachedName;
}
}
setTitle(title);
setSummary(summary);
setFragment(fragment);
updateSyncStatusIcon();
ChromeSigninController signinController = ChromeSigninController.get(getContext());
boolean enabled = signinController.isSignedIn() || SigninManager.get(getContext()).isSignInAllowed();
if (mViewEnabled != enabled) {
mViewEnabled = enabled;
notifyChanged();
}
if (!enabled)
setFragment(null);
if (SigninManager.get(getContext()).isSigninDisabledByPolicy()) {
setIcon(ManagedPreferencesUtils.getManagedByEnterpriseIconId());
} else {
Resources resources = getContext().getResources();
Bitmap bitmap = AccountManagementFragment.getUserPicture(signinController.getSignedInAccountName(), resources);
setIcon(new BitmapDrawable(resources, bitmap));
}
setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (!AccountSigninActivity.startIfAllowed(getContext(), SigninAccessPoint.SETTINGS)) {
return false;
}
setEnabled(false);
return true;
}
});
if (account == null && enabled) {
RecordUserAction.record("Signin_Impression_FromSettings");
}
}
Aggregations