Search in sources :

Example 1 with Preferences

use of org.chromium.chrome.browser.preferences.Preferences in project AndroidChromium by JackyAndroid.

the class AccountManagementFragment method updateAccountsList.

private void updateAccountsList() {
    PreferenceScreen prefScreen = getPreferenceScreen();
    if (prefScreen == null)
        return;
    for (int i = 0; i < mAccountsListPreferences.size(); i++) {
        prefScreen.removePreference(mAccountsListPreferences.get(i));
    }
    mAccountsListPreferences.clear();
    final Preferences activity = (Preferences) getActivity();
    Account[] accounts = AccountManagerHelper.get(activity).getGoogleAccounts();
    int nextPrefOrder = FIRST_ACCOUNT_PREF_ORDER;
    for (Account account : accounts) {
        ChromeBasePreference pref = new ChromeBasePreference(activity);
        pref.setSelectable(false);
        pref.setTitle(account.name);
        boolean isChildAccount = ChildAccountService.isChildAccount();
        pref.setIcon(new BitmapDrawable(getResources(), isChildAccount ? getBadgedUserPicture(account.name, getResources()) : getUserPicture(account.name, getResources())));
        pref.setOrder(nextPrefOrder++);
        prefScreen.addPreference(pref);
        mAccountsListPreferences.add(pref);
    }
}
Also used : Account(android.accounts.Account) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) PreferenceScreen(android.preference.PreferenceScreen) BitmapDrawable(android.graphics.drawable.BitmapDrawable) Preferences(org.chromium.chrome.browser.preferences.Preferences) Paint(android.graphics.Paint)

Example 2 with Preferences

use of org.chromium.chrome.browser.preferences.Preferences in project AndroidChromium by JackyAndroid.

the class AccountManagementFragment method configureSyncSettings.

private void configureSyncSettings() {
    final Preferences preferences = (Preferences) getActivity();
    final Account account = ChromeSigninController.get(getActivity()).getSignedInUser();
    findPreference(PREF_SYNC_SETTINGS).setOnPreferenceClickListener(new OnPreferenceClickListener() {

        @Override
        public boolean onPreferenceClick(Preference preference) {
            if (!isVisible() || !isResumed())
                return false;
            if (ProfileSyncService.get() == null)
                return true;
            Bundle args = new Bundle();
            args.putString(SyncCustomizationFragment.ARGUMENT_ACCOUNT, account.name);
            preferences.startFragment(SyncCustomizationFragment.class.getName(), args);
            return true;
        }
    });
}
Also used : OnPreferenceClickListener(android.preference.Preference.OnPreferenceClickListener) Account(android.accounts.Account) ChromeBasePreference(org.chromium.chrome.browser.preferences.ChromeBasePreference) SyncPreference(org.chromium.chrome.browser.preferences.SyncPreference) Preference(android.preference.Preference) Bundle(android.os.Bundle) Preferences(org.chromium.chrome.browser.preferences.Preferences)

Aggregations

Account (android.accounts.Account)2 ChromeBasePreference (org.chromium.chrome.browser.preferences.ChromeBasePreference)2 Preferences (org.chromium.chrome.browser.preferences.Preferences)2 Paint (android.graphics.Paint)1 BitmapDrawable (android.graphics.drawable.BitmapDrawable)1 Bundle (android.os.Bundle)1 Preference (android.preference.Preference)1 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)1 PreferenceScreen (android.preference.PreferenceScreen)1 SyncPreference (org.chromium.chrome.browser.preferences.SyncPreference)1