use of android.preference.Preference.OnPreferenceClickListener in project android_packages_apps_Settings by LineageOS.
the class VpnSettings method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.vpn_settings);
// restore VpnProfile list and construct VpnPreference map
mVpnListContainer = (PreferenceCategory) findPreference(PREF_VPN_LIST);
// set up the "add vpn" preference
mAddVpn = (PreferenceScreen) findPreference(PREF_ADD_VPN);
mAddVpn.setOnPreferenceClickListener(new OnPreferenceClickListener() {
public boolean onPreferenceClick(Preference preference) {
startVpnTypeSelection();
return true;
}
});
// for long-press gesture on a profile preference
registerForContextMenu(getListView());
// listen to vpn connectivity event
mVpnManager.registerConnectivityReceiver(mConnectivityReceiver);
retrieveVpnListFromStorage();
checkVpnConnectionStatusInBackground();
}
use of android.preference.Preference.OnPreferenceClickListener in project AndroidChromium by JackyAndroid.
the class AccountManagementFragment method configureSignOutSwitch.
private void configureSignOutSwitch() {
boolean isChildAccount = ChildAccountService.isChildAccount();
Preference signOutSwitch = findPreference(PREF_SIGN_OUT);
if (isChildAccount) {
getPreferenceScreen().removePreference(signOutSwitch);
} else {
signOutSwitch.setEnabled(getSignOutAllowedPreferenceValue(getActivity()));
signOutSwitch.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (!isVisible() || !isResumed())
return false;
if (ChromeSigninController.get(getActivity()).isSignedIn() && getSignOutAllowedPreferenceValue(getActivity())) {
AccountManagementScreenHelper.logEvent(ProfileAccountManagementMetrics.TOGGLE_SIGNOUT, mGaiaServiceType);
String managementDomain = SigninManager.get(getActivity()).getManagementDomain();
if (managementDomain != null) {
// Show the 'You are signing out of a managed account' dialog.
ConfirmManagedSyncDataDialog.showSignOutFromManagedAccountDialog(AccountManagementFragment.this, getFragmentManager(), getResources(), managementDomain);
} else {
// Show the 'You are signing out' dialog.
SignOutDialogFragment signOutFragment = new SignOutDialogFragment();
Bundle args = new Bundle();
args.putInt(SHOW_GAIA_SERVICE_TYPE_EXTRA, mGaiaServiceType);
signOutFragment.setArguments(args);
signOutFragment.setTargetFragment(AccountManagementFragment.this, 0);
signOutFragment.show(getFragmentManager(), SIGN_OUT_DIALOG_TAG);
}
return true;
}
return false;
}
});
}
}
use of android.preference.Preference.OnPreferenceClickListener in project AndroidChromium by JackyAndroid.
the class TranslatePreferences method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.translate_preferences);
getActivity().setTitle(R.string.google_translate);
setHasOptionsMenu(true);
final Context context = getActivity();
if (context == null)
return;
ChromeSwitchPreference translateSwitch = (ChromeSwitchPreference) findPreference(PREF_TRANSLATE_SWITCH);
boolean isTranslateEnabled = PrefServiceBridge.getInstance().isTranslateEnabled();
translateSwitch.setChecked(isTranslateEnabled);
translateSwitch.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
PrefServiceBridge.getInstance().setTranslateEnabled((boolean) newValue);
return true;
}
});
translateSwitch.setManagedPreferenceDelegate(new ManagedPreferenceDelegate() {
@Override
public boolean isPreferenceControlledByPolicy(Preference preference) {
return PrefServiceBridge.getInstance().isTranslateManaged();
}
});
ButtonPreference resetTranslateButton = (ButtonPreference) findPreference(PREF_RESET_TRANSLATE_BUTTON);
resetTranslateButton.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
PrefServiceBridge.getInstance().resetTranslateDefaults();
Toast.makeText(getActivity(), getString(R.string.translate_prefs_toast_description), Toast.LENGTH_SHORT).show();
return true;
}
});
}
use of android.preference.Preference.OnPreferenceClickListener in project newsrob by marianokamp.
the class SettingsActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
final EntryManager em = EntryManager.getInstance(this);
addPreferencesFromResource(R.xml.settings);
getPreferenceScreen().setOnPreferenceChangeListener(em);
if (SDKVersionUtil.getVersion() < 8)
disableSetting(em, EntryManager.SETTINGS_PLUGINS, "Froyo+");
if (SDKVersionUtil.getVersion() < 11) {
disableSetting(em, EntryManager.SETTINGS_HW_ACCEL_LISTS_ENABLED, "HC+ only");
disableSetting(em, EntryManager.SETTINGS_HW_ACCEL_ADV_ENABLED, "HC+ only");
}
if (!em.isProVersion()) {
disableSetting(em, EntryManager.SETTINGS_KEEP_STARRED);
disableSetting(em, EntryManager.SETTINGS_KEEP_SHARED);
disableSetting(em, EntryManager.SETTINGS_KEEP_NOTES);
disableSetting(em, EntryManager.SETTINGS_UI_THEME);
disableSetting(em, EntryManager.SETTINGS_SYNC_NEWSROB_ONLY_ENABLED);
}
if (em.shouldHWZoomControlsBeDisabled()) {
Preference pref = getPreferenceScreen().findPreference(EntryManager.SETTINGS_HOVERING_ZOOM_CONTROLS_ENABLED);
if (pref != null) {
pref.setEnabled(false);
if (pref.getSummary() != null)
pref.setSummary("Disabled until HTC fixes a bug that hurts this function. Sorry.");
}
}
if (em.shouldSyncInProgressNotificationBeDisabled()) {
Preference pref = getPreferenceScreen().findPreference(EntryManager.SETTINGS_SYNC_IN_PROGRESS_NOTIFICATION);
if (pref != null) {
pref.setEnabled(false);
if (pref.getSummary() != null)
pref.setSummary("Disabled until HTC/Dell fixes a bug that hurts this function. Sorry.");
}
}
if (em.shouldActionBarLocationOnlyAllowGone()) {
ListPreference pref = (ListPreference) getPreferenceScreen().findPreference(EntryManager.SETTINGS_UI_ACTION_BAR_LOCATION);
if (pref != null) {
pref.setEnabled(false);
CharSequence[] seq = pref.getEntries();
CharSequence[] newSeq = new CharSequence[] { seq[2] };
pref.setEntries(newSeq);
getPreferenceScreen().removePreference(pref);
}
}
final Preference p = getPreferenceScreen().findPreference(EntryManager.SETTINGS_USAGE_DATA_PERMISSION_GRANTED);
p.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Dialog dialog = DashboardListActivity.createUsageDataCollectionPermissionDialog(em, SettingsActivity.this);
dialog.show();
return true;
}
});
}
use of android.preference.Preference.OnPreferenceClickListener in project Float-Bar by tianzhijiexian.
the class MainActivity method onCreate.
@SuppressWarnings("deprecation")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.prefs_list_content);
addPreferencesFromResource(R.xml.float_preference);
prefs = new Prefs(MainActivity.this);
startcBox = (CheckBoxPreference) findPreference("started");
startcBox.setOnPreferenceChangeListener(this);
sendMail = (Preference) findPreference("mail");
sendMail.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
Util.sendMail(MainActivity.this, "联系作者");
return false;
}
});
returnDefault = (Preference) findPreference("returnDefaultSetting");
returnDefault.setOnPreferenceClickListener(new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
showDialog(MainActivity.this, "恢复默认设置", "确认后悬浮窗将会采用默认的设置", "确定", "取消");
return false;
}
});
// startActivity(new Intent(MainActivity.this,TestActivity.class));
}
Aggregations