Search in sources :

Example 6 with PreferenceCategory

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);
    }
}
Also used : PreferenceScreen(android.preference.PreferenceScreen) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory) ActivityManager(android.app.ActivityManager)

Example 7 with PreferenceCategory

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);
    }
}
Also used : PreferenceCategory(android.preference.PreferenceCategory) Preference(android.preference.Preference)

Example 8 with PreferenceCategory

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);
    }
}
Also used : EditTextPreference(android.preference.EditTextPreference) ListPreference(android.preference.ListPreference) QKPreference(com.moez.QKSMS.enums.QKPreference) CheckBoxPreference(android.preference.CheckBoxPreference) Preference(android.preference.Preference) PreferenceCategory(android.preference.PreferenceCategory)

Example 9 with PreferenceCategory

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

Example 10 with PreferenceCategory

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);
}
Also used : Context(android.content.Context) PreferenceCategory(android.preference.PreferenceCategory) SharedPreferences(android.content.SharedPreferences)

Aggregations

PreferenceCategory (android.preference.PreferenceCategory)34 Preference (android.preference.Preference)22 PreferenceScreen (android.preference.PreferenceScreen)17 CheckBoxPreference (android.preference.CheckBoxPreference)12 ListPreference (android.preference.ListPreference)11 Intent (android.content.Intent)7 EditTextPreference (android.preference.EditTextPreference)6 Bundle (android.os.Bundle)4 OnPreferenceClickListener (android.preference.Preference.OnPreferenceClickListener)4 ArrayList (java.util.ArrayList)4 SharedPreferences (android.content.SharedPreferences)3 Uri (android.net.Uri)3 Activity (android.app.Activity)2 AlertDialog (android.app.AlertDialog)2 Context (android.content.Context)2 DialogInterface (android.content.DialogInterface)2 PackageInfo (android.content.pm.PackageInfo)2 PackageManager (android.content.pm.PackageManager)2 SpannableString (android.text.SpannableString)2 View (android.view.View)2