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++;
}
}
}
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;
}
Aggregations