Search in sources :

Example 1 with INVALID_ID

use of net.osmand.plus.ContextMenuItem.INVALID_ID 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)

Aggregations

View (android.view.View)1 ArrayAdapter (android.widget.ArrayAdapter)1 ColorInt (androidx.annotation.ColorInt)1 DrawableRes (androidx.annotation.DrawableRes)1 NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 StringRes (androidx.annotation.StringRes)1 StyleRes (androidx.annotation.StyleRes)1 Snackbar (com.google.android.material.snackbar.Snackbar)1 DateFormat (java.text.DateFormat)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Iterator (java.util.Iterator)1 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Locale (java.util.Locale)1 Map (java.util.Map)1 CallbackWithObject (net.osmand.CallbackWithObject)1 IndexConstants (net.osmand.IndexConstants)1 PlatformUtil (net.osmand.PlatformUtil)1