Compare commits

...

126 commits
master ... r3.0

Author SHA1 Message Date
Chumva
1f96c9c00d fix photo hotes in android 4.4 2018-06-11 17:34:25 +03:00
Victor Shcherb
4ed7f81661 Update version to 27.1.1 2018-06-11 14:39:27 +02:00
crimean
3d8a20ca77 Added error notification 2018-06-11 15:07:28 +03:00
Victor Shcherb
55aec52fc0 Fix NPE's 2018-06-10 18:18:00 +02:00
Chumva
765402b4e8 move context to first place 2018-06-08 18:49:51 +03:00
Chumva
66dd86360f add translation to styles choose dialog 2018-06-08 18:49:51 +03:00
Chumva
8cba8ae6ba add translations to toast messages 2018-06-08 18:49:51 +03:00
Chumva
6488712bb7 add translations for styles 2018-06-08 18:49:51 +03:00
Alexey
9b5e835a8f
Merge pull request #5555 from osmandapp/TransportStopWithPoi
Transport stop with poi
2018-06-08 18:34:12 +03:00
Chumva
e5503c277d removed unnecessary null check 2018-06-08 18:33:02 +03:00
Chumva
864f4ef7a9 add null check for selectedObj 2018-06-08 18:22:11 +03:00
Chumva
9de34ecf0c removed unnecessary changes 2018-06-08 18:16:08 +03:00
Chumva
92235adeb1 add link to amenity for transportStop and create TransportStopMenuBuilder for amenity tags 2018-06-08 17:13:24 +03:00
Alex Sytnyk
7b6d02b93d Add getters for metadata extensions 2018-06-06 22:30:29 +03:00
Alex Sytnyk
8b167faac5 Add a method to retrieve an article by title and language 2018-06-06 22:30:12 +03:00
Alex Sytnyk
08e3f9d2bc Add missing annotations 2018-06-06 22:07:47 +03:00
Alex Sytnyk
3edeeac27c Make small refactoring 2018-06-06 21:21:18 +03:00
Alex Sytnyk
a05ff9c556 Add new tags to the GPXFile 2018-06-06 21:21:10 +03:00
Alexander Sytnyk
d4065587c0
Merge pull request #5546 from osmandapp/QuickActionsChooseDialog
Add choose dialog for quick actions menu
2018-06-06 19:56:10 +03:00
Chumva
988b916ddb renamed executeWithParams params 2018-06-06 15:53:20 +03:00
Chumva
fe478b7427 add QuickAction in choose dialog and executeWithParams for switchable actions 2018-06-06 15:31:03 +03:00
Chumva
08e8e8c972 add opening for edit actions dialog 2018-06-05 17:04:38 +03:00
Chumva
2d8b202e9b add choose dialog for quick actions menu for map view properties(style,source,underlay,overlay) 2018-06-04 18:53:16 +03:00
Victor Shcherb
b5f5cb3cfe Fix typo 2018-06-03 17:48:45 +02:00
Victor Shcherb
e76ea77a5b Fix #5535 - do not use getTime from location comparing with system time 2018-06-03 17:43:19 +02:00
Victor Shcherb
81fe4d2d94 Fix issue with wikivoayge not updated 2018-06-02 13:51:16 +02:00
Victor Shcherb
df81a47b6e Fix wikivoyage update issue 2018-06-02 13:19:35 +02:00
crimean
14e11eaff3 Disable D8 2018-06-02 14:05:30 +03:00
Alex Sytnyk
0cef616b45 Fix #5506 2018-05-31 20:15:17 +03:00
Dmitriy Prodchenko
c22968ea68 Merge branch 'r3.0' of https://github.com/osmandapp/Osmand into r3.0 2018-05-31 15:57:05 +03:00
Dmitriy Prodchenko
dd98c8d7c0 Change icon for file type, add for Save to File 2018-05-31 15:56:47 +03:00
Alexey Kulish
18a6aec223 Fix addOptionSplit crash 2018-05-31 13:51:51 +03:00
Alexey Kulish
fbc6665d76 Hide track after wpt was displayed 2018-05-30 23:58:45 +03:00
Alexey Kulish
624380773b Added show on map checkbox to points fragment 2018-05-30 22:00:33 +03:00
Alexey Kulish
abbc0fe2ee Fix show/hide track from map 2018-05-30 22:00:14 +03:00
Alexey Kulish
86665945be Fix track points display on mini map 2018-05-30 21:59:58 +03:00
Alex Sytnyk
b936a052e1 Create custom progress drawable for routing progress bar 2018-05-30 17:50:58 +03:00
Alexey
74d887a755
Merge pull request #5518 from osmandapp/FixContextMenuPadding
Context menu Ui improving
2018-05-30 16:26:46 +03:00
Victor Shcherb
1ddf2775e1 Don't show points if there are no points 2018-05-30 14:53:53 +02:00
Chumva
0ccc10ebf1 removed two calls to runLayoutListener 2018-05-30 15:28:52 +03:00
Victor Shcherb
61993a1452 Change layout for progress 2018-05-30 14:21:07 +02:00
Victor Shcherb
dc14885f1f Update progress 2018-05-30 13:22:54 +02:00
Victor Shcherb
e7c19ac764 Fix #5519 crash 2018-05-30 13:11:51 +02:00
Victor Shcherb
50647d29f7 Create initial progress 2018-05-30 11:46:03 +02:00
Chumva
7d2fdd3e4a fix context menu padding 2018-05-30 11:56:38 +03:00
Alex Sytnyk
35c53ed5e3 Fix possible NPE 2018-05-30 11:53:01 +03:00
Victor Shcherb
34ea004ea2 Fix double progress 2018-05-29 23:39:12 +02:00
Victor Shcherb
6c2d1e43a3 Fix double progress 2018-05-29 23:27:41 +02:00
Victor Shcherb
b6885b5a33 Fix double progress 2018-05-29 23:15:59 +02:00
Victor Shcherb
652d9209a8 Update iteration id 2018-05-29 23:07:37 +02:00
Victor Shcherb
8bd56274b1 Add iterations info to progress 2018-05-29 23:04:36 +02:00
Alexey
6ad69050a6
Merge pull request #5492 from osmandapp/FixPoiEdits
Add npe check for poi category
2018-05-29 18:05:04 +03:00
Chumva
144e0012c1 add checks for getPoiCategory 2018-05-29 17:40:30 +03:00
Alexey
11a6843476
Merge pull request #5512 from osmandapp/WikivoyageSharingLinks
WikivoyageSharingLinks fixes
2018-05-29 17:13:29 +03:00
Chumva
ff4b3f4046 add default type for null category 2018-05-29 16:06:05 +03:00
Chumva
5167a076fe fix check for articleId 2018-05-29 15:28:38 +03:00
Chumva
62a895a4a5 Merge branch 'r3.0' of ssh://github.com/osmandapp/Osmand into FixPoiEdits 2018-05-29 14:44:31 +03:00
Alexey Kulish
fd16da1f81 Fix #5502 2018-05-29 14:16:27 +03:00
Alex Sytnyk
c9f8057b13 Remove redundant code 2018-05-29 13:04:19 +03:00
Alex Sytnyk
5c7b4cf719 The "later" button on travel cards hides the card until the application is restarted 2018-05-29 13:04:08 +03:00
Victor Shcherb
846bd3fcfa try to wrap db 2018-05-29 10:25:35 +02:00
Victor Shcherb
ada8c2a998 Fix crashes 2018-05-28 22:12:41 +02:00
Victor Shcherb
4fc3b20e5d Fix crashes 2018-05-28 22:12:20 +02:00
Victor Shcherb
86376c9ed8 Try to avoid npe #5496 2018-05-26 11:36:47 +02:00
Victor Shcherb
c503c78c70 Fix NPE 2018-05-26 11:30:14 +02:00
Victor Shcherb
be1bb0e257 Avoid potential crash 2018-05-26 11:26:33 +02:00
Victor Shcherb
df88bf74be Fix turn lanes bug (a test fix) 2018-05-26 00:02:57 +02:00
Victor Shcherb
f8246c5cf4 Fix #5003 2018-05-25 23:13:05 +02:00
Alexander Sytnyk
d902888f4a
Merge pull request #5493 from osmandapp/location_provider_fix
Location provider fix
2018-05-25 19:09:14 +03:00
Alexey Kulish
85e2e19801 Fix #5309 2018-05-25 18:52:50 +03:00
Alex Sytnyk
27b88ea389 Fix check for "setLocation(null)" 2018-05-25 18:41:53 +03:00
Alex Sytnyk
ae2df017ef Add check for "setLocation(null)" 2018-05-25 18:41:42 +03:00
Alex Sytnyk
17f4dfb7c4 Fix OsmAndLocationProvider#scheduleCheckIfGpsLost 2018-05-25 18:41:34 +03:00
Alexey Kulish
1385b5e267 Merge 2018-05-25 18:10:59 +03:00
Alex Sytnyk
285d3c1a6c Replace cached location with current 2018-05-25 18:07:35 +03:00
Alex Sytnyk
0d1c54f534 Fix methods for receiving location 2018-05-25 18:07:19 +03:00
Alex Sytnyk
5e26ec37d9 Fix small issues with new progress bar 2018-05-25 17:44:54 +03:00
Chumva
7e16d30a71 add npe check for poi category 2018-05-25 17:20:07 +03:00
Alexey
c62f0ae66c
Merge pull request #5490 from osmandapp/WikivoyageSharingLinks
Add popup for sharing article links
2018-05-25 16:25:37 +03:00
Chumva
843962d0ec add Override 2018-05-25 16:24:24 +03:00
Chumva
2660d23d79 add popup for sharing article links 2018-05-25 16:14:17 +03:00
Alexey
cb6fe98a00
Merge pull request #5483 from osmandapp/WikivoyageSharingLinks
Wikivoyage sharing links
2018-05-25 15:13:02 +03:00
Chumva
4718accc86 removed changes from discount helper 2018-05-25 15:12:02 +03:00
Chumva
620e08794f removed changes 2018-05-25 15:09:50 +03:00
Chumva
34a711454e removed empty space 2018-05-25 14:56:55 +03:00
Chumva
520cb4a79e removed check for TRAVEL_PREFIX 2018-05-25 14:48:20 +03:00
Chumva
d58e00a552 fixed bug with getScheme 2018-05-25 14:28:05 +03:00
Chumva
f6e22b6b5d add parseLaunchIntentLink 2018-05-25 14:24:10 +03:00
Chumva
33c47cc399 removed empty space 2018-05-25 14:13:49 +03:00
Chumva
ea157a2d9c remove unused fields in DiscountHelper and add decodeTitleFromTravelUrl 2018-05-25 14:11:47 +03:00
Alexey Kulish
75f68df9f2 Merge WaypointsHelper changes 2018-05-25 13:43:09 +03:00
Chumva
22592206c7 added options button 2018-05-25 13:10:24 +03:00
Chumva
ecb496d21f fixed url decoding 2018-05-25 12:45:12 +03:00
Chumva
90def12184 refactored buildTravelUrl 2018-05-25 11:45:25 +03:00
Chumva
4ce1625e3e removed unused import 2018-05-25 11:42:49 +03:00
Chumva
1307b3e487 removed unnecessary click 2018-05-25 11:41:36 +03:00
Chumva
d493e5ef15 added fixes 2018-05-25 11:36:58 +03:00
Victor Shcherb
42c3d27029 Fix crash 2018-05-25 10:14:53 +02:00
Victor Shcherb
59cc7ec7ad Fix crash 2018-05-25 10:11:31 +02:00
Chumva
fff98d810d Merge branch 'r3.0' of ssh://github.com/osmandapp/Osmand into WikivoyageSharingLinks 2018-05-25 11:09:55 +03:00
Victor Shcherb
0cd0fb59d3 Fix crash 2018-05-25 10:07:40 +02:00
Victor Shcherb
16dd3cec72 Fix exception with permission 2018-05-25 10:03:50 +02:00
Alexey Kulish
405ae9f69e Fix #5111 2018-05-24 21:06:20 +03:00
Alex Sytnyk
284f53ba19 Fix #4149 2018-05-24 19:27:51 +03:00
Alex Sytnyk
8347b01194 Remove legacy code 2018-05-24 19:27:30 +03:00
Chumva
a8de3846f8 refactored buildTravelUrl 2018-05-24 18:48:39 +03:00
Chumva
d62f5a53df add intent and intent-filter for sharing wikivoyage links 2018-05-24 18:44:10 +03:00
Alexander Sytnyk
8d7331fd93
Merge pull request #5482 from osmandapp/FixException
Fix IllegalStateException
2018-05-24 18:31:43 +03:00
Chumva
76d9bc80b7 add check for added fragment 2018-05-24 18:16:40 +03:00
Alex Sytnyk
821511d7e3 Fix icons for context menu additional info 2018-05-24 17:59:04 +03:00
Chumva
bad6f228a3 fix IllegalStateException 2018-05-24 17:55:22 +03:00
Dmitriy Prodchenko
c7d77a1373 Merge branch 'r3.0' of https://github.com/osmandapp/Osmand into r3.0 2018-05-24 17:06:37 +03:00
Dmitriy Prodchenko
40ea33bf46 Add icon for internet access fee 2018-05-24 17:06:12 +03:00
PaulStets
696fdfe6be Removed unused imports 2018-05-24 16:59:47 +03:00
PaulStets
b559414be4 Removed unused imports 2018-05-24 16:59:34 +03:00
PaulStets
4fad525359 Fixed missing header images for some articles 2018-05-24 16:59:23 +03:00
Alex Sytnyk
d1d6eaeb73 Add route calculation progress to the map route info menu 2018-05-24 15:50:33 +03:00
Alexey Kulish
40c41d5e40 Fix #5267 2018-05-24 15:13:13 +03:00
Victor Shcherb
4c72b0df4c Add lang as parameter 2018-05-24 11:00:27 +02:00
Victor Shcherb
521f87027c Fix 5467 2018-05-23 22:56:35 +02:00
Alex Sytnyk
a7c38e3c8e Fix #5464 2018-05-23 17:43:25 +03:00
Victor Shcherb
bf242fa58c Try to locate crash with incremental changes 2018-05-23 15:59:42 +02:00
Alexey Kulish
c779f4b69d Rename method 2018-05-23 10:33:42 +03:00
Alexey Kulish
d81c98a13b Fix transport stop menu (stops close to each other) #5117 2018-05-23 10:33:21 +03:00
Victor Shcherb
159796f3e2 Wrap all cursor for null pointer check 2018-05-23 00:09:17 +02:00
Victor Shcherb
ff5b795694 Fix crashes 2018-05-22 23:58:08 +02:00
129 changed files with 1934 additions and 707 deletions

View file

@ -237,6 +237,7 @@ public class RouteDataObject {
return null; return null;
} }
public String getName(String lang){ public String getName(String lang){
return getName(lang, false); return getName(lang, false);
} }
@ -685,6 +686,18 @@ public class RouteDataObject {
return direction; return direction;
} }
public boolean isRoadDeleted() {
int[] pt = getTypes();
int sz = pt.length;
for (int i = 0; i < sz; i++) {
RouteTypeRule r = region.quickGetEncodingRule(pt[i]);
if ("osmand_change".equals(r.getTag()) && "delete".equals(r.getValue())) {
return true;
}
}
return false;
}
public boolean isStopApplicable(boolean direction, int intId, int startPointInd, int endPointInd) { public boolean isStopApplicable(boolean direction, int intId, int startPointInd, int endPointInd) {
int[] pt = getPointTypes(intId); int[] pt = getPointTypes(intId);
int sz = pt.length; int sz = pt.length;

View file

@ -1,7 +1,9 @@
package net.osmand.data; package net.osmand.data;
public class TransportStop extends MapObject { public class TransportStop extends MapObject {
int[] referencesToRoutes = null; private int[] referencesToRoutes = null;
private Amenity amenity;
public int distance;
public TransportStop(){ public TransportStop(){
} }
@ -14,4 +16,11 @@ public class TransportStop extends MapObject {
this.referencesToRoutes = referencesToRoutes; this.referencesToRoutes = referencesToRoutes;
} }
public Amenity getAmenity() {
return amenity;
}
public void setAmenity(Amenity amenity) {
this.amenity = amenity;
}
} }

View file

@ -15,6 +15,37 @@ public class RouteCalculationProgress {
public int loadedTiles = 0; public int loadedTiles = 0;
public int visitedSegments = 0; public int visitedSegments = 0;
public int totalIterations = 1;
public int iteration = -1;
public boolean isCancelled; public boolean isCancelled;
public boolean requestPrivateAccessRouting; public boolean requestPrivateAccessRouting;
private static final float INITIAL_PROGRESS = 0.05f;
private static final float FIRST_ITERATION = 0.72f;
public float getLinearProgress() {
float p = Math.max(distanceFromBegin, distanceFromEnd);
float all = totalEstimatedDistance * 1.35f;
float pr = 0;
if (all > 0) {
pr = Math.min(p * p / (all * all), 1);
}
float progress = INITIAL_PROGRESS;
if (totalIterations > 1) {
if (iteration < 1) {
progress = pr * FIRST_ITERATION + INITIAL_PROGRESS;
} else {
progress = (INITIAL_PROGRESS + FIRST_ITERATION) + pr * (1 - FIRST_ITERATION - INITIAL_PROGRESS);
}
} else {
progress = INITIAL_PROGRESS + pr * (1 - INITIAL_PROGRESS);
}
return Math.min(progress * 100f, 99);
}
public void nextIteration() {
iteration++;
totalEstimatedDistance = 0;
}
} }

View file

@ -158,6 +158,7 @@ public class RoutePlannerFrontEnd {
} }
if (ctx.calculationMode == RouteCalculationMode.COMPLEX && routeDirection == null if (ctx.calculationMode == RouteCalculationMode.COMPLEX && routeDirection == null
&& maxDistance > ctx.config.DEVIATION_RADIUS * 6) { && maxDistance > ctx.config.DEVIATION_RADIUS * 6) {
ctx.calculationProgress.totalIterations++;
RoutingContext nctx = buildRoutingContext(ctx.config, ctx.nativeLib, ctx.getMaps(), RouteCalculationMode.BASE); RoutingContext nctx = buildRoutingContext(ctx.config, ctx.nativeLib, ctx.getMaps(), RouteCalculationMode.BASE);
nctx.calculationProgress = ctx.calculationProgress; nctx.calculationProgress = ctx.calculationProgress;
List<RouteSegmentResult> ls = searchRoute(nctx, start, end, intermediates); List<RouteSegmentResult> ls = searchRoute(nctx, start, end, intermediates);
@ -175,6 +176,7 @@ public class RoutePlannerFrontEnd {
if (routeDirection != null) { if (routeDirection != null) {
ctx.precalculatedRouteDirection = routeDirection.adopt(ctx); ctx.precalculatedRouteDirection = routeDirection.adopt(ctx);
} }
ctx.calculationProgress.nextIteration();
List<RouteSegmentResult> res = runNativeRouting(ctx, recalculationEnd); List<RouteSegmentResult> res = runNativeRouting(ctx, recalculationEnd);
if (res != null) { if (res != null) {
new RouteResultPreparation().printResults(ctx, start, end, res); new RouteResultPreparation().printResults(ctx, start, end, res);
@ -197,6 +199,7 @@ public class RoutePlannerFrontEnd {
if (!addSegment(end, ctx, indexNotFound++, points)) { if (!addSegment(end, ctx, indexNotFound++, points)) {
return null; return null;
} }
ctx.calculationProgress.nextIteration();
List<RouteSegmentResult> res = searchRoute(ctx, points, routeDirection); List<RouteSegmentResult> res = searchRoute(ctx, points, routeDirection);
// make start and end more precise // make start and end more precise
makeStartEndPointsPrecise(res, start, end, intermediates); makeStartEndPointsPrecise(res, start, end, intermediates);

View file

@ -743,9 +743,9 @@ public class RouteResultPreparation {
} }
} }
} }
if(straightActiveLen == target.activeLen) { if(straightActiveBegin != -1 && straightActiveLen <= target.activeLen) {
active.activeStartIndex = straightActiveBegin; active.activeStartIndex = straightActiveBegin;
active.activeEndIndex = straightActiveBegin + target.activeLen - 1; active.activeEndIndex = straightActiveBegin + straightActiveLen - 1;
changed = true; changed = true;
} else { } else {
// cause the next-turn goes forward exclude left most and right most lane // cause the next-turn goes forward exclude left most and right most lane

View file

@ -71,6 +71,9 @@ public class RouteSegmentResult {
} }
public void attachRoute(int roadIndex, RouteSegmentResult r){ public void attachRoute(int roadIndex, RouteSegmentResult r){
if(r.getObject().isRoadDeleted()) {
return;
}
int st = Math.abs(roadIndex - startPointIndex); int st = Math.abs(roadIndex - startPointIndex);
if(attachedRoutes[st] == null) { if(attachedRoutes[st] == null) {
attachedRoutes[st] = new ArrayList<RouteSegmentResult>(); attachedRoutes[st] = new ArrayList<RouteSegmentResult>();

View file

@ -416,11 +416,13 @@ public class TurnType {
public static int convertType(String lane) { public static int convertType(String lane) {
int turn; int turn;
// merge should be recognized as continue route (but it could displayed differently) // merge should be recognized as continue route (but it could displayed differently)
if (lane.equals("none") || lane.equals("through") if(lane.equals("merge_to_left")) {
|| lane.equals("merge_to_left")
|| lane.equals("merge_to_right")) {
turn = TurnType.C; turn = TurnType.C;
} else if (lane.equals("slight_right") ) { } else if(lane.equals("merge_to_right")) {
turn = TurnType.C;
} else if (lane.equals("none") || lane.equals("through")) {
turn = TurnType.C;
} else if (lane.equals("slight_right")) {
turn = TurnType.TSLR; turn = TurnType.TSLR;
} else if (lane.equals("slight_left") ) { } else if (lane.equals("slight_left") ) {
turn = TurnType.TSLL; turn = TurnType.TSLL;

View file

@ -595,8 +595,8 @@
}, },
"expectedResults": { "expectedResults": {
"222244": "TL|TL|+C,TR", "222244": "TL|TL|+C,TR",
"222243": "TL|TL|+C|C|TSLR", "222243": "TL|TL|+C|+C|TSLR",
"222164": "TL|TL|+C|C" "222164": "TL|TL|+C|+C"
} }
}, },
{ {

View file

@ -756,7 +756,23 @@
</receiver> </receiver>
<activity android:name=".liveupdates.OsmLiveActivity" <activity android:name=".liveupdates.OsmLiveActivity"
android:label="@string/osm_live"/> android:label="@string/osm_live"/>
<activity android:name=".wikivoyage.explore.WikivoyageExploreActivity"/> <activity android:name=".wikivoyage.explore.WikivoyageExploreActivity">
<intent-filter>
<data android:scheme="http" />
<data android:scheme="https" />
<data android:host="osmand.net" />
<data android:pathPrefix="/travel" />
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<category android:name="android.intent.category.APP_MAPS" />
<category android:name="android.intent.category.CAR_MODE" />
<category android:name="android.intent.category.CAR_DOCK" />
<category android:name="android.intent.category.DESK_DOCK" />
</intent-filter>
</activity>
<receiver android:name="net.osmand.plus.liveupdates.LiveUpdatesAlarmReceiver"/> <receiver android:name="net.osmand.plus.liveupdates.LiveUpdatesAlarmReceiver"/>
</application> </application>

View file

@ -410,11 +410,11 @@ dependencies {
implementation 'com.facebook.android:facebook-android-sdk:4.31.0' implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
} }
implementation 'com.android.support:multidex:1.0.1' implementation 'com.android.support:multidex:1.0.1'
implementation 'com.android.support:gridlayout-v7:27.1.0' implementation 'com.android.support:gridlayout-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.0' implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.android.support:appcompat-v7:27.1.0' implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.0' implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:customtabs:27.1.0' implementation 'com.android.support:customtabs:27.1.1'
implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs') implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs')
implementation 'commons-logging:commons-logging-api:1.1' implementation 'commons-logging:commons-logging-api:1.1'

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.4 KiB

View file

@ -193,38 +193,18 @@
android:src="@drawable/headliner_close"/> android:src="@drawable/headliner_close"/>
</LinearLayout> </LinearLayout>
<!-- CONTEXT MENU --> <ProgressBar
android:id="@+id/map_horizontal_progress"
<LinearLayout style="?android:attr/progressBarStyleHorizontal"
android:id="@+id/map_context_menu_layout"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom" android:layout_gravity="bottom"
android:background="@drawable/btn_flat" android:layout_height="4dp"
android:visibility="gone"> android:max="100"
android:visibility="gone"
tools:progress="60"
tools:visibility="visible" />
<TextView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center">
</TextView>
<ImageButton
android:layout_width="@dimen/map_address_height"
android:layout_height="@dimen/map_address_height"
android:layout_gravity="center_vertical"
android:background="@drawable/btn_circle_transparent"
tools:src="@drawable/ic_action_test_light"/>
<ImageButton
android:layout_width="@dimen/map_address_height"
android:layout_height="@dimen/map_address_height"
android:layout_gravity="center_vertical"
android:background="@drawable/btn_circle_transparent"
tools:src="@drawable/ic_action_test_light"/>
</LinearLayout>
</FrameLayout> </FrameLayout>
<!-- RIGHT BUTTONS --> <!-- RIGHT BUTTONS -->
@ -274,6 +254,7 @@
</LinearLayout> </LinearLayout>
<include <include
layout="@layout/move_marker_bottom_sheet" layout="@layout/move_marker_bottom_sheet"
android:layout_width="match_parent" android:layout_width="match_parent"

View file

@ -603,16 +603,6 @@
</FrameLayout> </FrameLayout>
<ProgressBar
android:id="@+id/map_horizontal_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="@dimen/map_routing_progress_width"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/map_button_margin"
android:layout_marginRight="@dimen/map_button_margin"
android:max="100"
android:progress="60"
android:visibility="gone"/>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -17,6 +17,16 @@
android:clickable="true" android:clickable="true"
android:orientation="vertical"> android:orientation="vertical">
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:max="100"
android:visibility="gone"
tools:progress="60"
tools:visibility="visible" />
<LinearLayout <LinearLayout
android:id="@+id/ModesLayout" android:id="@+id/ModesLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View file

@ -39,6 +39,8 @@
<android.support.design.widget.TextInputLayout <android.support.design.widget.TextInputLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/shared_string_name"
android:importantForAutofill="noExcludeDescendants"
android:layout_marginLeft="72dp" android:layout_marginLeft="72dp"
android:layout_marginRight="16dp"> android:layout_marginRight="16dp">
@ -46,8 +48,8 @@
android:id="@+id/poiNameEditText" android:id="@+id/poiNameEditText"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/shared_string_name"
android:imeOptions="actionNext" android:imeOptions="actionNext"
android:importantForAutofill="noExcludeDescendants"
android:inputType="textCapSentences" android:inputType="textCapSentences"
tools:text="@string/lorem_ipsum"/> tools:text="@string/lorem_ipsum"/>
@ -73,6 +75,8 @@
android:id="@+id/poiTypeTextInputLayout" android:id="@+id/poiTypeTextInputLayout"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:hint="@string/poi_dialog_poi_type"
android:importantForAutofill="noExcludeDescendants"
android:layout_marginLeft="24dp" android:layout_marginLeft="24dp"
android:layout_weight="1"> android:layout_weight="1">
@ -82,7 +86,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:completionThreshold="1" android:completionThreshold="1"
android:drawableRight="@drawable/ic_action_arrow_drop_down" android:drawableRight="@drawable/ic_action_arrow_drop_down"
android:hint="@string/poi_dialog_poi_type" android:importantForAutofill="noExcludeDescendants"
android:imeOptions="actionSend" android:imeOptions="actionSend"
android:inputType="text" android:inputType="text"
tools:text="@string/lorem_ipsum"/> tools:text="@string/lorem_ipsum"/>

View file

@ -180,4 +180,14 @@
</LinearLayout> </LinearLayout>
<LinearLayout
android:id="@+id/bottom_divider"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:visibility="gone">
<include layout="@layout/list_item_divider"/>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -122,7 +122,7 @@
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
android:id="@+id/additional_info_row" android:id="@+id/additional_info_row_container"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -138,6 +138,11 @@
android:paddingLeft="@dimen/context_menu_padding_margin_default" android:paddingLeft="@dimen/context_menu_padding_margin_default"
android:paddingRight="@dimen/context_menu_padding_margin_default"> android:paddingRight="@dimen/context_menu_padding_margin_default">
<LinearLayout
android:id="@+id/additional_info_row"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:id="@+id/context_menu_line3" android:id="@+id/context_menu_line3"
style="@style/TextAppearance.ContextMenuSubtitle" style="@style/TextAppearance.ContextMenuSubtitle"
@ -194,6 +199,7 @@
tools:textColor="?android:textColorSecondary"/> tools:textColor="?android:textColorSecondary"/>
</LinearLayout> </LinearLayout>
</LinearLayout>
</LinearLayout> </LinearLayout>

View file

@ -231,8 +231,20 @@
tools:src="@drawable/ic_action_test_light"/> tools:src="@drawable/ic_action_test_light"/>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<ProgressBar
android:id="@+id/map_horizontal_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:layout_gravity="bottom"
android:max="100"
android:visibility="gone"
tools:progress="60"
tools:visibility="visible" />
</FrameLayout> </FrameLayout>
<FrameLayout <FrameLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content">
@ -251,36 +263,6 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"/> android:layout_height="match_parent"/>
<LinearLayout
android:id="@+id/map_context_menu_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:background="@drawable/btn_flat"
android:visibility="gone">
<TextView
android:layout_width="0dp"
android:layout_height="fill_parent"
android:layout_weight="1"
android:ellipsize="end"
android:gravity="center">
</TextView>
<ImageButton
android:layout_width="@dimen/map_address_height"
android:layout_height="@dimen/map_address_height"
android:layout_gravity="center_vertical"
android:background="@drawable/btn_circle_transparent"
tools:src="@drawable/ic_action_test_light"/>
<ImageButton
android:layout_width="@dimen/map_address_height"
android:layout_height="@dimen/map_address_height"
android:layout_gravity="center_vertical"
android:background="@drawable/btn_circle_transparent"
tools:src="@drawable/ic_action_test_light"/>
</LinearLayout>
</FrameLayout> </FrameLayout>
</LinearLayout> </LinearLayout>

View file

@ -647,16 +647,6 @@
</FrameLayout> </FrameLayout>
<ProgressBar
android:id="@+id/map_horizontal_progress"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="@dimen/map_routing_progress_width"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/map_button_margin"
android:layout_marginRight="@dimen/map_button_margin"
android:max="100"
android:progress="60"
android:visibility="gone"/>
</LinearLayout> </LinearLayout>
</FrameLayout> </FrameLayout>

View file

@ -17,6 +17,16 @@
android:clickable="true" android:clickable="true"
android:orientation="vertical"> android:orientation="vertical">
<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="4dp"
android:max="100"
android:visibility="gone"
tools:progress="60"
tools:visibility="visible" />
<LinearLayout <LinearLayout
android:id="@+id/ModesLayout" android:id="@+id/ModesLayout"
android:layout_width="fill_parent" android:layout_width="fill_parent"

View file

@ -6,6 +6,48 @@
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"> android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="56dp"
android:background="?attr/bg_color"
android:orientation="horizontal">
<TextView
android:id="@+id/textView3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_weight="1"
android:padding="16dp"
android:text="@string/quick_action_interim_dialog"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/default_list_text_size" />
<android.support.v7.widget.SwitchCompat
android:id="@+id/saveButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_bottom" />
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="top"
android:layout_marginTop="16dp"
android:scaleType="fitXY"
android:src="@drawable/bg_shadow_list_top" />
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"

View file

@ -111,6 +111,9 @@
<color name="map_widget_blue">#536dfe</color> <color name="map_widget_blue">#536dfe</color>
<color name="map_widget_blue_pressed">#485dd9</color> <color name="map_widget_blue_pressed">#485dd9</color>
<color name="map_progress_bar_bg_light">#f0f0f0</color>
<color name="map_progress_bar_bg_dark">#1b1d1f</color>
<color name="actionbar_dark_color">#39464d</color> <color name="actionbar_dark_color">#39464d</color>
<color name="tool_bar_color_dark">#CC080B0D</color> <color name="tool_bar_color_dark">#CC080B0D</color>

View file

@ -10,6 +10,8 @@
- For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience - For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
Thx - Hardy Thx - Hardy
--> -->
<string name="error_notification_desc">Please send screenshoot of this notification to support@osmand.net</string>
<string name="quick_action_edit_actions">Edit actions</string>
<string name="get_osmand_live">Get OsmAnd Live to unlock all features: Daily map updates with unlimited downloads, all paid and free plugins, Wikipedia, Wikivoyage and much more.</string> <string name="get_osmand_live">Get OsmAnd Live to unlock all features: Daily map updates with unlimited downloads, all paid and free plugins, Wikipedia, Wikivoyage and much more.</string>
<string name="unirs_render_descr">Modification of the default style to increase contrast of pedestrian and bicycle roads. Uses legacy Mapnik colors.</string> <string name="unirs_render_descr">Modification of the default style to increase contrast of pedestrian and bicycle roads. Uses legacy Mapnik colors.</string>
<string name="shared_string_bookmark">Bookmark</string> <string name="shared_string_bookmark">Bookmark</string>

View file

@ -10,7 +10,10 @@ import android.content.res.Resources;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Paint; import android.graphics.Paint;
import android.graphics.PointF; import android.graphics.PointF;
import android.graphics.drawable.ClipDrawable;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.graphics.drawable.LayerDrawable;
import android.graphics.drawable.ShapeDrawable;
import android.graphics.drawable.StateListDrawable; import android.graphics.drawable.StateListDrawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
@ -31,6 +34,7 @@ import android.text.style.ImageSpan;
import android.text.style.URLSpan; import android.text.style.URLSpan;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity;
import android.view.View; import android.view.View;
import android.view.ViewParent; import android.view.ViewParent;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
@ -112,8 +116,12 @@ public class AndroidUtils {
} }
public static Uri getUriForFile(Context context, File file) { public static Uri getUriForFile(Context context, File file) {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
return Uri.fromFile(file);
} else {
return FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file); return FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
} }
}
public static Spannable replaceCharsWithIcon(String text, Drawable icon, String[] chars) { public static Spannable replaceCharsWithIcon(String text, Drawable icon, String[] chars) {
Spannable spannable = new SpannableString(text); Spannable spannable = new SpannableString(text);
@ -251,6 +259,24 @@ public class AndroidUtils {
return res; return res;
} }
public static LayerDrawable createProgressDrawable(@ColorInt int bgColor, @ColorInt int progressColor) {
ShapeDrawable bg = new ShapeDrawable();
bg.getPaint().setColor(bgColor);
ShapeDrawable progress = new ShapeDrawable();
progress.getPaint().setColor(progressColor);
LayerDrawable res = new LayerDrawable(new Drawable[]{
bg,
new ClipDrawable(progress, Gravity.START, ClipDrawable.HORIZONTAL)
});
res.setId(0, android.R.id.background);
res.setId(1, android.R.id.progress);
return res;
}
public static void setSnackbarTextColor(Snackbar snackbar, @ColorRes int colorId) { public static void setSnackbarTextColor(Snackbar snackbar, @ColorRes int colorId) {
View view = snackbar.getView(); View view = snackbar.getView();
TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_action); TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_action);

View file

@ -13,7 +13,7 @@ import android.content.res.Configuration;
import android.content.res.Resources; import android.content.res.Resources;
import android.os.Build; import android.os.Build;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.util.Log;
import net.osmand.IProgress; import net.osmand.IProgress;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
@ -67,7 +67,6 @@ import java.util.Locale;
import java.util.Random; import java.util.Random;
import btools.routingapp.BRouterServiceConnection; import btools.routingapp.BRouterServiceConnection;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn;
@ -178,6 +177,8 @@ public class AppInitializer implements IProgress {
startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit(); startPrefs.edit().putString(VERSION_INSTALLED, Version.getFullVersion(app)).commit();
appVersionChanged = true; appVersionChanged = true;
} }
app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(true);
app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(true);
initSettings = true; initSettings = true;
} }
@ -352,7 +353,8 @@ public class AppInitializer implements IProgress {
Integer in = (Integer) f.get(null); Integer in = (Integer) f.get(null);
return app.getString(in); return app.getString(in);
} }
} catch (Exception e) { } catch (Throwable e) {
LOG.info("No translation: " + keyName);
} }
return null; return null;
} }

View file

@ -732,7 +732,7 @@ public class FavouritesDbHelper {
"SELECT " + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", " + FAVOURITE_COL_LAT + "," + FAVOURITE_COL_LON + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ "SELECT " + FAVOURITE_COL_NAME + ", " + FAVOURITE_COL_CATEGORY + ", " + FAVOURITE_COL_LAT + "," + FAVOURITE_COL_LON + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
FAVOURITE_TABLE_NAME, null); FAVOURITE_TABLE_NAME, null);
cachedFavoritePoints.clear(); cachedFavoritePoints.clear();
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
do { do {
String name = query.getString(0); String name = query.getString(0);
String cat = query.getString(1); String cat = query.getString(1);
@ -748,7 +748,9 @@ public class FavouritesDbHelper {
} }
} while (query.moveToNext()); } while (query.moveToNext());
} }
if (query != null) {
query.close(); query.close();
}
} finally { } finally {
db.close(); db.close();
} }

View file

@ -523,12 +523,14 @@ public class GPXDatabase {
if (db != null) { if (db != null) {
try { try {
SQLiteCursor query = db.rawQuery(GPX_TABLE_SELECT, null); SQLiteCursor query = db.rawQuery(GPX_TABLE_SELECT, null);
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
do { do {
items.add(readItem(query)); items.add(readItem(query));
} while (query.moveToNext()); } while (query.moveToNext());
} }
if (query != null) {
query.close(); query.close();
}
} finally { } finally {
db.close(); db.close();
} }
@ -546,10 +548,12 @@ public class GPXDatabase {
String fileDir = getFileDir(file); String fileDir = getFileDir(file);
SQLiteCursor query = db.rawQuery(GPX_TABLE_SELECT + " WHERE " + GPX_COL_NAME + " = ? AND " + SQLiteCursor query = db.rawQuery(GPX_TABLE_SELECT + " WHERE " + GPX_COL_NAME + " = ? AND " +
GPX_COL_DIR + " = ?", new String[] { fileName, fileDir }); GPX_COL_DIR + " = ?", new String[] { fileName, fileDir });
if (query.moveToFirst()) { if ( query != null && query.moveToFirst()) {
result = readItem(query); result = readItem(query);
} }
if (query != null) {
query.close(); query.close();
}
} finally { } finally {
db.close(); db.close();
} }

View file

@ -6,6 +6,7 @@ import android.graphics.Canvas;
import android.graphics.Color; import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.support.annotation.ColorInt; import android.support.annotation.ColorInt;
import android.support.annotation.Nullable;
import android.text.TextUtils; import android.text.TextUtils;
import net.osmand.Location; import net.osmand.Location;
@ -268,6 +269,20 @@ public class GPXUtilities {
} }
public static class Metadata extends GPXExtensions {
public String desc;
@Nullable
public String getArticleTitle() {
return getExtensionsToRead().get("article_title");
}
@Nullable
public String getArticleLang() {
return getExtensionsToRead().get("article_lang");
}
}
public static class GPXTrackAnalysis { public static class GPXTrackAnalysis {
public float totalDistance = 0; public float totalDistance = 0;
public int totalTracks = 0; public int totalTracks = 0;
@ -779,6 +794,7 @@ public class GPXUtilities {
public static class GPXFile extends GPXExtensions { public static class GPXFile extends GPXExtensions {
public String author; public String author;
public Metadata metadata;
public List<Track> tracks = new ArrayList<>(); public List<Track> tracks = new ArrayList<>();
private List<WptPt> points = new ArrayList<>(); private List<WptPt> points = new ArrayList<>();
public List<Route> routes = new ArrayList<>(); public List<Route> routes = new ArrayList<>();
@ -1231,7 +1247,9 @@ public class GPXUtilities {
public static String writeGpxFile(File fout, GPXFile file, OsmandApplication ctx) { public static String writeGpxFile(File fout, GPXFile file, OsmandApplication ctx) {
Writer output = null; Writer output = null;
try { try {
if(fout.getParentFile() != null) {
fout.getParentFile().mkdirs(); fout.getParentFile().mkdirs();
}
output = new OutputStreamWriter(new FileOutputStream(fout), "UTF-8"); //$NON-NLS-1$ output = new OutputStreamWriter(new FileOutputStream(fout), "UTF-8"); //$NON-NLS-1$
String msg = writeGpx(output, file, ctx); String msg = writeGpx(output, file, ctx);
if(Algorithms.isEmpty(file.path)) { if(Algorithms.isEmpty(file.path)) {
@ -1272,6 +1290,13 @@ public class GPXUtilities {
serializer.attribute(null, "xsi:schemaLocation", serializer.attribute(null, "xsi:schemaLocation",
"http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd"); "http://www.topografix.com/GPX/1/1 http://www.topografix.com/GPX/1/1/gpx.xsd");
if (file.metadata != null) {
serializer.startTag(null, "metadata");
writeNotNullText(serializer, "desc", file.metadata.desc);
writeExtensions(serializer, file.metadata);
serializer.endTag(null, "metadata");
}
for (Track track : file.tracks) { for (Track track : file.tracks) {
if (!track.generalTrack) { if (!track.generalTrack) {
serializer.startTag(null, "trk"); //$NON-NLS-1$ serializer.startTag(null, "trk"); //$NON-NLS-1$
@ -1448,8 +1473,8 @@ public class GPXUtilities {
formatMillis.setTimeZone(TimeZone.getTimeZone("UTC")); formatMillis.setTimeZone(TimeZone.getTimeZone("UTC"));
try { try {
XmlPullParser parser = PlatformUtil.newXMLPullParser(); XmlPullParser parser = PlatformUtil.newXMLPullParser();
parser.setInput(getUTF8Reader(f)); //$NON-NLS-1$ parser.setInput(getUTF8Reader(f));
Stack<GPXExtensions> parserState = new Stack<GPXExtensions>(); Stack<GPXExtensions> parserState = new Stack<>();
boolean extensionReadMode = false; boolean extensionReadMode = false;
parserState.push(res); parserState.push(res);
int tok; int tok;
@ -1473,55 +1498,64 @@ public class GPXUtilities {
extensionReadMode = true; extensionReadMode = true;
} else { } else {
if (parse instanceof GPXFile) { if (parse instanceof GPXFile) {
if (parser.getName().equals("gpx")) { if (tag.equals("gpx")) {
((GPXFile) parse).author = parser.getAttributeValue("", "creator"); ((GPXFile) parse).author = parser.getAttributeValue("", "creator");
} }
if (parser.getName().equals("trk")) { if (tag.equals("metadata")) {
Metadata metadata = new Metadata();
((GPXFile) parse).metadata = metadata;
parserState.push(metadata);
}
if (tag.equals("trk")) {
Track track = new Track(); Track track = new Track();
((GPXFile) parse).tracks.add(track); ((GPXFile) parse).tracks.add(track);
parserState.push(track); parserState.push(track);
} }
if (parser.getName().equals("rte")) { if (tag.equals("rte")) {
Route route = new Route(); Route route = new Route();
((GPXFile) parse).routes.add(route); ((GPXFile) parse).routes.add(route);
parserState.push(route); parserState.push(route);
} }
if (parser.getName().equals("wpt")) { if (tag.equals("wpt")) {
WptPt wptPt = parseWptAttributes(parser); WptPt wptPt = parseWptAttributes(parser);
((GPXFile) parse).points.add(wptPt); ((GPXFile) parse).points.add(wptPt);
parserState.push(wptPt); parserState.push(wptPt);
} }
} else if (parse instanceof Metadata) {
if (tag.equals("desc")) {
((Metadata) parse).desc = readText(parser, "desc");
}
} else if (parse instanceof Route) { } else if (parse instanceof Route) {
if (parser.getName().equals("name")) { if (tag.equals("name")) {
((Route) parse).name = readText(parser, "name"); ((Route) parse).name = readText(parser, "name");
} }
if (parser.getName().equals("desc")) { if (tag.equals("desc")) {
((Route) parse).desc = readText(parser, "desc"); ((Route) parse).desc = readText(parser, "desc");
} }
if (parser.getName().equals("rtept")) { if (tag.equals("rtept")) {
WptPt wptPt = parseWptAttributes(parser); WptPt wptPt = parseWptAttributes(parser);
((Route) parse).points.add(wptPt); ((Route) parse).points.add(wptPt);
parserState.push(wptPt); parserState.push(wptPt);
} }
} else if (parse instanceof Track) { } else if (parse instanceof Track) {
if (parser.getName().equals("name")) { if (tag.equals("name")) {
((Track) parse).name = readText(parser, "name"); ((Track) parse).name = readText(parser, "name");
} }
if (parser.getName().equals("desc")) { if (tag.equals("desc")) {
((Track) parse).desc = readText(parser, "desc"); ((Track) parse).desc = readText(parser, "desc");
} }
if (parser.getName().equals("trkseg")) { if (tag.equals("trkseg")) {
TrkSegment trkSeg = new TrkSegment(); TrkSegment trkSeg = new TrkSegment();
((Track) parse).segments.add(trkSeg); ((Track) parse).segments.add(trkSeg);
parserState.push(trkSeg); parserState.push(trkSeg);
} }
} else if (parse instanceof TrkSegment) { } else if (parse instanceof TrkSegment) {
if (parser.getName().equals("trkpt")) { if (tag.equals("trkpt")) {
WptPt wptPt = parseWptAttributes(parser); WptPt wptPt = parseWptAttributes(parser);
((TrkSegment) parse).points.add(wptPt); ((TrkSegment) parse).points.add(wptPt);
parserState.push(wptPt); parserState.push(wptPt);
} }
if (parser.getName().equals("csvattributes")) { if (tag.equals("csvattributes")) {
String segmentPoints = readText(parser, "csvattributes"); String segmentPoints = readText(parser, "csvattributes");
String[] pointsArr = segmentPoints.split("\n"); String[] pointsArr = segmentPoints.split("\n");
for (int i = 0; i < pointsArr.length; i++) { for (int i = 0; i < pointsArr.length; i++) {
@ -1543,20 +1577,20 @@ public class GPXUtilities {
} }
// main object to parse // main object to parse
} else if (parse instanceof WptPt) { } else if (parse instanceof WptPt) {
if (parser.getName().equals("name")) { if (tag.equals("name")) {
((WptPt) parse).name = readText(parser, "name"); ((WptPt) parse).name = readText(parser, "name");
} else if (parser.getName().equals("desc")) { } else if (tag.equals("desc")) {
((WptPt) parse).desc = readText(parser, "desc"); ((WptPt) parse).desc = readText(parser, "desc");
} else if (parser.getName().equals("cmt")) { } else if (tag.equals("cmt")) {
((WptPt) parse).comment = readText(parser, "cmt"); ((WptPt) parse).comment = readText(parser, "cmt");
} else if (parser.getName().equals("speed")) { } else if (tag.equals("speed")) {
try { try {
String value = readText(parser, "speed"); String value = readText(parser, "speed");
((WptPt) parse).speed = Float.parseFloat(value); ((WptPt) parse).speed = Float.parseFloat(value);
((WptPt) parse).getExtensionsToWrite().put("speed", value); ((WptPt) parse).getExtensionsToWrite().put("speed", value);
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
} else if (parser.getName().equals("link")) { } else if (tag.equals("link")) {
((WptPt) parse).link = parser.getAttributeValue("", "href"); ((WptPt) parse).link = parser.getAttributeValue("", "href");
} else if (tag.equals("category")) { } else if (tag.equals("category")) {
((WptPt) parse).category = readText(parser, "category"); ((WptPt) parse).category = readText(parser, "category");
@ -1564,7 +1598,7 @@ public class GPXUtilities {
if (((WptPt) parse).category == null) { if (((WptPt) parse).category == null) {
((WptPt) parse).category = readText(parser, "type"); ((WptPt) parse).category = readText(parser, "type");
} }
} else if (parser.getName().equals("ele")) { } else if (tag.equals("ele")) {
String text = readText(parser, "ele"); String text = readText(parser, "ele");
if (text != null) { if (text != null) {
try { try {
@ -1572,7 +1606,7 @@ public class GPXUtilities {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
} }
} else if (parser.getName().equals("hdop")) { } else if (tag.equals("hdop")) {
String text = readText(parser, "hdop"); String text = readText(parser, "hdop");
if (text != null) { if (text != null) {
try { try {
@ -1580,7 +1614,7 @@ public class GPXUtilities {
} catch (NumberFormatException e) { } catch (NumberFormatException e) {
} }
} }
} else if (parser.getName().equals("time")) { } else if (tag.equals("time")) {
String text = readText(parser, "time"); String text = readText(parser, "time");
if (text != null) { if (text != null) {
try { try {
@ -1604,7 +1638,10 @@ public class GPXUtilities {
extensionReadMode = false; extensionReadMode = false;
} }
if (tag.equals("trkpt")) { if (tag.equals("metadata")) {
Object pop = parserState.pop();
assert pop instanceof Metadata;
} else if (tag.equals("trkpt")) {
Object pop = parserState.pop(); Object pop = parserState.pop();
assert pop instanceof WptPt; assert pop instanceof WptPt;
} else if (tag.equals("wpt")) { } else if (tag.equals("wpt")) {
@ -1625,17 +1662,6 @@ public class GPXUtilities {
} }
} }
} }
// if (convertCloudmadeSource && res.isCloudmadeRouteFile()) {
// Track tk = new Track();
// res.tracks.add(tk);
// TrkSegment segment = new TrkSegment();
// tk.segments.add(segment);
//
// for (WptPt wp : res.points) {
// segment.points.add(wp);
// }
// res.points.clear();
// }
} catch (RuntimeException e) { } catch (RuntimeException e) {
log.error("Error reading gpx", e); //$NON-NLS-1$ log.error("Error reading gpx", e); //$NON-NLS-1$
res.warning = ctx.getString(R.string.error_reading_gpx) + " " + e.getMessage(); res.warning = ctx.getString(R.string.error_reading_gpx) + " " + e.getMessage();

View file

@ -244,7 +244,10 @@ public class GpxSelectionHelper {
return dg; return dg;
} }
private static void processGroupTrack(OsmandApplication app, GpxDisplayGroup group) { private static void processGroupTrack(@NonNull OsmandApplication app, @NonNull GpxDisplayGroup group) {
if (group.track == null) {
return;
}
List<GpxDisplayItem> list = group.getModifiableList(); List<GpxDisplayItem> list = group.getModifiableList();
String timeSpanClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_time_span_color)); String timeSpanClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_time_span_color));
String speedClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_speed)); String speedClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_speed));
@ -252,7 +255,6 @@ public class GpxSelectionHelper {
String descClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_altitude_desc)); String descClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_altitude_desc));
String distanceClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_distance_color)); String distanceClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_distance_color));
final float eleThreshold = 3; final float eleThreshold = 3;
// int t = 1;
for (TrkSegment r : group.track.segments) { for (TrkSegment r : group.track.segments) {
if (r.points.size() == 0) { if (r.points.size() == 0) {
continue; continue;

View file

@ -165,15 +165,12 @@ public class NavigationService extends Service implements LocationListener {
// registering icon at top level // registering icon at top level
// Leave icon visible even for navigation for proper display // Leave icon visible even for navigation for proper display
Notification notification = app.getNotificationHelper().buildTopNotification(); Notification notification = app.getNotificationHelper().buildTopNotification();
if (notification != null) {
startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification); startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification);
app.getNotificationHelper().refreshNotifications(); app.getNotificationHelper().refreshNotifications();
}
return START_REDELIVER_INTENT; return START_REDELIVER_INTENT;
} }
@Override @Override
public void onCreate() { public void onCreate() {
super.onCreate(); super.onCreate();

View file

@ -3,15 +3,19 @@ package net.osmand.plus;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import net.osmand.plus.notifications.ErrorNotification;
import net.osmand.plus.notifications.GpxNotification; import net.osmand.plus.notifications.GpxNotification;
import net.osmand.plus.notifications.NavigationNotification; import net.osmand.plus.notifications.NavigationNotification;
import net.osmand.plus.notifications.OsmandNotification; import net.osmand.plus.notifications.OsmandNotification;
import net.osmand.plus.notifications.OsmandNotification.NotificationType; import net.osmand.plus.notifications.OsmandNotification.NotificationType;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel; import android.app.NotificationChannel;
import android.app.NotificationManager; import android.app.NotificationManager;
import android.content.Context; import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.NotificationCompat.Builder; import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.NotificationManagerCompat;
@ -22,6 +26,7 @@ public class NotificationHelper {
private NavigationNotification navigationNotification; private NavigationNotification navigationNotification;
private GpxNotification gpxNotification; private GpxNotification gpxNotification;
private ErrorNotification errorNotification;
private List<OsmandNotification> all = new ArrayList<>(); private List<OsmandNotification> all = new ArrayList<>();
public NotificationHelper(OsmandApplication app) { public NotificationHelper(OsmandApplication app) {
@ -32,29 +37,43 @@ public class NotificationHelper {
private void init() { private void init() {
navigationNotification = new NavigationNotification(app); navigationNotification = new NavigationNotification(app);
gpxNotification = new GpxNotification(app); gpxNotification = new GpxNotification(app);
errorNotification = new ErrorNotification(app);
all.add(navigationNotification); all.add(navigationNotification);
all.add(gpxNotification); all.add(gpxNotification);
} }
@NonNull
public Notification buildTopNotification() { public Notification buildTopNotification() {
OsmandNotification notification = acquireTopNotification(); OsmandNotification notification = acquireTopNotification();
if (notification != null) { if (notification != null) {
removeNotification(notification.getType()); removeNotification(notification.getType());
setTopNotification(notification); setTopNotification(notification);
Builder notificationBuilder = notification.buildNotification(false); Builder notificationBuilder = notification.buildNotification(false);
if (notificationBuilder != null) {
return notificationBuilder.build(); return notificationBuilder.build();
} else {
return buildErrorNotification();
}
} else {
return buildErrorNotification();
} }
return null;
} }
private OsmandNotification acquireTopNotification() { private Notification buildErrorNotification() {
OsmandNotification notification = null; removeNotification(errorNotification.getType());
if (navigationNotification.isEnabled()) { setTopNotification(errorNotification);
notification = navigationNotification; return errorNotification.buildNotification(false).build();
} else if (gpxNotification.isEnabled() && gpxNotification.isActive()) { }
notification = gpxNotification;
@Nullable
private OsmandNotification acquireTopNotification() {
if (navigationNotification.isEnabled()) {
return navigationNotification;
} else if (gpxNotification.isEnabled() && gpxNotification.isActive()) {
return gpxNotification;
} else {
return null;
} }
return notification;
} }
public void updateTopNotification() { public void updateTopNotification() {

View file

@ -5,6 +5,7 @@ import java.util.Arrays;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
import net.osmand.GeoidAltitudeCorrection; import net.osmand.GeoidAltitudeCorrection;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
@ -70,19 +71,23 @@ public class OsmAndLocationProvider implements SensorEventListener {
private static final int GPS_DIST_REQUEST = 0; private static final int GPS_DIST_REQUEST = 0;
private static final int NOT_SWITCH_TO_NETWORK_WHEN_GPS_LOST_MS = 12000; private static final int NOT_SWITCH_TO_NETWORK_WHEN_GPS_LOST_MS = 12000;
private static final long STALE_LOCATION_TIMEOUT = 1000 * 60 * 5; // 5 minutes private static final long LOCATION_TIMEOUT_TO_BE_STALE = 1000 * 60 * 2; // 2 minutes
private static final long STALE_LOCATION_TIMEOUT_FOR_UI = 1000 * 60 * 15; // 15 minutes private static final long STALE_LOCATION_TIMEOUT_TO_BE_GONE = 1000 * 60 * 20; // 20 minutes
private static final int REQUESTS_BEFORE_CHECK_LOCATION = 100; private static final int REQUESTS_BEFORE_CHECK_LOCATION = 100;
private int locationRequestsCounter; private AtomicInteger locationRequestsCounter = new AtomicInteger();
private int staleLocationRequestsCounter; private AtomicInteger staleLocationRequestsCounter = new AtomicInteger();
private net.osmand.Location cachedLocation;
private long lastTimeGPSLocationFixed = 0; private long lastTimeGPSLocationFixed = 0;
private long lastTimeLocationFixed = 0;
private boolean gpsSignalLost; private boolean gpsSignalLost;
private SimulationProvider simulatePosition = null; private SimulationProvider simulatePosition = null;
private long cachedLocationTimeFix = 0;
private net.osmand.Location cachedLocation;
private boolean sensorRegistered = false; private boolean sensorRegistered = false;
private float[] mGravs = new float[3]; private float[] mGravs = new float[3];
private float[] mGeoMags = new float[3]; private float[] mGeoMags = new float[3];
@ -584,7 +589,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
@Override @Override
public void onLocationChanged(Location location) { public void onLocationChanged(Location location) {
if (location != null) { if (location != null) {
lastTimeGPSLocationFixed = location.getTime(); // lastTimeGPSLocationFixed = location.getTime();
lastTimeGPSLocationFixed = System.currentTimeMillis();
} }
if(!locationSimulation.isRouteAnimating()) { if(!locationSimulation.isRouteAnimating()) {
setLocation(convertLocation(location, app)); setLocation(convertLocation(location, app));
@ -690,7 +696,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
private void scheduleCheckIfGpsLost(final net.osmand.Location location) { private void scheduleCheckIfGpsLost(final net.osmand.Location location) {
final RoutingHelper routingHelper = app.getRoutingHelper(); final RoutingHelper routingHelper = app.getRoutingHelper();
if (location != null) { if (location != null && routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0
&& simulatePosition == null) {
final long fixTime = location.getTime(); final long fixTime = location.getTime();
app.runMessageInUIThreadAndCancelPrevious(LOST_LOCATION_MSG_ID, new Runnable() { app.runMessageInUIThreadAndCancelPrevious(LOST_LOCATION_MSG_ID, new Runnable() {
@ -702,13 +709,13 @@ public class OsmAndLocationProvider implements SensorEventListener {
return; return;
} }
gpsSignalLost = true; gpsSignalLost = true;
if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0) { if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0
&& simulatePosition == null) {
routingHelper.getVoiceRouter().gpsLocationLost(); routingHelper.getVoiceRouter().gpsLocationLost();
}
setLocation(null); setLocation(null);
} }
}
}, LOST_LOCATION_CHECK_DELAY); }, LOST_LOCATION_CHECK_DELAY);
if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0 && simulatePosition == null) {
app.runMessageInUIThreadAndCancelPrevious(START_SIMULATE_LOCATION_MSG_ID, new Runnable() { app.runMessageInUIThreadAndCancelPrevious(START_SIMULATE_LOCATION_MSG_ID, new Runnable() {
@Override @Override
@ -728,7 +735,6 @@ public class OsmAndLocationProvider implements SensorEventListener {
}, START_LOCATION_SIMULATION_DELAY); }, START_LOCATION_SIMULATION_DELAY);
} }
} }
}
public void simulatePosition() { public void simulatePosition() {
app.runMessageInUIThreadAndCancelPrevious(RUN_SIMULATE_LOCATION_MSG_ID, new Runnable() { app.runMessageInUIThreadAndCancelPrevious(RUN_SIMULATE_LOCATION_MSG_ID, new Runnable() {
@ -772,7 +778,10 @@ public class OsmAndLocationProvider implements SensorEventListener {
if(location == null){ if(location == null){
updateGPSInfo(null); updateGPSInfo(null);
} }
if(location != null) { if(location != null) {
// // use because there is a bug on some devices with location.getTime()
lastTimeLocationFixed = System.currentTimeMillis();
simulatePosition = null; simulatePosition = null;
if(gpsSignalLost) { if(gpsSignalLost) {
gpsSignalLost = false; gpsSignalLost = false;
@ -817,12 +826,6 @@ public class OsmAndLocationProvider implements SensorEventListener {
} }
} }
public void checkIfLastKnownLocationIsValid() {
net.osmand.Location loc = getLastKnownLocation();
if (loc != null && (System.currentTimeMillis() - loc.getTime()) > INTERVAL_TO_CLEAR_SET_LOCATION) {
setLocation(null);
}
}
public NavigationInfo getNavigationInfo() { public NavigationInfo getNavigationInfo() {
return navigationInfo; return navigationInfo;
@ -869,15 +872,14 @@ public class OsmAndLocationProvider implements SensorEventListener {
} }
public net.osmand.Location getLastKnownLocation() { public net.osmand.Location getLastKnownLocation() {
net.osmand.Location location = this.location; net.osmand.Location loc = this.location;
if (location != null && locationRequestsCounter == 0 if (loc != null) {
&& System.currentTimeMillis() - location.getTime() > STALE_LOCATION_TIMEOUT) { int counter = locationRequestsCounter.incrementAndGet();
if (counter >= REQUESTS_BEFORE_CHECK_LOCATION && locationRequestsCounter.compareAndSet(counter, 0)) {
if (System.currentTimeMillis() - lastTimeLocationFixed > LOCATION_TIMEOUT_TO_BE_STALE) {
location = null; location = null;
} }
if (locationRequestsCounter == REQUESTS_BEFORE_CHECK_LOCATION) { }
locationRequestsCounter = 0;
} else {
locationRequestsCounter++;
} }
return location; return location;
} }
@ -885,18 +887,17 @@ public class OsmAndLocationProvider implements SensorEventListener {
@Nullable @Nullable
public net.osmand.Location getLastStaleKnownLocation() { public net.osmand.Location getLastStaleKnownLocation() {
net.osmand.Location newLoc = getLastKnownLocation(); net.osmand.Location newLoc = getLastKnownLocation();
if (newLoc == null) { if (newLoc == null && cachedLocation != null) {
if (staleLocationRequestsCounter == 0 && cachedLocation != null int counter = staleLocationRequestsCounter.incrementAndGet();
&& System.currentTimeMillis() - cachedLocation.getTime() > STALE_LOCATION_TIMEOUT_FOR_UI) { if (counter >= REQUESTS_BEFORE_CHECK_LOCATION && staleLocationRequestsCounter.compareAndSet(counter, 0)) {
net.osmand.Location cached = cachedLocation;
if (cached != null && System.currentTimeMillis() - cachedLocationTimeFix > STALE_LOCATION_TIMEOUT_TO_BE_GONE) {
cachedLocation = null; cachedLocation = null;
} }
}
} else { } else {
cachedLocation = newLoc; cachedLocation = newLoc;
} cachedLocationTimeFix = lastTimeLocationFixed;
if (staleLocationRequestsCounter == REQUESTS_BEFORE_CHECK_LOCATION) {
staleLocationRequestsCounter = 0;
} else {
staleLocationRequestsCounter++;
} }
return cachedLocation; return cachedLocation;
} }

View file

@ -3006,6 +3006,9 @@ public class OsmandSettings {
public final OsmandPreference<String> SELECTED_TRAVEL_BOOK = new StringPreference("selected_travel_book", "").makeGlobal(); public final OsmandPreference<String> SELECTED_TRAVEL_BOOK = new StringPreference("selected_travel_book", "").makeGlobal();
public final OsmandPreference<Boolean> SHOW_TRAVEL_UPDATE_CARD = new BooleanPreference("show_travel_update_card", true).makeGlobal();
public final OsmandPreference<Boolean> SHOW_TRAVEL_NEEDED_MAPS_CARD = new BooleanPreference("show_travel_needed_maps_card", true).makeGlobal();
public final ListStringPreference TRANSPORT_DEFAULT_SETTINGS = public final ListStringPreference TRANSPORT_DEFAULT_SETTINGS =
(ListStringPreference) new ListStringPreference("transport_default_settings", "transportStops", ",").makeProfile(); (ListStringPreference) new ListStringPreference("transport_default_settings", "transportStops", ",").makeProfile();

View file

@ -238,7 +238,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false)); icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false));
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText, DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app, activity); favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app);
name.setText(getName(favorite)); name.setText(getName(favorite));
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item); final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);

View file

@ -93,7 +93,6 @@ import net.osmand.plus.helpers.ExternalApiHelper;
import net.osmand.plus.helpers.ImportHelper; import net.osmand.plus.helpers.ImportHelper;
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment; import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
import net.osmand.plus.helpers.WakeLockHelper; import net.osmand.plus.helpers.WakeLockHelper;
import net.osmand.plus.inapp.InAppPurchaseHelper;
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment; import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment; import net.osmand.plus.mapcontextmenu.builders.cards.dialogs.ContextMenuCardDialogFragment;
@ -282,8 +281,8 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
} }
}; };
app.getResourceManager().getMapTileDownloader().addDownloaderCallback(downloaderCallback); app.getResourceManager().getMapTileDownloader().addDownloaderCallback(downloaderCallback);
createProgressBarForRouting();
mapLayers.createLayers(mapView); mapLayers.createLayers(mapView);
createProgressBarForRouting();
updateStatusBarColor(); updateStatusBarColor();
// This situtation could be when navigation suddenly crashed and after restarting // This situtation could be when navigation suddenly crashed and after restarting
// it tries to continue the last route // it tries to continue the last route
@ -434,12 +433,26 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
app.getRoutingHelper().setProgressBar(new RouteCalculationProgressCallback() { app.getRoutingHelper().setProgressBar(new RouteCalculationProgressCallback() {
@Override
public void start() {
boolean night = getMyApplication().getDaynightHelper().isNightModeForMapControls();
int bgColor = ContextCompat.getColor(app, night
? R.color.map_progress_bar_bg_dark : R.color.map_progress_bar_bg_light);
pb.setProgressDrawable(AndroidUtils
.createProgressDrawable(bgColor, mapLayers.getRouteLayer().getRouteLineColor(night)));
}
@Override @Override
public void updateProgress(int progress) { public void updateProgress(int progress) {
mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateRouteCalculationProgress(progress);
if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) { if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) {
if (pbExtView.getVisibility() == View.VISIBLE) { if (pbExtView.getVisibility() == View.VISIBLE) {
pbExtView.setVisibility(View.GONE); pbExtView.setVisibility(View.GONE);
} }
if (MapRouteInfoMenu.isVisible()) {
pb.setVisibility(View.GONE);
return;
}
if (pb.getVisibility() == View.GONE) { if (pb.getVisibility() == View.GONE) {
pb.setVisibility(View.VISIBLE); pb.setVisibility(View.VISIBLE);
} }
@ -492,6 +505,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
@Override @Override
public void finish() { public void finish() {
mapLayers.getMapControlsLayer().getMapRouteInfoMenu().routeCalculationFinished();
pbExtView.setVisibility(View.GONE); pbExtView.setVisibility(View.GONE);
pb.setVisibility(View.GONE); pb.setVisibility(View.GONE);
} }
@ -641,7 +655,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
getSupportActionBar().hide(); getSupportActionBar().hide();
} }
app.getLocationProvider().checkIfLastKnownLocationIsValid();
// for voice navigation // for voice navigation
ApplicationMode routingAppMode = getRoutingHelper().getAppMode(); ApplicationMode routingAppMode = getRoutingHelper().getAppMode();
if (routingAppMode != null && settings.AUDIO_STREAM_GUIDANCE.getModeValue(routingAppMode) != null) { if (routingAppMode != null && settings.AUDIO_STREAM_GUIDANCE.getModeValue(routingAppMode) != null) {

View file

@ -568,6 +568,10 @@ public class MapActivityLayers {
return activity.getString(resId); return activity.getString(resId);
} }
public RouteLayer getRouteLayer() {
return routeLayer;
}
public PointNavigationLayer getNavigationLayer() { public PointNavigationLayer getNavigationLayer() {
return navigationLayer; return navigationLayer;
} }

View file

@ -19,8 +19,7 @@ public class OsmandActionBarActivity extends OsmandInAppPurchaseActivity {
//should be called after set content view //should be called after set content view
protected void setupHomeButton(){ protected void setupHomeButton(){
Drawable back = ((OsmandApplication)getApplication()).getIconsCache().getIcon(R.drawable.ic_arrow_back); Drawable back = ((OsmandApplication)getApplication()).getIconsCache().getIcon(R.drawable.ic_arrow_back, R.color.color_white);
back.setColorFilter(ContextCompat.getColor(this, R.color.color_white), PorterDuff.Mode.MULTIPLY);
final ActionBar supportActionBar = getSupportActionBar(); final ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) { if (supportActionBar != null) {
supportActionBar.setHomeButtonEnabled(true); supportActionBar.setHomeButtonEnabled(true);

View file

@ -34,6 +34,7 @@ import net.osmand.plus.R;
import net.osmand.plus.measurementtool.NewGpxData; import net.osmand.plus.measurementtool.NewGpxData;
import net.osmand.plus.myplaces.FavoritesActivity; import net.osmand.plus.myplaces.FavoritesActivity;
import net.osmand.plus.myplaces.SplitSegmentDialogFragment; import net.osmand.plus.myplaces.SplitSegmentDialogFragment;
import net.osmand.plus.myplaces.TrackActivityFragmentAdapter;
import net.osmand.plus.myplaces.TrackBitmapDrawer; import net.osmand.plus.myplaces.TrackBitmapDrawer;
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener; import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
import net.osmand.plus.myplaces.TrackPointFragment; import net.osmand.plus.myplaces.TrackPointFragment;
@ -51,6 +52,7 @@ public class TrackActivity extends TabActivity {
public static final String OPEN_POINTS_TAB = "OPEN_POINTS_TAB"; public static final String OPEN_POINTS_TAB = "OPEN_POINTS_TAB";
public static final String OPEN_TRACKS_LIST = "OPEN_TRACKS_LIST"; public static final String OPEN_TRACKS_LIST = "OPEN_TRACKS_LIST";
public static final String CURRENT_RECORDING = "CURRENT_RECORDING"; public static final String CURRENT_RECORDING = "CURRENT_RECORDING";
public static final String SHOW_TEMPORARILY = "SHOW_TEMPORARILY";
protected List<WeakReference<Fragment>> fragList = new ArrayList<>(); protected List<WeakReference<Fragment>> fragList = new ArrayList<>();
private OsmandApplication app; private OsmandApplication app;
private TrackBitmapDrawer trackBitmapDrawer; private TrackBitmapDrawer trackBitmapDrawer;
@ -320,6 +322,19 @@ public class TrackActivity extends TabActivity {
} }
} }
public void updateHeader(Fragment sender) {
for (WeakReference<Fragment> f : fragList) {
Fragment frag = f.get();
if (frag != sender) {
if (frag instanceof TrackSegmentFragment) {
((TrackSegmentFragment) frag).updateHeader();
} else if (frag instanceof TrackPointFragment) {
((TrackPointFragment) frag).updateHeader();
}
}
}
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (openTracksList) { if (openTracksList) {
@ -440,6 +455,7 @@ public class TrackActivity extends TabActivity {
private OsmandApplication app; private OsmandApplication app;
private WeakReference<TrackActivity> activityRef; private WeakReference<TrackActivity> activityRef;
private File file; private File file;
private boolean showTemporarily;
private TrackActivity getTrackActivity() { private TrackActivity getTrackActivity() {
return activityRef.get(); return activityRef.get();
@ -455,6 +471,11 @@ public class TrackActivity extends TabActivity {
TrackActivity activity = getTrackActivity(); TrackActivity activity = getTrackActivity();
if (activity != null) { if (activity != null) {
activity.setSupportProgressBarIndeterminateVisibility(true); activity.setSupportProgressBarIndeterminateVisibility(true);
Intent intent = activity.getIntent();
if (intent != null && intent.hasExtra(SHOW_TEMPORARILY)) {
showTemporarily = true;
intent.removeExtra(SHOW_TEMPORARILY);
}
} }
} }
@ -491,7 +512,9 @@ public class TrackActivity extends TabActivity {
TrackActivity activity = getTrackActivity(); TrackActivity activity = getTrackActivity();
if (activity != null) { if (activity != null) {
activity.setSupportProgressBarIndeterminateVisibility(false); activity.setSupportProgressBarIndeterminateVisibility(false);
if (showTemporarily && result != null) {
app.getSelectedGpxHelper().selectGpxFile(result, false, false);
}
if (!activity.stopped) { if (!activity.stopped) {
activity.onGPXFileReady(result); activity.onGPXFileReady(result);
} }

View file

@ -242,7 +242,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
TextView distanceText = (TextView) row.findViewById(R.id.distance); TextView distanceText = (TextView) row.findViewById(R.id.distance);
ImageView direction = (ImageView) row.findViewById(R.id.direction); ImageView direction = (ImageView) row.findViewById(R.id.direction);
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText, DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
historyEntry.getLat(), historyEntry.getLon(), screenOrientation, getMyApplication(), getActivity()); historyEntry.getLat(), historyEntry.getLon(), screenOrientation, getMyApplication());
ImageButton options = (ImageButton) row.findViewById(R.id.options); ImageButton options = (ImageButton) row.findViewById(R.id.options);
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white)); options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white));
options.setVisibility(View.VISIBLE); options.setVisibility(View.VISIBLE);

View file

@ -785,7 +785,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
if (dd instanceof DirectionDrawable) { if (dd instanceof DirectionDrawable) {
draw = (DirectionDrawable) dd; draw = (DirectionDrawable) dd;
} else { } else {
draw = new DirectionDrawable(SearchPOIActivity.this, 24, 24, draw = new DirectionDrawable(getMyApplication(), 24, 24,
R.drawable.ic_direction_arrow, R.color.color_distance); R.drawable.ic_direction_arrow, R.color.color_distance);
direction.setImageDrawable(draw); direction.setImageDrawable(draw);
} }

View file

@ -1,15 +1,19 @@
package net.osmand.plus.api; package net.osmand.plus.api;
import net.osmand.PlatformUtil;
import net.osmand.plus.OsmandApplication;
import org.apache.commons.logging.Log;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.database.Cursor; import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteDatabase;
import net.osmand.plus.OsmandApplication;
public class SQLiteAPIImpl implements SQLiteAPI { public class SQLiteAPIImpl implements SQLiteAPI {
private OsmandApplication app; private OsmandApplication app;
private static final Log LOG = PlatformUtil.getLog(SQLiteAPIImpl.class);
public SQLiteAPIImpl(OsmandApplication app) { public SQLiteAPIImpl(OsmandApplication app) {
this.app = app; this.app = app;
@ -18,9 +22,13 @@ public class SQLiteAPIImpl implements SQLiteAPI {
@SuppressLint("InlinedApi") @SuppressLint("InlinedApi")
@Override @Override
public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) { public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) {
android.database.sqlite.SQLiteDatabase db = app.openOrCreateDatabase(name, android.database.sqlite.SQLiteDatabase db = null;
Context.MODE_PRIVATE | try {
(readOnly ? 0 : Context.MODE_ENABLE_WRITE_AHEAD_LOGGING), null); db = app.openOrCreateDatabase(name, Context.MODE_PRIVATE
| (readOnly ? 0 : Context.MODE_ENABLE_WRITE_AHEAD_LOGGING), null);
} catch (RuntimeException e) {
LOG.error(e.getMessage(), e);
}
if(db == null) { if(db == null) {
return null; return null;
} }

View file

@ -3,6 +3,7 @@ package net.osmand.plus.audionotes;
import android.Manifest; import android.Manifest;
import android.annotation.TargetApi; import android.annotation.TargetApi;
import android.app.Activity; import android.app.Activity;
import android.content.ClipData;
import android.content.ComponentName; import android.content.ComponentName;
import android.content.Context; import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
@ -828,6 +829,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
public void captureImage(double lat, double lon, final MapActivity mapActivity) { public void captureImage(double lat, double lon, final MapActivity mapActivity) {
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
Uri fileUri = AndroidUtils.getUriForFile(mapActivity, getBaseFileName(lat, lon, app, IMG_EXTENSION)); Uri fileUri = AndroidUtils.getUriForFile(mapActivity, getBaseFileName(lat, lon, app, IMG_EXTENSION));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
intent.setClipData(ClipData.newRawUri("", fileUri));
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
// start the image capture Intent // start the image capture Intent
@ -842,8 +846,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
// ext = THREEGP_EXTENSION; // ext = THREEGP_EXTENSION;
// } // }
Uri fileUri = AndroidUtils.getUriForFile(mapActivity, getBaseFileName(lat, lon, app, ext)); Uri fileUri = AndroidUtils.getUriForFile(mapActivity, getBaseFileName(lat, lon, app, ext));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
intent.setClipData(ClipData.newRawUri("", fileUri));
}
intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name intent.putExtra(MediaStore.EXTRA_OUTPUT, fileUri); // set the image file name
intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high intent.putExtra(MediaStore.EXTRA_VIDEO_QUALITY, 1); // set the video image quality to high
// start the video capture Intent // start the video capture Intent
mapActivity.startActivityForResult(intent, 205); mapActivity.startActivityForResult(intent, 205);
@ -907,27 +914,26 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
} }
} }
public void recordVideo(final double lat, final double lon, final MapActivity mapActivity, final boolean forceExternal) { public void recordVideo(final double lat, final double lon, final MapActivity mapActivity,
final boolean forceExternal) {
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA) == PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO) == PackageManager.PERMISSION_GRANTED) {
if (AV_EXTERNAL_RECORDER.get() || forceExternal) { if (AV_EXTERNAL_RECORDER.get() || forceExternal) {
captureVideoExternal(lat, lon, mapActivity); captureVideoExternal(lat, lon, mapActivity);
} else { } else {
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA)
== PackageManager.PERMISSION_GRANTED
&& ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO)
== PackageManager.PERMISSION_GRANTED) {
openCamera(); openCamera();
if (cam != null) { if (cam != null) {
initRecMenu(AVActionType.REC_VIDEO, lat, lon); initRecMenu(AVActionType.REC_VIDEO, lat, lon);
recordVideoCamera(lat, lon, mapActivity); recordVideoCamera(lat, lon, mapActivity);
} }
}
} else { } else {
actionLat = lat; actionLat = lat;
actionLon = lon; actionLon = lon;
ActivityCompat.requestPermissions(mapActivity, ActivityCompat.requestPermissions(mapActivity, new String[] { Manifest.permission.CAMERA,
new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO}, Manifest.permission.RECORD_AUDIO }, CAMERA_FOR_VIDEO_REQUEST_CODE);
CAMERA_FOR_VIDEO_REQUEST_CODE);
}
} }
} }
public void recordVideoCamera(final double lat, final double lon, final MapActivity mapActivity) { public void recordVideoCamera(final double lat, final double lon, final MapActivity mapActivity) {
@ -1503,8 +1509,12 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE); Intent takePictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
final File f = getBaseFileName(lat, lon, app, IMG_EXTENSION); final File f = getBaseFileName(lat, lon, app, IMG_EXTENSION);
lastTakingPhoto = f; lastTakingPhoto = f;
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, AndroidUtils.getUriForFile(mapActivity,f)); Uri uri = AndroidUtils.getUriForFile(mapActivity, f);
takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN && Build.VERSION.SDK_INT <= Build.VERSION_CODES.LOLLIPOP) {
takePictureIntent.setClipData(ClipData.newRawUri("", uri));
}
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, uri);
takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION | Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
try { try {
mapActivity.startActivityForResult(takePictureIntent, 205); mapActivity.startActivityForResult(takePictureIntent, 205);
} catch (Exception e) { } catch (Exception e) {

View file

@ -32,7 +32,6 @@ public abstract class DashLocationFragment extends DashBaseFragment {
private static final int ORIENTATION_180 = 2; private static final int ORIENTATION_180 = 2;
protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>(); protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
private int screenOrientation; private int screenOrientation;
protected LatLon lastUpdatedLocation;
public static class DashLocationView { public static class DashLocationView {
public ImageView arrow; public ImageView arrow;
@ -98,50 +97,61 @@ public abstract class DashLocationFragment extends DashBaseFragment {
float head = d.getHeading(); float head = d.getHeading();
float mapRotation = d.getMapRotation(); float mapRotation = d.getMapRotation();
LatLon mw = d.getMapViewLocation(); LatLon mw = d.getMapViewLocation();
Location l = d.getMyLocation(); boolean useCenter = !d.isMapLinkedToLocation();
boolean mapLinked = d.isMapLinkedToLocation() && l != null;
LatLon myLoc = l == null ? null : new LatLon(l.getLatitude(), l.getLongitude());
boolean useCenter = !mapLinked;
LatLon loc = (useCenter ? mw : myLoc);
float h = useCenter ? -mapRotation : head; float h = useCenter ? -mapRotation : head;
lastUpdatedLocation = loc;
for (DashLocationView lv : distances) { for (DashLocationView lv : distances) {
updateLocationView(useCenter, loc, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc, screenOrientation, updateLocationView(useCenter, mw, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc, screenOrientation,
getMyApplication(), getActivity(), lv.paint); getMyApplication(), lv.paint);
} }
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int imgColor, TextView txt, int textColor, double toLat, double toLon, ImageView arrow, int imgColor, TextView txt, int textColor, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx) { int screenOrientation, OsmandApplication app, Context ctx) {
updateLocationView(useCenter, fromLoc, h, arrow, 0, imgColor, txt, textColor, new LatLon(toLat, toLon), screenOrientation, app, ctx, true); updateLocationView(useCenter, fromLoc, h, arrow, 0, imgColor, txt, textColor, new LatLon(toLat, toLon), screenOrientation, app, true);
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, TextView txt, double toLat, double toLon, ImageView arrow, TextView txt, double toLat, double toLon,
int screenOrientation, OsmandApplication app, Context ctx) { int screenOrientation, OsmandApplication app) {
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, new LatLon(toLat, toLon), screenOrientation, app, ctx, true); updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, new LatLon(toLat, toLon), screenOrientation, app, true);
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, TextView txt, LatLon toLoc, ImageView arrow, int arrowResId, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) { int screenOrientation, OsmandApplication app, boolean paint) {
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, ctx, paint); updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, paint);
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, int imgColor, TextView txt, LatLon toLoc, ImageView arrow, int arrowResId, int imgColor, TextView txt, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) { int screenOrientation, OsmandApplication app, boolean paint) {
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, ctx, paint); updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, paint);
} }
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h, public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
ImageView arrow, int arrowResId, int imgColor, TextView txt, int textColor, LatLon toLoc, ImageView arrow, int arrowResId, int imgColor, TextView txt, int textColor, LatLon toLoc,
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) { int screenOrientation, OsmandApplication app, boolean paint) {
float[] mes = new float[2]; float[] mes = new float[2];
boolean stale = false;
if(!useCenter) {
Location loc = app.getLocationProvider().getLastKnownLocation();
if(loc == null) {
loc = app.getLocationProvider().getLastStaleKnownLocation();
stale = true;
}
if(loc != null) {
fromLoc = new LatLon(loc.getLatitude(), loc.getLongitude());
} else {
fromLoc = null;
}
}
if (fromLoc != null && toLoc != null) { if (fromLoc != null && toLoc != null) {
Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes); Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
} }
if (arrow != null) { if (arrow != null) {
boolean newImage = false; boolean newImage = false;
if (arrowResId == 0) { if (arrowResId == 0) {
@ -150,11 +160,18 @@ public abstract class DashLocationFragment extends DashBaseFragment {
DirectionDrawable dd; DirectionDrawable dd;
if(!(arrow.getDrawable() instanceof DirectionDrawable)) { if(!(arrow.getDrawable() instanceof DirectionDrawable)) {
newImage = true; newImage = true;
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight()); dd = new DirectionDrawable(app, arrow.getWidth(), arrow.getHeight());
} else { } else {
dd = (DirectionDrawable) arrow.getDrawable(); dd = (DirectionDrawable) arrow.getDrawable();
} }
dd.setImage(arrowResId, imgColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : imgColor); int imgColorSet = imgColor;
if (imgColorSet == 0) {
imgColorSet = useCenter ? R.color.color_distance : R.color.color_myloc_distance;
if(stale) {
imgColorSet = R.color.icon_color;
}
}
dd.setImage(arrowResId, imgColorSet);
if (fromLoc == null || h == null || toLoc == null) { if (fromLoc == null || h == null || toLoc == null) {
dd.setAngle(0); dd.setAngle(0);
} else { } else {
@ -168,8 +185,14 @@ public abstract class DashLocationFragment extends DashBaseFragment {
if (txt != null) { if (txt != null) {
if (fromLoc != null && toLoc != null) { if (fromLoc != null && toLoc != null) {
if (paint) { if (paint) {
txt.setTextColor(app.getResources().getColor( int textColorSet = textColor;
textColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : textColor)); if(textColorSet == 0) {
textColorSet = useCenter ? R.color.color_distance : R.color.color_myloc_distance ;
if(stale) {
textColorSet = R.color.icon_color;
}
}
txt.setTextColor(app.getResources().getColor(textColorSet));
} }
txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app)); txt.setText(OsmAndFormatter.getFormattedDistance(mes[0], app));
} else { } else {

View file

@ -149,7 +149,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
private ApplicationMode previousAppMode; private ApplicationMode previousAppMode;
private boolean landscape; private boolean landscape;
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<>(); private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<>();
private net.osmand.Location myLocation;
private LatLon mapViewLocation; private LatLon mapViewLocation;
private float heading; private float heading;
private boolean mapLinkedToLocation; private boolean mapLinkedToLocation;
@ -621,10 +620,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} }
} }
public net.osmand.Location getMyLocation() {
return myLocation;
}
public LatLon getMapViewLocation() { public LatLon getMapViewLocation() {
return mapViewLocation; return mapViewLocation;
} }
@ -716,7 +711,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
mapViewLocation = mapActivity.getMapLocation(); mapViewLocation = mapActivity.getMapLocation();
mapRotation = mapActivity.getMapRotate(); mapRotation = mapActivity.getMapRotate();
mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation(); mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
mapActivity.getMapViewTrackingUtilities().setDashboard(this); mapActivity.getMapViewTrackingUtilities().setDashboard(this);
mapActivity.disableDrawer(); mapActivity.disableDrawer();
dashboardView.setVisibility(View.VISIBLE); dashboardView.setVisibility(View.VISIBLE);
@ -1218,7 +1212,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
} }
public void updateMyLocation(net.osmand.Location location) { public void updateMyLocation(net.osmand.Location location) {
myLocation = location;
updateLocation(false, true, false); updateLocation(false, true, false);
} }

View file

@ -67,10 +67,16 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
stylesMap = generateStylesMap(context); stylesMap = generateStylesMap(context);
if (savedInstanceState == null) { if (savedInstanceState == null) {
selectedStyle = getMyApplication().getRendererRegistry().getCurrentSelectedRenderer().getName(); RenderingRulesStorage current = getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
if (current != null) {
selectedStyle = current.getName();
}
} else { } else {
selectedStyle = savedInstanceState.getString(SELECTED_STYLE_KEY); selectedStyle = savedInstanceState.getString(SELECTED_STYLE_KEY);
} }
if(selectedStyle == null) {
selectedStyle = RendererRegistry.DEFAULT_RENDER;
}
rbColorList = AndroidUtils.createCheckedColorStateList(context, R.color.icon_color, getActiveColorId()); rbColorList = AndroidUtils.createCheckedColorStateList(context, R.color.icon_color, getActiveColorId());

View file

@ -0,0 +1,240 @@
package net.osmand.plus.dialogs;
import android.app.Activity;
import android.content.Context;
import android.content.res.ColorStateList;
import android.os.Bundle;
import android.support.annotation.ColorInt;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;
import android.support.v4.util.Pair;
import android.support.v4.widget.CompoundButtonCompat;
import android.support.v4.widget.NestedScrollView;
import android.view.ContextThemeWrapper;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.LinearLayout.LayoutParams;
import android.widget.RadioButton;
import android.widget.TextView;
import net.osmand.AndroidUtils;
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.base.MenuBottomSheetDialogFragment;
import net.osmand.plus.base.bottomsheetmenu.BaseBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.plus.quickaction.CreateEditActionDialog;
import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionFactory;
import net.osmand.plus.quickaction.QuickActionRegistry;
import net.osmand.plus.quickaction.SwitchableAction;
import net.osmand.plus.quickaction.actions.MapStyleAction;
import net.osmand.plus.quickaction.actions.MapSourceAction;
import net.osmand.plus.quickaction.actions.MapOverlayAction;
import net.osmand.plus.quickaction.actions.MapUnderlayAction;
import net.osmand.plus.render.RendererRegistry;
import net.osmand.render.RenderingRulesStorage;
import java.util.List;
public class SelectMapViewQuickActionsBottomSheet extends MenuBottomSheetDialogFragment {
public static final String TAG = SelectMapViewQuickActionsBottomSheet.class.getSimpleName();
private static final String SELECTED_ITEM_KEY = "selected_item";
private LinearLayout itemsContainer;
private View.OnClickListener onClickListener;
private ColorStateList rbColorList;
private String selectedItem;
private QuickAction action;
@Override
public void createMenuItems(Bundle savedInstanceState) {
Bundle args = getArguments();
if (args == null) {
return;
}
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
long id = args.getLong(SwitchableAction.KEY_ID);
OsmandApplication app = mapActivity.getMyApplication();
QuickActionRegistry quickActionRegistry = mapActivity.getMapLayers().getQuickActionRegistry();
action = quickActionRegistry.getQuickAction(id);
action = QuickActionFactory.produceAction(action);
if (action == null) {
return;
}
OsmandSettings settings = app.getSettings();
if (savedInstanceState != null) {
selectedItem = savedInstanceState.getString(SELECTED_ITEM_KEY);
} else {
if (action instanceof MapStyleAction) {
RenderingRulesStorage current = app.getRendererRegistry().getCurrentSelectedRenderer();
if (current != null) {
selectedItem = current.getName();
} else {
selectedItem = RendererRegistry.DEFAULT_RENDER;
}
} else if (action instanceof MapSourceAction) {
selectedItem = settings.MAP_ONLINE_DATA.get()
? settings.MAP_TILE_SOURCES.get()
: MapSourceAction.LAYER_OSM_VECTOR;
} else if (action instanceof MapUnderlayAction) {
selectedItem = settings.MAP_UNDERLAY.get();
} else if (action instanceof MapOverlayAction) {
selectedItem = settings.MAP_OVERLAY.get();
}
}
rbColorList = AndroidUtils.createCheckedColorStateList(app, R.color.icon_color, getActiveColorId());
items.add(new TitleItem(action.getName(app)));
NestedScrollView nestedScrollView = new NestedScrollView(app);
itemsContainer = new LinearLayout(app);
itemsContainer.setLayoutParams((new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT)));
itemsContainer.setOrientation(LinearLayout.VERTICAL);
int padding = getResources().getDimensionPixelSize(R.dimen.bottom_sheet_content_padding_small);
itemsContainer.setPadding(0, padding, 0, padding);
int itemsSize = 0;
if (action instanceof SwitchableAction) {
SwitchableAction switchableAction = (SwitchableAction) action;
List sources = switchableAction.loadListFromParams();
itemsSize = sources.size();
}
for (int i = 0; i < itemsSize; i++) {
LayoutInflater.from(new ContextThemeWrapper(app, themeRes))
.inflate(R.layout.bottom_sheet_item_with_radio_btn, itemsContainer, true);
}
nestedScrollView.addView(itemsContainer);
items.add(new BaseBottomSheetItem.Builder().setCustomView(nestedScrollView).create());
populateItemsList();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putString(SELECTED_ITEM_KEY, selectedItem);
}
@Override
protected int getRightBottomButtonTextId() {
return R.string.shared_string_close;
}
@Override
protected void onRightBottomButtonClick() {
dismiss();
}
@Override
protected int getDismissButtonTextId() {
return R.string.quick_action_edit_actions;
}
@Override
protected void onDismissButtonClickAction() {
FragmentManager fm = getFragmentManager();
if (fm == null) {
return;
}
CreateEditActionDialog dialog = CreateEditActionDialog.newInstance(action.getId());
dialog.show(fm, CreateEditActionDialog.TAG);
}
@Override
protected boolean useScrollableItemsContainer() {
return false;
}
@Nullable
private MapActivity getMapActivity() {
Activity activity = getActivity();
if (activity != null && activity instanceof MapActivity) {
return (MapActivity) activity;
}
return null;
}
private void populateItemsList() {
Context context = getContext();
if (context == null) {
return;
}
int counter = 0;
if (action instanceof MapStyleAction) {
MapStyleAction mapStyleAction = (MapStyleAction) action;
List<String> stylesList = mapStyleAction.getFilteredStyles();
for (String entry : stylesList) {
boolean selected = entry.equals(selectedItem);
createItemRow(selected, counter, mapStyleAction.getTranslatedItemName(context, entry), entry);
counter++;
}
} else if (action instanceof SwitchableAction) {
SwitchableAction switchableAction = (SwitchableAction) action;
List<Pair<String, String>> sources = (List<Pair<String, String>>) switchableAction.loadListFromParams();
for (Pair<String, String> entry : sources) {
String tag = entry.first;
boolean selected = tag.equals(selectedItem);
createItemRow(selected, counter, entry.second, tag);
counter++;
}
}
}
private void createItemRow(boolean selected, int counter, String text, String tag) {
View view = itemsContainer.getChildAt(counter);
view.setTag(tag);
view.setOnClickListener(getOnClickListener());
TextView titleTv = (TextView) view.findViewById(R.id.title);
titleTv.setText(text);
titleTv.setTextColor(getStyleTitleColor(selected));
RadioButton rb = (RadioButton) view.findViewById(R.id.compound_button);
rb.setChecked(selected);
CompoundButtonCompat.setButtonTintList(rb, rbColorList);
ImageView imageView = (ImageView) view.findViewById(R.id.icon);
imageView.setImageDrawable(getContentIcon(action.getIconRes()));
}
@ColorInt
private int getStyleTitleColor(boolean selected) {
int colorId = selected
? getActiveColorId()
: nightMode ? R.color.primary_text_dark : R.color.primary_text_light;
return getResolvedColor(colorId);
}
private View.OnClickListener getOnClickListener() {
if (onClickListener == null) {
onClickListener = new View.OnClickListener() {
@Override
public void onClick(View v) {
MapActivity mapActivity = getMapActivity();
if (mapActivity == null) {
return;
}
selectedItem = (String) v.getTag();
if (action instanceof SwitchableAction) {
((SwitchableAction) action).executeWithParams(mapActivity, selectedItem);
}
dismiss();
}
};
}
return onClickListener;
}
}

View file

@ -173,11 +173,18 @@ public class DownloadResources extends DownloadResourceGroup {
if ((item.getType() == DownloadActivityType.NORMAL_FILE && !item.extra) if ((item.getType() == DownloadActivityType.NORMAL_FILE && !item.extra)
|| item.getType() == DownloadActivityType.ROADS_FILE || item.getType() == DownloadActivityType.ROADS_FILE
|| item.getType() == DownloadActivityType.WIKIPEDIA_FILE || item.getType() == DownloadActivityType.WIKIPEDIA_FILE
|| item.getType() == DownloadActivityType.WIKIVOYAGE_FILE
|| item.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE || item.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE
|| item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) { || item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
outdated = true; outdated = true;
} else if(item.getType() == DownloadActivityType.WIKIVOYAGE_FILE) {
long itemSize = item.getContentSize();
long oldItemSize = app.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR +
item.getTargetFileName()).length();
if (itemSize != oldItemSize) {
outdated = true;
}
} else { } else {
long itemSize = item.getContentSize(); long itemSize = item.getContentSize();
long oldItemSize = 0; long oldItemSize = 0;
if (item.getType() == DownloadActivityType.VOICE_FILE) { if (item.getType() == DownloadActivityType.VOICE_FILE) {

View file

@ -47,6 +47,9 @@ public class DatabaseHelper {
private SQLiteAPI.SQLiteConnection openConnection(boolean readonly) { private SQLiteAPI.SQLiteConnection openConnection(boolean readonly) {
SQLiteAPI.SQLiteConnection conn = app.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly); SQLiteAPI.SQLiteConnection conn = app.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
if (conn == null) {
return null;
}
if (conn.getVersion() == 0 || DB_VERSION != conn.getVersion()) { if (conn.getVersion() == 0 || DB_VERSION != conn.getVersion()) {
if (readonly) { if (readonly) {
conn.close(); conn.close();

View file

@ -61,6 +61,7 @@ public class DiscountHelper {
pms.put("version", Version.getFullVersion(app)); pms.put("version", Version.getFullVersion(app));
pms.put("nd", app.getAppInitializer().getFirstInstalledDays() +""); pms.put("nd", app.getAppInitializer().getFirstInstalledDays() +"");
pms.put("ns", app.getAppInitializer().getNumberOfStarts() + ""); pms.put("ns", app.getAppInitializer().getNumberOfStarts() + "");
pms.put("lang", app.getLanguage() + "");
try { try {
pms.put("aid", Secure.getString(app.getContentResolver(), Secure.ANDROID_ID)); pms.put("aid", Secure.getString(app.getContentResolver(), Secure.ANDROID_ID));
} catch (Exception e) { } catch (Exception e) {

View file

@ -381,7 +381,7 @@ public class GpxUiHelper {
public void onClick(DialogInterface dialog, int which) { public void onClick(DialogInterface dialog, int which) {
int position = selectedPosition[0]; int position = selectedPosition[0];
if (position != -1) { if (position != -1 && position < list.size()) {
if (showCurrentGpx && position == 0) { if (showCurrentGpx && position == 0) {
callbackWithObject.processResult(null); callbackWithObject.processResult(null);
app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(null); app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(null);

View file

@ -54,7 +54,7 @@ public class MapMarkerDialogHelper {
DirectionDrawable dd; DirectionDrawable dd;
if (!(arrow.getDrawable() instanceof DirectionDrawable)) { if (!(arrow.getDrawable() instanceof DirectionDrawable)) {
newImage = true; newImage = true;
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight()); dd = new DirectionDrawable((OsmandApplication) ctx.getApplicationContext(), arrow.getWidth(), arrow.getHeight());
} else { } else {
dd = (DirectionDrawable) arrow.getDrawable(); dd = (DirectionDrawable) arrow.getDrawable();
} }

View file

@ -374,7 +374,7 @@ public class SearchHistoryHelper {
// LEGACY QUERY !! // LEGACY QUERY !!
SQLiteCursor query = db.rawQuery( SQLiteCursor query = db.rawQuery(
"SELECT name, latitude, longitude, time FROM history ORDER BY time DESC", null); //$NON-NLS-1$//$NON-NLS-2$ "SELECT name, latitude, longitude, time FROM history ORDER BY time DESC", null); //$NON-NLS-1$//$NON-NLS-2$
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
do { do {
String name = query.getString(0); String name = query.getString(0);
String type = PointDescription.POINT_TYPE_MARKER; String type = PointDescription.POINT_TYPE_MARKER;
@ -401,8 +401,10 @@ public class SearchHistoryHelper {
entries.add(e); entries.add(e);
} while (query.moveToNext()); } while (query.moveToNext());
} }
if(query != null) {
query.close(); query.close();
} }
}
return entries; return entries;
} }
@ -416,7 +418,7 @@ public class SearchHistoryHelper {
HISTORY_COL_TIME + ", " + HISTORY_COL_FREQ_INTERVALS + ", " + HISTORY_COL_FREQ_VALUES + HISTORY_COL_TIME + ", " + HISTORY_COL_FREQ_INTERVALS + ", " + HISTORY_COL_FREQ_VALUES +
" FROM " + HISTORY_TABLE_NAME , null); //$NON-NLS-1$//$NON-NLS-2$ " FROM " + HISTORY_TABLE_NAME , null); //$NON-NLS-1$//$NON-NLS-2$
Map<PointDescription, HistoryEntry> st = new HashMap<PointDescription, HistoryEntry>(); Map<PointDescription, HistoryEntry> st = new HashMap<PointDescription, HistoryEntry>();
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
boolean reinsert = false; boolean reinsert = false;
do { do {
String name = query.getString(0); String name = query.getString(0);
@ -443,7 +445,9 @@ public class SearchHistoryHelper {
} }
} }
if(query != null) {
query.close(); query.close();
}
} finally { } finally {
db.close(); db.close();
} }

View file

@ -33,7 +33,6 @@ import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.EnumSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -54,6 +53,7 @@ public class WaypointHelper {
private static final int LONG_ANNOUNCE_RADIUS = 700; private static final int LONG_ANNOUNCE_RADIUS = 700;
private static final int SHORT_ANNOUNCE_RADIUS = 150; private static final int SHORT_ANNOUNCE_RADIUS = 150;
private static final int ALARMS_ANNOUNCE_RADIUS = 150; private static final int ALARMS_ANNOUNCE_RADIUS = 150;
private static final int ALARMS_SHORT_ANNOUNCE_RADIUS = 100;
// don't annoy users by lots of announcements // don't annoy users by lots of announcements
private static final int APPROACH_POI_LIMIT = 1; private static final int APPROACH_POI_LIMIT = 1;
@ -70,8 +70,9 @@ public class WaypointHelper {
public static final int[] SEARCH_RADIUS_VALUES = {50, 100, 200, 500, 1000, 2000, 5000}; public static final int[] SEARCH_RADIUS_VALUES = {50, 100, 200, 500, 1000, 2000, 5000};
private static final double DISTANCE_IGNORE_DOUBLE_SPEEDCAMS = 150; private static final double DISTANCE_IGNORE_DOUBLE_SPEEDCAMS = 150;
private List<List<LocationPointWrapper>> locationPoints = new ArrayList<List<LocationPointWrapper>>(); private List<List<LocationPointWrapper>> locationPoints = new ArrayList<>();
private ConcurrentHashMap<LocationPoint, Integer> locationPointsStates = new ConcurrentHashMap<LocationPoint, Integer>(); private ConcurrentHashMap<LocationPoint, Integer> locationPointsStates = new ConcurrentHashMap<>();
private ConcurrentHashMap<AlarmInfo.AlarmInfoType, AlarmInfo> lastAnnouncedAlarms = new ConcurrentHashMap<>();
private TIntArrayList pointsProgress = new TIntArrayList(); private TIntArrayList pointsProgress = new TIntArrayList();
private RouteCalculationResult route; private RouteCalculationResult route;
@ -342,6 +343,8 @@ public class WaypointHelper {
kIterator++; kIterator++;
} }
pointsProgress.set(type, kIterator); pointsProgress.set(type, kIterator);
VoiceRouter voiceRouter = getVoiceRouter();
while (kIterator < lp.size()) { while (kIterator < lp.size()) {
LocationPointWrapper lwp = lp.get(kIterator); LocationPointWrapper lwp = lp.get(kIterator);
if (type == ALARMS && lwp.routeIndex < currentRoute) { if (type == ALARMS && lwp.routeIndex < currentRoute) {
@ -356,20 +359,45 @@ public class WaypointHelper {
double d1 = Math.max(0.0, MapUtils.getDistance(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(), double d1 = Math.max(0.0, MapUtils.getDistance(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(),
point.getLatitude(), point.getLongitude()) - lwp.getDeviationDistance()); point.getLatitude(), point.getLongitude()) - lwp.getDeviationDistance());
Integer state = locationPointsStates.get(point); Integer state = locationPointsStates.get(point);
if (state != null && state.intValue() == ANNOUNCED_ONCE if (state != null && state == ANNOUNCED_ONCE
&& getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS, 0f)) { && voiceRouter.isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS, 0f)) {
locationPointsStates.put(point, ANNOUNCED_DONE); locationPointsStates.put(point, ANNOUNCED_DONE);
announcePoints.add(lwp); announcePoints.add(lwp);
} else if (type != ALARMS && (state == null || state == NOT_ANNOUNCED) } else if (type != ALARMS && (state == null || state == NOT_ANNOUNCED)
&& getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, LONG_ANNOUNCE_RADIUS, 0f)) { && voiceRouter.isDistanceLess(lastKnownLocation.getSpeed(), d1, LONG_ANNOUNCE_RADIUS, 0f)) {
locationPointsStates.put(point, ANNOUNCED_ONCE); locationPointsStates.put(point, ANNOUNCED_ONCE);
approachPoints.add(lwp); approachPoints.add(lwp);
} else if (type == ALARMS && (state == null || state == NOT_ANNOUNCED) } else if (type == ALARMS && (state == null || state == NOT_ANNOUNCED)) {
&& getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, ALARMS_ANNOUNCE_RADIUS, 0f)) { AlarmInfo alarm = (AlarmInfo) point;
AlarmInfoType t = alarm.getType();
int announceRadius;
boolean filter = false;
switch (t) {
case TRAFFIC_CALMING:
announceRadius = ALARMS_SHORT_ANNOUNCE_RADIUS;
filter = true;
break;
default:
announceRadius = ALARMS_ANNOUNCE_RADIUS;
break;
}
boolean proceed = voiceRouter.isDistanceLess(lastKnownLocation.getSpeed(), d1, announceRadius, 0f);
if (proceed && filter) {
AlarmInfo lastAlarm = lastAnnouncedAlarms.get(t);
if (lastAlarm != null) {
double dist = MapUtils.getDistance(lastAlarm.getLatitude(), lastAlarm.getLongitude(), alarm.getLatitude(), alarm.getLongitude());
if (dist < ALARMS_SHORT_ANNOUNCE_RADIUS) {
locationPointsStates.put(point, ANNOUNCED_DONE);
proceed = false;
}
}
}
if (proceed) {
locationPointsStates.put(point, ANNOUNCED_ONCE); locationPointsStates.put(point, ANNOUNCED_ONCE);
approachPoints.add(lwp); approachPoints.add(lwp);
} }
} }
}
kIterator++; kIterator++;
} }
if (!announcePoints.isEmpty()) { if (!announcePoints.isEmpty()) {
@ -377,13 +405,13 @@ public class WaypointHelper {
announcePoints = announcePoints.subList(0, ANNOUNCE_POI_LIMIT); announcePoints = announcePoints.subList(0, ANNOUNCE_POI_LIMIT);
} }
if (type == WAYPOINTS) { if (type == WAYPOINTS) {
getVoiceRouter().announceWaypoint(announcePoints); voiceRouter.announceWaypoint(announcePoints);
} else if (type == POI) { } else if (type == POI) {
getVoiceRouter().announcePoi(announcePoints); voiceRouter.announcePoi(announcePoints);
} else if (type == ALARMS) { } else if (type == ALARMS) {
// nothing to announce // nothing to announce
} else if (type == FAVORITES) { } else if (type == FAVORITES) {
getVoiceRouter().announceFavorite(announcePoints); voiceRouter.announceFavorite(announcePoints);
} }
} }
if (!approachPoints.isEmpty()) { if (!approachPoints.isEmpty()) {
@ -391,19 +419,17 @@ public class WaypointHelper {
approachPoints = approachPoints.subList(0, APPROACH_POI_LIMIT); approachPoints = approachPoints.subList(0, APPROACH_POI_LIMIT);
} }
if (type == WAYPOINTS) { if (type == WAYPOINTS) {
getVoiceRouter().approachWaypoint(lastKnownLocation, approachPoints); voiceRouter.approachWaypoint(lastKnownLocation, approachPoints);
} else if (type == POI) { } else if (type == POI) {
getVoiceRouter().approachPoi(lastKnownLocation, approachPoints); voiceRouter.approachPoi(lastKnownLocation, approachPoints);
} else if (type == ALARMS) { } else if (type == ALARMS) {
EnumSet<AlarmInfoType> ait = EnumSet.noneOf(AlarmInfoType.class);
for (LocationPointWrapper pw : approachPoints) { for (LocationPointWrapper pw : approachPoints) {
ait.add(((AlarmInfo) pw.point).getType()); AlarmInfo alarm = (AlarmInfo) pw.point;
} voiceRouter.announceAlarm(new AlarmInfo(alarm.getType(), -1), lastKnownLocation.getSpeed());
for (AlarmInfoType t : ait) { lastAnnouncedAlarms.put(alarm.getType(), alarm);
app.getRoutingHelper().getVoiceRouter().announceAlarm(new AlarmInfo(t, -1), lastKnownLocation.getSpeed());
} }
} else if (type == FAVORITES) { } else if (type == FAVORITES) {
getVoiceRouter().approachFavorite(lastKnownLocation, approachPoints); voiceRouter.approachFavorite(lastKnownLocation, approachPoints);
} }
} }
} }
@ -455,6 +481,7 @@ public class WaypointHelper {
public void clearAllVisiblePoints() { public void clearAllVisiblePoints() {
this.locationPointsStates.clear(); this.locationPointsStates.clear();
this.lastAnnouncedAlarms.clear();
this.locationPoints = new ArrayList<List<LocationPointWrapper>>(); this.locationPoints = new ArrayList<List<LocationPointWrapper>>();
} }
@ -544,6 +571,7 @@ public class WaypointHelper {
protected synchronized void setLocationPoints(List<List<LocationPointWrapper>> locationPoints, RouteCalculationResult route) { protected synchronized void setLocationPoints(List<List<LocationPointWrapper>> locationPoints, RouteCalculationResult route) {
this.locationPoints = locationPoints; this.locationPoints = locationPoints;
this.locationPointsStates.clear(); this.locationPointsStates.clear();
this.lastAnnouncedAlarms.clear();
TIntArrayList list = new TIntArrayList(locationPoints.size()); TIntArrayList list = new TIntArrayList(locationPoints.size());
list.fill(0, locationPoints.size(), 0); list.fill(0, locationPoints.size(), 0);
this.pointsProgress = list; this.pointsProgress = list;

View file

@ -1287,7 +1287,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
} }
int line3Height = 0; int line3Height = 0;
View line3Container = view.findViewById(R.id.additional_info_row); View line3Container = view.findViewById(R.id.additional_info_row_container);
if (line3Container.getVisibility() == View.VISIBLE) { if (line3Container.getVisibility() == View.VISIBLE) {
line3Height = line3Container.getMeasuredHeight(); line3Height = line3Container.getMeasuredHeight();
} }
@ -1520,10 +1520,13 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
&& compassView.getVisibility() == View.INVISIBLE && compassView.getVisibility() == View.INVISIBLE
&& titleButtonContainer.getVisibility() == View.GONE && titleButtonContainer.getVisibility() == View.GONE
&& downloadButtonsContainer.getVisibility() == View.GONE && downloadButtonsContainer.getVisibility() == View.GONE
&& titleBottomButtonContainer.getVisibility() == View.GONE && titleBottomButtonContainer.getVisibility() == View.GONE) {
&& titleProgressContainer.getVisibility() == View.VISIBLE) { if (titleProgressContainer.getVisibility() == View.VISIBLE) {
view.findViewById(R.id.additional_info_row_container).setVisibility(View.GONE);
}
view.findViewById(R.id.additional_info_row).setVisibility(View.GONE); view.findViewById(R.id.additional_info_row).setVisibility(View.GONE);
} else { } else {
view.findViewById(R.id.additional_info_row_container).setVisibility(View.VISIBLE);
view.findViewById(R.id.additional_info_row).setVisibility(View.VISIBLE); view.findViewById(R.id.additional_info_row).setVisibility(View.VISIBLE);
} }
} }
@ -1909,6 +1912,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
private void doAfterMenuStateChange(int previousState, int newState) { private void doAfterMenuStateChange(int previousState, int newState) {
updateCompassVisibility(); updateCompassVisibility();
updateAdditionalInfoVisibility(); updateAdditionalInfoVisibility();
runLayoutListener();
} }
} }

View file

@ -13,6 +13,7 @@ import android.net.Uri;
import android.os.AsyncTask; import android.os.AsyncTask;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.graphics.drawable.DrawableCompat;
import android.support.v7.view.ContextThemeWrapper; import android.support.v7.view.ContextThemeWrapper;
import android.text.ClipboardManager; import android.text.ClipboardManager;
import android.text.TextUtils; import android.text.TextUtils;
@ -752,7 +753,10 @@ public class MenuBuilder {
public Drawable getRowIcon(Context ctx, String fileName) { public Drawable getRowIcon(Context ctx, String fileName) {
Drawable d = RenderingIcons.getBigIcon(ctx, fileName); Drawable d = RenderingIcons.getBigIcon(ctx, fileName);
if (d != null) { if (d != null) {
d.setColorFilter(app.getResources().getColor(light ? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark), PorterDuff.Mode.SRC_IN); d = DrawableCompat.wrap(d);
d.mutate();
d.setColorFilter(app.getResources().getColor(light
? R.color.ctx_menu_bottom_view_icon_light : R.color.ctx_menu_bottom_view_icon_dark), PorterDuff.Mode.SRC_IN);
return d; return d;
} else { } else {
return null; return null;

View file

@ -11,7 +11,6 @@ import android.support.annotation.NonNull;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.view.ContextThemeWrapper; import android.support.v7.view.ContextThemeWrapper;
import android.text.Html;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.util.Linkify; import android.text.util.Linkify;
import android.view.Gravity; import android.view.Gravity;
@ -26,6 +25,7 @@ import net.osmand.data.Amenity;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.osm.AbstractPoiType; import net.osmand.osm.AbstractPoiType;
import net.osmand.osm.MapPoiTypes; import net.osmand.osm.MapPoiTypes;
import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
@ -35,13 +35,13 @@ import net.osmand.plus.Version;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.FontCache; import net.osmand.plus.helpers.FontCache;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.wikipedia.WikiArticleHelper;
import net.osmand.plus.wikipedia.WikipediaArticleWikiLinkFragment;
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
import net.osmand.plus.osmedit.OsmEditingPlugin; import net.osmand.plus.osmedit.OsmEditingPlugin;
import net.osmand.plus.poi.PoiUIFilter; import net.osmand.plus.poi.PoiUIFilter;
import net.osmand.plus.views.POIMapLayer; import net.osmand.plus.views.POIMapLayer;
import net.osmand.plus.widgets.TextViewEx; import net.osmand.plus.widgets.TextViewEx;
import net.osmand.plus.wikipedia.WikiArticleHelper;
import net.osmand.plus.wikipedia.WikipediaArticleWikiLinkFragment;
import net.osmand.plus.wikipedia.WikipediaDialogFragment;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import net.osmand.util.OpeningHoursParser; import net.osmand.util.OpeningHoursParser;
@ -50,6 +50,7 @@ import java.util.Calendar;
import java.util.Collections; import java.util.Collections;
import java.util.Comparator; import java.util.Comparator;
import java.util.HashMap; import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.LinkedList; import java.util.LinkedList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -345,6 +346,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
Map<String, List<PoiType>> poiAdditionalCategories = new HashMap<>(); Map<String, List<PoiType>> poiAdditionalCategories = new HashMap<>();
AmenityInfoRow cuisineRow = null; AmenityInfoRow cuisineRow = null;
List<PoiType> collectedPoiTypes = new ArrayList<>();
for (Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) { for (Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
int iconId = 0; int iconId = 0;
@ -363,14 +365,15 @@ public class AmenityMenuBuilder extends MenuBuilder {
boolean isWiki = false; boolean isWiki = false;
boolean isText = false; boolean isText = false;
boolean isDescription = false; boolean isDescription = false;
boolean needLinks = !("population".equals(key) boolean needLinks = !("population".equals(key) || "height".equals(key));
|| "height".equals(key));
boolean isPhoneNumber = false; boolean isPhoneNumber = false;
boolean isUrl = false; boolean isUrl = false;
boolean isCuisine = false; boolean isCuisine = false;
int poiTypeOrder = 0; int poiTypeOrder = 0;
String poiTypeKeyName = ""; String poiTypeKeyName = "";
PoiType poiType = amenity.getType().getPoiTypeByKeyName(key);
AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(key); AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(key);
if (pt == null && !Algorithms.isEmpty(vl) && vl.length() < 50) { if (pt == null && !Algorithms.isEmpty(vl) && vl.length() < 50) {
pt = poiTypes.getAnyPoiAdditionalTypeByKey(key + "_" + vl); pt = poiTypes.getAnyPoiAdditionalTypeByKey(key + "_" + vl);
@ -474,6 +477,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
iconId = R.drawable.ic_action_poi_name; iconId = R.drawable.ic_action_poi_name;
} else if (key.equals("operator") || key.equals("brand")) { } else if (key.equals("operator") || key.equals("brand")) {
iconId = R.drawable.ic_action_poi_brand; iconId = R.drawable.ic_action_poi_brand;
} else if (key.equals("internet_access_fee_yes")) {
iconId = R.drawable.ic_action_internet_access_fee;
} else { } else {
iconId = R.drawable.ic_action_info_dark; iconId = R.drawable.ic_action_info_dark;
} }
@ -500,6 +505,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
if (icon == null && isText && iconId == 0) { if (icon == null && isText && iconId == 0) {
iconId = R.drawable.ic_action_note_dark; iconId = R.drawable.ic_action_note_dark;
} }
} else if (poiType != null) {
collectedPoiTypes.add(poiType);
} else { } else {
textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey()); textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey());
vl = amenity.unzipContent(e.getValue()); vl = amenity.unzipContent(e.getValue());
@ -523,12 +530,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
} }
if (isDescription) { if (isDescription) {
descriptions.add(row); descriptions.add(row);
} else { } else if (isCuisine) {
if (!isCuisine) {
infoRows.add(row);
} else {
cuisineRow = row; cuisineRow = row;
} } else if (poiType == null) {
infoRows.add(row);
} }
} }
@ -567,12 +572,27 @@ public class AmenityMenuBuilder extends MenuBuilder {
sb.append(pt.getTranslation()); sb.append(pt.getTranslation());
} }
boolean cuisineOrDish = categoryName.equals(Amenity.CUISINE) || categoryName.equals(Amenity.DISH); boolean cuisineOrDish = categoryName.equals(Amenity.CUISINE) || categoryName.equals(Amenity.DISH);
CollapsableView collapsableView = getPoiAdditionalCollapsableView(view.getContext(), true, categoryTypes, cuisineOrDish ? cuisineRow : null); CollapsableView collapsableView = getPoiTypeCollapsableView(view.getContext(), true, categoryTypes, true, cuisineOrDish ? cuisineRow : null);
infoRows.add(new AmenityInfoRow(poiAdditionalCategoryName, icon, pType.getPoiAdditionalCategoryTranslation(), sb.toString(), true, collapsableView, infoRows.add(new AmenityInfoRow(poiAdditionalCategoryName, icon, pType.getPoiAdditionalCategoryTranslation(), sb.toString(), true, collapsableView,
0, false, false, false, pType.getOrder(), pType.getKeyName(), false, false, false, 1)); 0, false, false, false, pType.getOrder(), pType.getKeyName(), false, false, false, 1));
} }
} }
if (collectedPoiTypes.size() > 0) {
CollapsableView collapsableView = getPoiTypeCollapsableView(view.getContext(), true, collectedPoiTypes, false, null);
PoiCategory poiCategory = amenity.getType();
Drawable icon = getRowIcon(view.getContext(), poiCategory.getIconKeyName());
StringBuilder sb = new StringBuilder();
for (PoiType pt : collectedPoiTypes) {
if (sb.length() > 0) {
sb.append("");
}
sb.append(pt.getTranslation());
}
infoRows.add(new AmenityInfoRow(poiCategory.getKeyName(), icon, poiCategory.getTranslation(), sb.toString(), true, collapsableView,
0, false, false, false, 40, poiCategory.getKeyName(), false, false, false, 1));
}
Collections.sort(infoRows, new Comparator<AmenityInfoRow>() { Collections.sort(infoRows, new Comparator<AmenityInfoRow>() {
@Override @Override
public int compare(AmenityInfoRow row1, AmenityInfoRow row2) { public int compare(AmenityInfoRow row1, AmenityInfoRow row2) {
@ -610,7 +630,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
if (processNearstWiki() && nearestWiki.size() > 0) { if (processNearstWiki() && nearestWiki.size() > 0) {
AmenityInfoRow wikiInfo = new AmenityInfoRow( AmenityInfoRow wikiInfo = new AmenityInfoRow(
"nearest_wiki", R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", true, "nearest_wiki", R.drawable.ic_plugin_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", true,
getCollapsableWikiView(view.getContext(), true), getCollapsableWikiView(view.getContext(), true),
0, false, false, false, 1000, null, false, false, false, 0); 0, false, false, false, 1000, null, false, false, false, 0);
buildAmenityRow(view, wikiInfo); buildAmenityRow(view, wikiInfo);
@ -663,9 +683,9 @@ public class AmenityMenuBuilder extends MenuBuilder {
return params; return params;
} }
private CollapsableView getPoiAdditionalCollapsableView( private CollapsableView getPoiTypeCollapsableView(final Context context, boolean collapsed,
final Context context, boolean collapsed, @NonNull final List<PoiType> categoryTypes,
@NonNull final List<PoiType> categoryTypes, AmenityInfoRow textCuisineRow) { final boolean poiAdditional, AmenityInfoRow textRow) {
final List<TextViewEx> buttons = new ArrayList<>(); final List<TextViewEx> buttons = new ArrayList<>();
@ -683,9 +703,15 @@ public class AmenityMenuBuilder extends MenuBuilder {
PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + amenity.getType().getKeyName()); PoiUIFilter filter = app.getPoiFilters().getFilterById(PoiUIFilter.STD_PREFIX + amenity.getType().getKeyName());
if (filter != null) { if (filter != null) {
filter.clearFilter(); filter.clearFilter();
if (poiAdditional) {
filter.setTypeToAccept(amenity.getType(), true); filter.setTypeToAccept(amenity.getType(), true);
filter.updateTypesToAccept(pt); filter.updateTypesToAccept(pt);
filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase()); filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase());
} else {
LinkedHashSet<String> accept = new LinkedHashSet<>();
accept.add(pt.getKeyName());
filter.selectSubTypesToAccept(amenity.getType(), accept);
}
getMapActivity().showQuickSearch(filter); getMapActivity().showQuickSearch(filter);
} }
} }
@ -698,9 +724,9 @@ public class AmenityMenuBuilder extends MenuBuilder {
view.addView(button); view.addView(button);
} }
if (textCuisineRow != null) { if (textRow != null) {
TextViewEx button = buildButtonInCollapsableView(context, true, false, false); TextViewEx button = buildButtonInCollapsableView(context, true, false, false);
String name = textCuisineRow.textPrefix + ": " + textCuisineRow.text.toLowerCase(); String name = textRow.textPrefix + ": " + textRow.text.toLowerCase();
button.setText(name); button.setText(name);
view.addView(button); view.addView(button);
} }

View file

@ -0,0 +1,29 @@
package net.osmand.plus.mapcontextmenu.builders;
import android.view.View;
import net.osmand.data.Amenity;
import net.osmand.data.TransportStop;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
public class TransportStopMenuBuilder extends MenuBuilder {
private final TransportStop transportStop;
public TransportStopMenuBuilder(MapActivity mapActivity, final TransportStop transportStop) {
super(mapActivity);
this.transportStop = transportStop;
}
@Override
public void buildInternal(View view) {
Amenity amenity = transportStop.getAmenity();
if (amenity != null) {
AmenityMenuBuilder builder = new AmenityMenuBuilder(mapActivity, amenity);
builder.setLatLon(getLatLon());
builder.setLight(light);
builder.buildInternal(view);
}
}
}

View file

@ -1,13 +1,15 @@
package net.osmand.plus.mapcontextmenu.controllers; package net.osmand.plus.mapcontextmenu.controllers;
import net.osmand.data.Amenity;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
import net.osmand.data.TransportRoute; import net.osmand.data.TransportRoute;
import net.osmand.data.TransportStop; import net.osmand.data.TransportStop;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.mapcontextmenu.builders.TransportStopMenuBuilder;
import net.osmand.plus.transport.TransportStopRoute; import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder;
import net.osmand.plus.mapcontextmenu.MenuController; import net.osmand.plus.mapcontextmenu.MenuController;
import net.osmand.plus.resources.TransportIndexRepository; import net.osmand.plus.resources.TransportIndexRepository;
import net.osmand.plus.transport.TransportStopType; import net.osmand.plus.transport.TransportStopType;
@ -30,7 +32,7 @@ public class TransportStopController extends MenuController {
public TransportStopController(MapActivity mapActivity, public TransportStopController(MapActivity mapActivity,
PointDescription pointDescription, TransportStop transportStop) { PointDescription pointDescription, TransportStop transportStop) {
super(new MenuBuilder(mapActivity), pointDescription, mapActivity); super(new TransportStopMenuBuilder(mapActivity, transportStop), pointDescription, mapActivity);
this.transportStop = transportStop; this.transportStop = transportStop;
processRoutes(); processRoutes();
} }
@ -157,4 +159,13 @@ public class TransportStopController extends MenuController {
return false; return false;
} }
@Override
public void addPlainMenuItems(String typeStr, PointDescription pointDescription, LatLon latLon) {
Amenity amenity = transportStop.getAmenity();
if (amenity != null) {
AmenityMenuController.addTypeMenuItem(amenity, builder);
} else {
super.addPlainMenuItems(typeStr, pointDescription, latLon);
}
}
} }

View file

@ -183,6 +183,9 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
} else { } else {
helper.editFavouriteName(favorite, name, category, description); helper.editFavouriteName(favorite, name, category, description);
} }
if(getMapActivity() == null) {
return;
}
getMapActivity().refreshMap(); getMapActivity().refreshMap();
if (needDismiss) { if (needDismiss) {
dismiss(false); dismiss(false);

View file

@ -1,7 +1,5 @@
package net.osmand.plus.mapcontextmenu.other; package net.osmand.plus.mapcontextmenu.other;
import android.app.Activity;
import android.content.Context;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
@ -9,7 +7,6 @@ import android.view.ViewGroup;
import android.widget.ImageView; import android.widget.ImageView;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.Location;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.plus.IconsCache; import net.osmand.plus.IconsCache;
@ -24,18 +21,21 @@ import java.util.List;
public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> { public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private final Context context;
private final List<FavouritePoint> favouritePoints;
private final List<FavouritePoint> favouritePoints;
private OsmandApplication app;
private IconsCache iconsCache;
private View.OnClickListener listener; private View.OnClickListener listener;
private LatLon location; private LatLon location;
private Float heading; private Float heading;
private boolean useCenter; private boolean useCenter;
private int screenOrientation; private int screenOrientation;
public FavouritesAdapter(Context context, List<FavouritePoint> FavouritePoints) { public FavouritesAdapter(OsmandApplication app, List<FavouritePoint> FavouritePoints) {
this.app = app;
iconsCache = app.getIconsCache();
this.favouritePoints = FavouritePoints; this.favouritePoints = FavouritePoints;
this.context = context;
} }
@Override @Override
@ -48,8 +48,6 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
@Override @Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder instanceof FavouritesViewHolder) { if (holder instanceof FavouritesViewHolder) {
OsmandApplication app = (OsmandApplication) ((Activity) context).getApplication();
IconsCache iconsCache = app.getIconsCache();
FavouritesViewHolder favouritesViewHolder = (FavouritesViewHolder) holder; FavouritesViewHolder favouritesViewHolder = (FavouritesViewHolder) holder;
FavouritePoint favouritePoint = getItem(position); FavouritePoint favouritePoint = getItem(position);
favouritesViewHolder.title.setText(favouritePoint.getName()); favouritesViewHolder.title.setText(favouritePoint.getName());
@ -58,17 +56,16 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
} else { } else {
favouritesViewHolder.description.setText(favouritePoint.getCategory()); favouritesViewHolder.description.setText(favouritePoint.getCategory());
} }
Location myloc = app.getLocationProvider().getLastKnownLocation(); favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, favouritePoint.getColor(), false));
favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(context, favouritePoint.getColor(), false)); if (location == null) {
if (myloc == null) {
return; return;
} }
float dist = (float) MapUtils.getDistance(favouritePoint.getLatitude(), favouritePoint.getLongitude(), myloc.getLatitude(), myloc.getLongitude()); float dist = (float) MapUtils.getDistance(favouritePoint.getLatitude(), favouritePoint.getLongitude(), location.getLatitude(), location.getLongitude());
favouritesViewHolder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, app)); favouritesViewHolder.distance.setText(OsmAndFormatter.getFormattedDistance(dist, app));
favouritesViewHolder.arrowImage.setImageDrawable(iconsCache.getIcon(R.drawable.ic_direction_arrow)); favouritesViewHolder.arrowImage.setImageDrawable(iconsCache.getIcon(R.drawable.ic_direction_arrow));
DashLocationFragment.updateLocationView(useCenter, location, heading, favouritesViewHolder.arrowImage, DashLocationFragment.updateLocationView(useCenter, location, heading, favouritesViewHolder.arrowImage,
favouritesViewHolder.distance, favouritePoint.getLatitude(), favouritePoint.getLongitude(), favouritesViewHolder.distance, favouritePoint.getLatitude(), favouritePoint.getLongitude(),
screenOrientation, app, context); screenOrientation, app);
} }
} }

View file

@ -66,11 +66,16 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
recyclerView = (RecyclerView) View.inflate(new ContextThemeWrapper(getContext(), themeRes), recyclerView = (RecyclerView) View.inflate(new ContextThemeWrapper(getContext(), themeRes),
R.layout.recyclerview, null); R.layout.recyclerview, null);
recyclerView.setLayoutManager(new LinearLayoutManager(getContext())); recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
location = getMyApplication().getLocationProvider().getLastKnownLocation(); location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
adapter = new FavouritesAdapter(getMyApplication(), favouritePoints);
if (location != null) { if (location != null) {
latLon = new LatLon(location.getLatitude(), location.getLongitude()); latLon = new LatLon(location.getLatitude(), location.getLongitude());
adapter.setUseCenter(false);
} else {
latLon = ((MapActivity) getActivity()).getMapLocation();
adapter.setUseCenter(true);
} }
adapter = new FavouritesAdapter(getContext(), favouritePoints); adapter.setLocation(latLon);
sortFavourites(); sortFavourites();
final BottomSheetItemTitleWithDescrAndButton[] title = new BottomSheetItemTitleWithDescrAndButton[1]; final BottomSheetItemTitleWithDescrAndButton[] title = new BottomSheetItemTitleWithDescrAndButton[1];
title[0] = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder() title[0] = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder()
@ -212,14 +217,14 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
@Override @Override
public void run() { public void run() {
if (location == null) { if (location == null) {
location = getMyApplication().getLocationProvider().getLastKnownLocation(); location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
} }
if (location == null) {
return; boolean useCenter = location == null;
} latLon = useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude());
adapter.setUseCenter(false); adapter.setUseCenter(useCenter);
adapter.setLocation(new LatLon(location.getLatitude(), location.getLongitude())); adapter.setLocation(latLon);
adapter.setHeading(heading != null ? heading : 99); adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
adapter.notifyDataSetChanged(); adapter.notifyDataSetChanged();
} }
}); });
@ -260,16 +265,11 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
} }
private void sortFavourites() { private void sortFavourites() {
if (location != null) {
latLon = new LatLon(location.getLatitude(), location.getLongitude());
} else if (sortByDist) {
return;
}
final Collator inst = Collator.getInstance(); final Collator inst = Collator.getInstance();
Collections.sort(favouritePoints, new Comparator<FavouritePoint>() { Collections.sort(favouritePoints, new Comparator<FavouritePoint>() {
@Override @Override
public int compare(FavouritePoint lhs, FavouritePoint rhs) { public int compare(FavouritePoint lhs, FavouritePoint rhs) {
if (sortByDist) { if (sortByDist && latLon != null) {
double ld = MapUtils.getDistance(latLon, lhs.getLatitude(), double ld = MapUtils.getDistance(latLon, lhs.getLatitude(),
lhs.getLongitude()); lhs.getLongitude());
double rd = MapUtils.getDistance(latLon, rhs.getLatitude(), double rd = MapUtils.getDistance(latLon, rhs.getLatitude(),

View file

@ -188,6 +188,20 @@ public class MapRouteInfoMenu implements IRouteInformationListener {
} }
} }
public void updateRouteCalculationProgress(int progress) {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().updateRouteCalculationProgress(progress);
}
}
public void routeCalculationFinished() {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) {
fragmentRef.get().hideRouteCalculationProgressBar();
}
}
public void updateMenu() { public void updateMenu() {
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment(); WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
if (fragmentRef != null) if (fragmentRef != null)

View file

@ -4,9 +4,11 @@ import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.v4.app.FragmentActivity; import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentManager;
import android.support.v4.content.ContextCompat;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.View; import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
@ -106,6 +108,23 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
} }
} }
public void updateRouteCalculationProgress(int progress) {
ProgressBar progressBar = (ProgressBar) mainView.findViewById(R.id.progress_bar);
if (progressBar != null) {
if (progressBar.getVisibility() != View.VISIBLE) {
progressBar.setVisibility(View.VISIBLE);
}
progressBar.setProgress(progress);
}
}
public void hideRouteCalculationProgressBar() {
View progressBar = mainView.findViewById(R.id.progress_bar);
if (progressBar != null) {
progressBar.setVisibility(View.GONE);
}
}
public void show(MapActivity mapActivity) { public void show(MapActivity mapActivity) {
int slideInAnim = 0; int slideInAnim = 0;
int slideOutAnim = 0; int slideOutAnim = 0;
@ -173,6 +192,11 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceTitle), nightMode); AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceTitle), nightMode);
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationText), nightMode); AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationText), nightMode);
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationTitle), nightMode); AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationTitle), nightMode);
int bgColor = ContextCompat.getColor(ctx, nightMode
? R.color.map_progress_bar_bg_dark : R.color.map_progress_bar_bg_light);
((ProgressBar) mainView.findViewById(R.id.progress_bar)).setProgressDrawable(AndroidUtils
.createProgressDrawable(bgColor, ctx.getMapLayers().getRouteLayer().getRouteLineColor(nightMode)));
} }
public static boolean showInstance(final MapActivity mapActivity) { public static boolean showInstance(final MapActivity mapActivity) {

View file

@ -1,6 +1,7 @@
package net.osmand.plus.mapcontextmenu.other; package net.osmand.plus.mapcontextmenu.other;
import android.graphics.Matrix; import android.graphics.Matrix;
import android.support.annotation.NonNull;
import android.support.v4.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v7.widget.PopupMenu; import android.support.v7.widget.PopupMenu;
import android.view.MenuItem; import android.view.MenuItem;
@ -18,6 +19,7 @@ import com.github.mikephil.charting.listener.ChartTouchListener.ChartGesture;
import com.github.mikephil.charting.listener.OnChartGestureListener; import com.github.mikephil.charting.listener.OnChartGestureListener;
import com.github.mikephil.charting.listener.OnChartValueSelectedListener; import com.github.mikephil.charting.listener.OnChartValueSelectedListener;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.QuadRect; import net.osmand.data.QuadRect;
import net.osmand.data.RotatedTileBox; import net.osmand.data.RotatedTileBox;
@ -54,11 +56,13 @@ public class TrackDetailsMenu {
private TrkSegment segment; private TrkSegment segment;
private TrackChartPoints trackChartPoints; private TrackChartPoints trackChartPoints;
private List<WptPt> xAxisPoints; private List<WptPt> xAxisPoints;
private int topMarginPx;
private static boolean VISIBLE; private static boolean VISIBLE;
public TrackDetailsMenu(MapActivity mapActivity) { public TrackDetailsMenu(@NonNull MapActivity mapActivity) {
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
topMarginPx = AndroidUtils.dpToPx(mapActivity, 48f);
} }
public GpxDisplayItem getGpxItem() { public GpxDisplayItem getGpxItem() {
@ -125,7 +129,7 @@ public class TrackDetailsMenu {
} }
} }
public WeakReference<TrackDetailsMenuFragment> findMenuFragment() { private WeakReference<TrackDetailsMenuFragment> findMenuFragment() {
Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(TrackDetailsMenuFragment.TAG); Fragment fragment = mapActivity.getSupportFragmentManager().findFragmentByTag(TrackDetailsMenuFragment.TAG);
if (fragment != null && !fragment.isDetached()) { if (fragment != null && !fragment.isDetached()) {
return new WeakReference<>((TrackDetailsMenuFragment) fragment); return new WeakReference<>((TrackDetailsMenuFragment) fragment);
@ -269,7 +273,6 @@ public class TrackDetailsMenu {
private void fitTrackOnMap(LineChart chart, LatLon location, boolean forceFit) { private void fitTrackOnMap(LineChart chart, LatLon location, boolean forceFit) {
QuadRect rect = getRect(chart, chart.getLowestVisibleX(), chart.getHighestVisibleX()); QuadRect rect = getRect(chart, chart.getLowestVisibleX(), chart.getHighestVisibleX());
if (rect != null) {
RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy(); RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
int tileBoxWidthPx = 0; int tileBoxWidthPx = 0;
int tileBoxHeightPx = 0; int tileBoxHeightPx = 0;
@ -284,18 +287,18 @@ public class TrackDetailsMenu {
tileBoxHeightPx = tb.getPixHeight() - f.getHeight(); tileBoxHeightPx = tb.getPixHeight() - f.getHeight();
} }
} }
if (tileBoxHeightPx > 0) {
if (forceFit) { if (forceFit) {
mapActivity.getMapView().fitRectToMap(rect.left, rect.right, rect.top, rect.bottom, mapActivity.getMapView().fitRectToMap(rect.left, rect.right, rect.top, rect.bottom,
tileBoxWidthPx, tileBoxHeightPx, 0); tileBoxWidthPx, tileBoxHeightPx, topMarginPx);
} else if (location != null && } else if (location != null &&
!mapActivity.getMapView().getTileBox(tileBoxWidthPx, tileBoxHeightPx, 0).containsLatLon(location)) { !mapActivity.getMapView().getTileBox(tileBoxWidthPx, tileBoxHeightPx, topMarginPx).containsLatLon(location)) {
boolean animating = mapActivity.getMapView().getAnimatedDraggingThread().isAnimating(); boolean animating = mapActivity.getMapView().getAnimatedDraggingThread().isAnimating();
mapActivity.getMapView().fitLocationToMap(location.getLatitude(), location.getLongitude(), mapActivity.getMapView().fitLocationToMap(location.getLatitude(), location.getLongitude(),
mapActivity.getMapView().getZoom(), tileBoxWidthPx, tileBoxHeightPx, 0, !animating); mapActivity.getMapView().getZoom(), tileBoxWidthPx, tileBoxHeightPx, topMarginPx, !animating);
} else { } else {
mapActivity.refreshMap(); mapActivity.refreshMap();
} }
} }
} }

View file

@ -13,7 +13,6 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.CompoundButton; import android.widget.CompoundButton;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.map.ITileSource; import net.osmand.map.ITileSource;
import net.osmand.map.TileSourceManager; import net.osmand.map.TileSourceManager;
@ -230,6 +229,7 @@ public class MapillaryPlugin extends OsmandPlugin {
boolean success = false; boolean success = false;
OsmandApplication app = (OsmandApplication) activity.getApplication(); OsmandApplication app = (OsmandApplication) activity.getApplication();
if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) { if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) {
try {
if (imageKey != null) { if (imageKey != null) {
Intent intent = new Intent(ACTION_VIEW, Uri.parse(MessageFormat.format("mapillary://mapillary/photo/{0}?image_key={0}", imageKey))); Intent intent = new Intent(ACTION_VIEW, Uri.parse(MessageFormat.format("mapillary://mapillary/photo/{0}?image_key={0}", imageKey)));
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
@ -239,6 +239,9 @@ public class MapillaryPlugin extends OsmandPlugin {
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
app.startActivity(intent); app.startActivity(intent);
} }
} catch (ActivityNotFoundException e) {
new MapillaryInstallDialogFragment().show(activity.getSupportFragmentManager(), MapillaryInstallDialogFragment.TAG);
}
success = true; success = true;
} else { } else {
new MapillaryInstallDialogFragment().show(activity.getSupportFragmentManager(), MapillaryInstallDialogFragment.TAG); new MapillaryInstallDialogFragment().show(activity.getSupportFragmentManager(), MapillaryInstallDialogFragment.TAG);

View file

@ -112,6 +112,9 @@ public class MapMarkersDbHelper {
private SQLiteConnection openConnection(boolean readonly) { private SQLiteConnection openConnection(boolean readonly) {
SQLiteConnection conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly); SQLiteConnection conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
if (conn == null) {
return conn;
}
int version = conn.getVersion(); int version = conn.getVersion();
if (version == 0 || DB_VERSION != version) { if (version == 0 || DB_VERSION != version) {
if (readonly) { if (readonly) {
@ -213,13 +216,15 @@ public class MapMarkersDbHelper {
if (db != null) { if (db != null) {
try { try {
SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT, null); SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT, null);
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
do { do {
MapMarkersGroup group = readGroup(query); MapMarkersGroup group = readGroup(query);
res.put(group.getId(), group); res.put(group.getId(), group);
} while (query.moveToNext()); } while (query.moveToNext());
} }
if(query != null) {
query.close(); query.close();
}
} finally { } finally {
db.close(); db.close();
} }
@ -392,10 +397,12 @@ public class MapMarkersDbHelper {
if (db != null) { if (db != null) {
try { try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ID + " = ?", new String[]{id}); SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ID + " = ?", new String[]{id});
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
res = readItem(query); res = readItem(query);
} }
if(query != null) {
query.close(); query.close();
}
} finally { } finally {
db.close(); db.close();
} }
@ -411,14 +418,16 @@ public class MapMarkersDbHelper {
try { try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?", SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
new String[]{String.valueOf(1)}); new String[]{String.valueOf(1)});
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
do { do {
MapMarker marker = readItem(query); MapMarker marker = readItem(query);
markers.put(marker.id, marker); markers.put(marker.id, marker);
nextKeys.add(marker.nextKey); nextKeys.add(marker.nextKey);
} while (query.moveToNext()); } while (query.moveToNext());
} }
if(query != null) {
query.close(); query.close();
}
} finally { } finally {
db.close(); db.close();
} }
@ -570,12 +579,14 @@ public class MapMarkersDbHelper {
try { try {
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?", SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
new String[]{String.valueOf(0)}); new String[]{String.valueOf(0)});
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
do { do {
markers.add(readItem(query)); markers.add(readItem(query));
} while (query.moveToNext()); } while (query.moveToNext());
} }
if(query != null) {
query.close(); query.close();
}
} finally { } finally {
db.close(); db.close();
} }

View file

@ -218,6 +218,12 @@ public class MarkersPlanRouteContext {
params.ctx = app; params.ctx = app;
params.calculationProgress = calculationProgress = new RouteCalculationProgress(); params.calculationProgress = calculationProgress = new RouteCalculationProgress();
params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() { params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
@Override
public void start() {
}
@Override @Override
public void updateProgress(int progress) { public void updateProgress(int progress) {
int pairs = calculatedPairs + snapToRoadPairsToCalculate.size(); int pairs = calculatedPairs + snapToRoadPairsToCalculate.size();

View file

@ -102,7 +102,7 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
DashLocationFragment.updateLocationView(useCenter, location, DashLocationFragment.updateLocationView(useCenter, location,
heading, holder.iconDirection, R.drawable.ic_direction_arrow, heading, holder.iconDirection, R.drawable.ic_direction_arrow,
holder.distance, new LatLon(mapMarker.getLatitude(), mapMarker.getLongitude()), holder.distance, new LatLon(mapMarker.getLatitude(), mapMarker.getLongitude()),
screenOrientation, mapActivity.getMyApplication(), mapActivity, true); screenOrientation, mapActivity.getMyApplication(), true);
} }
@Override @Override

View file

@ -196,7 +196,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
DashLocationFragment.updateLocationView(useCenter, location, DashLocationFragment.updateLocationView(useCenter, location,
heading, markerImageViewToUpdate, drawableResToUpdate, heading, markerImageViewToUpdate, drawableResToUpdate,
showDirectionEnabled && displayedInWidget ? markerColor : 0, holder.distance, markerLatLon, showDirectionEnabled && displayedInWidget ? markerColor : 0, holder.distance, markerLatLon,
screenOrientation, mapActivity.getMyApplication(), mapActivity, true); screenOrientation, mapActivity.getMyApplication(), true);
} }
@Override @Override

View file

@ -395,7 +395,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
DashLocationFragment.updateLocationView(useCenter, location, DashLocationFragment.updateLocationView(useCenter, location,
heading, markerImageViewToUpdate, drawableResToUpdate, markerToHighlight ? color : 0, heading, markerImageViewToUpdate, drawableResToUpdate, markerToHighlight ? color : 0,
itemViewHolder.distance, markerLatLon, itemViewHolder.distance, markerLatLon,
screenOrientation, app, mapActivity, true); screenOrientation, app, true);
} else if (holder instanceof MapMarkerHeaderViewHolder) { } else if (holder instanceof MapMarkerHeaderViewHolder) {
final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder; final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder;
final Object header = getItem(position); final Object header = getItem(position);

View file

@ -284,6 +284,12 @@ public class MeasurementEditingContext {
params.ctx = application; params.ctx = application;
params.calculationProgress = calculationProgress = new RouteCalculationProgress(); params.calculationProgress = calculationProgress = new RouteCalculationProgress();
params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() { params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
@Override
public void start() {
}
@Override @Override
public void updateProgress(int progress) { public void updateProgress(int progress) {
int pairs = calculatedPairs + snapToRoadPairsToCalculate.size(); int pairs = calculatedPairs + snapToRoadPairsToCalculate.size();

View file

@ -1,6 +1,7 @@
package net.osmand.plus.myplaces; package net.osmand.plus.myplaces;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap; import android.graphics.Bitmap;
import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask; import android.os.AsyncTask;
@ -36,6 +37,7 @@ import net.osmand.plus.GPXUtilities.WptPt;
import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup; import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType; import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings; import net.osmand.plus.OsmandSettings;
@ -238,10 +240,19 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
GPXFile gpx = getGpx(); GPXFile gpx = getGpx();
WptPt pointToShow = gpx != null ? gpx.findPointToShow() : null; WptPt pointToShow = gpx != null ? gpx.findPointToShow() : null;
if (activity != null && pointToShow != null) { if (activity != null && pointToShow != null) {
boolean gpxFileSelected = isGpxFileSelected(gpx);
if (!gpxFileSelected) {
Intent intent = activity.getIntent();
if (intent != null) {
intent.putExtra(TrackActivity.SHOW_TEMPORARILY, true);
}
}
setTrackVisibilityOnMap(true);
LatLon location = new LatLon(pointToShow.getLatitude(), LatLon location = new LatLon(pointToShow.getLatitude(),
pointToShow.getLongitude()); pointToShow.getLongitude());
final OsmandSettings settings = app.getSettings(); final OsmandSettings settings = app.getSettings();
String trackName = ""; String trackName;
if (gpx.showCurrentTrack) { if (gpx.showCurrentTrack) {
trackName = app.getString(R.string.shared_string_currently_recording_track); trackName = app.getString(R.string.shared_string_currently_recording_track);
} else if (gpxDataItem != null) { } else if (gpxDataItem != null) {
@ -265,15 +276,14 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
final View splitIntervalView = headerView.findViewById(R.id.split_interval_view); final View splitIntervalView = headerView.findViewById(R.id.split_interval_view);
final View colorView = headerView.findViewById(R.id.color_view); final View colorView = headerView.findViewById(R.id.color_view);
vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle); vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle);
final View bottomDivider = headerView.findViewById(R.id.bottom_divider);
GPXFile gpxFile = getGpx(); GPXFile gpxFile = getGpx();
final boolean selected = gpxFile != null && boolean gpxFileSelected = isGpxFileSelected(gpxFile);
((gpxFile.showCurrentTrack && app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null) ||
(gpxFile.path != null && app.getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path) != null));
boolean hasPath = gpxFile != null && (gpxFile.tracks.size() > 0 || gpxFile.routes.size() > 0); boolean hasPath = gpxFile != null && (gpxFile.tracks.size() > 0 || gpxFile.routes.size() > 0);
TrackActivity activity = getTrackActivity(); TrackActivity activity = getTrackActivity();
TrackBitmapDrawer trackDrawer = getTrackBitmapDrawer(); TrackBitmapDrawer trackDrawer = getTrackBitmapDrawer();
if (activity != null && trackDrawer!= null) { if (activity != null && trackDrawer != null) {
if (trackDrawer.isNonInitialized()) { if (trackDrawer.isNonInitialized()) {
if (trackDrawer.initAndDraw()) { if (trackDrawer.initAndDraw()) {
imageView.setVisibility(View.VISIBLE); imageView.setVisibility(View.VISIBLE);
@ -285,31 +295,33 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
} }
} }
if (showMapOnly) { vis.setChecked(gpxFileSelected);
headerView.findViewById(R.id.track_settings_view).setVisibility(View.GONE);
} else {
vis.setChecked(selected);
vis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { vis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (!isChecked) { if (!isChecked) {
selectedSplitInterval = 0; selectedSplitInterval = 0;
} }
GPXFile gpxFile = getGpx(); setTrackVisibilityOnMap(vis.isChecked());
if (gpxFile != null) { if (!showMapOnly) {
GpxSelectionHelper.SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile, vis.isChecked(), false);
final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, vis.isChecked() ? sf : null);
if (getGpxDataItem() != null) {
updateSplitInDatabase();
}
}
}
updateSplitIntervalView(splitIntervalView); updateSplitIntervalView(splitIntervalView);
updateColorView(colorView); updateColorView(colorView);
} }
TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null) {
trackActivity.updateHeader(fragment);
}
}
}); });
if (showMapOnly) {
splitIntervalView.setVisibility(View.GONE);
splitColorView.setVisibility(View.GONE);
divider.setVisibility(View.GONE);
bottomDivider.setVisibility(View.VISIBLE);
} else {
bottomDivider.setVisibility(View.GONE);
updateColorView(colorView); updateColorView(colorView);
colorView.setOnClickListener(new View.OnClickListener() { colorView.setOnClickListener(new View.OnClickListener() {
@Override @Override
@ -338,7 +350,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
int clr = item.getColor(); int clr = item.getColor();
if (vis.isChecked()) { if (vis.isChecked()) {
if (gpx != null) { if (gpx != null) {
GpxSelectionHelper.SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, vis.isChecked(), false); SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, vis.isChecked(), false);
if (clr != 0 && sf.getModifiableGpxFile() != null) { if (clr != 0 && sf.getModifiableGpxFile() != null) {
sf.getModifiableGpxFile().setColor(clr); sf.getModifiableGpxFile().setColor(clr);
if (getGpxDataItem() != null) { if (getGpxDataItem() != null) {
@ -388,17 +400,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
@Override @Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) { public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
selectedSplitInterval = position; selectedSplitInterval = position;
GPXFile gpx = getGpx(); setTrackVisibilityOnMap(vis.isChecked());
if (gpx != null) {
GpxSelectionHelper.SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpx, vis.isChecked(), false);
final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, vis.isChecked() ? sf : null);
if (getGpxDataItem() != null) {
updateSplitInDatabase();
}
}
}
splitListPopupWindow.dismiss(); splitListPopupWindow.dismiss();
updateSplitIntervalView(splitIntervalView); updateSplitIntervalView(splitIntervalView);
} }
@ -420,6 +422,29 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
} }
} }
public boolean isGpxFileSelected(GPXFile gpxFile) {
return gpxFile != null &&
((gpxFile.showCurrentTrack && app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null) ||
(gpxFile.path != null && app.getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path) != null));
}
private void setTrackVisibilityOnMap(boolean visible) {
GPXFile gpxFile = getGpx();
if (gpxFile != null) {
GpxSelectionHelper gpxHelper = app.getSelectedGpxHelper();
SelectedGpxFile sf = gpxHelper.selectGpxFile(gpxFile, visible, false);
if (gpxFile.hasTrkPt()) {
List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) {
updateSplit(groups, visible ? sf : null);
if (getGpxDataItem() != null) {
updateSplitInDatabase();
}
}
}
}
}
@Nullable @Nullable
private QuadRect getRect() { private QuadRect getRect() {
TrackActivity activity = getTrackActivity(); TrackActivity activity = getTrackActivity();
@ -574,7 +599,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
addOptionSplit(3600, false, groups); addOptionSplit(3600, false, groups);
} }
private void updateSplit(@NonNull List<GpxDisplayGroup> groups, @Nullable GpxSelectionHelper.SelectedGpxFile sf) { private void updateSplit(@NonNull List<GpxDisplayGroup> groups, @Nullable SelectedGpxFile sf) {
TrackActivity activity = getTrackActivity(); TrackActivity activity = getTrackActivity();
if (activity != null) { if (activity != null) {
new SplitTrackAsyncTask(activity, this, sf, groups) new SplitTrackAsyncTask(activity, this, sf, groups)
@ -582,7 +607,8 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
} }
} }
private void addOptionSplit(int value, boolean distance, List<GpxDisplayGroup> model) { private void addOptionSplit(int value, boolean distance, @NonNull List<GpxDisplayGroup> model) {
if (model.size() > 0) {
if (distance) { if (distance) {
double dvalue = OsmAndFormatter.calculateRoundedDist(value, app); double dvalue = OsmAndFormatter.calculateRoundedDist(value, app);
options.add(OsmAndFormatter.getFormattedDistance((float) dvalue, app)); options.add(OsmAndFormatter.getFormattedDistance((float) dvalue, app));
@ -606,6 +632,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
} }
} }
} }
}
private void updateSplitInDatabase() { private void updateSplitInDatabase() {
int splitType = 0; int splitType = 0;
@ -629,7 +656,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
public void updateSplitView() { public void updateSplitView() {
GPXFile gpxFile = getGpx(); GPXFile gpxFile = getGpx();
if (gpxFile != null) { if (gpxFile != null) {
GpxSelectionHelper.SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile, SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile,
((SwitchCompat) headerView.findViewById(R.id.showOnMapToggle)).isChecked(), false); ((SwitchCompat) headerView.findViewById(R.id.showOnMapToggle)).isChecked(), false);
final List<GpxDisplayGroup> groups = getDisplayGroups(); final List<GpxDisplayGroup> groups = getDisplayGroups();
if (groups.size() > 0) { if (groups.size() > 0) {
@ -749,7 +776,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
} }
private static class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> { private static class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {
private final GpxSelectionHelper.SelectedGpxFile selectedGpx; private final SelectedGpxFile selectedGpx;
private OsmandApplication app; private OsmandApplication app;
private final WeakReference<TrackActivity> activityRef; private final WeakReference<TrackActivity> activityRef;
private final WeakReference<TrackActivityFragmentAdapter> fragmentAdapterRef; private final WeakReference<TrackActivityFragmentAdapter> fragmentAdapterRef;
@ -761,7 +788,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
SplitTrackAsyncTask(@NonNull TrackActivity activity, SplitTrackAsyncTask(@NonNull TrackActivity activity,
@NonNull TrackActivityFragmentAdapter fragmentAdapter, @NonNull TrackActivityFragmentAdapter fragmentAdapter,
@Nullable GpxSelectionHelper.SelectedGpxFile selectedGpx, @Nullable SelectedGpxFile selectedGpx,
@NonNull List<GpxDisplayGroup> groups) { @NonNull List<GpxDisplayGroup> groups) {
activityRef = new WeakReference<>(activity); activityRef = new WeakReference<>(activity);
fragmentAdapterRef = new WeakReference<>(fragmentAdapter); fragmentAdapterRef = new WeakReference<>(fragmentAdapter);
@ -774,6 +801,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
timeSplit = fragmentAdapter.timeSplit; timeSplit = fragmentAdapter.timeSplit;
} }
@Override
protected void onPreExecute() { protected void onPreExecute() {
TrackActivity activity = activityRef.get(); TrackActivity activity = activityRef.get();
if (activity != null) { if (activity != null) {
@ -781,6 +809,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
} }
} }
@Override
protected void onPostExecute(Void result) { protected void onPostExecute(Void result) {
TrackActivity activity = activityRef.get(); TrackActivity activity = activityRef.get();
TrackActivityFragmentAdapter fragment = fragmentAdapterRef.get(); TrackActivityFragmentAdapter fragment = fragmentAdapterRef.get();

View file

@ -266,7 +266,7 @@ public class TrackBitmapDrawer {
float x = tileBox.getPixXFromLatLon(o.lat, o.lon); float x = tileBox.getPixXFromLatLon(o.lat, o.lon);
float y = tileBox.getPixYFromLatLon(o.lat, o.lon); float y = tileBox.getPixYFromLatLon(o.lat, o.lon);
int pointColor = o.getColor(fileColor); int pointColor = o.getColor(fileColor) | 0xff000000;
paintIcon.setColorFilter(new PorterDuffColorFilter(pointColor, PorterDuff.Mode.MULTIPLY)); paintIcon.setColorFilter(new PorterDuffColorFilter(pointColor, PorterDuff.Mode.MULTIPLY));
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon); canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
} }

View file

@ -341,6 +341,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
} }
// Needed to hide intermediate progress bar after closing action mode // Needed to hide intermediate progress bar after closing action mode
new Handler().postDelayed(new Runnable() { new Handler().postDelayed(new Runnable() {
@Override
public void run() { public void run() {
hideProgressBar(); hideProgressBar();
} }
@ -633,8 +634,19 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
} }
updateSelectionMode(actionMode); updateSelectionMode(actionMode);
} else { } else {
if (item.group.getGpx() != null) { GPXFile gpx = item.group.getGpx();
app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx()); if (gpx != null) {
TrackActivity trackActivity = getTrackActivity();
if (trackActivity != null && fragmentAdapter != null) {
boolean gpxFileSelected = fragmentAdapter.isGpxFileSelected(gpx);
if (!gpxFileSelected) {
Intent intent = trackActivity.getIntent();
if (intent != null) {
intent.putExtra(TrackActivity.SHOW_TEMPORARILY, true);
}
}
}
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
} }
final OsmandSettings settings = app.getSettings(); final OsmandSettings settings = app.getSettings();
LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon); LatLon location = new LatLon(item.locationStart.lat, item.locationStart.lon);
@ -675,6 +687,12 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
} }
} }
public void updateHeader() {
if (fragmentAdapter != null) {
fragmentAdapter.updateHeader(0);
}
}
class PointGPXAdapter extends OsmandBaseExpandableListAdapter implements Filterable { class PointGPXAdapter extends OsmandBaseExpandableListAdapter implements Filterable {
Map<GpxDisplayGroup, List<GpxDisplayItem>> itemGroups = new LinkedHashMap<>(); Map<GpxDisplayGroup, List<GpxDisplayItem>> itemGroups = new LinkedHashMap<>();

View file

@ -253,7 +253,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
} }
} }
private void updateHeader() { public void updateHeader() {
if (fragmentAdapter != null) { if (fragmentAdapter != null) {
fragmentAdapter.updateHeader(adapter.getCount()); fragmentAdapter.updateHeader(adapter.getCount());
} }

View file

@ -0,0 +1,78 @@
package net.osmand.plus.notifications;
import android.support.v4.app.NotificationCompat;
import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RoutingHelper;
public class ErrorNotification extends OsmandNotification {
private final static String GROUP_NAME = "ERROR";
public ErrorNotification(OsmandApplication app) {
super(app, GROUP_NAME);
}
@Override
public void init() {
}
@Override
public NotificationType getType() {
return NotificationType.ERROR;
}
@Override
public int getPriority() {
return NotificationCompat.PRIORITY_DEFAULT;
}
@Override
public boolean isActive() {
return true;
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public NotificationCompat.Builder buildNotification(boolean wearable) {
String notificationTitle;
String notificationText;
icon = R.drawable.ic_action_bug_dark;
notificationTitle = app.getString(R.string.shared_string_unexpected_error);
NavigationService service = app.getNavigationService();
RoutingHelper routingHelper = app.getRoutingHelper();
boolean following = routingHelper.isFollowingMode();
boolean planning = routingHelper.isRoutePlanningMode();
boolean pause = routingHelper.isPauseNavigation();
boolean gpxEnabled = OsmandPlugin.getEnabledPlugin(OsmandMonitoringPlugin.class) != null;
String usedBy = service != null ? "" + service.getUsedBy() : "X";
notificationText = "Info: " + (following ? "1" : "") + (planning ? "2" : "") + (pause ? "3" : "") + (gpxEnabled ? "4" : "") + "-" + usedBy + ". "
+ app.getString(R.string.error_notification_desc);
return createBuilder(wearable)
.setContentTitle(notificationTitle)
.setStyle(new NotificationCompat.BigTextStyle().bigText(notificationText));
}
@Override
public int getOsmandNotificationId() {
return ERROR_NOTIFICATION_SERVICE_ID;
}
@Override
public int getOsmandWearableNotificationId() {
return WEAR_ERROR_NOTIFICATION_SERVICE_ID;
}
}

View file

@ -5,9 +5,9 @@ import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.content.IntentFilter; import android.content.IntentFilter;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.BigTextStyle; import android.support.v4.app.NotificationCompat.BigTextStyle;
import android.support.v4.app.NotificationCompat.Builder; import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationCompat;
import net.osmand.plus.NavigationService; import net.osmand.plus.NavigationService;
import net.osmand.plus.OsmAndFormatter; import net.osmand.plus.OsmAndFormatter;

View file

@ -10,11 +10,10 @@ import android.graphics.Bitmap;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.PorterDuff; import android.graphics.PorterDuff;
import android.graphics.drawable.Drawable; import android.graphics.drawable.Drawable;
import android.os.Build; import android.os.Build;
import android.support.v4.app.NotificationCompat; import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationCompat.BigTextStyle; import android.support.v4.app.NotificationCompat.BigTextStyle;
import android.support.v4.app.NotificationCompat.Builder;
import android.view.View; import android.view.View;
import net.osmand.plus.NavigationService; import net.osmand.plus.NavigationService;

View file

@ -2,27 +2,27 @@ package net.osmand.plus.notifications;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.app.Notification; import android.app.Notification;
import android.app.NotificationChannel;
import android.app.NotificationManager;
import android.app.PendingIntent; import android.app.PendingIntent;
import android.content.Context; import android.content.Context;
import android.content.Intent; import android.content.Intent;
import android.support.v4.app.NotificationCompat;
import android.support.v4.app.NotificationCompat.Builder; import android.support.v4.app.NotificationCompat.Builder;
import android.support.v4.app.NotificationManagerCompat; import android.support.v4.app.NotificationManagerCompat;
import android.support.v4.app.NotificationCompat;
import net.osmand.plus.NotificationHelper; import net.osmand.plus.NotificationHelper;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
public abstract class OsmandNotification { public abstract class OsmandNotification {
public final static int NAVIGATION_NOTIFICATION_SERVICE_ID = 5; public final static int NAVIGATION_NOTIFICATION_SERVICE_ID = 5;
public final static int GPX_NOTIFICATION_SERVICE_ID = 6; public final static int GPX_NOTIFICATION_SERVICE_ID = 6;
public final static int ERROR_NOTIFICATION_SERVICE_ID = 7;
public final static int TOP_NOTIFICATION_SERVICE_ID = 100; public final static int TOP_NOTIFICATION_SERVICE_ID = 100;
public final static int WEAR_NAVIGATION_NOTIFICATION_SERVICE_ID = 1005; 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_GPX_NOTIFICATION_SERVICE_ID = 1006;
public final static int WEAR_ERROR_NOTIFICATION_SERVICE_ID = 1007;
protected OsmandApplication app; protected OsmandApplication app;
@ -36,7 +36,8 @@ public abstract class OsmandNotification {
public enum NotificationType { public enum NotificationType {
NAVIGATION, NAVIGATION,
GPX, GPX,
GPS GPS,
ERROR,
} }
public OsmandNotification(OsmandApplication app, String groupName) { public OsmandNotification(OsmandApplication app, String groupName) {

View file

@ -143,7 +143,12 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
amenityTagTextView.setText(pt.getEditOsmTag()); amenityTagTextView.setText(pt.getEditOsmTag());
amenityTextView.setText(pt.getEditOsmValue()); amenityTextView.setText(pt.getEditOsmValue());
} else { } else {
amenityTagTextView.setText(getData().getPoiCategory().getDefaultTag()); PoiCategory category = getData().getPoiCategory();
if (category != null) {
amenityTagTextView.setText(category.getDefaultTag());
} else {
amenityTagTextView.setText(R.string.tag_poi_amenity);
}
amenityTextView.setText(getData().getPoiTypeString()); amenityTextView.setText(getData().getPoiTypeString());
} }
} }

View file

@ -1,5 +1,7 @@
package net.osmand.plus.osmedit; package net.osmand.plus.osmedit;
import android.support.annotation.Nullable;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.osm.PoiCategory; import net.osmand.osm.PoiCategory;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
@ -52,7 +54,7 @@ public class EditPoiData {
} }
} }
@Nullable
public PoiCategory getPoiCategory() { public PoiCategory getPoiCategory() {
return category; return category;
} }

View file

@ -273,7 +273,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
if (!getEditPoiData().isInEdit()) { if (!getEditPoiData().isInEdit()) {
getEditPoiData().updateTypeTag(s.toString(), true); getEditPoiData().updateTypeTag(s.toString(), true);
if (!getMyApplication().isApplicationInitializing()) { if (!getMyApplication().isApplicationInitializing()) {
poiTypeTextInputLayout.setHint(editPoiData.getPoiCategory().getTranslation()); PoiCategory category = editPoiData.getPoiCategory();
if (category != null) {
poiTypeTextInputLayout.setHint(category.getTranslation());
}
} }
} }
} }
@ -289,9 +292,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
if (event.getX() >= (editText.getRight() if (event.getX() >= (editText.getRight()
- editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width() - editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width()
- editText.getPaddingRight())) { - editText.getPaddingRight())) {
if (editPoiData.getPoiCategory() != null) { PoiCategory category = editPoiData.getPoiCategory();
if (category != null) {
PoiSubTypeDialogFragment dialogFragment = PoiSubTypeDialogFragment dialogFragment =
PoiSubTypeDialogFragment.createInstance(editPoiData.getPoiCategory()); PoiSubTypeDialogFragment.createInstance(category);
dialogFragment.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() { dialogFragment.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() {
@Override @Override
public void select(String category) { public void select(String category) {
@ -466,8 +470,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2()); node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2());
} }
} else if (!Algorithms.isEmpty(poiTypeTag)) { } else if (!Algorithms.isEmpty(poiTypeTag)) {
node.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), poiTypeTag); PoiCategory category = editPoiData.getPoiCategory();
if (category != null) {
node.putTagNoLC(category.getDefaultTag(), poiTypeTag);
}
} }
if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) { if (offlineEdit && !Algorithms.isEmpty(poiTypeTag)) {
node.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag); node.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag);

View file

@ -18,6 +18,7 @@ import android.widget.Toast;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.data.Amenity; import net.osmand.data.Amenity;
import net.osmand.data.TransportStop;
import net.osmand.osm.PoiType; import net.osmand.osm.PoiType;
import net.osmand.osm.edit.Node; import net.osmand.osm.edit.Node;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
@ -195,7 +196,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
} else if (resId == R.string.context_menu_item_modify_note) { } else if (resId == R.string.context_menu_item_modify_note) {
modifyOsmNote(mapActivity, (OsmNotesPoint) selectedObj); modifyOsmNote(mapActivity, (OsmNotesPoint) selectedObj);
} else if (resId == R.string.poi_context_menu_modify) { } else if (resId == R.string.poi_context_menu_modify) {
EditPoiDialogFragment.showEditInstance((Amenity) selectedObj, mapActivity); EditPoiDialogFragment.showEditInstance(selectedObj instanceof TransportStop ?
((TransportStop) selectedObj).getAmenity() : (Amenity) selectedObj, mapActivity);
} else if (resId == R.string.poi_context_menu_modify_osm_change) { } else if (resId == R.string.poi_context_menu_modify_osm_change) {
final Node entity = ((OpenstreetmapPoint) selectedObj).getEntity(); final Node entity = ((OpenstreetmapPoint) selectedObj).getEntity();
EditPoiDialogFragment.createInstance(entity, false) EditPoiDialogFragment.createInstance(entity, false)
@ -205,8 +207,13 @@ public class OsmEditingPlugin extends OsmandPlugin {
} }
}; };
boolean isEditable = false; boolean isEditable = false;
if (selectedObj instanceof Amenity || (selectedObj instanceof TransportStop && ((TransportStop) selectedObj).getAmenity() != null)) {
Amenity amenity;
if (selectedObj instanceof Amenity) { if (selectedObj instanceof Amenity) {
Amenity amenity = (Amenity) selectedObj; amenity = (Amenity) selectedObj;
} else {
amenity = ((TransportStop) selectedObj).getAmenity();
}
final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType()); final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
isEditable = !amenity.getType().isWiki() && poiType !=null && !poiType.isNotEditableOsm(); isEditable = !amenity.getType().isWiki() && poiType !=null && !poiType.isNotEditableOsm();
} }

View file

@ -473,7 +473,7 @@ public class PoiFiltersHelper {
SQLiteCursor query = conn.rawQuery("SELECT " + CATEGORIES_FILTER_ID + ", " + CATEGORIES_COL_CATEGORY + "," + CATEGORIES_COL_SUBCATEGORY + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ SQLiteCursor query = conn.rawQuery("SELECT " + CATEGORIES_FILTER_ID + ", " + CATEGORIES_COL_CATEGORY + "," + CATEGORIES_COL_SUBCATEGORY + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
CATEGORIES_NAME, null); CATEGORIES_NAME, null);
Map<String, Map<PoiCategory, LinkedHashSet<String>>> map = new LinkedHashMap<String, Map<PoiCategory, LinkedHashSet<String>>>(); Map<String, Map<PoiCategory, LinkedHashSet<String>>> map = new LinkedHashMap<String, Map<PoiCategory, LinkedHashSet<String>>>();
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
do { do {
String filterId = query.getString(0); String filterId = query.getString(0);
if (!map.containsKey(filterId)) { if (!map.containsKey(filterId)) {
@ -492,11 +492,13 @@ public class PoiFiltersHelper {
} }
} while (query.moveToNext()); } while (query.moveToNext());
} }
if(query != null) {
query.close(); query.close();
}
query = conn.rawQuery("SELECT " + FILTER_COL_ID + ", " + FILTER_COL_NAME + "," + FILTER_COL_FILTERBYNAME + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ query = conn.rawQuery("SELECT " + FILTER_COL_ID + ", " + FILTER_COL_NAME + "," + FILTER_COL_FILTERBYNAME + " FROM " + //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
FILTER_NAME, null); FILTER_NAME, null);
if (query.moveToFirst()) { if (query != null && query.moveToFirst()) {
do { do {
String filterId = query.getString(0); String filterId = query.getString(0);
if (map.containsKey(filterId)) { if (map.containsKey(filterId)) {
@ -507,8 +509,10 @@ public class PoiFiltersHelper {
} }
} while (query.moveToNext()); } while (query.moveToNext());
} }
if(query != null) {
query.close(); query.close();
} }
}
return list; return list;
} }

View file

@ -76,6 +76,10 @@ public class QuickAction {
return id; return id;
} }
public long getType() {
return type;
}
public boolean isActionEditable() { public boolean isActionEditable() {
return isActionEditable; return isActionEditable;
} }

View file

@ -109,8 +109,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
private void setUpToolbar(View view) { private void setUpToolbar(View view) {
Toolbar toolbar = (Toolbar) view.findViewById(R.id.custom_toolbar); Toolbar toolbar = (Toolbar) view.findViewById(R.id.custom_toolbar);
Drawable back = getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back); Drawable back = getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back, R.color.color_white);
back.setColorFilter(ContextCompat.getColor(getContext(), R.color.color_white), PorterDuff.Mode.MULTIPLY);
toolbar.setNavigationIcon(back); toolbar.setNavigationIcon(back);
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up); toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
toolbar.setNavigationOnClickListener(new View.OnClickListener() { toolbar.setNavigationOnClickListener(new View.OnClickListener() {

View file

@ -1,9 +1,12 @@
package net.osmand.plus.quickaction; package net.osmand.plus.quickaction;
import android.content.Context; import android.content.Context;
import android.os.Bundle;
import android.support.annotation.StringRes; import android.support.annotation.StringRes;
import android.support.v4.app.FragmentManager;
import android.support.v4.view.MotionEventCompat; import android.support.v4.view.MotionEventCompat;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.SwitchCompat;
import android.support.v7.widget.helper.ItemTouchHelper; import android.support.v7.widget.helper.ItemTouchHelper;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -16,6 +19,7 @@ import android.widget.TextView;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.dialogs.SelectMapViewQuickActionsBottomSheet;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
@ -23,6 +27,10 @@ import java.util.List;
public abstract class SwitchableAction<T> extends QuickAction { public abstract class SwitchableAction<T> extends QuickAction {
public static final String KEY_ID = "id";
protected static final String KEY_DIALOG = "dialog";
private transient EditText title; private transient EditText title;
protected SwitchableAction(int type) { protected SwitchableAction(int type) {
@ -44,12 +52,17 @@ public abstract class SwitchableAction<T> extends QuickAction {
View view = LayoutInflater.from(parent.getContext()) View view = LayoutInflater.from(parent.getContext())
.inflate(R.layout.quick_action_switchable_action, parent, false); .inflate(R.layout.quick_action_switchable_action, parent, false);
SwitchCompat showDialog = (SwitchCompat) view.findViewById(R.id.saveButton);
if (!getParams().isEmpty()) {
showDialog.setChecked(Boolean.valueOf(getParams().get(KEY_DIALOG)));
}
final RecyclerView list = (RecyclerView) view.findViewById(R.id.list); final RecyclerView list = (RecyclerView) view.findViewById(R.id.list);
final QuickActionItemTouchHelperCallback touchHelperCallback = new QuickActionItemTouchHelperCallback(); final QuickActionItemTouchHelperCallback touchHelperCallback = new QuickActionItemTouchHelperCallback();
final ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback); final ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
final Adapter adapter = new Adapter(new QuickActionListFragment.OnStartDragListener() { final Adapter adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() {
@Override @Override
public void onStartDrag(RecyclerView.ViewHolder viewHolder) { public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
touchHelper.startDrag(viewHolder); touchHelper.startDrag(viewHolder);
@ -90,12 +103,28 @@ public abstract class SwitchableAction<T> extends QuickAction {
return hasParams; return hasParams;
} }
public abstract List<T> loadListFromParams();
public abstract void executeWithParams(MapActivity activity, String params);
public abstract String getTranslatedItemName(Context context, String item);
protected void showChooseDialog(FragmentManager fm) {
SelectMapViewQuickActionsBottomSheet fragment = new SelectMapViewQuickActionsBottomSheet();
Bundle args = new Bundle();
args.putLong(KEY_ID, id);
fragment.setArguments(args);
fragment.show(fm, SelectMapViewQuickActionsBottomSheet.TAG);
}
protected class Adapter extends RecyclerView.Adapter<Adapter.ItemHolder> implements QuickActionItemTouchHelperCallback.OnItemMoveCallback { protected class Adapter extends RecyclerView.Adapter<Adapter.ItemHolder> implements QuickActionItemTouchHelperCallback.OnItemMoveCallback {
private List<T> itemsList = new ArrayList<>(); private List<T> itemsList = new ArrayList<>();
private final QuickActionListFragment.OnStartDragListener onStartDragListener; private final QuickActionListFragment.OnStartDragListener onStartDragListener;
private Context context;
public Adapter(QuickActionListFragment.OnStartDragListener onStartDragListener) { public Adapter(Context context, QuickActionListFragment.OnStartDragListener onStartDragListener) {
this.context = context;
this.onStartDragListener = onStartDragListener; this.onStartDragListener = onStartDragListener;
this.itemsList = new ArrayList<>(); this.itemsList = new ArrayList<>();
} }
@ -110,7 +139,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
public void onBindViewHolder(final Adapter.ItemHolder holder, final int position) { public void onBindViewHolder(final Adapter.ItemHolder holder, final int position) {
final T item = itemsList.get(position); final T item = itemsList.get(position);
holder.title.setText(getItemName(item)); holder.title.setText(getItemName(context, item));
holder.handleView.setOnTouchListener(new View.OnTouchListener() { holder.handleView.setOnTouchListener(new View.OnTouchListener() {
@Override @Override
@ -249,9 +278,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
protected abstract void saveListToParams(List<T> list); protected abstract void saveListToParams(List<T> list);
protected abstract List<T> loadListFromParams(); protected abstract String getItemName(Context context, T item);
protected abstract String getItemName(T item);
protected abstract protected abstract
@StringRes @StringRes

View file

@ -117,8 +117,10 @@ public class AddPOIAction extends QuickAction {
newNode.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2()); newNode.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
} }
} else if (!Algorithms.isEmpty(tag.getValue())) { } else if (!Algorithms.isEmpty(tag.getValue())) {
newNode.putTagNoLC(editPoiData.getPoiCategory().getDefaultTag(), tag.getValue()); PoiCategory category = editPoiData.getPoiCategory();
if (category != null) {
newNode.putTagNoLC(category.getDefaultTag(), tag.getValue());
}
} }
if (offlineEdit && !Algorithms.isEmpty(tag.getValue())) { if (offlineEdit && !Algorithms.isEmpty(tag.getValue())) {
newNode.putTagNoLC(tag.getKey(), tag.getValue()); newNode.putTagNoLC(tag.getKey(), tag.getValue());

View file

@ -1,8 +1,10 @@
package net.osmand.plus.quickaction.actions; package net.osmand.plus.quickaction.actions;
import android.content.Context;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.support.v4.util.Pair; import android.support.v4.util.Pair;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import android.support.v7.widget.SwitchCompat;
import android.view.View; import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import android.widget.Toast; import android.widget.Toast;
@ -55,7 +57,7 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
} }
@Override @Override
protected List<Pair<String, String>> loadListFromParams() { public List<Pair<String, String>> loadListFromParams() {
String json = getParams().get(getListKey()); String json = getParams().get(getListKey());
@ -68,7 +70,7 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
} }
@Override @Override
protected String getItemName(Pair<String, String> item) { protected String getItemName(Context context, Pair<String, String> item) {
return item.second; return item.second;
} }
@ -82,6 +84,12 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
OsmandSettings settings = activity.getMyApplication().getSettings(); OsmandSettings settings = activity.getMyApplication().getSettings();
List<Pair<String, String>> sources = loadListFromParams(); List<Pair<String, String>> sources = loadListFromParams();
boolean showBottomSheetStyles = Boolean.valueOf(getParams().get(KEY_DIALOG));
if (showBottomSheetStyles) {
showChooseDialog(activity.getSupportFragmentManager());
return;
}
Pair<String, String> currentSource = new Pair<>( Pair<String, String> currentSource = new Pair<>(
settings.MAP_OVERLAY.get(), settings.MAP_OVERLAY.get(),
settings.MAP_OVERLAY.get()); settings.MAP_OVERLAY.get());
@ -92,18 +100,35 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
if (index >= 0 && index + 1 < sources.size()) { if (index >= 0 && index + 1 < sources.size()) {
nextSource = sources.get(index + 1); nextSource = sources.get(index + 1);
} }
executeWithParams(activity, nextSource.first);
}
}
boolean hasOverlay = !nextSource.first.equals(KEY_NO_OVERLAY); @Override
public void executeWithParams(MapActivity activity, String params) {
OsmandRasterMapsPlugin plugin = OsmandPlugin.getEnabledPlugin(OsmandRasterMapsPlugin.class);
if (plugin != null) {
OsmandSettings settings = activity.getMyApplication().getSettings();
boolean hasOverlay = !params.equals(KEY_NO_OVERLAY);
if (hasOverlay) { if (hasOverlay) {
settings.MAP_OVERLAY.set(nextSource.first); settings.MAP_OVERLAY.set(params);
settings.MAP_OVERLAY_PREVIOUS.set(nextSource.first); settings.MAP_OVERLAY_PREVIOUS.set(params);
} else { } else {
settings.MAP_OVERLAY.set(null); settings.MAP_OVERLAY.set(null);
settings.MAP_OVERLAY_PREVIOUS.set(null); settings.MAP_OVERLAY_PREVIOUS.set(null);
} }
plugin.updateMapLayers(activity.getMapView(), settings.MAP_OVERLAY, activity.getMapLayers()); plugin.updateMapLayers(activity.getMapView(), settings.MAP_OVERLAY, activity.getMapLayers());
Toast.makeText(activity, activity.getString(R.string.quick_action_map_overlay_switch, nextSource.second), Toast.LENGTH_SHORT).show(); Toast.makeText(activity, activity.getString(R.string.quick_action_map_overlay_switch,
getTranslatedItemName(activity, params)), Toast.LENGTH_SHORT).show();
}
}
@Override
public String getTranslatedItemName(Context context, String item) {
if (item.equals(KEY_NO_OVERLAY)) {
return context.getString(R.string.no_overlay);
} else {
return item;
} }
} }
@ -165,4 +190,11 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
} }
}; };
} }
@Override
public boolean fillParams(View root, MapActivity activity) {
super.fillParams(root, activity);
getParams().put(KEY_DIALOG, Boolean.toString(((SwitchCompat) root.findViewById(R.id.saveButton)).isChecked()));
return true;
}
} }

Some files were not shown because too many files have changed in this diff Show more