Search in sources :

Example 1 with CommonPreference

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

the class GpxUiHelper method createDialog.

private static AlertDialog createDialog(final Activity activity, final boolean showCurrentGpx, final boolean multipleChoice, final boolean showAppearanceSetting, final CallbackWithObject<GPXFile[]> callbackWithObject, final List<GPXInfo> gpxInfoList, final ContextMenuAdapter contextMenuAdapter, final int themeRes, final boolean nightMode) {
    final OsmandApplication app = (OsmandApplication) activity.getApplication();
    final File dir = app.getAppPath(IndexConstants.GPX_INDEX_DIR);
    AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
    final int layout = R.layout.gpx_track_item;
    final Map<String, String> gpxAppearanceParams = new HashMap<>();
    final DialogGpxDataItemCallback gpxDataItemCallback = new DialogGpxDataItemCallback(app);
    ArrayList<String> modifiableGpxFileNames = new ArrayList<>(Arrays.asList(contextMenuAdapter.getItemNames()));
    final ArrayAdapter<String> alertDialogAdapter = new ArrayAdapter<String>(activity, layout, R.id.title, modifiableGpxFileNames) {

        @Override
        public int getItemViewType(int position) {
            return showCurrentGpx && position == 0 ? 1 : 0;
        }

        @Override
        public int getViewTypeCount() {
            return 2;
        }

        private GpxDataItem getDataItem(GPXInfo info) {
            return app.getGpxDbHelper().getItem(new File(app.getAppPath(IndexConstants.GPX_INDEX_DIR), info.getFileName()), gpxDataItemCallback);
        }

        @Override
        @NonNull
        public View getView(final int position, View convertView, @NonNull ViewGroup parent) {
            // User super class to create the View
            View v = convertView;
            boolean checkLayout = getItemViewType(position) == 0;
            if (v == null) {
                v = View.inflate(new ContextThemeWrapper(activity, themeRes), layout, null);
            }
            final ContextMenuItem item = contextMenuAdapter.getItem(position);
            GPXInfo info = gpxInfoList.get(position);
            boolean currentlyRecordingTrack = showCurrentGpx && position == 0;
            GPXTrackAnalysis analysis = null;
            if (currentlyRecordingTrack) {
                analysis = app.getSavingTrackHelper().getCurrentTrack().getTrackAnalysis(app);
            } else {
                GpxDataItem dataItem = getDataItem(info);
                if (dataItem != null) {
                    analysis = dataItem.getAnalysis();
                }
            }
            updateGpxInfoView(v, item.getTitle(), info, analysis, app);
            if (item.getSelected() == null) {
                v.findViewById(R.id.check_item).setVisibility(View.GONE);
                v.findViewById(R.id.check_local_index).setVisibility(View.GONE);
            } else {
                if (checkLayout) {
                    final CheckBox ch = v.findViewById(R.id.check_local_index);
                    ch.setVisibility(View.VISIBLE);
                    v.findViewById(R.id.toggle_item).setVisibility(View.GONE);
                    ch.setOnCheckedChangeListener(null);
                    ch.setChecked(item.getSelected());
                    ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                        @Override
                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                            item.setSelected(isChecked);
                        }
                    });
                    UiUtilities.setupCompoundButton(ch, nightMode, PROFILE_DEPENDENT);
                } else {
                    final SwitchCompat ch = v.findViewById(R.id.toggle_item);
                    ch.setVisibility(View.VISIBLE);
                    v.findViewById(R.id.toggle_checkbox_item).setVisibility(View.GONE);
                    ch.setOnCheckedChangeListener(null);
                    ch.setChecked(item.getSelected());
                    ch.setOnCheckedChangeListener(new OnCheckedChangeListener() {

                        @Override
                        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
                            item.setSelected(isChecked);
                        }
                    });
                    UiUtilities.setupCompoundButton(ch, nightMode, PROFILE_DEPENDENT);
                }
                v.findViewById(R.id.check_item).setVisibility(View.VISIBLE);
            }
            return v;
        }
    };
    OnClickListener onClickListener = new OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int position) {
        }
    };
    gpxDataItemCallback.setListAdapter(alertDialogAdapter);
    builder.setAdapter(alertDialogAdapter, onClickListener);
    if (multipleChoice) {
        if (showAppearanceSetting) {
            final RenderingRuleProperty trackWidthProp;
            final RenderingRuleProperty trackColorProp;
            final RenderingRulesStorage renderer = app.getRendererRegistry().getCurrentSelectedRenderer();
            if (renderer != null) {
                trackWidthProp = renderer.PROPS.getCustomRule(CURRENT_TRACK_WIDTH_ATTR);
                trackColorProp = renderer.PROPS.getCustomRule(CURRENT_TRACK_COLOR_ATTR);
            } else {
                trackWidthProp = null;
                trackColorProp = null;
            }
            if (trackWidthProp == null || trackColorProp == null) {
                builder.setTitle(R.string.show_gpx);
            } else {
                final View apprTitleView = View.inflate(new ContextThemeWrapper(activity, themeRes), R.layout.select_gpx_appearance_title, null);
                final CommonPreference<String> prefWidth = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_WIDTH_ATTR);
                final CommonPreference<String> prefColor = app.getSettings().getCustomRenderProperty(CURRENT_TRACK_COLOR_ATTR);
                updateAppearanceTitle(activity, app, trackWidthProp, renderer, apprTitleView, prefWidth.get(), prefColor.get());
                apprTitleView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        final ListPopupWindow popup = new ListPopupWindow(new ContextThemeWrapper(activity, themeRes));
                        popup.setAnchorView(apprTitleView);
                        popup.setContentWidth(AndroidUtils.dpToPx(activity, 200f));
                        popup.setModal(true);
                        popup.setDropDownGravity(Gravity.END | Gravity.TOP);
                        popup.setVerticalOffset(AndroidUtils.dpToPx(activity, -48f));
                        popup.setHorizontalOffset(AndroidUtils.dpToPx(activity, -6f));
                        final GpxAppearanceAdapter gpxApprAdapter = new GpxAppearanceAdapter(new ContextThemeWrapper(activity, themeRes), gpxAppearanceParams.containsKey(CURRENT_TRACK_COLOR_ATTR) ? gpxAppearanceParams.get(CURRENT_TRACK_COLOR_ATTR) : prefColor.get(), GpxAppearanceAdapter.GpxAppearanceAdapterType.TRACK_WIDTH_COLOR, gpxAppearanceParams.containsKey(SHOW_START_FINISH_ATTR) ? "true".equals(gpxAppearanceParams.get(SHOW_START_FINISH_ATTR)) : app.getSettings().SHOW_START_FINISH_ICONS.get(), nightMode);
                        popup.setAdapter(gpxApprAdapter);
                        popup.setOnItemClickListener(new AdapterView.OnItemClickListener() {

                            @Override
                            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                                AppearanceListItem item = gpxApprAdapter.getItem(position);
                                if (item != null) {
                                    if (CURRENT_TRACK_WIDTH_ATTR.equals(item.getAttrName())) {
                                        gpxAppearanceParams.put(CURRENT_TRACK_WIDTH_ATTR, item.getValue());
                                    } else if (CURRENT_TRACK_COLOR_ATTR.equals(item.getAttrName())) {
                                        gpxAppearanceParams.put(CURRENT_TRACK_COLOR_ATTR, item.getValue());
                                    } else if (SHOW_START_FINISH_ATTR.equals(item.getAttrName())) {
                                        gpxAppearanceParams.put(SHOW_START_FINISH_ATTR, item.getValue());
                                    }
                                }
                                popup.dismiss();
                                updateAppearanceTitle(activity, app, trackWidthProp, renderer, apprTitleView, gpxAppearanceParams.containsKey(CURRENT_TRACK_WIDTH_ATTR) ? gpxAppearanceParams.get(CURRENT_TRACK_WIDTH_ATTR) : prefWidth.get(), gpxAppearanceParams.containsKey(CURRENT_TRACK_COLOR_ATTR) ? gpxAppearanceParams.get(CURRENT_TRACK_COLOR_ATTR) : prefColor.get());
                            }
                        });
                        popup.show();
                    }
                });
                builder.setCustomTitle(apprTitleView);
            }
        } else {
            builder.setTitle(R.string.show_gpx);
        }
        builder.setPositiveButton(R.string.shared_string_ok, new OnClickListener() {

            @Override
            public void onClick(DialogInterface dialog, int which) {
                if (gpxAppearanceParams.size() > 0) {
                    for (Map.Entry<String, String> entry : gpxAppearanceParams.entrySet()) {
                        if (SHOW_START_FINISH_ATTR.equals(entry.getKey())) {
                            app.getSettings().SHOW_START_FINISH_ICONS.set("true".equals(entry.getValue()));
                        } else {
                            final CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(entry.getKey());
                            pref.set(entry.getValue());
                        }
                    }
                    if (activity instanceof MapActivity) {
                        ((MapActivity) activity).refreshMapComplete();
                    }
                }
                GPXFile currentGPX = null;
                // clear all previously selected files before adding new one
                OsmandApplication app = (OsmandApplication) activity.getApplication();
                if (app.getSelectedGpxHelper() != null) {
                    app.getSelectedGpxHelper().clearAllGpxFilesToShow(false);
                }
                if (showCurrentGpx && contextMenuAdapter.getItem(0).getSelected()) {
                    currentGPX = app.getSavingTrackHelper().getCurrentGpx();
                }
                List<String> selectedGpxNames = new ArrayList<>();
                for (int i = (showCurrentGpx ? 1 : 0); i < contextMenuAdapter.length(); i++) {
                    if (contextMenuAdapter.getItem(i).getSelected()) {
                        selectedGpxNames.add(gpxInfoList.get(i).getFileName());
                    }
                }
                dialog.dismiss();
                updateSelectedTracksAppearance(app, selectedGpxNames, gpxAppearanceParams);
                loadGPXFileInDifferentThread(activity, callbackWithObject, dir, currentGPX, selectedGpxNames.toArray(new String[0]));
            }
        });
        builder.setNegativeButton(R.string.shared_string_cancel, null);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT && gpxInfoList.size() > 1 || !showCurrentGpx && gpxInfoList.size() > 0) {
            builder.setNeutralButton(R.string.gpx_add_track, null);
        }
    }
    final AlertDialog dlg = builder.create();
    dlg.setCanceledOnTouchOutside(true);
    if (gpxInfoList.size() == 0 || showCurrentGpx && gpxInfoList.size() == 1) {
        final View footerView = activity.getLayoutInflater().inflate(R.layout.no_gpx_files_list_footer, null);
        TextView descTextView = footerView.findViewById(R.id.descFolder);
        String descPrefix = app.getString(R.string.gpx_no_tracks_title_folder);
        SpannableString spannableDesc = new SpannableString(descPrefix + ": " + dir.getAbsolutePath());
        spannableDesc.setSpan(new StyleSpan(android.graphics.Typeface.BOLD), descPrefix.length() + 1, spannableDesc.length(), 0);
        descTextView.setText(spannableDesc);
        if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
            footerView.findViewById(R.id.button).setVisibility(View.GONE);
        } else {
            footerView.findViewById(R.id.button).setOnClickListener(new View.OnClickListener() {

                @Override
                public void onClick(View v) {
                    addTrack(activity, alertDialogAdapter, contextMenuAdapter, gpxInfoList);
                }
            });
        }
        dlg.getListView().addFooterView(footerView, null, false);
    }
    dlg.getListView().setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            if (multipleChoice) {
                ContextMenuItem item = contextMenuAdapter.getItem(position);
                item.setSelected(!item.getSelected());
                alertDialogAdapter.notifyDataSetInvalidated();
                if (position == 0 && showCurrentGpx && item.getSelected()) {
                    OsmandMonitoringPlugin monitoringPlugin = OsmandPlugin.getActivePlugin(OsmandMonitoringPlugin.class);
                    if (monitoringPlugin == null) {
                        AlertDialog.Builder confirm = new AlertDialog.Builder(new ContextThemeWrapper(activity, themeRes));
                        confirm.setPositiveButton(R.string.shared_string_ok, new DialogInterface.OnClickListener() {

                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                Bundle params = new Bundle();
                                params.putBoolean(PluginsFragment.OPEN_PLUGINS, true);
                                MapActivity.launchMapActivityMoveToTop(activity, null, null, params);
                            }
                        });
                        confirm.setNegativeButton(R.string.shared_string_cancel, null);
                        confirm.setMessage(activity.getString(R.string.enable_plugin_monitoring_services));
                        confirm.show();
                    } else if (!app.getSettings().SAVE_GLOBAL_TRACK_TO_GPX.get()) {
                        monitoringPlugin.controlDialog(activity);
                    }
                }
            } else {
                dlg.dismiss();
                if (showCurrentGpx && position == 0) {
                    callbackWithObject.processResult(null);
                } else {
                    String fileName = gpxInfoList.get(position).getFileName();
                    SelectedGpxFile selectedGpxFile = app.getSelectedGpxHelper().getSelectedFileByName(fileName);
                    if (selectedGpxFile != null) {
                        callbackWithObject.processResult(new GPXFile[] { selectedGpxFile.getGpxFile() });
                    } else {
                        loadGPXFileInDifferentThread(activity, callbackWithObject, dir, null, fileName);
                    }
                }
            }
        }
    });
    dlg.setOnShowListener(new DialogInterface.OnShowListener() {

        @Override
        public void onShow(DialogInterface dialog) {
            Button addTrackButton = ((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEUTRAL);
            if (addTrackButton != null) {
                addTrackButton.setOnClickListener(new View.OnClickListener() {

                    @Override
                    public void onClick(View v) {
                        addTrack(activity, alertDialogAdapter, contextMenuAdapter, gpxInfoList);
                    }
                });
            }
        }
    });
    dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {

        @Override
        public void onDismiss(DialogInterface dialog) {
            gpxDataItemCallback.setUpdateEnable(false);
        }
    });
    dlg.show();
    try {
        dlg.getListView().setFastScrollEnabled(true);
    } catch (Exception e) {
    // java.lang.ClassCastException: com.android.internal.widget.RoundCornerListAdapter
    // Unknown reason but on some devices fail
    }
    return dlg;
}
Also used : AlertDialog(androidx.appcompat.app.AlertDialog) OsmandApplication(net.osmand.plus.OsmandApplication) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) SpannableString(android.text.SpannableString) OsmandMonitoringPlugin(net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin) Button(android.widget.Button) CompoundButton(android.widget.CompoundButton) NonNull(androidx.annotation.NonNull) GpxDataItem(net.osmand.plus.track.helpers.GPXDatabase.GpxDataItem) ArrayList(java.util.ArrayList) List(java.util.List) TextView(android.widget.TextView) OnCheckedChangeListener(android.widget.CompoundButton.OnCheckedChangeListener) ContextMenuItem(net.osmand.plus.ContextMenuItem) OnItemClickListener(android.widget.AdapterView.OnItemClickListener) GPXTrackAnalysis(net.osmand.GPXUtilities.GPXTrackAnalysis) SpannableString(android.text.SpannableString) CheckBox(android.widget.CheckBox) OnClickListener(android.content.DialogInterface.OnClickListener) AdapterView(android.widget.AdapterView) GPXFile(net.osmand.GPXUtilities.GPXFile) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) File(java.io.File) SwitchCompat(androidx.appcompat.widget.SwitchCompat) DialogInterface(android.content.DialogInterface) AppearanceListItem(net.osmand.plus.track.GpxAppearanceAdapter.AppearanceListItem) Entry(com.github.mikephil.charting.data.Entry) BarEntry(com.github.mikephil.charting.data.BarEntry) ListPopupWindow(androidx.appcompat.widget.ListPopupWindow) GpxAppearanceAdapter(net.osmand.plus.track.GpxAppearanceAdapter) MapActivity(net.osmand.plus.activities.MapActivity) CommonPreference(net.osmand.plus.settings.backend.preferences.CommonPreference) ViewGroup(android.view.ViewGroup) Bundle(android.os.Bundle) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty) ImageView(android.widget.ImageView) GpxMarkerView(net.osmand.plus.track.GpxMarkerView) View(android.view.View) AdapterView(android.widget.AdapterView) TextView(android.widget.TextView) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage) ActivityNotFoundException(android.content.ActivityNotFoundException) ContextThemeWrapper(android.view.ContextThemeWrapper) SelectedGpxFile(net.osmand.plus.track.helpers.GpxSelectionHelper.SelectedGpxFile) StyleSpan(android.text.style.StyleSpan) GPXFile(net.osmand.GPXUtilities.GPXFile) ArrayAdapter(android.widget.ArrayAdapter) CompoundButton(android.widget.CompoundButton)

Example 2 with CommonPreference

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

the class TransportLinesMenu method getTransportPrefs.

public static List<CommonPreference<Boolean>> getTransportPrefs(@NonNull OsmandApplication app, List<RenderingRuleProperty> transportRules) {
    if (transportRules == null) {
        transportRules = getTransportRules(app);
    }
    List<CommonPreference<Boolean>> transportPrefs = new ArrayList<>();
    for (RenderingRuleProperty property : transportRules) {
        final CommonPreference<Boolean> pref = app.getSettings().getCustomRenderBooleanProperty(property.getAttrName());
        transportPrefs.add(pref);
    }
    return transportPrefs;
}
Also used : CommonPreference(net.osmand.plus.settings.backend.preferences.CommonPreference) ArrayList(java.util.ArrayList) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty)

Example 3 with CommonPreference

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

the class ConfigureMapMenu method createRenderingProperty.

public static ContextMenuItem createRenderingProperty(ContextMenuAdapter adapter, MapActivity activity, @DrawableRes int icon, RenderingRuleProperty p, String id, boolean nightMode) {
    OsmandApplication app = activity.getMyApplication();
    if (p.isBoolean()) {
        String name = AndroidUtils.getRenderingStringPropertyName(activity, p.getAttrName(), p.getName());
        return createBooleanRenderingProperty(activity, p.getAttrName(), name, id, p, icon, nightMode, null);
    } else {
        final CommonPreference<String> pref = app.getSettings().getCustomRenderProperty(p.getAttrName());
        String descr;
        if (!Algorithms.isEmpty(pref.get())) {
            descr = AndroidUtils.getRenderingStringPropertyValue(activity, pref.get());
        } else {
            descr = AndroidUtils.getRenderingStringPropertyValue(app, p.getDefaultValueDescription());
        }
        String propertyName = AndroidUtils.getRenderingStringPropertyName(app, p.getAttrName(), p.getName());
        ItemBuilder builder = ContextMenuItem.createBuilder(propertyName).setId(id).setListener((ad, itemId, pos, isChecked, viewCoordinates) -> {
            if (AndroidUtils.isActivityNotDestroyed(activity)) {
                ConfigureMapDialogs.showRenderingPropertyDialog(activity, adapter, p, pref, pos, nightMode);
            }
            return false;
        }).setDescription(descr).setItemDeleteAction(makeDeleteAction(pref)).setLayout(R.layout.list_item_single_line_descrition_narrow);
        if (icon != INVALID_ID) {
            builder.setIcon(icon);
        }
        return builder.createItem();
    }
}
Also used : PoiUIFilter(net.osmand.plus.poi.PoiUIFilter) Arrays(java.util.Arrays) A_ENGINE_V1(net.osmand.render.RenderingRuleStorageProperties.A_ENGINE_V1) NonNull(androidx.annotation.NonNull) HIDE_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.HIDE_ID) ItemClickListener(net.osmand.plus.ContextMenuAdapter.ItemClickListener) APP_PROFILES_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.APP_PROFILES_ID) R(net.osmand.plus.R) FAVORITES_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.FAVORITES_ID) INVALID_ID(net.osmand.plus.ContextMenuItem.INVALID_ID) DrawableRes(androidx.annotation.DrawableRes) RenderingRulesStorage(net.osmand.render.RenderingRulesStorage) MAP_RENDERING_CATEGORY_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_RENDERING_CATEGORY_ID) CUSTOM_RENDERING_ITEMS_ID_SCHEME(net.osmand.aidlapi.OsmAndCustomizationConstants.CUSTOM_RENDERING_ITEMS_ID_SCHEME) POI_OVERLAY_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.POI_OVERLAY_ID) ColorInt(androidx.annotation.ColorInt) ContextMenuAdapter.makeDeleteAction(net.osmand.plus.ContextMenuAdapter.makeDeleteAction) UiUtilities(net.osmand.plus.utils.UiUtilities) CallbackWithObject(net.osmand.CallbackWithObject) IndexConstants(net.osmand.IndexConstants) Locale(java.util.Locale) Map(java.util.Map) MAP_LANGUAGE_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_LANGUAGE_ID) View(android.view.View) TRANSPORT_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.TRANSPORT_ID) RENDERING_CATEGORY_OSM_ASSISTANT(net.osmand.plus.plugins.osmedit.OsmEditingPlugin.RENDERING_CATEGORY_OSM_ASSISTANT) DateFormat(java.text.DateFormat) TEXT_SIZE_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.TEXT_SIZE_ID) OsmandSettings(net.osmand.plus.settings.backend.OsmandSettings) OnRowItemClick(net.osmand.plus.ContextMenuAdapter.OnRowItemClick) OsmandApplication(net.osmand.plus.OsmandApplication) StyleRes(androidx.annotation.StyleRes) OsmandPlugin(net.osmand.plus.plugins.OsmandPlugin) DETAILS_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.DETAILS_ID) MAP_SOURCE_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_SOURCE_ID) StringRes(androidx.annotation.StringRes) List(java.util.List) Nullable(androidx.annotation.Nullable) A_APP_MODE(net.osmand.render.RenderingRuleStorageProperties.A_APP_MODE) DashboardType(net.osmand.plus.dashboard.DashboardOnMap.DashboardType) GPX_FILES_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.GPX_FILES_ID) CONTOUR_DENSITY_ATTR(net.osmand.plus.plugins.srtm.SRTMPlugin.CONTOUR_DENSITY_ATTR) ContextMenuAdapter(net.osmand.plus.ContextMenuAdapter) RENDERING_CATEGORY_TRANSPORT(net.osmand.plus.transport.TransportLinesMenu.RENDERING_CATEGORY_TRANSPORT) Snackbar(com.google.android.material.snackbar.Snackbar) ResourceManager(net.osmand.plus.resources.ResourceManager) MAP_MAGNIFIER_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_MAGNIFIER_ID) SunriseSunset(net.osmand.util.SunriseSunset) RendererRegistry(net.osmand.plus.render.RendererRegistry) SHOW_CATEGORY_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.SHOW_CATEGORY_ID) CommonPreference(net.osmand.plus.settings.backend.preferences.CommonPreference) ROAD_STYLE_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.ROAD_STYLE_ID) POI_OVERLAY_LABELS_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.POI_OVERLAY_LABELS_ID) ArrayList(java.util.ArrayList) MAP_MARKERS_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_MARKERS_ID) RenderingRuleProperty(net.osmand.render.RenderingRuleProperty) LinkedHashMap(java.util.LinkedHashMap) CONTOUR_WIDTH_ATTR(net.osmand.plus.plugins.srtm.SRTMPlugin.CONTOUR_WIDTH_ATTR) A_BASE_APP_MODE(net.osmand.render.RenderingRuleStorageProperties.A_BASE_APP_MODE) PlatformUtil(net.osmand.PlatformUtil) Algorithms(net.osmand.util.Algorithms) TransportLinesMenu(net.osmand.plus.transport.TransportLinesMenu) UI_CATEGORY_HIDE(net.osmand.render.RenderingRuleStorageProperties.UI_CATEGORY_HIDE) UI_CATEGORY_ROUTES(net.osmand.render.RenderingRuleStorageProperties.UI_CATEGORY_ROUTES) AndroidUtils(net.osmand.plus.utils.AndroidUtils) Iterator(java.util.Iterator) MAP_MODE_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_MODE_ID) ItemBuilder(net.osmand.plus.ContextMenuItem.ItemBuilder) DayNightMode(net.osmand.plus.settings.enums.DayNightMode) CONTOUR_LINES_SCHEME_ATTR(net.osmand.plus.plugins.srtm.SRTMPlugin.CONTOUR_LINES_SCHEME_ATTR) MAP_STYLE_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.MAP_STYLE_ID) ROUTES_ID(net.osmand.aidlapi.OsmAndCustomizationConstants.ROUTES_ID) UI_CATEGORY_HIDDEN(net.osmand.render.RenderingRuleStorageProperties.UI_CATEGORY_HIDDEN) ArrayAdapter(android.widget.ArrayAdapter) ContextMenuItem(net.osmand.plus.ContextMenuItem) UI_CATEGORY_DETAILS(net.osmand.render.RenderingRuleStorageProperties.UI_CATEGORY_DETAILS) Log(org.apache.commons.logging.Log) CONTOUR_LINES_ATTR(net.osmand.plus.plugins.srtm.SRTMPlugin.CONTOUR_LINES_ATTR) MapActivity(net.osmand.plus.activities.MapActivity) ItemBuilder(net.osmand.plus.ContextMenuItem.ItemBuilder) OsmandApplication(net.osmand.plus.OsmandApplication)

Example 4 with CommonPreference

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

the class OsmandSettings method registerLongPreference.

@SuppressWarnings("unchecked")
public CommonPreference<Long> registerLongPreference(String id, long defValue) {
    if (registeredPreferences.containsKey(id)) {
        return (CommonPreference<Long>) registeredPreferences.get(id);
    }
    LongPreference p = new LongPreference(this, id, defValue);
    registeredPreferences.put(id, p);
    return p;
}
Also used : CommonPreference(net.osmand.plus.settings.backend.preferences.CommonPreference) LongPreference(net.osmand.plus.settings.backend.preferences.LongPreference)

Example 5 with CommonPreference

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

the class OsmandSettings method registerBooleanPreference.

@SuppressWarnings("unchecked")
public CommonPreference<Boolean> registerBooleanPreference(String id, boolean defValue) {
    if (registeredPreferences.containsKey(id)) {
        return (CommonPreference<Boolean>) registeredPreferences.get(id);
    }
    BooleanPreference p = new BooleanPreference(this, id, defValue);
    registeredPreferences.put(id, p);
    return p;
}
Also used : BooleanPreference(net.osmand.plus.settings.backend.preferences.BooleanPreference) CommonPreference(net.osmand.plus.settings.backend.preferences.CommonPreference)

Aggregations

CommonPreference (net.osmand.plus.settings.backend.preferences.CommonPreference)20 RenderingRuleProperty (net.osmand.render.RenderingRuleProperty)9 View (android.view.View)7 ArrayList (java.util.ArrayList)7 ArrayAdapter (android.widget.ArrayAdapter)6 ContextMenuItem (net.osmand.plus.ContextMenuItem)5 OsmandApplication (net.osmand.plus.OsmandApplication)5 List (java.util.List)4 Map (java.util.Map)4 ItemClickListener (net.osmand.plus.ContextMenuAdapter.ItemClickListener)4 OnRowItemClick (net.osmand.plus.ContextMenuAdapter.OnRowItemClick)4 OsmandSettings (net.osmand.plus.settings.backend.OsmandSettings)4 RenderingRulesStorage (net.osmand.render.RenderingRulesStorage)4 CompoundButton (android.widget.CompoundButton)3 NonNull (androidx.annotation.NonNull)3 HashMap (java.util.HashMap)3 DialogInterface (android.content.DialogInterface)2 SpannableString (android.text.SpannableString)2 ViewGroup (android.view.ViewGroup)2 AdapterView (android.widget.AdapterView)2