use of android.preference.PreferenceScreen in project Signal-Android by WhisperSystems.
the class SmsMmsPreferenceFragment method initializePlatformSpecificOptions.
private void initializePlatformSpecificOptions() {
PreferenceScreen preferenceScreen = getPreferenceScreen();
Preference defaultPreference = findPreference(KITKAT_DEFAULT_PREF);
Preference allSmsPreference = findPreference(TextSecurePreferences.ALL_SMS_PREF);
Preference allMmsPreference = findPreference(TextSecurePreferences.ALL_MMS_PREF);
Preference manualMmsPreference = findPreference(MMS_PREF);
if (VERSION.SDK_INT >= VERSION_CODES.KITKAT) {
if (allSmsPreference != null)
preferenceScreen.removePreference(allSmsPreference);
if (allMmsPreference != null)
preferenceScreen.removePreference(allMmsPreference);
if (Util.isDefaultSmsProvider(getActivity())) {
defaultPreference.setIntent(new Intent(Settings.ACTION_WIRELESS_SETTINGS));
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_enabled));
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_change_your_default_sms_app));
} else {
Intent intent = new Intent(Telephony.Sms.Intents.ACTION_CHANGE_DEFAULT);
intent.putExtra(Telephony.Sms.Intents.EXTRA_PACKAGE_NAME, getActivity().getPackageName());
defaultPreference.setIntent(intent);
defaultPreference.setTitle(getString(R.string.ApplicationPreferencesActivity_sms_disabled));
defaultPreference.setSummary(getString(R.string.ApplicationPreferencesActivity_touch_to_make_signal_your_default_sms_app));
}
} else if (defaultPreference != null) {
preferenceScreen.removePreference(defaultPreference);
}
if (VERSION.SDK_INT >= VERSION_CODES.LOLLIPOP && manualMmsPreference != null) {
preferenceScreen.removePreference(manualMmsPreference);
}
}
use of android.preference.PreferenceScreen in project SeriesGuide by UweTrottmann.
the class ListWidgetPreferenceFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// use the settings file specific to widgets
getPreferenceManager().setSharedPreferencesName(WidgetSettings.SETTINGS_FILE);
getPreferenceManager().setSharedPreferencesMode(0);
// create a widget specific settings screen
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(getActivity());
int appWidgetId = getArguments().getInt("appWidgetId");
// widget type setting
final ListPreference typePref = new ListPreference(getActivity());
typePref.setKey(WidgetSettings.KEY_PREFIX_WIDGET_LISTTYPE + appWidgetId);
typePref.setTitle(R.string.pref_widget_type);
typePref.setEntries(R.array.widgetType);
typePref.setEntryValues(R.array.widgetTypeData);
typePref.setDefaultValue(getString(R.string.widget_default_type));
typePref.setPositiveButtonText(null);
typePref.setNegativeButtonText(null);
preferenceScreen.addPreference(typePref);
// widget show type sort order setting
final ListPreference sortPref = new ListPreference(getActivity());
sortPref.setKey(WidgetSettings.KEY_PREFIX_WIDGET_SHOWS_SORT_ORDER + appWidgetId);
sortPref.setTitle(R.string.action_shows_sort);
sortPref.setEntries(R.array.widgetShowSortOrder);
sortPref.setEntryValues(R.array.widgetShowSortOrderData);
sortPref.setDefaultValue(getString(R.string.widget_default_show_sort_order));
sortPref.setPositiveButtonText(null);
sortPref.setNegativeButtonText(null);
preferenceScreen.addPreference(sortPref);
// only favorite shows setting
final CheckBoxPreference onlyFavoritesPref = new CheckBoxPreference(getActivity());
onlyFavoritesPref.setKey(WidgetSettings.KEY_PREFIX_WIDGET_ONLY_FAVORITES + appWidgetId);
onlyFavoritesPref.setTitle(R.string.only_favorites);
onlyFavoritesPref.setDefaultValue(false);
preferenceScreen.addPreference(onlyFavoritesPref);
// hide watched setting
final CheckBoxPreference hideWatchedPreference = new CheckBoxPreference(getActivity());
hideWatchedPreference.setKey(WidgetSettings.KEY_PREFIX_WIDGET_HIDE_WATCHED + appWidgetId);
hideWatchedPreference.setTitle(R.string.hide_watched);
hideWatchedPreference.setDefaultValue(true);
preferenceScreen.addPreference(hideWatchedPreference);
// widget theme setting
ListPreference themePref = new ListPreference(getActivity());
themePref.setKey(WidgetSettings.KEY_PREFIX_WIDGET_THEME + appWidgetId);
themePref.setTitle(R.string.pref_theme);
themePref.setEntries(R.array.widgetTheme);
themePref.setEntryValues(R.array.widgetThemeData);
themePref.setDefaultValue("0");
themePref.setPositiveButtonText(null);
themePref.setNegativeButtonText(null);
preferenceScreen.addPreference(themePref);
// background setting
ListPreference backgroundPref = new ListPreference(getActivity());
backgroundPref.setKey(WidgetSettings.KEY_PREFIX_WIDGET_BACKGROUND_OPACITY + appWidgetId);
backgroundPref.setTitle(R.string.pref_widget_opacity);
backgroundPref.setEntries(R.array.widgetOpacity);
backgroundPref.setEntryValues(R.array.widgetOpacityData);
backgroundPref.setDefaultValue(WidgetSettings.DEFAULT_WIDGET_BACKGROUND_OPACITY);
backgroundPref.setPositiveButtonText(null);
backgroundPref.setNegativeButtonText(null);
preferenceScreen.addPreference(backgroundPref);
setPreferenceScreen(preferenceScreen);
bindPreferenceSummaryToValue(getPreferenceManager().getSharedPreferences(), typePref);
bindPreferenceSummaryToValue(getPreferenceManager().getSharedPreferences(), sortPref);
bindPreferenceSummaryToValue(getPreferenceManager().getSharedPreferences(), backgroundPref);
bindPreferenceSummaryToValue(getPreferenceManager().getSharedPreferences(), themePref);
// disable type and background pref for non-supporters
if (!Utils.hasAccessToX(getActivity())) {
typePref.setEnabled(false);
typePref.setSummary(R.string.onlyx);
themePref.setEnabled(false);
themePref.setSummary(R.string.onlyx);
backgroundPref.setEnabled(false);
backgroundPref.setSummary(R.string.onlyx);
}
// disable episode related setting if selecting show widget type
preferenceChangeListener = new SharedPreferences.OnSharedPreferenceChangeListener() {
@Override
public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
if (!isAdded()) {
// no longer attached to activity
return;
}
if (typePref.getKey().equals(key)) {
String newTypeValue = typePref.getValue();
boolean displayingShows = getString(R.string.widget_type_shows).equals(newTypeValue);
sortPref.setEnabled(displayingShows);
hideWatchedPreference.setEnabled(!displayingShows);
}
}
};
// trigger the listener to handle the current state
preferenceChangeListener.onSharedPreferenceChanged(getPreferenceManager().getSharedPreferences(), typePref.getKey());
getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(preferenceChangeListener);
}
use of android.preference.PreferenceScreen in project SeriesGuide by UweTrottmann.
the class AmazonConfigurationFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// use the Amazon extension settings file
getPreferenceManager().setSharedPreferencesName(AmazonSettings.SETTINGS_FILE);
getPreferenceManager().setSharedPreferencesMode(0);
// create a preference screen
PreferenceScreen preferenceScreen = getPreferenceManager().createPreferenceScreen(getActivity());
ListPreference countryPreference = new ListPreference(getActivity());
countryPreference.setKey(AmazonSettings.KEY_COUNTRY);
countryPreference.setTitle(R.string.pref_amazon_domain);
countryPreference.setEntries(R.array.amazonDomainsData);
countryPreference.setEntryValues(R.array.amazonDomainsData);
countryPreference.setDefaultValue(AmazonSettings.DEFAULT_DOMAIN);
countryPreference.setPositiveButtonText(null);
countryPreference.setNegativeButtonText(null);
preferenceScreen.addPreference(countryPreference);
setPreferenceScreen(preferenceScreen);
bindPreferenceSummaryToValue(getPreferenceManager().getSharedPreferences(), countryPreference);
}
use of android.preference.PreferenceScreen in project Shuttle by timusus.
the class PreferenceFragment method onActivityCreated.
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
if (mHavePrefs) {
bindPreferences();
}
mInitDone = true;
if (savedInstanceState != null) {
Bundle container = savedInstanceState.getBundle(PREFERENCES_TAG);
if (container != null) {
final PreferenceScreen preferenceScreen = getPreferenceScreen();
if (preferenceScreen != null) {
preferenceScreen.restoreHierarchyState(container);
}
}
}
}
use of android.preference.PreferenceScreen in project Shuttle by timusus.
the class PreferenceManagerCompat method getPreferenceScreen.
/**
* Returns the root of the preference hierarchy managed by this class.
*
* @return The {@link PreferenceScreen} object that is at the root of the hierarchy.
*/
static PreferenceScreen getPreferenceScreen(PreferenceManager manager) {
try {
Method m = PreferenceManager.class.getDeclaredMethod("getPreferenceScreen");
m.setAccessible(true);
return (PreferenceScreen) m.invoke(manager);
} catch (Exception e) {
Log.w(TAG, "Couldn't call PreferenceManager.getPreferenceScreen by reflection", e);
}
return null;
}
Aggregations