use of org.chromium.chrome.browser.preferences.ChromeBasePreference 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);
}
}
use of org.chromium.chrome.browser.preferences.ChromeBasePreference in project AndroidChromium by JackyAndroid.
the class AccountManagementFragment method configureAddAccountPreference.
private void configureAddAccountPreference() {
ChromeBasePreference addAccount = (ChromeBasePreference) findPreference(PREF_ADD_ACCOUNT);
if (ChildAccountService.isChildAccount()) {
getPreferenceScreen().removePreference(addAccount);
} else {
addAccount.setTitle(getResources().getString(R.string.account_management_add_account_title));
addAccount.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (!isVisible() || !isResumed())
return false;
AccountManagementScreenHelper.logEvent(ProfileAccountManagementMetrics.ADD_ACCOUNT, mGaiaServiceType);
AccountAdder.getInstance().addAccount(getActivity(), AccountAdder.ADD_ACCOUNT_RESULT);
// Return to the last opened tab if triggered from the content area.
if (mGaiaServiceType != AccountManagementScreenHelper.GAIA_SERVICE_TYPE_NONE) {
if (isAdded())
getActivity().finish();
}
return true;
}
});
addAccount.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
return !canAddAccounts();
}
});
}
}
use of org.chromium.chrome.browser.preferences.ChromeBasePreference in project AndroidChromium by JackyAndroid.
the class SavePasswordsPreferences method displayManageAccountLink.
private void displayManageAccountLink() {
if (getPreferenceScreen().findPreference(PREF_MANAGE_ACCOUNT_LINK) == null) {
if (mLinkPref == null) {
ForegroundColorSpan colorSpan = new ForegroundColorSpan(ApiCompatibilityUtils.getColor(getResources(), R.color.pref_accent_color));
SpannableString title = SpanApplier.applySpans(getString(R.string.manage_passwords_text), new SpanApplier.SpanInfo("<link>", "</link>", colorSpan));
mLinkPref = new ChromeBasePreference(getActivity());
mLinkPref.setKey(PREF_MANAGE_ACCOUNT_LINK);
mLinkPref.setTitle(title);
mLinkPref.setOnPreferenceClickListener(this);
mLinkPref.setOrder(ORDER_MANAGE_ACCOUNT_LINK);
}
getPreferenceScreen().addPreference(mLinkPref);
}
}
use of org.chromium.chrome.browser.preferences.ChromeBasePreference in project AndroidChromium by JackyAndroid.
the class SingleCategoryPreferences method configureGlobalToggles.
private void configureGlobalToggles() {
// Only some have a global toggle at the top.
ChromeSwitchPreference globalToggle = (ChromeSwitchPreference) getPreferenceScreen().findPreference(READ_WRITE_TOGGLE_KEY);
// Configure/hide the third-party cookie toggle, as needed.
Preference thirdPartyCookies = getPreferenceScreen().findPreference(THIRD_PARTY_COOKIES_TOGGLE_KEY);
if (mCategory.showCookiesSites()) {
thirdPartyCookies.setOnPreferenceChangeListener(this);
updateThirdPartyCookiesCheckBox();
} else {
getPreferenceScreen().removePreference(thirdPartyCookies);
}
// Configure/hide the notifications vibrate toggle, as needed.
Preference notificationsVibrate = getPreferenceScreen().findPreference(NOTIFICATIONS_VIBRATE_TOGGLE_KEY);
if (mCategory.showNotificationsSites()) {
notificationsVibrate.setOnPreferenceChangeListener(this);
updateNotificationsVibrateCheckBox();
} else {
getPreferenceScreen().removePreference(notificationsVibrate);
}
// Show/hide the link that explains protected media settings, as needed.
if (!mCategory.showProtectedMediaSites()) {
getPreferenceScreen().removePreference(getPreferenceScreen().findPreference(EXPLAIN_PROTECTED_MEDIA_KEY));
}
if (mCategory.showAllSites() || mCategory.showStorageSites()) {
getPreferenceScreen().removePreference(globalToggle);
getPreferenceScreen().removePreference(getPreferenceScreen().findPreference(ALLOWED_GROUP));
getPreferenceScreen().removePreference(getPreferenceScreen().findPreference(BLOCKED_GROUP));
} else {
// When this menu opens, make sure the Blocked list is collapsed.
if (!mGroupByAllowBlock) {
mBlockListExpanded = false;
mAllowListExpanded = true;
}
mGroupByAllowBlock = true;
PreferenceGroup allowedGroup = (PreferenceGroup) getPreferenceScreen().findPreference(ALLOWED_GROUP);
PreferenceGroup blockedGroup = (PreferenceGroup) getPreferenceScreen().findPreference(BLOCKED_GROUP);
if (mCategory.showPermissionBlockedMessage(getActivity())) {
getPreferenceScreen().removePreference(globalToggle);
getPreferenceScreen().removePreference(allowedGroup);
getPreferenceScreen().removePreference(blockedGroup);
// Show the link to system settings since permission is disabled.
ChromeBasePreference osWarning = new ChromeBasePreference(getActivity(), null);
ChromeBasePreference osWarningExtra = new ChromeBasePreference(getActivity(), null);
mCategory.configurePermissionIsOffPreferences(osWarning, osWarningExtra, getActivity(), true);
if (osWarning.getTitle() != null) {
getPreferenceScreen().addPreference(osWarning);
}
if (osWarningExtra.getTitle() != null) {
getPreferenceScreen().addPreference(osWarningExtra);
}
} else {
allowedGroup.setOnPreferenceClickListener(this);
blockedGroup.setOnPreferenceClickListener(this);
// Determine what toggle to use and what it should display.
int contentType = mCategory.toContentSettingsType();
globalToggle.setOnPreferenceChangeListener(this);
globalToggle.setTitle(ContentSettingsResources.getTitle(contentType));
if (mCategory.showGeolocationSites() && PrefServiceBridge.getInstance().isLocationAllowedByPolicy()) {
globalToggle.setSummaryOn(ContentSettingsResources.getGeolocationAllowedSummary());
} else {
globalToggle.setSummaryOn(ContentSettingsResources.getEnabledSummary(contentType));
}
globalToggle.setSummaryOff(ContentSettingsResources.getDisabledSummary(contentType));
if (mCategory.isManaged() && !mCategory.isManagedByCustodian()) {
globalToggle.setIcon(R.drawable.controlled_setting_mandatory);
}
if (mCategory.showAutoplaySites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().isAutoplayEnabled());
} else if (mCategory.showBackgroundSyncSites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().isBackgroundSyncAllowed());
} else if (mCategory.showCameraSites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().isCameraEnabled());
} else if (mCategory.showCookiesSites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().isAcceptCookiesEnabled());
} else if (mCategory.showFullscreenSites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().isFullscreenAllowed());
// The fullscreen global toggle cannot be disabled.
// TODO(mgiuca): Remove this setting entirely (requires deleting all the data;
// see https://crbug.com/591896).
globalToggle.setEnabled(false);
} else if (mCategory.showGeolocationSites()) {
globalToggle.setChecked(LocationSettings.getInstance().isChromeLocationSettingEnabled());
} else if (mCategory.showJavaScriptSites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().javaScriptEnabled());
} else if (mCategory.showMicrophoneSites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().isMicEnabled());
} else if (mCategory.showNotificationsSites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().isNotificationsEnabled());
} else if (mCategory.showPopupSites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().popupsEnabled());
} else if (mCategory.showProtectedMediaSites()) {
globalToggle.setChecked(PrefServiceBridge.getInstance().isProtectedMediaIdentifierEnabled());
}
}
}
}
Aggregations