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);
}
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;
}
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;
}
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);
}
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();
}
}
Aggregations