Search in sources :

Example 11 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class GeneralProfileSettingsFragment method setupAppThemePref.

private void setupAppThemePref() {
    final ListPreferenceEx appTheme = (ListPreferenceEx) findPreference(settings.OSMAND_THEME.getId());
    ArrayList<String> entries = new ArrayList<>();
    entries.add(getString(R.string.dark_theme));
    entries.add(getString(R.string.light_theme));
    ArrayList<Integer> values = new ArrayList<>();
    values.add(OsmandSettings.OSMAND_DARK_THEME);
    values.add(OsmandSettings.OSMAND_LIGHT_THEME);
    if (settings.isSupportSystemDefaultTheme()) {
        entries.add(getString(R.string.system_default_theme));
        values.add(OsmandSettings.SYSTEM_DEFAULT_THEME);
    }
    String[] entriesStrings = new String[entries.size()];
    appTheme.setEntries(entries.toArray(entriesStrings));
    appTheme.setEntryValues(values.toArray());
    appTheme.setIcon(getOsmandThemeIcon());
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx) ArrayList(java.util.ArrayList)

Example 12 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class GeneralProfileSettingsFragment method setupRotateMapPref.

private void setupRotateMapPref() {
    final ListPreferenceEx rotateMap = (ListPreferenceEx) findPreference(settings.ROTATE_MAP.getId());
    rotateMap.setEntries(new String[] { getString(R.string.rotate_map_none_opt), getString(R.string.rotate_map_bearing_opt), getString(R.string.rotate_map_compass_opt) });
    rotateMap.setEntryValues(new Integer[] { OsmandSettings.ROTATE_MAP_NONE, OsmandSettings.ROTATE_MAP_BEARING, OsmandSettings.ROTATE_MAP_COMPASS });
    rotateMap.setIcon(getRotateMapIcon());
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx)

Example 13 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class GeneralProfileSettingsFragment method setupAngularUnitsPref.

private void setupAngularUnitsPref() {
    AngularConstants[] ac = AngularConstants.values();
    String[] entries = new String[ac.length];
    Integer[] entryValues = new Integer[ac.length];
    for (int i = 0; i < entries.length; i++) {
        if (ac[i] == AngularConstants.DEGREES) {
            entries[i] = AngularConstants.DEGREES.toHumanString(app) + " 180";
            entryValues[i] = AngularConstants.DEGREES.ordinal();
        } else if (ac[i] == AngularConstants.DEGREES360) {
            entries[i] = AngularConstants.DEGREES.toHumanString(app) + " 360";
            entryValues[i] = AngularConstants.DEGREES360.ordinal();
        } else {
            entries[i] = ac[i].toHumanString(app);
            entryValues[i] = AngularConstants.MILLIRADS.ordinal();
        }
    }
    ListPreferenceEx angularUnits = (ListPreferenceEx) findPreference(settings.ANGULAR_UNITS.getId());
    angularUnits.setEntries(entries);
    angularUnits.setEntryValues(entryValues);
    angularUnits.setIcon(getActiveIcon(R.drawable.ic_action_angular_unit));
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx) AngularConstants(net.osmand.plus.settings.enums.AngularConstants)

Example 14 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class MultimediaNotesFragment method setupCameraFocusTypePref.

private void setupCameraFocusTypePref(Camera cam, AudioVideoNotesPlugin plugin) {
    ListPreferenceEx cameraFocusType = (ListPreferenceEx) findPreference(plugin.AV_CAMERA_FOCUS_TYPE.getId());
    cameraFocusType.setDescription(R.string.av_camera_focus_descr);
    cameraFocusType.setIcon(getPersistentPrefIcon(R.drawable.ic_action_camera_focus));
    if (cam == null) {
        cameraFocusType.setEnabled(false);
        return;
    }
    Camera.Parameters parameters = cam.getParameters();
    // focus mode settings
    // show in menu only suppoted modes
    List<String> sfm = parameters.getSupportedFocusModes();
    if (sfm == null) {
        cameraFocusType.setVisible(false);
        return;
    }
    List<String> items = new ArrayList<String>();
    List<Integer> itemsValues = new ArrayList<Integer>();
    // filtering known types for translate and set index
    for (int index = 0; index < sfm.size(); index++) {
        if (sfm.get(index).equals("auto")) {
            items.add(getString(R.string.av_camera_focus_auto));
            itemsValues.add(AV_CAMERA_FOCUS_AUTO);
        } else if (sfm.get(index).equals("fixed")) {
            items.add(getString(R.string.av_camera_focus_hiperfocal));
            itemsValues.add(AV_CAMERA_FOCUS_HIPERFOCAL);
        } else if (sfm.get(index).equals("edof")) {
            items.add(getString(R.string.av_camera_focus_edof));
            itemsValues.add(AV_CAMERA_FOCUS_EDOF);
        } else if (sfm.get(index).equals("infinity")) {
            items.add(getString(R.string.av_camera_focus_infinity));
            itemsValues.add(AV_CAMERA_FOCUS_INFINITY);
        } else if (sfm.get(index).equals("macro")) {
            items.add(getString(R.string.av_camera_focus_macro));
            itemsValues.add(AV_CAMERA_FOCUS_MACRO);
        } else if (sfm.get(index).equals("continuous-picture")) {
            items.add(getString(R.string.av_camera_focus_continuous));
            itemsValues.add(AV_CAMERA_FOCUS_CONTINUOUS);
        }
    }
    String[] entries = items.toArray(new String[0]);
    Integer[] entryValues = itemsValues.toArray(new Integer[0]);
    if (entries.length > 0) {
        cameraFocusType.setEntries(entries);
        cameraFocusType.setEntryValues(entryValues);
    } else {
        cameraFocusType.setVisible(false);
    }
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx) ArrayList(java.util.ArrayList) Camera(android.hardware.Camera) SpannableString(android.text.SpannableString)

Example 15 with ListPreferenceEx

use of net.osmand.plus.settings.preferences.ListPreferenceEx in project Osmand by osmandapp.

the class MultimediaNotesFragment method setupStorageSizePref.

private void setupStorageSizePref(AudioVideoNotesPlugin plugin) {
    ListPreferenceEx storageSize = (ListPreferenceEx) findPreference(plugin.AV_RS_STORAGE_SIZE.getId());
    long size = AndroidUtils.getTotalSpace(app) / (1 << 30);
    if (size > 0) {
        int value = 1;
        ArrayList<Integer> gbList = new ArrayList<>();
        while (value < size) {
            gbList.add(value);
            if (value < 5) {
                value++;
            } else {
                value += 5;
            }
        }
        if (value != size) {
            gbList.add((int) size);
        }
        String[] entries = new String[gbList.size()];
        Integer[] entryValues = new Integer[gbList.size()];
        int i = 0;
        for (int v : gbList) {
            entryValues[i] = v;
            entries[i] = AndroidUtils.formatSize(getActivity(), v * (1l << 30));
            i++;
        }
        storageSize.setEntries(entries);
        storageSize.setEntryValues(entryValues);
        storageSize.setDescription(R.string.rec_split_storage_size_desc);
        storageSize.setIcon(getActiveIcon(R.drawable.ic_sdcard));
    } else {
        storageSize.setVisible(false);
    }
}
Also used : ListPreferenceEx(net.osmand.plus.settings.preferences.ListPreferenceEx) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString)

Aggregations

ListPreferenceEx (net.osmand.plus.settings.preferences.ListPreferenceEx)41 SpannableString (android.text.SpannableString)13 ArrayList (java.util.ArrayList)5 ApplicationMode (net.osmand.plus.settings.backend.ApplicationMode)4 SpannableStringBuilder (android.text.SpannableStringBuilder)3 Camera (android.hardware.Camera)2 MultiSelectBooleanPreference (net.osmand.plus.settings.preferences.MultiSelectBooleanPreference)2 SwitchPreferenceEx (net.osmand.plus.settings.preferences.SwitchPreferenceEx)2 RoutingParameter (net.osmand.router.GeneralRouter.RoutingParameter)2 Context (android.content.Context)1 ImageView (android.widget.ImageView)1 TextView (android.widget.TextView)1 FragmentManager (androidx.fragment.app.FragmentManager)1 EditTextPreference (androidx.preference.EditTextPreference)1 Preference (androidx.preference.Preference)1 PreferenceScreen (androidx.preference.PreferenceScreen)1 Map (java.util.Map)1 OsmandApplication (net.osmand.plus.OsmandApplication)1 BooleanPreference (net.osmand.plus.settings.backend.preferences.BooleanPreference)1 CommonPreference (net.osmand.plus.settings.backend.preferences.CommonPreference)1