diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java index bcc36e0a28..e8156db842 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java @@ -49,6 +49,15 @@ public class QuickActionFactory { return quickActions != null ? quickActions : new ArrayList(); } + public List parseAndFilterActiveActionsList(String json) { + + Type type = new TypeToken>() { + }.getType(); + ArrayList quickActions = new Gson().fromJson(json, type); + + return quickActions != null ? quickActions : new ArrayList(); + } + public static List produceTypeActionsList() { ArrayList quickActions = new ArrayList<>(); @@ -67,13 +76,21 @@ public class QuickActionFactory { ArrayList quickActions = new ArrayList<>(); quickActions.add(new QuickAction(0, R.string.quick_action_add_create_items)); - quickActions.add(new MarkerAction()); quickActions.add(new FavoriteAction()); quickActions.add(new GPXAction()); - quickActions.add(new ParkingAction()); - quickActions.add(new TakeAudioNoteAction()); - quickActions.add(new TakePhotoNoteAction()); - quickActions.add(new TakeVideoNoteAction()); + quickActions.add(new MarkerAction()); + + if (OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class) != null) { + + quickActions.add(new TakeAudioNoteAction()); + quickActions.add(new TakePhotoNoteAction()); + quickActions.add(new TakeVideoNoteAction()); + } + + if (OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class) != null) { + + quickActions.add(new ParkingAction()); + } quickActions.add(new QuickAction(0, R.string.quick_action_add_configure_map)); quickActions.add(new ShowHideFavoritesAction()); diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java index 61e0ffc42b..1de9d7cf37 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionListFragment.java @@ -93,7 +93,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick ItemTouchHelper.Callback touchHelperCallback = new QuickActionItemTouchHelperCallback(adapter); touchHelper = new ItemTouchHelper(touchHelperCallback); touchHelper.attachToRecyclerView(quickActionRV); - adapter.addItems(quickActionRegistry.getQuickActions()); + adapter.addItems(quickActionRegistry.getFilteredQuickActions()); quickActionRV.addOnScrollListener(new RecyclerView.OnScrollListener() { @Override @@ -168,7 +168,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick @Override public void onActionsUpdated() { - adapter.addItems(quickActionRegistry.getQuickActions()); + adapter.addItems(quickActionRegistry.getFilteredQuickActions()); } public class QuickActionAdapter extends RecyclerView.Adapter implements QuickActionItemTouchHelperCallback.OnItemMoveCallback { diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java index f4beaf4bb7..62178a59af 100644 --- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java +++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionRegistry.java @@ -5,7 +5,10 @@ import android.content.Context; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandSettings; +import net.osmand.plus.audionotes.AudioVideoNotesPlugin; +import net.osmand.plus.parkingpoint.ParkingPositionPlugin; import java.lang.reflect.Type; import java.util.ArrayList; @@ -51,12 +54,44 @@ public class QuickActionRegistry { public List getQuickActions() { - ArrayList actions = new ArrayList<>(); + List actions = new ArrayList<>(); actions.addAll(quickActions); return actions; } + public List getFilteredQuickActions() { + + List actions = getQuickActions(); + List filteredActions = new ArrayList<>(); + + for (QuickAction action: actions){ + + boolean skip = false; + + if (OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class) == null) { + + if (action.type == QuickActionFactory.TakeAudioNoteAction.TYPE || + action.type == QuickActionFactory.TakePhotoNoteAction.TYPE || + action.type == QuickActionFactory.TakeVideoNoteAction.TYPE) { + + skip = true; + } + } + + if (OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class) == null) { + + if (action.type == QuickActionFactory.ParkingAction.TYPE) { + skip = true; + } + } + + if (!skip) filteredActions.add(action); + } + + return filteredActions; + } + public void addQuickAction(QuickAction action){ quickActions.add(action); diff --git a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java index 1bc5276646..c6bd473ce7 100644 --- a/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/MapQuickActionLayer.java @@ -153,7 +153,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe quickActionsWidget.setSelectionListener(null); } else { enterMovingMode(mapActivity.getMapView().getCurrentRotatedTileBox()); - quickActionsWidget.setActions(quickActionRegistry.getQuickActions()); + quickActionsWidget.setActions(quickActionRegistry.getFilteredQuickActions()); quickActionRegistry.setUpdatesListener(MapQuickActionLayer.this); quickActionsWidget.setSelectionListener(MapQuickActionLayer.this); } @@ -259,7 +259,7 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe @Override public void onActionsUpdated() { - quickActionsWidget.setActions(quickActionRegistry.getQuickActions()); + quickActionsWidget.setActions(quickActionRegistry.getFilteredQuickActions()); } @Override