Java Code Examples for android.preference.PreferenceScreen#addPreference()

The following examples show how to use android.preference.PreferenceScreen#addPreference() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: UsbDevicePreferences.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void resetList() {
    getPreferenceScreen().removeAll();
    addPreferencesFromResource(R.xml.usb_device_preferences);

    PreferenceScreen preferenceScreen = getPreferenceScreen();
    Preference header = preferenceScreen.findPreference(PREF_OBJECT_NAME);
    header.setTitle(mUsbInfo.getName());
    header.setOnPreferenceClickListener(this);

    for (int i = 0; i < mSites.size(); ++i) {
        Website site = mSites.get(i);
        Preference preference = new WebsitePreference(getActivity(), site, mCategory);
        preference.getExtras().putSerializable(SingleWebsitePreferences.EXTRA_SITE, site);
        preference.setFragment(SingleWebsitePreferences.class.getCanonicalName());
        preferenceScreen.addPreference(preference);
    }

    // Force this list to be reloaded if the activity is resumed.
    mSites = null;
}
 
Example 2
Source File: NumberGroups.java    From callmeter with GNU General Public License v3.0 6 votes vote down vote up
@SuppressWarnings("deprecation")
@Override
protected void onResume() {
    super.onResume();

    PreferenceScreen ps = (PreferenceScreen) findPreference("container");
    ps.removeAll();
    Cursor c = getContentResolver().query(DataProvider.NumbersGroup.CONTENT_URI,
            DataProvider.NumbersGroup.PROJECTION, null, null, null);
    if (c.moveToFirst()) {
        do {
            Preference p = new Preference(this);
            p.setPersistent(false);
            p.setTitle(c.getString(DataProvider.NumbersGroup.INDEX_NAME));
            p.setKey("group_" + c.getInt(DataProvider.NumbersGroup.INDEX_ID));
            p.setOnPreferenceClickListener(this);
            ps.addPreference(p);
        } while (c.moveToNext());
    }
    c.close();
}
 
Example 3
Source File: SettingsActivity.java    From Equate with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Helper Class to setup the default Unit Type preference list in code
 */
private void setUpUnitTypePrefs() {
   PreferenceScreen screen = getPreferenceScreen();
   MultiSelectListPreference listPref = new MultiSelectListPreference(super.getActivity());
   listPref.setOrder(0);
   listPref.setDialogTitle(R.string.unit_select_title);
   listPref.setKey(UNIT_TYPE_PREF_KEY);
   listPref.setSummary(R.string.unit_select_summary);
   listPref.setTitle(R.string.unit_select_title);
   listPref.setEntries(getUnitTypeNameArray(getResources()));

   String[] keyArray = getUnitTypeKeyArray(getResources());
   listPref.setEntryValues(keyArray);

   final Set<String> result = new HashSet<>();
   Collections.addAll(result, keyArray);

   listPref.setDefaultValue(result);

   screen.addPreference(listPref);
}
 
Example 4
Source File: ThemeSettingsFragment.java    From simple-keyboard with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_theme);
    final PreferenceScreen screen = getPreferenceScreen();
    final Context context = getActivity();
    final Resources res = getResources();
    final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
    final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
    for (int index = 0; index < keyboardThemeIds.length; index++) {
        final KeyboardThemePreference pref = new KeyboardThemePreference(
                context, keyboardThemeNames[index], keyboardThemeIds[index]);
        screen.addPreference(pref);
        pref.setOnRadioButtonClickedListener(this);
    }
    final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
    mSelectedThemeId = keyboardTheme.mThemeId;
}
 
Example 5
Source File: ThemeSettingsFragment.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_theme);
    final PreferenceScreen screen = getPreferenceScreen();
    final Context context = getActivity();
    final Resources res = getResources();
    final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
    final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
    for (int index = 0; index < keyboardThemeNames.length; index++) {
        final KeyboardThemePreference pref = new KeyboardThemePreference(
                context, keyboardThemeNames[index], keyboardThemeIds[index]);
        screen.addPreference(pref);
        pref.setOnRadioButtonClickedListener(this);
    }
    final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
    mSelectedThemeId = keyboardTheme.mThemeId;
}
 
Example 6
Source File: Preferences.java    From xDrip-plus with GNU General Public License v3.0 6 votes vote down vote up
private void update_nfc_expiry_preferences(Boolean show_age) {
    try {
        ;
        final PreferenceScreen nfcScreen = (PreferenceScreen) findPreference("xdrip_plus_nfc_settings");
        final String nfc_expiry_days_string = AllPrefsFragment.this.prefs.getString("nfc_expiry_days", "14.5");

        final CheckBoxPreference nfc_show_age = (CheckBoxPreference) findPreference("nfc_show_age");
        nfc_show_age.setSummaryOff("Show the sensor expiry time based on " + nfc_expiry_days_string + " days");
        if (show_age == null) show_age = nfc_show_age.isChecked();
        if (show_age) {
            nfcScreen.removePreference(nfc_expiry_days);
        } else {
            nfc_expiry_days.setOrder(3);
            nfcScreen.addPreference(nfc_expiry_days);
        }
    } catch (NullPointerException e) {
        //
    }
}
 
Example 7
Source File: ThemeSettingsFragment.java    From openboard with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void onCreate(final Bundle icicle) {
    super.onCreate(icicle);
    addPreferencesFromResource(R.xml.prefs_screen_theme);
    final PreferenceScreen screen = getPreferenceScreen();
    final Context context = getActivity();
    final Resources res = getResources();
    final String[] keyboardThemeNames = res.getStringArray(R.array.keyboard_theme_names);
    final int[] keyboardThemeIds = res.getIntArray(R.array.keyboard_theme_ids);
    for (int index = 0; index < keyboardThemeNames.length; index++) {
        final KeyboardThemePreference pref = new KeyboardThemePreference(
                context, keyboardThemeNames[index], keyboardThemeIds[index]);
        screen.addPreference(pref);
        pref.setOnRadioButtonClickedListener(this);
    }
    final KeyboardTheme keyboardTheme = KeyboardTheme.getKeyboardTheme(context);
    mSelectedThemeId = keyboardTheme.mThemeId;
}
 
Example 8
Source File: Preferences.java    From xDrip with GNU General Public License v3.0 6 votes vote down vote up
private void update_nfc_expiry_preferences(Boolean show_age) {
    try {
        ;
        final PreferenceScreen nfcScreen = (PreferenceScreen) findPreference("xdrip_plus_nfc_settings");
        final String nfc_expiry_days_string = AllPrefsFragment.this.prefs.getString("nfc_expiry_days", "14.5");

        final CheckBoxPreference nfc_show_age = (CheckBoxPreference) findPreference("nfc_show_age");
        nfc_show_age.setSummaryOff("Show the sensor expiry time based on " + nfc_expiry_days_string + " days");
        if (show_age == null) show_age = nfc_show_age.isChecked();
        if (show_age) {
            nfcScreen.removePreference(nfc_expiry_days);
        } else {
            nfc_expiry_days.setOrder(3);
            nfcScreen.addPreference(nfc_expiry_days);
        }
    } catch (NullPointerException e) {
        //
    }
}
 
Example 9
Source File: AccountManagementFragment.java    From delion with Apache License 2.0 5 votes vote down vote up
private void updateAccountsList() {
    PreferenceScreen prefScreen = getPreferenceScreen();
    if (prefScreen == null) return;

    for (int i = 0; i < mAccountsListPreferences.size(); i++) {
        prefScreen.removePreference(mAccountsListPreferences.get(i));
    }
    mAccountsListPreferences.clear();

    final Preferences activity = (Preferences) getActivity();
    Account[] accounts = AccountManagerHelper.get(activity).getGoogleAccounts();
    int nextPrefOrder = FIRST_ACCOUNT_PREF_ORDER;

    for (Account account : accounts) {
        ChromeBasePreference pref = new ChromeBasePreference(activity);
        pref.setSelectable(false);
        pref.setTitle(account.name);

        boolean isChildAccount = ChildAccountService.isChildAccount();

        pref.setIcon(new BitmapDrawable(getResources(),
                isChildAccount ? getBadgedUserPicture(account.name, getResources()) :
                    getUserPicture(account.name, getResources())));

        pref.setOrder(nextPrefOrder++);
        prefScreen.addPreference(pref);
        mAccountsListPreferences.add(pref);
    }
}
 
Example 10
Source File: AccountManagementFragment.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private void updateAccountsList() {
    PreferenceScreen prefScreen = getPreferenceScreen();
    if (prefScreen == null) return;

    for (int i = 0; i < mAccountsListPreferences.size(); i++) {
        prefScreen.removePreference(mAccountsListPreferences.get(i));
    }
    mAccountsListPreferences.clear();

    final Preferences activity = (Preferences) getActivity();
    Account[] accounts = AccountManagerHelper.get().getGoogleAccounts();
    int nextPrefOrder = FIRST_ACCOUNT_PREF_ORDER;

    for (Account account : accounts) {
        ChromeBasePreference pref = new ChromeBasePreference(activity);
        pref.setSelectable(false);
        pref.setTitle(account.name);

        boolean isChildAccount = mProfile.isChild();
        pref.setUseReducedPadding(isChildAccount);
        pref.setIcon(new BitmapDrawable(getResources(),
                isChildAccount ? getBadgedUserPicture(account.name, getResources()) :
                    getUserPicture(account.name, getResources())));

        pref.setOrder(nextPrefOrder++);
        prefScreen.addPreference(pref);
        mAccountsListPreferences.add(pref);
    }
}
 
Example 11
Source File: AccountManagementFragment.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void updateAccountsList() {
    PreferenceScreen prefScreen = getPreferenceScreen();
    if (prefScreen == null) return;

    for (int i = 0; i < mAccountsListPreferences.size(); i++) {
        prefScreen.removePreference(mAccountsListPreferences.get(i));
    }
    mAccountsListPreferences.clear();

    final Preferences activity = (Preferences) getActivity();
    Account[] accounts = AccountManagerHelper.get(activity).getGoogleAccounts();
    int nextPrefOrder = FIRST_ACCOUNT_PREF_ORDER;

    for (Account account : accounts) {
        ChromeBasePreference pref = new ChromeBasePreference(activity);
        pref.setSelectable(false);
        pref.setTitle(account.name);

        boolean isChildAccount = ChildAccountService.isChildAccount();

        pref.setIcon(new BitmapDrawable(getResources(),
                isChildAccount ? getBadgedUserPicture(account.name, getResources()) :
                    getUserPicture(account.name, getResources())));

        pref.setOrder(nextPrefOrder++);
        prefScreen.addPreference(pref);
        mAccountsListPreferences.add(pref);
    }
}
 
Example 12
Source File: Preferences.java    From xDrip-plus with GNU General Public License v3.0 5 votes vote down vote up
private void updateMiBandScreen(){
    MiBand.MiBandType type = MiBand.getMibandType();
    PreferenceScreen settings = (PreferenceScreen) findPreference(MiBandEntry.PREF_MIBAND_SETTINGS);
    PreferenceScreen prefs = (PreferenceScreen) findPreference(MiBandEntry.PREF_MIBAND_PREFERENCES);
    try {
        settings.removePreference(miband2_screen);
        settings.removePreference(miband3_4_screen);
        settings.removePreference(miband_nightmode_category);
        prefs.removePreference(miband_graph_category);
        prefs.removePreference(miband_send_readings_as_notification);
        prefs.removePreference(miband_authkey);

        if (type == MiBand.MiBandType.MI_BAND4) {
            settings.addPreference(miband3_4_screen);
            settings.addPreference(miband_nightmode_category);
            prefs.addPreference(miband_graph_category);
            prefs.addPreference(miband_send_readings_as_notification);
            prefs.addPreference(miband_authkey);
        } else if (type == MiBand.MiBandType.MI_BAND2) {
            settings.addPreference(miband2_screen);
        }
        else if (type == MiBand.MiBandType.MI_BAND3 || type == MiBand.MiBandType.MI_BAND3_1){
            settings.addPreference(miband3_4_screen);
            settings.addPreference(miband_nightmode_category);
        }
    } catch (Exception e) {
        Log.e(TAG, "Cannot find preference item: " + e);
    }
}
 
Example 13
Source File: ConfigActivity.java    From AccelerationAlert with Apache License 2.0 5 votes vote down vote up
private void toggleEmailCategories(boolean enabled)
{
	PreferenceScreen screen = getPreferenceScreen();

	if (!enabled)
	{
		screen.removePreference(emailHostCategory);
		screen.removePreference(emailRecipientCategory);
	}
	else
	{
		screen.addPreference(emailHostCategory);
		screen.addPreference(emailRecipientCategory);
	}
}
 
Example 14
Source File: NumberGroupEdit.java    From callmeter with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Reload numbers.
 */
@SuppressWarnings("deprecation")
private void reload() {
    Cursor c = getContentResolver().query(
            ContentUris.withAppendedId(DataProvider.NumbersGroup.CONTENT_URI, gid),
            DataProvider.NumbersGroup.PROJECTION, null, null, null);
    if (c.moveToFirst()) {
        CallMeter.setActivitySubtitle(this, c.getString(DataProvider.NumbersGroup.INDEX_NAME));
    }
    c.close();
    PreferenceScreen ps = (PreferenceScreen) findPreference("container");
    ps.removeAll();
    c = getContentResolver().query(
            ContentUris.withAppendedId(DataProvider.Numbers.GROUP_URI, gid),
            DataProvider.Numbers.PROJECTION, null, null, DataProvider.Numbers.NUMBER);
    if (c.moveToFirst()) {
        do {
            Preference p = new Preference(this);
            p.setPersistent(false);
            String number = c.getString(DataProvider.Numbers.INDEX_NUMBER);
            p.setTitle(number);
            p.setKey("item_" + c.getInt(DataProvider.Numbers.INDEX_ID));
            p.setOnPreferenceClickListener(this);
            ps.addPreference(p);

            if (number != null && !number.contains("%")
                    && CallMeter.hasPermission(this, Manifest.permission.READ_CONTACTS)) {
                String name = CWRAPPER.getNameForNumber(getContentResolver(), number);
                if (!TextUtils.isEmpty(name)) {
                    p.setSummary(name);
                }
            }
        } while (c.moveToNext());
    }
    c.close();
}
 
Example 15
Source File: SettingsActivity.java    From document-viewer with GNU General Public License v3.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
void loadPreferences(final PreferenceScreen root, final int... resourceIds) {
    for (final int id : resourceIds) {
        setPreferenceScreen(null);
        addPreferencesFromResource(id);
        root.addPreference(getPreferenceScreen());
        setPreferenceScreen(null);
    }
}
 
Example 16
Source File: NotifySettingsActivity.java    From AndroidPNClient with Apache License 2.0 4 votes vote down vote up
private PreferenceScreen createPreferenceHierarchy() {
    Log.d(LOGTAG, "createSettingsPreferenceScreen()...");

    PreferenceManager preferenceManager = getPreferenceManager();
    preferenceManager
            .setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME);
    preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);

    PreferenceScreen root = preferenceManager.createPreferenceScreen(this);

    //        PreferenceCategory prefCat = new PreferenceCategory(this);
    //        // inlinePrefCat.setTitle("");
    //        root.addPreference(prefCat);

    CheckBoxPreference notifyPref = new CheckBoxPreference(this);
    notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED);
    notifyPref.setTitle(R.string.notifications_enabled);
    notifyPref.setSummaryOn(R.string.receive_push_messages);
    notifyPref.setSummaryOff(R.string.do_not_receive_push_messages);
    notifyPref.setDefaultValue(Boolean.TRUE);
    notifyPref
            .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
                public boolean onPreferenceChange(Preference preference,
                        Object newValue) {
                    boolean checked = Boolean.valueOf(newValue.toString());
                    if (checked) {
                        preference.setTitle(R.string.notifications_enabled);
                    } else {
                        preference.setTitle(R.string.notifications_disabled);
                    }
                    return true;
                }
            });

    CheckBoxPreference soundPref = new CheckBoxPreference(this);
    soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED);
    soundPref.setTitle(R.string.sound);
    soundPref.setSummary(R.string.play_sound_for_notifications);
    soundPref.setDefaultValue(Boolean.TRUE);
    // soundPref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED);

    CheckBoxPreference vibratePref = new CheckBoxPreference(this);
    vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED);
    vibratePref.setTitle(R.string.vibrate);
    vibratePref.setSummary(R.string.vibrate_the_phone_for_notifications);
    vibratePref.setDefaultValue(Boolean.TRUE);
    // vibratePref.setDependency(Constants.SETTINGS_NOTIFICATION_ENABLED);

    root.addPreference(notifyPref);
    root.addPreference(soundPref);
    root.addPreference(vibratePref);

    //        prefCat.addPreference(notifyPref);
    //        prefCat.addPreference(soundPref);
    //        prefCat.addPreference(vibratePref);
    //        root.addPreference(prefCat);

    return root;
}
 
Example 17
Source File: Pref.java    From GeoLog with Apache License 2.0 4 votes vote down vote up
public static PreferenceCategory Category(Context context, PreferenceScreen root, int caption) {
	PreferenceCategory retval = new PreferenceCategory(context);
	if (caption > 0) retval.setTitle(caption);
	root.addPreference(retval);
	return retval;    	
}
 
Example 18
Source File: NotificationSettingsActivity.java    From AndroidPNClient with Apache License 2.0 4 votes vote down vote up
private PreferenceScreen createPreferenceHierarchy() {
    Log.d(LOGTAG, "createSettingsPreferenceScreen()...");

    PreferenceManager preferenceManager = getPreferenceManager();
    preferenceManager
            .setSharedPreferencesName(Constants.SHARED_PREFERENCE_NAME);
    preferenceManager.setSharedPreferencesMode(Context.MODE_PRIVATE);

    PreferenceScreen root = preferenceManager.createPreferenceScreen(this);

    CheckBoxPreference notifyPref = new CheckBoxPreference(this);
    notifyPref.setKey(Constants.SETTINGS_NOTIFICATION_ENABLED);
    notifyPref.setTitle("Notifications Enabled");
    notifyPref.setSummaryOn("Receive push messages");
    notifyPref.setSummaryOff("Do not receive push messages");
    notifyPref.setDefaultValue(Boolean.TRUE);
    notifyPref
            .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {
                public boolean onPreferenceChange(Preference preference,
                        Object newValue) {
                    boolean checked = Boolean.valueOf(newValue.toString());
                    if (checked) {
                        preference.setTitle("Notifications Enabled");
                    } else {
                        preference.setTitle("Notifications Disabled");
                    }
                    return true;
                }
            });

    CheckBoxPreference soundPref = new CheckBoxPreference(this);
    soundPref.setKey(Constants.SETTINGS_SOUND_ENABLED);
    soundPref.setTitle("Sound");
    soundPref.setSummary("Play a sound for notifications");
    soundPref.setDefaultValue(Boolean.TRUE);

    CheckBoxPreference vibratePref = new CheckBoxPreference(this);
    vibratePref.setKey(Constants.SETTINGS_VIBRATE_ENABLED);
    vibratePref.setTitle("Vibrate");
    vibratePref.setSummary("Vibrate the phone for notifications");
    vibratePref.setDefaultValue(Boolean.TRUE);

    root.addPreference(notifyPref);
    root.addPreference(soundPref);
    root.addPreference(vibratePref);


    return root;
}
 
Example 19
Source File: ExportActivity.java    From GeoLog with Apache License 2.0 4 votes vote down vote up
private PreferenceScreen createPreferenceHierarchy() {
	metric = !prefs.getString(SettingsFragment.PREF_UNITS, SettingsFragment.PREF_UNITS_DEFAULT).equals(SettingsFragment.VALUE_UNITS_IMPERIAL);
	
	PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
	
	prefFormat = Pref.List(
			this, 
			null, 
			R.string.export_preference_format_title, 
			0, 
			R.string.export_preference_format_popup, 
			PREF_FORMAT, 
			PREF_FORMAT_DEFAULT, 
			new String[] {
				getString(R.string.export_preference_format_gpx),
				getString(R.string.export_preference_format_kml)
			},
			new String[] {
				VALUE_FORMAT_GPX,
				VALUE_FORMAT_KML
			},
			true
	);
	root.addPreference(prefFormat);
	
	prefMergeTrackGap = Pref.Edit(
			this, 
			null,
			R.string.export_preference_track_merge_gap_title,
			0, 
			R.string.export_preference_track_merge_gap_popup,
			PREF_TRACK_MERGE_GAP, 
			String.valueOf(PREF_TRACK_MERGE_GAP_DEFAULT), 
			true,
			InputType.TYPE_CLASS_NUMBER
	);
	root.addPreference(prefMergeTrackGap);
	
	PreferenceCategory catDateFilter = Pref.Category(this, root, R.string.export_preference_datefilter_category);
	
	prefDateStart = new DateTimePickerPreference(this, prefs, PREF_DATETIME_START, PREF_DATETIME_START_DEFAULT, dateFirst, dateLast, false);
	prefDateStart.setTitle(getString(R.string.export_preference_date_start_title));
	prefDateStart.setSummary("");
	prefDateStart.setPopupTitle(getString(R.string.export_preference_date_start_popup));
	catDateFilter.addPreference(prefDateStart.getPreference());
	
	prefDateEnd = new DateTimePickerPreference(this, prefs, PREF_DATETIME_END, PREF_DATETIME_END_DEFAULT, dateFirst, dateLast, true);
	prefDateEnd.setTitle(getString(R.string.export_preference_date_end_title));
	prefDateEnd.setSummary("");
	prefDateEnd.setPopupTitle(getString(R.string.export_preference_date_end_popup));
	catDateFilter.addPreference(prefDateEnd.getPreference());
	
	int popup = metric ? R.string.export_preference_accuracy_popup_meters : R.string.export_preference_accuracy_popup_feet;
	
	PreferenceCategory catTrack = Pref.Category(this, root, R.string.export_preference_trackfilter_category);
	prefTrackMinPoints = Pref.Edit(this, catTrack, R.string.export_preference_track_min_points_title, 0, R.string.export_preference_track_min_points_popup, PREF_TRACK_MIN_POINTS, String.valueOf(PREF_TRACK_MIN_POINTS_DEFAULT), true, InputType.TYPE_CLASS_NUMBER);
	prefTrackMinTime = Pref.Edit(this, catTrack, R.string.export_preference_track_min_time_title, 0, R.string.export_preference_track_min_time_popup, PREF_TRACK_MIN_TIME, String.valueOf(PREF_TRACK_MIN_TIME_DEFAULT), true, InputType.TYPE_CLASS_NUMBER);
	prefTrackMinDistance = editDistance(this, catTrack, R.string.export_preference_track_min_distance_title, 0, popup, PREF_TRACK_MIN_DISTANCE, String.valueOf(PREF_TRACK_MIN_DISTANCE_DEFAULT), true);
	
	PreferenceCategory catAccLP = Pref.Category(this, root, R.string.export_preference_lowpowerfilter_category);		
	prefAccLPUnknown = editDistance(this, catAccLP, R.string.profile_preference_caption_unknown, 0, popup, PREF_ACC_LP_UNKNOWN, String.valueOf(PREF_ACC_LP_UNKNOWN_DEFAULT), true);
	prefAccLPStill = editDistance(this, catAccLP, R.string.profile_preference_caption_still, 0, popup, PREF_ACC_LP_STILL, String.valueOf(PREF_ACC_LP_STILL_DEFAULT), true);
	prefAccLPFoot = editDistance(this, catAccLP, R.string.profile_preference_caption_foot, 0, popup, PREF_ACC_LP_FOOT, String.valueOf(PREF_ACC_LP_FOOT_DEFAULT), true);
	prefAccLPBicycle = editDistance(this, catAccLP, R.string.profile_preference_caption_bicycle, 0, popup, PREF_ACC_LP_BICYCLE, String.valueOf(PREF_ACC_LP_BICYCLE_DEFAULT), true);
	prefAccLPVehicle = editDistance(this, catAccLP, R.string.profile_preference_caption_vehicle, 0, popup, PREF_ACC_LP_VEHICLE, String.valueOf(PREF_ACC_LP_VEHICLE_DEFAULT), true);

	PreferenceCategory catAccHA = Pref.Category(this, root, R.string.export_preference_highaccuracyfilter_category);
	prefAccHAUnknown = editDistance(this, catAccHA, R.string.profile_preference_caption_unknown, 0, popup, PREF_ACC_HA_UNKNOWN, String.valueOf(PREF_ACC_HA_UNKNOWN_DEFAULT), true);
	prefAccHAStill = editDistance(this, catAccHA, R.string.profile_preference_caption_still, 0, popup, PREF_ACC_HA_STILL, String.valueOf(PREF_ACC_HA_STILL_DEFAULT), true);
	prefAccHAFoot = editDistance(this, catAccHA, R.string.profile_preference_caption_foot, 0, popup, PREF_ACC_HA_FOOT, String.valueOf(PREF_ACC_HA_FOOT_DEFAULT), true);
	prefAccHABicycle = editDistance(this, catAccHA, R.string.profile_preference_caption_bicycle, 0, popup, PREF_ACC_HA_BICYCLE, String.valueOf(PREF_ACC_HA_BICYCLE_DEFAULT), true);
	prefAccHAVehicle = editDistance(this, catAccHA, R.string.profile_preference_caption_vehicle, 0, popup, PREF_ACC_HA_VEHICLE, String.valueOf(PREF_ACC_HA_VEHICLE_DEFAULT), true);

	updatePrefs(null);
	
	doneLoading = true;
	if (progressBar != null) progressBar.setVisibility(View.GONE);
	getListView().setVisibility(View.VISIBLE);		
			
	return root;				
}
 
Example 20
Source File: SettingsActivity.java    From javainstaller with GNU General Public License v3.0 4 votes vote down vote up
private PreferenceScreen createPreferenceHierarchy() {

       CharSequence[] cs = new String[] { "Terminal Emulator", "Run Activity", "auto" };
       CharSequence[] cs2 = new String[] { "off", "on" };

       // Root
       PreferenceScreen root = getPreferenceManager().createPreferenceScreen(this);
       PreferenceCategory dialogBasedPrefCat = new PreferenceCategory(this);
       dialogBasedPrefCat.setTitle("install");
       root.addPreference(dialogBasedPrefCat); // Adding a category

       // List preference under the category
       ListPreference listPref = new ListPreference(this);
       listPref.setKey("runmode");
       listPref.setDefaultValue(cs[2]);
       listPref.setEntries(cs);
       listPref.setEntryValues(cs);
       listPref.setDialogTitle("run install.sh in");
       listPref.setTitle("run install.sh in");
       listPref.setSummary("run install.sh in");
       dialogBasedPrefCat.addPreference(listPref);
       ListPreference rootmode = new ListPreference(this);
       rootmode.setKey("rootmode");
       rootmode.setDefaultValue(cs2[0]);
       rootmode.setEntries(cs2);
       rootmode.setEntryValues(cs2);
       rootmode.setDialogTitle("run install.sh as superuser");
       rootmode.setTitle("run install.sh as superuser");
       rootmode.setSummary("root required");
       dialogBasedPrefCat.addPreference(rootmode);
       
       PreferenceCategory dialogBasedPrefCat2 = new PreferenceCategory(this);
       dialogBasedPrefCat2.setTitle("run");
       root.addPreference(dialogBasedPrefCat2); // Adding a category

       // List preference under the category
       CharSequence[] csjar = new String[] { "Terminal Emulator", "Run Activity" };
       ListPreference listPref2 = new ListPreference(this);
       listPref2.setKey("runmode2");
       listPref2.setDefaultValue(csjar[1]);
       listPref2.setEntries(csjar);
       listPref2.setEntryValues(csjar);
       listPref2.setDialogTitle("run jar file in");
       listPref2.setTitle("run jar file in");
       listPref2.setSummary("run jar file in");
       dialogBasedPrefCat2.addPreference(listPref2);
       ListPreference rootmode2 = new ListPreference(this);
       rootmode2.setKey("rootmode2");
       rootmode2.setDefaultValue(cs2[0]);
       rootmode2.setEntries(cs2);
       rootmode2.setEntryValues(cs2);
       rootmode2.setDialogTitle("run jar file as superuser");
       rootmode2.setTitle("run jar file as superuser");
       rootmode2.setSummary("root required");
       dialogBasedPrefCat2.addPreference(rootmode2);
       
       PreferenceCategory dialogBasedPrefCat3 = new PreferenceCategory(this);
       dialogBasedPrefCat3.setTitle("path broadcast");
       root.addPreference(dialogBasedPrefCat3); // Adding a category

       // List preference under the category
       CharSequence[] cspath = new String[] { "on", "off", "if jamvm is installed" };
       ListPreference listPref3 = new ListPreference(this);
       listPref3.setKey("broadcast");
       listPref3.setDefaultValue(cspath[2]);
       listPref3.setEntries(cspath);
       listPref3.setEntryValues(cspath);
       listPref3.setDialogTitle("broadcast path to terminal emulator");
       listPref3.setTitle("broadcast path to terminal emulator");
       listPref3.setSummary("broadcast path to terminal emulator");
       dialogBasedPrefCat3.addPreference(listPref3);
       EditTextPreference path = new EditTextPreference(this);
       path.setKey("broadcastpath");
       path.setDefaultValue("/data/data/julianwi.javainstaller");
       path.setDialogTitle("path to broadcast");
       path.setTitle("path to broadcast");
       path.setSummary("path to broadcast");
       dialogBasedPrefCat3.addPreference(path);

       return root;
   }