use of android.preference.Preference in project AntennaPod by AntennaPod.
the class PreferenceController method checkItemVisibility.
@SuppressWarnings("deprecation")
private void checkItemVisibility() {
boolean hasFlattrToken = FlattrUtils.hasToken();
ui.findPreference(PreferenceController.PREF_FLATTR_SETTINGS).setEnabled(FlattrUtils.hasAPICredentials());
ui.findPreference(PreferenceController.PREF_FLATTR_AUTH).setEnabled(!hasFlattrToken);
ui.findPreference(PreferenceController.PREF_FLATTR_REVOKE).setEnabled(hasFlattrToken);
ui.findPreference(PreferenceController.PREF_AUTO_FLATTR_PREFS).setEnabled(hasFlattrToken);
boolean autoDownload = UserPreferences.isEnableAutodownload();
ui.findPreference(UserPreferences.PREF_EPISODE_CACHE_SIZE).setEnabled(autoDownload);
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_ON_BATTERY).setEnabled(autoDownload);
ui.findPreference(UserPreferences.PREF_ENABLE_AUTODL_WIFI_FILTER).setEnabled(autoDownload);
setSelectedNetworksEnabled(autoDownload && UserPreferences.isEnableAutodownloadWifiFilter());
ui.findPreference(PREF_SEND_CRASH_REPORT).setEnabled(CrashReportWriter.getFile().exists());
if (Build.VERSION.SDK_INT >= 16) {
ui.findPreference(UserPreferences.PREF_SONIC).setEnabled(true);
} else {
Preference prefSonic = ui.findPreference(UserPreferences.PREF_SONIC);
prefSonic.setSummary("[Android 4.1+]\n" + prefSonic.getSummary());
}
}
use of android.preference.Preference in project AndroidChromium by JackyAndroid.
the class SingleCategoryPreferences method onPreferenceChange.
// OnPreferenceChangeListener:
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
if (READ_WRITE_TOGGLE_KEY.equals(preference.getKey())) {
if (mCategory.isManaged())
return false;
if (mCategory.showAutoplaySites()) {
PrefServiceBridge.getInstance().setAutoplayEnabled((boolean) newValue);
} else if (mCategory.showBackgroundSyncSites()) {
PrefServiceBridge.getInstance().setBackgroundSyncEnabled((boolean) newValue);
} else if (mCategory.showCameraSites()) {
PrefServiceBridge.getInstance().setCameraEnabled((boolean) newValue);
} else if (mCategory.showCookiesSites()) {
PrefServiceBridge.getInstance().setAllowCookiesEnabled((boolean) newValue);
updateThirdPartyCookiesCheckBox();
} else if (mCategory.showFullscreenSites()) {
PrefServiceBridge.getInstance().setFullscreenAllowed((boolean) newValue);
} else if (mCategory.showGeolocationSites()) {
PrefServiceBridge.getInstance().setAllowLocationEnabled((boolean) newValue);
} else if (mCategory.showJavaScriptSites()) {
PrefServiceBridge.getInstance().setJavaScriptEnabled((boolean) newValue);
} else if (mCategory.showMicrophoneSites()) {
PrefServiceBridge.getInstance().setMicEnabled((boolean) newValue);
} else if (mCategory.showNotificationsSites()) {
PrefServiceBridge.getInstance().setNotificationsEnabled((boolean) newValue);
updateNotificationsVibrateCheckBox();
} else if (mCategory.showPopupSites()) {
PrefServiceBridge.getInstance().setAllowPopupsEnabled((boolean) newValue);
} else if (mCategory.showProtectedMediaSites()) {
PrefServiceBridge.getInstance().setProtectedMediaIdentifierEnabled((boolean) newValue);
}
// Categories that support adding exceptions also manage the 'Add site' preference.
if (mCategory.showAutoplaySites() || mCategory.showBackgroundSyncSites() || mCategory.showJavaScriptSites()) {
if ((boolean) newValue) {
Preference addException = getPreferenceScreen().findPreference(ADD_EXCEPTION_KEY);
if (addException != null) {
// Can be null in testing.
getPreferenceScreen().removePreference(addException);
}
} else {
getPreferenceScreen().addPreference(new AddExceptionPreference(getActivity(), ADD_EXCEPTION_KEY, getAddExceptionDialogMessage(), this));
}
}
ChromeSwitchPreference globalToggle = (ChromeSwitchPreference) getPreferenceScreen().findPreference(READ_WRITE_TOGGLE_KEY);
updateAllowedHeader(mAllowedSiteCount, !globalToggle.isChecked());
getInfoForOrigins();
} else if (THIRD_PARTY_COOKIES_TOGGLE_KEY.equals(preference.getKey())) {
PrefServiceBridge.getInstance().setBlockThirdPartyCookiesEnabled(!((boolean) newValue));
} else if (NOTIFICATIONS_VIBRATE_TOGGLE_KEY.equals(preference.getKey())) {
PrefServiceBridge.getInstance().setNotificationsVibrateEnabled((boolean) newValue);
}
return true;
}
use of android.preference.Preference in project AndroidChromium by JackyAndroid.
the class SingleCategoryPreferences method updateThirdPartyCookiesCheckBox.
private void updateThirdPartyCookiesCheckBox() {
ChromeBaseCheckBoxPreference thirdPartyCookiesPref = (ChromeBaseCheckBoxPreference) getPreferenceScreen().findPreference(THIRD_PARTY_COOKIES_TOGGLE_KEY);
thirdPartyCookiesPref.setEnabled(PrefServiceBridge.getInstance().isAcceptCookiesEnabled());
thirdPartyCookiesPref.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
return PrefServiceBridge.getInstance().isBlockThirdPartyCookiesManaged();
}
});
}
use of android.preference.Preference in project AndroidChromium by JackyAndroid.
the class AccountManagementFragment method configureGoogleActivityControls.
private void configureGoogleActivityControls() {
Preference pref = findPreference(PREF_GOOGLE_ACTIVITY_CONTROLS);
pref.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Activity activity = getActivity();
((ChromeApplication) (activity.getApplicationContext())).createGoogleActivityController().openWebAndAppActivitySettings(activity, ChromeSigninController.get(activity).getSignedInAccountName());
RecordUserAction.record("Signin_AccountSettings_GoogleActivityControlsClicked");
return true;
}
});
}
use of android.preference.Preference 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;
}
});
}
Aggregations