Compare commits
126 commits
Author | SHA1 | Date | |
---|---|---|---|
|
1f96c9c00d | ||
|
4ed7f81661 | ||
|
3d8a20ca77 | ||
|
55aec52fc0 | ||
|
765402b4e8 | ||
|
66dd86360f | ||
|
8cba8ae6ba | ||
|
6488712bb7 | ||
|
9b5e835a8f | ||
|
e5503c277d | ||
|
864f4ef7a9 | ||
|
9de34ecf0c | ||
|
92235adeb1 | ||
|
7b6d02b93d | ||
|
8b167faac5 | ||
|
08e3f9d2bc | ||
|
3edeeac27c | ||
|
a05ff9c556 | ||
|
d4065587c0 | ||
|
988b916ddb | ||
|
fe478b7427 | ||
|
08e8e8c972 | ||
|
2d8b202e9b | ||
|
b5f5cb3cfe | ||
|
e76ea77a5b | ||
|
81fe4d2d94 | ||
|
df81a47b6e | ||
|
14e11eaff3 | ||
|
0cef616b45 | ||
|
c22968ea68 | ||
|
dd98c8d7c0 | ||
|
18a6aec223 | ||
|
fbc6665d76 | ||
|
624380773b | ||
|
abbc0fe2ee | ||
|
86665945be | ||
|
b936a052e1 | ||
|
74d887a755 | ||
|
1ddf2775e1 | ||
|
0ccc10ebf1 | ||
|
61993a1452 | ||
|
dc14885f1f | ||
|
e7c19ac764 | ||
|
50647d29f7 | ||
|
7d2fdd3e4a | ||
|
35c53ed5e3 | ||
|
34ea004ea2 | ||
|
6c2d1e43a3 | ||
|
b6885b5a33 | ||
|
652d9209a8 | ||
|
8bd56274b1 | ||
|
6ad69050a6 | ||
|
144e0012c1 | ||
|
11a6843476 | ||
|
ff4b3f4046 | ||
|
5167a076fe | ||
|
62a895a4a5 | ||
|
fd16da1f81 | ||
|
c9f8057b13 | ||
|
5c7b4cf719 | ||
|
846bd3fcfa | ||
|
ada8c2a998 | ||
|
4fc3b20e5d | ||
|
86376c9ed8 | ||
|
c503c78c70 | ||
|
be1bb0e257 | ||
|
df88bf74be | ||
|
f8246c5cf4 | ||
|
d902888f4a | ||
|
85e2e19801 | ||
|
27b88ea389 | ||
|
ae2df017ef | ||
|
17f4dfb7c4 | ||
|
1385b5e267 | ||
|
285d3c1a6c | ||
|
0d1c54f534 | ||
|
5e26ec37d9 | ||
|
7e16d30a71 | ||
|
c62f0ae66c | ||
|
843962d0ec | ||
|
2660d23d79 | ||
|
cb6fe98a00 | ||
|
4718accc86 | ||
|
620e08794f | ||
|
34a711454e | ||
|
520cb4a79e | ||
|
d58e00a552 | ||
|
f6e22b6b5d | ||
|
33c47cc399 | ||
|
ea157a2d9c | ||
|
75f68df9f2 | ||
|
22592206c7 | ||
|
ecb496d21f | ||
|
90def12184 | ||
|
4ce1625e3e | ||
|
1307b3e487 | ||
|
d493e5ef15 | ||
|
42c3d27029 | ||
|
59cc7ec7ad | ||
|
fff98d810d | ||
|
0cd0fb59d3 | ||
|
16dd3cec72 | ||
|
405ae9f69e | ||
|
284f53ba19 | ||
|
8347b01194 | ||
|
a8de3846f8 | ||
|
d62f5a53df | ||
|
8d7331fd93 | ||
|
76d9bc80b7 | ||
|
821511d7e3 | ||
|
bad6f228a3 | ||
|
c7d77a1373 | ||
|
40ea33bf46 | ||
|
696fdfe6be | ||
|
b559414be4 | ||
|
4fad525359 | ||
|
d1d6eaeb73 | ||
|
40c41d5e40 | ||
|
4c72b0df4c | ||
|
521f87027c | ||
|
a7c38e3c8e | ||
|
bf242fa58c | ||
|
c779f4b69d | ||
|
d81c98a13b | ||
|
159796f3e2 | ||
|
ff5b795694 |
|
@ -236,6 +236,7 @@ public class RouteDataObject {
|
|||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
public String getName(String lang){
|
||||
return getName(lang, false);
|
||||
|
@ -684,6 +685,18 @@ public class RouteDataObject {
|
|||
}
|
||||
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) {
|
||||
int[] pt = getPointTypes(intId);
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package net.osmand.data;
|
||||
|
||||
public class TransportStop extends MapObject {
|
||||
int[] referencesToRoutes = null;
|
||||
|
||||
private int[] referencesToRoutes = null;
|
||||
private Amenity amenity;
|
||||
public int distance;
|
||||
|
||||
public TransportStop(){
|
||||
}
|
||||
|
||||
|
@ -14,4 +16,11 @@ public class TransportStop extends MapObject {
|
|||
this.referencesToRoutes = referencesToRoutes;
|
||||
}
|
||||
|
||||
public Amenity getAmenity() {
|
||||
return amenity;
|
||||
}
|
||||
|
||||
public void setAmenity(Amenity amenity) {
|
||||
this.amenity = amenity;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,37 @@ public class RouteCalculationProgress {
|
|||
public int loadedTiles = 0;
|
||||
public int visitedSegments = 0;
|
||||
|
||||
public int totalIterations = 1;
|
||||
public int iteration = -1;
|
||||
|
||||
public boolean isCancelled;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -158,6 +158,7 @@ public class RoutePlannerFrontEnd {
|
|||
}
|
||||
if (ctx.calculationMode == RouteCalculationMode.COMPLEX && routeDirection == null
|
||||
&& maxDistance > ctx.config.DEVIATION_RADIUS * 6) {
|
||||
ctx.calculationProgress.totalIterations++;
|
||||
RoutingContext nctx = buildRoutingContext(ctx.config, ctx.nativeLib, ctx.getMaps(), RouteCalculationMode.BASE);
|
||||
nctx.calculationProgress = ctx.calculationProgress;
|
||||
List<RouteSegmentResult> ls = searchRoute(nctx, start, end, intermediates);
|
||||
|
@ -175,6 +176,7 @@ public class RoutePlannerFrontEnd {
|
|||
if (routeDirection != null) {
|
||||
ctx.precalculatedRouteDirection = routeDirection.adopt(ctx);
|
||||
}
|
||||
ctx.calculationProgress.nextIteration();
|
||||
List<RouteSegmentResult> res = runNativeRouting(ctx, recalculationEnd);
|
||||
if (res != null) {
|
||||
new RouteResultPreparation().printResults(ctx, start, end, res);
|
||||
|
@ -197,6 +199,7 @@ public class RoutePlannerFrontEnd {
|
|||
if (!addSegment(end, ctx, indexNotFound++, points)) {
|
||||
return null;
|
||||
}
|
||||
ctx.calculationProgress.nextIteration();
|
||||
List<RouteSegmentResult> res = searchRoute(ctx, points, routeDirection);
|
||||
// make start and end more precise
|
||||
makeStartEndPointsPrecise(res, start, end, intermediates);
|
||||
|
|
|
@ -743,9 +743,9 @@ public class RouteResultPreparation {
|
|||
}
|
||||
}
|
||||
}
|
||||
if(straightActiveLen == target.activeLen) {
|
||||
if(straightActiveBegin != -1 && straightActiveLen <= target.activeLen) {
|
||||
active.activeStartIndex = straightActiveBegin;
|
||||
active.activeEndIndex = straightActiveBegin + target.activeLen - 1;
|
||||
active.activeEndIndex = straightActiveBegin + straightActiveLen - 1;
|
||||
changed = true;
|
||||
} else {
|
||||
// cause the next-turn goes forward exclude left most and right most lane
|
||||
|
|
|
@ -71,6 +71,9 @@ public class RouteSegmentResult {
|
|||
}
|
||||
|
||||
public void attachRoute(int roadIndex, RouteSegmentResult r){
|
||||
if(r.getObject().isRoadDeleted()) {
|
||||
return;
|
||||
}
|
||||
int st = Math.abs(roadIndex - startPointIndex);
|
||||
if(attachedRoutes[st] == null) {
|
||||
attachedRoutes[st] = new ArrayList<RouteSegmentResult>();
|
||||
|
|
|
@ -416,11 +416,13 @@ public class TurnType {
|
|||
public static int convertType(String lane) {
|
||||
int turn;
|
||||
// merge should be recognized as continue route (but it could displayed differently)
|
||||
if (lane.equals("none") || lane.equals("through")
|
||||
|| lane.equals("merge_to_left")
|
||||
|| lane.equals("merge_to_right")) {
|
||||
if(lane.equals("merge_to_left")) {
|
||||
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;
|
||||
} else if (lane.equals("slight_left") ) {
|
||||
turn = TurnType.TSLL;
|
||||
|
|
|
@ -595,8 +595,8 @@
|
|||
},
|
||||
"expectedResults": {
|
||||
"222244": "TL|TL|+C,TR",
|
||||
"222243": "TL|TL|+C|C|TSLR",
|
||||
"222164": "TL|TL|+C|C"
|
||||
"222243": "TL|TL|+C|+C|TSLR",
|
||||
"222164": "TL|TL|+C|+C"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -756,7 +756,23 @@
|
|||
</receiver>
|
||||
<activity android:name=".liveupdates.OsmLiveActivity"
|
||||
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"/>
|
||||
</application>
|
||||
|
|
|
@ -410,11 +410,11 @@ dependencies {
|
|||
implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
|
||||
}
|
||||
implementation 'com.android.support:multidex:1.0.1'
|
||||
implementation 'com.android.support:gridlayout-v7:27.1.0'
|
||||
implementation 'com.android.support:cardview-v7:27.1.0'
|
||||
implementation 'com.android.support:appcompat-v7:27.1.0'
|
||||
implementation 'com.android.support:design:27.1.0'
|
||||
implementation 'com.android.support:customtabs:27.1.0'
|
||||
implementation 'com.android.support:gridlayout-v7:27.1.1'
|
||||
implementation 'com.android.support:cardview-v7:27.1.1'
|
||||
implementation 'com.android.support:appcompat-v7:27.1.1'
|
||||
implementation 'com.android.support:design:27.1.1'
|
||||
implementation 'com.android.support:customtabs:27.1.1'
|
||||
implementation fileTree(include: ['gnu-trove-osmand.jar', 'icu4j-49_1_patched.jar'], dir: 'libs')
|
||||
|
||||
implementation 'commons-logging:commons-logging-api:1.1'
|
||||
|
|
BIN
OsmAnd/res/drawable-hdpi/ic_action_internet_access_fee.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
BIN
OsmAnd/res/drawable-hdpi/ic_action_save_to_file.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.2 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_internet_access_fee.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-mdpi/ic_action_save_to_file.png
Normal file
After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_internet_access_fee.png
Normal file
After Width: | Height: | Size: 1.7 KiB |
BIN
OsmAnd/res/drawable-xhdpi/ic_action_save_to_file.png
Normal file
After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.3 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_internet_access_fee.png
Normal file
After Width: | Height: | Size: 2.1 KiB |
BIN
OsmAnd/res/drawable-xxhdpi/ic_action_save_to_file.png
Normal file
After Width: | Height: | Size: 1.5 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.4 KiB |
|
@ -192,39 +192,19 @@
|
|||
android:contentDescription="@string/shared_string_hide"
|
||||
android:src="@drawable/headliner_close"/>
|
||||
</LinearLayout>
|
||||
|
||||
<ProgressBar
|
||||
android:id="@+id/map_horizontal_progress"
|
||||
style="?android:attr/progressBarStyleHorizontal"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_gravity="bottom"
|
||||
android:layout_height="4dp"
|
||||
android:max="100"
|
||||
android:visibility="gone"
|
||||
tools:progress="60"
|
||||
tools:visibility="visible" />
|
||||
|
||||
|
||||
<!-- CONTEXT MENU -->
|
||||
|
||||
<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>
|
||||
|
||||
<!-- RIGHT BUTTONS -->
|
||||
|
@ -274,6 +254,7 @@
|
|||
|
||||
</LinearLayout>
|
||||
|
||||
|
||||
<include
|
||||
layout="@layout/move_marker_bottom_sheet"
|
||||
android:layout_width="match_parent"
|
||||
|
|
|
@ -603,16 +603,6 @@
|
|||
|
||||
</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>
|
||||
</FrameLayout>
|
||||
</LinearLayout>
|
||||
|
|
|
@ -17,6 +17,16 @@
|
|||
android:clickable="true"
|
||||
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
|
||||
android:id="@+id/ModesLayout"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -39,6 +39,8 @@
|
|||
<android.support.design.widget.TextInputLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/shared_string_name"
|
||||
android:importantForAutofill="noExcludeDescendants"
|
||||
android:layout_marginLeft="72dp"
|
||||
android:layout_marginRight="16dp">
|
||||
|
||||
|
@ -46,8 +48,8 @@
|
|||
android:id="@+id/poiNameEditText"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/shared_string_name"
|
||||
android:imeOptions="actionNext"
|
||||
android:importantForAutofill="noExcludeDescendants"
|
||||
android:inputType="textCapSentences"
|
||||
tools:text="@string/lorem_ipsum"/>
|
||||
|
||||
|
@ -73,6 +75,8 @@
|
|||
android:id="@+id/poiTypeTextInputLayout"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:hint="@string/poi_dialog_poi_type"
|
||||
android:importantForAutofill="noExcludeDescendants"
|
||||
android:layout_marginLeft="24dp"
|
||||
android:layout_weight="1">
|
||||
|
||||
|
@ -82,7 +86,7 @@
|
|||
android:layout_height="wrap_content"
|
||||
android:completionThreshold="1"
|
||||
android:drawableRight="@drawable/ic_action_arrow_drop_down"
|
||||
android:hint="@string/poi_dialog_poi_type"
|
||||
android:importantForAutofill="noExcludeDescendants"
|
||||
android:imeOptions="actionSend"
|
||||
android:inputType="text"
|
||||
tools:text="@string/lorem_ipsum"/>
|
||||
|
|
|
@ -180,4 +180,14 @@
|
|||
|
||||
</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>
|
|
@ -122,7 +122,7 @@
|
|||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/additional_info_row"
|
||||
android:id="@+id/additional_info_row_container"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
@ -137,7 +137,12 @@
|
|||
android:paddingBottom="3dp"
|
||||
android:paddingLeft="@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
|
||||
android:id="@+id/context_menu_line3"
|
||||
style="@style/TextAppearance.ContextMenuSubtitle"
|
||||
|
@ -194,6 +199,7 @@
|
|||
tools:textColor="?android:textColorSecondary"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
|
|
@ -231,9 +231,21 @@
|
|||
tools:src="@drawable/ic_action_test_light"/>
|
||||
</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
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
|
@ -251,36 +263,6 @@
|
|||
android:layout_width="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>
|
||||
|
||||
</LinearLayout>
|
|
@ -647,16 +647,6 @@
|
|||
|
||||
</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>
|
||||
</FrameLayout>
|
||||
|
||||
|
|
|
@ -17,6 +17,16 @@
|
|||
android:clickable="true"
|
||||
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
|
||||
android:id="@+id/ModesLayout"
|
||||
android:layout_width="fill_parent"
|
||||
|
|
|
@ -6,6 +6,48 @@
|
|||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
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
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
|
|
|
@ -111,6 +111,9 @@
|
|||
<color name="map_widget_blue">#536dfe</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="tool_bar_color_dark">#CC080B0D</color>
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
- For wording and consistency, please note http://osmand.net/help-online?id=technical-articles#Creating_a_Consistent_User_Experience
|
||||
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="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>
|
||||
|
|
|
@ -10,7 +10,10 @@ import android.content.res.Resources;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.Paint;
|
||||
import android.graphics.PointF;
|
||||
import android.graphics.drawable.ClipDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.graphics.drawable.LayerDrawable;
|
||||
import android.graphics.drawable.ShapeDrawable;
|
||||
import android.graphics.drawable.StateListDrawable;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
|
@ -31,6 +34,7 @@ import android.text.style.ImageSpan;
|
|||
import android.text.style.URLSpan;
|
||||
import android.util.DisplayMetrics;
|
||||
import android.util.TypedValue;
|
||||
import android.view.Gravity;
|
||||
import android.view.View;
|
||||
import android.view.ViewParent;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
@ -112,7 +116,11 @@ public class AndroidUtils {
|
|||
}
|
||||
|
||||
public static Uri getUriForFile(Context context, File file) {
|
||||
return FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN) {
|
||||
return Uri.fromFile(file);
|
||||
} else {
|
||||
return FileProvider.getUriForFile(context, context.getPackageName() + ".fileprovider", file);
|
||||
}
|
||||
}
|
||||
|
||||
public static Spannable replaceCharsWithIcon(String text, Drawable icon, String[] chars) {
|
||||
|
@ -251,6 +259,24 @@ public class AndroidUtils {
|
|||
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) {
|
||||
View view = snackbar.getView();
|
||||
TextView tv = (TextView) view.findViewById(android.support.design.R.id.snackbar_action);
|
||||
|
|
|
@ -13,7 +13,7 @@ import android.content.res.Configuration;
|
|||
import android.content.res.Resources;
|
||||
import android.os.Build;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import android.util.Log;
|
||||
import net.osmand.IProgress;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.PlatformUtil;
|
||||
|
@ -67,7 +67,6 @@ import java.util.Locale;
|
|||
import java.util.Random;
|
||||
|
||||
import btools.routingapp.BRouterServiceConnection;
|
||||
|
||||
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent;
|
||||
import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck;
|
||||
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();
|
||||
appVersionChanged = true;
|
||||
}
|
||||
app.getSettings().SHOW_TRAVEL_UPDATE_CARD.set(true);
|
||||
app.getSettings().SHOW_TRAVEL_NEEDED_MAPS_CARD.set(true);
|
||||
initSettings = true;
|
||||
}
|
||||
|
||||
|
@ -352,7 +353,8 @@ public class AppInitializer implements IProgress {
|
|||
Integer in = (Integer) f.get(null);
|
||||
return app.getString(in);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (Throwable e) {
|
||||
LOG.info("No translation: " + keyName);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -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$
|
||||
FAVOURITE_TABLE_NAME, null);
|
||||
cachedFavoritePoints.clear();
|
||||
if (query.moveToFirst()) {
|
||||
if (query != null && query.moveToFirst()) {
|
||||
do {
|
||||
String name = query.getString(0);
|
||||
String cat = query.getString(1);
|
||||
|
@ -748,7 +748,9 @@ public class FavouritesDbHelper {
|
|||
}
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
query.close();
|
||||
if (query != null) {
|
||||
query.close();
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
|
|
@ -523,12 +523,14 @@ public class GPXDatabase {
|
|||
if (db != null) {
|
||||
try {
|
||||
SQLiteCursor query = db.rawQuery(GPX_TABLE_SELECT, null);
|
||||
if (query.moveToFirst()) {
|
||||
if (query != null && query.moveToFirst()) {
|
||||
do {
|
||||
items.add(readItem(query));
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
query.close();
|
||||
if (query != null) {
|
||||
query.close();
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
@ -546,10 +548,12 @@ public class GPXDatabase {
|
|||
String fileDir = getFileDir(file);
|
||||
SQLiteCursor query = db.rawQuery(GPX_TABLE_SELECT + " WHERE " + GPX_COL_NAME + " = ? AND " +
|
||||
GPX_COL_DIR + " = ?", new String[] { fileName, fileDir });
|
||||
if (query.moveToFirst()) {
|
||||
if ( query != null && query.moveToFirst()) {
|
||||
result = readItem(query);
|
||||
}
|
||||
query.close();
|
||||
if (query != null) {
|
||||
query.close();
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
|
|
@ -6,6 +6,7 @@ import android.graphics.Canvas;
|
|||
import android.graphics.Color;
|
||||
import android.graphics.Paint;
|
||||
import android.support.annotation.ColorInt;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
|
||||
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 float totalDistance = 0;
|
||||
public int totalTracks = 0;
|
||||
|
@ -779,6 +794,7 @@ public class GPXUtilities {
|
|||
|
||||
public static class GPXFile extends GPXExtensions {
|
||||
public String author;
|
||||
public Metadata metadata;
|
||||
public List<Track> tracks = new ArrayList<>();
|
||||
private List<WptPt> points = 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) {
|
||||
Writer output = null;
|
||||
try {
|
||||
fout.getParentFile().mkdirs();
|
||||
if(fout.getParentFile() != null) {
|
||||
fout.getParentFile().mkdirs();
|
||||
}
|
||||
output = new OutputStreamWriter(new FileOutputStream(fout), "UTF-8"); //$NON-NLS-1$
|
||||
String msg = writeGpx(output, file, ctx);
|
||||
if(Algorithms.isEmpty(file.path)) {
|
||||
|
@ -1272,6 +1290,13 @@ public class GPXUtilities {
|
|||
serializer.attribute(null, "xsi:schemaLocation",
|
||||
"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) {
|
||||
if (!track.generalTrack) {
|
||||
serializer.startTag(null, "trk"); //$NON-NLS-1$
|
||||
|
@ -1448,8 +1473,8 @@ public class GPXUtilities {
|
|||
formatMillis.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
try {
|
||||
XmlPullParser parser = PlatformUtil.newXMLPullParser();
|
||||
parser.setInput(getUTF8Reader(f)); //$NON-NLS-1$
|
||||
Stack<GPXExtensions> parserState = new Stack<GPXExtensions>();
|
||||
parser.setInput(getUTF8Reader(f));
|
||||
Stack<GPXExtensions> parserState = new Stack<>();
|
||||
boolean extensionReadMode = false;
|
||||
parserState.push(res);
|
||||
int tok;
|
||||
|
@ -1473,55 +1498,64 @@ public class GPXUtilities {
|
|||
extensionReadMode = true;
|
||||
} else {
|
||||
if (parse instanceof GPXFile) {
|
||||
if (parser.getName().equals("gpx")) {
|
||||
if (tag.equals("gpx")) {
|
||||
((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();
|
||||
((GPXFile) parse).tracks.add(track);
|
||||
parserState.push(track);
|
||||
}
|
||||
if (parser.getName().equals("rte")) {
|
||||
if (tag.equals("rte")) {
|
||||
Route route = new Route();
|
||||
((GPXFile) parse).routes.add(route);
|
||||
parserState.push(route);
|
||||
}
|
||||
if (parser.getName().equals("wpt")) {
|
||||
if (tag.equals("wpt")) {
|
||||
WptPt wptPt = parseWptAttributes(parser);
|
||||
((GPXFile) parse).points.add(wptPt);
|
||||
parserState.push(wptPt);
|
||||
}
|
||||
} else if (parse instanceof Metadata) {
|
||||
if (tag.equals("desc")) {
|
||||
((Metadata) parse).desc = readText(parser, "desc");
|
||||
}
|
||||
} else if (parse instanceof Route) {
|
||||
if (parser.getName().equals("name")) {
|
||||
if (tag.equals("name")) {
|
||||
((Route) parse).name = readText(parser, "name");
|
||||
}
|
||||
if (parser.getName().equals("desc")) {
|
||||
if (tag.equals("desc")) {
|
||||
((Route) parse).desc = readText(parser, "desc");
|
||||
}
|
||||
if (parser.getName().equals("rtept")) {
|
||||
if (tag.equals("rtept")) {
|
||||
WptPt wptPt = parseWptAttributes(parser);
|
||||
((Route) parse).points.add(wptPt);
|
||||
parserState.push(wptPt);
|
||||
}
|
||||
} else if (parse instanceof Track) {
|
||||
if (parser.getName().equals("name")) {
|
||||
if (tag.equals("name")) {
|
||||
((Track) parse).name = readText(parser, "name");
|
||||
}
|
||||
if (parser.getName().equals("desc")) {
|
||||
if (tag.equals("desc")) {
|
||||
((Track) parse).desc = readText(parser, "desc");
|
||||
}
|
||||
if (parser.getName().equals("trkseg")) {
|
||||
if (tag.equals("trkseg")) {
|
||||
TrkSegment trkSeg = new TrkSegment();
|
||||
((Track) parse).segments.add(trkSeg);
|
||||
parserState.push(trkSeg);
|
||||
}
|
||||
} else if (parse instanceof TrkSegment) {
|
||||
if (parser.getName().equals("trkpt")) {
|
||||
if (tag.equals("trkpt")) {
|
||||
WptPt wptPt = parseWptAttributes(parser);
|
||||
((TrkSegment) parse).points.add(wptPt);
|
||||
parserState.push(wptPt);
|
||||
}
|
||||
if (parser.getName().equals("csvattributes")) {
|
||||
if (tag.equals("csvattributes")) {
|
||||
String segmentPoints = readText(parser, "csvattributes");
|
||||
String[] pointsArr = segmentPoints.split("\n");
|
||||
for (int i = 0; i < pointsArr.length; i++) {
|
||||
|
@ -1543,20 +1577,20 @@ public class GPXUtilities {
|
|||
}
|
||||
// main object to parse
|
||||
} else if (parse instanceof WptPt) {
|
||||
if (parser.getName().equals("name")) {
|
||||
if (tag.equals("name")) {
|
||||
((WptPt) parse).name = readText(parser, "name");
|
||||
} else if (parser.getName().equals("desc")) {
|
||||
} else if (tag.equals("desc")) {
|
||||
((WptPt) parse).desc = readText(parser, "desc");
|
||||
} else if (parser.getName().equals("cmt")) {
|
||||
} else if (tag.equals("cmt")) {
|
||||
((WptPt) parse).comment = readText(parser, "cmt");
|
||||
} else if (parser.getName().equals("speed")) {
|
||||
} else if (tag.equals("speed")) {
|
||||
try {
|
||||
String value = readText(parser, "speed");
|
||||
((WptPt) parse).speed = Float.parseFloat(value);
|
||||
((WptPt) parse).getExtensionsToWrite().put("speed", value);
|
||||
} catch (NumberFormatException e) {
|
||||
}
|
||||
} else if (parser.getName().equals("link")) {
|
||||
} else if (tag.equals("link")) {
|
||||
((WptPt) parse).link = parser.getAttributeValue("", "href");
|
||||
} else if (tag.equals("category")) {
|
||||
((WptPt) parse).category = readText(parser, "category");
|
||||
|
@ -1564,7 +1598,7 @@ public class GPXUtilities {
|
|||
if (((WptPt) parse).category == null) {
|
||||
((WptPt) parse).category = readText(parser, "type");
|
||||
}
|
||||
} else if (parser.getName().equals("ele")) {
|
||||
} else if (tag.equals("ele")) {
|
||||
String text = readText(parser, "ele");
|
||||
if (text != null) {
|
||||
try {
|
||||
|
@ -1572,7 +1606,7 @@ public class GPXUtilities {
|
|||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
} else if (parser.getName().equals("hdop")) {
|
||||
} else if (tag.equals("hdop")) {
|
||||
String text = readText(parser, "hdop");
|
||||
if (text != null) {
|
||||
try {
|
||||
|
@ -1580,7 +1614,7 @@ public class GPXUtilities {
|
|||
} catch (NumberFormatException e) {
|
||||
}
|
||||
}
|
||||
} else if (parser.getName().equals("time")) {
|
||||
} else if (tag.equals("time")) {
|
||||
String text = readText(parser, "time");
|
||||
if (text != null) {
|
||||
try {
|
||||
|
@ -1604,7 +1638,10 @@ public class GPXUtilities {
|
|||
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();
|
||||
assert pop instanceof WptPt;
|
||||
} 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) {
|
||||
log.error("Error reading gpx", e); //$NON-NLS-1$
|
||||
res.warning = ctx.getString(R.string.error_reading_gpx) + " " + e.getMessage();
|
||||
|
|
|
@ -244,7 +244,10 @@ public class GpxSelectionHelper {
|
|||
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();
|
||||
String timeSpanClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_time_span_color));
|
||||
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 distanceClr = Algorithms.colorToString(ContextCompat.getColor(app, R.color.gpx_distance_color));
|
||||
final float eleThreshold = 3;
|
||||
// int t = 1;
|
||||
for (TrkSegment r : group.track.segments) {
|
||||
if (r.points.size() == 0) {
|
||||
continue;
|
||||
|
|
|
@ -46,7 +46,7 @@ public class NavigationService extends Service implements LocationListener {
|
|||
|
||||
private static WakeLock lockStatic;
|
||||
private PendingIntent pendingIntent;
|
||||
|
||||
|
||||
protected int usedBy = 0;
|
||||
private OsmAndLocationProvider locationProvider;
|
||||
|
||||
|
@ -74,7 +74,7 @@ public class NavigationService extends Service implements LocationListener {
|
|||
public int getServiceOffInterval() {
|
||||
return serviceOffInterval;
|
||||
}
|
||||
|
||||
|
||||
public int getUsedBy() {
|
||||
return usedBy;
|
||||
}
|
||||
|
@ -165,14 +165,11 @@ public class NavigationService extends Service implements LocationListener {
|
|||
// registering icon at top level
|
||||
// Leave icon visible even for navigation for proper display
|
||||
Notification notification = app.getNotificationHelper().buildTopNotification();
|
||||
if (notification != null) {
|
||||
startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification);
|
||||
app.getNotificationHelper().refreshNotifications();
|
||||
}
|
||||
startForeground(OsmandNotification.TOP_NOTIFICATION_SERVICE_ID, notification);
|
||||
app.getNotificationHelper().refreshNotifications();
|
||||
return START_REDELIVER_INTENT;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
|
|
|
@ -3,15 +3,19 @@ package net.osmand.plus;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.osmand.plus.notifications.ErrorNotification;
|
||||
import net.osmand.plus.notifications.GpxNotification;
|
||||
import net.osmand.plus.notifications.NavigationNotification;
|
||||
import net.osmand.plus.notifications.OsmandNotification;
|
||||
import net.osmand.plus.notifications.OsmandNotification.NotificationType;
|
||||
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
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.NotificationManagerCompat;
|
||||
|
||||
|
@ -22,6 +26,7 @@ public class NotificationHelper {
|
|||
|
||||
private NavigationNotification navigationNotification;
|
||||
private GpxNotification gpxNotification;
|
||||
private ErrorNotification errorNotification;
|
||||
private List<OsmandNotification> all = new ArrayList<>();
|
||||
|
||||
public NotificationHelper(OsmandApplication app) {
|
||||
|
@ -32,29 +37,43 @@ public class NotificationHelper {
|
|||
private void init() {
|
||||
navigationNotification = new NavigationNotification(app);
|
||||
gpxNotification = new GpxNotification(app);
|
||||
errorNotification = new ErrorNotification(app);
|
||||
all.add(navigationNotification);
|
||||
all.add(gpxNotification);
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public Notification buildTopNotification() {
|
||||
OsmandNotification notification = acquireTopNotification();
|
||||
if (notification != null) {
|
||||
removeNotification(notification.getType());
|
||||
setTopNotification(notification);
|
||||
Builder notificationBuilder = notification.buildNotification(false);
|
||||
return notificationBuilder.build();
|
||||
if (notificationBuilder != null) {
|
||||
return notificationBuilder.build();
|
||||
} else {
|
||||
return buildErrorNotification();
|
||||
}
|
||||
} else {
|
||||
return buildErrorNotification();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private Notification buildErrorNotification() {
|
||||
removeNotification(errorNotification.getType());
|
||||
setTopNotification(errorNotification);
|
||||
return errorNotification.buildNotification(false).build();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private OsmandNotification acquireTopNotification() {
|
||||
OsmandNotification notification = null;
|
||||
if (navigationNotification.isEnabled()) {
|
||||
notification = navigationNotification;
|
||||
return navigationNotification;
|
||||
} else if (gpxNotification.isEnabled() && gpxNotification.isActive()) {
|
||||
notification = gpxNotification;
|
||||
return gpxNotification;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return notification;
|
||||
}
|
||||
|
||||
public void updateTopNotification() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.Arrays;
|
|||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
import net.osmand.GeoidAltitudeCorrection;
|
||||
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 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 STALE_LOCATION_TIMEOUT_FOR_UI = 1000 * 60 * 15; // 15 minutes
|
||||
private static final long LOCATION_TIMEOUT_TO_BE_STALE = 1000 * 60 * 2; // 2 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 int locationRequestsCounter;
|
||||
private int staleLocationRequestsCounter;
|
||||
private AtomicInteger locationRequestsCounter = new AtomicInteger();
|
||||
private AtomicInteger staleLocationRequestsCounter = new AtomicInteger();
|
||||
|
||||
|
||||
private net.osmand.Location cachedLocation;
|
||||
|
||||
private long lastTimeGPSLocationFixed = 0;
|
||||
private long lastTimeLocationFixed = 0;
|
||||
private boolean gpsSignalLost;
|
||||
private SimulationProvider simulatePosition = null;
|
||||
|
||||
private long cachedLocationTimeFix = 0;
|
||||
private net.osmand.Location cachedLocation;
|
||||
|
||||
private boolean sensorRegistered = false;
|
||||
private float[] mGravs = new float[3];
|
||||
private float[] mGeoMags = new float[3];
|
||||
|
@ -584,7 +589,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
@Override
|
||||
public void onLocationChanged(Location location) {
|
||||
if (location != null) {
|
||||
lastTimeGPSLocationFixed = location.getTime();
|
||||
// lastTimeGPSLocationFixed = location.getTime();
|
||||
lastTimeGPSLocationFixed = System.currentTimeMillis();
|
||||
}
|
||||
if(!locationSimulation.isRouteAnimating()) {
|
||||
setLocation(convertLocation(location, app));
|
||||
|
@ -690,7 +696,8 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
|
||||
private void scheduleCheckIfGpsLost(final net.osmand.Location location) {
|
||||
final RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (location != null) {
|
||||
if (location != null && routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0
|
||||
&& simulatePosition == null) {
|
||||
final long fixTime = location.getTime();
|
||||
app.runMessageInUIThreadAndCancelPrevious(LOST_LOCATION_MSG_ID, new Runnable() {
|
||||
|
||||
|
@ -702,31 +709,30 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
return;
|
||||
}
|
||||
gpsSignalLost = true;
|
||||
if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0) {
|
||||
if (routingHelper.isFollowingMode() && routingHelper.getLeftDistance() > 0
|
||||
&& simulatePosition == null) {
|
||||
routingHelper.getVoiceRouter().gpsLocationLost();
|
||||
setLocation(null);
|
||||
}
|
||||
setLocation(null);
|
||||
}
|
||||
}, 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
|
||||
public void run() {
|
||||
net.osmand.Location lastKnown = getLastKnownLocation();
|
||||
if (lastKnown != null && lastKnown.getTime() > fixTime) {
|
||||
// false positive case, still strange how we got here with removeMessages
|
||||
return;
|
||||
}
|
||||
List<RouteSegmentResult> tunnel = routingHelper.getUpcomingTunnel(1000);
|
||||
if(tunnel != null) {
|
||||
simulatePosition = new SimulationProvider();
|
||||
simulatePosition.startSimulation(tunnel, location);
|
||||
simulatePositionImpl();
|
||||
}
|
||||
@Override
|
||||
public void run() {
|
||||
net.osmand.Location lastKnown = getLastKnownLocation();
|
||||
if (lastKnown != null && lastKnown.getTime() > fixTime) {
|
||||
// false positive case, still strange how we got here with removeMessages
|
||||
return;
|
||||
}
|
||||
}, START_LOCATION_SIMULATION_DELAY);
|
||||
}
|
||||
List<RouteSegmentResult> tunnel = routingHelper.getUpcomingTunnel(1000);
|
||||
if(tunnel != null) {
|
||||
simulatePosition = new SimulationProvider();
|
||||
simulatePosition.startSimulation(tunnel, location);
|
||||
simulatePositionImpl();
|
||||
}
|
||||
}
|
||||
}, START_LOCATION_SIMULATION_DELAY);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -772,7 +778,10 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
if(location == null){
|
||||
updateGPSInfo(null);
|
||||
}
|
||||
|
||||
if(location != null) {
|
||||
// // use because there is a bug on some devices with location.getTime()
|
||||
lastTimeLocationFixed = System.currentTimeMillis();
|
||||
simulatePosition = null;
|
||||
if(gpsSignalLost) {
|
||||
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() {
|
||||
return navigationInfo;
|
||||
|
@ -869,15 +872,14 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
}
|
||||
|
||||
public net.osmand.Location getLastKnownLocation() {
|
||||
net.osmand.Location location = this.location;
|
||||
if (location != null && locationRequestsCounter == 0
|
||||
&& System.currentTimeMillis() - location.getTime() > STALE_LOCATION_TIMEOUT) {
|
||||
location = null;
|
||||
}
|
||||
if (locationRequestsCounter == REQUESTS_BEFORE_CHECK_LOCATION) {
|
||||
locationRequestsCounter = 0;
|
||||
} else {
|
||||
locationRequestsCounter++;
|
||||
net.osmand.Location loc = this.location;
|
||||
if (loc != null) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
return location;
|
||||
}
|
||||
|
@ -885,18 +887,17 @@ public class OsmAndLocationProvider implements SensorEventListener {
|
|||
@Nullable
|
||||
public net.osmand.Location getLastStaleKnownLocation() {
|
||||
net.osmand.Location newLoc = getLastKnownLocation();
|
||||
if (newLoc == null) {
|
||||
if (staleLocationRequestsCounter == 0 && cachedLocation != null
|
||||
&& System.currentTimeMillis() - cachedLocation.getTime() > STALE_LOCATION_TIMEOUT_FOR_UI) {
|
||||
cachedLocation = null;
|
||||
if (newLoc == null && cachedLocation != null) {
|
||||
int counter = staleLocationRequestsCounter.incrementAndGet();
|
||||
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;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
cachedLocation = newLoc;
|
||||
}
|
||||
if (staleLocationRequestsCounter == REQUESTS_BEFORE_CHECK_LOCATION) {
|
||||
staleLocationRequestsCounter = 0;
|
||||
} else {
|
||||
staleLocationRequestsCounter++;
|
||||
cachedLocationTimeFix = lastTimeLocationFixed;
|
||||
}
|
||||
return cachedLocation;
|
||||
}
|
||||
|
|
|
@ -3006,6 +3006,9 @@ public class OsmandSettings {
|
|||
|
||||
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 =
|
||||
(ListStringPreference) new ListStringPreference("transport_default_settings", "transportStops", ",").makeProfile();
|
||||
|
||||
|
|
|
@ -238,7 +238,7 @@ public class FavoritesListFragment extends OsmAndListFragment implements SearchA
|
|||
|
||||
icon.setImageDrawable(FavoriteImageDrawable.getOrCreate(activity, favorite.getColor(), false));
|
||||
DashLocationFragment.updateLocationView(!searchAroundLocation, location, heading, direction, distanceText,
|
||||
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app, activity);
|
||||
favorite.getLatitude(), favorite.getLongitude(), screenOrientation, app);
|
||||
|
||||
name.setText(getName(favorite));
|
||||
final CheckBox ch = (CheckBox) row.findViewById(R.id.toggle_item);
|
||||
|
|
|
@ -93,7 +93,6 @@ import net.osmand.plus.helpers.ExternalApiHelper;
|
|||
import net.osmand.plus.helpers.ImportHelper;
|
||||
import net.osmand.plus.helpers.ImportHelper.ImportGpxBottomSheetDialogFragment;
|
||||
import net.osmand.plus.helpers.WakeLockHelper;
|
||||
import net.osmand.plus.inapp.InAppPurchaseHelper;
|
||||
import net.osmand.plus.mapcontextmenu.AdditionalActionsBottomSheetDialogFragment;
|
||||
import net.osmand.plus.mapcontextmenu.MapContextMenu;
|
||||
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);
|
||||
createProgressBarForRouting();
|
||||
mapLayers.createLayers(mapView);
|
||||
createProgressBarForRouting();
|
||||
updateStatusBarColor();
|
||||
// This situtation could be when navigation suddenly crashed and after restarting
|
||||
// it tries to continue the last route
|
||||
|
@ -434,12 +433,26 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
|
||||
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
|
||||
public void updateProgress(int progress) {
|
||||
mapLayers.getMapControlsLayer().getMapRouteInfoMenu().updateRouteCalculationProgress(progress);
|
||||
if (findViewById(R.id.MapHudButtonsOverlay).getVisibility() == View.VISIBLE) {
|
||||
if (pbExtView.getVisibility() == View.VISIBLE) {
|
||||
pbExtView.setVisibility(View.GONE);
|
||||
}
|
||||
if (MapRouteInfoMenu.isVisible()) {
|
||||
pb.setVisibility(View.GONE);
|
||||
return;
|
||||
}
|
||||
if (pb.getVisibility() == View.GONE) {
|
||||
pb.setVisibility(View.VISIBLE);
|
||||
}
|
||||
|
@ -492,6 +505,7 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
|
||||
@Override
|
||||
public void finish() {
|
||||
mapLayers.getMapControlsLayer().getMapRouteInfoMenu().routeCalculationFinished();
|
||||
pbExtView.setVisibility(View.GONE);
|
||||
pb.setVisibility(View.GONE);
|
||||
}
|
||||
|
@ -641,7 +655,6 @@ public class MapActivity extends OsmandActionBarActivity implements DownloadEven
|
|||
getSupportActionBar().hide();
|
||||
}
|
||||
|
||||
app.getLocationProvider().checkIfLastKnownLocationIsValid();
|
||||
// for voice navigation
|
||||
ApplicationMode routingAppMode = getRoutingHelper().getAppMode();
|
||||
if (routingAppMode != null && settings.AUDIO_STREAM_GUIDANCE.getModeValue(routingAppMode) != null) {
|
||||
|
|
|
@ -568,6 +568,10 @@ public class MapActivityLayers {
|
|||
return activity.getString(resId);
|
||||
}
|
||||
|
||||
public RouteLayer getRouteLayer() {
|
||||
return routeLayer;
|
||||
}
|
||||
|
||||
public PointNavigationLayer getNavigationLayer() {
|
||||
return navigationLayer;
|
||||
}
|
||||
|
|
|
@ -19,8 +19,7 @@ public class OsmandActionBarActivity extends OsmandInAppPurchaseActivity {
|
|||
|
||||
//should be called after set content view
|
||||
protected void setupHomeButton(){
|
||||
Drawable back = ((OsmandApplication)getApplication()).getIconsCache().getIcon(R.drawable.ic_arrow_back);
|
||||
back.setColorFilter(ContextCompat.getColor(this, R.color.color_white), PorterDuff.Mode.MULTIPLY);
|
||||
Drawable back = ((OsmandApplication)getApplication()).getIconsCache().getIcon(R.drawable.ic_arrow_back, R.color.color_white);
|
||||
final ActionBar supportActionBar = getSupportActionBar();
|
||||
if (supportActionBar != null) {
|
||||
supportActionBar.setHomeButtonEnabled(true);
|
||||
|
|
|
@ -34,6 +34,7 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.measurementtool.NewGpxData;
|
||||
import net.osmand.plus.myplaces.FavoritesActivity;
|
||||
import net.osmand.plus.myplaces.SplitSegmentDialogFragment;
|
||||
import net.osmand.plus.myplaces.TrackActivityFragmentAdapter;
|
||||
import net.osmand.plus.myplaces.TrackBitmapDrawer;
|
||||
import net.osmand.plus.myplaces.TrackBitmapDrawer.TrackBitmapDrawerListener;
|
||||
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_TRACKS_LIST = "OPEN_TRACKS_LIST";
|
||||
public static final String CURRENT_RECORDING = "CURRENT_RECORDING";
|
||||
public static final String SHOW_TEMPORARILY = "SHOW_TEMPORARILY";
|
||||
protected List<WeakReference<Fragment>> fragList = new ArrayList<>();
|
||||
private OsmandApplication app;
|
||||
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
|
||||
public void onBackPressed() {
|
||||
if (openTracksList) {
|
||||
|
@ -440,6 +455,7 @@ public class TrackActivity extends TabActivity {
|
|||
private OsmandApplication app;
|
||||
private WeakReference<TrackActivity> activityRef;
|
||||
private File file;
|
||||
private boolean showTemporarily;
|
||||
|
||||
private TrackActivity getTrackActivity() {
|
||||
return activityRef.get();
|
||||
|
@ -455,6 +471,11 @@ public class TrackActivity extends TabActivity {
|
|||
TrackActivity activity = getTrackActivity();
|
||||
if (activity != null) {
|
||||
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();
|
||||
if (activity != null) {
|
||||
activity.setSupportProgressBarIndeterminateVisibility(false);
|
||||
|
||||
if (showTemporarily && result != null) {
|
||||
app.getSelectedGpxHelper().selectGpxFile(result, false, false);
|
||||
}
|
||||
if (!activity.stopped) {
|
||||
activity.onGPXFileReady(result);
|
||||
}
|
||||
|
|
|
@ -242,7 +242,7 @@ public class SearchHistoryFragment extends OsmAndListFragment implements SearchA
|
|||
TextView distanceText = (TextView) row.findViewById(R.id.distance);
|
||||
ImageView direction = (ImageView) row.findViewById(R.id.direction);
|
||||
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);
|
||||
options.setImageDrawable(getMyApplication().getIconsCache().getThemedIcon(R.drawable.ic_overflow_menu_white));
|
||||
options.setVisibility(View.VISIBLE);
|
||||
|
|
|
@ -785,7 +785,7 @@ public class SearchPOIActivity extends OsmandListActivity implements OsmAndCompa
|
|||
if (dd instanceof DirectionDrawable) {
|
||||
draw = (DirectionDrawable) dd;
|
||||
} else {
|
||||
draw = new DirectionDrawable(SearchPOIActivity.this, 24, 24,
|
||||
draw = new DirectionDrawable(getMyApplication(), 24, 24,
|
||||
R.drawable.ic_direction_arrow, R.color.color_distance);
|
||||
direction.setImageDrawable(draw);
|
||||
}
|
||||
|
|
|
@ -1,15 +1,19 @@
|
|||
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.content.Context;
|
||||
import android.database.Cursor;
|
||||
import android.database.sqlite.SQLiteDatabase;
|
||||
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
|
||||
public class SQLiteAPIImpl implements SQLiteAPI {
|
||||
|
||||
private OsmandApplication app;
|
||||
private static final Log LOG = PlatformUtil.getLog(SQLiteAPIImpl.class);
|
||||
|
||||
public SQLiteAPIImpl(OsmandApplication app) {
|
||||
this.app = app;
|
||||
|
@ -18,9 +22,13 @@ public class SQLiteAPIImpl implements SQLiteAPI {
|
|||
@SuppressLint("InlinedApi")
|
||||
@Override
|
||||
public SQLiteConnection getOrCreateDatabase(String name, boolean readOnly) {
|
||||
android.database.sqlite.SQLiteDatabase db = app.openOrCreateDatabase(name,
|
||||
Context.MODE_PRIVATE |
|
||||
(readOnly ? 0 : Context.MODE_ENABLE_WRITE_AHEAD_LOGGING), null);
|
||||
android.database.sqlite.SQLiteDatabase db = null;
|
||||
try {
|
||||
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) {
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@ package net.osmand.plus.audionotes;
|
|||
import android.Manifest;
|
||||
import android.annotation.TargetApi;
|
||||
import android.app.Activity;
|
||||
import android.content.ClipData;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
|
@ -828,6 +829,9 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
public void captureImage(double lat, double lon, final MapActivity mapActivity) {
|
||||
Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
|
||||
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.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
// start the image capture Intent
|
||||
|
@ -842,8 +846,11 @@ public class AudioVideoNotesPlugin extends OsmandPlugin {
|
|||
// ext = THREEGP_EXTENSION;
|
||||
// }
|
||||
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.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
|
||||
// start the video capture Intent
|
||||
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) {
|
||||
if (AV_EXTERNAL_RECORDER.get() || forceExternal) {
|
||||
captureVideoExternal(lat, lon, mapActivity);
|
||||
} else {
|
||||
if (ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.CAMERA)
|
||||
== PackageManager.PERMISSION_GRANTED
|
||||
&& ActivityCompat.checkSelfPermission(mapActivity, Manifest.permission.RECORD_AUDIO)
|
||||
== PackageManager.PERMISSION_GRANTED) {
|
||||
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) {
|
||||
captureVideoExternal(lat, lon, mapActivity);
|
||||
} else {
|
||||
openCamera();
|
||||
if (cam != null) {
|
||||
initRecMenu(AVActionType.REC_VIDEO, lat, lon);
|
||||
recordVideoCamera(lat, lon, mapActivity);
|
||||
}
|
||||
} else {
|
||||
actionLat = lat;
|
||||
actionLon = lon;
|
||||
ActivityCompat.requestPermissions(mapActivity,
|
||||
new String[]{Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO},
|
||||
CAMERA_FOR_VIDEO_REQUEST_CODE);
|
||||
}
|
||||
} else {
|
||||
actionLat = lat;
|
||||
actionLon = lon;
|
||||
ActivityCompat.requestPermissions(mapActivity, new String[] { Manifest.permission.CAMERA,
|
||||
Manifest.permission.RECORD_AUDIO }, CAMERA_FOR_VIDEO_REQUEST_CODE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
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);
|
||||
final File f = getBaseFileName(lat, lon, app, IMG_EXTENSION);
|
||||
lastTakingPhoto = f;
|
||||
takePictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, AndroidUtils.getUriForFile(mapActivity,f));
|
||||
takePictureIntent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
|
||||
Uri uri = AndroidUtils.getUriForFile(mapActivity, f);
|
||||
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 {
|
||||
mapActivity.startActivityForResult(takePictureIntent, 205);
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -32,7 +32,6 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
private static final int ORIENTATION_180 = 2;
|
||||
protected List<DashLocationView> distances = new ArrayList<DashLocationFragment.DashLocationView>();
|
||||
private int screenOrientation;
|
||||
protected LatLon lastUpdatedLocation;
|
||||
|
||||
public static class DashLocationView {
|
||||
public ImageView arrow;
|
||||
|
@ -98,50 +97,61 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
float head = d.getHeading();
|
||||
float mapRotation = d.getMapRotation();
|
||||
LatLon mw = d.getMapViewLocation();
|
||||
Location l = d.getMyLocation();
|
||||
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);
|
||||
boolean useCenter = !d.isMapLinkedToLocation();
|
||||
float h = useCenter ? -mapRotation : head;
|
||||
lastUpdatedLocation = loc;
|
||||
for (DashLocationView lv : distances) {
|
||||
updateLocationView(useCenter, loc, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc, screenOrientation,
|
||||
getMyApplication(), getActivity(), lv.paint);
|
||||
updateLocationView(useCenter, mw, h, lv.arrow, lv.arrowResId, lv.txt, lv.loc, screenOrientation,
|
||||
getMyApplication(), lv.paint);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
ImageView arrow, int imgColor, TextView txt, int textColor, double toLat, double toLon,
|
||||
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,
|
||||
ImageView arrow, TextView txt, double toLat, double toLon,
|
||||
int screenOrientation, OsmandApplication app, Context ctx) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, new LatLon(toLat, toLon), screenOrientation, app, ctx, true);
|
||||
int screenOrientation, OsmandApplication app) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, 0, txt, new LatLon(toLat, toLon), screenOrientation, app, true);
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
ImageView arrow, int arrowResId, TextView txt, LatLon toLoc,
|
||||
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, ctx, paint);
|
||||
int screenOrientation, OsmandApplication app, boolean paint) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, 0, txt, 0, toLoc, screenOrientation, app, paint);
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
ImageView arrow, int arrowResId, int imgColor, TextView txt, LatLon toLoc,
|
||||
int screenOrientation, OsmandApplication app, Context ctx, boolean paint) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, ctx, paint);
|
||||
int screenOrientation, OsmandApplication app, boolean paint) {
|
||||
updateLocationView(useCenter, fromLoc, h, arrow, arrowResId, imgColor, txt, 0, toLoc, screenOrientation, app, paint);
|
||||
}
|
||||
|
||||
public static void updateLocationView(boolean useCenter, LatLon fromLoc, Float h,
|
||||
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];
|
||||
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) {
|
||||
Location.distanceBetween(toLoc.getLatitude(), toLoc.getLongitude(), fromLoc.getLatitude(), fromLoc.getLongitude(), mes);
|
||||
}
|
||||
|
||||
|
||||
if (arrow != null) {
|
||||
boolean newImage = false;
|
||||
if (arrowResId == 0) {
|
||||
|
@ -150,11 +160,18 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
DirectionDrawable dd;
|
||||
if(!(arrow.getDrawable() instanceof DirectionDrawable)) {
|
||||
newImage = true;
|
||||
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight());
|
||||
dd = new DirectionDrawable(app, arrow.getWidth(), arrow.getHeight());
|
||||
} else {
|
||||
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) {
|
||||
dd.setAngle(0);
|
||||
} else {
|
||||
|
@ -168,8 +185,14 @@ public abstract class DashLocationFragment extends DashBaseFragment {
|
|||
if (txt != null) {
|
||||
if (fromLoc != null && toLoc != null) {
|
||||
if (paint) {
|
||||
txt.setTextColor(app.getResources().getColor(
|
||||
textColor == 0 ? useCenter ? R.color.color_distance : R.color.color_myloc_distance : textColor));
|
||||
int textColorSet = 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));
|
||||
} else {
|
||||
|
|
|
@ -149,7 +149,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
private ApplicationMode previousAppMode;
|
||||
private boolean landscape;
|
||||
private List<WeakReference<DashBaseFragment>> fragList = new LinkedList<>();
|
||||
private net.osmand.Location myLocation;
|
||||
private LatLon mapViewLocation;
|
||||
private float heading;
|
||||
private boolean mapLinkedToLocation;
|
||||
|
@ -621,10 +620,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
}
|
||||
}
|
||||
|
||||
public net.osmand.Location getMyLocation() {
|
||||
return myLocation;
|
||||
}
|
||||
|
||||
public LatLon getMapViewLocation() {
|
||||
return mapViewLocation;
|
||||
}
|
||||
|
@ -716,7 +711,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
mapViewLocation = mapActivity.getMapLocation();
|
||||
mapRotation = mapActivity.getMapRotate();
|
||||
mapLinkedToLocation = mapActivity.getMapViewTrackingUtilities().isMapLinkedToLocation();
|
||||
myLocation = mapActivity.getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
mapActivity.getMapViewTrackingUtilities().setDashboard(this);
|
||||
mapActivity.disableDrawer();
|
||||
dashboardView.setVisibility(View.VISIBLE);
|
||||
|
@ -1218,7 +1212,6 @@ public class DashboardOnMap implements ObservableScrollViewCallbacks, DynamicLis
|
|||
}
|
||||
|
||||
public void updateMyLocation(net.osmand.Location location) {
|
||||
myLocation = location;
|
||||
updateLocation(false, true, false);
|
||||
}
|
||||
|
||||
|
|
|
@ -67,10 +67,16 @@ public class SelectMapStyleBottomSheetDialogFragment extends MenuBottomSheetDial
|
|||
|
||||
stylesMap = generateStylesMap(context);
|
||||
if (savedInstanceState == null) {
|
||||
selectedStyle = getMyApplication().getRendererRegistry().getCurrentSelectedRenderer().getName();
|
||||
RenderingRulesStorage current = getMyApplication().getRendererRegistry().getCurrentSelectedRenderer();
|
||||
if (current != null) {
|
||||
selectedStyle = current.getName();
|
||||
}
|
||||
} else {
|
||||
selectedStyle = savedInstanceState.getString(SELECTED_STYLE_KEY);
|
||||
}
|
||||
if(selectedStyle == null) {
|
||||
selectedStyle = RendererRegistry.DEFAULT_RENDER;
|
||||
}
|
||||
|
||||
rbColorList = AndroidUtils.createCheckedColorStateList(context, R.color.icon_color, getActiveColorId());
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -173,11 +173,18 @@ public class DownloadResources extends DownloadResourceGroup {
|
|||
if ((item.getType() == DownloadActivityType.NORMAL_FILE && !item.extra)
|
||||
|| item.getType() == DownloadActivityType.ROADS_FILE
|
||||
|| item.getType() == DownloadActivityType.WIKIPEDIA_FILE
|
||||
|| item.getType() == DownloadActivityType.WIKIVOYAGE_FILE
|
||||
|| item.getType() == DownloadActivityType.DEPTH_CONTOUR_FILE
|
||||
|| item.getType() == DownloadActivityType.SRTM_COUNTRY_FILE) {
|
||||
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 {
|
||||
|
||||
long itemSize = item.getContentSize();
|
||||
long oldItemSize = 0;
|
||||
if (item.getType() == DownloadActivityType.VOICE_FILE) {
|
||||
|
|
|
@ -47,6 +47,9 @@ public class DatabaseHelper {
|
|||
|
||||
private SQLiteAPI.SQLiteConnection openConnection(boolean readonly) {
|
||||
SQLiteAPI.SQLiteConnection conn = app.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
|
||||
if (conn == null) {
|
||||
return null;
|
||||
}
|
||||
if (conn.getVersion() == 0 || DB_VERSION != conn.getVersion()) {
|
||||
if (readonly) {
|
||||
conn.close();
|
||||
|
|
|
@ -61,6 +61,7 @@ public class DiscountHelper {
|
|||
pms.put("version", Version.getFullVersion(app));
|
||||
pms.put("nd", app.getAppInitializer().getFirstInstalledDays() +"");
|
||||
pms.put("ns", app.getAppInitializer().getNumberOfStarts() + "");
|
||||
pms.put("lang", app.getLanguage() + "");
|
||||
try {
|
||||
pms.put("aid", Secure.getString(app.getContentResolver(), Secure.ANDROID_ID));
|
||||
} catch (Exception e) {
|
||||
|
|
|
@ -381,7 +381,7 @@ public class GpxUiHelper {
|
|||
public void onClick(DialogInterface dialog, int which) {
|
||||
|
||||
int position = selectedPosition[0];
|
||||
if (position != -1) {
|
||||
if (position != -1 && position < list.size()) {
|
||||
if (showCurrentGpx && position == 0) {
|
||||
callbackWithObject.processResult(null);
|
||||
app.getSettings().LAST_SELECTED_GPX_TRACK_FOR_NEW_POINT.set(null);
|
||||
|
|
|
@ -54,7 +54,7 @@ public class MapMarkerDialogHelper {
|
|||
DirectionDrawable dd;
|
||||
if (!(arrow.getDrawable() instanceof DirectionDrawable)) {
|
||||
newImage = true;
|
||||
dd = new DirectionDrawable(ctx, arrow.getWidth(), arrow.getHeight());
|
||||
dd = new DirectionDrawable((OsmandApplication) ctx.getApplicationContext(), arrow.getWidth(), arrow.getHeight());
|
||||
} else {
|
||||
dd = (DirectionDrawable) arrow.getDrawable();
|
||||
}
|
||||
|
|
|
@ -374,7 +374,7 @@ public class SearchHistoryHelper {
|
|||
// LEGACY QUERY !!
|
||||
SQLiteCursor query = db.rawQuery(
|
||||
"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 {
|
||||
String name = query.getString(0);
|
||||
String type = PointDescription.POINT_TYPE_MARKER;
|
||||
|
@ -401,7 +401,9 @@ public class SearchHistoryHelper {
|
|||
entries.add(e);
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
query.close();
|
||||
if(query != null) {
|
||||
query.close();
|
||||
}
|
||||
}
|
||||
return entries;
|
||||
}
|
||||
|
@ -416,7 +418,7 @@ public class SearchHistoryHelper {
|
|||
HISTORY_COL_TIME + ", " + HISTORY_COL_FREQ_INTERVALS + ", " + HISTORY_COL_FREQ_VALUES +
|
||||
" FROM " + HISTORY_TABLE_NAME , null); //$NON-NLS-1$//$NON-NLS-2$
|
||||
Map<PointDescription, HistoryEntry> st = new HashMap<PointDescription, HistoryEntry>();
|
||||
if (query.moveToFirst()) {
|
||||
if (query != null && query.moveToFirst()) {
|
||||
boolean reinsert = false;
|
||||
do {
|
||||
String name = query.getString(0);
|
||||
|
@ -443,7 +445,9 @@ public class SearchHistoryHelper {
|
|||
|
||||
}
|
||||
}
|
||||
query.close();
|
||||
if(query != null) {
|
||||
query.close();
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import java.util.ArrayList;
|
|||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.EnumSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
@ -54,6 +53,7 @@ public class WaypointHelper {
|
|||
private static final int LONG_ANNOUNCE_RADIUS = 700;
|
||||
private static final int SHORT_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
|
||||
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};
|
||||
private static final double DISTANCE_IGNORE_DOUBLE_SPEEDCAMS = 150;
|
||||
|
||||
private List<List<LocationPointWrapper>> locationPoints = new ArrayList<List<LocationPointWrapper>>();
|
||||
private ConcurrentHashMap<LocationPoint, Integer> locationPointsStates = new ConcurrentHashMap<LocationPoint, Integer>();
|
||||
private List<List<LocationPointWrapper>> locationPoints = new ArrayList<>();
|
||||
private ConcurrentHashMap<LocationPoint, Integer> locationPointsStates = new ConcurrentHashMap<>();
|
||||
private ConcurrentHashMap<AlarmInfo.AlarmInfoType, AlarmInfo> lastAnnouncedAlarms = new ConcurrentHashMap<>();
|
||||
private TIntArrayList pointsProgress = new TIntArrayList();
|
||||
private RouteCalculationResult route;
|
||||
|
||||
|
@ -342,6 +343,8 @@ public class WaypointHelper {
|
|||
kIterator++;
|
||||
}
|
||||
pointsProgress.set(type, kIterator);
|
||||
|
||||
VoiceRouter voiceRouter = getVoiceRouter();
|
||||
while (kIterator < lp.size()) {
|
||||
LocationPointWrapper lwp = lp.get(kIterator);
|
||||
if (type == ALARMS && lwp.routeIndex < currentRoute) {
|
||||
|
@ -356,18 +359,43 @@ public class WaypointHelper {
|
|||
double d1 = Math.max(0.0, MapUtils.getDistance(lastKnownLocation.getLatitude(), lastKnownLocation.getLongitude(),
|
||||
point.getLatitude(), point.getLongitude()) - lwp.getDeviationDistance());
|
||||
Integer state = locationPointsStates.get(point);
|
||||
if (state != null && state.intValue() == ANNOUNCED_ONCE
|
||||
&& getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS, 0f)) {
|
||||
if (state != null && state == ANNOUNCED_ONCE
|
||||
&& voiceRouter.isDistanceLess(lastKnownLocation.getSpeed(), d1, SHORT_ANNOUNCE_RADIUS, 0f)) {
|
||||
locationPointsStates.put(point, ANNOUNCED_DONE);
|
||||
announcePoints.add(lwp);
|
||||
} else if (type != ALARMS && (state == null || state == NOT_ANNOUNCED)
|
||||
&& getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, LONG_ANNOUNCE_RADIUS, 0f)) {
|
||||
locationPointsStates.put(point, ANNOUNCED_ONCE);
|
||||
approachPoints.add(lwp);
|
||||
} else if (type == ALARMS && (state == null || state == NOT_ANNOUNCED)
|
||||
&& getVoiceRouter().isDistanceLess(lastKnownLocation.getSpeed(), d1, ALARMS_ANNOUNCE_RADIUS, 0f)) {
|
||||
&& voiceRouter.isDistanceLess(lastKnownLocation.getSpeed(), d1, LONG_ANNOUNCE_RADIUS, 0f)) {
|
||||
locationPointsStates.put(point, ANNOUNCED_ONCE);
|
||||
approachPoints.add(lwp);
|
||||
} else if (type == ALARMS && (state == null || state == NOT_ANNOUNCED)) {
|
||||
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);
|
||||
approachPoints.add(lwp);
|
||||
}
|
||||
}
|
||||
}
|
||||
kIterator++;
|
||||
|
@ -377,13 +405,13 @@ public class WaypointHelper {
|
|||
announcePoints = announcePoints.subList(0, ANNOUNCE_POI_LIMIT);
|
||||
}
|
||||
if (type == WAYPOINTS) {
|
||||
getVoiceRouter().announceWaypoint(announcePoints);
|
||||
voiceRouter.announceWaypoint(announcePoints);
|
||||
} else if (type == POI) {
|
||||
getVoiceRouter().announcePoi(announcePoints);
|
||||
voiceRouter.announcePoi(announcePoints);
|
||||
} else if (type == ALARMS) {
|
||||
// nothing to announce
|
||||
} else if (type == FAVORITES) {
|
||||
getVoiceRouter().announceFavorite(announcePoints);
|
||||
voiceRouter.announceFavorite(announcePoints);
|
||||
}
|
||||
}
|
||||
if (!approachPoints.isEmpty()) {
|
||||
|
@ -391,19 +419,17 @@ public class WaypointHelper {
|
|||
approachPoints = approachPoints.subList(0, APPROACH_POI_LIMIT);
|
||||
}
|
||||
if (type == WAYPOINTS) {
|
||||
getVoiceRouter().approachWaypoint(lastKnownLocation, approachPoints);
|
||||
voiceRouter.approachWaypoint(lastKnownLocation, approachPoints);
|
||||
} else if (type == POI) {
|
||||
getVoiceRouter().approachPoi(lastKnownLocation, approachPoints);
|
||||
voiceRouter.approachPoi(lastKnownLocation, approachPoints);
|
||||
} else if (type == ALARMS) {
|
||||
EnumSet<AlarmInfoType> ait = EnumSet.noneOf(AlarmInfoType.class);
|
||||
for (LocationPointWrapper pw : approachPoints) {
|
||||
ait.add(((AlarmInfo) pw.point).getType());
|
||||
}
|
||||
for (AlarmInfoType t : ait) {
|
||||
app.getRoutingHelper().getVoiceRouter().announceAlarm(new AlarmInfo(t, -1), lastKnownLocation.getSpeed());
|
||||
AlarmInfo alarm = (AlarmInfo) pw.point;
|
||||
voiceRouter.announceAlarm(new AlarmInfo(alarm.getType(), -1), lastKnownLocation.getSpeed());
|
||||
lastAnnouncedAlarms.put(alarm.getType(), alarm);
|
||||
}
|
||||
} else if (type == FAVORITES) {
|
||||
getVoiceRouter().approachFavorite(lastKnownLocation, approachPoints);
|
||||
voiceRouter.approachFavorite(lastKnownLocation, approachPoints);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -455,6 +481,7 @@ public class WaypointHelper {
|
|||
|
||||
public void clearAllVisiblePoints() {
|
||||
this.locationPointsStates.clear();
|
||||
this.lastAnnouncedAlarms.clear();
|
||||
this.locationPoints = new ArrayList<List<LocationPointWrapper>>();
|
||||
}
|
||||
|
||||
|
@ -544,6 +571,7 @@ public class WaypointHelper {
|
|||
protected synchronized void setLocationPoints(List<List<LocationPointWrapper>> locationPoints, RouteCalculationResult route) {
|
||||
this.locationPoints = locationPoints;
|
||||
this.locationPointsStates.clear();
|
||||
this.lastAnnouncedAlarms.clear();
|
||||
TIntArrayList list = new TIntArrayList(locationPoints.size());
|
||||
list.fill(0, locationPoints.size(), 0);
|
||||
this.pointsProgress = list;
|
||||
|
|
|
@ -1287,7 +1287,7 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
}
|
||||
|
||||
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) {
|
||||
line3Height = line3Container.getMeasuredHeight();
|
||||
}
|
||||
|
@ -1520,10 +1520,13 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
&& compassView.getVisibility() == View.INVISIBLE
|
||||
&& titleButtonContainer.getVisibility() == View.GONE
|
||||
&& downloadButtonsContainer.getVisibility() == View.GONE
|
||||
&& titleBottomButtonContainer.getVisibility() == View.GONE
|
||||
&& titleProgressContainer.getVisibility() == View.VISIBLE) {
|
||||
&& titleBottomButtonContainer.getVisibility() == View.GONE) {
|
||||
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);
|
||||
} else {
|
||||
view.findViewById(R.id.additional_info_row_container).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) {
|
||||
updateCompassVisibility();
|
||||
updateAdditionalInfoVisibility();
|
||||
runLayoutListener();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,6 +13,7 @@ import android.net.Uri;
|
|||
import android.os.AsyncTask;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.graphics.drawable.DrawableCompat;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.text.ClipboardManager;
|
||||
import android.text.TextUtils;
|
||||
|
@ -752,7 +753,10 @@ public class MenuBuilder {
|
|||
public Drawable getRowIcon(Context ctx, String fileName) {
|
||||
Drawable d = RenderingIcons.getBigIcon(ctx, fileName);
|
||||
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;
|
||||
} else {
|
||||
return null;
|
||||
|
|
|
@ -11,7 +11,6 @@ import android.support.annotation.NonNull;
|
|||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.view.ContextThemeWrapper;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.text.util.Linkify;
|
||||
import android.view.Gravity;
|
||||
|
@ -26,6 +25,7 @@ import net.osmand.data.Amenity;
|
|||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.osm.AbstractPoiType;
|
||||
import net.osmand.osm.MapPoiTypes;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
|
@ -35,13 +35,13 @@ import net.osmand.plus.Version;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.FontCache;
|
||||
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.poi.PoiUIFilter;
|
||||
import net.osmand.plus.views.POIMapLayer;
|
||||
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.OpeningHoursParser;
|
||||
|
||||
|
@ -50,6 +50,7 @@ import java.util.Calendar;
|
|||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -345,6 +346,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
Map<String, List<PoiType>> poiAdditionalCategories = new HashMap<>();
|
||||
AmenityInfoRow cuisineRow = null;
|
||||
List<PoiType> collectedPoiTypes = new ArrayList<>();
|
||||
|
||||
for (Map.Entry<String, String> e : amenity.getAdditionalInfo().entrySet()) {
|
||||
int iconId = 0;
|
||||
|
@ -363,14 +365,15 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
boolean isWiki = false;
|
||||
boolean isText = false;
|
||||
boolean isDescription = false;
|
||||
boolean needLinks = !("population".equals(key)
|
||||
|| "height".equals(key));
|
||||
boolean needLinks = !("population".equals(key) || "height".equals(key));
|
||||
boolean isPhoneNumber = false;
|
||||
boolean isUrl = false;
|
||||
boolean isCuisine = false;
|
||||
int poiTypeOrder = 0;
|
||||
String poiTypeKeyName = "";
|
||||
|
||||
PoiType poiType = amenity.getType().getPoiTypeByKeyName(key);
|
||||
|
||||
AbstractPoiType pt = poiTypes.getAnyPoiAdditionalTypeByKey(key);
|
||||
if (pt == null && !Algorithms.isEmpty(vl) && vl.length() < 50) {
|
||||
pt = poiTypes.getAnyPoiAdditionalTypeByKey(key + "_" + vl);
|
||||
|
@ -474,6 +477,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
iconId = R.drawable.ic_action_poi_name;
|
||||
} else if (key.equals("operator") || key.equals("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 {
|
||||
iconId = R.drawable.ic_action_info_dark;
|
||||
}
|
||||
|
@ -500,6 +505,8 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
if (icon == null && isText && iconId == 0) {
|
||||
iconId = R.drawable.ic_action_note_dark;
|
||||
}
|
||||
} else if (poiType != null) {
|
||||
collectedPoiTypes.add(poiType);
|
||||
} else {
|
||||
textPrefix = Algorithms.capitalizeFirstLetterAndLowercase(e.getKey());
|
||||
vl = amenity.unzipContent(e.getValue());
|
||||
|
@ -523,12 +530,10 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
}
|
||||
if (isDescription) {
|
||||
descriptions.add(row);
|
||||
} else {
|
||||
if (!isCuisine) {
|
||||
infoRows.add(row);
|
||||
} else {
|
||||
cuisineRow = row;
|
||||
}
|
||||
} else if (isCuisine) {
|
||||
cuisineRow = row;
|
||||
} else if (poiType == null) {
|
||||
infoRows.add(row);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -567,12 +572,27 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
sb.append(pt.getTranslation());
|
||||
}
|
||||
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,
|
||||
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>() {
|
||||
@Override
|
||||
public int compare(AmenityInfoRow row1, AmenityInfoRow row2) {
|
||||
|
@ -610,7 +630,7 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
|
||||
if (processNearstWiki() && nearestWiki.size() > 0) {
|
||||
AmenityInfoRow wikiInfo = new AmenityInfoRow(
|
||||
"nearest_wiki", R.drawable.ic_action_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", true,
|
||||
"nearest_wiki", R.drawable.ic_plugin_wikipedia, null, app.getString(R.string.wiki_around) + " (" + nearestWiki.size() + ")", true,
|
||||
getCollapsableWikiView(view.getContext(), true),
|
||||
0, false, false, false, 1000, null, false, false, false, 0);
|
||||
buildAmenityRow(view, wikiInfo);
|
||||
|
@ -663,9 +683,9 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
return params;
|
||||
}
|
||||
|
||||
private CollapsableView getPoiAdditionalCollapsableView(
|
||||
final Context context, boolean collapsed,
|
||||
@NonNull final List<PoiType> categoryTypes, AmenityInfoRow textCuisineRow) {
|
||||
private CollapsableView getPoiTypeCollapsableView(final Context context, boolean collapsed,
|
||||
@NonNull final List<PoiType> categoryTypes,
|
||||
final boolean poiAdditional, AmenityInfoRow textRow) {
|
||||
|
||||
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());
|
||||
if (filter != null) {
|
||||
filter.clearFilter();
|
||||
filter.setTypeToAccept(amenity.getType(), true);
|
||||
filter.updateTypesToAccept(pt);
|
||||
filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase());
|
||||
if (poiAdditional) {
|
||||
filter.setTypeToAccept(amenity.getType(), true);
|
||||
filter.updateTypesToAccept(pt);
|
||||
filter.setFilterByName(pt.getKeyName().replace('_', ':').toLowerCase());
|
||||
} else {
|
||||
LinkedHashSet<String> accept = new LinkedHashSet<>();
|
||||
accept.add(pt.getKeyName());
|
||||
filter.selectSubTypesToAccept(amenity.getType(), accept);
|
||||
}
|
||||
getMapActivity().showQuickSearch(filter);
|
||||
}
|
||||
}
|
||||
|
@ -698,9 +724,9 @@ public class AmenityMenuBuilder extends MenuBuilder {
|
|||
view.addView(button);
|
||||
}
|
||||
|
||||
if (textCuisineRow != null) {
|
||||
if (textRow != null) {
|
||||
TextViewEx button = buildButtonInCollapsableView(context, true, false, false);
|
||||
String name = textCuisineRow.textPrefix + ": " + textCuisineRow.text.toLowerCase();
|
||||
String name = textRow.textPrefix + ": " + textRow.text.toLowerCase();
|
||||
button.setText(name);
|
||||
view.addView(button);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,13 +1,15 @@
|
|||
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.QuadRect;
|
||||
import net.osmand.data.TransportRoute;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.mapcontextmenu.builders.TransportStopMenuBuilder;
|
||||
import net.osmand.plus.transport.TransportStopRoute;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
import net.osmand.plus.mapcontextmenu.MenuController;
|
||||
import net.osmand.plus.resources.TransportIndexRepository;
|
||||
import net.osmand.plus.transport.TransportStopType;
|
||||
|
@ -29,8 +31,8 @@ public class TransportStopController extends MenuController {
|
|||
private TransportStopType topType;
|
||||
|
||||
public TransportStopController(MapActivity mapActivity,
|
||||
PointDescription pointDescription, TransportStop transportStop) {
|
||||
super(new MenuBuilder(mapActivity), pointDescription, mapActivity);
|
||||
PointDescription pointDescription, TransportStop transportStop) {
|
||||
super(new TransportStopMenuBuilder(mapActivity, transportStop), pointDescription, mapActivity);
|
||||
this.transportStop = transportStop;
|
||||
processRoutes();
|
||||
}
|
||||
|
@ -157,4 +159,13 @@ public class TransportStopController extends MenuController {
|
|||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -183,6 +183,9 @@ public class FavoritePointEditorFragment extends PointEditorFragment {
|
|||
} else {
|
||||
helper.editFavouriteName(favorite, name, category, description);
|
||||
}
|
||||
if(getMapActivity() == null) {
|
||||
return;
|
||||
}
|
||||
getMapActivity().refreshMap();
|
||||
if (needDismiss) {
|
||||
dismiss(false);
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
package net.osmand.plus.mapcontextmenu.other;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
|
@ -9,7 +7,6 @@ import android.view.ViewGroup;
|
|||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import net.osmand.Location;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.plus.IconsCache;
|
||||
|
@ -24,18 +21,21 @@ import java.util.List;
|
|||
|
||||
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 LatLon location;
|
||||
private Float heading;
|
||||
private boolean useCenter;
|
||||
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.context = context;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -48,8 +48,6 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
@Override
|
||||
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
|
||||
if (holder instanceof FavouritesViewHolder) {
|
||||
OsmandApplication app = (OsmandApplication) ((Activity) context).getApplication();
|
||||
IconsCache iconsCache = app.getIconsCache();
|
||||
FavouritesViewHolder favouritesViewHolder = (FavouritesViewHolder) holder;
|
||||
FavouritePoint favouritePoint = getItem(position);
|
||||
favouritesViewHolder.title.setText(favouritePoint.getName());
|
||||
|
@ -58,17 +56,16 @@ public class FavouritesAdapter extends RecyclerView.Adapter<RecyclerView.ViewHol
|
|||
} else {
|
||||
favouritesViewHolder.description.setText(favouritePoint.getCategory());
|
||||
}
|
||||
Location myloc = app.getLocationProvider().getLastKnownLocation();
|
||||
favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(context, favouritePoint.getColor(), false));
|
||||
if (myloc == null) {
|
||||
favouritesViewHolder.favouriteImage.setImageDrawable(FavoriteImageDrawable.getOrCreate(app, favouritePoint.getColor(), false));
|
||||
if (location == null) {
|
||||
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.arrowImage.setImageDrawable(iconsCache.getIcon(R.drawable.ic_direction_arrow));
|
||||
DashLocationFragment.updateLocationView(useCenter, location, heading, favouritesViewHolder.arrowImage,
|
||||
favouritesViewHolder.distance, favouritePoint.getLatitude(), favouritePoint.getLongitude(),
|
||||
screenOrientation, app, context);
|
||||
screenOrientation, app);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,11 +66,16 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
recyclerView = (RecyclerView) View.inflate(new ContextThemeWrapper(getContext(), themeRes),
|
||||
R.layout.recyclerview, null);
|
||||
recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
location = getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
|
||||
adapter = new FavouritesAdapter(getMyApplication(), favouritePoints);
|
||||
if (location != null) {
|
||||
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();
|
||||
final BottomSheetItemTitleWithDescrAndButton[] title = new BottomSheetItemTitleWithDescrAndButton[1];
|
||||
title[0] = (BottomSheetItemTitleWithDescrAndButton) new BottomSheetItemTitleWithDescrAndButton.Builder()
|
||||
|
@ -212,14 +217,14 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
@Override
|
||||
public void run() {
|
||||
if (location == null) {
|
||||
location = getMyApplication().getLocationProvider().getLastKnownLocation();
|
||||
location = getMyApplication().getLocationProvider().getLastStaleKnownLocation();
|
||||
}
|
||||
if (location == null) {
|
||||
return;
|
||||
}
|
||||
adapter.setUseCenter(false);
|
||||
adapter.setLocation(new LatLon(location.getLatitude(), location.getLongitude()));
|
||||
adapter.setHeading(heading != null ? heading : 99);
|
||||
|
||||
boolean useCenter = location == null;
|
||||
latLon = useCenter ? mapActivity.getMapLocation() : new LatLon(location.getLatitude(), location.getLongitude());
|
||||
adapter.setUseCenter(useCenter);
|
||||
adapter.setLocation(latLon);
|
||||
adapter.setHeading(useCenter ? -mapActivity.getMapRotate() : heading != null ? heading : 99);
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
@ -260,16 +265,11 @@ public class FavouritesBottomSheetMenuFragment extends MenuBottomSheetDialogFrag
|
|||
}
|
||||
|
||||
private void sortFavourites() {
|
||||
if (location != null) {
|
||||
latLon = new LatLon(location.getLatitude(), location.getLongitude());
|
||||
} else if (sortByDist) {
|
||||
return;
|
||||
}
|
||||
final Collator inst = Collator.getInstance();
|
||||
Collections.sort(favouritePoints, new Comparator<FavouritePoint>() {
|
||||
@Override
|
||||
public int compare(FavouritePoint lhs, FavouritePoint rhs) {
|
||||
if (sortByDist) {
|
||||
if (sortByDist && latLon != null) {
|
||||
double ld = MapUtils.getDistance(latLon, lhs.getLatitude(),
|
||||
lhs.getLongitude());
|
||||
double rd = MapUtils.getDistance(latLon, rhs.getLatitude(),
|
||||
|
|
|
@ -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() {
|
||||
WeakReference<MapRouteInfoMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null)
|
||||
|
|
|
@ -4,9 +4,11 @@ import android.os.Bundle;
|
|||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.FragmentActivity;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ProgressBar;
|
||||
import android.widget.TextView;
|
||||
|
||||
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) {
|
||||
int slideInAnim = 0;
|
||||
int slideOutAnim = 0;
|
||||
|
@ -173,6 +192,11 @@ public class MapRouteInfoMenuFragment extends BaseOsmAndFragment {
|
|||
AndroidUtils.setTextSecondaryColor(ctx, (TextView) mainView.findViewById(R.id.DistanceTitle), nightMode);
|
||||
AndroidUtils.setTextPrimaryColor(ctx, (TextView) mainView.findViewById(R.id.DurationText), 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) {
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.mapcontextmenu.other;
|
||||
|
||||
import android.graphics.Matrix;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
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.OnChartValueSelectedListener;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.QuadRect;
|
||||
import net.osmand.data.RotatedTileBox;
|
||||
|
@ -54,11 +56,13 @@ public class TrackDetailsMenu {
|
|||
private TrkSegment segment;
|
||||
private TrackChartPoints trackChartPoints;
|
||||
private List<WptPt> xAxisPoints;
|
||||
private int topMarginPx;
|
||||
|
||||
private static boolean VISIBLE;
|
||||
|
||||
public TrackDetailsMenu(MapActivity mapActivity) {
|
||||
public TrackDetailsMenu(@NonNull MapActivity mapActivity) {
|
||||
this.mapActivity = mapActivity;
|
||||
topMarginPx = AndroidUtils.dpToPx(mapActivity, 48f);
|
||||
}
|
||||
|
||||
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);
|
||||
if (fragment != null && !fragment.isDetached()) {
|
||||
return new WeakReference<>((TrackDetailsMenuFragment) fragment);
|
||||
|
@ -269,33 +273,32 @@ public class TrackDetailsMenu {
|
|||
|
||||
private void fitTrackOnMap(LineChart chart, LatLon location, boolean forceFit) {
|
||||
QuadRect rect = getRect(chart, chart.getLowestVisibleX(), chart.getHighestVisibleX());
|
||||
if (rect != null) {
|
||||
RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
|
||||
int tileBoxWidthPx = 0;
|
||||
int tileBoxHeightPx = 0;
|
||||
RotatedTileBox tb = mapActivity.getMapView().getCurrentRotatedTileBox().copy();
|
||||
int tileBoxWidthPx = 0;
|
||||
int tileBoxHeightPx = 0;
|
||||
|
||||
WeakReference<TrackDetailsMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
TrackDetailsMenuFragment f = fragmentRef.get();
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
if (!portrait) {
|
||||
tileBoxWidthPx = tb.getPixWidth() - f.getWidth();
|
||||
} else {
|
||||
tileBoxHeightPx = tb.getPixHeight() - f.getHeight();
|
||||
}
|
||||
WeakReference<TrackDetailsMenuFragment> fragmentRef = findMenuFragment();
|
||||
if (fragmentRef != null) {
|
||||
TrackDetailsMenuFragment f = fragmentRef.get();
|
||||
boolean portrait = AndroidUiHelper.isOrientationPortrait(mapActivity);
|
||||
if (!portrait) {
|
||||
tileBoxWidthPx = tb.getPixWidth() - f.getWidth();
|
||||
} else {
|
||||
tileBoxHeightPx = tb.getPixHeight() - f.getHeight();
|
||||
}
|
||||
}
|
||||
if (tileBoxHeightPx > 0) {
|
||||
if (forceFit) {
|
||||
mapActivity.getMapView().fitRectToMap(rect.left, rect.right, rect.top, rect.bottom,
|
||||
tileBoxWidthPx, tileBoxHeightPx, 0);
|
||||
tileBoxWidthPx, tileBoxHeightPx, topMarginPx);
|
||||
} 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();
|
||||
mapActivity.getMapView().fitLocationToMap(location.getLatitude(), location.getLongitude(),
|
||||
mapActivity.getMapView().getZoom(), tileBoxWidthPx, tileBoxHeightPx, 0, !animating);
|
||||
mapActivity.getMapView().getZoom(), tileBoxWidthPx, tileBoxHeightPx, topMarginPx, !animating);
|
||||
} else {
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import android.view.View;
|
|||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.CompoundButton;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.map.ITileSource;
|
||||
import net.osmand.map.TileSourceManager;
|
||||
|
@ -230,14 +229,18 @@ public class MapillaryPlugin extends OsmandPlugin {
|
|||
boolean success = false;
|
||||
OsmandApplication app = (OsmandApplication) activity.getApplication();
|
||||
if (isPackageInstalled(MAPILLARY_PACKAGE_ID, app)) {
|
||||
if (imageKey != null) {
|
||||
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);
|
||||
app.startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mapillary://mapillary/capture"));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
app.startActivity(intent);
|
||||
try {
|
||||
if (imageKey != null) {
|
||||
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);
|
||||
app.startActivity(intent);
|
||||
} else {
|
||||
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("mapillary://mapillary/capture"));
|
||||
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
|
||||
app.startActivity(intent);
|
||||
}
|
||||
} catch (ActivityNotFoundException e) {
|
||||
new MapillaryInstallDialogFragment().show(activity.getSupportFragmentManager(), MapillaryInstallDialogFragment.TAG);
|
||||
}
|
||||
success = true;
|
||||
} else {
|
||||
|
|
|
@ -112,6 +112,9 @@ public class MapMarkersDbHelper {
|
|||
|
||||
private SQLiteConnection openConnection(boolean readonly) {
|
||||
SQLiteConnection conn = context.getSQLiteAPI().getOrCreateDatabase(DB_NAME, readonly);
|
||||
if (conn == null) {
|
||||
return conn;
|
||||
}
|
||||
int version = conn.getVersion();
|
||||
if (version == 0 || DB_VERSION != version) {
|
||||
if (readonly) {
|
||||
|
@ -213,13 +216,15 @@ public class MapMarkersDbHelper {
|
|||
if (db != null) {
|
||||
try {
|
||||
SQLiteCursor query = db.rawQuery(GROUPS_TABLE_SELECT, null);
|
||||
if (query.moveToFirst()) {
|
||||
if (query != null && query.moveToFirst()) {
|
||||
do {
|
||||
MapMarkersGroup group = readGroup(query);
|
||||
res.put(group.getId(), group);
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
query.close();
|
||||
if(query != null) {
|
||||
query.close();
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
@ -392,10 +397,12 @@ public class MapMarkersDbHelper {
|
|||
if (db != null) {
|
||||
try {
|
||||
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);
|
||||
}
|
||||
query.close();
|
||||
if(query != null) {
|
||||
query.close();
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
@ -411,14 +418,16 @@ public class MapMarkersDbHelper {
|
|||
try {
|
||||
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
|
||||
new String[]{String.valueOf(1)});
|
||||
if (query.moveToFirst()) {
|
||||
if (query != null && query.moveToFirst()) {
|
||||
do {
|
||||
MapMarker marker = readItem(query);
|
||||
markers.put(marker.id, marker);
|
||||
nextKeys.add(marker.nextKey);
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
query.close();
|
||||
if(query != null) {
|
||||
query.close();
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
@ -570,12 +579,14 @@ public class MapMarkersDbHelper {
|
|||
try {
|
||||
SQLiteCursor query = db.rawQuery(MARKERS_TABLE_SELECT + " WHERE " + MARKERS_COL_ACTIVE + " = ?",
|
||||
new String[]{String.valueOf(0)});
|
||||
if (query.moveToFirst()) {
|
||||
if (query != null && query.moveToFirst()) {
|
||||
do {
|
||||
markers.add(readItem(query));
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
query.close();
|
||||
if(query != null) {
|
||||
query.close();
|
||||
}
|
||||
} finally {
|
||||
db.close();
|
||||
}
|
||||
|
|
|
@ -218,6 +218,12 @@ public class MarkersPlanRouteContext {
|
|||
params.ctx = app;
|
||||
params.calculationProgress = calculationProgress = new RouteCalculationProgress();
|
||||
params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(int progress) {
|
||||
int pairs = calculatedPairs + snapToRoadPairsToCalculate.size();
|
||||
|
|
|
@ -102,7 +102,7 @@ public class CoordinateInputAdapter extends RecyclerView.Adapter<MapMarkerItemVi
|
|||
DashLocationFragment.updateLocationView(useCenter, location,
|
||||
heading, holder.iconDirection, R.drawable.ic_direction_arrow,
|
||||
holder.distance, new LatLon(mapMarker.getLatitude(), mapMarker.getLongitude()),
|
||||
screenOrientation, mapActivity.getMyApplication(), mapActivity, true);
|
||||
screenOrientation, mapActivity.getMyApplication(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -196,7 +196,7 @@ public class MapMarkersActiveAdapter extends RecyclerView.Adapter<MapMarkerItemV
|
|||
DashLocationFragment.updateLocationView(useCenter, location,
|
||||
heading, markerImageViewToUpdate, drawableResToUpdate,
|
||||
showDirectionEnabled && displayedInWidget ? markerColor : 0, holder.distance, markerLatLon,
|
||||
screenOrientation, mapActivity.getMyApplication(), mapActivity, true);
|
||||
screenOrientation, mapActivity.getMyApplication(), true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -395,7 +395,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter<RecyclerView.V
|
|||
DashLocationFragment.updateLocationView(useCenter, location,
|
||||
heading, markerImageViewToUpdate, drawableResToUpdate, markerToHighlight ? color : 0,
|
||||
itemViewHolder.distance, markerLatLon,
|
||||
screenOrientation, app, mapActivity, true);
|
||||
screenOrientation, app, true);
|
||||
} else if (holder instanceof MapMarkerHeaderViewHolder) {
|
||||
final MapMarkerHeaderViewHolder headerViewHolder = (MapMarkerHeaderViewHolder) holder;
|
||||
final Object header = getItem(position);
|
||||
|
|
|
@ -284,6 +284,12 @@ public class MeasurementEditingContext {
|
|||
params.ctx = application;
|
||||
params.calculationProgress = calculationProgress = new RouteCalculationProgress();
|
||||
params.calculationProgressCallback = new RoutingHelper.RouteCalculationProgressCallback() {
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateProgress(int progress) {
|
||||
int pairs = calculatedPairs + snapToRoadPairsToCalculate.size();
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package net.osmand.plus.myplaces;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Bitmap;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.os.AsyncTask;
|
||||
|
@ -36,6 +37,7 @@ import net.osmand.plus.GPXUtilities.WptPt;
|
|||
import net.osmand.plus.GpxSelectionHelper;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayGroup;
|
||||
import net.osmand.plus.GpxSelectionHelper.GpxDisplayItemType;
|
||||
import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandSettings;
|
||||
|
@ -238,10 +240,19 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
GPXFile gpx = getGpx();
|
||||
WptPt pointToShow = gpx != null ? gpx.findPointToShow() : 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(),
|
||||
pointToShow.getLongitude());
|
||||
final OsmandSettings settings = app.getSettings();
|
||||
String trackName = "";
|
||||
String trackName;
|
||||
if (gpx.showCurrentTrack) {
|
||||
trackName = app.getString(R.string.shared_string_currently_recording_track);
|
||||
} 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 colorView = headerView.findViewById(R.id.color_view);
|
||||
vis = (SwitchCompat) headerView.findViewById(R.id.showOnMapToggle);
|
||||
final View bottomDivider = headerView.findViewById(R.id.bottom_divider);
|
||||
GPXFile gpxFile = getGpx();
|
||||
final boolean selected = gpxFile != null &&
|
||||
((gpxFile.showCurrentTrack && app.getSelectedGpxHelper().getSelectedCurrentRecordingTrack() != null) ||
|
||||
(gpxFile.path != null && app.getSelectedGpxHelper().getSelectedFileByPath(gpxFile.path) != null));
|
||||
boolean gpxFileSelected = isGpxFileSelected(gpxFile);
|
||||
|
||||
boolean hasPath = gpxFile != null && (gpxFile.tracks.size() > 0 || gpxFile.routes.size() > 0);
|
||||
TrackActivity activity = getTrackActivity();
|
||||
TrackBitmapDrawer trackDrawer = getTrackBitmapDrawer();
|
||||
if (activity != null && trackDrawer!= null) {
|
||||
if (activity != null && trackDrawer != null) {
|
||||
if (trackDrawer.isNonInitialized()) {
|
||||
if (trackDrawer.initAndDraw()) {
|
||||
imageView.setVisibility(View.VISIBLE);
|
||||
|
@ -285,31 +295,33 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
}
|
||||
}
|
||||
|
||||
if (showMapOnly) {
|
||||
headerView.findViewById(R.id.track_settings_view).setVisibility(View.GONE);
|
||||
} else {
|
||||
vis.setChecked(selected);
|
||||
vis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (!isChecked) {
|
||||
selectedSplitInterval = 0;
|
||||
}
|
||||
GPXFile gpxFile = getGpx();
|
||||
if (gpxFile != null) {
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
vis.setChecked(gpxFileSelected);
|
||||
vis.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
|
||||
@Override
|
||||
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
||||
if (!isChecked) {
|
||||
selectedSplitInterval = 0;
|
||||
}
|
||||
setTrackVisibilityOnMap(vis.isChecked());
|
||||
if (!showMapOnly) {
|
||||
updateSplitIntervalView(splitIntervalView);
|
||||
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);
|
||||
colorView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
|
@ -338,7 +350,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
int clr = item.getColor();
|
||||
if (vis.isChecked()) {
|
||||
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) {
|
||||
sf.getModifiableGpxFile().setColor(clr);
|
||||
if (getGpxDataItem() != null) {
|
||||
|
@ -388,17 +400,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
@Override
|
||||
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
|
||||
selectedSplitInterval = position;
|
||||
GPXFile gpx = getGpx();
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
setTrackVisibilityOnMap(vis.isChecked());
|
||||
splitListPopupWindow.dismiss();
|
||||
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
|
||||
private QuadRect getRect() {
|
||||
TrackActivity activity = getTrackActivity();
|
||||
|
@ -574,7 +599,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
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();
|
||||
if (activity != null) {
|
||||
new SplitTrackAsyncTask(activity, this, sf, groups)
|
||||
|
@ -582,27 +607,29 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
}
|
||||
}
|
||||
|
||||
private void addOptionSplit(int value, boolean distance, List<GpxDisplayGroup> model) {
|
||||
if (distance) {
|
||||
double dvalue = OsmAndFormatter.calculateRoundedDist(value, app);
|
||||
options.add(OsmAndFormatter.getFormattedDistance((float) dvalue, app));
|
||||
distanceSplit.add(dvalue);
|
||||
timeSplit.add(-1);
|
||||
if (Math.abs(model.get(0).getSplitDistance() - dvalue) < 1) {
|
||||
selectedSplitInterval = distanceSplit.size() - 1;
|
||||
}
|
||||
} else {
|
||||
if (value < 60) {
|
||||
options.add(value + " " + app.getString(R.string.int_seconds));
|
||||
} else if (value % 60 == 0) {
|
||||
options.add((value / 60) + " " + app.getString(R.string.int_min));
|
||||
private void addOptionSplit(int value, boolean distance, @NonNull List<GpxDisplayGroup> model) {
|
||||
if (model.size() > 0) {
|
||||
if (distance) {
|
||||
double dvalue = OsmAndFormatter.calculateRoundedDist(value, app);
|
||||
options.add(OsmAndFormatter.getFormattedDistance((float) dvalue, app));
|
||||
distanceSplit.add(dvalue);
|
||||
timeSplit.add(-1);
|
||||
if (Math.abs(model.get(0).getSplitDistance() - dvalue) < 1) {
|
||||
selectedSplitInterval = distanceSplit.size() - 1;
|
||||
}
|
||||
} else {
|
||||
options.add((value / 60f) + " " + app.getString(R.string.int_min));
|
||||
}
|
||||
distanceSplit.add(-1d);
|
||||
timeSplit.add(value);
|
||||
if (model.get(0).getSplitTime() == value) {
|
||||
selectedSplitInterval = distanceSplit.size() - 1;
|
||||
if (value < 60) {
|
||||
options.add(value + " " + app.getString(R.string.int_seconds));
|
||||
} else if (value % 60 == 0) {
|
||||
options.add((value / 60) + " " + app.getString(R.string.int_min));
|
||||
} else {
|
||||
options.add((value / 60f) + " " + app.getString(R.string.int_min));
|
||||
}
|
||||
distanceSplit.add(-1d);
|
||||
timeSplit.add(value);
|
||||
if (model.get(0).getSplitTime() == value) {
|
||||
selectedSplitInterval = distanceSplit.size() - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -629,7 +656,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
public void updateSplitView() {
|
||||
GPXFile gpxFile = getGpx();
|
||||
if (gpxFile != null) {
|
||||
GpxSelectionHelper.SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile,
|
||||
SelectedGpxFile sf = app.getSelectedGpxHelper().selectGpxFile(gpxFile,
|
||||
((SwitchCompat) headerView.findViewById(R.id.showOnMapToggle)).isChecked(), false);
|
||||
final List<GpxDisplayGroup> groups = getDisplayGroups();
|
||||
if (groups.size() > 0) {
|
||||
|
@ -749,7 +776,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
}
|
||||
|
||||
private static class SplitTrackAsyncTask extends AsyncTask<Void, Void, Void> {
|
||||
private final GpxSelectionHelper.SelectedGpxFile selectedGpx;
|
||||
private final SelectedGpxFile selectedGpx;
|
||||
private OsmandApplication app;
|
||||
private final WeakReference<TrackActivity> activityRef;
|
||||
private final WeakReference<TrackActivityFragmentAdapter> fragmentAdapterRef;
|
||||
|
@ -761,7 +788,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
|
||||
SplitTrackAsyncTask(@NonNull TrackActivity activity,
|
||||
@NonNull TrackActivityFragmentAdapter fragmentAdapter,
|
||||
@Nullable GpxSelectionHelper.SelectedGpxFile selectedGpx,
|
||||
@Nullable SelectedGpxFile selectedGpx,
|
||||
@NonNull List<GpxDisplayGroup> groups) {
|
||||
activityRef = new WeakReference<>(activity);
|
||||
fragmentAdapterRef = new WeakReference<>(fragmentAdapter);
|
||||
|
@ -774,6 +801,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
timeSplit = fragmentAdapter.timeSplit;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPreExecute() {
|
||||
TrackActivity activity = activityRef.get();
|
||||
if (activity != null) {
|
||||
|
@ -781,6 +809,7 @@ public class TrackActivityFragmentAdapter implements TrackBitmapDrawerListener {
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
TrackActivity activity = activityRef.get();
|
||||
TrackActivityFragmentAdapter fragment = fragmentAdapterRef.get();
|
||||
|
|
|
@ -266,7 +266,7 @@ public class TrackBitmapDrawer {
|
|||
float x = tileBox.getPixXFromLatLon(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));
|
||||
canvas.drawBitmap(pointSmall, x - pointSmall.getWidth() / 2, y - pointSmall.getHeight() / 2, paintIcon);
|
||||
}
|
||||
|
|
|
@ -341,6 +341,7 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
}
|
||||
// Needed to hide intermediate progress bar after closing action mode
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
hideProgressBar();
|
||||
}
|
||||
|
@ -633,8 +634,19 @@ public class TrackPointFragment extends OsmandExpandableListFragment implements
|
|||
}
|
||||
updateSelectionMode(actionMode);
|
||||
} else {
|
||||
if (item.group.getGpx() != null) {
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(item.group.getGpx());
|
||||
GPXFile gpx = 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();
|
||||
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 {
|
||||
|
||||
Map<GpxDisplayGroup, List<GpxDisplayItem>> itemGroups = new LinkedHashMap<>();
|
||||
|
|
|
@ -253,7 +253,7 @@ public class TrackSegmentFragment extends OsmAndListFragment implements TrackBit
|
|||
}
|
||||
}
|
||||
|
||||
private void updateHeader() {
|
||||
public void updateHeader() {
|
||||
if (fragmentAdapter != null) {
|
||||
fragmentAdapter.updateHeader(adapter.getCount());
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -5,9 +5,9 @@ import android.content.BroadcastReceiver;
|
|||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationCompat.BigTextStyle;
|
||||
import android.support.v4.app.NotificationCompat.Builder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import net.osmand.plus.NavigationService;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
|
|
|
@ -10,11 +10,10 @@ import android.graphics.Bitmap;
|
|||
import android.graphics.Canvas;
|
||||
import android.graphics.PorterDuff;
|
||||
import android.graphics.drawable.Drawable;
|
||||
|
||||
import android.os.Build;
|
||||
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.Builder;
|
||||
import android.view.View;
|
||||
|
||||
import net.osmand.plus.NavigationService;
|
||||
|
|
|
@ -2,28 +2,28 @@ package net.osmand.plus.notifications;
|
|||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Notification;
|
||||
import android.app.NotificationChannel;
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
import android.support.v4.app.NotificationCompat.Builder;
|
||||
import android.support.v4.app.NotificationManagerCompat;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import net.osmand.plus.NotificationHelper;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
|
||||
public abstract class OsmandNotification {
|
||||
|
||||
public final static int NAVIGATION_NOTIFICATION_SERVICE_ID = 5;
|
||||
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 WEAR_NAVIGATION_NOTIFICATION_SERVICE_ID = 1005;
|
||||
public final static int WEAR_GPX_NOTIFICATION_SERVICE_ID = 1006;
|
||||
|
||||
public final static int WEAR_ERROR_NOTIFICATION_SERVICE_ID = 1007;
|
||||
|
||||
|
||||
protected OsmandApplication app;
|
||||
protected boolean ongoing = true;
|
||||
|
@ -36,7 +36,8 @@ public abstract class OsmandNotification {
|
|||
public enum NotificationType {
|
||||
NAVIGATION,
|
||||
GPX,
|
||||
GPS
|
||||
GPS,
|
||||
ERROR,
|
||||
}
|
||||
|
||||
public OsmandNotification(OsmandApplication app, String groupName) {
|
||||
|
@ -69,7 +70,7 @@ public abstract class OsmandNotification {
|
|||
PendingIntent.FLAG_UPDATE_CURRENT);
|
||||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
|
||||
app.getNotificationHelper().createNotificationChannel();
|
||||
}
|
||||
}
|
||||
Builder builder = new Builder(app, NotificationHelper.NOTIFICATION_CHANEL_ID)
|
||||
.setVisibility(android.support.v4.app.NotificationCompat.VISIBILITY_PUBLIC)
|
||||
.setPriority(top ? NotificationCompat.PRIORITY_HIGH : getPriority())
|
||||
|
|
|
@ -143,7 +143,12 @@ public class AdvancedEditPoiFragment extends BaseOsmAndFragment
|
|||
amenityTagTextView.setText(pt.getEditOsmTag());
|
||||
amenityTextView.setText(pt.getEditOsmValue());
|
||||
} 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());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
package net.osmand.plus.osmedit;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.osm.PoiCategory;
|
||||
import net.osmand.osm.PoiType;
|
||||
|
@ -52,7 +54,7 @@ public class EditPoiData {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
public PoiCategory getPoiCategory() {
|
||||
return category;
|
||||
}
|
||||
|
|
|
@ -273,7 +273,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
if (!getEditPoiData().isInEdit()) {
|
||||
getEditPoiData().updateTypeTag(s.toString(), true);
|
||||
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()
|
||||
- editText.getCompoundDrawables()[DRAWABLE_RIGHT].getBounds().width()
|
||||
- editText.getPaddingRight())) {
|
||||
if (editPoiData.getPoiCategory() != null) {
|
||||
PoiCategory category = editPoiData.getPoiCategory();
|
||||
if (category != null) {
|
||||
PoiSubTypeDialogFragment dialogFragment =
|
||||
PoiSubTypeDialogFragment.createInstance(editPoiData.getPoiCategory());
|
||||
PoiSubTypeDialogFragment.createInstance(category);
|
||||
dialogFragment.setOnItemSelectListener(new PoiSubTypeDialogFragment.OnItemSelectListener() {
|
||||
@Override
|
||||
public void select(String category) {
|
||||
|
@ -466,8 +470,10 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
node.removeTag(EditPoiData.REMOVE_TAG_PREFIX + poiType.getOsmTag2());
|
||||
}
|
||||
} 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)) {
|
||||
node.putTagNoLC(EditPoiData.POI_TYPE_TAG, poiTypeTag);
|
||||
|
|
|
@ -18,6 +18,7 @@ import android.widget.Toast;
|
|||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.data.Amenity;
|
||||
import net.osmand.data.TransportStop;
|
||||
import net.osmand.osm.PoiType;
|
||||
import net.osmand.osm.edit.Node;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
|
@ -195,7 +196,8 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
} else if (resId == R.string.context_menu_item_modify_note) {
|
||||
modifyOsmNote(mapActivity, (OsmNotesPoint) selectedObj);
|
||||
} 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) {
|
||||
final Node entity = ((OpenstreetmapPoint) selectedObj).getEntity();
|
||||
EditPoiDialogFragment.createInstance(entity, false)
|
||||
|
@ -205,8 +207,13 @@ public class OsmEditingPlugin extends OsmandPlugin {
|
|||
}
|
||||
};
|
||||
boolean isEditable = false;
|
||||
if (selectedObj instanceof Amenity) {
|
||||
Amenity amenity = (Amenity) selectedObj;
|
||||
if (selectedObj instanceof Amenity || (selectedObj instanceof TransportStop && ((TransportStop) selectedObj).getAmenity() != null)) {
|
||||
Amenity amenity;
|
||||
if (selectedObj instanceof Amenity) {
|
||||
amenity = (Amenity) selectedObj;
|
||||
} else {
|
||||
amenity = ((TransportStop) selectedObj).getAmenity();
|
||||
}
|
||||
final PoiType poiType = amenity.getType().getPoiTypeByKeyName(amenity.getSubType());
|
||||
isEditable = !amenity.getType().isWiki() && poiType !=null && !poiType.isNotEditableOsm();
|
||||
}
|
||||
|
|
|
@ -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$
|
||||
CATEGORIES_NAME, null);
|
||||
Map<String, Map<PoiCategory, LinkedHashSet<String>>> map = new LinkedHashMap<String, Map<PoiCategory, LinkedHashSet<String>>>();
|
||||
if (query.moveToFirst()) {
|
||||
if (query != null && query.moveToFirst()) {
|
||||
do {
|
||||
String filterId = query.getString(0);
|
||||
if (!map.containsKey(filterId)) {
|
||||
|
@ -492,11 +492,13 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
query.close();
|
||||
if(query != null) {
|
||||
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$
|
||||
FILTER_NAME, null);
|
||||
if (query.moveToFirst()) {
|
||||
if (query != null && query.moveToFirst()) {
|
||||
do {
|
||||
String filterId = query.getString(0);
|
||||
if (map.containsKey(filterId)) {
|
||||
|
@ -507,7 +509,9 @@ public class PoiFiltersHelper {
|
|||
}
|
||||
} while (query.moveToNext());
|
||||
}
|
||||
query.close();
|
||||
if(query != null) {
|
||||
query.close();
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
|
|
@ -76,6 +76,10 @@ public class QuickAction {
|
|||
return id;
|
||||
}
|
||||
|
||||
public long getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public boolean isActionEditable() {
|
||||
return isActionEditable;
|
||||
}
|
||||
|
|
|
@ -109,8 +109,7 @@ public class QuickActionListFragment extends BaseOsmAndFragment implements Quick
|
|||
|
||||
private void setUpToolbar(View view) {
|
||||
Toolbar toolbar = (Toolbar) view.findViewById(R.id.custom_toolbar);
|
||||
Drawable back = getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back);
|
||||
back.setColorFilter(ContextCompat.getColor(getContext(), R.color.color_white), PorterDuff.Mode.MULTIPLY);
|
||||
Drawable back = getMyApplication().getIconsCache().getIcon(R.drawable.ic_arrow_back, R.color.color_white);
|
||||
toolbar.setNavigationIcon(back);
|
||||
toolbar.setNavigationContentDescription(R.string.access_shared_string_navigate_up);
|
||||
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
|
||||
|
|
|
@ -1,9 +1,12 @@
|
|||
package net.osmand.plus.quickaction;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
import android.support.v4.view.MotionEventCompat;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.support.v7.widget.helper.ItemTouchHelper;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -16,6 +19,7 @@ import android.widget.TextView;
|
|||
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.dialogs.SelectMapViewQuickActionsBottomSheet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
|
@ -23,6 +27,10 @@ import java.util.List;
|
|||
|
||||
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;
|
||||
|
||||
protected SwitchableAction(int type) {
|
||||
|
@ -43,13 +51,18 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
|||
|
||||
View view = LayoutInflater.from(parent.getContext())
|
||||
.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 QuickActionItemTouchHelperCallback touchHelperCallback = new QuickActionItemTouchHelperCallback();
|
||||
final ItemTouchHelper touchHelper = new ItemTouchHelper(touchHelperCallback);
|
||||
|
||||
final Adapter adapter = new Adapter(new QuickActionListFragment.OnStartDragListener() {
|
||||
final Adapter adapter = new Adapter(activity, new QuickActionListFragment.OnStartDragListener() {
|
||||
@Override
|
||||
public void onStartDrag(RecyclerView.ViewHolder viewHolder) {
|
||||
touchHelper.startDrag(viewHolder);
|
||||
|
@ -90,12 +103,28 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
|||
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 {
|
||||
|
||||
private List<T> itemsList = new ArrayList<>();
|
||||
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.itemsList = new ArrayList<>();
|
||||
}
|
||||
|
@ -110,7 +139,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
|||
public void onBindViewHolder(final Adapter.ItemHolder holder, final int position) {
|
||||
final T item = itemsList.get(position);
|
||||
|
||||
holder.title.setText(getItemName(item));
|
||||
holder.title.setText(getItemName(context, item));
|
||||
|
||||
holder.handleView.setOnTouchListener(new View.OnTouchListener() {
|
||||
@Override
|
||||
|
@ -249,9 +278,7 @@ public abstract class SwitchableAction<T> extends QuickAction {
|
|||
|
||||
protected abstract void saveListToParams(List<T> list);
|
||||
|
||||
protected abstract List<T> loadListFromParams();
|
||||
|
||||
protected abstract String getItemName(T item);
|
||||
protected abstract String getItemName(Context context, T item);
|
||||
|
||||
protected abstract
|
||||
@StringRes
|
||||
|
|
|
@ -117,8 +117,10 @@ public class AddPOIAction extends QuickAction {
|
|||
newNode.putTagNoLC(poiType.getOsmTag2(), poiType.getOsmValue2());
|
||||
}
|
||||
} 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())) {
|
||||
newNode.putTagNoLC(tag.getKey(), tag.getValue());
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
package net.osmand.plus.quickaction.actions;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
import android.support.v7.widget.SwitchCompat;
|
||||
import android.view.View;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.Toast;
|
||||
|
@ -55,7 +57,7 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected List<Pair<String, String>> loadListFromParams() {
|
||||
public List<Pair<String, String>> loadListFromParams() {
|
||||
|
||||
String json = getParams().get(getListKey());
|
||||
|
||||
|
@ -68,7 +70,7 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
|||
}
|
||||
|
||||
@Override
|
||||
protected String getItemName(Pair<String, String> item) {
|
||||
protected String getItemName(Context context, Pair<String, String> item) {
|
||||
return item.second;
|
||||
}
|
||||
|
||||
|
@ -82,6 +84,12 @@ public class MapOverlayAction extends SwitchableAction<Pair<String, String>> {
|
|||
OsmandSettings settings = activity.getMyApplication().getSettings();
|
||||
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<>(
|
||||
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()) {
|
||||
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) {
|
||||
settings.MAP_OVERLAY.set(nextSource.first);
|
||||
settings.MAP_OVERLAY_PREVIOUS.set(nextSource.first);
|
||||
settings.MAP_OVERLAY.set(params);
|
||||
settings.MAP_OVERLAY_PREVIOUS.set(params);
|
||||
} else {
|
||||
settings.MAP_OVERLAY.set(null);
|
||||
settings.MAP_OVERLAY_PREVIOUS.set(null);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|