use of android.preference.PreferenceCategory in project weiciyuan by qii.
the class AboutFragment method detectDebugPreference.
private void detectDebugPreference() {
Preference debugPreferenceCategory = (PreferenceCategory) findPreference(DEBUG_INFO);
Preference debugPreference = findPreference(SettingActivity.DEBUG_MEM_INFO);
Preference crashPreferenceCategory = findPreference(SettingActivity.CRASH);
if (SettingUtility.isBlackMagicEnabled()) {
Runtime rt = Runtime.getRuntime();
long vmAlloc = rt.totalMemory() - rt.freeMemory();
long nativeAlloc = Debug.getNativeHeapAllocatedSize();
String vmAllocStr = "VM Allocated " + formatMemoryText(vmAlloc);
String nativeAllocStr = "Native Allocated " + formatMemoryText(nativeAlloc);
ActivityManager am = (ActivityManager) getActivity().getSystemService(Context.ACTIVITY_SERVICE);
int memoryClass = am.getMemoryClass();
String result = "VM Max " + Integer.toString(memoryClass) + "MB";
debugPreference.setSummary(vmAllocStr + "," + nativeAllocStr + "," + result);
crashPreferenceCategory.setOnPreferenceClickListener(new Preference.OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
throw new IllegalArgumentException("about -> crash test");
}
});
} else {
PreferenceScreen screen = getPreferenceScreen();
screen.removePreference(debugPreferenceCategory);
}
}
use of android.preference.PreferenceCategory in project Conversations by siacs.
the class SettingsFragment method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Load the preferences from an XML resource
addPreferencesFromResource(R.xml.preferences);
// Remove from standard preferences if the flag ONLY_INTERNAL_STORAGE is not true
if (!Config.ONLY_INTERNAL_STORAGE) {
PreferenceCategory mCategory = (PreferenceCategory) findPreference("security_options");
Preference mPref1 = findPreference("clean_cache");
Preference mPref2 = findPreference("clean_private_storage");
mCategory.removePreference(mPref1);
mCategory.removePreference(mPref2);
}
}
use of android.preference.PreferenceCategory in project qksms by moezbhatti.
the class SettingsFragment method removePreference.
/**
* Removes a preference from a given category
*/
private void removePreference(String key, String category) {
Preference pref = findPreference(key);
PreferenceCategory cat = (PreferenceCategory) findPreference(category);
if (pref != null && cat != null) {
cat.removePreference(pref);
}
}
use of android.preference.PreferenceCategory in project Ushahidi_Android by ushahidi.
the class Settings method createPreferenceHierarchy.
private PreferenceScreen createPreferenceHierarchy() {
// ROOT element
PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
// Basic preferences
PreferenceCategory basicPrefCat = new PreferenceCategory(this);
basicPrefCat.setTitle(R.string.basic_settings);
root.addPreference(basicPrefCat);
// Total reports to fetch at a time
// set list values
// TODO:// need to look into how to properly handle this. It looks ugly
// but it works.
CharSequence[] totalReportsEntries = { "20 ".concat(recentReports), "40 ".concat(recentReports), "60 ".concat(recentReports), "80 ".concat(recentReports), "100 ".concat(recentReports), "250 ".concat(recentReports), "500 ".concat(recentReports), "1000 ".concat(recentReports) };
CharSequence[] totalReportsValues = { "20", "40", "60", "80", "100", "250", "500", "1000" };
CharSequence[] mapTileEntries = { "Google Tiles", "OSM Tiles ", "Mapbox Tiles" };
CharSequence[] mapTileValues = { "google", "osm", "mapbox" };
totalReportsPref.setEntries(totalReportsEntries);
totalReportsPref.setEntryValues(totalReportsValues);
totalReportsPref.setDefaultValue(totalReportsValues[0]);
totalReportsPref.setDialogTitle(R.string.total_reports);
totalReportsPref.setKey("total_reports_preference");
totalReportsPref.setTitle(R.string.total_reports);
totalReportsPref.setSummary(R.string.hint_total_reports);
basicPrefCat.addPreference(totalReportsPref);
// Map tile preference
mapTileProviderPref.setEntries(mapTileEntries);
mapTileProviderPref.setKey(MAP_TILE_PROVIDER_PREFERENCE);
mapTileProviderPref.setTitle(R.string.map_tiles);
mapTileProviderPref.setSummary(R.string.map_tiles_summary);
mapTileProviderPref.setDialogTitle(R.string.map_tiles);
mapTileProviderPref.setEntryValues(mapTileValues);
mapTileProviderPref.setDefaultValue(mapTileValues[0]);
basicPrefCat.addPreference(mapTileProviderPref);
// First name entry field
firstNamePref.setDialogTitle(R.string.txt_first_name);
firstNamePref.setKey("first_name_preference");
firstNamePref.setTitle(R.string.txt_first_name);
firstNamePref.setSummary(R.string.hint_first_name);
firstNamePref.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
basicPrefCat.addPreference(firstNamePref);
// Last name entry field
lastNamePref.setDialogTitle(R.string.txt_last_name);
lastNamePref.setKey("last_name_preference");
lastNamePref.setTitle(R.string.txt_last_name);
lastNamePref.setSummary(R.string.hint_last_name);
lastNamePref.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_PERSON_NAME);
basicPrefCat.addPreference(lastNamePref);
// Email name entry field
emailAddressPref.setDialogTitle(R.string.txt_email);
emailAddressPref.setKey("email_address_preference");
emailAddressPref.setTitle(R.string.txt_email);
emailAddressPref.setSummary(R.string.hint_email);
emailAddressPref.getEditText().setInputType(InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS);
basicPrefCat.addPreference(emailAddressPref);
// phone number entry field
phoneNumberPref.setDialogTitle(R.string.txt_phonenumber);
phoneNumberPref.setKey("phone_number_preference");
phoneNumberPref.setTitle(R.string.txt_phonenumber);
phoneNumberPref.setSummary(R.string.hint_phonenumber);
phoneNumberPref.getEditText().setInputType(InputType.TYPE_CLASS_PHONE);
// GeneratePhotoFilename resize seekbar
basicPrefCat.addPreference(photoSizePref);
return root;
}
use of android.preference.PreferenceCategory in project WordPress-Android by wordpress-mobile.
the class NotificationsSettingsFragment method addPreferencesForPreferenceScreen.
private void addPreferencesForPreferenceScreen(PreferenceScreen preferenceScreen, Channel channel, long blogId) {
Context context = getActivity();
if (context == null)
return;
PreferenceCategory rootCategory = new PreferenceCategory(context);
rootCategory.setTitle(R.string.notification_types);
preferenceScreen.addPreference(rootCategory);
NotificationsSettingsDialogPreference timelinePreference = new NotificationsSettingsDialogPreference(context, null, channel, NotificationsSettings.Type.TIMELINE, blogId, mNotificationsSettings, mOnSettingsChangedListener);
timelinePreference.setIcon(R.drawable.ic_bell_grey_24dp);
timelinePreference.setTitle(R.string.notifications_tab);
timelinePreference.setDialogTitle(R.string.notifications_tab);
timelinePreference.setSummary(R.string.notifications_tab_summary);
rootCategory.addPreference(timelinePreference);
NotificationsSettingsDialogPreference emailPreference = new NotificationsSettingsDialogPreference(context, null, channel, NotificationsSettings.Type.EMAIL, blogId, mNotificationsSettings, mOnSettingsChangedListener);
emailPreference.setIcon(R.drawable.ic_mail_grey_24dp);
emailPreference.setTitle(R.string.email);
emailPreference.setDialogTitle(R.string.email);
emailPreference.setSummary(R.string.notifications_email_summary);
rootCategory.addPreference(emailPreference);
SharedPreferences settings = PreferenceManager.getDefaultSharedPreferences(context);
String deviceID = settings.getString(NotificationsUtils.WPCOM_PUSH_DEVICE_SERVER_ID, null);
if (!TextUtils.isEmpty(deviceID)) {
NotificationsSettingsDialogPreference devicePreference = new NotificationsSettingsDialogPreference(context, null, channel, NotificationsSettings.Type.DEVICE, blogId, mNotificationsSettings, mOnSettingsChangedListener);
devicePreference.setIcon(R.drawable.ic_phone_grey_24dp);
devicePreference.setTitle(R.string.app_notifications);
devicePreference.setDialogTitle(R.string.app_notifications);
devicePreference.setSummary(R.string.notifications_push_summary);
devicePreference.setEnabled(mNotificationsEnabled);
rootCategory.addPreference(devicePreference);
}
mTypePreferenceCategories.add(rootCategory);
}
Aggregations