use of android.support.v7.preference.PreferenceScreen in project AndroidChromium by JackyAndroid.
the class SingleWebsitePreferences method onPreferenceClick.
@Override
public boolean onPreferenceClick(Preference preference) {
Bundle extras = preference.peekExtras();
if (extras != null) {
UsbInfo usbInfo = (UsbInfo) extras.getSerializable(EXTRA_USB_INFO);
if (usbInfo != null) {
usbInfo.revoke();
PreferenceScreen preferenceScreen = getPreferenceScreen();
preferenceScreen.removePreference(preference);
mUsbPermissionCount--;
if (!hasPermissionsPreferences()) {
Preference heading = preferenceScreen.findPreference(PREF_PERMISSIONS);
preferenceScreen.removePreference(heading);
}
return true;
}
}
// Handle the Clear & Reset preference click by showing a confirmation.
new AlertDialog.Builder(getActivity(), R.style.AlertDialogTheme).setTitle(R.string.website_reset).setMessage(R.string.website_reset_confirmation).setPositiveButton(R.string.website_reset, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
resetSite();
}
}).setNegativeButton(R.string.cancel, null).show();
return true;
}
use of android.support.v7.preference.PreferenceScreen in project wire-android by wireapp.
the class RootPreferences method onCreatePreferences2.
@Override
public void onCreatePreferences2(Bundle savedInstanceState, String rootKey) {
super.onCreatePreferences2(savedInstanceState, rootKey);
if (BuildConfig.SHOW_DEVELOPER_OPTIONS) {
addPreferencesFromResource(R.xml.preference_root__developer);
findPreference(getString(R.string.pref_dev_avs_screen_key)).setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
getChildFragmentManager().beginTransaction().setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE).add(AvsOptionsDialogFragment.newInstance(), AvsOptionsDialogFragment.TAG).addToBackStack(AvsOptionsDialogFragment.TAG).commit();
return true;
}
});
} else {
addPreferencesFromResource(R.xml.preference_root);
}
inviteButtonPreference = (ButtonPreference) findPreference(getString(R.string.pref_invite_key));
inviteButtonPreference.setAccentColor(getControllerFactory().getAccentColorController().getColor());
inviteButtonPreference.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
sendGenericInvite();
return true;
}
});
devicesPreferenceScreenLike = (BadgeablePreferenceScreenLike) findPreference(getString(R.string.pref_devices_screen_key));
devicesPreferenceScreenLike.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (otrClients != null) {
for (OtrClient client : otrClients) {
client.setVerified(false);
}
}
return false;
}
});
getStoreFactory().getZMessagingApiStore().getApi().onInit(new InitListener() {
@Override
public void onInitialized(Self user) {
otrClientsObserver.setAndUpdate(getStoreFactory().getZMessagingApiStore().getApi().getSelf().getIncomingOtrClients());
}
});
if (savedInstanceState == null) {
boolean showSpotifyLogin = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_SPOTIFY_LOGIN, false);
boolean showOtrDevices = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_OTR_DEVICES, false);
boolean showAccount = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_ACCOUNT, false);
boolean showUsernameEdit = getArguments().getBoolean(ZetaPreferencesActivity.SHOW_USERNAME_EDIT);
final PreferenceManager.OnNavigateToScreenListener navigateToScreenListener = getPreferenceManager().getOnNavigateToScreenListener();
PreferenceScreen preference = null;
if (showAccount) {
preference = (PreferenceScreen) findPreference(getString(R.string.pref_account_screen_key));
} else if (showSpotifyLogin) {
preference = (PreferenceScreen) findPreference(getString(R.string.pref_options_screen_key));
getControllerFactory().getSpotifyController().login(getActivity());
} else if (showOtrDevices) {
preference = devicesPreferenceScreenLike.getPreferenceScreen();
} else if (showUsernameEdit) {
preference = ((BadgeablePreferenceScreenLike) findPreference(getString(R.string.pref_account_screen_key))).getPreferenceScreen();
}
if (preference != null) {
preference.getExtras().putAll(getArguments());
navigateToScreenListener.onNavigateToScreen(preference);
}
}
}
use of android.support.v7.preference.PreferenceScreen in project wire-android by wireapp.
the class BadgeablePreferenceScreenLike method getPreferenceScreen.
public PreferenceScreen getPreferenceScreen() {
PreferenceScreen preferenceScreen = new PreferenceScreen(getContext(), null);
preferenceScreen.getExtras().putAll(getExtras());
preferenceScreen.setTitle(getTitle());
preferenceScreen.setSummary(getSummary());
preferenceScreen.setIcon(getIcon());
preferenceScreen.setKey(getKey());
return preferenceScreen;
}
use of android.support.v7.preference.PreferenceScreen in project wire-android by wireapp.
the class ZetaPreferencesActivity method onBuildPreferenceFragment.
@Override
public PreferenceFragmentCompat onBuildPreferenceFragment(PreferenceScreen preferenceScreen) {
final String rootKey = preferenceScreen.getKey();
final Bundle extras = preferenceScreen.getExtras();
final PreferenceFragmentCompat instance;
if (rootKey.equals(getString(R.string.pref_account_screen_key))) {
instance = AccountPreferences.newInstance(rootKey, extras);
} else if (rootKey.equals(getString(R.string.pref_about_screen_key))) {
instance = AboutPreferences.newInstance(rootKey, extras);
} else if (rootKey.equals(getString(R.string.pref_options_screen_key))) {
instance = OptionsPreferences.newInstance(rootKey, extras);
} else if (rootKey.equals(getString(R.string.pref_support_screen_key))) {
instance = SupportPreferences.newInstance(rootKey, extras);
} else if (rootKey.equals(getString(R.string.pref_advanced_screen_key))) {
instance = AdvancedPreferences.newInstance(rootKey, extras);
} else if (rootKey.equals(getString(R.string.pref_developer_screen_key))) {
instance = DeveloperPreferences.newInstance(rootKey, extras);
} else if (rootKey.equals(getString(R.string.pref_devices_screen_key))) {
instance = DevicesPreferences.newInstance(rootKey, extras);
} else if (rootKey.equals(getString(R.string.pref_device_details_screen_key))) {
instance = DeviceDetailPreferences.newInstance(rootKey, extras);
} else {
instance = RootPreferences.newInstance(rootKey, extras);
}
resetIntentExtras(preferenceScreen);
return instance;
}
use of android.support.v7.preference.PreferenceScreen in project android_frameworks_base by AOSPA.
the class DemoModeFragment method onCreatePreferences.
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
Context context = getContext();
mEnabledSwitch = new SwitchPreference(context);
mEnabledSwitch.setTitle(R.string.enable_demo_mode);
mEnabledSwitch.setOnPreferenceChangeListener(this);
mOnSwitch = new SwitchPreference(context);
mOnSwitch.setTitle(R.string.show_demo_mode);
mOnSwitch.setEnabled(false);
mOnSwitch.setOnPreferenceChangeListener(this);
PreferenceScreen screen = getPreferenceManager().createPreferenceScreen(context);
screen.addPreference(mEnabledSwitch);
screen.addPreference(mOnSwitch);
setPreferenceScreen(screen);
updateDemoModeEnabled();
updateDemoModeOn();
ContentResolver contentResolver = getContext().getContentResolver();
contentResolver.registerContentObserver(Settings.Global.getUriFor(DemoMode.DEMO_MODE_ALLOWED), false, mDemoModeObserver);
contentResolver.registerContentObserver(Settings.Global.getUriFor(DEMO_MODE_ON), false, mDemoModeObserver);
setHasOptionsMenu(true);
}
Aggregations