Search in sources :

Example 66 with PreferenceScreen

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;
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) PreferenceScreen(android.preference.PreferenceScreen) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) DialogInterface(android.content.DialogInterface) Bundle(android.os.Bundle)

Example 67 with PreferenceScreen

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);
        }
    }
}
Also used : InitListener(com.waz.api.InitListener) PreferenceScreen(android.support.v7.preference.PreferenceScreen) Preference(android.support.v7.preference.Preference) Self(com.waz.api.Self) OtrClient(com.waz.api.OtrClient) PreferenceManager(android.support.v7.preference.PreferenceManager)

Example 68 with PreferenceScreen

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;
}
Also used : PreferenceScreen(android.support.v7.preference.PreferenceScreen)

Example 69 with 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;
}
Also used : Bundle(android.os.Bundle) PreferenceFragmentCompat(android.support.v7.preference.PreferenceFragmentCompat)

Example 70 with PreferenceScreen

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);
}
Also used : Context(android.content.Context) PreferenceScreen(android.support.v7.preference.PreferenceScreen) SwitchPreference(android.support.v14.preference.SwitchPreference) ContentResolver(android.content.ContentResolver)

Aggregations

PreferenceScreen (android.support.v7.preference.PreferenceScreen)115 Preference (android.support.v7.preference.Preference)42 ContentResolver (android.content.ContentResolver)35 SwitchPreference (android.support.v14.preference.SwitchPreference)21 Context (android.content.Context)19 Resources (android.content.res.Resources)16 PreferenceCategory (android.support.v7.preference.PreferenceCategory)14 Intent (android.content.Intent)12 ArrayList (java.util.ArrayList)9 ListPreference (android.support.v7.preference.ListPreference)8 OnPreferenceChangeListener (android.support.v7.preference.Preference.OnPreferenceChangeListener)7 PreferenceGroup (android.support.v7.preference.PreferenceGroup)7 PackageManager (android.content.pm.PackageManager)6 OnPreferenceClickListener (android.support.v7.preference.Preference.OnPreferenceClickListener)6 PreferenceManager (android.support.v7.preference.PreferenceManager)6 Activity (android.app.Activity)5 SharedPreferences (android.content.SharedPreferences)4 Bundle (android.os.Bundle)4 InputMethodInfo (android.view.inputmethod.InputMethodInfo)4 ComponentName (android.content.ComponentName)3