Fix formatting

This commit is contained in:
Victor Shcherb 2017-07-17 11:10:13 +02:00
parent 6aa748cefc
commit f158d89495

View file

@ -1,6 +1,5 @@
package net.osmand.plus.quickaction;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
@ -42,76 +41,65 @@ import java.util.List;
public class QuickActionFactory {
public String quickActionListToString(List<QuickAction> quickActions) {
public String quickActionListToString(List<QuickAction> quickActions) {
return new Gson().toJson(quickActions);
}
}
public List<QuickAction> parseActiveActionsList(String json) {
public List<QuickAction> parseActiveActionsList(String json) {
Type type = new TypeToken<List<QuickAction>>() {
}.getType();
ArrayList<QuickAction> quickActions = new Gson().fromJson(json, type);
return quickActions != null ? quickActions : new ArrayList<QuickAction>();
}
Type type = new TypeToken<List<QuickAction>>() {
}.getType();
ArrayList<QuickAction> quickActions = new Gson().fromJson(json, type);
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();
return quickActions != null ? quickActions : new ArrayList<QuickAction>();
}
if (!marker.hasInstanceInList(active)) {
quickActions.add(marker);
}
public static List<QuickAction> produceTypeActionsListWithHeaders(List<QuickAction> active) {
if (OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class) != null) {
QuickAction audio = new TakeAudioNoteAction();
QuickAction photo = new TakePhotoNoteAction();
QuickAction video = new TakeVideoNoteAction();
ArrayList<QuickAction> quickActions = new ArrayList<>();
if (!audio.hasInstanceInList(active)) {
quickActions.add(audio);
}
quickActions.add(new QuickAction(0, R.string.quick_action_add_create_items));
quickActions.add(new FavoriteAction());
quickActions.add(new GPXAction());
if (!photo.hasInstanceInList(active)) {
quickActions.add(photo);
}
QuickAction marker = new MarkerAction();
if (!video.hasInstanceInList(active)) {
quickActions.add(video);
}
}
if (!marker.hasInstanceInList(active)) {
quickActions.add(marker);
}
if (OsmandPlugin.getEnabledPlugin(OsmEditingPlugin.class) != null) {
quickActions.add(new AddPOIAction());
quickActions.add(new AddOSMBugAction());
}
if (OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class) != null) {
if (OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class) != null) {
QuickAction parking = new ParkingAction();
if (!parking.hasInstanceInList(active)) {
quickActions.add(parking);
}
}
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());
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)) {
@ -120,15 +108,13 @@ public class QuickActionFactory {
}
quickActions.add(new MapStyleAction());
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
quickActions.add(new MapSourceAction());
quickActions.add(new MapOverlayAction());
quickActions.add(new MapUnderlayAction());
}
if (OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class) != null) {
quickActions.add(new MapSourceAction());
quickActions.add(new MapOverlayAction());
quickActions.add(new MapUnderlayAction());
}
QuickAction voice = new NavVoiceAction();
QuickAction voice = new NavVoiceAction();
QuickAction addDestination = new NavAddDestinationAction();
QuickAction addFirstIntermediate = new NavAddFirstIntermediateAction();
QuickAction replaceDestination = new NavReplaceDestinationAction();
@ -136,9 +122,9 @@ public class QuickActionFactory {
ArrayList<QuickAction> navigationQuickActions = new ArrayList<>();
if (!voice.hasInstanceInList(active)) {
navigationQuickActions.add(voice);
}
if (!voice.hasInstanceInList(active)) {
navigationQuickActions.add(voice);
}
if (!addDestination.hasInstanceInList(active)) {
navigationQuickActions.add(addDestination);
}
@ -157,331 +143,331 @@ public class QuickActionFactory {
quickActions.addAll(navigationQuickActions);
}
return quickActions;
}
}
public static QuickAction newActionByType(int type) {
public static QuickAction newActionByType(int type) {
switch (type) {
switch (type) {
case NewAction.TYPE:
return new NewAction();
case NewAction.TYPE:
return new NewAction();
case MarkerAction.TYPE:
return new MarkerAction();
case MarkerAction.TYPE:
return new MarkerAction();
case FavoriteAction.TYPE:
return new FavoriteAction();
case FavoriteAction.TYPE:
return new FavoriteAction();
case ShowHideFavoritesAction.TYPE:
return new ShowHideFavoritesAction();
case ShowHideFavoritesAction.TYPE:
return new ShowHideFavoritesAction();
case ShowHidePoiAction.TYPE:
return new ShowHidePoiAction();
case ShowHidePoiAction.TYPE:
return new ShowHidePoiAction();
case GPXAction.TYPE:
return new GPXAction();
case GPXAction.TYPE:
return new GPXAction();
case ParkingAction.TYPE:
return new ParkingAction();
case ParkingAction.TYPE:
return new ParkingAction();
case TakeAudioNoteAction.TYPE:
return new TakeAudioNoteAction();
case TakeAudioNoteAction.TYPE:
return new TakeAudioNoteAction();
case TakePhotoNoteAction.TYPE:
return new TakePhotoNoteAction();
case TakePhotoNoteAction.TYPE:
return new TakePhotoNoteAction();
case TakeVideoNoteAction.TYPE:
return new TakeVideoNoteAction();
case TakeVideoNoteAction.TYPE:
return new TakeVideoNoteAction();
case NavVoiceAction.TYPE:
return new NavVoiceAction();
case NavVoiceAction.TYPE:
return new NavVoiceAction();
case ShowHideOSMBugAction.TYPE:
return new ShowHideOSMBugAction();
case ShowHideOSMBugAction.TYPE:
return new ShowHideOSMBugAction();
case AddOSMBugAction.TYPE:
return new AddOSMBugAction();
case AddOSMBugAction.TYPE:
return new AddOSMBugAction();
case AddPOIAction.TYPE:
return new AddPOIAction();
case AddPOIAction.TYPE:
return new AddPOIAction();
case MapStyleAction.TYPE:
return new MapStyleAction();
case MapStyleAction.TYPE:
return new MapStyleAction();
case MapSourceAction.TYPE:
return new MapSourceAction();
case MapSourceAction.TYPE:
return new MapSourceAction();
case MapOverlayAction.TYPE:
return new MapOverlayAction();
case MapOverlayAction.TYPE:
return new MapOverlayAction();
case MapUnderlayAction.TYPE:
return new MapUnderlayAction();
case MapUnderlayAction.TYPE:
return new MapUnderlayAction();
case NavAddDestinationAction.TYPE:
return new NavAddDestinationAction();
case NavAddDestinationAction.TYPE:
return new NavAddDestinationAction();
case NavAddFirstIntermediateAction.TYPE:
return new NavAddFirstIntermediateAction();
case NavAddFirstIntermediateAction.TYPE:
return new NavAddFirstIntermediateAction();
case NavReplaceDestinationAction.TYPE:
return new NavReplaceDestinationAction();
case NavReplaceDestinationAction.TYPE:
return new NavReplaceDestinationAction();
case NavAutoZoomMapAction.TYPE:
return new NavAutoZoomMapAction();
case NavAutoZoomMapAction.TYPE:
return new NavAutoZoomMapAction();
default:
return new QuickAction();
}
}
default:
return new QuickAction();
}
}
public static QuickAction produceAction(QuickAction quickAction) {
public static QuickAction produceAction(QuickAction quickAction) {
switch (quickAction.type) {
switch (quickAction.type) {
case NewAction.TYPE:
return new NewAction(quickAction);
case NewAction.TYPE:
return new NewAction(quickAction);
case MarkerAction.TYPE:
return new MarkerAction(quickAction);
case MarkerAction.TYPE:
return new MarkerAction(quickAction);
case FavoriteAction.TYPE:
return new FavoriteAction(quickAction);
case FavoriteAction.TYPE:
return new FavoriteAction(quickAction);
case ShowHideFavoritesAction.TYPE:
return new ShowHideFavoritesAction(quickAction);
case ShowHideFavoritesAction.TYPE:
return new ShowHideFavoritesAction(quickAction);
case ShowHidePoiAction.TYPE:
return new ShowHidePoiAction(quickAction);
case ShowHidePoiAction.TYPE:
return new ShowHidePoiAction(quickAction);
case GPXAction.TYPE:
return new GPXAction(quickAction);
case GPXAction.TYPE:
return new GPXAction(quickAction);
case ParkingAction.TYPE:
return new ParkingAction(quickAction);
case ParkingAction.TYPE:
return new ParkingAction(quickAction);
case TakeAudioNoteAction.TYPE:
return new TakeAudioNoteAction(quickAction);
case TakeAudioNoteAction.TYPE:
return new TakeAudioNoteAction(quickAction);
case TakePhotoNoteAction.TYPE:
return new TakePhotoNoteAction(quickAction);
case TakePhotoNoteAction.TYPE:
return new TakePhotoNoteAction(quickAction);
case TakeVideoNoteAction.TYPE:
return new TakeVideoNoteAction(quickAction);
case TakeVideoNoteAction.TYPE:
return new TakeVideoNoteAction(quickAction);
case NavVoiceAction.TYPE:
return new NavVoiceAction(quickAction);
case NavVoiceAction.TYPE:
return new NavVoiceAction(quickAction);
case ShowHideOSMBugAction.TYPE:
return new ShowHideOSMBugAction(quickAction);
case ShowHideOSMBugAction.TYPE:
return new ShowHideOSMBugAction(quickAction);
case AddOSMBugAction.TYPE:
return new AddOSMBugAction(quickAction);
case AddOSMBugAction.TYPE:
return new AddOSMBugAction(quickAction);
case AddPOIAction.TYPE:
return new AddPOIAction(quickAction);
case AddPOIAction.TYPE:
return new AddPOIAction(quickAction);
case MapStyleAction.TYPE:
return new MapStyleAction(quickAction);
case MapStyleAction.TYPE:
return new MapStyleAction(quickAction);
case MapSourceAction.TYPE:
return new MapSourceAction(quickAction);
case MapSourceAction.TYPE:
return new MapSourceAction(quickAction);
case MapOverlayAction.TYPE:
return new MapOverlayAction(quickAction);
case MapOverlayAction.TYPE:
return new MapOverlayAction(quickAction);
case MapUnderlayAction.TYPE:
return new MapUnderlayAction(quickAction);
case MapUnderlayAction.TYPE:
return new MapUnderlayAction(quickAction);
case NavAddDestinationAction.TYPE:
return new NavAddDestinationAction(quickAction);
case NavAddDestinationAction.TYPE:
return new NavAddDestinationAction(quickAction);
case NavAddFirstIntermediateAction.TYPE:
return new NavAddFirstIntermediateAction(quickAction);
case NavAddFirstIntermediateAction.TYPE:
return new NavAddFirstIntermediateAction(quickAction);
case NavReplaceDestinationAction.TYPE:
return new NavReplaceDestinationAction(quickAction);
case NavReplaceDestinationAction.TYPE:
return new NavReplaceDestinationAction(quickAction);
case NavAutoZoomMapAction.TYPE:
return new NavAutoZoomMapAction(quickAction);
case NavAutoZoomMapAction.TYPE:
return new NavAutoZoomMapAction(quickAction);
default:
return quickAction;
}
}
default:
return quickAction;
}
}
public static @DrawableRes int getActionIcon(int type) {
public static @DrawableRes int getActionIcon(int type) {
switch (type) {
switch (type) {
case NewAction.TYPE:
return R.drawable.ic_action_plus;
case NewAction.TYPE:
return R.drawable.ic_action_plus;
case MarkerAction.TYPE:
return R.drawable.ic_action_flag_dark;
case MarkerAction.TYPE:
return R.drawable.ic_action_flag_dark;
case FavoriteAction.TYPE:
return R.drawable.ic_action_fav_dark;
case FavoriteAction.TYPE:
return R.drawable.ic_action_fav_dark;
case ShowHideFavoritesAction.TYPE:
return R.drawable.ic_action_fav_dark;
case ShowHideFavoritesAction.TYPE:
return R.drawable.ic_action_fav_dark;
case ShowHidePoiAction.TYPE:
return R.drawable.ic_action_gabout_dark;
case ShowHidePoiAction.TYPE:
return R.drawable.ic_action_gabout_dark;
case GPXAction.TYPE:
return R.drawable.ic_action_flag_dark;
case GPXAction.TYPE:
return R.drawable.ic_action_flag_dark;
case ParkingAction.TYPE:
return R.drawable.ic_action_parking_dark;
case ParkingAction.TYPE:
return R.drawable.ic_action_parking_dark;
case TakeAudioNoteAction.TYPE:
return R.drawable.ic_action_micro_dark;
case TakeAudioNoteAction.TYPE:
return R.drawable.ic_action_micro_dark;
case TakePhotoNoteAction.TYPE:
return R.drawable.ic_action_photo_dark;
case TakePhotoNoteAction.TYPE:
return R.drawable.ic_action_photo_dark;
case TakeVideoNoteAction.TYPE:
return R.drawable.ic_action_video_dark;
case TakeVideoNoteAction.TYPE:
return R.drawable.ic_action_video_dark;
case NavVoiceAction.TYPE:
return R.drawable.ic_action_volume_up;
case NavVoiceAction.TYPE:
return R.drawable.ic_action_volume_up;
case ShowHideOSMBugAction.TYPE:
return R.drawable.ic_action_bug_dark;
case ShowHideOSMBugAction.TYPE:
return R.drawable.ic_action_bug_dark;
case AddOSMBugAction.TYPE:
return R.drawable.ic_action_bug_dark;
case AddOSMBugAction.TYPE:
return R.drawable.ic_action_bug_dark;
case AddPOIAction.TYPE:
return R.drawable.ic_action_gabout_dark;
case AddPOIAction.TYPE:
return R.drawable.ic_action_gabout_dark;
case MapStyleAction.TYPE:
return R.drawable.ic_map;
case MapStyleAction.TYPE:
return R.drawable.ic_map;
case MapSourceAction.TYPE:
return R.drawable.ic_world_globe_dark;
case MapSourceAction.TYPE:
return R.drawable.ic_world_globe_dark;
case MapOverlayAction.TYPE:
return R.drawable.ic_layer_top_dark;
case MapOverlayAction.TYPE:
return R.drawable.ic_layer_top_dark;
case MapUnderlayAction.TYPE:
return R.drawable.ic_layer_bottom_dark;
case MapUnderlayAction.TYPE:
return R.drawable.ic_layer_bottom_dark;
case NavAddDestinationAction.TYPE:
return R.drawable.ic_action_target;
case NavAddDestinationAction.TYPE:
return R.drawable.ic_action_target;
case NavAddFirstIntermediateAction.TYPE:
return R.drawable.ic_action_intermediate;
case NavAddFirstIntermediateAction.TYPE:
return R.drawable.ic_action_intermediate;
case NavReplaceDestinationAction.TYPE:
return R.drawable.ic_action_target;
case NavReplaceDestinationAction.TYPE:
return R.drawable.ic_action_target;
case NavAutoZoomMapAction.TYPE:
return R.drawable.ic_action_search_dark;
case NavAutoZoomMapAction.TYPE:
return R.drawable.ic_action_search_dark;
default:
return R.drawable.ic_action_plus;
}
}
default:
return R.drawable.ic_action_plus;
}
}
public static @StringRes int getActionName(int type) {
public static @StringRes int getActionName(int type) {
switch (type) {
switch (type) {
case NewAction.TYPE:
return R.string.quick_action_new_action;
case NewAction.TYPE:
return R.string.quick_action_new_action;
case MarkerAction.TYPE:
return R.string.quick_action_add_marker;
case MarkerAction.TYPE:
return R.string.quick_action_add_marker;
case FavoriteAction.TYPE:
return R.string.quick_action_add_favorite;
case FavoriteAction.TYPE:
return R.string.quick_action_add_favorite;
case ShowHideFavoritesAction.TYPE:
return R.string.quick_action_showhide_favorites_title;
case ShowHideFavoritesAction.TYPE:
return R.string.quick_action_showhide_favorites_title;
case ShowHidePoiAction.TYPE:
return R.string.quick_action_showhide_poi_title;
case ShowHidePoiAction.TYPE:
return R.string.quick_action_showhide_poi_title;
case GPXAction.TYPE:
return R.string.quick_action_add_gpx;
case GPXAction.TYPE:
return R.string.quick_action_add_gpx;
case ParkingAction.TYPE:
return R.string.quick_action_add_parking;
case ParkingAction.TYPE:
return R.string.quick_action_add_parking;
case TakeAudioNoteAction.TYPE:
return R.string.quick_action_take_audio_note;
case TakeAudioNoteAction.TYPE:
return R.string.quick_action_take_audio_note;
case TakePhotoNoteAction.TYPE:
return R.string.quick_action_take_photo_note;
case TakePhotoNoteAction.TYPE:
return R.string.quick_action_take_photo_note;
case TakeVideoNoteAction.TYPE:
return R.string.quick_action_take_video_note;
case TakeVideoNoteAction.TYPE:
return R.string.quick_action_take_video_note;
case NavVoiceAction.TYPE:
return R.string.quick_action_navigation_voice;
case NavVoiceAction.TYPE:
return R.string.quick_action_navigation_voice;
case ShowHideOSMBugAction.TYPE:
return R.string.quick_action_showhide_osmbugs_title;
case ShowHideOSMBugAction.TYPE:
return R.string.quick_action_showhide_osmbugs_title;
case AddOSMBugAction.TYPE:
return R.string.quick_action_add_osm_bug;
case AddOSMBugAction.TYPE:
return R.string.quick_action_add_osm_bug;
case AddPOIAction.TYPE:
return R.string.quick_action_add_poi;
case AddPOIAction.TYPE:
return R.string.quick_action_add_poi;
case MapStyleAction.TYPE:
return R.string.quick_action_map_style;
case MapStyleAction.TYPE:
return R.string.quick_action_map_style;
case MapSourceAction.TYPE:
return R.string.quick_action_map_source;
case MapSourceAction.TYPE:
return R.string.quick_action_map_source;
case MapOverlayAction.TYPE:
return R.string.quick_action_map_overlay;
case MapOverlayAction.TYPE:
return R.string.quick_action_map_overlay;
case MapUnderlayAction.TYPE:
return R.string.quick_action_map_underlay;
case MapUnderlayAction.TYPE:
return R.string.quick_action_map_underlay;
case NavAddDestinationAction.TYPE:
return R.string.quick_action_add_destination;
case NavAddDestinationAction.TYPE:
return R.string.quick_action_add_destination;
case NavAddFirstIntermediateAction.TYPE:
return R.string.quick_action_add_first_intermediate;
case NavAddFirstIntermediateAction.TYPE:
return R.string.quick_action_add_first_intermediate;
case NavReplaceDestinationAction.TYPE:
return R.string.quick_action_replace_destination;
case NavReplaceDestinationAction.TYPE:
return R.string.quick_action_replace_destination;
case NavAutoZoomMapAction.TYPE:
return R.string.quick_action_auto_zoom;
case NavAutoZoomMapAction.TYPE:
return R.string.quick_action_auto_zoom;
default:
return R.string.quick_action_new_action;
}
}
default:
return R.string.quick_action_new_action;
}
}
public static boolean isActionEditable(int type) {
public static boolean isActionEditable(int type) {
switch (type) {
switch (type) {
case NewAction.TYPE:
case MarkerAction.TYPE:
case ShowHideFavoritesAction.TYPE:
case ShowHidePoiAction.TYPE:
case ParkingAction.TYPE:
case TakeAudioNoteAction.TYPE:
case TakePhotoNoteAction.TYPE:
case TakeVideoNoteAction.TYPE:
case NavVoiceAction.TYPE:
case NavAddDestinationAction.TYPE:
case NavAddFirstIntermediateAction.TYPE:
case NavReplaceDestinationAction.TYPE:
case NavAutoZoomMapAction.TYPE:
case ShowHideOSMBugAction.TYPE:
return false;
case NewAction.TYPE:
case MarkerAction.TYPE:
case ShowHideFavoritesAction.TYPE:
case ShowHidePoiAction.TYPE:
case ParkingAction.TYPE:
case TakeAudioNoteAction.TYPE:
case TakePhotoNoteAction.TYPE:
case TakeVideoNoteAction.TYPE:
case NavVoiceAction.TYPE:
case NavAddDestinationAction.TYPE:
case NavAddFirstIntermediateAction.TYPE:
case NavReplaceDestinationAction.TYPE:
case NavAutoZoomMapAction.TYPE:
case ShowHideOSMBugAction.TYPE:
return false;
default: return true;
}
}
default:
return true;
}
}
}