Merge branch 'master' of ssh://github.com/osmandapp/Osmand into TrackerLiveTrack
This commit is contained in:
commit
af65e6d5f7
9 changed files with 8198 additions and 71 deletions
|
@ -853,8 +853,8 @@ public class SearchUICore {
|
||||||
boolean topVisible1 = ObjectType.isTopVisible(o1.objectType);
|
boolean topVisible1 = ObjectType.isTopVisible(o1.objectType);
|
||||||
boolean topVisible2 = ObjectType.isTopVisible(o2.objectType);
|
boolean topVisible2 = ObjectType.isTopVisible(o2.objectType);
|
||||||
if ((!topVisible1 && !topVisible2) || (topVisible1 && topVisible2)) {
|
if ((!topVisible1 && !topVisible2) || (topVisible1 && topVisible2)) {
|
||||||
if (o1.isUnknownPhraseMatches() != o2.isUnknownPhraseMatches()) {
|
if (o1.getUnknownPhraseMatchWeight() != o2.getUnknownPhraseMatchWeight()) {
|
||||||
return o1.isUnknownPhraseMatches() ? -1 : 1;
|
return -Double.compare(o1.getUnknownPhraseMatchWeight(), o2.getUnknownPhraseMatchWeight());
|
||||||
} else if (o1.getFoundWordCount() != o2.getFoundWordCount()) {
|
} else if (o1.getFoundWordCount() != o2.getFoundWordCount()) {
|
||||||
return -Algorithms.compare(o1.getFoundWordCount(), o2.getFoundWordCount());
|
return -Algorithms.compare(o1.getFoundWordCount(), o2.getFoundWordCount());
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,4 +44,28 @@ public enum ObjectType {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static double getTypeWeight(ObjectType t) {
|
||||||
|
if (t == null) {
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
switch (t) {
|
||||||
|
case CITY:
|
||||||
|
return 1.0;
|
||||||
|
case VILLAGE:
|
||||||
|
return 1.0;
|
||||||
|
case POSTCODE:
|
||||||
|
return 1.0;
|
||||||
|
case STREET:
|
||||||
|
return 2.0;
|
||||||
|
case HOUSE:
|
||||||
|
return 3.0;
|
||||||
|
case STREET_INTERSECTION:
|
||||||
|
return 3.0;
|
||||||
|
case POI:
|
||||||
|
return 2.0;
|
||||||
|
default:
|
||||||
|
return 1.0;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
package net.osmand.search.core;
|
package net.osmand.search.core;
|
||||||
|
|
||||||
import net.osmand.binary.BinaryMapIndexReader;
|
import net.osmand.binary.BinaryMapIndexReader;
|
||||||
import net.osmand.data.Amenity;
|
|
||||||
import net.osmand.data.City;
|
import net.osmand.data.City;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.Street;
|
import net.osmand.data.Street;
|
||||||
|
@ -30,10 +29,18 @@ public class SearchResult {
|
||||||
public boolean firstUnknownWordMatches = true;
|
public boolean firstUnknownWordMatches = true;
|
||||||
public boolean unknownPhraseMatches = false;
|
public boolean unknownPhraseMatches = false;
|
||||||
|
|
||||||
public boolean isUnknownPhraseMatches() {
|
public double getUnknownPhraseMatchWeight() {
|
||||||
boolean res = unknownPhraseMatches;
|
double res = 0;
|
||||||
if (!res && parentSearchResult != null) {
|
boolean isHouse = objectType == ObjectType.HOUSE;
|
||||||
res = parentSearchResult.unknownPhraseMatches;
|
if (unknownPhraseMatches) {
|
||||||
|
res = ObjectType.getTypeWeight(objectType);
|
||||||
|
}
|
||||||
|
if (res == 0 && parentSearchResult != null && parentSearchResult.unknownPhraseMatches) {
|
||||||
|
if (isHouse && parentSearchResult.objectType == ObjectType.STREET) {
|
||||||
|
res = ObjectType.getTypeWeight(ObjectType.HOUSE);
|
||||||
|
} else {
|
||||||
|
res = ObjectType.getTypeWeight(parentSearchResult.objectType);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
8100
OsmAnd-java/src/test/resources/search/spring_street.json
Normal file
8100
OsmAnd-java/src/test/resources/search/spring_street.json
Normal file
File diff suppressed because it is too large
Load diff
|
@ -32,8 +32,7 @@
|
||||||
"Carrer Santa Clara, Castelló d'Empúries",
|
"Carrer Santa Clara, Castelló d'Empúries",
|
||||||
"Carrer de Santa Clara, Vilafranca del Penedès",
|
"Carrer de Santa Clara, Vilafranca del Penedès",
|
||||||
"Carrer de Santa Clara, Castelló d'Empúries",
|
"Carrer de Santa Clara, Castelló d'Empúries",
|
||||||
"Carrer Clara Campoamor, Santa Coloma de Gramenet",
|
"Carrer Clara Campoamor, Santa Coloma de Gramenet"
|
||||||
"Santa Clara"
|
|
||||||
],
|
],
|
||||||
"amenities": [
|
"amenities": [
|
||||||
{
|
{
|
||||||
|
|
|
@ -3,12 +3,10 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
||||||
import android.graphics.drawable.Drawable;
|
import android.graphics.drawable.Drawable;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.support.v4.content.ContextCompat;
|
import android.support.v4.content.ContextCompat;
|
||||||
import android.util.Log;
|
|
||||||
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.data.LatLon;
|
import net.osmand.data.LatLon;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.GPXUtilities.WptPt;
|
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper;
|
||||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.MapMarkersHelper;
|
import net.osmand.plus.MapMarkersHelper;
|
||||||
|
@ -18,30 +16,26 @@ import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.WptPtMenuBuilder;
|
|
||||||
import net.osmand.plus.wikivoyage.menu.WikivoyageWptPtMenuBuilder;
|
import net.osmand.plus.wikivoyage.menu.WikivoyageWptPtMenuBuilder;
|
||||||
import net.osmand.plus.wikivoyage.menu.WikivoyageWptPtMenuController;
|
import net.osmand.plus.wikivoyage.menu.WikivoyageWptPtMenuController;
|
||||||
import net.osmand.util.Algorithms;
|
import net.osmand.util.Algorithms;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class WptPtMenuController extends MenuController {
|
public class WptPtMenuController extends MenuController {
|
||||||
|
|
||||||
private WptPt wpt;
|
private WptPt wpt;
|
||||||
private MapMarker mapMarker;
|
private MapMarker mapMarker;
|
||||||
private MapActivity mapActivity;
|
|
||||||
|
|
||||||
public WptPtMenuController(@NonNull MenuBuilder menuBuilder, @NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull final WptPt wpt) {
|
public WptPtMenuController(@NonNull MenuBuilder menuBuilder, @NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull final WptPt wpt) {
|
||||||
super(menuBuilder, pointDescription, mapActivity);
|
super(menuBuilder, pointDescription, mapActivity);
|
||||||
this.wpt = wpt;
|
this.wpt = wpt;
|
||||||
this.mapActivity = mapActivity;
|
MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||||
|
|
||||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
|
||||||
mapMarker = markersHelper.getMapMarker(wpt);
|
mapMarker = markersHelper.getMapMarker(wpt);
|
||||||
if (mapMarker == null) {
|
if (mapMarker == null) {
|
||||||
mapMarker = markersHelper.getMapMarker(new LatLon(wpt.lat, wpt.lon));
|
mapMarker = markersHelper.getMapMarker(new LatLon(wpt.lat, wpt.lon));
|
||||||
} else {
|
}
|
||||||
|
if (mapMarker != null) {
|
||||||
MapMarkerMenuController markerMenuController =
|
MapMarkerMenuController markerMenuController =
|
||||||
new MapMarkerMenuController(mapActivity, mapMarker.getPointDescription(mapActivity), mapMarker);
|
new MapMarkerMenuController(mapActivity, mapMarker.getPointDescription(mapActivity), mapMarker);
|
||||||
leftTitleButtonController = markerMenuController.getLeftTitleButtonController();
|
leftTitleButtonController = markerMenuController.getLeftTitleButtonController();
|
||||||
|
@ -145,16 +139,12 @@ public class WptPtMenuController extends MenuController {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static WptPtMenuController getInstance(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull final WptPt wpt) {
|
public static WptPtMenuController getInstance(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull final WptPt wpt) {
|
||||||
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFile(wpt);
|
WptPtMenuController controller = WikivoyageWptPtMenuController.getInstance(mapActivity, pointDescription, wpt);
|
||||||
GPXUtilities.GPXFile gpxFile = selectedGpxFile != null ? selectedGpxFile.getGpxFile() : null;
|
if (controller == null) {
|
||||||
GPXUtilities.Metadata metadata = gpxFile != null ? gpxFile.metadata : null;
|
controller = new WptPtMenuController(new WikivoyageWptPtMenuBuilder(mapActivity, wpt), mapActivity, pointDescription, wpt);
|
||||||
Map<String, String> extensions = metadata != null ? metadata.getExtensionsToRead() : null;
|
|
||||||
String metadataDesc = extensions != null ? metadata.getExtensionsToRead().get("desc") : null;
|
|
||||||
if (metadataDesc != null && metadataDesc.contains("wikivoyage.org/")) {
|
|
||||||
return new WikivoyageWptPtMenuController(new WikivoyageWptPtMenuBuilder(mapActivity, wpt), mapActivity, pointDescription, wpt, gpxFile);
|
|
||||||
}
|
}
|
||||||
return new WptPtMenuController(new WptPtMenuBuilder(mapActivity, wpt), mapActivity, pointDescription, wpt);
|
return controller;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -395,7 +395,7 @@ public class GPXLayer extends OsmandMapLayer implements ContextMenuLayer.IContex
|
||||||
} else {
|
} else {
|
||||||
color = getPointColor(o, fileColor);
|
color = getPointColor(o, fileColor);
|
||||||
}
|
}
|
||||||
paintIcon.setColorFilter(new PorterDuffColorFilter(color, PorterDuff.Mode.MULTIPLY));
|
paintIcon.setColorFilter(new PorterDuffColorFilter(color | 0xff000000, PorterDuff.Mode.MULTIPLY));
|
||||||
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
|
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
|
||||||
smallObjectsLatLon.add(new LatLon(o.lat, o.lon));
|
smallObjectsLatLon.add(new LatLon(o.lat, o.lon));
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -3,7 +3,7 @@ package net.osmand.plus.wikivoyage.menu;
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.builders.WptPtMenuBuilder;
|
import net.osmand.plus.mapcontextmenu.builders.WptPtMenuBuilder;
|
||||||
|
@ -12,35 +12,27 @@ import net.osmand.util.Algorithms;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
public class WikivoyageWptPtMenuBuilder extends WptPtMenuBuilder {
|
public class WikivoyageWptPtMenuBuilder extends WptPtMenuBuilder {
|
||||||
final String KEY_PHONE = "Phone: ";
|
private final static String KEY_PHONE = "Phone: ";
|
||||||
final String KEY_EMAIL = "Email: ";
|
private final static String KEY_EMAIL = "Email: ";
|
||||||
final String KEY_WORKING_HOURS = "Working hours: ";
|
private final static String KEY_WORKING_HOURS = "Working hours: ";
|
||||||
final String KEY_PRICE = "Price: ";
|
private final static String KEY_PRICE = "Price: ";
|
||||||
final String KEY_DIRECTIONS = "Directions: ";
|
private final static String KEY_DIRECTIONS = "Directions: ";
|
||||||
final String KEY_OTHER_DESCRIPTION = "Other description";
|
private final static String KEY_DESCRIPTION = "Description";
|
||||||
|
|
||||||
public WikivoyageWptPtMenuBuilder(@NonNull MapActivity mapActivity, @NonNull GPXUtilities.WptPt wpt) {
|
public WikivoyageWptPtMenuBuilder(@NonNull MapActivity mapActivity, @NonNull WptPt wpt) {
|
||||||
super(mapActivity, wpt);
|
super(mapActivity, wpt);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void prepareDescription(final GPXUtilities.WptPt wpt, View view) {
|
protected void prepareDescription(final WptPt wpt, View view) {
|
||||||
String description = wpt.desc;
|
HashMap<String, String> descTokens = getDescriptionTokens(wpt.desc, KEY_PHONE, KEY_EMAIL, KEY_WORKING_HOURS, KEY_PRICE, KEY_DIRECTIONS);
|
||||||
|
|
||||||
if (!description.contains("\n")) {
|
|
||||||
super.prepareDescription(wpt, view);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
HashMap<String, String> descTokens = getDescriptionTokens(description, KEY_PHONE, KEY_EMAIL, KEY_WORKING_HOURS, KEY_PRICE, KEY_DIRECTIONS);
|
|
||||||
|
|
||||||
String phones = descTokens.get(KEY_PHONE);
|
String phones = descTokens.get(KEY_PHONE);
|
||||||
String emails = descTokens.get(KEY_EMAIL);
|
String emails = descTokens.get(KEY_EMAIL);
|
||||||
String workingHours = descTokens.get(KEY_WORKING_HOURS);
|
String workingHours = descTokens.get(KEY_WORKING_HOURS);
|
||||||
String price = descTokens.get(KEY_PRICE);
|
String price = descTokens.get(KEY_PRICE);
|
||||||
String direction = descTokens.get(KEY_DIRECTIONS);
|
String direction = descTokens.get(KEY_DIRECTIONS);
|
||||||
|
|
||||||
final String desc = descTokens.get(KEY_OTHER_DESCRIPTION);
|
final String desc = descTokens.get(KEY_DESCRIPTION);
|
||||||
if (!Algorithms.isEmpty(desc)) {
|
if (!Algorithms.isEmpty(desc)) {
|
||||||
buildRow(view, R.drawable.ic_action_note_dark, null, desc, 0, false, null, true, 10, false, null, false);
|
buildRow(view, R.drawable.ic_action_note_dark, null, desc, 0, false, null, true, 10, false, null, false);
|
||||||
}
|
}
|
||||||
|
@ -89,8 +81,8 @@ public class WikivoyageWptPtMenuBuilder extends WptPtMenuBuilder {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!matched) {
|
if (!matched) {
|
||||||
String s = mTokens.get(KEY_OTHER_DESCRIPTION);
|
String s = mTokens.get(KEY_DESCRIPTION);
|
||||||
mTokens.put(KEY_OTHER_DESCRIPTION, s != null ? s + "\n" + token : token);
|
mTokens.put(KEY_DESCRIPTION, s != null ? s + "\n" + token : token);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mTokens;
|
return mTokens;
|
||||||
|
|
|
@ -1,41 +1,56 @@
|
||||||
package net.osmand.plus.wikivoyage.menu;
|
package net.osmand.plus.wikivoyage.menu;
|
||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
|
||||||
import net.osmand.GPXUtilities;
|
import net.osmand.GPXUtilities.GPXFile;
|
||||||
|
import net.osmand.GPXUtilities.Metadata;
|
||||||
|
import net.osmand.GPXUtilities.WptPt;
|
||||||
import net.osmand.data.PointDescription;
|
import net.osmand.data.PointDescription;
|
||||||
import net.osmand.plus.GpxSelectionHelper;
|
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||||
import net.osmand.plus.OsmandApplication;
|
|
||||||
import net.osmand.plus.R;
|
import net.osmand.plus.R;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
|
||||||
import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController;
|
import net.osmand.plus.mapcontextmenu.controllers.WptPtMenuController;
|
||||||
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
import net.osmand.plus.wikivoyage.article.WikivoyageArticleDialogFragment;
|
||||||
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
import net.osmand.plus.wikivoyage.data.TravelArticle;
|
||||||
|
|
||||||
public class WikivoyageWptPtMenuController extends WptPtMenuController {
|
public class WikivoyageWptPtMenuController extends WptPtMenuController {
|
||||||
public WikivoyageWptPtMenuController(@NonNull MenuBuilder menuBuilder, @NonNull final MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull GPXUtilities.WptPt wpt, GPXUtilities.GPXFile gpxFile) {
|
|
||||||
super(menuBuilder, mapActivity, pointDescription, wpt);
|
private WikivoyageWptPtMenuController(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull WptPt wpt, @NonNull TravelArticle article) {
|
||||||
GPXUtilities.Metadata metadata = gpxFile != null ? gpxFile.metadata : null;
|
super(new WikivoyageWptPtMenuBuilder(mapActivity, wpt), mapActivity, pointDescription, wpt);
|
||||||
final TravelArticle article = metadata != null ? getTravelArticle(metadata) : null;
|
final long tripId = article.getTripId();
|
||||||
if (article != null) {
|
final String lang = article.getLang();
|
||||||
leftTitleButtonController = new TitleButtonController() {
|
leftTitleButtonController = new TitleButtonController() {
|
||||||
@Override
|
@Override
|
||||||
public void buttonPressed() {
|
public void buttonPressed() {
|
||||||
WikivoyageArticleDialogFragment.showInstance(mapActivity.getMyApplication(), mapActivity.getSupportFragmentManager(), article.getTripId(), article.getLang());
|
MapActivity mapActivity = getMapActivity();
|
||||||
|
if (mapActivity != null) {
|
||||||
|
WikivoyageArticleDialogFragment.showInstance(mapActivity.getMyApplication(),
|
||||||
|
mapActivity.getSupportFragmentManager(), tripId, lang);
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
leftTitleButtonController.caption = mapActivity.getString(R.string.context_menu_read_article);
|
};
|
||||||
leftTitleButtonController.leftIconId = R.drawable.ic_action_read_text;
|
leftTitleButtonController.caption = mapActivity.getString(R.string.context_menu_read_article);
|
||||||
}
|
leftTitleButtonController.leftIconId = R.drawable.ic_action_read_text;
|
||||||
}
|
}
|
||||||
|
|
||||||
private TravelArticle getTravelArticle(@NonNull GPXUtilities.Metadata metadata) {
|
private static TravelArticle getTravelArticle(@NonNull MapActivity mapActivity, @NonNull WptPt wpt) {
|
||||||
String title = metadata.getArticleTitle();
|
SelectedGpxFile selectedGpxFile = mapActivity.getMyApplication().getSelectedGpxHelper().getSelectedGPXFile(wpt);
|
||||||
String lang = metadata.getArticleLang();
|
GPXFile gpxFile = selectedGpxFile != null ? selectedGpxFile.getGpxFile() : null;
|
||||||
|
Metadata metadata = gpxFile != null ? gpxFile.metadata : null;
|
||||||
|
String title = metadata != null ? metadata.getArticleTitle() : null;
|
||||||
|
String lang = metadata != null ? metadata.getArticleLang() : null;
|
||||||
if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(lang)) {
|
if (!TextUtils.isEmpty(title) && !TextUtils.isEmpty(lang)) {
|
||||||
return getMapActivity().getMyApplication().getTravelDbHelper().getArticle(title, lang);
|
return mapActivity.getMyApplication().getTravelDbHelper().getArticle(title, lang);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WptPtMenuController getInstance(@NonNull MapActivity mapActivity, @NonNull PointDescription pointDescription, @NonNull WptPt wpt) {
|
||||||
|
TravelArticle travelArticle = getTravelArticle(mapActivity, wpt);
|
||||||
|
if (travelArticle != null) {
|
||||||
|
return new WikivoyageWptPtMenuController(mapActivity, pointDescription, wpt, travelArticle);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue