Search in sources :

Example 1 with MapStyleAction

use of net.osmand.plus.quickaction.actions.MapStyleAction in project Osmand by osmandapp.

the class SelectMapViewQuickActionsBottomSheet method populateItemsList.

private void populateItemsList() {
    Context context = getContext();
    if (context == null) {
        return;
    }
    int counter = 0;
    if (action instanceof MapStyleAction) {
        MapStyleAction mapStyleAction = (MapStyleAction) action;
        List<String> stylesList = mapStyleAction.getFilteredStyles();
        for (String entry : stylesList) {
            boolean selected = entry.equals(selectedItem);
            createItemRow(selected, counter, getContentIcon(action.getIconRes()), mapStyleAction.getTranslatedItemName(context, entry), entry);
            counter++;
        }
    } else if (action instanceof SwitchProfileAction) {
        SwitchProfileAction switchProfileAction = (SwitchProfileAction) action;
        List<String> profilesKeys = (List<String>) switchProfileAction.loadListFromParams();
        for (String key : profilesKeys) {
            ApplicationMode appMode = ApplicationMode.valueOfStringKey(key, null);
            if (appMode != null) {
                boolean selected = key.equals(selectedItem);
                int iconId = appMode.getIconRes();
                int color = appMode.getProfileColor(nightMode);
                Drawable icon = getPaintedIcon(iconId, color);
                String translatedName = appMode.toHumanString();
                createItemRow(selected, counter, icon, translatedName, key);
                counter++;
            }
        }
    } else if (action instanceof SwitchableAction) {
        SwitchableAction switchableAction = (SwitchableAction) action;
        List<Pair<String, String>> sources = (List<Pair<String, String>>) switchableAction.loadListFromParams();
        for (Pair<String, String> entry : sources) {
            String tag = entry.first;
            boolean selected = tag.equals(selectedItem);
            createItemRow(selected, counter, getContentIcon(action.getIconRes()), entry.second, tag);
            counter++;
        }
    }
}
Also used : Context(android.content.Context) Drawable(android.graphics.drawable.Drawable) MapStyleAction(net.osmand.plus.quickaction.actions.MapStyleAction) ApplicationMode(net.osmand.plus.settings.backend.ApplicationMode) SwitchableAction(net.osmand.plus.quickaction.SwitchableAction) SwitchProfileAction(net.osmand.plus.quickaction.actions.SwitchProfileAction) ColorStateList(android.content.res.ColorStateList) List(java.util.List) Pair(androidx.core.util.Pair)

Example 2 with MapStyleAction

use of net.osmand.plus.quickaction.actions.MapStyleAction in project Osmand by osmandapp.

the class QuickActionFactory method produceTypeActionsListWithHeaders.

public static List<QuickAction> produceTypeActionsListWithHeaders(List<QuickAction> active) {
    ArrayList<QuickAction> quickActions = new ArrayList<>();
    quickActions.add(new QuickAction(0, R.string.quick_action_add_create_items));
    quickActions.add(new FavoriteAction());
    quickActions.add(new GPXAction());
    QuickAction marker = new MarkerAction();
    if (!marker.hasInstanceInList(active)) {
        quickActions.add(marker);
    }
    if (OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class) != null) {
        QuickAction audio = new TakeAudioNoteAction();
        QuickAction photo = new TakePhotoNoteAction();
        QuickAction video = new TakeVideoNoteAction();
        if (!audio.hasInstanceInList(active)) {
            quickActions.add(audio);
        }
        if (!photo.hasInstanceInList(active)) {
            quickActions.add(photo);
        }
        if (!video.hasInstanceInList(active)) {
            quickActions.add(video);
        }
    }
    if (OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null) {
        quickActions.add(new AddPOIAction());
        quickActions.add(new AddOSMBugAction());
    }
    if (OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class) != null) {
        QuickAction parking = new ParkingAction();
        if (!parking.hasInstanceInList(active)) {
            quickActions.add(parking);
        }
    }
    quickActions.add(new QuickAction(0, R.string.quick_action_add_configure_map));
    QuickAction favorites = new ShowHideFavoritesAction();
    if (!favorites.hasInstanceInList(active)) {
        quickActions.add(favorites);
    }
    quickActions.add(new ShowHidePoiAction());
    if (OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null) {
        QuickAction showHideOSMBugAction = new ShowHideOSMBugAction();
        if (!showHideOSMBugAction.hasInstanceInList(active)) {
            quickActions.add(showHideOSMBugAction);
        }
    }
    quickActions.add(new MapStyleAction());
    if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
        quickActions.add(new MapSourceAction());
        quickActions.add(new MapOverlayAction());
        quickActions.add(new MapUnderlayAction());
    }
    QuickAction voice = new NavVoiceAction();
    QuickAction addDestination = new NavAddDestinationAction();
    QuickAction addFirstIntermediate = new NavAddFirstIntermediateAction();
    QuickAction replaceDestination = new NavReplaceDestinationAction();
    QuickAction autoZoomMap = new NavAutoZoomMapAction();
    QuickAction startStopNavigation = new NavStartStopAction();
    QuickAction resumePauseNavigation = new NavResumePauseAction();
    ArrayList<QuickAction> navigationQuickActions = new ArrayList<>();
    if (!voice.hasInstanceInList(active)) {
        navigationQuickActions.add(voice);
    }
    if (!addDestination.hasInstanceInList(active)) {
        navigationQuickActions.add(addDestination);
    }
    if (!addFirstIntermediate.hasInstanceInList(active)) {
        navigationQuickActions.add(addFirstIntermediate);
    }
    if (!replaceDestination.hasInstanceInList(active)) {
        navigationQuickActions.add(replaceDestination);
    }
    if (!autoZoomMap.hasInstanceInList(active)) {
        navigationQuickActions.add(autoZoomMap);
    }
    if (!startStopNavigation.hasInstanceInList(active)) {
        navigationQuickActions.add(startStopNavigation);
    }
    if (!resumePauseNavigation.hasInstanceInList(active)) {
        navigationQuickActions.add(resumePauseNavigation);
    }
    if (navigationQuickActions.size() > 0) {
        quickActions.add(new QuickAction(0, R.string.quick_action_add_navigation));
        quickActions.addAll(navigationQuickActions);
    }
    return quickActions;
}
Also used : AudioVideoNotesPlugin(net.osmand.plus.audionotes.AudioVideoNotesPlugin) NavStartStopAction(net.osmand.plus.quickaction.actions.NavStartStopAction) ArrayList(java.util.ArrayList) MapUnderlayAction(net.osmand.plus.quickaction.actions.MapUnderlayAction) ShowHideFavoritesAction(net.osmand.plus.quickaction.actions.ShowHideFavoritesAction) ParkingPositionPlugin(net.osmand.plus.parkingpoint.ParkingPositionPlugin) NavVoiceAction(net.osmand.plus.quickaction.actions.NavVoiceAction) NavReplaceDestinationAction(net.osmand.plus.quickaction.actions.NavReplaceDestinationAction) TakeAudioNoteAction(net.osmand.plus.audionotes.TakeAudioNoteAction) NavAutoZoomMapAction(net.osmand.plus.quickaction.actions.NavAutoZoomMapAction) NavAddFirstIntermediateAction(net.osmand.plus.quickaction.actions.NavAddFirstIntermediateAction) FavoriteAction(net.osmand.plus.quickaction.actions.FavoriteAction) OsmandRasterMapsPlugin(net.osmand.plus.rastermaps.OsmandRasterMapsPlugin) NavResumePauseAction(net.osmand.plus.quickaction.actions.NavResumePauseAction) AddPOIAction(net.osmand.plus.quickaction.actions.AddPOIAction) MarkerAction(net.osmand.plus.quickaction.actions.MarkerAction) MapSourceAction(net.osmand.plus.quickaction.actions.MapSourceAction) MapOverlayAction(net.osmand.plus.quickaction.actions.MapOverlayAction) TakeVideoNoteAction(net.osmand.plus.audionotes.TakeVideoNoteAction) MapStyleAction(net.osmand.plus.quickaction.actions.MapStyleAction) TakePhotoNoteAction(net.osmand.plus.audionotes.TakePhotoNoteAction) OsmEditingPlugin(net.osmand.plus.osmedit.OsmEditingPlugin) GPXAction(net.osmand.plus.quickaction.actions.GPXAction) ShowHideOSMBugAction(net.osmand.plus.quickaction.actions.ShowHideOSMBugAction) AddOSMBugAction(net.osmand.plus.quickaction.actions.AddOSMBugAction) NavAddDestinationAction(net.osmand.plus.quickaction.actions.NavAddDestinationAction) ParkingAction(net.osmand.plus.parkingpoint.ParkingAction) ShowHidePoiAction(net.osmand.plus.quickaction.actions.ShowHidePoiAction)

Aggregations

MapStyleAction (net.osmand.plus.quickaction.actions.MapStyleAction)2 Context (android.content.Context)1 ColorStateList (android.content.res.ColorStateList)1 Drawable (android.graphics.drawable.Drawable)1 Pair (androidx.core.util.Pair)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AudioVideoNotesPlugin (net.osmand.plus.audionotes.AudioVideoNotesPlugin)1 TakeAudioNoteAction (net.osmand.plus.audionotes.TakeAudioNoteAction)1 TakePhotoNoteAction (net.osmand.plus.audionotes.TakePhotoNoteAction)1 TakeVideoNoteAction (net.osmand.plus.audionotes.TakeVideoNoteAction)1 OsmEditingPlugin (net.osmand.plus.osmedit.OsmEditingPlugin)1 ParkingAction (net.osmand.plus.parkingpoint.ParkingAction)1 ParkingPositionPlugin (net.osmand.plus.parkingpoint.ParkingPositionPlugin)1 SwitchableAction (net.osmand.plus.quickaction.SwitchableAction)1 AddOSMBugAction (net.osmand.plus.quickaction.actions.AddOSMBugAction)1 AddPOIAction (net.osmand.plus.quickaction.actions.AddPOIAction)1 FavoriteAction (net.osmand.plus.quickaction.actions.FavoriteAction)1 GPXAction (net.osmand.plus.quickaction.actions.GPXAction)1 MapOverlayAction (net.osmand.plus.quickaction.actions.MapOverlayAction)1