quick action hide with disabled plugin
This commit is contained in:
parent
4c2935ce12
commit
26c20d2079
4 changed files with 62 additions and 10 deletions
|
@ -49,6 +49,15 @@ public class QuickActionFactory {
|
|||
return quickActions != null ? quickActions : new ArrayList<QuickAction>();
|
||||
}
|
||||
|
||||
public List<QuickAction> parseAndFilterActiveActionsList(String json) {
|
||||
|
||||
Type type = new TypeToken<List<QuickAction>>() {
|
||||
}.getType();
|
||||
ArrayList<QuickAction> quickActions = new Gson().fromJson(json, type);
|
||||
|
||||
return quickActions != null ? quickActions : new ArrayList<QuickAction>();
|
||||
}
|
||||
|
||||
public static List<QuickAction> produceTypeActionsList() {
|
||||
|
||||
ArrayList<QuickAction> quickActions = new ArrayList<>();
|
||||
|
@ -67,13 +76,21 @@ public class QuickActionFactory {
|
|||
ArrayList<QuickAction> 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 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());
|
||||
|
|
|
@ -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<RecyclerView.ViewHolder> implements QuickActionItemTouchHelperCallback.OnItemMoveCallback {
|
||||
|
|
|
@ -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<QuickAction> getQuickActions() {
|
||||
|
||||
ArrayList<QuickAction> actions = new ArrayList<>();
|
||||
List<QuickAction> actions = new ArrayList<>();
|
||||
actions.addAll(quickActions);
|
||||
|
||||
return actions;
|
||||
}
|
||||
|
||||
public List<QuickAction> getFilteredQuickActions() {
|
||||
|
||||
List<QuickAction> actions = getQuickActions();
|
||||
List<QuickAction> 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);
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue