Compare commits
60 commits
Author | SHA1 | Date | |
---|---|---|---|
|
9c6b43a373 | ||
|
6b95c84b73 | ||
|
28fd5b1400 | ||
|
76736312db | ||
|
6fc0ce85e7 | ||
|
2227b9e963 | ||
|
865ad4ca2a | ||
|
53434d7527 | ||
|
5bc6cb9ad9 | ||
|
52d92ae996 | ||
|
c60d1bac4a | ||
|
b15aca3570 | ||
|
8059e46cc2 | ||
|
f2948143c0 | ||
|
6c39e33516 | ||
|
1221a2785a | ||
|
2daa1a7c47 | ||
|
9d5b24afbd | ||
|
67c941eb43 | ||
|
11abd18dcb | ||
|
efeb40bad8 | ||
|
8b39eebb77 | ||
|
12403b4306 | ||
|
182fb80ef2 | ||
|
a66486f726 | ||
|
1e57d9ec8d | ||
|
e71266bbf6 | ||
|
6f803ea8b9 | ||
|
2c8d7d0f74 | ||
|
dc3f3db408 | ||
|
9c42b6d387 | ||
|
22a690c3ca | ||
|
e1c8d3b336 | ||
|
af7031bfb6 | ||
|
9705573d12 | ||
|
41fffd4458 | ||
|
169679a86b | ||
|
5c00a7f8c9 | ||
|
db791779d5 | ||
|
4b62beaeb3 | ||
|
ea15865333 | ||
|
ccaa339a4a | ||
|
e38b2424df | ||
|
050aadf201 | ||
|
a7311bee9e | ||
|
71055fe315 | ||
|
5904101789 | ||
|
ef966b5e6d | ||
|
9569b9e73f | ||
|
3e9fe5c3ae | ||
|
f7aa37a235 | ||
|
a06b98bc4b | ||
|
9bbe2ed141 | ||
|
e35edc2b90 | ||
|
1b0bd7d774 | ||
|
6645a7c307 | ||
|
7e1d427373 | ||
|
d97b0a052a | ||
|
f78bb712f8 | ||
|
5f0add31a3 |
90 changed files with 1522 additions and 603 deletions
|
@ -73,9 +73,9 @@ public class BinaryInspector {
|
|||
if ("test".equals(args[0])) {
|
||||
in.inspector(new String[] {
|
||||
// "-vpoi",
|
||||
"-vmap", "-vmapobjects", // "-vmapcoordinates",
|
||||
// "-vmap", "-vmapobjects", // "-vmapcoordinates",
|
||||
// "-vrouting",
|
||||
// "-vtransport",
|
||||
"-vtransport",
|
||||
// "-vaddress", "-vcities","-vstreetgroups",
|
||||
// "-vstreets", "-vbuildings", "-vintersections",
|
||||
// "-lang=ru",
|
||||
|
|
|
@ -184,7 +184,7 @@ public class Amenity extends MapObject {
|
|||
}
|
||||
String enName = getAdditionalInfo(tag + ":en");
|
||||
if (!Algorithms.isEmpty(enName)) {
|
||||
return enName;
|
||||
return "en";
|
||||
}
|
||||
int maxLen = 0;
|
||||
String lng = defLang;
|
||||
|
|
|
@ -1,8 +1,18 @@
|
|||
package net.osmand.map;
|
||||
|
||||
|
||||
import gnu.trove.iterator.TIntObjectIterator;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.binary.BinaryMapIndexReader.MapIndex;
|
||||
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapAlgorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
|
@ -21,19 +31,8 @@ import java.util.Map;
|
|||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.binary.BinaryMapIndexReader.MapIndex;
|
||||
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.util.Algorithms;
|
||||
import net.osmand.util.MapAlgorithms;
|
||||
import net.osmand.util.MapUtils;
|
||||
import gnu.trove.iterator.TIntObjectIterator;
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class OsmandRegions {
|
||||
|
||||
|
@ -385,7 +384,11 @@ public class OsmandRegions {
|
|||
}
|
||||
|
||||
public WorldRegion getRegionDataByDownloadName(String downloadName) {
|
||||
return getRegionData(downloadNamesToFullNames.get(downloadName.toLowerCase()));
|
||||
if (downloadName == null) {
|
||||
return null;
|
||||
} else {
|
||||
return getRegionData(downloadNamesToFullNames.get(downloadName.toLowerCase()));
|
||||
}
|
||||
}
|
||||
|
||||
public String getDownloadName(BinaryMapDataObject o) {
|
||||
|
@ -686,4 +689,53 @@ public class OsmandRegions {
|
|||
}
|
||||
}
|
||||
|
||||
public BinaryMapDataObject findBinaryMapDataObject(LatLon latLon) {
|
||||
int point31x = MapUtils.get31TileNumberX(latLon.getLongitude());
|
||||
int point31y = MapUtils.get31TileNumberY(latLon.getLatitude());
|
||||
|
||||
BinaryMapDataObject res = null;
|
||||
List<BinaryMapDataObject> mapDataObjects = null;
|
||||
try {
|
||||
mapDataObjects = queryBbox(point31x, point31x, point31y, point31y);
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
if (mapDataObjects != null) {
|
||||
Iterator<BinaryMapDataObject> it = mapDataObjects.iterator();
|
||||
while (it.hasNext()) {
|
||||
BinaryMapDataObject o = it.next();
|
||||
if (o.getTypes() != null) {
|
||||
boolean isRegion = true;
|
||||
for (int i = 0; i < o.getTypes().length; i++) {
|
||||
TagValuePair tp = o.getMapIndex().decodeType(o.getTypes()[i]);
|
||||
if ("boundary".equals(tp.value)) {
|
||||
isRegion = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
WorldRegion downloadRegion = getRegionData(getFullName(o));
|
||||
if (!isRegion
|
||||
|| downloadRegion == null
|
||||
|| !downloadRegion.isRegionMapDownload()
|
||||
|| !contain(o, point31x, point31y)) {
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
double smallestArea = -1;
|
||||
for (BinaryMapDataObject o : mapDataObjects) {
|
||||
double area = OsmandRegions.getArea(o);
|
||||
if (smallestArea == -1) {
|
||||
smallestArea = area;
|
||||
res = o;
|
||||
} else if (area < smallestArea) {
|
||||
smallestArea = area;
|
||||
res = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -20,6 +20,7 @@ import net.osmand.binary.BinaryMapIndexReader;
|
|||
import net.osmand.binary.BinaryMapRouteReaderAdapter.RouteTypeRule;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.osm.MapRenderingTypes;
|
||||
import net.osmand.router.BinaryRoutePlanner.FinalRouteSegment;
|
||||
import net.osmand.router.BinaryRoutePlanner.RouteSegment;
|
||||
import net.osmand.router.RoutePlannerFrontEnd.RouteCalculationMode;
|
||||
|
@ -1066,6 +1067,17 @@ public class RouteResultPreparation {
|
|||
RoadSplitStructure rs = new RoadSplitStructure();
|
||||
int speakPriority = Math.max(highwaySpeakPriority(prevSegm.getObject().getHighway()), highwaySpeakPriority(currentSegm.getObject().getHighway()));
|
||||
for (RouteSegmentResult attached : attachedRoutes) {
|
||||
boolean restricted = false;
|
||||
for(int k = 0; k < prevSegm.getObject().getRestrictionLength(); k++) {
|
||||
if(prevSegm.getObject().getRestrictionId(k) == attached.getObject().getId() &&
|
||||
prevSegm.getObject().getRestrictionType(k) <= MapRenderingTypes.RESTRICTION_NO_STRAIGHT_ON) {
|
||||
restricted = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(restricted) {
|
||||
continue;
|
||||
}
|
||||
double ex = MapUtils.degreesDiff(attached.getBearingBegin(), currentSegm.getBearingBegin());
|
||||
double mpi = Math.abs(MapUtils.degreesDiff(prevSegm.getBearingEnd(), attached.getBearingBegin()));
|
||||
int rsSpeakPriority = highwaySpeakPriority(attached.getObject().getHighway());
|
||||
|
|
|
@ -7,6 +7,7 @@ import net.osmand.ResultMatcher;
|
|||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.search.core.CustomSearchPoiFilter;
|
||||
import net.osmand.search.core.ObjectType;
|
||||
|
@ -220,6 +221,8 @@ public class SearchUICore {
|
|||
}
|
||||
return MapUtils.getDistance(r1.location, r2.location) < similarityRadius;
|
||||
}
|
||||
} else if (r1.object != null && r2.object != null) {
|
||||
return r1.object == r2.object;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,7 @@
|
|||
package net.osmand.search.core;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import com.jwetherell.openmap.common.LatLonPoint;
|
||||
import com.jwetherell.openmap.common.UTMPoint;
|
||||
|
||||
import net.osmand.CollatorStringMatcher.StringMatcherMode;
|
||||
import net.osmand.ResultMatcher;
|
||||
|
@ -44,8 +31,20 @@ import net.osmand.util.GeoPointParserUtil;
|
|||
import net.osmand.util.GeoPointParserUtil.GeoParsedPoint;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import com.jwetherell.openmap.common.LatLonPoint;
|
||||
import com.jwetherell.openmap.common.UTMPoint;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
|
||||
public class SearchCoreFactory {
|
||||
|
@ -53,30 +52,30 @@ public class SearchCoreFactory {
|
|||
public static final int MAX_DEFAULT_SEARCH_RADIUS = 7;
|
||||
|
||||
//////////////// CONSTANTS //////////
|
||||
public static final int SEARCH_REGION_API_PRIORITY = 3;
|
||||
public static final int SEARCH_REGION_OBJECT_PRIORITY = 10;
|
||||
public static final int SEARCH_REGION_API_PRIORITY = 300;
|
||||
public static final int SEARCH_REGION_OBJECT_PRIORITY = 1000;
|
||||
|
||||
// context less
|
||||
public static final int SEARCH_LOCATION_PRIORITY = 0;
|
||||
public static final int SEARCH_AMENITY_TYPE_PRIORITY = 1;
|
||||
public static final int SEARCH_AMENITY_TYPE_API_PRIORITY = 1;
|
||||
public static final int SEARCH_AMENITY_TYPE_PRIORITY = 100;
|
||||
public static final int SEARCH_AMENITY_TYPE_API_PRIORITY = 100;
|
||||
|
||||
// context
|
||||
public static final int SEARCH_STREET_BY_CITY_PRIORITY = 2;
|
||||
public static final int SEARCH_BUILDING_BY_CITY_PRIORITY = 3;
|
||||
public static final int SEARCH_BUILDING_BY_STREET_PRIORITY = 1;
|
||||
public static final int SEARCH_AMENITY_BY_TYPE_PRIORITY = 3;
|
||||
public static final int SEARCH_STREET_BY_CITY_PRIORITY = 200;
|
||||
public static final int SEARCH_BUILDING_BY_CITY_PRIORITY = 300;
|
||||
public static final int SEARCH_BUILDING_BY_STREET_PRIORITY = 100;
|
||||
public static final int SEARCH_AMENITY_BY_TYPE_PRIORITY = 300;
|
||||
|
||||
// context less (slow)
|
||||
public static final int SEARCH_ADDRESS_BY_NAME_API_PRIORITY = 5;
|
||||
public static final int SEARCH_ADDRESS_BY_NAME_API_PRIORITY_RADIUS2 = 5;
|
||||
public static final int SEARCH_ADDRESS_BY_NAME_PRIORITY = 5;
|
||||
public static final int SEARCH_ADDRESS_BY_NAME_PRIORITY_RADIUS2 = 5;
|
||||
public static final int SEARCH_ADDRESS_BY_NAME_API_PRIORITY = 500;
|
||||
public static final int SEARCH_ADDRESS_BY_NAME_API_PRIORITY_RADIUS2 = 500;
|
||||
public static final int SEARCH_ADDRESS_BY_NAME_PRIORITY = 500;
|
||||
public static final int SEARCH_ADDRESS_BY_NAME_PRIORITY_RADIUS2 = 500;
|
||||
|
||||
// context less (slower)
|
||||
public static final int SEARCH_AMENITY_BY_NAME_PRIORITY = 7;
|
||||
public static final int SEARCH_AMENITY_BY_NAME_API_PRIORITY_IF_POI_TYPE = 7;
|
||||
public static final int SEARCH_AMENITY_BY_NAME_API_PRIORITY_IF_3_CHAR = 7;
|
||||
public static final int SEARCH_AMENITY_BY_NAME_PRIORITY = 700;
|
||||
public static final int SEARCH_AMENITY_BY_NAME_API_PRIORITY_IF_POI_TYPE = 700;
|
||||
public static final int SEARCH_AMENITY_BY_NAME_API_PRIORITY_IF_3_CHAR = 700;
|
||||
protected static final double SEARCH_AMENITY_BY_NAME_CITY_PRIORITY_DISTANCE = 0.001;
|
||||
protected static final double SEARCH_AMENITY_BY_NAME_TOWN_PRIORITY_DISTANCE = 0.005;
|
||||
|
||||
|
@ -272,7 +271,7 @@ public class SearchCoreFactory {
|
|||
|
||||
private void searchByName(final SearchPhrase phrase, final SearchResultMatcher resultMatcher)
|
||||
throws IOException {
|
||||
if(phrase.getRadiusLevel() > 1 || phrase.getUnknownSearchWordLength() > 3) {
|
||||
if(phrase.getRadiusLevel() > 1 || phrase.getUnknownSearchWordLength() > 3 || phrase.getUnknownSearchWords().size() > 0) {
|
||||
final boolean locSpecified = phrase.getLastTokenLocation() != null;
|
||||
LatLon loc = phrase.getLastTokenLocation();
|
||||
final List<SearchResult> immediateResults = new ArrayList<>();
|
||||
|
@ -533,34 +532,42 @@ public class SearchCoreFactory {
|
|||
categories = types.getCategories(false);
|
||||
}
|
||||
// results.clear();
|
||||
TreeMap<String, AbstractPoiType> results = new TreeMap<String, AbstractPoiType>() ;
|
||||
List<AbstractPoiType> results = new ArrayList<AbstractPoiType>() ;
|
||||
NameStringMatcher nm = phrase.getNameStringMatcher();
|
||||
for (PoiFilter pf : topVisibleFilters) {
|
||||
if (!phrase.isUnknownSearchWordPresent() || nm.matches(pf.getTranslation())) {
|
||||
results.put(pf.getTranslation(), pf);
|
||||
results.add(pf);
|
||||
}
|
||||
}
|
||||
if (phrase.isUnknownSearchWordPresent()) {
|
||||
for (PoiCategory c : categories) {
|
||||
if (!phrase.isUnknownSearchWordPresent() || nm.matches(c.getTranslation())) {
|
||||
results.put(c.getTranslation(), c);
|
||||
if (!results.contains(c) && nm.matches(c.getTranslation())) {
|
||||
results.add(c);
|
||||
}
|
||||
}
|
||||
Iterator<Entry<String, PoiType>> it = translatedNames.entrySet().iterator();
|
||||
while (it.hasNext()) {
|
||||
Entry<String, PoiType> e = it.next();
|
||||
if (e.getValue().getCategory() != types.getOtherMapCategory()
|
||||
&& (nm.matches(e.getKey()) || nm.matches(e.getValue().getTranslation()))) {
|
||||
results.put(e.getValue().getTranslation(), e.getValue());
|
||||
PoiType pt = e.getValue();
|
||||
if (pt.getCategory() != types.getOtherMapCategory()) {
|
||||
if (!results.contains(pt) && (nm.matches(e.getKey()) || nm.matches(pt.getTranslation()))) {
|
||||
results.add(pt);
|
||||
}
|
||||
List<PoiType> additionals = pt.getPoiAdditionals();
|
||||
if (additionals != null) {
|
||||
for (PoiType a : additionals) {
|
||||
if (!a.isReference() && !results.contains(a) && (nm.matches(a.getKeyName()) || nm.matches(a.getTranslation()))) {
|
||||
results.add(a);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Iterator<Entry<String, AbstractPoiType>> it = results.entrySet().iterator();
|
||||
while(it.hasNext()) {
|
||||
Entry<String, AbstractPoiType> p = it.next();
|
||||
for (AbstractPoiType pt : results) {
|
||||
SearchResult res = new SearchResult(phrase);
|
||||
res.localeName = p.getKey();
|
||||
res.object = p.getValue();
|
||||
res.localeName = pt.getTranslation();
|
||||
res.object = pt;
|
||||
res.priority = SEARCH_AMENITY_TYPE_PRIORITY;
|
||||
res.priorityDistance = 0;
|
||||
res.objectType = ObjectType.POI_TYPE;
|
||||
|
|
|
@ -164,6 +164,9 @@ def replaceNoTranslate(line) {
|
|||
if (line.contains("\"app_name\"") && System.getenv("TARGET_APP_NAME")) {
|
||||
return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<")
|
||||
}
|
||||
if (line.contains("\"app_name_free\"") && System.getenv("TARGET_APP_NAME")) {
|
||||
return line.replaceAll(">[^<]*<", ">" + System.getenv("TARGET_APP_NAME") + "<")
|
||||
}
|
||||
if (line.contains("\"app_edition\"") && System.getenv("APP_EDITION")) {
|
||||
return line.replaceAll(">[^<]*<", ">" + System.getenv("APP_EDITION") + "<")
|
||||
}
|
||||
|
@ -350,8 +353,18 @@ repositories {
|
|||
// mavenCentral()
|
||||
}
|
||||
|
||||
def analytics = (System.getenv("APP_FEATURES") && System.getenv("APP_FEATURES").contains("+play_market") &&
|
||||
System.getenv("PACKAGE_TO_BUILT").equals("net.osmand") ) || System.getenv("USE_FIREBASE")
|
||||
dependencies {
|
||||
compile project(path: ':OsmAnd-java', configuration: 'android')
|
||||
|
||||
if(analytics) {
|
||||
compile 'com.google.firebase:firebase-core:9.8.0'
|
||||
compile 'com.google.firebase:firebase-config:9.8.0'
|
||||
|
||||
}
|
||||
|
||||
|
||||
// compile project(':eclipse-compile:design')
|
||||
// compile project(':eclipse-compile:cardview')
|
||||
// compile project(':eclipse-compile:gridlayout')
|
||||
|
@ -366,3 +379,7 @@ dependencies {
|
|||
qtcoreCompile "net.osmand:OsmAndCore_androidNativeRelease:0.1-SNAPSHOT@aar"
|
||||
qtcoreCompile "net.osmand:OsmAndCore_android:0.1-SNAPSHOT@aar"
|
||||
}
|
||||
if(analytics) {
|
||||
println "Apply GMS plugin"
|
||||
apply plugin: 'com.google.gms.google-services'
|
||||
}
|
||||
|
|
42
OsmAnd/google-services.json
Normal file
42
OsmAnd/google-services.json
Normal file
|
@ -0,0 +1,42 @@
|
|||
{
|
||||
"project_info": {
|
||||
"project_number": "521675454867",
|
||||
"firebase_url": "https://osmand-1e236.firebaseio.com",
|
||||
"project_id": "osmand-1e236",
|
||||
"storage_bucket": "osmand-1e236.appspot.com"
|
||||
},
|
||||
"client": [
|
||||
{
|
||||
"client_info": {
|
||||
"mobilesdk_app_id": "1:521675454867:android:be0477f14dc015f4",
|
||||
"android_client_info": {
|
||||
"package_name": "net.osmand"
|
||||
}
|
||||
},
|
||||
"oauth_client": [
|
||||
{
|
||||
"client_id": "521675454867-ttjur3617a74qj0a9rkbkbcjavvuebjp.apps.googleusercontent.com",
|
||||
"client_type": 3
|
||||
}
|
||||
],
|
||||
"api_key": [
|
||||
{
|
||||
"current_key": "AIzaSyBMaRMiPY-mS3J_-aX30sRBFB-WGIm-M-U"
|
||||
}
|
||||
],
|
||||
"services": {
|
||||
"analytics_service": {
|
||||
"status": 1
|
||||
},
|
||||
"appinvite_service": {
|
||||
"status": 1,
|
||||
"other_platform_oauth_client": []
|
||||
},
|
||||
"ads_service": {
|
||||
"status": 2
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"configuration_version": "1"
|
||||
}
|
|
@ -5,6 +5,10 @@
|
|||
<solid android:color="@color/map_widget_blue_pressed" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
</shape></item>
|
||||
<item android:state_enabled="false"><shape android:shape="rectangle">
|
||||
<solid android:color="@color/searchbar_tab_inactive_light" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
</shape></item>
|
||||
<item><shape android:shape="rectangle">
|
||||
<solid android:color="@color/map_widget_blue" />
|
||||
<corners android:radius="@dimen/map_button_rect_rad" />
|
||||
|
|
|
@ -41,7 +41,7 @@
|
|||
android:layout_marginLeft="16dp"
|
||||
android:layout_marginRight="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
tools:text="Lat: 50.45375 Lon: 30.48693"/>
|
||||
tools:text="Lat: 50.45375\nLon: 30.48693"/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
|
@ -50,18 +50,15 @@
|
|||
android:layout_marginLeft="12dp"
|
||||
android:layout_marginRight="12dp">
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
<Button
|
||||
android:id="@+id/apply_button"
|
||||
style="@style/Widget.AppCompat.Button.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/DialogActionButton"
|
||||
android:layout_marginRight="8dp"
|
||||
android:text="@string/shared_string_apply"/>
|
||||
|
||||
<android.support.v7.widget.AppCompatButton
|
||||
<Button
|
||||
android:id="@+id/cancel_button"
|
||||
style="@style/Widget.AppCompat.Button.Borderless.Colored"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
style="@style/DialogCancelButton"
|
||||
android:text="@string/shared_string_cancel"/>
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -25,43 +25,7 @@
|
|||
app:contentInsetLeft="54dp"
|
||||
app:contentInsetStart="54dp">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:focusableInTouchMode="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:gravity="center_vertical"
|
||||
android:hint="@string/search_poi_category_hint"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="?attr/searchbar_text"
|
||||
android:textColorHint="?attr/searchbar_text_hint"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/searchProgressBar"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/clearButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_close"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
</LinearLayout>
|
||||
<include layout="@layout/search_text_layout"/>
|
||||
|
||||
</android.support.v7.widget.Toolbar>
|
||||
|
||||
|
|
38
OsmAnd/res/layout/search_text_layout.xml
Normal file
38
OsmAnd/res/layout/search_text_layout.xml
Normal file
|
@ -0,0 +1,38 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="56dp"
|
||||
android:focusableInTouchMode="true"
|
||||
android:gravity="center_vertical"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<EditText
|
||||
android:id="@+id/searchEditText"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="match_parent"
|
||||
android:layout_weight="1"
|
||||
android:background="@null"
|
||||
android:gravity="center_vertical"
|
||||
android:hint="@string/search_poi_category_hint"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:textColor="?attr/searchbar_text"
|
||||
android:textColorHint="?attr/searchbar_text_hint"/>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/searchProgressBar"
|
||||
android:layout_width="32dp"
|
||||
android:layout_height="32dp"
|
||||
android:layout_marginRight="8dp"
|
||||
android:indeterminate="true"
|
||||
android:visibility="gone"/>
|
||||
|
||||
<ImageButton
|
||||
android:id="@+id/clearButton"
|
||||
style="@style/Widget.AppCompat.ActionButton"
|
||||
android:layout_width="48dp"
|
||||
android:layout_height="48dp"
|
||||
android:contentDescription="@string/shared_string_close"
|
||||
android:src="@drawable/ic_action_remove_dark"/>
|
||||
|
||||
</LinearLayout>
|
|
@ -2534,10 +2534,10 @@ Wenn Sie OsmAnd und OSM lieben und unterstützen wollen, so ist dies die perfekt
|
|||
<string name="edit_filter">Kategorien bearbeiten</string>
|
||||
<string name="subcategories">Unterkategorien</string>
|
||||
<string name="translit_names">Namen umschreiben</string>
|
||||
<string name="translit_name_if_miss">Umschreiben, wenn Namen in %1$s fehlen</string>
|
||||
<string name="translit_name_if_miss">Transliteration, wenn Namen in %1$s fehlen</string>
|
||||
<string name="rendering_value_light_brown_name">Hellbraun</string>
|
||||
<string name="rendering_value_dark_brown_name">Dunkelbraun</string>
|
||||
<string name="rendering_attr_contourColorScheme_name">Farbschema der Konturen</string>
|
||||
<string name="rendering_attr_contourColorScheme_name">Farbschema für Höhenlinien</string>
|
||||
<string name="rendering_attr_surfaceIntegrity_name">Straßenoberflächenbeschaffenheit</string>
|
||||
<string name="search_hint">Stadt, Adresse, POI Name eingeben</string>
|
||||
<string name="christmas_poi">Weihnachts POI</string>
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<dimen name="dialog_button_height">36dp</dimen>
|
||||
<dimen name="undo_bottom_offset">15dp</dimen>
|
||||
<dimen name="touch_slop">32dp</dimen>
|
||||
|
||||
|
|
|
@ -10,6 +10,14 @@
|
|||
PLEASE: Have a look at http://code.google.com/p/osmand/wiki/UIConsistency, it may really improve your and our work :-) Thx - Hardy
|
||||
-->
|
||||
|
||||
<string name="legacy_search">Legacy search</string>
|
||||
<string name="show_legacy_search">Show legacy search</string>
|
||||
<string name="show_legacy_search_desc">Enable legacy search in the drawer list</string>
|
||||
<string name="routing_attr_allow_motorway_name">Allow motorways</string>
|
||||
<string name="routing_attr_allow_motorway_description">Allow motorways</string>
|
||||
<string name="upload_osm_note_description">You can upload your OSM Note anonymously or using your OpenStreetMap.org profile.</string>
|
||||
<string name="wiki_around">Nearby Wikipedia articles</string>
|
||||
<string name="search_map_hint">Search city or region</string>
|
||||
<string name="route_roundabout_short">Take %1$d exit and go</string>
|
||||
<string name="upload_poi">Upload POI</string>
|
||||
<string name="route_calculation">Route calculation</string>
|
||||
|
@ -568,7 +576,7 @@
|
|||
<string name="waypoint_visit_before">Visit before</string>
|
||||
<string name="simulate_your_location">Simulate your position</string>
|
||||
<string name="drawer">Flat list</string>
|
||||
<string name="short_location_on_map">Lat %1$s\n Lon %2$s</string>
|
||||
<string name="short_location_on_map">Lat %1$s\nLon %2$s</string>
|
||||
<string name="tips_and_tricks_descr">Frequently asked questions, recent changes, and others</string>
|
||||
<string name="routing_settings_2">Navigation settings</string>
|
||||
<string name="general_settings_2">General settings</string>
|
||||
|
|
|
@ -50,6 +50,30 @@
|
|||
<item name="android:background">?attr/dashboard_button</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogActionButton">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:minHeight">@dimen/dialog_button_height</item>
|
||||
<item name="android:paddingLeft">16dp</item>
|
||||
<item name="android:paddingRight">16dp</item>
|
||||
<item name="android:paddingTop">8dp</item>
|
||||
<item name="android:paddingBottom">8dp</item>
|
||||
<item name="android:textColor">@color/color_white</item>
|
||||
<item name="android:background">@drawable/btn_round_blue</item>
|
||||
</style>
|
||||
|
||||
<style name="DialogCancelButton">
|
||||
<item name="android:layout_width">wrap_content</item>
|
||||
<item name="android:layout_height">wrap_content</item>
|
||||
<item name="android:minHeight">@dimen/dialog_button_height</item>
|
||||
<item name="android:paddingLeft">16dp</item>
|
||||
<item name="android:paddingRight">16dp</item>
|
||||
<item name="android:paddingTop">8dp</item>
|
||||
<item name="android:paddingBottom">8dp</item>
|
||||
<item name="android:textColor">?attr/contextMenuButtonColor</item>
|
||||
<item name="android:background">?attr/selectableItemBackground</item>
|
||||
</style>
|
||||
|
||||
<!-- Osmand themes styles -->
|
||||
<style name="OsmandLightTheme" parent="Theme.AppCompat.Light">
|
||||
<item name="ctx_menu_info_divider">@color/ctx_menu_info_divider_light</item>
|
||||
|
|
|
@ -24,8 +24,13 @@ import java.io.BufferedReader;
|
|||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
|
||||
|
@ -196,4 +201,19 @@ public class AndroidUtils {
|
|||
}
|
||||
return new PointF(centroidX, centroidY);
|
||||
}
|
||||
|
||||
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map) {
|
||||
List<Map.Entry<K, V>> list = new LinkedList<>(map.entrySet());
|
||||
Collections.sort(list, new Comparator<Map.Entry<K, V>>() {
|
||||
public int compare(Map.Entry<K, V> o1, Map.Entry<K, V> o2) {
|
||||
return (o1.getValue()).compareTo(o2.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
Map<K, V> result = new LinkedHashMap<>();
|
||||
for (Map.Entry<K, V> entry : list) {
|
||||
result.put(entry.getKey(), entry.getValue());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -85,7 +85,7 @@ public class AppInitializer implements IProgress {
|
|||
private static final String VERSION_INSTALLED = "VERSION_INSTALLED"; //$NON-NLS-1$
|
||||
private static final String EXCEPTION_FILE_SIZE = "EXCEPTION_FS"; //$NON-NLS-1$
|
||||
|
||||
public static final String LATEST_CHANGES_URL = "http://osmand.net/blog?id=osmand-2-4-released";
|
||||
public static final String LATEST_CHANGES_URL = "http://osmand.net/blog?id=osmand-2-5-released";
|
||||
// public static final String LATEST_CHANGES_URL = null; // not enough to read
|
||||
public static final int APP_EXIT_CODE = 4;
|
||||
public static final String APP_EXIT_KEY = "APP_EXIT_KEY";
|
||||
|
|
|
@ -44,7 +44,7 @@ public class NotificationHelper {
|
|||
if (notification != null) {
|
||||
removeNotification(notification.getType());
|
||||
setTopNotification(notification);
|
||||
Builder notificationBuilder = notification.buildNotification();
|
||||
Builder notificationBuilder = notification.buildNotification(false);
|
||||
return notificationBuilder.build();
|
||||
}
|
||||
return null;
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.content.pm.PackageManager.NameNotFoundException;
|
|||
import android.content.res.Configuration;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.support.multidex.MultiDex;
|
||||
|
@ -22,6 +23,7 @@ import android.view.accessibility.AccessibilityManager;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.CallbackWithObject;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.access.AccessibilityPlugin;
|
||||
|
@ -57,8 +59,11 @@ import java.io.File;
|
|||
import java.io.FileWriter;
|
||||
import java.io.PrintStream;
|
||||
import java.lang.Thread.UncaughtExceptionHandler;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
import btools.routingapp.BRouterServiceConnection;
|
||||
import btools.routingapp.IBRouterService;
|
||||
|
@ -67,6 +72,8 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
public static final String EXCEPTION_PATH = "exception.log"; //$NON-NLS-1$
|
||||
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(OsmandApplication.class);
|
||||
|
||||
public static final String SHOW_PLUS_VERSION_PARAM = "show_plus_version";
|
||||
|
||||
final AppInitializer appInitializer = new AppInitializer(this);
|
||||
OsmandSettings osmandSettings = null;
|
||||
OsmAndAppCustomization appCustomization;
|
||||
|
@ -147,6 +154,7 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
// targetPointsHelper.clearPointToNavigate(false);
|
||||
// }
|
||||
|
||||
initRemoteConfig();
|
||||
startApplication();
|
||||
System.out.println("Time to start application " + (System.currentTimeMillis() - timeToStart) + " ms. Should be less < 800 ms");
|
||||
timeToStart = System.currentTimeMillis();
|
||||
|
@ -776,4 +784,78 @@ public class OsmandApplication extends MultiDexApplication {
|
|||
}
|
||||
return l;
|
||||
}
|
||||
|
||||
public void logEvent(Activity ctx, String event) {
|
||||
try {
|
||||
if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) {
|
||||
Class<?> cl = Class.forName("com.google.firebase.analytics.FirebaseAnalytics");
|
||||
Method mm = cl.getMethod("getInstance", Context.class);
|
||||
Object inst = mm.invoke(null, ctx == null ? this : ctx);
|
||||
Method log = cl.getMethod("logEvent", String.class, Bundle.class);
|
||||
log.invoke(inst, event, new Bundle());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void initRemoteConfig() {
|
||||
try {
|
||||
if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) {
|
||||
Class<?> cl = Class.forName("com.google.firebase.remoteconfig.FirebaseRemoteConfig");
|
||||
Method mm = cl.getMethod("getInstance");
|
||||
Object inst = mm.invoke(null);
|
||||
Method log = cl.getMethod("setDefaults", Map.class);
|
||||
Map<String, Object> defaults = new HashMap<>();
|
||||
defaults.put(SHOW_PLUS_VERSION_PARAM, Boolean.FALSE);
|
||||
log.invoke(inst, defaults);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void fetchRemoteParams() {
|
||||
try {
|
||||
if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) {
|
||||
Class<?> cl = Class.forName("com.google.firebase.remoteconfig.FirebaseRemoteConfig");
|
||||
Method mm = cl.getMethod("getInstance");
|
||||
Object inst = mm.invoke(null);
|
||||
Method log = cl.getMethod("fetch");
|
||||
log.invoke(inst);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public void activateFetchedRemoteParams() {
|
||||
try {
|
||||
if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) {
|
||||
Class<?> cl = Class.forName("com.google.firebase.remoteconfig.FirebaseRemoteConfig");
|
||||
Method mm = cl.getMethod("getInstance");
|
||||
Object inst = mm.invoke(null);
|
||||
Method log = cl.getMethod("activateFetched");
|
||||
log.invoke(inst);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean getRemoteBoolean(String key, boolean defaultValue) {
|
||||
try {
|
||||
if(Version.isGooglePlayEnabled(this) && Version.isFreeVersion(this)) {
|
||||
Class<?> cl = Class.forName("com.google.firebase.remoteconfig.FirebaseRemoteConfig");
|
||||
Method mm = cl.getMethod("getInstance");
|
||||
Object inst = mm.invoke(null);
|
||||
Method log = cl.getMethod("getBoolean", String.class);
|
||||
Boolean res = (Boolean)log.invoke(inst, key);
|
||||
return res == null ? defaultValue : res;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return defaultValue;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -904,6 +904,7 @@ public class OsmandSettings {
|
|||
public static final String BILLING_USER_DONATION_NONE_PARAMETER = "none";
|
||||
|
||||
public final OsmandPreference<String> BILLING_USER_ID = new StringPreference("billing_user_id", "").makeGlobal();
|
||||
public final OsmandPreference<String> BILLING_USER_TOKEN = new StringPreference("billing_user_token", "").makeGlobal();
|
||||
public final OsmandPreference<String> BILLING_USER_NAME = new StringPreference("billing_user_name", "").makeGlobal();
|
||||
public final OsmandPreference<String> BILLING_USER_EMAIL = new StringPreference("billing_user_email", "").makeGlobal();
|
||||
public final OsmandPreference<String> BILLING_USER_COUNTRY = new StringPreference("billing_user_country", "").makeGlobal();
|
||||
|
@ -1119,7 +1120,9 @@ public class OsmandSettings {
|
|||
public final OsmandPreference<String> OSMO_GROUPS = new StringPreference("osmo_groups", "{}").makeGlobal();
|
||||
|
||||
public final OsmandPreference<Boolean> NO_DISCOUNT_INFO = new BooleanPreference("no_discount_info", false).makeGlobal();
|
||||
|
||||
|
||||
public final OsmandPreference<Boolean> SHOW_LEGACY_SEARCH = new BooleanPreference("show_legacy_search", false).makeGlobal();
|
||||
|
||||
// this value string is synchronized with settings_pref.xml preference name
|
||||
public final OsmandPreference<Boolean> DEBUG_RENDERING_INFO = new BooleanPreference("debug_rendering", false).makeGlobal();
|
||||
|
||||
|
|
|
@ -60,8 +60,7 @@ public class LocalIndexInfo {
|
|||
}
|
||||
|
||||
// Special domain object represents category
|
||||
public LocalIndexInfo(@NonNull LocalIndexType type, boolean backup, @NonNull String subfolder,
|
||||
@NonNull OsmandApplication app) {
|
||||
public LocalIndexInfo(@NonNull LocalIndexType type, boolean backup, @NonNull String subfolder) {
|
||||
this.type = type;
|
||||
backupedData = backup;
|
||||
this.subfolder = subfolder;
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.Manifest;
|
|||
import android.app.Activity;
|
||||
import android.app.AlarmManager;
|
||||
import android.app.Dialog;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
|
@ -72,9 +71,9 @@ import net.osmand.plus.base.FailSafeFuntions;
|
|||
import net.osmand.plus.base.MapViewTrackingUtilities;
|
||||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.dialogs.ErrorBottomSheetDialog;
|
||||
import net.osmand.plus.dialogs.XMasDialogFragment;
|
||||
import net.osmand.plus.dialogs.RateUsBottomSheetDialog;
|
||||
import net.osmand.plus.dialogs.WhatsNewDialogFragment;
|
||||
import net.osmand.plus.dialogs.XMasDialogFragment;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
|
||||
import net.osmand.plus.download.ui.DataStoragePlaceDialogFragment;
|
||||
|
@ -114,7 +113,6 @@ import org.apache.commons.logging.Log;
|
|||
import java.io.File;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -780,9 +778,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
}
|
||||
//mapContextMenu.setMapZoom(settings.getMapZoomToShow());
|
||||
mapContextMenu.setMapZoom(tb.getZoom());
|
||||
if (mapLayers.getMapControlsLayer().getMapRouteInfoMenu().isVisible()) {
|
||||
if (MapRouteInfoMenu.isVisible()) {
|
||||
mapContextMenu.showMinimized(latLonToShow, mapLabelToShow, toShow);
|
||||
mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateMenu();
|
||||
MapRouteInfoMenu.showLocationOnMap(this, latLonToShow.getLatitude(), latLonToShow.getLongitude());
|
||||
} else {
|
||||
mapContextMenu.show(latLonToShow, mapLabelToShow, toShow);
|
||||
}
|
||||
|
@ -1383,6 +1382,10 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
|
||||
}
|
||||
|
||||
public boolean isLandscapeLayout() {
|
||||
return landscapeLayout;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
|
||||
RoutingHelper rh = app.getRoutingHelper();
|
||||
|
|
|
@ -571,7 +571,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
|
||||
public ContextMenuAdapter createMainOptionsMenu() {
|
||||
final OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
int viewHeight = mapView.getViewHeight();
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
ContextMenuAdapter optionsMenuHelper = new ContextMenuAdapter();
|
||||
|
||||
|
@ -580,6 +579,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_dashboard_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.closeDrawer();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.DASHBOARD);
|
||||
|
@ -592,6 +592,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_markers_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.MAP_MARKERS);
|
||||
return false;
|
||||
|
@ -603,6 +604,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_waypoints_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.WAYPOINTS);
|
||||
return false;
|
||||
|
@ -615,6 +617,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_myplaces_open");
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getFavoritesActivity());
|
||||
newIntent.setFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
|
@ -628,28 +631,52 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_search_open");
|
||||
mapActivity.showQuickSearch(MapActivity.ShowQuickSearchMode.NEW_IF_EXPIRED, false);
|
||||
/*
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getSearchActivity());
|
||||
LatLon loc = mapActivity.getMapLocation();
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
|
||||
if (mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation()) {
|
||||
newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
|
||||
}
|
||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
if (settings.SHOW_LEGACY_SEARCH.get()) {
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.legacy_search, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_search_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_legacy_search_open");
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getSearchActivity());
|
||||
LatLon loc = mapActivity.getMapLocation();
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LAT, loc.getLatitude());
|
||||
newIntent.putExtra(SearchActivity.SEARCH_LON, loc.getLongitude());
|
||||
if (mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation()) {
|
||||
newIntent.putExtra(SearchActivity.SEARCH_NEARBY, true);
|
||||
}
|
||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(newIntent);
|
||||
return true;
|
||||
}
|
||||
}).createItem());
|
||||
}
|
||||
|
||||
optionsMenuHelper.addItem(new ContextMenuItem.ItemBuilder().setTitleId(R.string.configure_map, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_layers_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_config_map_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_MAP);
|
||||
return false;
|
||||
}
|
||||
}).createItem());
|
||||
|
||||
optionsMenuHelper.addItem(new ItemBuilder().setTitleId(R.string.get_directions, mapActivity)
|
||||
.setIcon(R.drawable.ic_action_gdirections_dark)
|
||||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_directions_open");
|
||||
MapControlsLayer mapControlsLayer = mapActivity.getMapLayers().getMapControlsLayer();
|
||||
if (mapControlsLayer != null) {
|
||||
mapControlsLayer.doRoute(false);
|
||||
|
@ -670,6 +697,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_download_maps_open");
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getDownloadActivity());
|
||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
|
@ -684,6 +712,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_osm_live_open");
|
||||
Intent intent = new Intent(mapActivity, OsmLiveActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(intent);
|
||||
|
@ -710,6 +739,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_plugins_open");
|
||||
Intent newIntent = new Intent(mapActivity, mapActivity.getMyApplication().getAppCustomization()
|
||||
.getPluginsActivity());
|
||||
newIntent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
|
@ -723,6 +753,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_config_screen_open");
|
||||
MapActivity.clearPrevActivityIntent();
|
||||
mapActivity.getDashboard().setDashboardVisibility(true, DashboardType.CONFIGURE_SCREEN);
|
||||
return false;
|
||||
|
@ -734,6 +765,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_settings_open");
|
||||
final Intent settings = new Intent(mapActivity, getMyApplication().getAppCustomization()
|
||||
.getSettingsActivity());
|
||||
settings.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
|
@ -760,6 +792,7 @@ public class MapActivityActions implements DialogProvider {
|
|||
.setListener(new ContextMenuAdapter.ItemClickListener() {
|
||||
@Override
|
||||
public boolean onContextMenuClick(ArrayAdapter<ContextMenuItem> adapter, int itemId, int pos, boolean isChecked) {
|
||||
app.logEvent(mapActivity, "drawer_help_open");
|
||||
Intent intent = new Intent(mapActivity, HelpActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
mapActivity.startActivity(intent);
|
||||
|
@ -779,15 +812,6 @@ public class MapActivityActions implements DialogProvider {
|
|||
}
|
||||
|
||||
ItemBuilder divider = new ItemBuilder().setLayout(R.layout.drawer_divider);
|
||||
if (viewHeight > 0) {
|
||||
int listItemHeight = app.getResources().getDimensionPixelSize(R.dimen.list_item_height);
|
||||
int dividerHeight = viewHeight - optionsMenuHelper.length() * listItemHeight;
|
||||
if (dividerHeight > 0) {
|
||||
divider.setMinHeight(dividerHeight);
|
||||
} else if (dividerHeight < 0) {
|
||||
divider.setMinHeight(AndroidUtils.dpToPx(app, 16f));
|
||||
}
|
||||
}
|
||||
divider.setPosition(pluginsItemIndex >= 0 ? pluginsItemIndex : 7);
|
||||
optionsMenuHelper.addItem(divider.createItem());
|
||||
|
||||
|
|
|
@ -95,7 +95,11 @@ public class PluginActivity extends OsmandActionBarActivity {
|
|||
getButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
|
||||
try {
|
||||
startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(plugin.getInstallURL())));
|
||||
} catch (Exception e) {
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.audionotes.AudioVideoNotesPlugin.Recording;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
|
||||
|
@ -24,8 +24,8 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder {
|
|||
|
||||
private final Recording recording;
|
||||
|
||||
public AudioVideoNoteMenuBuilder(OsmandApplication app, final Recording recording) {
|
||||
super(app);
|
||||
public AudioVideoNoteMenuBuilder(MapActivity mapActivity, final Recording recording) {
|
||||
super(mapActivity);
|
||||
this.recording = recording;
|
||||
}
|
||||
|
||||
|
@ -42,7 +42,8 @@ public class AudioVideoNoteMenuBuilder extends MenuBuilder {
|
|||
DateFormat dateFormat = android.text.format.DateFormat.getMediumDateFormat(view.getContext());
|
||||
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
|
||||
Date date = new Date(recording.getFile().lastModified());
|
||||
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, 0, false, null);
|
||||
buildRow(view, R.drawable.ic_action_data, dateFormat.format(date) + " — " + timeFormat.format(date),
|
||||
0, false, null, false, 0, false, null);
|
||||
|
||||
buildPlainMenuItems(view);
|
||||
|
||||
|
|
|
@ -22,8 +22,8 @@ public class AudioVideoNoteMenuController extends MenuController {
|
|||
private AudioVideoNotesPlugin mPlugin;
|
||||
private boolean mIsFileAvailable;
|
||||
|
||||
public AudioVideoNoteMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final Recording recording) {
|
||||
super(new AudioVideoNoteMenuBuilder(app, recording), pointDescription, mapActivity);
|
||||
public AudioVideoNoteMenuController(MapActivity mapActivity, PointDescription pointDescription, final Recording recording) {
|
||||
super(new AudioVideoNoteMenuBuilder(mapActivity, recording), pointDescription, mapActivity);
|
||||
this.mRecording = recording;
|
||||
mPlugin = OsmandPlugin.getPlugin(AudioVideoNotesPlugin.class);
|
||||
mIsFileAvailable = mRecording.getFile().exists();
|
||||
|
@ -85,11 +85,6 @@ public class AudioVideoNoteMenuController extends MenuController {
|
|||
return mRecording;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
if (mRecording.isPhoto()) {
|
||||
|
|
|
@ -463,8 +463,12 @@ public class DashChooseAppDirFragment {
|
|||
Toast.makeText(ctx, R.string.shared_string_io_error, Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
if(progress.getDialog().isShowing()) {
|
||||
progress.getDialog().dismiss();
|
||||
try {
|
||||
if (progress.getDialog().isShowing()) {
|
||||
progress.getDialog().dismiss();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -541,8 +545,12 @@ public class DashChooseAppDirFragment {
|
|||
|
||||
@Override
|
||||
protected void onPostExecute(Boolean result) {
|
||||
if (progress.getDialog().isShowing()) {
|
||||
progress.getDialog().dismiss();
|
||||
try {
|
||||
if (progress.getDialog().isShowing()) {
|
||||
progress.getDialog().dismiss();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
//ignored
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -69,6 +69,7 @@ import net.osmand.plus.helpers.MapMarkerDialogHelper.MapMarkersDialogHelperCallb
|
|||
import net.osmand.plus.helpers.WaypointDialogHelper;
|
||||
import net.osmand.plus.helpers.WaypointDialogHelper.WaypointDialogHelperCallbacks;
|
||||
import net.osmand.plus.helpers.WaypointHelper.LocationPointWrapper;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu;
|
||||
import net.osmand.plus.mapcontextmenu.other.RoutePreferencesMenu.LocalRoutingParameter;
|
||||
import net.osmand.plus.rastermaps.OsmandRasterMapsPlugin;
|
||||
|
@ -841,7 +842,7 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
mapActivity.getMapViewTrackingUtilities().setDashboard(null);
|
||||
hide(dashboardView.findViewById(R.id.animateContent), animation);
|
||||
|
||||
if (!mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().isVisible()) {
|
||||
if (!MapRouteInfoMenu.isVisible()) {
|
||||
AndroidUiHelper.updateVisibility(mapActivity.findViewById(R.id.map_route_land_left_margin_external), false);
|
||||
mapActivity.getMapView().setMapPositionX(0);
|
||||
mapActivity.getMapView().refreshMap();
|
||||
|
|
|
@ -86,6 +86,8 @@ public class SettingsDevelopmentActivity extends SettingsBaseActivity {
|
|||
cat.addPreference(createCheckBoxPreference(settings.NO_DISCOUNT_INFO,
|
||||
R.string.no_update_info, R.string.no_update_info_desc));
|
||||
|
||||
cat.addPreference(createCheckBoxPreference(settings.SHOW_LEGACY_SEARCH,
|
||||
R.string.show_legacy_search, R.string.show_legacy_search_desc));
|
||||
|
||||
// FIXME delete USE_MAP_MARKERS
|
||||
// cat.addPreference(createCheckBoxPreference(settings.USE_MAP_MARKERS,
|
||||
|
|
|
@ -1066,8 +1066,13 @@ public class ConfigureMapMenu {
|
|||
final Spinner spinner = (Spinner) spinnerView.findViewById(R.id.spinner);
|
||||
TextView description = (TextView) spinnerView.findViewById(R.id.description);
|
||||
|
||||
title.setText(p.getName());
|
||||
description.setText(p.getDescription());
|
||||
String propertyName = SettingsActivity.getStringPropertyName(activity, p.getAttrName(),
|
||||
p.getName());
|
||||
String propertyDescr = SettingsActivity.getStringPropertyDescription(activity,
|
||||
p.getAttrName(), p.getName());
|
||||
|
||||
title.setText(propertyName);
|
||||
description.setText(propertyDescr);
|
||||
|
||||
int i = Arrays.asList(p.getPossibleValues()).indexOf(pref.get());
|
||||
if (i >= 0) {
|
||||
|
|
31
OsmAnd/src/net/osmand/plus/download/CityItem.java
Normal file
31
OsmAnd/src/net/osmand/plus/download/CityItem.java
Normal file
|
@ -0,0 +1,31 @@
|
|||
package net.osmand.plus.download;
|
||||
|
||||
import net.osmand.data.Amenity;
|
||||
|
||||
public class CityItem {
|
||||
private String name;
|
||||
private Amenity amenity;
|
||||
private IndexItem indexItem;
|
||||
|
||||
public CityItem(String name, Amenity amenity, IndexItem indexItem) {
|
||||
this.name = name;
|
||||
this.amenity = amenity;
|
||||
this.indexItem = indexItem;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Amenity getAmenity() {
|
||||
return amenity;
|
||||
}
|
||||
|
||||
public IndexItem getIndexItem() {
|
||||
return indexItem;
|
||||
}
|
||||
|
||||
public void setIndexItem(IndexItem indexItem) {
|
||||
this.indexItem = indexItem;
|
||||
}
|
||||
}
|
|
@ -121,6 +121,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
protected void onCreate(Bundle savedInstanceState) {
|
||||
getMyApplication().applyTheme(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
getMyApplication().fetchRemoteParams();
|
||||
downloadThread = getMyApplication().getDownloadThread();
|
||||
DownloadResources indexes = getDownloadThread().getIndexes();
|
||||
if (!indexes.isDownloadedFromInternet) {
|
||||
|
@ -378,6 +379,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
&& isDownlodingPermitted(ctx.getMyApplication().getSettings())) {
|
||||
collapseBanner();
|
||||
} else {
|
||||
ctx.getMyApplication().logEvent(ctx, "click_free_dialog");
|
||||
new FreeVersionDialogFragment().show(ctx.getSupportFragmentManager(), "dialog");
|
||||
// expandBanner();
|
||||
}
|
||||
|
@ -435,6 +437,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
fullVersionButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ctx.getMyApplication().logEvent(ctx, "click_buy_plus");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(
|
||||
ctx.getMyApplication()) + "net.osmand.plus"));
|
||||
try {
|
||||
|
@ -447,6 +450,7 @@ public class DownloadActivity extends AbstractDownloadActivity implements Downlo
|
|||
osmLiveButton.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
ctx.getMyApplication().logEvent(ctx, "click_subscribe_live_osm");
|
||||
Intent intent = new Intent(ctx, OsmLiveActivity.class);
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_REORDER_TO_FRONT);
|
||||
intent.putExtra(OsmLiveActivity.OPEN_SUBSCRIPTION_INTENT_PARAM, true);
|
||||
|
|
|
@ -264,6 +264,9 @@ public class DownloadIndexesThread {
|
|||
return;
|
||||
}
|
||||
}
|
||||
if(uiActivity instanceof Activity) {
|
||||
app.logEvent((Activity) uiActivity, "download_files");
|
||||
}
|
||||
for(IndexItem item : items) {
|
||||
if (!item.equals(currentDownloadingItem) && !indexItemDownloading.contains(item)) {
|
||||
indexItemDownloading.add(item);
|
||||
|
|
|
@ -121,7 +121,7 @@ public class DownloadValidationManager {
|
|||
builder.setMessage(MessageFormat.format(context.getString(R.string.download_files_error_not_enough_space), i, szChange, asz, szMaxTemp));
|
||||
builder.setNegativeButton(R.string.shared_string_ok, null);
|
||||
builder.show();
|
||||
} else if (asz != -1 && asz > 0 && (szChange / asz > 0.8 || szMaxTemp / asz > 0.9)) {
|
||||
} else if (asz != -1 && asz > 0 && ((szChange + 10 > asz) || (szMaxTemp + 10 > asz))) {
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(context);
|
||||
if (szChange != szMaxTemp) {
|
||||
builder.setMessage(MessageFormat.format(context.getString(R.string.download_files_question_space_with_temp), i, szChange, asz, szMaxTemp));
|
||||
|
|
|
@ -49,6 +49,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
private DownloadResourceGroup group;
|
||||
private DownloadActivity activity;
|
||||
private Toolbar toolbar;
|
||||
private View searchView;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -101,6 +102,7 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
}
|
||||
|
||||
listView = (ExpandableListView) view.findViewById(android.R.id.list);
|
||||
addSearchRow();
|
||||
listView.setOnChildClickListener(this);
|
||||
listAdapter = new DownloadResourceGroupAdapter(activity);
|
||||
listView.setAdapter(listAdapter);
|
||||
|
@ -108,6 +110,37 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
return view;
|
||||
}
|
||||
|
||||
private void addSearchRow() {
|
||||
if (!openAsDialog() ) {
|
||||
searchView = activity.getLayoutInflater().inflate(R.layout.simple_list_menu_item, null);
|
||||
searchView.setBackgroundResource(android.R.drawable.list_selector_background);
|
||||
TextView title = (TextView) searchView.findViewById(R.id.title);
|
||||
title.setCompoundDrawablesWithIntrinsicBounds(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_action_search_dark), null, null, null);
|
||||
title.setHint(R.string.search_map_hint);
|
||||
searchView.setOnClickListener(new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
getDownloadActivity().showDialog(getActivity(), SearchDialogFragment.createInstance(""));
|
||||
}
|
||||
});
|
||||
listView.addHeaderView(searchView);
|
||||
listView.setHeaderDividersEnabled(false);
|
||||
IndexItem worldBaseMapItem = activity.getDownloadThread().getIndexes().getWorldBaseMapItem();
|
||||
if (worldBaseMapItem == null || !worldBaseMapItem.isDownloaded()) {
|
||||
title.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void updateSearchView() {
|
||||
if (searchView != null && searchView.findViewById(R.id.title).getVisibility() == View.GONE) {
|
||||
IndexItem worldBaseMapItem = activity.getDownloadThread().getIndexes().getWorldBaseMapItem();
|
||||
if (worldBaseMapItem != null && worldBaseMapItem.isDownloaded()) {
|
||||
searchView.findViewById(R.id.title).setVisibility(View.VISIBLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
@ -133,6 +166,9 @@ public class DownloadResourceGroupFragment extends DialogFragment implements Dow
|
|||
}
|
||||
|
||||
private void reloadData() {
|
||||
if (!openAsDialog()) {
|
||||
updateSearchView();
|
||||
}
|
||||
DownloadResources indexes = activity.getDownloadThread().getIndexes();
|
||||
group = indexes.getGroupById(groupId);
|
||||
if (group != null) {
|
||||
|
|
|
@ -1,51 +1,44 @@
|
|||
package net.osmand.plus.download.ui;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Dialog;
|
||||
import android.os.Bundle;
|
||||
import android.provider.Settings;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivity.FreeVersionDialog;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import static net.osmand.plus.OsmandApplication.SHOW_PLUS_VERSION_PARAM;
|
||||
|
||||
public class FreeVersionDialogFragment extends DialogFragment {
|
||||
|
||||
|
||||
private FreeVersionDialog dialog;
|
||||
|
||||
@SuppressLint("HardwareIds")
|
||||
@NonNull
|
||||
@Override
|
||||
public Dialog onCreateDialog(Bundle savedInstanceState) {
|
||||
OsmandApplication app = (OsmandApplication) getActivity().getApplication();
|
||||
app.activateFetchedRemoteParams();
|
||||
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(new ContextThemeWrapper(getActivity(), R.style.OsmandDarkTheme));
|
||||
builder.setNegativeButton(R.string.later, null);
|
||||
View view = getActivity().getLayoutInflater().inflate(R.layout.free_version_banner, null);
|
||||
boolean hidePlus = false;
|
||||
try {
|
||||
String devId = Settings.Secure.getString(getContext().getContentResolver(), Settings.Secure.ANDROID_ID);
|
||||
if (!Algorithms.isEmpty(devId)) {
|
||||
hidePlus = devId.hashCode() % 20 == 8;
|
||||
}
|
||||
} catch (Exception e) {
|
||||
// ignored
|
||||
}
|
||||
|
||||
boolean hidePlus = !app.getRemoteBoolean(SHOW_PLUS_VERSION_PARAM, false);
|
||||
view.findViewById(R.id.osmLiveLayoutTopDivider).setVisibility(hidePlus ? View.GONE : View.VISIBLE);
|
||||
view.findViewById(R.id.fullVersionLayout).setVisibility(hidePlus ? View.GONE : View.VISIBLE);
|
||||
builder.setView(view);
|
||||
|
||||
dialog = new DownloadActivity.FreeVersionDialog(view, getDownloadActivity(), true);
|
||||
dialog.initFreeVersionBanner();
|
||||
dialog.expandBanner();
|
||||
return builder.create();
|
||||
}
|
||||
|
||||
|
||||
DownloadActivity getDownloadActivity() {
|
||||
return (DownloadActivity) getActivity();
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.download.ui;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.ActivityNotFoundException;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.res.Resources;
|
||||
|
@ -25,6 +26,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.Version;
|
||||
import net.osmand.plus.activities.LocalIndexHelper.LocalIndexType;
|
||||
import net.osmand.plus.activities.LocalIndexInfo;
|
||||
import net.osmand.plus.download.CityItem;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
import net.osmand.plus.download.DownloadResourceGroup;
|
||||
|
@ -33,6 +35,7 @@ import net.osmand.plus.download.IndexItem;
|
|||
import net.osmand.plus.download.ui.LocalIndexesFragment.LocalIndexOperationTask;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.srtmplugin.SRTMPlugin;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.text.DateFormat;
|
||||
|
@ -130,6 +133,10 @@ public class ItemViewHolder {
|
|||
}
|
||||
|
||||
public void bindIndexItem(final IndexItem indexItem) {
|
||||
bindIndexItem(indexItem, null);
|
||||
}
|
||||
|
||||
public void bindIndexItem(final IndexItem indexItem, final String cityName) {
|
||||
initAppStatusVariables();
|
||||
boolean isDownloading = context.getDownloadThread().isDownloading(indexItem);
|
||||
int progress = -1;
|
||||
|
@ -138,11 +145,14 @@ public class ItemViewHolder {
|
|||
}
|
||||
boolean disabled = checkDisabledAndClickAction(indexItem);
|
||||
/// name and left item
|
||||
String name;
|
||||
if(showTypeInName) {
|
||||
nameTextView.setText(indexItem.getType().getString(context));
|
||||
name = indexItem.getType().getString(context);
|
||||
} else {
|
||||
nameTextView.setText(indexItem.getVisibleName(context, context.getMyApplication().getRegions(), showParentRegionName));
|
||||
name = indexItem.getVisibleName(context, context.getMyApplication().getRegions(), showParentRegionName);
|
||||
}
|
||||
String text = (!Algorithms.isEmpty(cityName) && !cityName.equals(name) ? cityName + "\n" : "") + name;
|
||||
nameTextView.setText(text);
|
||||
if(!disabled) {
|
||||
nameTextView.setTextColor(textColorPrimary);
|
||||
} else {
|
||||
|
@ -209,6 +219,17 @@ public class ItemViewHolder {
|
|||
}
|
||||
}
|
||||
|
||||
public void bindIndexItem(final CityItem cityItem) {
|
||||
if (cityItem.getIndexItem() != null) {
|
||||
bindIndexItem(cityItem.getIndexItem(), cityItem.getName());
|
||||
} else {
|
||||
nameTextView.setText(cityItem.getName());
|
||||
nameTextView.setTextColor(textColorPrimary);
|
||||
leftImageView.setImageDrawable(getContentIcon(context, R.drawable.ic_map));
|
||||
descrTextView.setVisibility(View.GONE);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
protected void download(IndexItem indexItem, DownloadResourceGroup parentOptional) {
|
||||
boolean handled = false;
|
||||
|
@ -303,9 +324,14 @@ public class ItemViewHolder {
|
|||
public void onClick(View v) {
|
||||
switch (clickAction) {
|
||||
case ASK_FOR_FULL_VERSION_PURCHASE:
|
||||
context.getMyApplication().logEvent(context, "click_buy_plus");
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(Version.marketPrefix(context
|
||||
.getMyApplication()) + "net.osmand.plus"));
|
||||
context.startActivity(intent);
|
||||
try {
|
||||
context.startActivity(intent);
|
||||
} catch (ActivityNotFoundException e) {
|
||||
//ignore
|
||||
}
|
||||
break;
|
||||
case ASK_FOR_SEAMARKS_PLUGIN:
|
||||
context.startActivity(new Intent(context, context.getMyApplication().getAppCustomization()
|
||||
|
|
|
@ -342,7 +342,9 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
|
||||
@Override
|
||||
public void loadFile(LocalIndexInfo... loaded) {
|
||||
publishProgress(loaded);
|
||||
if (!isCancelled()) {
|
||||
publishProgress(loaded);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -853,8 +855,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
return i;
|
||||
}
|
||||
}
|
||||
LocalIndexInfo newCat = new LocalIndexInfo(val.getType(), backuped, val.getSubfolder(),
|
||||
getMyApplication());
|
||||
LocalIndexInfo newCat = new LocalIndexInfo(val.getType(), backuped, val.getSubfolder());
|
||||
category.add(newCat);
|
||||
data.put(newCat, new ArrayList<LocalIndexInfo>());
|
||||
return newCat;
|
||||
|
@ -931,8 +932,7 @@ public class LocalIndexesFragment extends OsmandExpandableListFragment implement
|
|||
}
|
||||
if (found == -1) {
|
||||
found = category.size();
|
||||
category.add(new LocalIndexInfo(info.getType(), info.isBackupedData(),
|
||||
info.getSubfolder(), getMyApplication()));
|
||||
category.add(new LocalIndexInfo(info.getType(), info.isBackupedData(), info.getSubfolder()));
|
||||
}
|
||||
if (!data.containsKey(category.get(found))) {
|
||||
data.put(category.get(found), new ArrayList<LocalIndexInfo>());
|
||||
|
|
|
@ -1,12 +1,14 @@
|
|||
package net.osmand.plus.download.ui;
|
||||
|
||||
import android.content.res.TypedArray;
|
||||
import android.graphics.Color;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.DialogFragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.support.v7.widget.SearchView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.text.Editable;
|
||||
import android.text.TextWatcher;
|
||||
import android.util.TypedValue;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -14,20 +16,29 @@ import android.view.ViewGroup;
|
|||
import android.widget.AdapterView;
|
||||
import android.widget.AdapterView.OnItemClickListener;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.EditText;
|
||||
import android.widget.ExpandableListView;
|
||||
import android.widget.Filter;
|
||||
import android.widget.Filterable;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.ListView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.RelativeLayout.LayoutParams;
|
||||
import android.widget.ProgressBar;
|
||||
|
||||
import net.osmand.Collator;
|
||||
import net.osmand.CollatorStringMatcher;
|
||||
import net.osmand.OsmAndCollator;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.binary.BinaryMapIndexReader.SearchRequest;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.map.OsmandRegions;
|
||||
import net.osmand.map.WorldRegion;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.download.CityItem;
|
||||
import net.osmand.plus.download.DownloadActivity;
|
||||
import net.osmand.plus.download.DownloadActivity.BannerAndDownloadFreeVersion;
|
||||
import net.osmand.plus.download.DownloadActivityType;
|
||||
|
@ -36,9 +47,15 @@ import net.osmand.plus.download.DownloadResourceGroup;
|
|||
import net.osmand.plus.download.DownloadResourceGroup.DownloadResourceGroupType;
|
||||
import net.osmand.plus.download.DownloadResources;
|
||||
import net.osmand.plus.download.IndexItem;
|
||||
import net.osmand.search.core.SearchPhrase;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.RandomAccessFile;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
|
@ -52,7 +69,10 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
private SearchListAdapter listAdapter;
|
||||
private BannerAndDownloadFreeVersion banner;
|
||||
private String searchText;
|
||||
private SearchView searchView;
|
||||
private View searchView;
|
||||
private EditText searchEditText;
|
||||
private ProgressBar progressBar;
|
||||
private ImageButton clearButton;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
|
@ -106,42 +126,48 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
|
||||
TypedValue typedValue = new TypedValue();
|
||||
getActivity().getTheme().resolveAttribute(R.attr.toolbar_theme, typedValue, true);
|
||||
searchView = new SearchView(new ContextThemeWrapper(getActivity(), typedValue.data));
|
||||
RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(
|
||||
LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
|
||||
params.setMargins(0, 0, 0, 0);
|
||||
searchView.setLayoutParams(params);
|
||||
|
||||
searchView = inflater.inflate(R.layout.search_text_layout, toolbar, false);
|
||||
toolbar.addView(searchView);
|
||||
|
||||
searchView.setOnCloseListener(new SearchView.OnCloseListener() {
|
||||
searchEditText = (EditText) view.findViewById(R.id.searchEditText);
|
||||
searchEditText.setHint(R.string.search_map_hint);
|
||||
searchEditText.setTextColor(Color.WHITE);
|
||||
boolean isLight = getMyApplication().getSettings().isLightContent();
|
||||
searchEditText.setHintTextColor(isLight ?
|
||||
getMyApplication().getResources().getColor(R.color.inactive_item_orange) : getMyApplication().getResources().getColor(R.color.searchbar_tab_inactive_dark));
|
||||
|
||||
progressBar = (ProgressBar) view.findViewById(R.id.searchProgressBar);
|
||||
clearButton = (ImageButton) view.findViewById(R.id.clearButton);
|
||||
clearButton.setVisibility(View.GONE);
|
||||
|
||||
searchEditText.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public boolean onClose() {
|
||||
if (searchView.getQuery().length() == 0) {
|
||||
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) {
|
||||
updateSearchText(s.toString());
|
||||
}
|
||||
});
|
||||
|
||||
clearButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (searchEditText.getText().length() == 0) {
|
||||
dismiss();
|
||||
return true;
|
||||
} else {
|
||||
searchEditText.setText("");
|
||||
}
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
searchView.setOnQueryTextFocusChangeListener(new View.OnFocusChangeListener() {
|
||||
@Override
|
||||
public void onFocusChange(View v, boolean hasFocus) {
|
||||
}
|
||||
});
|
||||
|
||||
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
|
||||
@Override
|
||||
public boolean onQueryTextSubmit(String query) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onQueryTextChange(String newText) {
|
||||
updateSearchText(newText);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
searchEditText.requestFocus();
|
||||
|
||||
return view;
|
||||
}
|
||||
|
@ -188,15 +214,16 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
searchView.setIconified(false);
|
||||
if (!Algorithms.isEmpty(searchText)) {
|
||||
searchView.setQuery(searchText, true);
|
||||
searchEditText.setText(searchText);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateSearchText(String searchText) {
|
||||
this.searchText = searchText;
|
||||
listAdapter.getFilter().filter(searchText);
|
||||
SearchListAdapter.SearchIndexFilter filter = (SearchListAdapter.SearchIndexFilter) listAdapter.getFilter();
|
||||
filter.cancelFilter();
|
||||
filter.filter(searchText);
|
||||
}
|
||||
|
||||
private OsmandApplication getMyApplication() {
|
||||
|
@ -231,15 +258,35 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
}
|
||||
}
|
||||
|
||||
private void showProgressBar() {
|
||||
updateClearButtonVisibility(false);
|
||||
progressBar.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
||||
private void hideProgressBar() {
|
||||
updateClearButtonVisibility(true);
|
||||
progressBar.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
private void updateClearButtonVisibility(boolean show) {
|
||||
if (show) {
|
||||
clearButton.setVisibility(searchEditText.length() > 0 ? View.VISIBLE : View.GONE);
|
||||
} else {
|
||||
clearButton.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
|
||||
private class SearchListAdapter extends BaseAdapter implements Filterable {
|
||||
|
||||
private SearchIndexFilter mFilter;
|
||||
private OsmandRegions osmandRegions;
|
||||
|
||||
private List<Object> items = new LinkedList<>();
|
||||
private DownloadActivity ctx;
|
||||
|
||||
public SearchListAdapter(DownloadActivity ctx) {
|
||||
this.ctx = ctx;
|
||||
this.osmandRegions = ctx.getMyApplication().getRegions();
|
||||
TypedArray ta = ctx.getTheme().obtainStyledAttributes(new int[]{android.R.attr.textColorPrimary});
|
||||
ta.recycle();
|
||||
}
|
||||
|
@ -267,7 +314,7 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
@Override
|
||||
public int getItemViewType(int position) {
|
||||
Object obj = items.get(position);
|
||||
if (obj instanceof IndexItem) {
|
||||
if (obj instanceof IndexItem || obj instanceof CityItem) {
|
||||
return 0;
|
||||
} else {
|
||||
return 1;
|
||||
|
@ -282,9 +329,8 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
@Override
|
||||
public View getView(final int position, View convertView, ViewGroup parent) {
|
||||
final Object obj = items.get(position);
|
||||
if (obj instanceof IndexItem) {
|
||||
if (obj instanceof IndexItem || obj instanceof CityItem) {
|
||||
|
||||
IndexItem item = (IndexItem) obj;
|
||||
ItemViewHolder viewHolder;
|
||||
if (convertView != null && convertView.getTag() instanceof ItemViewHolder) {
|
||||
viewHolder = (ItemViewHolder) convertView.getTag();
|
||||
|
@ -295,8 +341,17 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
viewHolder.setShowRemoteDate(true);
|
||||
convertView.setTag(viewHolder);
|
||||
}
|
||||
viewHolder.setShowTypeInDesc(true);
|
||||
viewHolder.bindIndexItem(item);
|
||||
if (obj instanceof IndexItem) {
|
||||
IndexItem item = (IndexItem) obj;
|
||||
viewHolder.setShowTypeInDesc(true);
|
||||
viewHolder.bindIndexItem(item);
|
||||
} else {
|
||||
CityItem item = (CityItem) obj;
|
||||
viewHolder.bindIndexItem(item);
|
||||
if (item.getIndexItem() == null) {
|
||||
new IndexItemResolverTask(viewHolder, item).execute();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
DownloadResourceGroup group = (DownloadResourceGroup) obj;
|
||||
DownloadGroupViewHolder viewHolder;
|
||||
|
@ -327,14 +382,64 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
return mFilter;
|
||||
}
|
||||
|
||||
class IndexItemResolverTask extends AsyncTask<Void, Void, IndexItem> {
|
||||
private final WeakReference<ItemViewHolder> viewHolderReference;
|
||||
private final CityItem cityItem;
|
||||
|
||||
public IndexItemResolverTask(ItemViewHolder viewHolder, CityItem cityItem) {
|
||||
this.viewHolderReference = new WeakReference<>(viewHolder);
|
||||
this.cityItem = cityItem;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IndexItem doInBackground(Void... params) {
|
||||
Amenity amenity = cityItem.getAmenity();
|
||||
BinaryMapDataObject o = osmandRegions.findBinaryMapDataObject(amenity.getLocation());
|
||||
if (o != null) {
|
||||
String selectedFullName = osmandRegions.getFullName(o);
|
||||
WorldRegion downloadRegion = osmandRegions.getRegionData(selectedFullName);
|
||||
List<IndexItem> indexItems = ctx.getDownloadThread().getIndexes().getIndexItems(downloadRegion);
|
||||
for (IndexItem item : indexItems) {
|
||||
if (item.getType() == DownloadActivityType.NORMAL_FILE) {
|
||||
return item;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(IndexItem indexItem) {
|
||||
if (isCancelled()) {
|
||||
return;
|
||||
}
|
||||
ItemViewHolder viewHolder = viewHolderReference.get();
|
||||
if (viewHolder != null) {
|
||||
if (indexItem != null) {
|
||||
cityItem.setIndexItem(indexItem);
|
||||
viewHolder.bindIndexItem(indexItem, cityItem.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private final class SearchIndexFilter extends Filter {
|
||||
|
||||
private OsmandRegions osmandRegions;
|
||||
private final int searchCityLimit = 10000;
|
||||
private final List<String> citySubTypes = Arrays.asList("city", "town");
|
||||
private SearchRequest<Amenity> searchCityRequest;
|
||||
|
||||
public SearchIndexFilter() {
|
||||
this.osmandRegions = ctx.getMyApplication().getRegions();
|
||||
}
|
||||
|
||||
public void cancelFilter() {
|
||||
if (searchCityRequest != null) {
|
||||
searchCityRequest.setInterrupted(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void processGroup(DownloadResourceGroup group, List<Object> filter, List<List<String>> conds) {
|
||||
String name = null;
|
||||
if (group.getRegion() != null && group.getRegion().getRegionSearchText() != null) {
|
||||
|
@ -387,8 +492,73 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
}
|
||||
}
|
||||
|
||||
public List<CityItem> searchCities(final OsmandApplication app, final String text) throws IOException {
|
||||
IndexItem worldBaseMapItem = app.getDownloadThread().getIndexes().getWorldBaseMapItem();
|
||||
if (worldBaseMapItem == null || !worldBaseMapItem.isDownloaded()) {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
File obf = worldBaseMapItem.getTargetFile(app);
|
||||
final BinaryMapIndexReader baseMapReader = new BinaryMapIndexReader(new RandomAccessFile(obf, "r"), obf);
|
||||
final SearchPhrase.NameStringMatcher nm = new SearchPhrase.NameStringMatcher(
|
||||
text, CollatorStringMatcher.StringMatcherMode.CHECK_STARTS_FROM_SPACE);
|
||||
final String lang = app.getSettings().MAP_PREFERRED_LOCALE.get();
|
||||
final boolean translit = app.getSettings().MAP_TRANSLITERATE_NAMES.get();
|
||||
final List<Amenity> amenities = new ArrayList<>();
|
||||
SearchRequest<Amenity> request = BinaryMapIndexReader.buildSearchPoiRequest(
|
||||
0, 0,
|
||||
text,
|
||||
Integer.MIN_VALUE, Integer.MAX_VALUE,
|
||||
Integer.MIN_VALUE, Integer.MAX_VALUE,
|
||||
new ResultMatcher<Amenity>() {
|
||||
int count = 0;
|
||||
|
||||
@Override
|
||||
public boolean publish(Amenity amenity) {
|
||||
if (count++ > searchCityLimit) {
|
||||
return false;
|
||||
}
|
||||
List<String> otherNames = amenity.getAllNames(true);
|
||||
String localeName = amenity.getName(lang, translit);
|
||||
String subType = amenity.getSubType();
|
||||
if (!citySubTypes.contains(subType)
|
||||
|| (!nm.matches(localeName) && !nm.matches(otherNames))) {
|
||||
return false;
|
||||
}
|
||||
amenities.add(amenity);
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCancelled() {
|
||||
return count > searchCityLimit;
|
||||
}
|
||||
});
|
||||
|
||||
searchCityRequest = request;
|
||||
baseMapReader.searchPoiByName(request);
|
||||
try {
|
||||
baseMapReader.close();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
List<CityItem> items = new ArrayList<>();
|
||||
for (Amenity amenity : amenities) {
|
||||
items.add(new CityItem(amenity.getName(), amenity, null));
|
||||
}
|
||||
return items;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected FilterResults performFiltering(CharSequence constraint) {
|
||||
|
||||
getMyApplication().runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
showProgressBar();
|
||||
}
|
||||
});
|
||||
|
||||
DownloadResources root = ctx.getDownloadThread().getIndexes();
|
||||
|
||||
FilterResults results = new FilterResults();
|
||||
|
@ -396,6 +566,15 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
results.values = new ArrayList<>();
|
||||
results.count = 0;
|
||||
} else {
|
||||
List<Object> filter = new ArrayList<>();
|
||||
if (constraint.length() > 2) {
|
||||
try {
|
||||
filter.addAll(searchCities(getMyApplication(), constraint.toString()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
String[] ors = constraint.toString().split(",");
|
||||
List<List<String>> conds = new ArrayList<>();
|
||||
for (String or : ors) {
|
||||
|
@ -411,7 +590,6 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
}
|
||||
}
|
||||
|
||||
List<Object> filter = new ArrayList<>();
|
||||
processGroup(root, filter, conds);
|
||||
|
||||
final Collator collator = OsmAndCollator.primaryCollator();
|
||||
|
@ -422,13 +600,27 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
String str2;
|
||||
if (obj1 instanceof DownloadResourceGroup) {
|
||||
str1 = ((DownloadResourceGroup) obj1).getName(ctx);
|
||||
} else {
|
||||
} else if (obj1 instanceof IndexItem) {
|
||||
str1 = ((IndexItem) obj1).getVisibleName(getMyApplication(), osmandRegions, false);
|
||||
} else {
|
||||
Amenity a = ((CityItem) obj1).getAmenity();
|
||||
if ("city".equals(a.getSubType())) {
|
||||
str1 = "!" + ((CityItem) obj1).getName();
|
||||
} else {
|
||||
str1 = ((CityItem) obj1).getName();
|
||||
}
|
||||
}
|
||||
if (obj2 instanceof DownloadResourceGroup) {
|
||||
str2 = ((DownloadResourceGroup) obj2).getName(ctx);
|
||||
} else {
|
||||
} else if (obj2 instanceof IndexItem) {
|
||||
str2 = ((IndexItem) obj2).getVisibleName(getMyApplication(), osmandRegions, false);
|
||||
} else {
|
||||
Amenity a = ((CityItem) obj2).getAmenity();
|
||||
if ("city".equals(a.getSubType())) {
|
||||
str2 = "!" + ((CityItem) obj2).getName();
|
||||
} else {
|
||||
str2 = ((CityItem) obj2).getName();
|
||||
}
|
||||
}
|
||||
return collator.compare(str1, str2);
|
||||
}
|
||||
|
@ -437,6 +629,14 @@ public class SearchDialogFragment extends DialogFragment implements DownloadEven
|
|||
results.values = filter;
|
||||
results.count = filter.size();
|
||||
}
|
||||
|
||||
getMyApplication().runInUIThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hideProgressBar();
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
}
|
||||
|
||||
|
|
|
@ -311,7 +311,9 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
|||
view.findViewById(R.id.map_downloading_action_button).setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
showOnMap(new LatLon(location.getLatitude(), location.getLongitude()), 13);
|
||||
if (location != null) {
|
||||
showOnMap(new LatLon(location.getLatitude(), location.getLongitude()), 13);
|
||||
}
|
||||
}
|
||||
});
|
||||
view.findViewById(R.id.map_downloading_card).setVisibility(View.VISIBLE);
|
||||
|
@ -621,9 +623,12 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
|||
|
||||
private void searchCountryMap() {
|
||||
closeWizard();
|
||||
final Intent intent = new Intent(getActivity(), DownloadActivity.class);
|
||||
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
||||
getActivity().startActivity(intent);
|
||||
FragmentActivity activity = getActivity();
|
||||
if (activity != null) {
|
||||
final Intent intent = new Intent(activity, DownloadActivity.class);
|
||||
intent.putExtra(DownloadActivity.TAB_TO_OPEN, DownloadActivity.DOWNLOAD_TAB);
|
||||
activity.startActivity(intent);
|
||||
}
|
||||
}
|
||||
|
||||
private void searchMap() {
|
||||
|
@ -692,13 +697,15 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
|||
}
|
||||
|
||||
public static void startWizard(FragmentActivity activity) {
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
if (!app.getSettings().isInternetConnectionAvailable()) {
|
||||
showNoInternetFragment(activity);
|
||||
} else if (location == null) {
|
||||
findLocation(activity, true);
|
||||
} else {
|
||||
showSearchMapFragment(activity);
|
||||
if (activity != null) {
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
if (!app.getSettings().isInternetConnectionAvailable()) {
|
||||
showNoInternetFragment(activity);
|
||||
} else if (location == null) {
|
||||
findLocation(activity, true);
|
||||
} else {
|
||||
showSearchMapFragment(activity);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -730,19 +737,21 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
|||
}
|
||||
|
||||
private static void findLocation(FragmentActivity activity, boolean searchLocationByIp) {
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
if (searchLocationByIp) {
|
||||
showSearchLocationFragment(activity, true);
|
||||
} else if (OsmAndLocationProvider.isLocationPermissionAvailable(activity)) {
|
||||
Location loc = app.getLocationProvider().getLastKnownLocation();
|
||||
if (loc == null) {
|
||||
showSearchLocationFragment(activity, false);
|
||||
if (activity != null) {
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
if (searchLocationByIp) {
|
||||
showSearchLocationFragment(activity, true);
|
||||
} else if (OsmAndLocationProvider.isLocationPermissionAvailable(activity)) {
|
||||
Location loc = app.getLocationProvider().getLastKnownLocation();
|
||||
if (loc == null) {
|
||||
showSearchLocationFragment(activity, false);
|
||||
} else {
|
||||
location = new Location(loc);
|
||||
showSearchMapFragment(activity);
|
||||
}
|
||||
} else {
|
||||
location = new Location(loc);
|
||||
showSearchMapFragment(activity);
|
||||
showSearchLocationFragment(activity, false);
|
||||
}
|
||||
} else {
|
||||
showSearchLocationFragment(activity, false);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -870,7 +879,7 @@ public class FirstUsageWizardFragment extends Fragment implements OsmAndLocation
|
|||
}
|
||||
|
||||
private static void showFragment(FragmentActivity activity, Fragment fragment) {
|
||||
if (!wizardClosed) {
|
||||
if (!wizardClosed && activity != null) {
|
||||
activity.getSupportFragmentManager()
|
||||
.beginTransaction()
|
||||
.replace(R.id.fragmentContainer, fragment, FirstUsageWizardFragment.TAG)
|
||||
|
|
|
@ -27,9 +27,7 @@
|
|||
</name>
|
||||
</author>
|
||||
</metadata>
|
||||
<xsl:for-each select="//kml:Folder">
|
||||
<xsl:variable name="foldername" select="kml:name"/>
|
||||
<xsl:for-each select="kml:Placemark">
|
||||
<xsl:for-each select="//kml:Placemark">
|
||||
<xsl:variable name="lonlat" select="kml:Point/kml:coordinates"/>
|
||||
<xsl:variable name="lon" select="substring-before($lonlat,',')"/>
|
||||
<xsl:variable name="latele" select="substring-after($lonlat,',')"/>
|
||||
|
@ -43,6 +41,8 @@
|
|||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
</xsl:variable>
|
||||
<xsl:variable name="foldername" select="../kml:name"/>
|
||||
|
||||
<xsl:if test="$lon">
|
||||
<wpt lon="{$lon}" lat="{$lat}">
|
||||
<xsl:choose>
|
||||
|
@ -64,7 +64,6 @@
|
|||
</wpt>
|
||||
</xsl:if>
|
||||
</xsl:for-each>
|
||||
</xsl:for-each>
|
||||
<xsl:for-each select="//gx:Track">
|
||||
<trk>
|
||||
<trkseg>
|
||||
|
|
|
@ -231,7 +231,7 @@ public class InAppHelper {
|
|||
boolean needSendToken = false;
|
||||
if (!isDeveloperVersion && liveUpdatesPurchase != null) {
|
||||
OsmandSettings settings = ctx.getSettings();
|
||||
if (Algorithms.isEmpty(settings.BILLING_USER_ID.get())
|
||||
if ((Algorithms.isEmpty(settings.BILLING_USER_ID.get()) || Algorithms.isEmpty(settings.BILLING_USER_TOKEN.get()))
|
||||
&& !Algorithms.isEmpty(liveUpdatesPurchase.getDeveloperPayload())) {
|
||||
String payload = liveUpdatesPurchase.getDeveloperPayload();
|
||||
if (!Algorithms.isEmpty(payload)) {
|
||||
|
@ -241,6 +241,7 @@ public class InAppHelper {
|
|||
}
|
||||
if (arr.length > 1) {
|
||||
token = arr[1];
|
||||
settings.BILLING_USER_TOKEN.set(token);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -324,8 +325,9 @@ public class InAppHelper {
|
|||
try {
|
||||
JSONObject obj = new JSONObject(response);
|
||||
userId = obj.getString("userid");
|
||||
token = obj.getString("token");
|
||||
ctx.getSettings().BILLING_USER_ID.set(userId);
|
||||
token = obj.getString("token");
|
||||
ctx.getSettings().BILLING_USER_TOKEN.set(token);
|
||||
logDebug("UserId=" + userId);
|
||||
} catch (JSONException e) {
|
||||
String message = "JSON parsing error: "
|
||||
|
@ -432,6 +434,7 @@ public class InAppHelper {
|
|||
|
||||
private void sendToken(String purchaseToken, final OnRequestResultListener listener) {
|
||||
final String userId = ctx.getSettings().BILLING_USER_ID.get();
|
||||
final String token = ctx.getSettings().BILLING_USER_TOKEN.get();
|
||||
final String email = ctx.getSettings().BILLING_USER_EMAIL.get();
|
||||
try {
|
||||
Map<String, String> parameters = new HashMap<>();
|
||||
|
|
|
@ -359,6 +359,7 @@ public class SubscriptionFragment extends BaseOsmAndDialogFragment implements In
|
|||
|
||||
@Override
|
||||
public void onItemPurchased(String sku) {
|
||||
getMyApplication().logEvent(getActivity(), "live_osm_subscription_purchased");
|
||||
dismiss();
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,10 @@ import android.content.res.Resources;
|
|||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.net.Uri;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.text.ClipboardManager;
|
||||
import android.text.TextUtils;
|
||||
import android.text.util.Linkify;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
|
@ -20,12 +23,24 @@ import android.widget.LinearLayout;
|
|||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.IconsCache;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
|
||||
|
||||
|
@ -33,10 +48,15 @@ public class MenuBuilder {
|
|||
|
||||
public static final float SHADOW_HEIGHT_TOP_DP = 17f;
|
||||
|
||||
protected MapActivity mapActivity;
|
||||
protected OsmandApplication app;
|
||||
protected LinkedList<PlainMenuItem> plainMenuItems;
|
||||
private boolean firstRow;
|
||||
protected boolean light;
|
||||
private long objectId;
|
||||
private LatLon latLon;
|
||||
private boolean showNearestWiki = false;
|
||||
protected List<Amenity> nearestWiki = new ArrayList<>();
|
||||
|
||||
public class PlainMenuItem {
|
||||
private int iconId;
|
||||
|
@ -74,17 +94,40 @@ public class MenuBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
public MenuBuilder(OsmandApplication app) {
|
||||
this.app = app;
|
||||
public MenuBuilder(MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
this.app = mapActivity.getMyApplication();
|
||||
plainMenuItems = new LinkedList<>();
|
||||
}
|
||||
|
||||
public LatLon getLatLon() {
|
||||
return latLon;
|
||||
}
|
||||
|
||||
public void setLatLon(LatLon objectLocation) {
|
||||
this.latLon = objectLocation;
|
||||
}
|
||||
|
||||
public boolean isShowNearestWiki() {
|
||||
return showNearestWiki;
|
||||
}
|
||||
|
||||
public void setShowNearestWiki(boolean showNearestWiki) {
|
||||
this.showNearestWiki = showNearestWiki;
|
||||
}
|
||||
|
||||
public void setShowNearestWiki(boolean showNearestWiki, long objectId) {
|
||||
this.objectId = objectId;
|
||||
this.showNearestWiki = showNearestWiki;
|
||||
}
|
||||
|
||||
public void setLight(boolean light) {
|
||||
this.light = light;
|
||||
}
|
||||
|
||||
public void build(View view) {
|
||||
firstRow = true;
|
||||
buildNearestWikiRow(view);
|
||||
if (needBuildPlainMenuItems()) {
|
||||
buildPlainMenuItems(view);
|
||||
}
|
||||
|
@ -94,7 +137,8 @@ public class MenuBuilder {
|
|||
|
||||
protected void buildPlainMenuItems(View view) {
|
||||
for (PlainMenuItem item : plainMenuItems) {
|
||||
buildRow(view, item.getIconId(), item.getText(), 0, item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener());
|
||||
buildRow(view, item.getIconId(), item.getText(), 0, false, null,
|
||||
item.isNeedLinks(), 0, item.isUrl(), item.getOnClickListener());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -102,6 +146,14 @@ public class MenuBuilder {
|
|||
return true;
|
||||
}
|
||||
|
||||
protected void buildNearestWikiRow(View view) {
|
||||
if (processNearstWiki() && nearestWiki.size() > 0) {
|
||||
buildRow(view, R.drawable.ic_action_wikipedia, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", 0,
|
||||
true, getCollapsableWikiView(view.getContext(), true),
|
||||
false, 0, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
protected void buildInternal(View view) {
|
||||
}
|
||||
|
||||
|
@ -117,16 +169,26 @@ public class MenuBuilder {
|
|||
firstRow = false;
|
||||
}
|
||||
|
||||
protected View buildRow(View view, int iconId, String text, int textColor, boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
|
||||
return buildRow(view, getRowIcon(iconId), text, textColor, needLinks, textLinesLimit, isUrl, onClickListener);
|
||||
protected View buildRow(View view, int iconId, String text, int textColor,
|
||||
boolean collapsable, final View collapsableView,
|
||||
boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
|
||||
return buildRow(view, getRowIcon(iconId), text, textColor, collapsable, collapsableView,
|
||||
needLinks, textLinesLimit, isUrl, onClickListener);
|
||||
}
|
||||
|
||||
protected View buildRow(final View view, Drawable icon, final String text, int textColor, boolean needLinks, int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
|
||||
protected View buildRow(final View view, Drawable icon, final String text, int textColor,
|
||||
boolean collapsable, final View collapsableView, boolean needLinks,
|
||||
int textLinesLimit, boolean isUrl, OnClickListener onClickListener) {
|
||||
|
||||
if (!isFirstRow()) {
|
||||
buildRowDivider(view, false);
|
||||
}
|
||||
|
||||
LinearLayout baseView = new LinearLayout(view.getContext());
|
||||
baseView.setOrientation(LinearLayout.VERTICAL);
|
||||
LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
baseView.setLayoutParams(llBaseViewParams);
|
||||
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
@ -140,6 +202,8 @@ public class MenuBuilder {
|
|||
}
|
||||
});
|
||||
|
||||
baseView.addView(ll);
|
||||
|
||||
// Icon
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
@ -189,6 +253,38 @@ public class MenuBuilder {
|
|||
llText.setLayoutParams(llTextViewParams);
|
||||
llText.addView(textView);
|
||||
|
||||
final ImageView iconViewCollapse = new ImageView(view.getContext());
|
||||
if (collapsable && collapsableView != null) {
|
||||
// Icon
|
||||
LinearLayout llIconCollapse = new LinearLayout(view.getContext());
|
||||
llIconCollapse.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(40f), dpToPx(48f)));
|
||||
llIconCollapse.setOrientation(LinearLayout.HORIZONTAL);
|
||||
llIconCollapse.setGravity(Gravity.CENTER_VERTICAL);
|
||||
ll.addView(llIconCollapse);
|
||||
|
||||
LinearLayout.LayoutParams llIconCollapseParams = new LinearLayout.LayoutParams(dpToPx(24f), dpToPx(24f));
|
||||
llIconCollapseParams.setMargins(0, dpToPx(12f), dpToPx(32f), dpToPx(12f));
|
||||
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconViewCollapse.setLayoutParams(llIconCollapseParams);
|
||||
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(collapsableView.getVisibility() == View.GONE ?
|
||||
R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up));
|
||||
llIconCollapse.addView(iconViewCollapse);
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (collapsableView.getVisibility() == View.VISIBLE) {
|
||||
collapsableView.setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down));
|
||||
} else {
|
||||
collapsableView.setVisibility(View.VISIBLE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_up));
|
||||
}
|
||||
}
|
||||
});
|
||||
baseView.addView(collapsableView);
|
||||
}
|
||||
|
||||
if (onClickListener != null) {
|
||||
ll.setOnClickListener(onClickListener);
|
||||
} else if (isUrl) {
|
||||
|
@ -202,7 +298,7 @@ public class MenuBuilder {
|
|||
});
|
||||
}
|
||||
|
||||
((LinearLayout) view).addView(ll);
|
||||
((LinearLayout) view).addView(baseView);
|
||||
|
||||
rowBuilt();
|
||||
|
||||
|
@ -316,4 +412,92 @@ public class MenuBuilder {
|
|||
r.getDisplayMetrics()
|
||||
);
|
||||
}
|
||||
|
||||
protected View getCollapsableTextView(Context context, boolean collapsed, String text) {
|
||||
final TextView textView = new TextView(context);
|
||||
textView.setVisibility(collapsed ? View.GONE : View.VISIBLE);
|
||||
LinearLayout.LayoutParams llTextDescParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextDescParams.setMargins(dpToPx(72f), 0, dpToPx(40f), dpToPx(13f));
|
||||
textView.setLayoutParams(llTextDescParams);
|
||||
textView.setTextSize(16);
|
||||
textView.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
textView.setText(text);
|
||||
return textView;
|
||||
}
|
||||
|
||||
protected View getCollapsableWikiView(Context context, boolean collapsed) {
|
||||
final LinearLayout view = new LinearLayout(context);
|
||||
view.setOrientation(LinearLayout.VERTICAL);
|
||||
view.setVisibility(collapsed ? View.GONE : View.VISIBLE);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llParams.setMargins(dpToPx(68f), 0, dpToPx(12f), dpToPx(13f));
|
||||
view.setLayoutParams(llParams);
|
||||
|
||||
for (final Amenity wiki : nearestWiki) {
|
||||
AppCompatButton wikiButton = new AppCompatButton(
|
||||
new ContextThemeWrapper(view.getContext(), light ? R.style.OsmandLightTheme : R.style.OsmandDarkTheme));
|
||||
LinearLayout.LayoutParams llWikiButtonParams =
|
||||
new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
wikiButton.setLayoutParams(llWikiButtonParams);
|
||||
wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
|
||||
wikiButton.setTextColor(app.getResources()
|
||||
.getColor(light ? R.color.color_dialog_buttons_light : R.color.color_dialog_buttons_dark));
|
||||
wikiButton.setText(wiki.getName());
|
||||
|
||||
wikiButton.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
|
||||
wikiButton.setSingleLine(true);
|
||||
wikiButton.setEllipsize(TextUtils.TruncateAt.END);
|
||||
wikiButton.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
PointDescription pointDescription = mapActivity.getMapLayers().getPoiMapLayer().getObjectName(wiki);
|
||||
mapActivity.getContextMenu().show(
|
||||
new LatLon(wiki.getLocation().getLatitude(), wiki.getLocation().getLongitude()),
|
||||
pointDescription, wiki);
|
||||
}
|
||||
});
|
||||
view.addView(wikiButton);
|
||||
}
|
||||
|
||||
return view;
|
||||
}
|
||||
|
||||
protected boolean processNearstWiki() {
|
||||
if (showNearestWiki && latLon != null) {
|
||||
QuadRect rect = MapUtils.calculateLatLonBbox(
|
||||
latLon.getLatitude(), latLon.getLongitude(), 250);
|
||||
nearestWiki = app.getResourceManager().searchAmenities(
|
||||
new BinaryMapIndexReader.SearchPoiTypeFilter() {
|
||||
@Override
|
||||
public boolean accept(PoiCategory type, String subcategory) {
|
||||
return type.isWiki();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
return false;
|
||||
}
|
||||
}, rect.top, rect.left, rect.bottom, rect.right, -1, null);
|
||||
Collections.sort(nearestWiki, new Comparator<Amenity>() {
|
||||
|
||||
@Override
|
||||
public int compare(Amenity o1, Amenity o2) {
|
||||
double d1 = MapUtils.getDistance(latLon, o1.getLocation());
|
||||
double d2 = MapUtils.getDistance(latLon, o2.getLocation());
|
||||
return Double.compare(d1, d2);
|
||||
}
|
||||
});
|
||||
Long id = objectId;
|
||||
if (id != 0) {
|
||||
for (Amenity wiki : nearestWiki) {
|
||||
if (wiki.getId().equals(id)) {
|
||||
nearestWiki.remove(wiki);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import android.widget.LinearLayout;
|
|||
import net.osmand.IndexConstants;
|
||||
import net.osmand.NativeLibrary.RenderedObject;
|
||||
import net.osmand.binary.BinaryMapDataObject;
|
||||
import net.osmand.binary.BinaryMapIndexReader;
|
||||
import net.osmand.binary.BinaryMapIndexReader.TagValuePair;
|
||||
import net.osmand.binary.RouteDataObject;
|
||||
import net.osmand.data.Amenity;
|
||||
|
@ -123,47 +122,47 @@ public abstract class MenuController extends BaseMenuController {
|
|||
MenuController menuController = null;
|
||||
if (object != null) {
|
||||
if (object instanceof Amenity) {
|
||||
menuController = new AmenityMenuController(app, mapActivity, pointDescription, (Amenity) object);
|
||||
menuController = new AmenityMenuController(mapActivity, pointDescription, (Amenity) object);
|
||||
} else if (object instanceof FavouritePoint) {
|
||||
menuController = new FavouritePointMenuController(app, mapActivity, pointDescription, (FavouritePoint) object);
|
||||
menuController = new FavouritePointMenuController(mapActivity, pointDescription, (FavouritePoint) object);
|
||||
} else if (object instanceof SearchHistoryHelper.HistoryEntry) {
|
||||
menuController = new HistoryMenuController(app, mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
|
||||
menuController = new HistoryMenuController(mapActivity, pointDescription, (SearchHistoryHelper.HistoryEntry) object);
|
||||
} else if (object instanceof TargetPoint) {
|
||||
menuController = new TargetPointMenuController(app, mapActivity, pointDescription, (TargetPoint) object);
|
||||
menuController = new TargetPointMenuController(mapActivity, pointDescription, (TargetPoint) object);
|
||||
} else if (object instanceof OsMoDevice) {
|
||||
menuController = new OsMoMenuController(app, mapActivity, pointDescription, (OsMoDevice) object);
|
||||
menuController = new OsMoMenuController(mapActivity, pointDescription, (OsMoDevice) object);
|
||||
} else if (object instanceof Recording) {
|
||||
menuController = new AudioVideoNoteMenuController(app, mapActivity, pointDescription, (Recording) object);
|
||||
menuController = new AudioVideoNoteMenuController(mapActivity, pointDescription, (Recording) object);
|
||||
} else if (object instanceof OsmPoint) {
|
||||
menuController = new EditPOIMenuController(app, mapActivity, pointDescription, (OsmPoint) object);
|
||||
menuController = new EditPOIMenuController(mapActivity, pointDescription, (OsmPoint) object);
|
||||
} else if (object instanceof WptPt) {
|
||||
menuController = new WptPtMenuController(app, mapActivity, pointDescription, (WptPt) object);
|
||||
menuController = new WptPtMenuController(mapActivity, pointDescription, (WptPt) object);
|
||||
} else if (object instanceof DownloadMapObject) {
|
||||
menuController = new MapDataMenuController(app, mapActivity, pointDescription, (DownloadMapObject) object);
|
||||
menuController = new MapDataMenuController(mapActivity, pointDescription, (DownloadMapObject) object);
|
||||
} else if (object instanceof OpenStreetNote) {
|
||||
menuController = new OsmBugMenuController(app, mapActivity, pointDescription, (OpenStreetNote) object);
|
||||
menuController = new OsmBugMenuController(mapActivity, pointDescription, (OpenStreetNote) object);
|
||||
} else if (object instanceof GpxDisplayItem) {
|
||||
menuController = new GpxItemMenuController(app, mapActivity, pointDescription, (GpxDisplayItem) object);
|
||||
menuController = new GpxItemMenuController(mapActivity, pointDescription, (GpxDisplayItem) object);
|
||||
} else if (object instanceof MapMarker) {
|
||||
menuController = new MapMarkerMenuController(app, mapActivity, pointDescription, (MapMarker) object);
|
||||
menuController = new MapMarkerMenuController(mapActivity, pointDescription, (MapMarker) object);
|
||||
} else if (object instanceof TransportStopRoute) {
|
||||
menuController = new TransportRouteController(app, mapActivity, pointDescription, (TransportStopRoute) object);
|
||||
menuController = new TransportRouteController(mapActivity, pointDescription, (TransportStopRoute) object);
|
||||
} else if (object instanceof TransportStop) {
|
||||
menuController = new TransportStopController(app, mapActivity, pointDescription, (TransportStop) object);
|
||||
menuController = new TransportStopController(mapActivity, pointDescription, (TransportStop) object);
|
||||
} else if (object instanceof LatLon) {
|
||||
if (pointDescription.isParking()) {
|
||||
menuController = new ParkingPositionMenuController(app, mapActivity, pointDescription);
|
||||
menuController = new ParkingPositionMenuController(mapActivity, pointDescription);
|
||||
} else if (pointDescription.isMyLocation()) {
|
||||
menuController = new MyLocationMenuController(app, mapActivity, pointDescription);
|
||||
menuController = new MyLocationMenuController(mapActivity, pointDescription);
|
||||
}
|
||||
} else if (object instanceof RouteDataObject) {
|
||||
menuController = new ImpassibleRoadsMenuController(app, mapActivity, pointDescription, (RouteDataObject) object);
|
||||
menuController = new ImpassibleRoadsMenuController(mapActivity, pointDescription, (RouteDataObject) object);
|
||||
} else if (object instanceof RenderedObject) {
|
||||
menuController = new RenderedObjectMenuController(app, mapActivity, pointDescription, (RenderedObject) object);
|
||||
menuController = new RenderedObjectMenuController(mapActivity, pointDescription, (RenderedObject) object);
|
||||
}
|
||||
}
|
||||
if (menuController == null) {
|
||||
menuController = new PointDescriptionMenuController(app, mapActivity, pointDescription);
|
||||
menuController = new PointDescriptionMenuController(mapActivity, pointDescription);
|
||||
}
|
||||
menuController.menuType = menuType;
|
||||
menuController.setLatLon(latLon);
|
||||
|
@ -205,7 +204,7 @@ public abstract class MenuController extends BaseMenuController {
|
|||
|
||||
protected void addMyLocationToPlainItems(LatLon latLon) {
|
||||
addPlainMenuItem(R.drawable.ic_action_get_my_location, PointDescription.getLocationName(getMapActivity(),
|
||||
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", ""), false, false, null);
|
||||
latLon.getLatitude(), latLon.getLongitude(), true).replaceAll("\n", " "), false, false, null);
|
||||
}
|
||||
|
||||
public PointDescription getPointDescription() {
|
||||
|
@ -502,6 +501,9 @@ public abstract class MenuController extends BaseMenuController {
|
|||
|
||||
public void setLatLon(@NonNull LatLon latLon) {
|
||||
this.latLon = latLon;
|
||||
if (builder != null) {
|
||||
builder.setLatLon(latLon);
|
||||
}
|
||||
}
|
||||
|
||||
public void buildMapDownloadButton(LatLon latLon) {
|
||||
|
@ -538,22 +540,29 @@ public abstract class MenuController extends BaseMenuController {
|
|||
}
|
||||
String selectedFullName = "";
|
||||
double smallestArea = -1;
|
||||
downloadMapDataObject = null;
|
||||
for (BinaryMapDataObject o : mapDataObjects) {
|
||||
boolean downloaded = checkIfObjectDownloaded(rm, osmandRegions.getDownloadName(o));
|
||||
if (downloaded) {
|
||||
downloadMapDataObject = null;
|
||||
break;
|
||||
} else {
|
||||
String fullName = osmandRegions.getFullName(o);
|
||||
double area = OsmandRegions.getArea(o);
|
||||
if (smallestArea == -1) {
|
||||
smallestArea = area;
|
||||
selectedFullName = fullName;
|
||||
downloadMapDataObject = o;
|
||||
} else if (area < smallestArea) {
|
||||
smallestArea = area;
|
||||
selectedFullName = fullName;
|
||||
downloadMapDataObject = o;
|
||||
String downloadName = osmandRegions.getDownloadName(o);
|
||||
if (!Algorithms.isEmpty(downloadName)) {
|
||||
boolean downloaded = checkIfObjectDownloaded(rm, downloadName);
|
||||
if (downloaded) {
|
||||
downloadMapDataObject = null;
|
||||
break;
|
||||
} else {
|
||||
String fullName = osmandRegions.getFullName(o);
|
||||
WorldRegion region = osmandRegions.getRegionData(fullName);
|
||||
if (region != null && region.isRegionMapDownload()) {
|
||||
double area = OsmandRegions.getArea(o);
|
||||
if (smallestArea == -1) {
|
||||
smallestArea = area;
|
||||
selectedFullName = fullName;
|
||||
downloadMapDataObject = o;
|
||||
} else if (area < smallestArea) {
|
||||
smallestArea = area;
|
||||
selectedFullName = fullName;
|
||||
downloadMapDataObject = o;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -612,7 +621,14 @@ public abstract class MenuController extends BaseMenuController {
|
|||
+ IndexConstants.BINARY_MAP_INDEX_EXT;
|
||||
final String roadsRegionName = Algorithms.capitalizeFirstLetterAndLowercase(downloadName) + ".road"
|
||||
+ IndexConstants.BINARY_MAP_INDEX_EXT;
|
||||
return rm.getIndexFileNames().containsKey(regionName) || rm.getIndexFileNames().containsKey(roadsRegionName);
|
||||
boolean downloaded = rm.getIndexFileNames().containsKey(regionName) || rm.getIndexFileNames().containsKey(roadsRegionName);
|
||||
if (!downloaded) {
|
||||
WorldRegion region = rm.getOsmandRegions().getRegionDataByDownloadName(downloadName);
|
||||
if (region != null && region.getSuperregion() != null && region.getSuperregion().isRegionMapDownload()) {
|
||||
return checkIfObjectDownloaded(rm, region.getSuperregion().getRegionDownloadName());
|
||||
}
|
||||
}
|
||||
return downloaded;
|
||||
}
|
||||
|
||||
public static class ContextMenuToolbarController extends TopToolbarController {
|
||||
|
|
|
@ -24,8 +24,8 @@ import net.osmand.data.PointDescription;
|
|||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.views.POIMapLayer;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -42,21 +42,26 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
private final Amenity amenity;
|
||||
|
||||
public AmenityMenuBuilder(OsmandApplication app, final Amenity amenity) {
|
||||
super(app);
|
||||
public AmenityMenuBuilder(MapActivity mapActivity, final Amenity amenity) {
|
||||
super(mapActivity);
|
||||
this.amenity = amenity;
|
||||
setShowNearestWiki(true, amenity.getId());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildNearestWikiRow(View view) {
|
||||
}
|
||||
|
||||
private void buildRow(View view, int iconId, String text, String textPrefix,
|
||||
final String textDescription, boolean collapsable,
|
||||
boolean collapsable, final View collapsableView,
|
||||
int textColor, boolean isWiki, boolean isText, boolean needLinks,
|
||||
boolean isPhoneNumber, boolean isUrl) {
|
||||
buildRow(view, getRowIcon(iconId), text, textPrefix, textDescription, collapsable, textColor,
|
||||
buildRow(view, getRowIcon(iconId), text, textPrefix, collapsable, collapsableView, textColor,
|
||||
isWiki, isText, needLinks, isPhoneNumber, isUrl);
|
||||
}
|
||||
|
||||
protected void buildRow(final View view, Drawable icon, final String text, final String textPrefix,
|
||||
final String textDescription, boolean collapsable,
|
||||
boolean collapsable, final View collapsableView,
|
||||
int textColor, boolean isWiki, boolean isText, boolean needLinks,
|
||||
boolean isPhoneNumber, boolean isUrl) {
|
||||
|
||||
|
@ -71,6 +76,11 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
txt = text;
|
||||
}
|
||||
|
||||
LinearLayout baseView = new LinearLayout(view.getContext());
|
||||
baseView.setOrientation(LinearLayout.VERTICAL);
|
||||
LinearLayout.LayoutParams llBaseViewParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
baseView.setLayoutParams(llBaseViewParams);
|
||||
|
||||
LinearLayout ll = new LinearLayout(view.getContext());
|
||||
ll.setOrientation(LinearLayout.HORIZONTAL);
|
||||
LinearLayout.LayoutParams llParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
|
@ -84,6 +94,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
}
|
||||
});
|
||||
|
||||
baseView.addView(ll);
|
||||
|
||||
// Icon
|
||||
LinearLayout llIcon = new LinearLayout(view.getContext());
|
||||
llIcon.setOrientation(LinearLayout.HORIZONTAL);
|
||||
|
@ -149,7 +161,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
llText.addView(textView);
|
||||
|
||||
final ImageView iconViewCollapse = new ImageView(view.getContext());
|
||||
if (collapsable && !Algorithms.isEmpty(textDescription)) {
|
||||
if (collapsable && collapsableView != null) {
|
||||
// Icon
|
||||
LinearLayout llIconCollapse = new LinearLayout(view.getContext());
|
||||
llIconCollapse.setLayoutParams(new LinearLayout.LayoutParams(dpToPx(40f), dpToPx(48f)));
|
||||
|
@ -162,47 +174,28 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
llIconCollapseParams.gravity = Gravity.CENTER_VERTICAL;
|
||||
iconViewCollapse.setLayoutParams(llIconCollapseParams);
|
||||
iconViewCollapse.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(iconViewCollapse.getTag() == null ?
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(collapsableView.getVisibility() == View.GONE ?
|
||||
R.drawable.ic_action_arrow_down : R.drawable.ic_action_arrow_up));
|
||||
llIconCollapse.addView(iconViewCollapse);
|
||||
}
|
||||
|
||||
if (!Algorithms.isEmpty(textDescription)) {
|
||||
final TextView textViewDesc = new TextView(view.getContext());
|
||||
boolean collapsed = false;
|
||||
if (collapsable) {
|
||||
collapsed = textView.getTag() == null;
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (iconViewCollapse.getTag() != null) {
|
||||
textViewDesc.setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down));
|
||||
iconViewCollapse.setTag(null);
|
||||
} else {
|
||||
textViewDesc.setVisibility(View.VISIBLE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_up));
|
||||
iconViewCollapse.setTag(1);
|
||||
}
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (collapsableView.getVisibility() == View.VISIBLE) {
|
||||
collapsableView.setVisibility(View.GONE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_down));
|
||||
} else {
|
||||
collapsableView.setVisibility(View.VISIBLE);
|
||||
iconViewCollapse.setImageDrawable(app.getIconsCache().getThemedIcon(R.drawable.ic_action_arrow_up));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
textViewDesc.setVisibility(collapsed ? View.GONE : View.VISIBLE);
|
||||
LinearLayout.LayoutParams llTextDescParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llTextDescParams.setMargins(0, 0, 0, collapsable ? dpToPx(13f) : dpToPx(8f));
|
||||
textViewDesc.setLayoutParams(llTextDescParams);
|
||||
textViewDesc.setTextSize(16);
|
||||
textViewDesc.setTextColor(app.getResources().getColor(light ? R.color.ctx_menu_info_text_light : R.color.ctx_menu_info_text_dark));
|
||||
textViewDesc.setText(textDescription);
|
||||
|
||||
llText.addView(textViewDesc);
|
||||
}
|
||||
});
|
||||
baseView.addView(collapsableView);
|
||||
}
|
||||
|
||||
if (isWiki) {
|
||||
AppCompatButton wikiButton = new AppCompatButton(view.getContext());
|
||||
LinearLayout.LayoutParams llWikiButtonParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
|
||||
llWikiButtonParams.setMargins(0, dpToPx(10f), 0, dpToPx(10f));
|
||||
llWikiButtonParams.setMargins(0, dpToPx(10f), dpToPx(2f), dpToPx(10f));
|
||||
wikiButton.setLayoutParams(llWikiButtonParams);
|
||||
wikiButton.setPadding(dpToPx(14f), 0, dpToPx(14f), 0);
|
||||
wikiButton.setBackgroundResource(R.drawable.blue_button_drawable);
|
||||
|
@ -217,7 +210,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
llText.addView(wikiButton);
|
||||
}
|
||||
|
||||
((LinearLayout) view).addView(ll);
|
||||
((LinearLayout) view).addView(baseView);
|
||||
|
||||
if (isPhoneNumber) {
|
||||
ll.setOnClickListener(new View.OnClickListener() {
|
||||
|
@ -290,7 +283,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
String vl = e.getValue();
|
||||
|
||||
String textPrefix = "";
|
||||
String textDescription = "";
|
||||
View collapsableView = null;
|
||||
boolean collapsable = false;
|
||||
boolean isWiki = false;
|
||||
boolean isText = false;
|
||||
|
@ -325,7 +318,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
final String langSelected = lng;
|
||||
String content = amenity.getDescription(langSelected);
|
||||
vl = Html.fromHtml(content).toString();
|
||||
vl = (content != null) ? Html.fromHtml(content).toString() : "";
|
||||
if (vl.length() > 300) {
|
||||
vl = vl.substring(0, 300);
|
||||
}
|
||||
|
@ -339,7 +332,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
continue;
|
||||
} else if (Amenity.OPENING_HOURS.equals(key)) {
|
||||
iconId = R.drawable.ic_action_time;
|
||||
textDescription = amenity.getOpeningHours();
|
||||
collapsableView = getCollapsableTextView(view.getContext(), true, amenity.getOpeningHours());
|
||||
collapsable = true;
|
||||
OpeningHoursParser.OpeningHours rs = OpeningHoursParser.parseOpenedHours(amenity.getOpeningHours());
|
||||
if (rs != null) {
|
||||
|
@ -418,12 +411,12 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
if (isDescription) {
|
||||
descriptions.add(new AmenityInfoRow(key, R.drawable.ic_action_note_dark, textPrefix,
|
||||
vl, textDescription, collapsable, 0, false, true, true, 0, "", false, false));
|
||||
vl, collapsable, collapsableView, 0, false, true, true, 0, "", false, false));
|
||||
} else if (icon != null) {
|
||||
infoRows.add(new AmenityInfoRow(key, icon, textPrefix, vl, textDescription, collapsable,
|
||||
infoRows.add(new AmenityInfoRow(key, icon, textPrefix, vl, collapsable, collapsableView,
|
||||
textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl));
|
||||
} else {
|
||||
infoRows.add(new AmenityInfoRow(key, iconId, textPrefix, vl, textDescription, collapsable,
|
||||
infoRows.add(new AmenityInfoRow(key, iconId, textPrefix, vl, collapsable, collapsableView,
|
||||
textColor, isWiki, isText, needLinks, poiTypeOrder, poiTypeKeyName, isPhoneNumber, isUrl));
|
||||
}
|
||||
}
|
||||
|
@ -463,17 +456,25 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
buildAmenityRow(view, info);
|
||||
}
|
||||
|
||||
if (processNearstWiki() && nearestWiki.size() > 0) {
|
||||
AmenityInfoRow wikiInfo = new AmenityInfoRow(
|
||||
"nearest_wiki", R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size()+")", true,
|
||||
getCollapsableWikiView(view.getContext(), true),
|
||||
0, false, false, false, 1000, null, false, false);
|
||||
buildAmenityRow(view, wikiInfo);
|
||||
}
|
||||
|
||||
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app,
|
||||
amenity.getLocation().getLatitude(), amenity.getLocation().getLongitude(), true)
|
||||
.replaceAll("\n", ""), 0, false, 0, false, null);
|
||||
.replaceAll("\n", " "), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
|
||||
public void buildAmenityRow(View view, AmenityInfoRow info) {
|
||||
if (info.icon != null) {
|
||||
buildRow(view, info.icon, info.text, info.textPrefix, info.textDescription, info.collapsable,
|
||||
buildRow(view, info.icon, info.text, info.textPrefix, info.collapsable, info.collapsableView,
|
||||
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl);
|
||||
} else if (info.iconId != 0) {
|
||||
buildRow(view, info.iconId, info.text, info.textPrefix, info.textDescription, info.collapsable,
|
||||
buildRow(view, info.iconId, info.text, info.textPrefix, info.collapsable, info.collapsableView,
|
||||
info.textColor, info.isWiki, info.isText, info.needLinks, info.isPhoneNumber, info.isUrl);
|
||||
}
|
||||
}
|
||||
|
@ -484,7 +485,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
private int iconId;
|
||||
private String textPrefix;
|
||||
private String text;
|
||||
private String textDescription;
|
||||
private View collapsableView;
|
||||
private boolean collapsable;
|
||||
private int textColor;
|
||||
private boolean isWiki;
|
||||
|
@ -496,15 +497,15 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
private String name;
|
||||
|
||||
public AmenityInfoRow(String key, Drawable icon, String textPrefix, String text,
|
||||
String textDescription, boolean collapsable,
|
||||
boolean collapsable, View collapsableView,
|
||||
int textColor, boolean isWiki, boolean isText, boolean needLinks,
|
||||
int order, String name, boolean isPhoneNumber, boolean isUrl) {
|
||||
this.key = key;
|
||||
this.icon = icon;
|
||||
this.textPrefix = textPrefix;
|
||||
this.text = text;
|
||||
this.textDescription = textDescription;
|
||||
this.collapsable = collapsable;
|
||||
this.collapsableView = collapsableView;
|
||||
this.textColor = textColor;
|
||||
this.isWiki = isWiki;
|
||||
this.isText = isText;
|
||||
|
@ -516,15 +517,15 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
}
|
||||
|
||||
public AmenityInfoRow(String key, int iconId, String textPrefix, String text,
|
||||
String textDescription, boolean collapsable,
|
||||
boolean collapsable, View collapsableView,
|
||||
int textColor, boolean isWiki, boolean isText, boolean needLinks,
|
||||
int order, String name, boolean isPhoneNumber, boolean isUrl) {
|
||||
this.key = key;
|
||||
this.iconId = iconId;
|
||||
this.textPrefix = textPrefix;
|
||||
this.text = text;
|
||||
this.textDescription = textDescription;
|
||||
this.collapsable = collapsable;
|
||||
this.collapsableView = collapsableView;
|
||||
this.textColor = textColor;
|
||||
this.isWiki = isWiki;
|
||||
this.isText = isText;
|
||||
|
|
|
@ -9,7 +9,7 @@ import net.osmand.data.FavouritePoint;
|
|||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.util.MapUtils;
|
||||
|
||||
|
@ -20,9 +20,10 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
private final FavouritePoint fav;
|
||||
private Object originObject;
|
||||
|
||||
public FavouritePointMenuBuilder(OsmandApplication app, final FavouritePoint fav) {
|
||||
super(app);
|
||||
public FavouritePointMenuBuilder(MapActivity mapActivity, final FavouritePoint fav) {
|
||||
super(mapActivity);
|
||||
this.fav = fav;
|
||||
setShowNearestWiki(true);
|
||||
acquireOriginObject();
|
||||
}
|
||||
|
||||
|
@ -42,14 +43,20 @@ public class FavouritePointMenuBuilder extends MenuBuilder {
|
|||
return originObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void buildNearestWikiRow(View view) {
|
||||
if (originObject == null || !(originObject instanceof Amenity)) {
|
||||
super.buildNearestWikiRow(view);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void buildInternal(View view) {
|
||||
if (originObject != null) {
|
||||
if (originObject instanceof Amenity) {
|
||||
AmenityMenuBuilder builder = new AmenityMenuBuilder(app, (Amenity) originObject);
|
||||
builder.setLight(light);
|
||||
builder.buildInternal(view);
|
||||
}
|
||||
if (originObject != null && originObject instanceof Amenity) {
|
||||
AmenityMenuBuilder builder = new AmenityMenuBuilder(mapActivity, (Amenity) originObject);
|
||||
builder.setLatLon(getLatLon());
|
||||
builder.setLight(light);
|
||||
builder.buildInternal(view);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.GpxUiHelper;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -19,8 +19,8 @@ import net.osmand.util.Algorithms;
|
|||
public class GpxItemMenuBuilder extends MenuBuilder {
|
||||
private GpxDisplayItem item;
|
||||
|
||||
public GpxItemMenuBuilder(OsmandApplication app, GpxDisplayItem item) {
|
||||
super(app);
|
||||
public GpxItemMenuBuilder(MapActivity mapActivity, GpxDisplayItem item) {
|
||||
super(mapActivity);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
|
@ -34,7 +34,7 @@ public class GpxItemMenuBuilder extends MenuBuilder {
|
|||
String description = GpxUiHelper.getDescription(app, item.analysis, false);
|
||||
String[] lines = description.split("\n");
|
||||
for (String line : lines) {
|
||||
buildRow(view, R.drawable.ic_action_info_dark, line, 0, false, 0, false, null);
|
||||
buildRow(view, R.drawable.ic_action_info_dark, line, 0, false, null, false, 0, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -4,8 +4,8 @@ import android.view.View;
|
|||
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.views.POIMapLayer;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
@ -17,9 +17,10 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
|||
|
||||
private final WptPt wpt;
|
||||
|
||||
public WptPtMenuBuilder(OsmandApplication app, final WptPt wpt) {
|
||||
super(app);
|
||||
public WptPtMenuBuilder(MapActivity mapActivity, final WptPt wpt) {
|
||||
super(mapActivity);
|
||||
this.wpt = wpt;
|
||||
setShowNearestWiki(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -34,23 +35,23 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
|||
DateFormat timeFormat = android.text.format.DateFormat.getTimeFormat(view.getContext());
|
||||
Date date = new Date(wpt.time);
|
||||
buildRow(view, R.drawable.ic_action_data,
|
||||
dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, 0, false, null);
|
||||
dateFormat.format(date) + " — " + timeFormat.format(date), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
if (wpt.speed > 0) {
|
||||
buildRow(view, R.drawable.ic_action_speed,
|
||||
OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, 0, false, null);
|
||||
OsmAndFormatter.getFormattedSpeed((float)wpt.speed, app), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
if (!Double.isNaN(wpt.ele)) {
|
||||
buildRow(view, R.drawable.ic_action_altitude,
|
||||
OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, 0, false, null);
|
||||
OsmAndFormatter.getFormattedDistance((float) wpt.ele, app), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
if (!Double.isNaN(wpt.hdop)) {
|
||||
buildRow(view, R.drawable.ic_action_gps_info,
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": "
|
||||
+ OsmAndFormatter.getFormattedDistance((float)wpt.hdop, app), 0, false, 0, false, null);
|
||||
Algorithms.capitalizeFirstLetterAndLowercase(app.getString(R.string.plugin_distance_point_hdop)) + ": " + (int)wpt.hdop, 0,
|
||||
false, null, false, 0, false, null);
|
||||
}
|
||||
if (!Algorithms.isEmpty(wpt.desc)) {
|
||||
final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, true, 10, false, null);
|
||||
final View row = buildRow(view, R.drawable.ic_action_note_dark, wpt.desc, 0, false, null, true, 10, false, null);
|
||||
row.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
@ -60,7 +61,8 @@ public class WptPtMenuBuilder extends MenuBuilder {
|
|||
});
|
||||
}
|
||||
if (!Algorithms.isEmpty(wpt.comment)) {
|
||||
final View rowc = buildRow(view, R.drawable.ic_action_note_dark, wpt.comment, 0, true, 10, false, null);
|
||||
final View rowc = buildRow(view, R.drawable.ic_action_note_dark, wpt.comment, 0,
|
||||
false, null, true, 10, false, null);
|
||||
rowc.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
|
|
@ -11,7 +11,6 @@ import net.osmand.data.TransportStop;
|
|||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiFilter;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
|
@ -36,8 +35,8 @@ public class AmenityMenuController extends MenuController {
|
|||
private Amenity amenity;
|
||||
private List<TransportStopRoute> routes = new ArrayList<>();
|
||||
|
||||
public AmenityMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, Amenity amenity) {
|
||||
super(new AmenityMenuBuilder(app, amenity), pointDescription, mapActivity);
|
||||
public AmenityMenuController(MapActivity mapActivity, PointDescription pointDescription, Amenity amenity) {
|
||||
super(new AmenityMenuBuilder(mapActivity, amenity), pointDescription, mapActivity);
|
||||
this.amenity = amenity;
|
||||
if (amenity.getType().getKeyName().equals("transportation")) {
|
||||
boolean showTransportStops = false;
|
||||
|
@ -68,11 +67,6 @@ public class AmenityMenuController extends MenuController {
|
|||
return amenity;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needStreetName() {
|
||||
if (amenity.getSubType() != null && amenity.getType() != null) {
|
||||
|
|
|
@ -8,7 +8,6 @@ import net.osmand.data.FavouritePoint;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
|
@ -22,8 +21,8 @@ public class FavouritePointMenuController extends MenuController {
|
|||
|
||||
private FavouritePoint fav;
|
||||
|
||||
public FavouritePointMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
|
||||
super(new FavouritePointMenuBuilder(app, fav), pointDescription, mapActivity);
|
||||
public FavouritePointMenuController(MapActivity mapActivity, PointDescription pointDescription, final FavouritePoint fav) {
|
||||
super(new FavouritePointMenuBuilder(mapActivity, fav), pointDescription, mapActivity);
|
||||
this.fav = fav;
|
||||
}
|
||||
|
||||
|
@ -39,11 +38,6 @@ public class FavouritePointMenuController extends MenuController {
|
|||
return fav;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean handleSingleTapOnMap() {
|
||||
Fragment fragment = getMapActivity().getSupportFragmentManager().findFragmentByTag(FavoritePointEditor.TAG);
|
||||
|
@ -112,7 +106,7 @@ public class FavouritePointMenuController extends MenuController {
|
|||
} else if (originObject instanceof TransportStop) {
|
||||
TransportStop stop = (TransportStop) originObject;
|
||||
TransportStopController transportStopController =
|
||||
new TransportStopController(getMapActivity().getMyApplication(), getMapActivity(), pointDescription, stop);
|
||||
new TransportStopController(getMapActivity(), pointDescription, stop);
|
||||
transportStopController.addPlainMenuItems(builder, latLon);
|
||||
addMyLocationToPlainItems(latLon);
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.graphics.drawable.Drawable;
|
|||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItem;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
|
@ -13,8 +12,8 @@ import net.osmand.plus.mapcontextmenu.builders.GpxItemMenuBuilder;
|
|||
public class GpxItemMenuController extends MenuController {
|
||||
private GpxDisplayItem item;
|
||||
|
||||
public GpxItemMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, GpxDisplayItem item) {
|
||||
super(new GpxItemMenuBuilder(app, item), pointDescription, mapActivity);
|
||||
public GpxItemMenuController(MapActivity mapActivity, PointDescription pointDescription, GpxDisplayItem item) {
|
||||
super(new GpxItemMenuBuilder(mapActivity, item), pointDescription, mapActivity);
|
||||
this.item = item;
|
||||
}
|
||||
|
||||
|
@ -30,11 +29,6 @@ public class GpxItemMenuController extends MenuController {
|
|||
return item;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return getPointDescription().getTypeName();
|
||||
|
|
|
@ -2,8 +2,8 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.search.SearchHistoryFragment;
|
||||
|
@ -17,9 +17,10 @@ public class HistoryMenuController extends MenuController {
|
|||
private HistoryEntry entry;
|
||||
private boolean hasTypeInDescription;
|
||||
|
||||
public HistoryMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final HistoryEntry entry) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public HistoryMenuController(MapActivity mapActivity, PointDescription pointDescription, final HistoryEntry entry) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.entry = entry;
|
||||
builder.setShowNearestWiki(true);
|
||||
initData();
|
||||
}
|
||||
|
||||
|
@ -40,11 +41,6 @@ public class HistoryMenuController extends MenuController {
|
|||
return entry;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayStreetNameInTitle() {
|
||||
return entry.getName().isLocation();
|
||||
|
|
|
@ -16,10 +16,11 @@ public class ImpassibleRoadsMenuController extends MenuController {
|
|||
|
||||
private RouteDataObject route;
|
||||
|
||||
public ImpassibleRoadsMenuController(final OsmandApplication app, final MapActivity mapActivity,
|
||||
public ImpassibleRoadsMenuController(final MapActivity mapActivity,
|
||||
PointDescription pointDescription, RouteDataObject route) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.route = route;
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
rightTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
|
|
|
@ -52,11 +52,12 @@ public class MapDataMenuController extends MenuController {
|
|||
|
||||
private DownloadIndexesThread downloadThread;
|
||||
|
||||
public MapDataMenuController(final OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription, final DownloadMapObject mapObject) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public MapDataMenuController(final MapActivity mapActivity, PointDescription pointDescription, final DownloadMapObject mapObject) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.mapObject = mapObject;
|
||||
indexItem = mapObject.getIndexItem();
|
||||
localIndexInfo = mapObject.getLocalIndexInfo();
|
||||
final OsmandApplication app = mapActivity.getMyApplication();
|
||||
downloadThread = app.getDownloadThread();
|
||||
if (indexItem != null) {
|
||||
downloaded = indexItem.isDownloaded();
|
||||
|
|
|
@ -2,10 +2,10 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.MapMarkersHelper;
|
||||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.MapMarkerDialogHelper;
|
||||
|
@ -17,10 +17,11 @@ public class MapMarkerMenuController extends MenuController {
|
|||
|
||||
private MapMarker mapMarker;
|
||||
|
||||
public MapMarkerMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, MapMarker mapMarker) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public MapMarkerMenuController(MapActivity mapActivity, PointDescription pointDescription, MapMarker mapMarker) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.mapMarker = mapMarker;
|
||||
final MapMarkersHelper markersHelper = app.getMapMarkersHelper();
|
||||
builder.setShowNearestWiki(true);
|
||||
final MapMarkersHelper markersHelper = mapActivity.getMyApplication().getMapMarkersHelper();
|
||||
leftTitleButtonController = new TitleButtonController() {
|
||||
@Override
|
||||
public void buttonPressed() {
|
||||
|
@ -49,11 +50,6 @@ public class MapMarkerMenuController extends MenuController {
|
|||
return mapMarker;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needTypeStr() {
|
||||
return !Algorithms.isEmpty(getNameStr());
|
||||
|
|
|
@ -2,10 +2,8 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
|
@ -13,8 +11,9 @@ import net.osmand.plus.mapcontextmenu.MenuController;
|
|||
|
||||
public class MyLocationMenuController extends MenuController {
|
||||
|
||||
public MyLocationMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public MyLocationMenuController(MapActivity mapActivity, PointDescription pointDescription) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
builder.setShowNearestWiki(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -26,11 +25,6 @@ public class MyLocationMenuController extends MenuController {
|
|||
return getLatLon();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getTypeStr() {
|
||||
return getPointDescription().getTypeName();
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.activities.search.SearchHistoryFragment;
|
||||
|
@ -15,8 +14,9 @@ public class PointDescriptionMenuController extends MenuController {
|
|||
|
||||
private boolean hasTypeInDescription;
|
||||
|
||||
public PointDescriptionMenuController(OsmandApplication app, MapActivity mapActivity, final PointDescription pointDescription) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public PointDescriptionMenuController(MapActivity mapActivity, final PointDescription pointDescription) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
builder.setShowNearestWiki(true);
|
||||
initData();
|
||||
}
|
||||
|
||||
|
@ -34,11 +34,6 @@ public class PointDescriptionMenuController extends MenuController {
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayStreetNameInTitle() {
|
||||
return true;
|
||||
|
|
|
@ -2,7 +2,6 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
|
||||
import net.osmand.NativeLibrary.RenderedObject;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
|
@ -14,8 +13,9 @@ public class RenderedObjectMenuController extends MenuController {
|
|||
|
||||
private RenderedObject renderedObject;
|
||||
|
||||
public RenderedObjectMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, final RenderedObject renderedObject) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public RenderedObjectMenuController(MapActivity mapActivity, PointDescription pointDescription, final RenderedObject renderedObject) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
builder.setShowNearestWiki(true);
|
||||
this.renderedObject = renderedObject;
|
||||
}
|
||||
|
||||
|
@ -31,11 +31,6 @@ public class RenderedObjectMenuController extends MenuController {
|
|||
return renderedObject;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean displayStreetNameInTitle() {
|
||||
return Algorithms.isEmpty(getNameStr());
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.mapcontextmenu.controllers;
|
|||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.TargetPointsHelper.TargetPoint;
|
||||
|
@ -17,9 +16,10 @@ public class TargetPointMenuController extends MenuController {
|
|||
|
||||
private TargetPoint targetPoint;
|
||||
|
||||
public TargetPointMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, TargetPoint targetPoint) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public TargetPointMenuController(MapActivity mapActivity, PointDescription pointDescription, TargetPoint targetPoint) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.targetPoint = targetPoint;
|
||||
builder.setShowNearestWiki(true);
|
||||
final TargetPointsHelper targetPointsHelper = getMapActivity().getMyApplication().getTargetPointsHelper();
|
||||
final int intermediatePointsCount = targetPointsHelper.getIntermediatePoints().size();
|
||||
RoutingHelper routingHelper = getMapActivity().getMyApplication().getRoutingHelper();
|
||||
|
@ -67,11 +67,6 @@ public class TargetPointMenuController extends MenuController {
|
|||
return targetPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needTypeStr() {
|
||||
return !Algorithms.isEmpty(getNameStr());
|
||||
|
|
|
@ -7,7 +7,6 @@ import net.osmand.binary.OsmandOdb.TransportRouteStop;
|
|||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
|
@ -24,9 +23,9 @@ public class TransportRouteController extends MenuController {
|
|||
|
||||
private TransportStopRoute transportRoute;
|
||||
|
||||
public TransportRouteController(OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription,
|
||||
public TransportRouteController(final MapActivity mapActivity, PointDescription pointDescription,
|
||||
final TransportStopRoute transportRoute) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.transportRoute = transportRoute;
|
||||
toolbarController = new ContextMenuToolbarController(this);
|
||||
toolbarController.setTitle(getNameStr());
|
||||
|
@ -62,11 +61,6 @@ public class TransportRouteController extends MenuController {
|
|||
return transportRoute;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLeftIconId() {
|
||||
return this.transportRoute.type == null ?
|
||||
|
|
|
@ -78,9 +78,9 @@ public class TransportStopController extends MenuController {
|
|||
private List<TransportStopRoute> routes = new ArrayList<>();
|
||||
private TransportStopType topType;
|
||||
|
||||
public TransportStopController(OsmandApplication app, MapActivity mapActivity,
|
||||
public TransportStopController(MapActivity mapActivity,
|
||||
PointDescription pointDescription, TransportStop transportStop) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.transportStop = transportStop;
|
||||
processTransportStop();
|
||||
}
|
||||
|
@ -98,11 +98,6 @@ public class TransportStopController extends MenuController {
|
|||
return transportStop;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLeftIconId() {
|
||||
if (topType == null) {
|
||||
|
|
|
@ -5,7 +5,6 @@ import android.support.v4.content.ContextCompat;
|
|||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.GPXUtilities.WptPt;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.base.FavoriteImageDrawable;
|
||||
|
@ -17,8 +16,8 @@ public class WptPtMenuController extends MenuController {
|
|||
|
||||
private WptPt wpt;
|
||||
|
||||
public WptPtMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, WptPt wpt) {
|
||||
super(new WptPtMenuBuilder(app, wpt), pointDescription, mapActivity);
|
||||
public WptPtMenuController(MapActivity mapActivity, PointDescription pointDescription, WptPt wpt) {
|
||||
super(new WptPtMenuBuilder(mapActivity, wpt), pointDescription, mapActivity);
|
||||
this.wpt = wpt;
|
||||
}
|
||||
|
||||
|
@ -34,11 +33,6 @@ public class WptPtMenuController extends MenuController {
|
|||
return wpt;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
public boolean handleSingleTapOnMap() {
|
||||
|
|
|
@ -20,6 +20,7 @@ import android.widget.Spinner;
|
|||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.ValueHolder;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -71,7 +72,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
private boolean selectFromMapForTarget;
|
||||
|
||||
private boolean showMenu = false;
|
||||
private boolean visible;
|
||||
private static boolean visible;
|
||||
private MapActivity mapActivity;
|
||||
private MapControlsLayer mapControlsLayer;
|
||||
public static final String TARGET_SELECT = "TARGET_SELECT";
|
||||
|
@ -510,7 +511,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
return directionInfo;
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
public static boolean isVisible() {
|
||||
return visible;
|
||||
}
|
||||
|
||||
|
@ -547,8 +548,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
RouteDirectionInfo info = routingHelper.getRouteDirections().get(directionInfo);
|
||||
net.osmand.Location l = routingHelper.getLocationFromRouteDirection(info);
|
||||
contextMenu.showMinimized(new LatLon(l.getLatitude(), l.getLongitude()), null, info);
|
||||
mapView.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(),
|
||||
mapView.getZoom(), true);
|
||||
showLocationOnMap(mapActivity, l.getLatitude(), l.getLongitude());
|
||||
}
|
||||
}
|
||||
mapView.refreshMap();
|
||||
|
@ -570,7 +570,7 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
RouteDirectionInfo info = routingHelper.getRouteDirections().get(directionInfo);
|
||||
net.osmand.Location l = routingHelper.getLocationFromRouteDirection(info);
|
||||
contextMenu.showMinimized(new LatLon(l.getLatitude(), l.getLongitude()), null, info);
|
||||
mapView.getAnimatedDraggingThread().startMoving(l.getLatitude(), l.getLongitude(), mapView.getZoom(), true);
|
||||
showLocationOnMap(mapActivity, l.getLatitude(), l.getLongitude());
|
||||
}
|
||||
mapView.refreshMap();
|
||||
updateInfo(mainView);
|
||||
|
@ -623,6 +623,25 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
|
|||
}
|
||||
}
|
||||
|
||||
public static void showLocationOnMap(MapActivity mapActivity, double latitude, double longitude) {
|
||||
RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
|
||||
int tileBoxWidthPx = 0;
|
||||
int tileBoxHeightPx = 0;
|
||||
|
||||
MapRouteInfoMenu routeInfoMenu = mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu();
|
||||
WeakReference<MapRouteInfoMenuFragment> fragmentRef = routeInfoMenu.findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
MapRouteInfoMenuFragment f = fragmentRef.get();
|
||||
if (mapActivity.isLandscapeLayout()) {
|
||||
tileBoxWidthPx = tb.getPixWidth() - f.getWidth();
|
||||
} else {
|
||||
tileBoxHeightPx = tb.getPixHeight() - f.getHeight();
|
||||
}
|
||||
}
|
||||
mapActivity.getMapView().fitLocationToMap(latitude, longitude, mapActivity.getMapView().getZoom(),
|
||||
tileBoxWidthPx, tileBoxHeightPx, AndroidUtils.dpToPx(mapActivity, 40f));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void newRouteIsCalculated(boolean newRoute, ValueHolder<Boolean> showToast) {
|
||||
directionInfo = -1;
|
||||
|
|
|
@ -42,8 +42,12 @@ public class FavoritesActivity extends TabActivity {
|
|||
|
||||
@Override
|
||||
public void onCreate(Bundle icicle) {
|
||||
((OsmandApplication) getApplication()).applyTheme(this);
|
||||
OsmandApplication app = (OsmandApplication) getApplication();
|
||||
app.applyTheme(this);
|
||||
super.onCreate(icicle);
|
||||
|
||||
app.logEvent(this, "myplaces_open");
|
||||
|
||||
//noinspection ConstantConditions
|
||||
getSupportActionBar().setTitle(R.string.shared_string_my_places);
|
||||
getSupportActionBar().setElevation(0);
|
||||
|
|
|
@ -19,9 +19,10 @@ import static net.osmand.plus.NavigationService.USED_BY_WAKE_UP;
|
|||
public class GpsWakeUpNotification extends OsmandNotification {
|
||||
|
||||
public final static String OSMAND_STOP_GPS_WAKE_UP_SERVICE_ACTION = "OSMAND_STOP_GPS_WAKE_UP_SERVICE_ACTION";
|
||||
public final static String GROUP_NAME = "GPS_WAKE_UP";
|
||||
|
||||
public GpsWakeUpNotification(OsmandApplication app) {
|
||||
super(app);
|
||||
super(app, GROUP_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -58,7 +59,7 @@ public class GpsWakeUpNotification extends OsmandNotification {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder buildNotification() {
|
||||
public Builder buildNotification(boolean wearable) {
|
||||
NavigationService service = app.getNavigationService();
|
||||
String notificationTitle;
|
||||
String notificationText;
|
||||
|
@ -80,7 +81,7 @@ public class GpsWakeUpNotification extends OsmandNotification {
|
|||
return null;
|
||||
}
|
||||
|
||||
final Builder notificationBuilder = createBuilder()
|
||||
final Builder notificationBuilder = createBuilder(wearable)
|
||||
.setContentTitle(notificationTitle)
|
||||
.setStyle(new BigTextStyle().bigText(notificationText));
|
||||
|
||||
|
@ -94,7 +95,12 @@ public class GpsWakeUpNotification extends OsmandNotification {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getUniqueId() {
|
||||
public int getOsmandNotificationId() {
|
||||
return GPS_WAKE_UP_NOTIFICATION_SERVICE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOsmandWearableNotificationId() {
|
||||
return WEAR_GPS_WAKE_UP_NOTIFICATION_SERVICE_ID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -14,23 +14,22 @@ import net.osmand.plus.OsmAndFormatter;
|
|||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import static net.osmand.plus.NavigationService.USED_BY_GPX;
|
||||
import static net.osmand.plus.NavigationService.USED_BY_NAVIGATION;
|
||||
|
||||
public class GpxNotification extends OsmandNotification {
|
||||
|
||||
public final static String OSMAND_SAVE_GPX_SERVICE_ACTION = "OSMAND_SAVE_GPX_SERVICE_ACTION";
|
||||
public final static String OSMAND_START_GPX_SERVICE_ACTION = "OSMAND_START_GPX_SERVICE_ACTION";
|
||||
public final static String OSMAND_STOP_GPX_SERVICE_ACTION = "OSMAND_STOP_GPX_SERVICE_ACTION";
|
||||
public final static String GROUP_NAME = "GPX";
|
||||
|
||||
private boolean wasDismissed;
|
||||
|
||||
public GpxNotification(OsmandApplication app) {
|
||||
super(app);
|
||||
super(app, GROUP_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -100,7 +99,7 @@ public class GpxNotification extends OsmandNotification {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder buildNotification() {
|
||||
public Builder buildNotification(boolean wearable) {
|
||||
if (!isEnabled()) {
|
||||
return null;
|
||||
}
|
||||
|
@ -134,7 +133,7 @@ public class GpxNotification extends OsmandNotification {
|
|||
return null;
|
||||
}
|
||||
|
||||
final Builder notificationBuilder = createBuilder()
|
||||
final Builder notificationBuilder = createBuilder(wearable)
|
||||
.setContentTitle(notificationTitle)
|
||||
.setStyle(new BigTextStyle().bigText(notificationText));
|
||||
|
||||
|
@ -173,7 +172,12 @@ public class GpxNotification extends OsmandNotification {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getUniqueId() {
|
||||
public int getOsmandNotificationId() {
|
||||
return GPX_NOTIFICATION_SERVICE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOsmandWearableNotificationId() {
|
||||
return WEAR_GPX_NOTIFICATION_SERVICE_ID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,13 +44,14 @@ public class NavigationNotification extends OsmandNotification {
|
|||
public final static String OSMAND_PAUSE_NAVIGATION_SERVICE_ACTION = "OSMAND_PAUSE_NAVIGATION_SERVICE_ACTION";
|
||||
public final static String OSMAND_RESUME_NAVIGATION_SERVICE_ACTION = "OSMAND_RESUME_NAVIGATION_SERVICE_ACTION";
|
||||
public final static String OSMAND_STOP_NAVIGATION_SERVICE_ACTION = "OSMAND_STOP_NAVIGATION_SERVICE_ACTION";
|
||||
public final static String GROUP_NAME = "NAVIGATION";
|
||||
|
||||
private Map<TurnPathHelper.TurnResource, Bitmap> bitmapCache = new HashMap<>();
|
||||
private Bitmap turnBitmap;
|
||||
private boolean leftSide;
|
||||
|
||||
public NavigationNotification(OsmandApplication app) {
|
||||
super(app);
|
||||
super(app, GROUP_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -108,7 +109,7 @@ public class NavigationNotification extends OsmandNotification {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder buildNotification() {
|
||||
public Builder buildNotification(boolean wearable) {
|
||||
NavigationService service = app.getNavigationService();
|
||||
String notificationTitle;
|
||||
StringBuilder notificationText = new StringBuilder();
|
||||
|
@ -200,7 +201,7 @@ public class NavigationNotification extends OsmandNotification {
|
|||
return null;
|
||||
}
|
||||
|
||||
final Builder notificationBuilder = createBuilder()
|
||||
final Builder notificationBuilder = createBuilder(wearable)
|
||||
.setContentTitle(notificationTitle)
|
||||
.setStyle(new BigTextStyle().bigText(notificationText))
|
||||
.setLargeIcon(turnBitmap);
|
||||
|
@ -260,7 +261,12 @@ public class NavigationNotification extends OsmandNotification {
|
|||
}
|
||||
|
||||
@Override
|
||||
public int getUniqueId() {
|
||||
public int getOsmandNotificationId() {
|
||||
return NAVIGATION_NOTIFICATION_SERVICE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOsmandWearableNotificationId() {
|
||||
return WEAR_NAVIGATION_NOTIFICATION_SERVICE_ID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,9 +22,10 @@ public class OsMoNotification extends OsmandNotification {
|
|||
public final static String OSMAND_STOP_OSMO_SERVICE_ACTION = "OSMAND_STOP_OSMO_SERVICE_ACTION";
|
||||
public final static String OSMAND_START_SHARE_LOCATION_ACTION = "OSMAND_START_SHARE_LOCATION_ACTION";
|
||||
public final static String OSMAND_STOP_SHARE_LOCATION_ACTION = "OSMAND_STOP_SHARE_LOCATION_ACTION";
|
||||
public final static String GROUP_NAME = "OSMO";
|
||||
|
||||
public OsMoNotification(OsmandApplication app) {
|
||||
super(app);
|
||||
super(app, GROUP_NAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -115,7 +116,7 @@ public class OsMoNotification extends OsmandNotification {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Builder buildNotification() {
|
||||
public Builder buildNotification(boolean wearable) {
|
||||
OsMoPlugin osMoPlugin = OsmandPlugin.getEnabledPlugin(OsMoPlugin.class);
|
||||
if (osMoPlugin == null) {
|
||||
return null;
|
||||
|
@ -130,7 +131,7 @@ public class OsMoNotification extends OsmandNotification {
|
|||
notificationTitle = app.getString(R.string.osmo_service_running);
|
||||
notificationText = app.getString(R.string.osmo_share_my_location) + ": " + (shareLocation ? app.getString(R.string.shared_string_yes) : app.getString(R.string.shared_string_no)).toLowerCase();
|
||||
|
||||
final Builder notificationBuilder = createBuilder()
|
||||
final Builder notificationBuilder = createBuilder(wearable)
|
||||
.setContentTitle(notificationTitle)
|
||||
.setContentText(notificationText);
|
||||
|
||||
|
@ -169,7 +170,12 @@ public class OsMoNotification extends OsmandNotification {
|
|||
|
||||
|
||||
@Override
|
||||
public int getUniqueId() {
|
||||
public int getOsmandNotificationId() {
|
||||
return OSMO_NOTIFICATION_SERVICE_ID;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOsmandWearableNotificationId() {
|
||||
return WEAR_OSMO_NOTIFICATION_SERVICE_ID;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package net.osmand.plus.notifications;
|
||||
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.NotificationCompat.Builder;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.support.v7.app.NotificationCompat;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
@ -20,12 +19,19 @@ public abstract class OsmandNotification {
|
|||
public final static int GPS_WAKE_UP_NOTIFICATION_SERVICE_ID = 8;
|
||||
public final static int TOP_NOTIFICATION_SERVICE_ID = 100;
|
||||
|
||||
public final static int WEAR_NAVIGATION_NOTIFICATION_SERVICE_ID = 1005;
|
||||
public final static int WEAR_GPX_NOTIFICATION_SERVICE_ID = 1006;
|
||||
public final static int WEAR_OSMO_NOTIFICATION_SERVICE_ID = 1007;
|
||||
public final static int WEAR_GPS_WAKE_UP_NOTIFICATION_SERVICE_ID = 1008;
|
||||
|
||||
protected OsmandApplication app;
|
||||
protected boolean ongoing = true;
|
||||
protected int color;
|
||||
protected int icon;
|
||||
protected boolean top;
|
||||
|
||||
private String groupName;
|
||||
|
||||
public enum NotificationType {
|
||||
NAVIGATION,
|
||||
GPX,
|
||||
|
@ -33,14 +39,19 @@ public abstract class OsmandNotification {
|
|||
GPS
|
||||
}
|
||||
|
||||
public OsmandNotification(OsmandApplication app) {
|
||||
public OsmandNotification(OsmandApplication app, String groupName) {
|
||||
this.app = app;
|
||||
this.groupName = groupName;
|
||||
init();
|
||||
}
|
||||
|
||||
public void init() {
|
||||
}
|
||||
|
||||
public String getGroupName() {
|
||||
return groupName;
|
||||
}
|
||||
|
||||
public abstract NotificationType getType();
|
||||
|
||||
public boolean isTop() {
|
||||
|
@ -51,17 +62,20 @@ public abstract class OsmandNotification {
|
|||
this.top = top;
|
||||
}
|
||||
|
||||
protected Builder createBuilder() {
|
||||
protected Builder createBuilder(boolean wearable) {
|
||||
Intent contentIntent = new Intent(app, MapActivity.class);
|
||||
PendingIntent contentPendingIntent = PendingIntent.getActivity(app, 0, contentIntent,
|
||||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
|
||||
Builder builder = new Builder(app)
|
||||
.setVisibility(android.support.v7.app.NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setVisibility(android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setPriority(top ? NotificationCompat.PRIORITY_HIGH : getPriority())
|
||||
.setOngoing(ongoing)
|
||||
.setOngoing(ongoing && !wearable)
|
||||
.setContentIntent(contentPendingIntent)
|
||||
.setDeleteIntent(NotificationDismissReceiver.createIntent(app, getType()));
|
||||
if (top) {
|
||||
builder.setGroup(groupName).setGroupSummary(!wearable);
|
||||
}
|
||||
|
||||
if (color != 0) {
|
||||
builder.setColor(color);
|
||||
|
@ -73,9 +87,11 @@ public abstract class OsmandNotification {
|
|||
return builder;
|
||||
}
|
||||
|
||||
public abstract Builder buildNotification();
|
||||
public abstract Builder buildNotification(boolean wearable);
|
||||
|
||||
public abstract int getUniqueId();
|
||||
public abstract int getOsmandNotificationId();
|
||||
|
||||
public abstract int getOsmandWearableNotificationId();
|
||||
|
||||
public abstract int getPriority();
|
||||
|
||||
|
@ -90,13 +106,20 @@ public abstract class OsmandNotification {
|
|||
}
|
||||
|
||||
public boolean showNotification() {
|
||||
NotificationManager notificationManager = (NotificationManager) app.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(app);
|
||||
if (isEnabled()) {
|
||||
Builder newNotification = buildNotification();
|
||||
if (newNotification != null) {
|
||||
Notification notification = newNotification.build();
|
||||
Builder notificationBuilder = buildNotification(false);
|
||||
if (notificationBuilder != null) {
|
||||
Notification notification = notificationBuilder.build();
|
||||
setupNotification(notification);
|
||||
notificationManager.notify(top ? TOP_NOTIFICATION_SERVICE_ID : getUniqueId(), notification);
|
||||
notificationManager.notify(top ? TOP_NOTIFICATION_SERVICE_ID : getOsmandNotificationId(), notification);
|
||||
if (top) {
|
||||
Builder wearNotificationBuilder = buildNotification(true);
|
||||
if (wearNotificationBuilder != null) {
|
||||
Notification wearNotification = wearNotificationBuilder.build();
|
||||
notificationManager.notify(getOsmandWearableNotificationId(), wearNotification);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -104,31 +127,39 @@ public abstract class OsmandNotification {
|
|||
}
|
||||
|
||||
public boolean refreshNotification() {
|
||||
NotificationManager notificationManager = (NotificationManager) app.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(app);
|
||||
if (isEnabled()) {
|
||||
Builder newNotification = buildNotification();
|
||||
if (newNotification != null) {
|
||||
Notification notification = newNotification.build();
|
||||
Builder notificationBuilder = buildNotification(false);
|
||||
if (notificationBuilder != null) {
|
||||
Notification notification = notificationBuilder.build();
|
||||
setupNotification(notification);
|
||||
if (top) {
|
||||
notificationManager.cancel(getUniqueId());
|
||||
notificationManager.cancel(getOsmandNotificationId());
|
||||
notificationManager.notify(TOP_NOTIFICATION_SERVICE_ID, notification);
|
||||
|
||||
Builder wearNotificationBuilder = buildNotification(true);
|
||||
if (wearNotificationBuilder != null) {
|
||||
Notification wearNotification = wearNotificationBuilder.build();
|
||||
notificationManager.notify(getOsmandWearableNotificationId(), wearNotification);
|
||||
}
|
||||
|
||||
} else {
|
||||
notificationManager.notify(getUniqueId(), notification);
|
||||
notificationManager.notify(getOsmandNotificationId(), notification);
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
notificationManager.cancel(getUniqueId());
|
||||
notificationManager.cancel(getOsmandNotificationId());
|
||||
}
|
||||
} else {
|
||||
notificationManager.cancel(getUniqueId());
|
||||
notificationManager.cancel(getOsmandNotificationId());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removeNotification() {
|
||||
NotificationManager notificationManager = (NotificationManager) app.getSystemService(Context.NOTIFICATION_SERVICE);
|
||||
notificationManager.cancel(getUniqueId());
|
||||
NotificationManagerCompat notificationManager = NotificationManagerCompat.from(app);
|
||||
notificationManager.cancel(getOsmandNotificationId());
|
||||
notificationManager.cancel(getOsmandWearableNotificationId());
|
||||
}
|
||||
|
||||
public void closeSystemDialogs(Context context) {
|
||||
|
|
|
@ -5,8 +5,8 @@ import android.view.View;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
|
||||
|
@ -16,8 +16,8 @@ public class EditPOIMenuBuilder extends MenuBuilder {
|
|||
|
||||
private final OsmPoint osmPoint;
|
||||
|
||||
public EditPOIMenuBuilder(OsmandApplication app, final OsmPoint osmPoint) {
|
||||
super(app);
|
||||
public EditPOIMenuBuilder(MapActivity mapActivity, final OsmPoint osmPoint) {
|
||||
super(mapActivity);
|
||||
this.osmPoint = osmPoint;
|
||||
}
|
||||
|
||||
|
@ -31,8 +31,8 @@ public class EditPOIMenuBuilder extends MenuBuilder {
|
|||
if (osmPoint instanceof OsmNotesPoint) {
|
||||
OsmNotesPoint notes = (OsmNotesPoint) osmPoint;
|
||||
|
||||
buildRow(view, R.drawable.ic_action_note_dark, notes.getText(), 0, false, 0, false, null);
|
||||
buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, 0, false, null);
|
||||
buildRow(view, R.drawable.ic_action_note_dark, notes.getText(), 0, false, null, false, 0, false, null);
|
||||
buildRow(view, R.drawable.ic_group, notes.getAuthor(), 0, false, null, false, 0, false, null);
|
||||
|
||||
} else if (osmPoint instanceof OpenstreetmapPoint) {
|
||||
OpenstreetmapPoint point = (OpenstreetmapPoint) osmPoint;
|
||||
|
@ -57,7 +57,7 @@ public class EditPOIMenuBuilder extends MenuBuilder {
|
|||
if (resId == 0) {
|
||||
resId = R.drawable.ic_action_folder_stroke;
|
||||
}
|
||||
buildRow(view, resId, poiTranslation, 0, false, 0, false, null);
|
||||
buildRow(view, resId, poiTranslation, 0, false, null, false, 0, false, null);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -67,12 +67,12 @@ public class EditPOIMenuBuilder extends MenuBuilder {
|
|||
continue;
|
||||
}
|
||||
String text = e.getKey() + "=" + e.getValue();
|
||||
buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, 0, false, null);
|
||||
buildRow(view, R.drawable.ic_action_info_dark, text, 0, false, null, false, 0, false, null);
|
||||
}
|
||||
}
|
||||
|
||||
buildRow(view, R.drawable.ic_action_get_my_location, PointDescription.getLocationName(app,
|
||||
osmPoint.getLatitude(), osmPoint.getLongitude(), true)
|
||||
.replaceAll("\n", ""), 0, false, 0, false, null);
|
||||
.replaceAll("\n", " "), 0, false, null, false, 0, false, null);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,7 +6,6 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -23,8 +22,8 @@ public class EditPOIMenuController extends MenuController {
|
|||
private String pointTypeStr;
|
||||
private ProgressDialogPoiUploader poiUploader;
|
||||
|
||||
public EditPOIMenuController(OsmandApplication app, final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) {
|
||||
super(new EditPOIMenuBuilder(app, osmPoint), pointDescription, mapActivity);
|
||||
public EditPOIMenuController(final MapActivity mapActivity, PointDescription pointDescription, OsmPoint osmPoint) {
|
||||
super(new EditPOIMenuBuilder(mapActivity, osmPoint), pointDescription, mapActivity);
|
||||
this.osmPoint = osmPoint;
|
||||
plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||
|
||||
|
@ -119,11 +118,6 @@ public class EditPOIMenuController extends MenuController {
|
|||
return osmPoint;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean needTypeStr() {
|
||||
return !Algorithms.isEmpty(pointTypeStr);
|
||||
|
|
|
@ -4,7 +4,6 @@ import android.graphics.drawable.Drawable;
|
|||
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -17,8 +16,8 @@ public class OsmBugMenuController extends MenuController {
|
|||
private OsmEditingPlugin plugin;
|
||||
private OpenStreetNote bug;
|
||||
|
||||
public OsmBugMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, OpenStreetNote bug) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public OsmBugMenuController(MapActivity mapActivity, PointDescription pointDescription, OpenStreetNote bug) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
plugin = OsmandPlugin.getPlugin(OsmEditingPlugin.class);
|
||||
this.bug = bug;
|
||||
|
||||
|
@ -73,11 +72,6 @@ public class OsmBugMenuController extends MenuController {
|
|||
return bug;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSupportedMenuStatesPortrait() {
|
||||
return MenuState.HEADER_ONLY | MenuState.HALF_SCREEN | MenuState.FULL_SCREEN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Drawable getLeftIcon() {
|
||||
if (bug.isOpened()) {
|
||||
|
|
|
@ -19,8 +19,8 @@ public class OsMoMenuController extends MenuController {
|
|||
|
||||
private OsMoDevice device;
|
||||
|
||||
public OsMoMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription, OsMoDevice device) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public OsMoMenuController(MapActivity mapActivity, PointDescription pointDescription, OsMoDevice device) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
this.device = device;
|
||||
|
||||
leftTitleButtonController = new TitleButtonController() {
|
||||
|
|
|
@ -3,7 +3,6 @@ package net.osmand.plus.parkingpoint;
|
|||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
@ -16,8 +15,8 @@ public class ParkingPositionMenuController extends MenuController {
|
|||
private ParkingPositionPlugin plugin;
|
||||
private String parkingDescription = "";
|
||||
|
||||
public ParkingPositionMenuController(OsmandApplication app, MapActivity mapActivity, PointDescription pointDescription) {
|
||||
super(new MenuBuilder(app), pointDescription, mapActivity);
|
||||
public ParkingPositionMenuController(MapActivity mapActivity, PointDescription pointDescription) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
plugin = OsmandPlugin.getPlugin(ParkingPositionPlugin.class);
|
||||
if (plugin != null) {
|
||||
buildParkingDescription(mapActivity);
|
||||
|
|
|
@ -36,6 +36,7 @@ import android.widget.ListView;
|
|||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.ResultMatcher;
|
||||
|
@ -43,6 +44,7 @@ import net.osmand.data.LatLon;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.AppInitializer;
|
||||
import net.osmand.plus.AppInitializer.AppInitializeListener;
|
||||
import net.osmand.plus.GPXUtilities;
|
||||
|
@ -1142,6 +1144,26 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
}
|
||||
|
||||
public void completeQueryWithObject(SearchResult sr) {
|
||||
if (sr.object instanceof PoiType && ((PoiType) sr.object).isAdditional()) {
|
||||
PoiType additional = (PoiType) sr.object;
|
||||
AbstractPoiType parent = additional.getParentType();
|
||||
if (parent != null) {
|
||||
PoiUIFilter custom = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + parent.getKeyName());
|
||||
if (custom != null) {
|
||||
custom.clearFilter();
|
||||
custom.updateTypesToAccept(parent);
|
||||
custom.setFilterByName(additional.getKeyName().replace('_', ':').toLowerCase());
|
||||
|
||||
SearchPhrase phrase = searchUICore.getPhrase();
|
||||
sr = new SearchResult(phrase);
|
||||
sr.localeName = custom.getName();
|
||||
sr.object = custom;
|
||||
sr.priority = SEARCH_AMENITY_TYPE_PRIORITY;
|
||||
sr.priorityDistance = 0;
|
||||
sr.objectType = ObjectType.POI_TYPE;
|
||||
}
|
||||
}
|
||||
}
|
||||
searchUICore.selectSearchResult(sr);
|
||||
String txt = searchUICore.getPhrase().getText(true);
|
||||
searchQuery = txt;
|
||||
|
@ -1223,8 +1245,9 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
return false;
|
||||
}
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
mapActivity.getMyApplication().logEvent(mapActivity, "search_open");
|
||||
|
||||
Bundle bundle = new Bundle();
|
||||
if (object != null) {
|
||||
bundle.putBoolean(QUICK_SEARCH_RUN_SEARCH_FIRST_TIME_KEY, true);
|
||||
String objectLocalizedName = searchQuery;
|
||||
|
|
|
@ -22,13 +22,14 @@ import net.osmand.search.core.SearchResult;
|
|||
|
||||
public class QuickSearchHelper implements ResourceListener {
|
||||
|
||||
public static final int SEARCH_FAVORITE_API_PRIORITY = 2;
|
||||
public static final int SEARCH_FAVORITE_API_CATEGORY_PRIORITY = 7;
|
||||
public static final int SEARCH_FAVORITE_OBJECT_PRIORITY = 10;
|
||||
public static final int SEARCH_WPT_API_PRIORITY = 2;
|
||||
public static final int SEARCH_WPT_OBJECT_PRIORITY = 10;
|
||||
public static final int SEARCH_HISTORY_API_PRIORITY = 3;
|
||||
public static final int SEARCH_HISTORY_OBJECT_PRIORITY = 10;
|
||||
public static final int SEARCH_FAVORITE_API_PRIORITY = 50;
|
||||
public static final int SEARCH_FAVORITE_API_CATEGORY_PRIORITY = 50;
|
||||
public static final int SEARCH_FAVORITE_OBJECT_PRIORITY = 50;
|
||||
public static final int SEARCH_FAVORITE_CATEGORY_PRIORITY = 51;
|
||||
public static final int SEARCH_WPT_API_PRIORITY = 50;
|
||||
public static final int SEARCH_WPT_OBJECT_PRIORITY = 52;
|
||||
public static final int SEARCH_HISTORY_API_PRIORITY = 50;
|
||||
public static final int SEARCH_HISTORY_OBJECT_PRIORITY = 53;
|
||||
private OsmandApplication app;
|
||||
private SearchUICore core;
|
||||
private SearchResultCollection resultCollection;
|
||||
|
@ -113,7 +114,7 @@ public class QuickSearchHelper implements ResourceListener {
|
|||
SearchResult sr = new SearchResult(phrase);
|
||||
sr.localeName = point.getName();
|
||||
sr.object = point;
|
||||
sr.priority = SEARCH_FAVORITE_OBJECT_PRIORITY;
|
||||
sr.priority = SEARCH_FAVORITE_CATEGORY_PRIORITY;
|
||||
sr.objectType = ObjectType.FAVORITE;
|
||||
sr.location = new LatLon(point.getLatitude(), point.getLongitude());
|
||||
sr.preferredZoom = 17;
|
||||
|
|
|
@ -11,6 +11,7 @@ import android.widget.CheckBox;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.Amenity;
|
||||
|
|
|
@ -89,7 +89,7 @@ public class QuickSearchListItem {
|
|||
PointDescription pd = historyEntry.getName();
|
||||
return pd.getSimpleName(app, false);
|
||||
case LOCATION:
|
||||
LatLon latLon = (LatLon) searchResult.object;
|
||||
LatLon latLon = searchResult.location;
|
||||
return PointDescription.getLocationNamePlain(app, latLon.getLatitude(), latLon.getLongitude());
|
||||
}
|
||||
return searchResult.localeName;
|
||||
|
@ -266,6 +266,9 @@ public class QuickSearchListItem {
|
|||
((PoiType) abstractPoiType).getOsmTag() + "_" + ((PoiType) abstractPoiType).getOsmValue())) {
|
||||
return ((PoiType) abstractPoiType).getOsmTag() + "_" + ((PoiType) abstractPoiType).getOsmValue();
|
||||
}
|
||||
if (abstractPoiType instanceof PoiType && ((PoiType) abstractPoiType).getParentType() != null) {
|
||||
return getPoiTypeIconName(((PoiType) abstractPoiType).getParentType());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -318,7 +321,7 @@ public class QuickSearchListItem {
|
|||
iconId = R.drawable.mx_user_defined;
|
||||
}
|
||||
}
|
||||
if (iconId != -1) {
|
||||
if (iconId > 0) {
|
||||
return app.getIconsCache().getIcon(iconId,
|
||||
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);
|
||||
} else {
|
||||
|
@ -329,8 +332,12 @@ public class QuickSearchListItem {
|
|||
String id = getAmenityIconName(amenity);
|
||||
if (id != null) {
|
||||
iconId = RenderingIcons.getBigIconResourceId(id);
|
||||
return app.getIconsCache().getIcon(iconId,
|
||||
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);
|
||||
if (iconId > 0) {
|
||||
return app.getIconsCache().getIcon(iconId,
|
||||
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
|
@ -353,7 +360,7 @@ public class QuickSearchListItem {
|
|||
iconId = app.getResources().getIdentifier(iconName, "drawable", app.getPackageName());
|
||||
}
|
||||
}
|
||||
if (iconId == -1) {
|
||||
if (iconId <= 0) {
|
||||
return app.getIconsCache().getIcon(SearchHistoryFragment.getItemIcon(entry.getName()),
|
||||
app.getSettings().isLightContent() ? R.color.osmand_orange : R.color.osmand_orange_dark);
|
||||
} else {
|
||||
|
|
|
@ -290,6 +290,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
menu.show(ll, pointDescription, newObject);
|
||||
view.refreshMap();
|
||||
}
|
||||
selectedObjectContextMenuProvider = null;
|
||||
applyingMarkerLatLon = null;
|
||||
}
|
||||
|
||||
|
@ -463,6 +464,7 @@ public class ContextMenuLayer extends OsmandMapLayer {
|
|||
|
||||
} else if (showUnknownLocation) {
|
||||
hideVisibleMenues();
|
||||
selectedObjectContextMenuProvider = null;
|
||||
LatLon latLon = getLatLon(point, tileBox);
|
||||
activity.getMapViewTrackingUtilities().setMapLinkedToLocation(false);
|
||||
menu.show(latLon, null, null);
|
||||
|
|
|
@ -169,11 +169,13 @@ public class ImpassableRoadsLayer extends OsmandMapLayer implements
|
|||
|
||||
for (RouteDataObject road : getMissingRoads()) {
|
||||
Location location = getMissingRoadLocations().get(road.getId());
|
||||
int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
int y = (int) tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
if (calculateBelongs(ex, ey, x, y, compare)) {
|
||||
compare = radius;
|
||||
o.add(road);
|
||||
if (location != null) {
|
||||
int x = (int) tileBox.getPixXFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
int y = (int) tileBox.getPixYFromLatLon(location.getLatitude(), location.getLongitude());
|
||||
if (calculateBelongs(ex, ey, x, y, compare)) {
|
||||
compare = radius;
|
||||
o.add(road);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@ package net.osmand.plus.views;
|
|||
|
||||
import android.Manifest;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.pm.PackageManager;
|
||||
|
@ -26,7 +27,6 @@ import android.widget.ImageView;
|
|||
import android.widget.LinearLayout;
|
||||
import android.widget.SeekBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.core.android.MapRendererContext;
|
||||
import net.osmand.data.LatLon;
|
||||
|
@ -582,6 +582,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
mapRouteInfoMenu.show();
|
||||
} else {
|
||||
touchEvent = 0;
|
||||
app.logEvent(mapActivity, "start_navigation");
|
||||
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
|
||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
||||
|
@ -623,7 +624,7 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
routePlanningMode = true;
|
||||
}
|
||||
boolean routeFollowingMode = !routePlanningMode && rh.isFollowingMode();
|
||||
boolean dialogOpened = mapRouteInfoMenu.isVisible();
|
||||
boolean dialogOpened = MapRouteInfoMenu.isVisible();
|
||||
boolean showRouteCalculationControls = routePlanningMode ||
|
||||
((app.accessibilityEnabled() || (System.currentTimeMillis() - touchEvent < TIMEOUT_TO_SHOW_BUTTONS)) && routeFollowingMode);
|
||||
updateMyLocation(rh, dialogOpened);
|
||||
|
|
|
@ -798,6 +798,29 @@ public class OsmandMapTileView implements IMapDownloaderCallback {
|
|||
animatedDraggingThread.startMoving(clat, clon, tb.getZoom(), true);
|
||||
}
|
||||
|
||||
public void fitLocationToMap(double clat, double clon, int zoom,
|
||||
int tileBoxWidthPx, int tileBoxHeightPx, int marginTopPx) {
|
||||
RotatedTileBox tb = currentViewport.copy();
|
||||
int dy = 0;
|
||||
|
||||
int tbw = tb.getPixWidth();
|
||||
int tbh = tb.getPixHeight();
|
||||
if (tileBoxWidthPx > 0) {
|
||||
tbw = tileBoxWidthPx;
|
||||
} else if (tileBoxHeightPx > 0) {
|
||||
tbh = tileBoxHeightPx;
|
||||
dy = (tb.getPixHeight() - tileBoxHeightPx) / 2 - marginTopPx;
|
||||
}
|
||||
tb.setPixelDimensions(tbw, tbh);
|
||||
tb.setLatLonCenter(clat, clon);
|
||||
tb.setZoom(zoom);
|
||||
if (dy != 0) {
|
||||
clat = tb.getLatFromPixel(tb.getPixWidth() / 2, tb.getPixHeight() / 2 + dy);
|
||||
clon = tb.getLonFromPixel(tb.getPixWidth() / 2, tb.getPixHeight() / 2);
|
||||
}
|
||||
animatedDraggingThread.startMoving(clat, clon, tb.getZoom(), true);
|
||||
}
|
||||
|
||||
public boolean onGenericMotionEvent(MotionEvent event) {
|
||||
if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0 &&
|
||||
event.getAction() == MotionEvent.ACTION_SCROLL &&
|
||||
|
|
|
@ -33,6 +33,8 @@ import android.widget.LinearLayout;
|
|||
import android.widget.LinearLayout.LayoutParams;
|
||||
import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.ResultMatcher;
|
||||
import net.osmand.ValueHolder;
|
||||
|
@ -43,16 +45,12 @@ import net.osmand.data.QuadRect;
|
|||
import net.osmand.data.QuadTree;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.FileNameTranslationHelper;
|
||||
import net.osmand.plus.poi.PoiFiltersHelper;
|
||||
import net.osmand.plus.poi.PoiUIFilter;
|
||||
import net.osmand.plus.render.RenderingIcons;
|
||||
import net.osmand.plus.resources.ResourceManager;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.routing.RoutingHelper.IRouteInformationListener;
|
||||
import net.osmand.plus.views.MapTextLayer.MapTextProvider;
|
||||
|
@ -61,7 +59,9 @@ import net.osmand.util.Algorithms;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
|
@ -352,7 +352,7 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
MenuItem mi = topBar.getMenu().add(langSelected.toUpperCase()).setOnMenuItemClickListener(new OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(final MenuItem item) {
|
||||
showPopupLangMenu(ctx, topBar, app, a, dialog);
|
||||
showPopupLangMenu(ctx, topBar, app, a, dialog, langSelected);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
@ -449,20 +449,41 @@ public class POIMapLayer extends OsmandMapLayer implements ContextMenuLayer.ICon
|
|||
}
|
||||
|
||||
protected static void showPopupLangMenu(final Context ctx, Toolbar tb,
|
||||
final OsmandApplication app, final Amenity a, final Dialog dialog) {
|
||||
final OsmandApplication app, final Amenity a,
|
||||
final Dialog dialog, final String langSelected) {
|
||||
final PopupMenu optionsMenu = new PopupMenu(ctx, tb, Gravity.RIGHT);
|
||||
Set<String> names = new TreeSet<>();
|
||||
names.addAll(a.getNames("content", "en"));
|
||||
names.addAll(a.getNames("description", "en"));
|
||||
Set<String> namesSet = new TreeSet<>();
|
||||
namesSet.addAll(a.getNames("content", "en"));
|
||||
namesSet.addAll(a.getNames("description", "en"));
|
||||
|
||||
for (final String n : names) {
|
||||
String vn = FileNameTranslationHelper.getVoiceName(ctx, n);
|
||||
MenuItem item = optionsMenu.getMenu().add(vn);
|
||||
Map<String, String> names = new HashMap<>();
|
||||
for (String n : namesSet) {
|
||||
names.put(n, FileNameTranslationHelper.getVoiceName(ctx, n));
|
||||
}
|
||||
String selectedLangName = names.get(langSelected);
|
||||
if (selectedLangName != null) {
|
||||
names.remove(langSelected);
|
||||
}
|
||||
Map<String, String> sortedNames = AndroidUtils.sortByValue(names);
|
||||
|
||||
if (selectedLangName != null) {
|
||||
MenuItem item = optionsMenu.getMenu().add(selectedLangName);
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
dialog.dismiss();
|
||||
showWiki(ctx, app, a, n);
|
||||
showWiki(ctx, app, a, langSelected);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
for (final Map.Entry<String, String> e : sortedNames.entrySet()) {
|
||||
MenuItem item = optionsMenu.getMenu().add(e.getValue());
|
||||
item.setOnMenuItemClickListener(new MenuItem.OnMenuItemClickListener() {
|
||||
@Override
|
||||
public boolean onMenuItemClick(MenuItem item) {
|
||||
dialog.dismiss();
|
||||
showWiki(ctx, app, a, e.getKey());
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
|
|
@ -31,7 +31,7 @@ import android.graphics.PorterDuffColorFilter;
|
|||
|
||||
public class RouteLayer extends OsmandMapLayer {
|
||||
|
||||
private static final float EPSILON_IN_DPI = 4;
|
||||
private static final float EPSILON_IN_DPI = 2;
|
||||
|
||||
private OsmandMapTileView view;
|
||||
|
||||
|
@ -273,9 +273,13 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
distances = new ArrayList<Double>(locations.size());
|
||||
angles = new ArrayList<Double>(locations.size());
|
||||
simplifyPoints.fill(0, locations.size(), (byte)0);
|
||||
if(locations.size() > 0) {
|
||||
simplifyPoints.set(0, (byte) 1);
|
||||
}
|
||||
double distInPix = (tb.getDistance(0, 0, tb.getPixWidth(), 0) / tb.getPixWidth());
|
||||
double cullDistance = (distInPix * (EPSILON_IN_DPI * Math.max(1, tb.getDensity())));
|
||||
cullRamerDouglasPeucker(simplifyPoints, locations, 0, locations.size() - 1, cullDistance);
|
||||
|
||||
int previousIndex = -1;
|
||||
for(int i = 0; i < locations.size(); i++) {
|
||||
double d = 0;
|
||||
|
@ -301,9 +305,6 @@ public class RouteLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
public List<Double> getAngles() {
|
||||
return angles;
|
||||
}
|
||||
|
||||
public List<Double> getDistances() {
|
||||
return distances;
|
||||
|
|
|
@ -562,7 +562,7 @@ public class MapInfoWidgetsFactory {
|
|||
}
|
||||
} else {
|
||||
int di = MapRouteInfoMenu.getDirectionInfo();
|
||||
if (di >= 0 && MapRouteInfoMenu.isControlVisible() &&
|
||||
if (di >= 0 && MapRouteInfoMenu.isVisible() &&
|
||||
di < routingHelper.getRouteDirections().size()) {
|
||||
showNextTurn = true;
|
||||
RouteDirectionInfo next = routingHelper.getRouteDirections().get(di);
|
||||
|
@ -575,7 +575,8 @@ public class MapInfoWidgetsFactory {
|
|||
if (text == null) {
|
||||
text = "";
|
||||
}
|
||||
|
||||
} else {
|
||||
text = null;
|
||||
}
|
||||
}
|
||||
} else if (map.getMapViewTrackingUtilities().isMapLinkedToLocation() &&
|
||||
|
|
|
@ -18,6 +18,7 @@ import net.osmand.plus.dashboard.DashLocationFragment;
|
|||
import net.osmand.plus.dashboard.DashboardOnMap;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
import net.osmand.plus.helpers.MapMarkerDialogHelper;
|
||||
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
|
||||
import net.osmand.plus.views.AnimateDraggingMapThread;
|
||||
import net.osmand.plus.views.DirectionDrawable;
|
||||
import net.osmand.plus.views.OsmandMapLayer.DrawSettings;
|
||||
|
@ -199,7 +200,7 @@ public class MapMarkersWidgetsFactory {
|
|||
|| !map.getMyApplication().getSettings().MAP_MARKERS_MODE.get().isToolbar()
|
||||
|| map.getMyApplication().getRoutingHelper().isFollowingMode()
|
||||
|| map.getMyApplication().getRoutingHelper().isRoutePlanningMode()
|
||||
|| map.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().isVisible()
|
||||
|| MapRouteInfoMenu.isVisible()
|
||||
|| addressTopBar.getVisibility() == View.VISIBLE
|
||||
|| map.isTopToolbarActive()) {
|
||||
updateVisibility(false);
|
||||
|
|
|
@ -816,13 +816,15 @@ public class RouteInfoWidgetsFactory {
|
|||
}
|
||||
} else {
|
||||
int di = MapRouteInfoMenu.getDirectionInfo();
|
||||
if (di >= 0 && MapRouteInfoMenu.isControlVisible()
|
||||
if (di >= 0 && MapRouteInfoMenu.isVisible()
|
||||
&& di < rh.getRouteDirections().size()) {
|
||||
RouteDirectionInfo next = rh.getRouteDirections().get(di);
|
||||
if (next != null) {
|
||||
loclanes = next.getTurnType().getLanes();
|
||||
// primary = next.getTurnType();
|
||||
}
|
||||
} else {
|
||||
loclanes = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ buildscript {
|
|||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.1.3'
|
||||
classpath 'com.google.gms:google-services:3.0.0'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue