diff --git a/OsmAnd/res/values/strings.xml b/OsmAnd/res/values/strings.xml
index 09cd072cbe..9628a7b7da 100644
--- a/OsmAnd/res/values/strings.xml
+++ b/OsmAnd/res/values/strings.xml
@@ -9,6 +9,12 @@
3. All your modified/created strings are in the top of the file (to make easier find what\'s translated).
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
-->
+ Add destination
+ Replace destination
+ Add first intermediate
+ Tapping the action button will add a destination at the screen center location.
+ Tapping the action button will replace location of the destination with the screen center location.
+ Tapping the action button will add a first intermediate point at the screen center location.
No overlay
No underlay
Error
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/TakeAudioNoteAction.java b/OsmAnd/src/net/osmand/plus/audionotes/TakeAudioNoteAction.java
new file mode 100644
index 0000000000..c86046fba8
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/audionotes/TakeAudioNoteAction.java
@@ -0,0 +1,48 @@
+package net.osmand.plus.audionotes;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import net.osmand.data.LatLon;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.quickaction.QuickAction;
+
+public class TakeAudioNoteAction extends QuickAction {
+ public static final int TYPE = 8;
+
+ public TakeAudioNoteAction() {
+ super(TYPE);
+ }
+
+ public TakeAudioNoteAction(QuickAction quickAction) {
+ super(quickAction);
+ }
+
+ @Override
+ public void execute(MapActivity activity) {
+
+ LatLon latLon = activity.getMapView()
+ .getCurrentRotatedTileBox()
+ .getCenterLatLon();
+
+ AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
+ if (plugin != null)
+ plugin.recordAudio(latLon.getLatitude(), latLon.getLongitude(), activity);
+ }
+
+ @Override
+ public void drawUI(ViewGroup parent, MapActivity activity) {
+
+ View view = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.quick_action_with_text, parent, false);
+
+ ((TextView) view.findViewById(R.id.text)).setText(
+ R.string.quick_action_take_audio_note_descr);
+
+ parent.addView(view);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/TakePhotoNoteAction.java b/OsmAnd/src/net/osmand/plus/audionotes/TakePhotoNoteAction.java
new file mode 100644
index 0000000000..4b56929a2b
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/audionotes/TakePhotoNoteAction.java
@@ -0,0 +1,48 @@
+package net.osmand.plus.audionotes;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import net.osmand.data.LatLon;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.quickaction.QuickAction;
+
+public class TakePhotoNoteAction extends QuickAction {
+ public static final int TYPE = 10;
+
+ public TakePhotoNoteAction() {
+ super(TYPE);
+ }
+
+ public TakePhotoNoteAction(QuickAction quickAction) {
+ super(quickAction);
+ }
+
+ @Override
+ public void execute(MapActivity activity) {
+
+ LatLon latLon = activity.getMapView()
+ .getCurrentRotatedTileBox()
+ .getCenterLatLon();
+
+ AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
+ if (plugin != null)
+ plugin.takePhoto(latLon.getLatitude(), latLon.getLongitude(), activity, false);
+ }
+
+ @Override
+ public void drawUI(ViewGroup parent, MapActivity activity) {
+
+ View view = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.quick_action_with_text, parent, false);
+
+ ((TextView) view.findViewById(R.id.text)).setText(
+ R.string.quick_action_take_photo_note_descr);
+
+ parent.addView(view);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/audionotes/TakeVideoNoteAction.java b/OsmAnd/src/net/osmand/plus/audionotes/TakeVideoNoteAction.java
new file mode 100644
index 0000000000..17e917d74a
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/audionotes/TakeVideoNoteAction.java
@@ -0,0 +1,48 @@
+package net.osmand.plus.audionotes;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import net.osmand.data.LatLon;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.quickaction.QuickAction;
+
+public class TakeVideoNoteAction extends QuickAction {
+ public static final int TYPE = 9;
+
+ public TakeVideoNoteAction() {
+ super(TYPE);
+ }
+
+ public TakeVideoNoteAction(QuickAction quickAction) {
+ super(quickAction);
+ }
+
+ @Override
+ public void execute(MapActivity activity) {
+
+ LatLon latLon = activity.getMapView()
+ .getCurrentRotatedTileBox()
+ .getCenterLatLon();
+
+ AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
+ if (plugin != null)
+ plugin.recordVideo(latLon.getLatitude(), latLon.getLongitude(), activity);
+ }
+
+ @Override
+ public void drawUI(ViewGroup parent, MapActivity activity) {
+
+ View view = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.quick_action_with_text, parent, false);
+
+ ((TextView) view.findViewById(R.id.text)).setText(
+ R.string.quick_action_take_video_note_descr);
+
+ parent.addView(view);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingAction.java b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingAction.java
new file mode 100644
index 0000000000..825c6c34e6
--- /dev/null
+++ b/OsmAnd/src/net/osmand/plus/parkingpoint/ParkingAction.java
@@ -0,0 +1,52 @@
+package net.osmand.plus.parkingpoint;
+
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.TextView;
+
+import net.osmand.data.LatLon;
+import net.osmand.plus.OsmandPlugin;
+import net.osmand.plus.R;
+import net.osmand.plus.activities.MapActivity;
+import net.osmand.plus.quickaction.QuickAction;
+
+public class ParkingAction extends QuickAction {
+
+ public static final int TYPE = 7;
+
+ public ParkingAction() {
+ super(TYPE);
+ }
+
+ public ParkingAction(QuickAction quickAction) {
+ super(quickAction);
+ }
+
+ @Override
+ public void execute(MapActivity activity) {
+
+ ParkingPositionPlugin plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
+
+ if (plugin != null) {
+
+ LatLon latLon = activity.getMapView()
+ .getCurrentRotatedTileBox()
+ .getCenterLatLon();
+
+ plugin.showAddParkingDialog(activity, latLon.getLatitude(), latLon.getLongitude());
+ }
+ }
+
+ @Override
+ public void drawUI(ViewGroup parent, MapActivity activity) {
+
+ View view = LayoutInflater.from(parent.getContext())
+ .inflate(R.layout.quick_action_with_text, parent, false);
+
+ ((TextView) view.findViewById(R.id.text)).setText(
+ R.string.quick_action_add_parking_descr);
+
+ parent.addView(view);
+ }
+}
diff --git a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java
index ca173f7126..9aa2ceb2c6 100644
--- a/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java
+++ b/OsmAnd/src/net/osmand/plus/quickaction/QuickActionFactory.java
@@ -1,108 +1,48 @@
package net.osmand.plus.quickaction;
-import android.app.Dialog;
-import android.app.ProgressDialog;
-import android.content.Context;
-import android.content.DialogInterface;
-import android.content.Intent;
-import android.content.res.Resources;
-import android.graphics.drawable.Drawable;
-import android.net.Uri;
-import android.os.Build;
import android.support.annotation.DrawableRes;
import android.support.annotation.StringRes;
-import android.support.design.widget.TextInputLayout;
-import android.support.v4.util.Pair;
-import android.support.v4.view.MotionEventCompat;
-import android.support.v7.app.AlertDialog;
-import android.support.v7.widget.RecyclerView;
-import android.support.v7.widget.SwitchCompat;
-import android.support.v7.widget.helper.ItemTouchHelper;
-import android.text.Editable;
-import android.text.TextUtils;
-import android.text.TextWatcher;
-import android.util.TypedValue;
-import android.view.LayoutInflater;
-import android.view.MotionEvent;
-import android.view.View;
-import android.view.ViewGroup;
-import android.widget.AdapterView;
-import android.widget.ArrayAdapter;
-import android.widget.AutoCompleteTextView;
-import android.widget.Button;
-import android.widget.EditText;
-import android.widget.ImageButton;
-import android.widget.ImageView;
-import android.widget.LinearLayout;
-import android.widget.TextView;
-import android.widget.Toast;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
-import net.osmand.CallbackWithObject;
-import net.osmand.data.LatLon;
-import net.osmand.data.PointDescription;
-import net.osmand.osm.AbstractPoiType;
-import net.osmand.osm.MapPoiTypes;
-import net.osmand.osm.PoiCategory;
-import net.osmand.osm.PoiType;
-import net.osmand.osm.edit.Node;
-import net.osmand.plus.ContextMenuAdapter;
-import net.osmand.plus.ContextMenuItem;
-import net.osmand.plus.FavouritesDbHelper;
-import net.osmand.plus.GeocodingLookupService;
-import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
-import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
-import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
-import net.osmand.plus.dialogs.ConfigureMapMenu;
-import net.osmand.plus.mapcontextmenu.editors.EditCategoryDialogFragment;
-import net.osmand.plus.mapcontextmenu.editors.SelectCategoryDialogFragment;
-import net.osmand.plus.openseamapsplugin.NauticalMapsPlugin;
-import net.osmand.plus.osmedit.EditPoiData;
-import net.osmand.plus.osmedit.EditPoiDialogFragment;
-import net.osmand.plus.osmedit.OpenstreetmapLocalUtil;
-import net.osmand.plus.osmedit.OpenstreetmapPoint;
-import net.osmand.plus.osmedit.OpenstreetmapUtil;
+import net.osmand.plus.audionotes.TakeAudioNoteAction;
+import net.osmand.plus.audionotes.TakePhotoNoteAction;
+import net.osmand.plus.audionotes.TakeVideoNoteAction;
import net.osmand.plus.osmedit.OsmEditingPlugin;
-import net.osmand.plus.osmedit.OsmPoint;
-import net.osmand.plus.osmedit.dialogs.PoiSubTypeDialogFragment;
+import net.osmand.plus.parkingpoint.ParkingAction;
import net.osmand.plus.parkingpoint.ParkingPositionPlugin;
-import net.osmand.plus.poi.PoiFiltersHelper;
-import net.osmand.plus.poi.PoiUIFilter;
+import net.osmand.plus.quickaction.actions.AddOSMBugAction;
+import net.osmand.plus.quickaction.actions.AddPOIAction;
+import net.osmand.plus.quickaction.actions.FavoriteAction;
+import net.osmand.plus.quickaction.actions.GPXAction;
+import net.osmand.plus.quickaction.actions.MapOverlayAction;
+import net.osmand.plus.quickaction.actions.MapSourceAction;
+import net.osmand.plus.quickaction.actions.MapStyleAction;
+import net.osmand.plus.quickaction.actions.MapUnderlayAction;
+import net.osmand.plus.quickaction.actions.MarkerAction;
+import net.osmand.plus.quickaction.actions.NavAddDestinationAction;
+import net.osmand.plus.quickaction.actions.NavAddFirstIntermediateAction;
+import net.osmand.plus.quickaction.actions.NavReplaceDestinationAction;
+import net.osmand.plus.quickaction.actions.NavVoiceAction;
+import net.osmand.plus.quickaction.actions.NewAction;
+import net.osmand.plus.quickaction.actions.ShowHideFavoritesAction;
+import net.osmand.plus.quickaction.actions.ShowHidePoiAction;
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
-import net.osmand.plus.render.RendererRegistry;
-import net.osmand.plus.render.RenderingIcons;
-import net.osmand.plus.views.OsmandMapTileView;
-import net.osmand.plus.widgets.AutoCompleteTextViewEx;
-import net.osmand.render.RenderingRulesStorage;
-import net.osmand.util.Algorithms;
import java.lang.reflect.Type;
import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.Comparator;
-import java.util.HashSet;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
-
-import static net.osmand.plus.osmedit.AdvancedEditPoiFragment.addPoiToStringSet;
-import static net.osmand.plus.osmedit.EditPoiData.POI_TYPE_TAG;
public class QuickActionFactory {
public String quickActionListToString(List quickActions) {
- String json = new Gson().toJson(quickActions);
- return json;
+ return new Gson().toJson(quickActions);
}
public List parseActiveActionsList(String json) {
@@ -181,15 +121,33 @@ public class QuickActionFactory {
quickActions.add(new MapUnderlayAction());
}
- QuickAction voice = new NavigationVoiceAction();
+ QuickAction voice = new NavVoiceAction();
+ QuickAction addDestination = new NavAddDestinationAction();
+ QuickAction addFirstIntermediate = new NavAddFirstIntermediateAction();
+ QuickAction replaceDestination = new NavReplaceDestinationAction();
+
+ ArrayList navigationQuickActions = new ArrayList<>();
if (!voice.hasInstanceInList(active)) {
-
- quickActions.add(new QuickAction(0, R.string.quick_action_add_navigation));
- quickActions.add(voice);
+ navigationQuickActions.add(voice);
}
+ if (!addDestination.hasInstanceInList(active)) {
+ navigationQuickActions.add(addDestination);
+ }
+ if (!addFirstIntermediate.hasInstanceInList(active)) {
+ navigationQuickActions.add(addFirstIntermediate);
+ }
+ if (!replaceDestination.hasInstanceInList(active)) {
+ navigationQuickActions.add(replaceDestination);
+ }
- return quickActions;
+ if (navigationQuickActions.size() > 0) {
+ quickActions.add(new QuickAction(0, R.string.quick_action_add_navigation));
+ quickActions.addAll(navigationQuickActions);
+ }
+
+
+ return quickActions;
}
public static QuickAction newActionByType(int type) {
@@ -226,8 +184,8 @@ public class QuickActionFactory {
case TakeVideoNoteAction.TYPE:
return new TakeVideoNoteAction();
- case NavigationVoiceAction.TYPE:
- return new NavigationVoiceAction();
+ case NavVoiceAction.TYPE:
+ return new NavVoiceAction();
case AddOSMBugAction.TYPE:
return new AddOSMBugAction();
@@ -247,6 +205,15 @@ public class QuickActionFactory {
case MapUnderlayAction.TYPE:
return new MapUnderlayAction();
+ case NavAddDestinationAction.TYPE:
+ return new NavAddDestinationAction();
+
+ case NavAddFirstIntermediateAction.TYPE:
+ return new NavAddFirstIntermediateAction();
+
+ case NavReplaceDestinationAction.TYPE:
+ return new NavReplaceDestinationAction();
+
default:
return new QuickAction();
}
@@ -286,8 +253,8 @@ public class QuickActionFactory {
case TakeVideoNoteAction.TYPE:
return new TakeVideoNoteAction(quickAction);
- case NavigationVoiceAction.TYPE:
- return new NavigationVoiceAction(quickAction);
+ case NavVoiceAction.TYPE:
+ return new NavVoiceAction(quickAction);
case AddOSMBugAction.TYPE:
return new AddOSMBugAction(quickAction);
@@ -307,7 +274,16 @@ public class QuickActionFactory {
case MapUnderlayAction.TYPE:
return new MapUnderlayAction(quickAction);
- default:
+ case NavAddDestinationAction.TYPE:
+ return new NavAddDestinationAction(quickAction);
+
+ case NavAddFirstIntermediateAction.TYPE:
+ return new NavAddFirstIntermediateAction(quickAction);
+
+ case NavReplaceDestinationAction.TYPE:
+ return new NavReplaceDestinationAction(quickAction);
+
+ default:
return quickAction;
}
}
@@ -346,7 +322,7 @@ public class QuickActionFactory {
case TakeVideoNoteAction.TYPE:
return R.drawable.ic_action_video_dark;
- case NavigationVoiceAction.TYPE:
+ case NavVoiceAction.TYPE:
return R.drawable.ic_action_volume_up;
case AddOSMBugAction.TYPE:
@@ -367,7 +343,17 @@ public class QuickActionFactory {
case MapUnderlayAction.TYPE:
return R.drawable.ic_layer_bottom_dark;
- default: return R.drawable.ic_action_plus;
+ case NavAddDestinationAction.TYPE:
+ return R.drawable.ic_action_target;
+
+ case NavAddFirstIntermediateAction.TYPE:
+ return R.drawable.ic_action_intermediate;
+
+ case NavReplaceDestinationAction.TYPE:
+ return R.drawable.ic_action_target;
+
+ default:
+ return R.drawable.ic_action_plus;
}
}
@@ -405,7 +391,7 @@ public class QuickActionFactory {
case TakeVideoNoteAction.TYPE:
return R.string.quick_action_take_video_note;
- case NavigationVoiceAction.TYPE:
+ case NavVoiceAction.TYPE:
return R.string.quick_action_navigation_voice;
case AddOSMBugAction.TYPE:
@@ -426,7 +412,17 @@ public class QuickActionFactory {
case MapUnderlayAction.TYPE:
return R.string.quick_action_map_underlay;
- default: return R.string.quick_action_new_action;
+ case NavAddDestinationAction.TYPE:
+ return R.string.quick_action_add_destination;
+
+ case NavAddFirstIntermediateAction.TYPE:
+ return R.string.quick_action_add_first_intermediate;
+
+ case NavReplaceDestinationAction.TYPE:
+ return R.string.quick_action_replace_destination;
+
+ default:
+ return R.string.quick_action_new_action;
}
}
@@ -442,2406 +438,13 @@ public class QuickActionFactory {
case TakeAudioNoteAction.TYPE:
case TakePhotoNoteAction.TYPE:
case TakeVideoNoteAction.TYPE:
- case NavigationVoiceAction.TYPE:
+ case NavVoiceAction.TYPE:
+ case NavAddDestinationAction.TYPE:
+ case NavAddFirstIntermediateAction.TYPE:
+ case NavReplaceDestinationAction.TYPE:
return false;
default: return true;
}
}
-
- public static class NewAction extends QuickAction {
-
- public static final int TYPE = 1;
-
- protected NewAction() {
- super(TYPE);
- }
-
- public NewAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- AddQuickActionDialog dialog = new AddQuickActionDialog();
- dialog.show(activity.getSupportFragmentManager(), AddQuickActionDialog.TAG);
- }
-
- @Override
- public void drawUI(ViewGroup parent, MapActivity activity) {
-
- }
- }
-
- public static class MarkerAction extends QuickAction {
-
- public static final int TYPE = 2;
-
- private MarkerAction() {
- super(TYPE);
- }
-
- public MarkerAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- LatLon latLon = activity.getMapView()
- .getCurrentRotatedTileBox()
- .getCenterLatLon();
-
- PointDescription pointDescription = new PointDescription(
- latLon.getLatitude(),
- latLon.getLongitude());
-
- if (pointDescription.isLocation() && pointDescription.getName().equals(PointDescription.getAddressNotFoundStr(activity)))
- pointDescription = new PointDescription(PointDescription.POINT_TYPE_LOCATION, "");
-
- activity.getMapActions().addMapMarker(
- latLon.getLatitude(),
- latLon.getLongitude(),
- pointDescription);
- }
-
- @Override
- public void drawUI(ViewGroup parent, MapActivity activity) {
-
- View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_with_text, parent, false);
-
- ((TextView) view.findViewById(R.id.text)).setText(
- R.string.quick_action_add_marker_descr);
-
- parent.addView(view);
- }
- }
-
- public static class FavoriteAction extends QuickAction {
-
- public static final int TYPE = 3;
-
- public static final String KEY_NAME = "name";
- public static final String KEY_DIALOG = "dialog";
- public static final String KEY_CATEGORY_NAME = "category_name";
- public static final String KEY_CATEGORY_COLOR = "category_color";
-
- private FavoriteAction() {
- super(TYPE);
- }
-
- public FavoriteAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(final MapActivity activity) {
-
- final LatLon latLon = activity.getMapView()
- .getCurrentRotatedTileBox()
- .getCenterLatLon();
-
- final String title = getParams().get(KEY_NAME);
-
- if (title == null || title.isEmpty()) {
-
- final Dialog progressDialog = new ProgressDialog(activity);
- progressDialog.setCancelable(false);
- progressDialog.setTitle(R.string.search_address);
- progressDialog.show();
-
- GeocodingLookupService.AddressLookupRequest lookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon,
-
- new GeocodingLookupService.OnAddressLookupResult() {
-
- @Override
- public void geocodingDone(String address) {
-
- if (progressDialog != null) progressDialog.dismiss();
-
- if (activity != null) {
-
- activity.getContextMenu().getFavoritePointEditor().add(latLon, address, "",
- getParams().get(KEY_CATEGORY_NAME),
- Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)),
- !Boolean.valueOf(getParams().get(KEY_DIALOG)));
- }
- }
-
- }, null);
-
- activity.getMyApplication().getGeocodingLookupService().lookupAddress(lookupRequest);
-
- } else activity.getContextMenu().getFavoritePointEditor().add(latLon, title, "",
- getParams().get(KEY_CATEGORY_NAME),
- Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)),
- !Boolean.valueOf(getParams().get(KEY_DIALOG)));
- }
-
- @Override
- public void drawUI(final ViewGroup parent, final MapActivity activity) {
-
- FavouritesDbHelper helper = activity.getMyApplication().getFavorites();
-
- final View root = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_add_favorite, parent, false);
-
- parent.addView(root);
-
- AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) root.findViewById(R.id.category_edit);
- SwitchCompat showDialog = (SwitchCompat) root.findViewById(R.id.saveButton);
- ImageView categoryImage = (ImageView) root.findViewById(R.id.category_image);
- EditText name = (EditText) root.findViewById(R.id.name_edit);
-
- if (!getParams().isEmpty()) {
-
- showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
- categoryImage.setColorFilter(Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)));
- name.setText(getParams().get(KEY_NAME));
- categoryEdit.setText(getParams().get(KEY_CATEGORY_NAME));
-
- if (getParams().get(KEY_NAME).isEmpty() && Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)) == 0) {
-
- categoryEdit.setText(activity.getString(R.string.shared_string_favorites));
- categoryImage.setColorFilter(activity.getResources().getColor(R.color.color_favorite));
- }
-
- } else if (helper.getFavoriteGroups().size() > 0) {
-
- FavouritesDbHelper.FavoriteGroup group = helper.getFavoriteGroups().get(0);
-
- if (group.name.isEmpty() && group.color == 0) {
-
- group.name = activity.getString(R.string.shared_string_favorites);
-
- categoryEdit.setText(activity.getString(R.string.shared_string_favorites));
- categoryImage.setColorFilter(activity.getResources().getColor(R.color.color_favorite));
-
- } else {
-
- categoryEdit.setText(group.name);
- categoryImage.setColorFilter(group.color);
- }
-
- getParams().put(KEY_CATEGORY_NAME, group.name);
- getParams().put(KEY_CATEGORY_COLOR, String.valueOf(group.color));
-
- } else {
-
- categoryEdit.setText(activity.getString(R.string.shared_string_favorites));
- categoryImage.setColorFilter(activity.getResources().getColor(R.color.color_favorite));
-
- getParams().put(KEY_CATEGORY_NAME, "");
- getParams().put(KEY_CATEGORY_COLOR, "0");
- }
-
- categoryEdit.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(final View view) {
-
- SelectCategoryDialogFragment dialogFragment = SelectCategoryDialogFragment.createInstance("");
-
- dialogFragment.show(
- activity.getSupportFragmentManager(),
- SelectCategoryDialogFragment.TAG);
-
- dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {
- @Override
- public void onCategorySelected(String category, int color) {
-
- fillGroupParams(root, category, color);
- }
- });
- }
- });
-
- SelectCategoryDialogFragment dialogFragment = (SelectCategoryDialogFragment)
- activity.getSupportFragmentManager().findFragmentByTag(SelectCategoryDialogFragment.TAG);
-
- if (dialogFragment != null) {
-
- dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {
- @Override
- public void onCategorySelected(String category, int color) {
-
- fillGroupParams(root, category, color);
- }
- });
-
- } else {
-
- EditCategoryDialogFragment dialog = (EditCategoryDialogFragment)
- activity.getSupportFragmentManager().findFragmentByTag(EditCategoryDialogFragment.TAG);
-
- if (dialog != null) {
-
- dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {
- @Override
- public void onCategorySelected(String category, int color) {
-
- fillGroupParams(root, category, color);
- }
- });
- }
- }
- }
-
- @Override
- public boolean fillParams(View root, MapActivity activity) {
-
- getParams().put(KEY_NAME, ((EditText) root.findViewById(R.id.name_edit)).getText().toString());
- getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
-
- return true;
- }
-
- private void fillGroupParams(View root, String name, int color) {
-
- if (color == 0) color = root.getContext().getResources().getColor(R.color.color_favorite);
-
- ((AutoCompleteTextViewEx) root.findViewById(R.id.category_edit)).setText(name);
- ((ImageView) root.findViewById(R.id.category_image)).setColorFilter(color);
-
- getParams().put(KEY_CATEGORY_NAME, name);
- getParams().put(KEY_CATEGORY_COLOR, String.valueOf(color));
- }
- }
-
- public static class ShowHideFavoritesAction extends QuickAction {
-
- public static final int TYPE = 4;
-
- protected ShowHideFavoritesAction() {
- super(TYPE);
- }
-
- public ShowHideFavoritesAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- activity.getMyApplication().getSettings().SHOW_FAVORITES.set(
- !activity.getMyApplication().getSettings().SHOW_FAVORITES.get());
-
- activity.getMapLayers().updateLayers(activity.getMapView());
- }
-
- @Override
- public void drawUI(ViewGroup parent, MapActivity activity) {
-
- View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_with_text, parent, false);
-
- ((TextView) view.findViewById(R.id.text)).setText(
- R.string.quick_action_showhide_favorites_descr);
-
- parent.addView(view);
- }
-
- @Override
- public String getActionText(OsmandApplication application) {
-
- return application.getSettings().SHOW_FAVORITES.get()
- ? application.getString(R.string.quick_action_favorites_hide)
- : application.getString(R.string.quick_action_favorites_show);
- }
-
- @Override
- public boolean isActionWithSlash(OsmandApplication application) {
-
- return application.getSettings().SHOW_FAVORITES.get();
- }
- }
-
- public static class ShowHidePoiAction extends QuickAction {
-
- public static final int TYPE = 5;
-
- public static final String KEY_FILTERS = "filters";
-
- private transient EditText title;
-
- protected ShowHidePoiAction() {
- super(TYPE);
- }
-
- public ShowHidePoiAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public String getActionText(OsmandApplication application) {
-
- return !isCurrentFilters(application)
- ? application.getString(R.string.quick_action_poi_show, getName(application))
- : application.getString(R.string.quick_action_poi_hide, getName(application));
- }
-
- @Override
- public boolean isActionWithSlash(OsmandApplication application) {
-
- return isCurrentFilters(application);
- }
-
- @Override
- public void setAutoGeneratedTitle(EditText title) {
- this.title = title;
- }
-
- @Override
- public int getIconRes(Context context) {
-
- if (getParams().get(KEY_FILTERS) == null || getParams().get(KEY_FILTERS).isEmpty()) {
-
- return super.getIconRes();
-
- } else {
-
- OsmandApplication app = (OsmandApplication) context.getApplicationContext();
- List filters = new ArrayList<>();
-
- String filtersId = getParams().get(KEY_FILTERS);
- Collections.addAll(filters, filtersId.split(","));
-
- if (app.getPoiFilters() == null) return super.getIconRes();
-
- PoiUIFilter filter = app.getPoiFilters().getFilterById(filters.get(0));
-
- if (filter == null) return super.getIconRes();
-
- Object res = filter.getIconResource();
-
- if (res instanceof String && RenderingIcons.containsBigIcon(res.toString())) {
-
- return RenderingIcons.getBigIconResourceId(res.toString());
-
- } else return super.getIconRes();
- }
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- PoiFiltersHelper pf = activity.getMyApplication().getPoiFilters();
- List poiFilters = loadPoiFilters(activity.getMyApplication().getPoiFilters());
-
- if (!isCurrentFilters(pf.getSelectedPoiFilters(), poiFilters)){
-
- pf.clearSelectedPoiFilters();
-
- for (PoiUIFilter filter : poiFilters) {
- pf.addSelectedPoiFilter(filter);
- }
-
- } else pf.clearSelectedPoiFilters();
-
- activity.getMapLayers().updateLayers(activity.getMapView());
- }
-
- private boolean isCurrentFilters(OsmandApplication application) {
-
- PoiFiltersHelper pf = application.getPoiFilters();
- List poiFilters = loadPoiFilters(application.getPoiFilters());
-
- return isCurrentFilters(pf.getSelectedPoiFilters(), poiFilters);
- }
-
- private boolean isCurrentFilters(Set currentPoiFilters, List poiFilters){
-
- if (currentPoiFilters.size() != poiFilters.size()) return false;
-
- return currentPoiFilters.containsAll(poiFilters);
- }
-
- @Override
- public void drawUI(ViewGroup parent, final MapActivity activity) {
-
- View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_show_hide_poi, parent, false);
-
- RecyclerView list = (RecyclerView) view.findViewById(R.id.list);
- Button addFilter = (Button) view.findViewById(R.id.btnAddCategory);
-
- final Adapter adapter = new Adapter(!getParams().isEmpty()
- ? loadPoiFilters(activity.getMyApplication().getPoiFilters())
- : new ArrayList());
-
- list.setAdapter(adapter);
-
- addFilter.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- showSingleChoicePoiFilterDialog(activity.getMyApplication(), activity, adapter);
- }
- });
-
- parent.addView(view);
- }
-
- public class Adapter extends RecyclerView.Adapter {
-
- private List filters;
-
- public Adapter(List filters) {
- this.filters = filters;
- }
-
- private void addItem(PoiUIFilter filter) {
-
- if (!filters.contains(filter)) {
-
- filters.add(filter);
- savePoiFilters(filters);
-
- notifyDataSetChanged();
- }
- }
-
- @Override
- public Holder onCreateViewHolder(ViewGroup parent, int viewType) {
-
- return new Holder(LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_deletable_list_item, parent, false));
- }
-
- @Override
- public void onBindViewHolder(final Holder holder, final int position) {
-
- final PoiUIFilter filter = filters.get(position);
-
- Object res = filter.getIconResource();
-
- if (res instanceof String && RenderingIcons.containsBigIcon(res.toString())) {
- holder.icon.setImageResource(RenderingIcons.getBigIconResourceId(res.toString()));
- } else {
- holder.icon.setImageResource(R.drawable.mx_user_defined);
- }
-
- holder.title.setText(filter.getName());
- holder.delete.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
-
- String oldTitle = getTitle(filters);
-
- filters.remove(position);
- savePoiFilters(filters);
-
- notifyDataSetChanged();
-
- if (oldTitle.equals(title.getText().toString()) || title.getText().toString().equals(getName(holder.title.getContext()))) {
-
- String newTitle = getTitle(filters);
- title.setText(newTitle);
- }
- }
- });
- }
-
- @Override
- public int getItemCount() {
- return filters.size();
- }
-
- class Holder extends RecyclerView.ViewHolder {
-
- private TextView title;
- private ImageView icon;
- private ImageView delete;
-
- public Holder(View itemView) {
- super(itemView);
-
- title = (TextView) itemView.findViewById(R.id.title);
- icon = (ImageView) itemView.findViewById(R.id.icon);
- delete = (ImageView) itemView.findViewById(R.id.delete);
- }
- }
- }
-
- public void savePoiFilters(List poiFilters) {
-
- List filters = new ArrayList<>();
-
- for (PoiUIFilter f : poiFilters) {
- filters.add(f.getFilterId());
- }
-
- getParams().put(KEY_FILTERS, TextUtils.join(",", filters));
- }
-
- private List loadPoiFilters(PoiFiltersHelper helper) {
-
- List filters = new ArrayList<>();
-
- String filtersId = getParams().get(KEY_FILTERS);
-
- if (filtersId != null && !filtersId.trim().isEmpty()) {
- Collections.addAll(filters, filtersId.split(","));
- }
-
- List poiFilters = new ArrayList<>();
-
- for (String f : filters) {
-
- PoiUIFilter filter = helper.getFilterById(f);
-
- if (filter != null) {
- poiFilters.add(filter);
- }
- }
-
- return poiFilters;
- }
-
- private void showSingleChoicePoiFilterDialog(final OsmandApplication app, final MapActivity activity, final Adapter filtersAdapter) {
-
- final PoiFiltersHelper poiFilters = app.getPoiFilters();
- final ContextMenuAdapter adapter = new ContextMenuAdapter();
-
- adapter.addItem(new ContextMenuItem.ItemBuilder()
- .setTitleId(R.string.shared_string_search, app)
- .setIcon(R.drawable.ic_action_search_dark).createItem());
-
- final List list = new ArrayList<>();
- list.add(poiFilters.getCustomPOIFilter());
-
- for (PoiUIFilter f : poiFilters.getTopDefinedPoiFilters()) {
- addFilterToList(adapter, list, f);
- }
- for (PoiUIFilter f : poiFilters.getSearchPoiFilters()) {
- addFilterToList(adapter, list, f);
- }
-
- final ArrayAdapter listAdapter =
- adapter.createListAdapter(activity, app.getSettings().isLightContent());
- AlertDialog.Builder builder = new AlertDialog.Builder(activity);
- builder.setAdapter(listAdapter, new DialogInterface.OnClickListener() {
- @Override
- public void onClick(DialogInterface dialog, int which) {
-
- String oldTitle = getTitle(filtersAdapter.filters);
-
- filtersAdapter.addItem(list.get(which));
-
- if (oldTitle.equals(title.getText().toString()) || title.getText().toString().equals(getName(activity))) {
-
- String newTitle = getTitle(filtersAdapter.filters);
- title.setText(newTitle);
- }
- }
-
- });
- builder.setTitle(R.string.show_poi_over_map);
- builder.setNegativeButton(R.string.shared_string_dismiss, null);
-
- final AlertDialog alertDialog = builder.create();
-
- alertDialog.setOnShowListener(new DialogInterface.OnShowListener() {
- @Override
- public void onShow(DialogInterface dialog) {
- Button neutralButton = alertDialog.getButton(DialogInterface.BUTTON_NEUTRAL);
- Drawable drawable = app.getIconsCache().getThemedIcon(R.drawable.ic_action_multiselect);
- neutralButton.setCompoundDrawablesWithIntrinsicBounds(drawable, null, null, null);
- }
- });
-
- alertDialog.show();
- }
-
- private String getTitle(List filters) {
-
- if (filters.isEmpty()) return "";
-
- return filters.size() > 1
- ? filters.get(0).getName() + " +" + (filters.size() - 1)
- : filters.get(0).getName();
- }
-
- private void addFilterToList(final ContextMenuAdapter adapter,
- final List list,
- final PoiUIFilter f) {
- list.add(f);
- ContextMenuItem.ItemBuilder builder = new ContextMenuItem.ItemBuilder();
-
- builder.setTitle(f.getName());
-
- if (RenderingIcons.containsBigIcon(f.getIconId())) {
- builder.setIcon(RenderingIcons.getBigIconResourceId(f.getIconId()));
- } else {
- builder.setIcon(R.drawable.mx_user_defined);
- }
-
- builder.setColor(ContextMenuItem.INVALID_ID);
- builder.setSkipPaintingWithoutColor(true);
- adapter.addItem(builder.createItem());
- }
-
- @Override
- public boolean fillParams(View root, MapActivity activity) {
- return !getParams().isEmpty() && (getParams().get(KEY_FILTERS) != null || !getParams().get(KEY_FILTERS).isEmpty());
- }
- }
-
- public static class GPXAction extends QuickAction {
-
- public static final int TYPE = 6;
-
- public static final String KEY_NAME = "name";
- public static final String KEY_DIALOG = "dialog";
- public static final String KEY_CATEGORY_NAME = "category_name";
- public static final String KEY_CATEGORY_COLOR = "category_color";
-
- private GPXAction() {
- super(TYPE);
- }
-
- public GPXAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(final MapActivity activity) {
-
- final LatLon latLon = activity.getMapView()
- .getCurrentRotatedTileBox()
- .getCenterLatLon();
-
- final String title = getParams().get(KEY_NAME);
-
- if (title == null || title.isEmpty()) {
-
- final Dialog progressDialog = new ProgressDialog(activity);
- progressDialog.setCancelable(false);
- progressDialog.setTitle(R.string.search_address);
- progressDialog.show();
-
- GeocodingLookupService.AddressLookupRequest lookupRequest = new GeocodingLookupService.AddressLookupRequest(latLon,
-
- new GeocodingLookupService.OnAddressLookupResult() {
-
- @Override
- public void geocodingDone(String address) {
-
- progressDialog.dismiss();
- activity.getContextMenu().addWptPt(latLon, address,
- getParams().get(KEY_CATEGORY_NAME),
- Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)),
- !Boolean.valueOf(getParams().get(KEY_DIALOG)));
- }
-
- }, null);
-
- activity.getMyApplication().getGeocodingLookupService().lookupAddress(lookupRequest);
-
- } else activity.getContextMenu().addWptPt(latLon, title,
- getParams().get(KEY_CATEGORY_NAME),
- Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)),
- !Boolean.valueOf(getParams().get(KEY_DIALOG)));
- }
-
- @Override
- public void drawUI(final ViewGroup parent, final MapActivity activity) {
-
- final View root = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_add_gpx, parent, false);
-
- parent.addView(root);
-
- AutoCompleteTextViewEx categoryEdit = (AutoCompleteTextViewEx) root.findViewById(R.id.category_edit);
- SwitchCompat showDialog = (SwitchCompat) root.findViewById(R.id.saveButton);
- ImageView categoryImage = (ImageView) root.findViewById(R.id.category_image);
- EditText name = (EditText) root.findViewById(R.id.name_edit);
-
- if (!getParams().isEmpty()) {
-
- showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
- categoryImage.setColorFilter(Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)));
- name.setText(getParams().get(KEY_NAME));
- categoryEdit.setText(getParams().get(KEY_CATEGORY_NAME));
-
- if (getParams().get(KEY_NAME).isEmpty() && Integer.valueOf(getParams().get(KEY_CATEGORY_COLOR)) == 0) {
-
- categoryEdit.setText("");
- categoryImage.setColorFilter(activity.getResources().getColor(R.color.icon_color));
- }
-
- } else {
-
- categoryEdit.setText("");
- categoryImage.setColorFilter(activity.getResources().getColor(R.color.icon_color));
-
- getParams().put(KEY_CATEGORY_NAME, "");
- getParams().put(KEY_CATEGORY_COLOR, "0");
- }
-
- categoryEdit.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(final View view) {
-
- SelectCategoryDialogFragment dialogFragment = SelectCategoryDialogFragment.createInstance("");
-
- dialogFragment.show(
- activity.getSupportFragmentManager(),
- SelectCategoryDialogFragment.TAG);
-
- dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {
- @Override
- public void onCategorySelected(String category, int color) {
-
- fillGroupParams(root, category, color);
- }
- });
- }
- });
-
- SelectCategoryDialogFragment dialogFragment = (SelectCategoryDialogFragment)
- activity.getSupportFragmentManager().findFragmentByTag(SelectCategoryDialogFragment.TAG);
-
- if (dialogFragment != null) {
-
- dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {
- @Override
- public void onCategorySelected(String category, int color) {
-
- fillGroupParams(root, category, color);
- }
- });
-
- } else {
-
- EditCategoryDialogFragment dialog = (EditCategoryDialogFragment)
- activity.getSupportFragmentManager().findFragmentByTag(EditCategoryDialogFragment.TAG);
-
- if (dialog != null) {
-
- dialogFragment.setSelectionListener(new SelectCategoryDialogFragment.CategorySelectionListener() {
- @Override
- public void onCategorySelected(String category, int color) {
-
- fillGroupParams(root, category, color);
- }
- });
- }
- }
- }
-
- @Override
- public boolean fillParams(View root, MapActivity activity) {
-
- getParams().put(KEY_NAME, ((EditText) root.findViewById(R.id.name_edit)).getText().toString());
- getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
-
- return true;
- }
-
- private void fillGroupParams(View root, String name, int color) {
-
- if (color == 0) color = root.getContext().getResources().getColor(R.color.icon_color);
-
- ((AutoCompleteTextViewEx) root.findViewById(R.id.category_edit)).setText(name);
- ((ImageView) root.findViewById(R.id.category_image)).setColorFilter(color);
-
- getParams().put(KEY_CATEGORY_NAME, name);
- getParams().put(KEY_CATEGORY_COLOR, String.valueOf(color));
- }
- }
-
- public static class ParkingAction extends QuickAction {
-
- public static final int TYPE = 7;
-
- private ParkingAction() {
- super(TYPE);
- }
-
- public ParkingAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- ParkingPositionPlugin plugin = OsmandPlugin.getEnabledPlugin(ParkingPositionPlugin.class);
-
- if (plugin != null) {
-
- LatLon latLon = activity.getMapView()
- .getCurrentRotatedTileBox()
- .getCenterLatLon();
-
- plugin.showAddParkingDialog(activity, latLon.getLatitude(), latLon.getLongitude());
- }
- }
-
- @Override
- public void drawUI(ViewGroup parent, MapActivity activity) {
-
- View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_with_text, parent, false);
-
- ((TextView) view.findViewById(R.id.text)).setText(
- R.string.quick_action_add_parking_descr);
-
- parent.addView(view);
- }
- }
-
- public static class TakeAudioNoteAction extends QuickAction {
- public static final int TYPE = 8;
-
- protected TakeAudioNoteAction() {
- super(TYPE);
- }
-
- public TakeAudioNoteAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- LatLon latLon = activity.getMapView()
- .getCurrentRotatedTileBox()
- .getCenterLatLon();
-
- AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
- if (plugin != null)
- plugin.recordAudio(latLon.getLatitude(), latLon.getLongitude(), activity);
- }
-
- @Override
- public void drawUI(ViewGroup parent, MapActivity activity) {
-
- View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_with_text, parent, false);
-
- ((TextView) view.findViewById(R.id.text)).setText(
- R.string.quick_action_take_audio_note_descr);
-
- parent.addView(view);
- }
- }
-
- public static class TakeVideoNoteAction extends QuickAction {
- public static final int TYPE = 9;
-
- protected TakeVideoNoteAction() {
- super(TYPE);
- }
-
- public TakeVideoNoteAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- LatLon latLon = activity.getMapView()
- .getCurrentRotatedTileBox()
- .getCenterLatLon();
-
- AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
- if (plugin != null)
- plugin.recordVideo(latLon.getLatitude(), latLon.getLongitude(), activity);
- }
-
- @Override
- public void drawUI(ViewGroup parent, MapActivity activity) {
-
- View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_with_text, parent, false);
-
- ((TextView) view.findViewById(R.id.text)).setText(
- R.string.quick_action_take_video_note_descr);
-
- parent.addView(view);
- }
- }
-
- public static class TakePhotoNoteAction extends QuickAction {
- public static final int TYPE = 10;
-
- protected TakePhotoNoteAction() {
- super(TYPE);
- }
-
- public TakePhotoNoteAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- LatLon latLon = activity.getMapView()
- .getCurrentRotatedTileBox()
- .getCenterLatLon();
-
- AudioVideoNotesPlugin plugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
- if (plugin != null)
- plugin.takePhoto(latLon.getLatitude(), latLon.getLongitude(), activity, false);
- }
-
- @Override
- public void drawUI(ViewGroup parent, MapActivity activity) {
-
- View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_with_text, parent, false);
-
- ((TextView) view.findViewById(R.id.text)).setText(
- R.string.quick_action_take_photo_note_descr);
-
- parent.addView(view);
- }
- }
-
- public static class NavigationVoiceAction extends QuickAction {
- public static final int TYPE = 11;
-
- protected NavigationVoiceAction() {
- super(TYPE);
- }
-
- public NavigationVoiceAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- boolean voice = activity.getMyApplication().getSettings().VOICE_MUTE.get();
-
- activity.getMyApplication().getSettings().VOICE_MUTE.set(!voice);
- activity.getRoutingHelper().getVoiceRouter().setMute(!voice);
- }
-
- @Override
- public void drawUI(ViewGroup parent, MapActivity activity) {
-
- View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_with_text, parent, false);
-
- ((TextView) view.findViewById(R.id.text)).setText(
- R.string.quick_action_navigation_voice_descr);
-
- parent.addView(view);
- }
-
- @Override
- public String getActionText(OsmandApplication application) {
-
- return application.getSettings().VOICE_MUTE.get()
- ? application.getString(R.string.quick_action_navigation_voice_off)
- : application.getString(R.string.quick_action_navigation_voice_on);
- }
-
- @Override
- public boolean isActionWithSlash(OsmandApplication application) {
-
- return application.getSettings().VOICE_MUTE.get();
- }
- }
-
- public static class AddOSMBugAction extends QuickAction {
-
- public static final int TYPE = 12;
-
- private static final String KEY_MESSAGE = "message";
- private static final String KEY_SHO_DIALOG = "dialog";
-
- protected AddOSMBugAction() {
- super(TYPE);
- }
-
- public AddOSMBugAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(MapActivity activity) {
-
- OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
-
- if (plugin != null) {
-
- LatLon latLon = activity.getMapView()
- .getCurrentRotatedTileBox()
- .getCenterLatLon();
-
- if (getParams().isEmpty()) {
-
- plugin.openOsmNote(activity, latLon.getLatitude(), latLon.getLongitude(), "", true);
-
- } else {
-
- plugin.openOsmNote(activity, latLon.getLatitude(), latLon.getLongitude(),
- getParams().get(KEY_MESSAGE),
- !Boolean.valueOf(getParams().get(KEY_SHO_DIALOG)));
- }
- }
- }
-
- @Override
- public void drawUI(ViewGroup parent, MapActivity activity) {
-
- View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_add_bug, parent, false);
-
- SwitchCompat showDialog = (SwitchCompat) view.findViewById(R.id.dialogSwitch);
- EditText message = (EditText) view.findViewById(R.id.message_edit);
-
- if (!getParams().isEmpty()){
-
- showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_SHO_DIALOG)));
- message.setText(getParams().get(KEY_MESSAGE));
- }
-
- parent.addView(view);
- }
-
- @Override
- public boolean fillParams(View root, MapActivity activity) {
-
- SwitchCompat showDialog = (SwitchCompat) root.findViewById(R.id.dialogSwitch);
- EditText message = (EditText) root.findViewById(R.id.message_edit);
-
- getParams().put(KEY_SHO_DIALOG, String.valueOf(showDialog.isChecked()));
- getParams().put(KEY_MESSAGE, message.getText().toString());
-
- return !(Boolean.valueOf(getParams().get(KEY_SHO_DIALOG)) && getParams().get(KEY_MESSAGE).isEmpty());
- }
- }
-
-
- public static class AddPOIAction extends QuickAction {
- public static final int TYPE = 13;
- public static final String KEY_TAG = "key_tag";
- public static final String KEY_DIALOG = "dialog";
-
- private transient EditText title;
- private transient String prevType = "";
-
- protected AddPOIAction() {
- super(TYPE);
- }
-
- public AddPOIAction(QuickAction quickAction) {
- super(quickAction);
- }
-
- @Override
- public void execute(final MapActivity activity) {
-
- LatLon latLon = activity.getMapView()
- .getCurrentRotatedTileBox()
- .getCenterLatLon();
-
- OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
- if (plugin == null) return;
- Node node = new Node(latLon.getLatitude(), latLon.getLongitude(), -1);
- node.replaceTags(getTagsFromParams());
- EditPoiData editPoiData = new EditPoiData(node, activity.getMyApplication());
- if (Boolean.valueOf(getParams().get(KEY_DIALOG))) {
- Node newNode = editPoiData.getEntity();
- EditPoiDialogFragment editPoiDialogFragment =
- EditPoiDialogFragment.createInstance(newNode, true, getTagsFromParams());
- editPoiDialogFragment.show(activity.getSupportFragmentManager(),
- EditPoiDialogFragment.TAG);
- } else {
- OpenstreetmapUtil mOpenstreetmapUtil;
- if (activity.getMyApplication().getSettings().OFFLINE_EDITION.get()
- || !activity.getMyApplication().getSettings().isInternetConnectionAvailable(true)) {
- mOpenstreetmapUtil = plugin.getPoiModificationLocalUtil();
- } else {
- mOpenstreetmapUtil = plugin.getPoiModificationRemoteUtil();
- }
-
- final boolean offlineEdit = mOpenstreetmapUtil instanceof OpenstreetmapLocalUtil;
- Node newNode = new Node(node.getLatitude(), node.getLongitude(), node.getId());
- OsmPoint.Action action = newNode.getId() < 0 ? OsmPoint.Action.CREATE : OsmPoint.Action.MODIFY;
- for (Map.Entry tag : editPoiData.getTagValues().entrySet()) {
- if (tag.getKey().equals(EditPoiData.POI_TYPE_TAG)) {
- final PoiType poiType = editPoiData.getAllTranslatedSubTypes().get(tag.getValue().trim().toLowerCase());
- if (poiType != null) {
- newNode.putTag(poiType.getOsmTag(), poiType.getOsmValue());
- if (poiType.getOsmTag2() != null) {
- newNode.putTag(poiType.getOsmTag2(), poiType.getOsmValue2());
- }
- } else if (!Algorithms.isEmpty(tag.getValue())) {
- newNode.putTag(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue());
-
- }
- if (offlineEdit && !Algorithms.isEmpty(tag.getValue())) {
- newNode.putTag(tag.getKey(), tag.getValue());
- }
- } else if (!Algorithms.isEmpty(tag.getKey()) && !Algorithms.isEmpty(tag.getValue())) {
- newNode.putTag(tag.getKey(), tag.getValue());
- }
- }
- EditPoiDialogFragment.commitNode(action, newNode, mOpenstreetmapUtil.getEntityInfo(newNode.getId()), "", false,
- new CallbackWithObject() {
-
- @Override
- public boolean processResult(Node result) {
- if (result != null) {
- OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
- if (plugin != null && offlineEdit) {
- List points = plugin.getDBPOI().getOpenstreetmapPoints();
- if (activity instanceof MapActivity && points.size() > 0) {
- OsmPoint point = points.get(points.size() - 1);
- activity.getContextMenu().showOrUpdate(
- new LatLon(point.getLatitude(), point.getLongitude()),
- plugin.getOsmEditsLayer(activity).getObjectName(point), point);
- }
- }
-
- if (activity instanceof MapActivity) {
- activity.getMapView().refreshMap(true);
- }
- } else {
-// OsmEditingPlugin plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
-// mOpenstreetmapUtil = plugin.getPoiModificationLocalUtil();
-// Button saveButton = (Button) view.findViewById(R.id.saveButton);
-// saveButton.setText(mOpenstreetmapUtil instanceof OpenstreetmapRemoteUtil
-// ? R.string.shared_string_upload : R.string.shared_string_save);
- }
-
- return false;
- }
- }, activity, mOpenstreetmapUtil);
-
- }
- }
-
- @Override
- public void setAutoGeneratedTitle(EditText title) {
- this.title = title;
- }
-
- @Override
- public void drawUI(final ViewGroup parent, final MapActivity activity) {
- final View view = LayoutInflater.from(parent.getContext())
- .inflate(R.layout.quick_action_add_poi_layout, parent, false);
-
- final OsmandApplication application = activity.getMyApplication();
- Drawable deleteDrawable = application.getIconsCache().getPaintedIcon(R.drawable.ic_action_remove_dark,
- activity.getResources().getColor(R.color.dash_search_icon_dark));
-
- final LinearLayout editTagsLineaLayout =
- (LinearLayout) view.findViewById(R.id.editTagsList);
-
- final MapPoiTypes poiTypes = application.getPoiTypes();
- final Map allTranslatedNames = poiTypes.getAllTranslatedNames(true);
- final TagAdapterLinearLayoutHack mAdapter = new TagAdapterLinearLayoutHack(editTagsLineaLayout, getTagsFromParams(), deleteDrawable);
- // It is possible to not restart initialization every time, and probably move initialization to appInit
- Map translatedTypes = poiTypes.getAllTranslatedNames(true);
- HashSet tagKeys = new HashSet<>();
- HashSet valueKeys = new HashSet<>();
- for (AbstractPoiType abstractPoiType : translatedTypes.values()) {
- addPoiToStringSet(abstractPoiType, tagKeys, valueKeys);
- }
- addPoiToStringSet(poiTypes.getOtherMapCategory(), tagKeys, valueKeys);
- tagKeys.addAll(EditPoiDialogFragment.BASIC_TAGS);
- mAdapter.setTagData(tagKeys.toArray(new String[tagKeys.size()]));
- mAdapter.setValueData(valueKeys.toArray(new String[valueKeys.size()]));
- Button addTagButton = (Button) view.findViewById(R.id.addTagButton);
- addTagButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- for (int i = 0; i < editTagsLineaLayout.getChildCount(); i++) {
- View item = editTagsLineaLayout.getChildAt(i);
- if (((EditText)item.findViewById(R.id.tagEditText)).getText().toString().isEmpty() &&
- ((EditText)item.findViewById(R.id.valueEditText)).getText().toString().isEmpty())
- return;
- }
- mAdapter.addTagView("", "");
- }
- });
-
- mAdapter.updateViews();
-
- final TextInputLayout poiTypeTextInputLayout = (TextInputLayout) view.findViewById(R.id.poiTypeTextInputLayout);
- final AutoCompleteTextView poiTypeEditText = (AutoCompleteTextView) view.findViewById(R.id.poiTypeEditText);
- final SwitchCompat showDialog = (SwitchCompat) view.findViewById(R.id.saveButton);
-// showDialog.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
-// @Override
-// public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
-// getParams().put(KEY_DIALOG, Boolean.toString(isChecked));
-// }
-// });
- showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
-
- final String text = getTagsFromParams().get(POI_TYPE_TAG);
- poiTypeEditText.addTextChangedListener(new TextWatcher() {
- @Override
- public void beforeTextChanged(CharSequence s, int start, int count, int after) {
- }
-
- @Override
- public void onTextChanged(CharSequence s, int start, int before, int count) {
- }
-
- @Override
- public void afterTextChanged(Editable s) {
- String tp = s.toString();
- putTagIntoParams(POI_TYPE_TAG, tp);
- PoiCategory category = getCategory(allTranslatedNames);
-
- if (category != null) {
- poiTypeTextInputLayout.setHint(category.getTranslation());
- }
-
- String add = application.getString(R.string.shared_string_add);
-
- if (title != null) {
-
- if (prevType.equals(title.getText().toString())
- || title.getText().toString().equals(activity.getString(getNameRes()))
- || title.getText().toString().equals((add + " "))) {
-
- if (!tp.isEmpty()) {
-
- title.setText(add + " " + tp);
- prevType = title.getText().toString();
- }
- }
- }
- }
- });
- poiTypeEditText.setText(text != null ? text : "");
- poiTypeEditText.setOnTouchListener(new View.OnTouchListener() {
- @Override
- public boolean onTouch(final View v, MotionEvent event) {
- final EditText editText = (EditText) v;
- final int DRAWABLE_RIGHT = 2;
- if (event.getAction() == MotionEvent.ACTION_UP) {
- if (event.getX() >= (editText.getRight()
- - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width()
- - editText.getPaddingRight())) {
- PoiCategory category = getCategory(allTranslatedNames);
- PoiCategory tempPoiCategory= (category != null) ? category : poiTypes.getOtherPoiCategory();
- PoiSubTypeDialogFragment f =
- PoiSubTypeDialogFragment.createInstance(tempPoiCategory);
- f.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() {
- @Override
- public void select(String category) {
- poiTypeEditText.setText(category);
- }
- });
-
- CreateEditActionDialog parentFragment = (CreateEditActionDialog) activity.getSupportFragmentManager().findFragmentByTag(CreateEditActionDialog.TAG);
- f.show(activity.getSupportFragmentManager(), "PoiSubTypeDialogFragment");
-
- return true;
- }
- }
- return false;
- }
- });
-
- setUpAdapterForPoiTypeEditText(activity, allTranslatedNames, poiTypeEditText);
-
- ImageButton onlineDocumentationButton =
- (ImageButton) view.findViewById(R.id.onlineDocumentationButton);
- onlineDocumentationButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View v) {
- activity.startActivity(new Intent(Intent.ACTION_VIEW,
- Uri.parse("https://wiki.openstreetmap.org/wiki/Map_Features")));
- }
- });
-
- boolean isLightTheme = activity.getMyApplication().getSettings().OSMAND_THEME.get() == OsmandSettings.OSMAND_LIGHT_THEME;
- final int colorId = isLightTheme ? R.color.inactive_item_orange : R.color.dash_search_icon_dark;
- final int color = activity.getResources().getColor(colorId);
- onlineDocumentationButton.setImageDrawable(activity.getMyApplication().getIconsCache().getPaintedIcon(R.drawable.ic_action_help, color));
-// poiTypeEditText.setCompoundDrawables(null, null, activity.getMyApplication().getIconsCache().getPaintedIcon(R.drawable.ic_action_arrow_drop_down, color), null);
-
-// Button addTypeButton = (Button) view.findViewById(R.id.addTypeButton);
-// addTypeButton.setOnClickListener(new View.OnClickListener() {
-// @Override
-// public void onClick(View v) {
-// PoiSubTypeDialogFragment f = PoiSubTypeDialogFragment.createInstance(poiTypes.getOtherPoiCategory());
-// f.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() {
-// @Override
-// public void select(String category) {
-// putTagIntoParams(POI_TYPE_TAG, category);
-// }
-// });
-//
-// CreateEditActionDialog parentFragment = (CreateEditActionDialog) activity.getSupportFragmentManager().findFragmentByTag(CreateEditActionDialog.TAG);
-// f.show(parentFragment.getChildFragmentManager(), "PoiSubTypeDialogFragment");
-// }
-// });
-
- parent.addView(view);
- }
-
- private void setUpAdapterForPoiTypeEditText(final MapActivity activity, final Map allTranslatedNames, final AutoCompleteTextView poiTypeEditText) {
- final Map subCategories = new LinkedHashMap<>();
-// PoiCategory ct = editPoiData.getPoiCategory();
-// if (ct != null) {
-// for (PoiType s : ct.getPoiTypes()) {
-// if (!s.isReference() && !s.isNotEditableOsm() && s.getBaseLangType() == null) {
-// addMapEntryAdapter(subCategories, s.getTranslation(), s);
-// if(!s.getKeyName().contains("osmand")) {
-// addMapEntryAdapter(subCategories, s.getKeyName().replace('_', ' '), s);
-// }
-// }
-// }
-// }
- for (Entry s : allTranslatedNames.entrySet()) {
- addMapEntryAdapter(subCategories, s.getKey(), s.getValue());
- }
- final ArrayAdapter