Search in sources :

Example 41 with PreferenceScreen

use of android.preference.PreferenceScreen in project aware-client by denzilferreira.

the class Aware_Client method onPreferenceTreeClick.

@Override
public boolean onPreferenceTreeClick(PreferenceScreen preferenceScreen, final Preference preference) {
    if (preference instanceof PreferenceScreen) {
        Dialog subpref = ((PreferenceScreen) preference).getDialog();
        ViewGroup root = (ViewGroup) subpref.findViewById(android.R.id.content).getParent();
        Toolbar toolbar = new Toolbar(this);
        toolbar.setBackgroundColor(ContextCompat.getColor(preferenceScreen.getContext(), R.color.primary));
        toolbar.setTitleTextColor(ContextCompat.getColor(preferenceScreen.getContext(), android.R.color.white));
        toolbar.setTitle(preference.getTitle());
        // add to the top
        root.addView(toolbar, 0);
        subpref.setOnDismissListener(new DialogInterface.OnDismissListener() {

            @Override
            public void onDismiss(DialogInterface dialog) {
                new SettingsSync().execute(preference);
            }
        });
    }
    return super.onPreferenceTreeClick(preferenceScreen, preference);
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) DialogInterface(android.content.DialogInterface) Dialog(android.app.Dialog) ViewGroup(android.view.ViewGroup) Toolbar(android.support.v7.widget.Toolbar)

Example 42 with PreferenceScreen

use of android.preference.PreferenceScreen in project xabber-android by redsolution.

the class BaseSettingsFragment method getPreferences.

/**
 * Get values from the UI elements.
 *
 * @param source
 * @return
 */
protected Map<String, Object> getPreferences(Map<String, Object> source) {
    Map<String, Object> result = new HashMap<>();
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    for (int index = 0; index < preferenceScreen.getPreferenceCount(); index++) {
        Preference preference = preferenceScreen.getPreference(index);
        result.put(preference.getKey(), getPreference(preference, source));
    }
    return result;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) HashMap(java.util.HashMap) RingtonePreference(com.xabber.android.ui.widget.RingtonePreference) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference)

Example 43 with PreferenceScreen

use of android.preference.PreferenceScreen in project xabber-android by redsolution.

the class BaseSettingsFragment method onCreateView.

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = super.onCreateView(inflater, container, savedInstanceState);
    onInflate(savedInstanceState);
    PreferenceSummaryHelperActivity.updateSummary(getPreferenceScreen());
    if (savedInstanceState == null)
        operation(Operation.read);
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    for (int index = 0; index < preferenceScreen.getPreferenceCount(); index++) {
        Preference preference = preferenceScreen.getPreference(index);
        preference.setOnPreferenceChangeListener(this);
        if (preference instanceof EditTextPreference)
            onPreferenceChange(preference, ((EditTextPreference) preference).getText());
        else if (preference instanceof CheckBoxPreference)
            onPreferenceChange(preference, ((CheckBoxPreference) preference).isChecked());
        else if (preference instanceof ListPreference)
            onPreferenceChange(preference, ((ListPreference) preference).getValue());
    }
    return view;
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) RingtonePreference(com.xabber.android.ui.widget.RingtonePreference) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) Preference(android.preference.Preference) SwitchPreference(android.preference.SwitchPreference) CheckBoxPreference(android.preference.CheckBoxPreference) EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) View(android.view.View)

Example 44 with PreferenceScreen

use of android.preference.PreferenceScreen in project xabber-android by redsolution.

the class PrivacySettingsFragment method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    addPreferencesFromResource(R.xml.preference_privacy);
    PreferenceScreen preferenceScreen = getPreferenceScreen();
    PreferenceSummaryHelperActivity.updateSummary(preferenceScreen);
}
Also used : PreferenceScreen(android.preference.PreferenceScreen)

Example 45 with PreferenceScreen

use of android.preference.PreferenceScreen in project meatspace-android by RomainPiel.

the class PreferenceDialogFragment method addPreferencesFromResource.

/**
 * Inflates the given XML resource and adds the preference hierarchy to the current
 * preference hierarchy.
 *
 * @param preferencesResId The XML resource ID to inflate.
 */
public void addPreferencesFromResource(int preferencesResId) {
    try {
        Method m = PreferenceManager.class.getDeclaredMethod("inflateFromResource", Context.class, int.class, PreferenceScreen.class);
        m.setAccessible(true);
        PreferenceScreen prefScreen = (PreferenceScreen) m.invoke(mPreferenceManager, getActivity(), preferencesResId, getPreferenceScreen());
        setPreferenceScreen(prefScreen);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) Method(java.lang.reflect.Method)

Aggregations

PreferenceScreen (android.preference.PreferenceScreen)83 Preference (android.preference.Preference)36 ListPreference (android.preference.ListPreference)21 PreferenceCategory (android.preference.PreferenceCategory)17 CheckBoxPreference (android.preference.CheckBoxPreference)16 EditTextPreference (android.preference.EditTextPreference)14 Bundle (android.os.Bundle)13 Method (java.lang.reflect.Method)11 SharedPreferences (android.content.SharedPreferences)9 Intent (android.content.Intent)6 Dialog (android.app.Dialog)5 ArrayList (java.util.ArrayList)5 DialogInterface (android.content.DialogInterface)4 Activity (android.app.Activity)3 Context (android.content.Context)3 MultiSelectListPreference (android.preference.MultiSelectListPreference)3 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)3 PreferenceManager (android.preference.PreferenceManager)3 TwoStatePreference (android.preference.TwoStatePreference)3 View (android.view.View)3