Compare commits

...

28 commits
master ... r3.1

Author SHA1 Message Date
crimean
d1161ce5d3 Optimize imports 2018-08-30 17:26:39 +03:00
crimean
76d87db4a3 Added search and navigate api feature. Fixes. 2018-08-30 17:26:24 +03:00
crimean
e23e835e75 Added searchType parameter to AIDL Search API 2018-08-30 17:26:13 +03:00
crimean
2f6d331c42 Added search feature to aidl api 2018-08-30 17:25:58 +03:00
crimean
c8bee8f39b Fix stop nav api action 2018-08-25 19:06:42 +03:00
crimean
191a3ef99d Added nav api pause/resume/stop/mute/unmute 2018-08-25 19:06:25 +03:00
crimean
562cc114e0 Replace gnustl_shared with c++_shared 2018-08-16 11:48:21 +03:00
Chumva
381656f032 remove hardcoded strings 2018-08-09 13:44:52 +03:00
Alex Sytnyk
222e4f3c01 Fix cleanupDuplicatesInCore task; disable D8
(cherry picked from commit 0e5bf69)
2018-08-07 19:57:02 +03:00
Alex Sytnyk
965d60aadb Fix possible NPE
(cherry picked from commit cbf6529)
2018-08-06 15:59:42 +03:00
Alex Sytnyk
386b9ce5db Fix possible NPE
(cherry picked from commit 293c424)
2018-08-06 13:52:15 +03:00
crimean
2095f843be Fix possible npe 2018-08-06 11:25:21 +03:00
crimean
b167096be1 Fix MapMultiSelectionMenu crash 2018-08-06 11:25:02 +03:00
Alex Sytnyk
750cb432b0 Fix possible NPE in the BasicEditPoiFragment
(cherry picked from commit 998a9f9)
2018-08-02 13:00:10 +03:00
Chumva
b700856c14 fix possible npe
(cherry picked from commit d24596f)
2018-08-02 12:48:37 +03:00
Alexander Sytnyk
e6ae64877a
Merge pull request #5765 from osmandapp/Fix5003
Fix_5003
2018-08-02 12:00:14 +03:00
Chumva
b037b98c11 remove unnecessary method 2018-08-02 11:37:31 +03:00
Chumva
ba1b92ee68 remove unnecessary date file 2018-08-01 18:53:33 +03:00
Chumva
a0dd42e1e8 add date check in checkIfItemOutdated 2018-08-01 18:45:08 +03:00
Chumva
13fcd309c0 Fix #5003 2018-08-01 18:31:38 +03:00
Alex Sytnyk
4c554f8fa2 Show separator for all types of context menu
(cherry picked from commit 5fe78fa)
2018-08-01 16:47:36 +03:00
Alex Sytnyk
e654d02241 Fix vertical offset
(cherry picked from commit cd688b4)
2018-08-01 16:47:27 +03:00
Alex Sytnyk
c6d47c2f3f Add some info from AMapPoint to the Context Menu
(cherry picked from commit 918ada7)
2018-08-01 16:47:21 +03:00
Alexander Sytnyk
07ed7d8b72
Merge pull request #5761 from osmandapp/UiImprovements
Fix search and editing toasts
2018-08-01 14:15:22 +03:00
Chumva
83f88fa62a fix toast translation 2018-08-01 13:58:18 +03:00
Chumva
ed9c9d1949 fix tabs in resources 2018-08-01 13:42:10 +03:00
Chumva
c3318556f6 add new string resources and toast after sending search request 2018-08-01 13:22:30 +03:00
Alex Sytnyk
65153ba598 Fix the "map_context_menu_fragment" layout formatting
(cherry picked from commit 2624deb)
2018-08-01 12:42:20 +03:00
47 changed files with 1554 additions and 306 deletions

View file

@ -401,6 +401,10 @@ public class SearchUICore {
} }
public void search(final String text, final boolean delayedExecution, final ResultMatcher<SearchResult> matcher) { public void search(final String text, final boolean delayedExecution, final ResultMatcher<SearchResult> matcher) {
search(text, delayedExecution, matcher, searchSettings);
}
public void search(final String text, final boolean delayedExecution, final ResultMatcher<SearchResult> matcher, final SearchSettings searchSettings) {
final int request = requestNumber.incrementAndGet(); final int request = requestNumber.incrementAndGet();
final SearchPhrase phrase = this.phrase.generateNewPhrase(text, searchSettings); final SearchPhrase phrase = this.phrase.generateNewPhrase(text, searchSettings);
this.phrase = phrase; this.phrase = phrase;

1
OsmAnd/.gitignore vendored
View file

@ -27,6 +27,7 @@ local.properties
raw/ raw/
obj/ obj/
libgnustl/ libgnustl/
libc++/
cpd.xml cpd.xml
jni/Local.mk jni/Local.mk
out/ out/

View file

@ -103,7 +103,7 @@ android {
} }
legacy { legacy {
jniLibs.srcDirs = ["libgnustl"] jniLibs.srcDirs = ["libc++"]
} }
} }
@ -311,14 +311,12 @@ task cleanupDuplicatesInCore() {
dependsOn buildOsmAndCore dependsOn buildOsmAndCore
// doesn't work for legacy debug builds // doesn't work for legacy debug builds
doLast { doLast {
file("libgnustl/armeabi").mkdirs() file("libc++/armeabi-v7a").mkdirs()
file("libs/armeabi/libgnustl_shared.so").renameTo(file("libgnustl/armeabi/libgnustl_shared.so")) file("libs/armeabi-v7a/libc++_shared.so").renameTo(file("libc++/armeabi-v7a/libc++_shared.so"))
file("libgnustl/armeabi-v7a").mkdirs() file("libc++/arm64-v8a").mkdirs()
file("libs/armeabi-v7a/libgnustl_shared.so").renameTo(file("libgnustl/armeabi-v7a/libgnustl_shared.so")) file("libs/arm64-v8a/libc++_shared.so").renameTo(file("libc++/arm64-v8a/libc++_shared.so"))
file("libgnustl/mips").mkdirs() file("libc++/x86").mkdirs()
file("libs/mips/libgnustl_shared.so").renameTo(file("libgnustl/mips/libgnustl_shared.so")) file("libs/x86/libc++_shared.so").renameTo(file("libc++/x86/libc++_shared.so"))
file("libgnustl/x86").mkdirs()
file("libs/x86/libgnustl_shared.so").renameTo(file("libgnustl/x86/libgnustl_shared.so"))
} }
} }
afterEvaluate { afterEvaluate {

View file

@ -1,5 +1,5 @@
APP_STL := gnustl_shared # APP_STL := gnustl_shared
# APP_STL := c++_shared APP_STL := c++_shared
APP_CPPFLAGS := -std=c++11 -fexceptions -frtti APP_CPPFLAGS := -std=c++11 -fexceptions -frtti
APP_SHORT_COMMANDS := true APP_SHORT_COMMANDS := true

View file

@ -2,3 +2,4 @@ armeabi/
x86/ x86/
armeabi-v7a/ armeabi-v7a/
mips/ mips/
arm64-v8a/

View file

@ -99,21 +99,21 @@
android:paddingTop="3dp"> android:paddingTop="3dp">
<net.osmand.plus.widgets.TextViewEx <net.osmand.plus.widgets.TextViewEx
android:layout_gravity="center_vertical"
android:id="@+id/nearby_routes_within_text_view" android:id="@+id/nearby_routes_within_text_view"
style="@style/TextAppearance.ContextMenuSubtitle" style="@style/TextAppearance.ContextMenuSubtitle"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="@dimen/context_menu_padding_margin_small" android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
android:layout_marginRight="@dimen/context_menu_padding_margin_small" android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:textSize="@dimen/default_sub_text_size" android:textSize="@dimen/default_sub_text_size"
osmand:typeface="@string/font_roboto_medium"/> osmand:typeface="@string/font_roboto_medium"/>
<GridView <GridView
android:layout_gravity="center_vertical"
android:id="@+id/transport_stop_nearby_routes_grid" android:id="@+id/transport_stop_nearby_routes_grid"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:columnWidth="@dimen/context_menu_transport_grid_item_width" android:columnWidth="@dimen/context_menu_transport_grid_item_width"
android:horizontalSpacing="@dimen/context_menu_transport_grid_spacing" android:horizontalSpacing="@dimen/context_menu_transport_grid_spacing"
android:numColumns="auto_fit" android:numColumns="auto_fit"
@ -133,10 +133,10 @@
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny" android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
android:gravity="top" android:gravity="top"
android:orientation="horizontal" android:orientation="horizontal"
android:paddingTop="3dp"
android:paddingBottom="3dp" android:paddingBottom="3dp"
android:paddingLeft="@dimen/context_menu_padding_margin_default" android:paddingLeft="@dimen/context_menu_padding_margin_default"
android:paddingRight="@dimen/context_menu_padding_margin_default"> android:paddingRight="@dimen/context_menu_padding_margin_default"
android:paddingTop="3dp">
<LinearLayout <LinearLayout
android:id="@+id/additional_info_row" android:id="@+id/additional_info_row"
@ -161,8 +161,8 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="top" android:layout_gravity="top"
android:paddingTop="1dp"
android:paddingRight="@dimen/context_menu_padding_margin_small" android:paddingRight="@dimen/context_menu_padding_margin_small"
android:paddingTop="1dp"
tools:src="@drawable/ic_action_opening_hour_16"/> tools:src="@drawable/ic_action_opening_hour_16"/>
<TextView <TextView
@ -173,6 +173,17 @@
android:layout_marginRight="@dimen/context_menu_padding_margin_small" android:layout_marginRight="@dimen/context_menu_padding_margin_small"
tools:text="Closed till 10:00"/> tools:text="Closed till 10:00"/>
<TextView
android:id="@+id/info_compass_separator"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
android:text="•"
android:textColor="@color/icon_color"
android:visibility="gone"
tools:visibility="visible"/>
<LinearLayout <LinearLayout
android:id="@+id/compass_layout" android:id="@+id/compass_layout"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -723,13 +734,13 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="left" android:layout_gravity="left"
android:scaleType="center"
android:textColor="@color/abc_primary_text_material_dark"
android:textSize="@dimen/abc_text_size_large_material"
android:ellipsize="end" android:ellipsize="end"
android:lines="1" android:lines="1"
android:maxLines="1" android:maxLines="1"
android:scaleType="center"
android:singleLine="true" android:singleLine="true"
android:textColor="@color/abc_primary_text_material_dark"
android:textSize="@dimen/abc_text_size_large_material"
tools:text="Toolbar" tools:text="Toolbar"
tools:visibility="visible"/> tools:visibility="visible"/>

View file

@ -58,7 +58,7 @@
android:gravity="center_vertical" android:gravity="center_vertical"
android:lines="1" android:lines="1"
android:singleLine="true" android:singleLine="true"
android:text="5 selected" tools:text="5 selected"
android:textColor="@color/color_white" android:textColor="@color/color_white"
android:textSize="@dimen/default_list_text_size_large"/> android:textSize="@dimen/default_list_text_size_large"/>
@ -237,7 +237,7 @@
android:paddingLeft="@dimen/bottom_sheet_content_margin" android:paddingLeft="@dimen/bottom_sheet_content_margin"
android:paddingRight="@dimen/bottom_sheet_content_margin" android:paddingRight="@dimen/bottom_sheet_content_margin"
android:paddingTop="@dimen/context_menu_padding_margin_tiny" android:paddingTop="@dimen/context_menu_padding_margin_tiny"
android:text="@string/search_no_results_description" android:text="@string/search_no_results_feedback"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" /> osmand:typeface="@string/font_roboto_medium" />
@ -264,7 +264,7 @@
android:paddingLeft="@dimen/context_menu_padding_margin_small" android:paddingLeft="@dimen/context_menu_padding_margin_small"
android:paddingRight="@dimen/context_menu_padding_margin_small" android:paddingRight="@dimen/context_menu_padding_margin_small"
android:paddingTop="@dimen/context_menu_padding_margin_small" android:paddingTop="@dimen/context_menu_padding_margin_small"
android:text="Отправить" android:text="@string/shared_string_send"
android:textColor="?attr/wikivoyage_active_color" android:textColor="?attr/wikivoyage_active_color"
android:textSize="@dimen/default_desc_text_size" android:textSize="@dimen/default_desc_text_size"
osmand:typeface="@string/font_roboto_medium" /> osmand:typeface="@string/font_roboto_medium" />

View file

@ -11,6 +11,9 @@
Thx - Hardy Thx - Hardy
--> -->
<string name="thank_you_for_feedback">Thank you for feedback</string>
<string name="poi_cannot_be_found">Node or way cannot be found.</string>
<string name="search_no_results_feedback">No search results?\nGive us feedback</string>
<string name="release_3_1"> <string name="release_3_1">
• Navigation: Fix progress bar, fast swapping of the start and end point of the route\n\n • Navigation: Fix progress bar, fast swapping of the start and end point of the route\n\n
• Map markers: fix turn on/off groups, ability to hide markers from the map\n\n • Map markers: fix turn on/off groups, ability to hide markers from the map\n\n
@ -23,7 +26,6 @@
<string name="increase_search_radius_to">Increase search radius to %1$s</string> <string name="increase_search_radius_to">Increase search radius to %1$s</string>
<string name="send_search_query_description"><![CDATA[We will send your search query: <b>\"%1$s\"</b>, as well as your location.<br/><br/> <string name="send_search_query_description"><![CDATA[We will send your search query: <b>\"%1$s\"</b>, as well as your location.<br/><br/>
We do not collect personal information, we only need search data to improve the search algorithm.<br/>]]></string> We do not collect personal information, we only need search data to improve the search algorithm.<br/>]]></string>
<string name="search_no_results_description">No results?\nTell us about this.</string>
<string name="send_search_query">Send search query?</string> <string name="send_search_query">Send search query?</string>
<string name="shared_string_world">World</string> <string name="shared_string_world">World</string>
<string name="point_deleted">Point %1$s deleted</string> <string name="point_deleted">Point %1$s deleted</string>
@ -2673,7 +2675,6 @@
<string name="favourites_remove_dialog_success">Favorite point {0} deleted.</string> <string name="favourites_remove_dialog_success">Favorite point {0} deleted.</string>
<string name="poi_edit_title">Edit POI</string> <string name="poi_edit_title">Edit POI</string>
<string name="poi_create_title">Create POI</string> <string name="poi_create_title">Create POI</string>
<string name="poi_error_poi_not_found">Node cannot be found, or amenity consists of several nodes, which is not yet supported.</string>
<string name="poi_remove_confirm_template">Delete {0} (comment)?</string> <string name="poi_remove_confirm_template">Delete {0} (comment)?</string>
<string name="poi_remove_title">Delete POI</string> <string name="poi_remove_title">Delete POI</string>
<string name="poi_remove_success">POI deleted</string> <string name="poi_remove_success">POI deleted</string>

View file

@ -0,0 +1,7 @@
package net.osmand.aidl;
import net.osmand.aidl.search.SearchResult;
interface IOsmAndAidlCallback {
void onSearchComplete(in List<SearchResult> resultSet);
}

View file

@ -55,6 +55,18 @@ import net.osmand.aidl.maplayer.point.ShowMapPointParams;
import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams; import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams;
import net.osmand.aidl.navigation.PauseNavigationParams;
import net.osmand.aidl.navigation.ResumeNavigationParams;
import net.osmand.aidl.navigation.StopNavigationParams;
import net.osmand.aidl.navigation.MuteNavigationParams;
import net.osmand.aidl.navigation.UnmuteNavigationParams;
import net.osmand.aidl.IOsmAndAidlCallback;
import net.osmand.aidl.search.SearchResult;
import net.osmand.aidl.search.SearchParams;
import net.osmand.aidl.navigation.NavigateSearchParams;
// NOTE: Add new methods at the end of file!!! // NOTE: Add new methods at the end of file!!!
interface IOsmAndAidlInterface { interface IOsmAndAidlInterface {
@ -109,4 +121,13 @@ interface IOsmAndAidlInterface {
boolean showMapPoint(in ShowMapPointParams params); boolean showMapPoint(in ShowMapPointParams params);
boolean setNavDrawerItems(in SetNavDrawerItemsParams params); boolean setNavDrawerItems(in SetNavDrawerItemsParams params);
boolean pauseNavigation(in PauseNavigationParams params);
boolean resumeNavigation(in ResumeNavigationParams params);
boolean stopNavigation(in StopNavigationParams params);
boolean muteNavigation(in MuteNavigationParams params);
boolean unmuteNavigation(in UnmuteNavigationParams params);
boolean search(in SearchParams params, IOsmAndAidlCallback callback);
boolean navigateSearch(in NavigateSearchParams params);
} }

View file

@ -1,5 +1,6 @@
package net.osmand.aidl; package net.osmand.aidl;
import android.annotation.SuppressLint;
import android.app.Activity; import android.app.Activity;
import android.content.BroadcastReceiver; import android.content.BroadcastReceiver;
import android.content.Context; import android.content.Context;
@ -18,6 +19,7 @@ import android.view.View;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.Location;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.aidl.favorite.AFavorite; import net.osmand.aidl.favorite.AFavorite;
import net.osmand.aidl.favorite.group.AFavoriteGroup; import net.osmand.aidl.favorite.group.AFavoriteGroup;
@ -28,9 +30,11 @@ import net.osmand.aidl.maplayer.AMapLayer;
import net.osmand.aidl.maplayer.point.AMapPoint; import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.aidl.mapmarker.AMapMarker; import net.osmand.aidl.mapmarker.AMapMarker;
import net.osmand.aidl.mapwidget.AMapWidget; import net.osmand.aidl.mapwidget.AMapWidget;
import net.osmand.aidl.search.SearchResult;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.AppInitializer;
import net.osmand.plus.ApplicationMode; import net.osmand.plus.ApplicationMode;
import net.osmand.plus.ContextMenuAdapter; import net.osmand.plus.ContextMenuAdapter;
import net.osmand.plus.ContextMenuItem; import net.osmand.plus.ContextMenuItem;
@ -44,11 +48,12 @@ import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
import net.osmand.plus.dialogs.ConfigureMapMenu; import net.osmand.plus.dialogs.ConfigureMapMenu;
import net.osmand.plus.helpers.ColorDialogs; import net.osmand.plus.helpers.ColorDialogs;
import net.osmand.plus.helpers.ExternalApiHelper;
import net.osmand.plus.monitoring.OsmandMonitoringPlugin; import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.views.AidlMapLayer; import net.osmand.plus.views.AidlMapLayer;
@ -73,6 +78,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
@ -101,6 +107,7 @@ public class OsmandAidlApi {
private static final String AIDL_DATA = "aidl_data"; private static final String AIDL_DATA = "aidl_data";
private static final String AIDL_URI = "aidl_uri"; private static final String AIDL_URI = "aidl_uri";
private static final String AIDL_FORCE = "aidl_force"; private static final String AIDL_FORCE = "aidl_force";
private static final String AIDL_SEARCH_QUERY = "aidl_search_query";
private static final String AIDL_OBJECT_ID = "aidl_object_id"; private static final String AIDL_OBJECT_ID = "aidl_object_id";
@ -117,6 +124,12 @@ public class OsmandAidlApi {
private static final String AIDL_NAVIGATE = "aidl_navigate"; private static final String AIDL_NAVIGATE = "aidl_navigate";
private static final String AIDL_NAVIGATE_GPX = "aidl_navigate_gpx"; private static final String AIDL_NAVIGATE_GPX = "aidl_navigate_gpx";
private static final String AIDL_NAVIGATE_SEARCH = "aidl_navigate_search";
private static final String AIDL_PAUSE_NAVIGATION = "pause_navigation";
private static final String AIDL_RESUME_NAVIGATION = "resume_navigation";
private static final String AIDL_STOP_NAVIGATION = "stop_navigation";
private static final String AIDL_MUTE_NAVIGATION = "mute_navigation";
private static final String AIDL_UNMUTE_NAVIGATION = "unmute_navigation";
private static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR; private static final ApplicationMode DEFAULT_PROFILE = ApplicationMode.CAR;
@ -135,14 +148,14 @@ public class OsmandAidlApi {
private Map<String, TextInfoWidget> widgetControls = new ConcurrentHashMap<>(); private Map<String, TextInfoWidget> widgetControls = new ConcurrentHashMap<>();
private Map<String, AMapLayer> layers = new ConcurrentHashMap<>(); private Map<String, AMapLayer> layers = new ConcurrentHashMap<>();
private Map<String, OsmandMapLayer> mapLayers = new ConcurrentHashMap<>(); private Map<String, OsmandMapLayer> mapLayers = new ConcurrentHashMap<>();
private Map<String, BroadcastReceiver> receivers = new TreeMap<String, BroadcastReceiver>(); private Map<String, BroadcastReceiver> receivers = new TreeMap<>();
public OsmandAidlApi(OsmandApplication app) { public OsmandAidlApi(OsmandApplication app) {
this.app = app; this.app = app;
} }
public void onCreateMapActivity(final MapActivity mapActivity) { public void onCreateMapActivity(MapActivity mapActivity) {
registerRefreshMapReceiver(mapActivity); registerRefreshMapReceiver(mapActivity);
registerSetMapLocationReceiver(mapActivity); registerSetMapLocationReceiver(mapActivity);
registerAddMapWidgetReceiver(mapActivity); registerAddMapWidgetReceiver(mapActivity);
@ -155,9 +168,15 @@ public class OsmandAidlApi {
registerStopRecordingReceiver(mapActivity); registerStopRecordingReceiver(mapActivity);
registerNavigateReceiver(mapActivity); registerNavigateReceiver(mapActivity);
registerNavigateGpxReceiver(mapActivity); registerNavigateGpxReceiver(mapActivity);
registerNavigateSearchReceiver(mapActivity);
registerPauseNavigationReceiver(mapActivity);
registerResumeNavigationReceiver(mapActivity);
registerStopNavigationReceiver(mapActivity);
registerMuteNavigationReceiver(mapActivity);
registerUnmuteNavigationReceiver(mapActivity);
} }
public void onDestroyMapActivity(final MapActivity mapActivity) { public void onDestroyMapActivity(MapActivity mapActivity) {
for (BroadcastReceiver b : receivers.values()) { for (BroadcastReceiver b : receivers.values()) {
if(b == null) { if(b == null) {
continue; continue;
@ -168,23 +187,30 @@ public class OsmandAidlApi {
LOG.error(e.getMessage(), e); LOG.error(e.getMessage(), e);
} }
} }
receivers = new TreeMap<String, BroadcastReceiver>(); receivers = new TreeMap<>();
} }
private void registerRefreshMapReceiver(final MapActivity mapActivity) { private void registerRefreshMapReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver refreshMapReceiver = new BroadcastReceiver() { BroadcastReceiver refreshMapReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) {
mapActivity.refreshMap(); mapActivity.refreshMap();
} }
}
}; };
registerReceiver(refreshMapReceiver, mapActivity, AIDL_REFRESH_MAP); registerReceiver(refreshMapReceiver, mapActivity, AIDL_REFRESH_MAP);
} }
private void registerSetMapLocationReceiver(final MapActivity mapActivity) { private void registerSetMapLocationReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver setMapLocationReceiver = new BroadcastReceiver() { BroadcastReceiver setMapLocationReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) {
double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN); double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN);
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN); double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
int zoom = intent.getIntExtra(AIDL_ZOOM, 0); int zoom = intent.getIntExtra(AIDL_ZOOM, 0);
@ -206,6 +232,7 @@ public class OsmandAidlApi {
} }
mapActivity.refreshMap(); mapActivity.refreshMap();
} }
}
}; };
registerReceiver(setMapLocationReceiver, mapActivity, AIDL_SET_MAP_LOCATION); registerReceiver(setMapLocationReceiver, mapActivity, AIDL_SET_MAP_LOCATION);
} }
@ -218,12 +245,14 @@ public class OsmandAidlApi {
} }
} }
private void registerAddMapWidgetReceiver(final MapActivity mapActivity) { private void registerAddMapWidgetReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver addMapWidgetReceiver = new BroadcastReceiver() { BroadcastReceiver addMapWidgetReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
String widgetId = intent.getStringExtra(AIDL_OBJECT_ID); String widgetId = intent.getStringExtra(AIDL_OBJECT_ID);
if (widgetId != null) { if (mapActivity != null && widgetId != null) {
AMapWidget widget = widgets.get(widgetId); AMapWidget widget = widgets.get(widgetId);
if (widget != null) { if (widget != null) {
MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer(); MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer();
@ -252,12 +281,14 @@ public class OsmandAidlApi {
ma.registerReceiver(rec, new IntentFilter(filter)); ma.registerReceiver(rec, new IntentFilter(filter));
} }
private void registerRemoveMapWidgetReceiver(final MapActivity mapActivity) { private void registerRemoveMapWidgetReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver removeMapWidgetReceiver = new BroadcastReceiver() { BroadcastReceiver removeMapWidgetReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
String widgetId = intent.getStringExtra(AIDL_OBJECT_ID); String widgetId = intent.getStringExtra(AIDL_OBJECT_ID);
if (widgetId != null) { if (mapActivity != null && widgetId != null) {
MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer(); MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer();
TextInfoWidget widgetControl = widgetControls.get(widgetId); TextInfoWidget widgetControl = widgetControls.get(widgetId);
if (layer != null && widgetControl != null) { if (layer != null && widgetControl != null) {
@ -288,12 +319,14 @@ public class OsmandAidlApi {
} }
} }
private void registerAddMapLayerReceiver(final MapActivity mapActivity) { private void registerAddMapLayerReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver addMapLayerReceiver = new BroadcastReceiver() { BroadcastReceiver addMapLayerReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
String layerId = intent.getStringExtra(AIDL_OBJECT_ID); String layerId = intent.getStringExtra(AIDL_OBJECT_ID);
if (layerId != null) { if (mapActivity != null && layerId != null) {
AMapLayer layer = layers.get(layerId); AMapLayer layer = layers.get(layerId);
if (layer != null) { if (layer != null) {
OsmandMapLayer mapLayer = mapLayers.get(layerId); OsmandMapLayer mapLayer = mapLayers.get(layerId);
@ -310,12 +343,14 @@ public class OsmandAidlApi {
registerReceiver(addMapLayerReceiver, mapActivity, AIDL_ADD_MAP_LAYER); registerReceiver(addMapLayerReceiver, mapActivity, AIDL_ADD_MAP_LAYER);
} }
private void registerRemoveMapLayerReceiver(final MapActivity mapActivity) { private void registerRemoveMapLayerReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver removeMapLayerReceiver = new BroadcastReceiver() { BroadcastReceiver removeMapLayerReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
String layerId = intent.getStringExtra(AIDL_OBJECT_ID); String layerId = intent.getStringExtra(AIDL_OBJECT_ID);
if (layerId != null) { if (mapActivity != null && layerId != null) {
OsmandMapLayer mapLayer = mapLayers.remove(layerId); OsmandMapLayer mapLayer = mapLayers.remove(layerId);
if (mapLayer != null) { if (mapLayer != null) {
mapActivity.getMapView().removeLayer(mapLayer); mapActivity.getMapView().removeLayer(mapLayer);
@ -327,12 +362,14 @@ public class OsmandAidlApi {
registerReceiver(removeMapLayerReceiver, mapActivity, AIDL_REMOVE_MAP_LAYER); registerReceiver(removeMapLayerReceiver, mapActivity, AIDL_REMOVE_MAP_LAYER);
} }
private void registerTakePhotoNoteReceiver(final MapActivity mapActivity) { private void registerTakePhotoNoteReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver takePhotoNoteReceiver = new BroadcastReceiver() { BroadcastReceiver takePhotoNoteReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class); final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
if (plugin != null) { if (mapActivity != null && plugin != null) {
double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN); double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN);
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN); double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
plugin.takePhoto(lat, lon, mapActivity, false, true); plugin.takePhoto(lat, lon, mapActivity, false, true);
@ -342,12 +379,14 @@ public class OsmandAidlApi {
registerReceiver(takePhotoNoteReceiver, mapActivity, AIDL_TAKE_PHOTO_NOTE); registerReceiver(takePhotoNoteReceiver, mapActivity, AIDL_TAKE_PHOTO_NOTE);
} }
private void registerStartVideoRecordingReceiver(final MapActivity mapActivity) { private void registerStartVideoRecordingReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver startVideoRecordingReceiver = new BroadcastReceiver() { BroadcastReceiver startVideoRecordingReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class); final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
if (plugin != null) { if (mapActivity != null && plugin != null) {
double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN); double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN);
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN); double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
plugin.recordVideo(lat, lon, mapActivity, true); plugin.recordVideo(lat, lon, mapActivity, true);
@ -357,12 +396,14 @@ public class OsmandAidlApi {
registerReceiver(startVideoRecordingReceiver, mapActivity, AIDL_START_VIDEO_RECORDING); registerReceiver(startVideoRecordingReceiver, mapActivity, AIDL_START_VIDEO_RECORDING);
} }
private void registerStartAudioRecordingReceiver(final MapActivity mapActivity) { private void registerStartAudioRecordingReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver startAudioRecordingReceiver = new BroadcastReceiver() { BroadcastReceiver startAudioRecordingReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class); final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
if (plugin != null) { if (mapActivity != null && plugin != null) {
double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN); double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN);
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN); double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
plugin.recordAudio(lat, lon, mapActivity); plugin.recordAudio(lat, lon, mapActivity);
@ -372,12 +413,14 @@ public class OsmandAidlApi {
registerReceiver(startAudioRecordingReceiver, mapActivity, AIDL_START_AUDIO_RECORDING); registerReceiver(startAudioRecordingReceiver, mapActivity, AIDL_START_AUDIO_RECORDING);
} }
private void registerStopRecordingReceiver(final MapActivity mapActivity) { private void registerStopRecordingReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver stopRecordingReceiver = new BroadcastReceiver() { BroadcastReceiver stopRecordingReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class); final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
if (plugin != null) { if (mapActivity != null && plugin != null) {
plugin.stopRecording(mapActivity, false); plugin.stopRecording(mapActivity, false);
} }
} }
@ -385,7 +428,8 @@ public class OsmandAidlApi {
registerReceiver(stopRecordingReceiver, mapActivity, AIDL_STOP_RECORDING); registerReceiver(stopRecordingReceiver, mapActivity, AIDL_STOP_RECORDING);
} }
private void registerNavigateReceiver(final MapActivity mapActivity) { private void registerNavigateReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver navigateReceiver = new BroadcastReceiver() { BroadcastReceiver navigateReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
@ -398,7 +442,8 @@ public class OsmandAidlApi {
break; break;
} }
} }
if (validProfile) { MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null && validProfile) {
String startName = intent.getStringExtra(AIDL_START_NAME); String startName = intent.getStringExtra(AIDL_START_NAME);
if (Algorithms.isEmpty(startName)) { if (Algorithms.isEmpty(startName)) {
startName = ""; startName = "";
@ -433,13 +478,14 @@ public class OsmandAidlApi {
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
if (!routingHelper.isFollowingMode()) { MapActivity mapActivity = mapActivityRef.get();
startNavigation(mapActivity, null, start, startDesc, dest, destDesc, profile); if (mapActivity != null && !routingHelper.isFollowingMode()) {
ExternalApiHelper.startNavigation(mapActivity, start, startDesc, dest, destDesc, profile);
} }
} }
}); });
} else { } else {
startNavigation(mapActivity, null, start, startDesc, dest, destDesc, profile); ExternalApiHelper.startNavigation(mapActivity, start, startDesc, dest, destDesc, profile);
} }
} }
} }
@ -447,12 +493,79 @@ public class OsmandAidlApi {
registerReceiver(navigateReceiver, mapActivity, AIDL_NAVIGATE); registerReceiver(navigateReceiver, mapActivity, AIDL_NAVIGATE);
} }
private void registerNavigateGpxReceiver(final MapActivity mapActivity) { private void registerNavigateSearchReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver navigateSearchReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
String profileStr = intent.getStringExtra(AIDL_PROFILE);
final ApplicationMode profile = ApplicationMode.valueOfStringKey(profileStr, DEFAULT_PROFILE);
boolean validProfile = false;
for (ApplicationMode mode : VALID_PROFILES) {
if (mode == profile) {
validProfile = true;
break;
}
}
MapActivity mapActivity = mapActivityRef.get();
final String searchQuery = intent.getStringExtra(AIDL_SEARCH_QUERY);
if (mapActivity != null && validProfile && !Algorithms.isEmpty(searchQuery)) {
String startName = intent.getStringExtra(AIDL_START_NAME);
if (Algorithms.isEmpty(startName)) {
startName = "";
}
final LatLon start;
final PointDescription startDesc;
double startLat = intent.getDoubleExtra(AIDL_START_LAT, 0);
double startLon = intent.getDoubleExtra(AIDL_START_LON, 0);
if (startLat != 0 && startLon != 0) {
start = new LatLon(startLat, startLon);
startDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, startName);
} else {
Location location = app.getLocationProvider().getLastKnownLocation();
if (location != null) {
start = new LatLon(location.getLatitude(), location.getLongitude());
startDesc = new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION, mapActivity.getString(R.string.shared_string_my_location));
} else {
start = null;
startDesc = null;
}
}
if (start != null) {
final RoutingHelper routingHelper = app.getRoutingHelper();
boolean force = intent.getBooleanExtra(AIDL_FORCE, true);
if (routingHelper.isFollowingMode() && !force) {
AlertDialog dlg = mapActivity.getMapActions().stopNavigationActionConfirm();
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null && !routingHelper.isFollowingMode()) {
ExternalApiHelper.searchAndNavigate(mapActivity, start, startDesc, profile, searchQuery);
}
}
});
} else {
ExternalApiHelper.searchAndNavigate(mapActivity, start, startDesc, profile, searchQuery);
}
}
}
}
};
registerReceiver(navigateSearchReceiver, mapActivity, AIDL_NAVIGATE_SEARCH);
}
private void registerNavigateGpxReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver navigateGpxReceiver = new BroadcastReceiver() { BroadcastReceiver navigateGpxReceiver = new BroadcastReceiver() {
@Override @Override
public void onReceive(Context context, Intent intent) { public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) {
boolean force = intent.getBooleanExtra(AIDL_FORCE, false); boolean force = intent.getBooleanExtra(AIDL_FORCE, false);
GPXFile gpx = null; GPXFile gpx = null;
if (intent.getStringExtra(AIDL_DATA) != null) { if (intent.getStringExtra(AIDL_DATA) != null) {
String gpxStr = intent.getStringExtra(AIDL_DATA); String gpxStr = intent.getStringExtra(AIDL_DATA);
@ -485,13 +598,15 @@ public class OsmandAidlApi {
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
if (!routingHelper.isFollowingMode()) { MapActivity mapActivity = mapActivityRef.get();
startNavigation(mapActivity, gpxFile, null, null, null, null, null); if (mapActivity != null && !routingHelper.isFollowingMode()) {
ExternalApiHelper.startNavigation(mapActivity, gpxFile);
} }
} }
}); });
} else { } else {
startNavigation(mapActivity, gpx, null, null, null, null, null); ExternalApiHelper.startNavigation(mapActivity, gpx);
}
} }
} }
} }
@ -499,35 +614,89 @@ public class OsmandAidlApi {
registerReceiver(navigateGpxReceiver, mapActivity, AIDL_NAVIGATE_GPX); registerReceiver(navigateGpxReceiver, mapActivity, AIDL_NAVIGATE_GPX);
} }
private void startNavigation(MapActivity mapActivity, private void registerPauseNavigationReceiver(MapActivity mapActivity) {
GPXFile gpx, final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
LatLon from, PointDescription fromDesc, BroadcastReceiver pauseNavigationReceiver = new BroadcastReceiver() {
LatLon to, PointDescription toDesc, @Override
ApplicationMode mode) { public void onReceive(Context context, Intent intent) {
OsmandApplication app = mapActivity.getMyApplication(); MapActivity mapActivity = mapActivityRef.get();
RoutingHelper routingHelper = app.getRoutingHelper(); if (mapActivity != null) {
if (gpx == null) { RoutingHelper routingHelper = mapActivity.getRoutingHelper();
app.getSettings().APPLICATION_MODE.set(mode); if (routingHelper.isRouteCalculated() && !routingHelper.isRoutePlanningMode()) {
final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper(); routingHelper.setRoutePlanningMode(true);
targets.removeAllWayPoints(false, true); routingHelper.setFollowingMode(false);
targets.navigateToPoint(to, true, -1, toDesc); routingHelper.setPauseNavigation(true);
} }
mapActivity.getMapActions().enterRoutePlanningModeGivenGpx(gpx, from, fromDesc, true, false);
if (!app.getTargetPointsHelper().checkPointToNavigateShort()) {
mapActivity.getMapLayers().getMapControlsLayer().getMapRouteInfoMenu().show();
} else {
if (app.getSettings().APPLICATION_MODE.get() != routingHelper.getAppMode()) {
app.getSettings().APPLICATION_MODE.set(routingHelper.getAppMode());
} }
mapActivity.getMapViewTrackingUtilities().backToLocationImpl(); }
app.getSettings().FOLLOW_THE_ROUTE.set(true); };
routingHelper.setFollowingMode(true); registerReceiver(pauseNavigationReceiver, mapActivity, AIDL_PAUSE_NAVIGATION);
}
private void registerResumeNavigationReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver resumeNavigationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (routingHelper.isRouteCalculated() && routingHelper.isRoutePlanningMode()) {
routingHelper.setRoutePlanningMode(false); routingHelper.setRoutePlanningMode(false);
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode(); routingHelper.setFollowingMode(true);
app.getRoutingHelper().notifyIfRouteIsCalculated();
routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false);
} }
} }
}
};
registerReceiver(resumeNavigationReceiver, mapActivity, AIDL_RESUME_NAVIGATION);
}
private void registerStopNavigationReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver stopNavigationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (routingHelper.isPauseNavigation() || routingHelper.isFollowingMode()) {
mapActivity.getMapLayers().getMapControlsLayer().stopNavigationWithoutConfirm();
}
}
}
};
registerReceiver(stopNavigationReceiver, mapActivity, AIDL_STOP_NAVIGATION);
}
private void registerMuteNavigationReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver muteNavigationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) {
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(true);
mapActivity.getRoutingHelper().getVoiceRouter().setMute(true);
}
}
};
registerReceiver(muteNavigationReceiver, mapActivity, AIDL_MUTE_NAVIGATION);
}
private void registerUnmuteNavigationReceiver(MapActivity mapActivity) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
BroadcastReceiver unmuteNavigationReceiver = new BroadcastReceiver() {
@Override
public void onReceive(Context context, Intent intent) {
MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) {
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(false);
mapActivity.getRoutingHelper().getVoiceRouter().setMute(false);
}
}
};
registerReceiver(unmuteNavigationReceiver, mapActivity, AIDL_UNMUTE_NAVIGATION);
}
public void registerMapLayers(MapActivity mapActivity) { public void registerMapLayers(MapActivity mapActivity) {
for (AMapLayer layer : layers.values()) { for (AMapLayer layer : layers.values()) {
@ -547,7 +716,7 @@ public class OsmandAidlApi {
app.sendBroadcast(intent); app.sendBroadcast(intent);
} }
private TextInfoWidget createWidgetControl(final MapActivity mapActivity, final String widgetId) { private TextInfoWidget createWidgetControl(MapActivity mapActivity, final String widgetId) {
final TextInfoWidget control = new TextInfoWidget(mapActivity) { final TextInfoWidget control = new TextInfoWidget(mapActivity) {
@Override @Override
@ -898,6 +1067,7 @@ public class OsmandAidlApi {
return false; return false;
} }
@SuppressLint("StaticFieldLeak")
private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) { private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) {
int col = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor( int col = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor(
app.getRendererRegistry().getCurrentSelectedRenderer(), color); app.getRendererRegistry().getCurrentSelectedRenderer(), color);
@ -1039,6 +1209,7 @@ public class OsmandAidlApi {
return false; return false;
} }
@SuppressLint("StaticFieldLeak")
boolean showGpx(String fileName) { boolean showGpx(String fileName) {
if (!Algorithms.isEmpty(fileName)) { if (!Algorithms.isEmpty(fileName)) {
File f = app.getAppPath(IndexConstants.GPX_INDEX_DIR + fileName); File f = app.getAppPath(IndexConstants.GPX_INDEX_DIR + fileName);
@ -1191,6 +1362,54 @@ public class OsmandAidlApi {
return true; return true;
} }
boolean navigateSearch(String startName, double startLat, double startLon, String searchQuery, String profile, boolean force) {
Intent intent = new Intent();
intent.setAction(AIDL_NAVIGATE_SEARCH);
intent.putExtra(AIDL_START_NAME, startName);
intent.putExtra(AIDL_START_LAT, startLat);
intent.putExtra(AIDL_START_LON, startLon);
intent.putExtra(AIDL_SEARCH_QUERY, searchQuery);
intent.putExtra(AIDL_PROFILE, profile);
intent.putExtra(AIDL_FORCE, force);
app.sendBroadcast(intent);
return true;
}
boolean pauseNavigation() {
Intent intent = new Intent();
intent.setAction(AIDL_PAUSE_NAVIGATION);
app.sendBroadcast(intent);
return true;
}
boolean resumeNavigation() {
Intent intent = new Intent();
intent.setAction(AIDL_RESUME_NAVIGATION);
app.sendBroadcast(intent);
return true;
}
boolean stopNavigation() {
Intent intent = new Intent();
intent.setAction(AIDL_STOP_NAVIGATION);
app.sendBroadcast(intent);
return true;
}
boolean muteNavigation() {
Intent intent = new Intent();
intent.setAction(AIDL_MUTE_NAVIGATION);
app.sendBroadcast(intent);
return true;
}
boolean unmuteNavigation() {
Intent intent = new Intent();
intent.setAction(AIDL_UNMUTE_NAVIGATION);
app.sendBroadcast(intent);
return true;
}
boolean navigateGpx(String data, Uri uri, boolean force) { boolean navigateGpx(String data, Uri uri, boolean force) {
Intent intent = new Intent(); Intent intent = new Intent();
intent.setAction(AIDL_NAVIGATE_GPX); intent.setAction(AIDL_NAVIGATE_GPX);
@ -1201,6 +1420,28 @@ public class OsmandAidlApi {
return true; return true;
} }
boolean search(final String searchQuery, final int searchType, final double latitude, final double longitude,
final int radiusLevel, final int totalLimit, final SearchCompleteCallback callback) {
if (Algorithms.isEmpty(searchQuery) || latitude == 0 || longitude == 0 || callback == null) {
return false;
}
if (app.isApplicationInitializing()) {
app.getAppInitializer().addListener(new AppInitializer.AppInitializeListener() {
@Override
public void onProgress(AppInitializer init, AppInitializer.InitEvents event) {
}
@Override
public void onFinish(AppInitializer init) {
ExternalApiHelper.runSearch(app, searchQuery, searchType, latitude, longitude, radiusLevel, totalLimit, callback);
}
});
} else {
ExternalApiHelper.runSearch(app, searchQuery, searchType, latitude, longitude, radiusLevel, totalLimit, callback);
}
return true;
}
boolean setNavDrawerItems(String appPackage, List<net.osmand.aidl.navdrawer.NavDrawerItem> items) { boolean setNavDrawerItems(String appPackage, List<net.osmand.aidl.navdrawer.NavDrawerItem> items) {
if (!TextUtils.isEmpty(appPackage) && items != null) { if (!TextUtils.isEmpty(appPackage) && items != null) {
if (items.isEmpty()) { if (items.isEmpty()) {
@ -1339,4 +1580,8 @@ public class OsmandAidlApi {
this.flags = flags; this.flags = flags;
} }
} }
public interface SearchCompleteCallback {
void onSearchComplete(List<SearchResult> resultSet);
}
} }

View file

@ -2,10 +2,12 @@ package net.osmand.aidl;
import android.app.Service; import android.app.Service;
import android.content.Intent; import android.content.Intent;
import android.os.Bundle;
import android.os.IBinder; import android.os.IBinder;
import android.os.RemoteException; import android.os.RemoteException;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.aidl.OsmandAidlApi.SearchCompleteCallback;
import net.osmand.aidl.calculateroute.CalculateRouteParams; import net.osmand.aidl.calculateroute.CalculateRouteParams;
import net.osmand.aidl.favorite.AddFavoriteParams; import net.osmand.aidl.favorite.AddFavoriteParams;
import net.osmand.aidl.favorite.RemoveFavoriteParams; import net.osmand.aidl.favorite.RemoveFavoriteParams;
@ -35,23 +37,34 @@ import net.osmand.aidl.mapwidget.AddMapWidgetParams;
import net.osmand.aidl.mapwidget.RemoveMapWidgetParams; import net.osmand.aidl.mapwidget.RemoveMapWidgetParams;
import net.osmand.aidl.mapwidget.UpdateMapWidgetParams; import net.osmand.aidl.mapwidget.UpdateMapWidgetParams;
import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams; import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams;
import net.osmand.aidl.navigation.MuteNavigationParams;
import net.osmand.aidl.navigation.NavigateGpxParams; import net.osmand.aidl.navigation.NavigateGpxParams;
import net.osmand.aidl.navigation.NavigateParams; import net.osmand.aidl.navigation.NavigateParams;
import net.osmand.aidl.navigation.NavigateSearchParams;
import net.osmand.aidl.navigation.PauseNavigationParams;
import net.osmand.aidl.navigation.ResumeNavigationParams;
import net.osmand.aidl.navigation.StopNavigationParams;
import net.osmand.aidl.navigation.UnmuteNavigationParams;
import net.osmand.aidl.note.StartAudioRecordingParams; import net.osmand.aidl.note.StartAudioRecordingParams;
import net.osmand.aidl.note.StartVideoRecordingParams; import net.osmand.aidl.note.StartVideoRecordingParams;
import net.osmand.aidl.note.StopRecordingParams; import net.osmand.aidl.note.StopRecordingParams;
import net.osmand.aidl.note.TakePhotoNoteParams; import net.osmand.aidl.note.TakePhotoNoteParams;
import net.osmand.aidl.search.SearchParams;
import net.osmand.aidl.search.SearchResult;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import java.util.ArrayList;
import java.util.List; import java.util.List;
public class OsmandAidlService extends Service { public class OsmandAidlService extends Service {
private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class); private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class);
private static final String DATA_KEY_RESULT_SET = "resultSet";
OsmandApplication getApp() { OsmandApplication getApp() {
return (OsmandApplication) getApplication(); return (OsmandApplication) getApplication();
} }
@ -71,7 +84,6 @@ public class OsmandAidlService extends Service {
private void handleException(Exception e) { private void handleException(Exception e) {
LOG.error("AIDL e.getMessage()", e); LOG.error("AIDL e.getMessage()", e);
} }
@Override @Override
@ -442,7 +454,10 @@ public class OsmandAidlService extends Service {
@Override @Override
public boolean navigate(NavigateParams params) throws RemoteException { public boolean navigate(NavigateParams params) throws RemoteException {
try { try {
return params != null && getApi("navigate").navigate(params.getStartName(), params.getStartLat(), params.getStartLon(), params.getDestName(), params.getDestLat(), params.getDestLon(), params.getProfile(), params.isForce()); return params != null && getApi("navigate").navigate(
params.getStartName(), params.getStartLat(), params.getStartLon(),
params.getDestName(), params.getDestLat(), params.getDestLon(),
params.getProfile(), params.isForce());
} catch (Exception e) { } catch (Exception e) {
handleException(e); handleException(e);
return false; return false;
@ -459,6 +474,56 @@ public class OsmandAidlService extends Service {
} }
} }
@Override
public boolean pauseNavigation(PauseNavigationParams params) throws RemoteException {
try {
return getApi("pauseNavigation").pauseNavigation();
} catch (Exception e) {
handleException(e);
return false;
}
}
@Override
public boolean resumeNavigation(ResumeNavigationParams params) throws RemoteException {
try {
return getApi("resumeNavigation").resumeNavigation();
} catch (Exception e) {
handleException(e);
return false;
}
}
@Override
public boolean stopNavigation(StopNavigationParams params) throws RemoteException {
try {
return getApi("stopNavigation").stopNavigation();
} catch (Exception e) {
handleException(e);
return false;
}
}
@Override
public boolean muteNavigation(MuteNavigationParams params) throws RemoteException {
try {
return getApi("muteNavigation").muteNavigation();
} catch (Exception e) {
handleException(e);
return false;
}
}
@Override
public boolean unmuteNavigation(UnmuteNavigationParams params) throws RemoteException {
try {
return getApi("unmuteNavigation").unmuteNavigation();
} catch (Exception e) {
handleException(e);
return false;
}
}
@Override @Override
public boolean setNavDrawerItems(SetNavDrawerItemsParams params) throws RemoteException { public boolean setNavDrawerItems(SetNavDrawerItemsParams params) throws RemoteException {
try { try {
@ -468,5 +533,41 @@ public class OsmandAidlService extends Service {
return false; return false;
} }
} }
@Override
public boolean search(SearchParams params, final IOsmAndAidlCallback callback) throws RemoteException {
try {
return params != null && getApi("search").search(params.getSearchQuery(), params.getSearchType(),
params.getLatitude(), params.getLongitude(), params.getRadiusLevel(), params.getTotalLimit(), new SearchCompleteCallback() {
@Override
public void onSearchComplete(List<SearchResult> resultSet) {
Bundle data = new Bundle();
if (resultSet.size() > 0) {
data.putParcelableArrayList(DATA_KEY_RESULT_SET, new ArrayList<>(resultSet));
}
try {
callback.onSearchComplete(resultSet);
} catch (RemoteException e) {
handleException(e);
}
}
});
} catch (Exception e) {
handleException(e);
return false;
}
}
@Override
public boolean navigateSearch(NavigateSearchParams params) throws RemoteException {
try {
return params != null && getApi("navigateSearch").navigateSearch(
params.getStartName(), params.getStartLat(), params.getStartLon(),
params.getSearchQuery(), params.getProfile(), params.isForce());
} catch (Exception e) {
handleException(e);
return false;
}
}
}; };
} }

View file

@ -12,6 +12,8 @@ import java.util.Map;
public class AMapPoint implements Parcelable { public class AMapPoint implements Parcelable {
public static final String POINT_IMAGE_URI_PARAM = "point_image_uri_param"; public static final String POINT_IMAGE_URI_PARAM = "point_image_uri_param";
public static final String POINT_SPEED_PARAM = "point_speed_param";
public static final String POINT_TYPE_ICON_NAME_PARAM = "point_type_icon_name_param";
private String id; private String id;
private String shortName; private String shortName;

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.navigation;
parcelable MuteNavigationParams;

View file

@ -0,0 +1,38 @@
package net.osmand.aidl.navigation;
import android.os.Parcel;
import android.os.Parcelable;
public class MuteNavigationParams implements Parcelable {
public MuteNavigationParams() {
}
public MuteNavigationParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<MuteNavigationParams> CREATOR = new Creator<MuteNavigationParams>() {
@Override
public MuteNavigationParams createFromParcel(Parcel in) {
return new MuteNavigationParams(in);
}
@Override
public MuteNavigationParams[] newArray(int size) {
return new MuteNavigationParams[size];
}
};
@Override
public void writeToParcel(Parcel out, int flags) {
}
private void readFromParcel(Parcel in) {
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.navigation;
parcelable NavigateSearchParams;

View file

@ -0,0 +1,88 @@
package net.osmand.aidl.navigation;
import android.os.Parcel;
import android.os.Parcelable;
public class NavigateSearchParams implements Parcelable {
private String startName;
private double startLat;
private double startLon;
private String searchQuery;
private String profile;
private boolean force;
public NavigateSearchParams(String startName, double startLat, double startLon, String searchQuery, String profile, boolean force) {
this.startName = startName;
this.startLat = startLat;
this.startLon = startLon;
this.searchQuery = searchQuery;
this.profile = profile;
this.force = force;
}
public NavigateSearchParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<NavigateSearchParams> CREATOR = new Creator<NavigateSearchParams>() {
@Override
public NavigateSearchParams createFromParcel(Parcel in) {
return new NavigateSearchParams(in);
}
@Override
public NavigateSearchParams[] newArray(int size) {
return new NavigateSearchParams[size];
}
};
public String getStartName() {
return startName;
}
public double getStartLat() {
return startLat;
}
public double getStartLon() {
return startLon;
}
public String getSearchQuery() {
return searchQuery;
}
public String getProfile() {
return profile;
}
public boolean isForce() {
return force;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeString(startName);
out.writeDouble(startLat);
out.writeDouble(startLon);
out.writeString(searchQuery);
out.writeString(profile);
out.writeByte((byte) (force ? 1 : 0));
}
private void readFromParcel(Parcel in) {
startName = in.readString();
startLat = in.readDouble();
startLon = in.readDouble();
searchQuery = in.readString();
profile = in.readString();
force = in.readByte() != 0;
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.navigation;
parcelable PauseNavigationParams;

View file

@ -0,0 +1,38 @@
package net.osmand.aidl.navigation;
import android.os.Parcel;
import android.os.Parcelable;
public class PauseNavigationParams implements Parcelable {
public PauseNavigationParams() {
}
public PauseNavigationParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<PauseNavigationParams> CREATOR = new Creator<PauseNavigationParams>() {
@Override
public PauseNavigationParams createFromParcel(Parcel in) {
return new PauseNavigationParams(in);
}
@Override
public PauseNavigationParams[] newArray(int size) {
return new PauseNavigationParams[size];
}
};
@Override
public void writeToParcel(Parcel out, int flags) {
}
private void readFromParcel(Parcel in) {
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.navigation;
parcelable ResumeNavigationParams;

View file

@ -0,0 +1,38 @@
package net.osmand.aidl.navigation;
import android.os.Parcel;
import android.os.Parcelable;
public class ResumeNavigationParams implements Parcelable {
public ResumeNavigationParams() {
}
public ResumeNavigationParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<ResumeNavigationParams> CREATOR = new Creator<ResumeNavigationParams>() {
@Override
public ResumeNavigationParams createFromParcel(Parcel in) {
return new ResumeNavigationParams(in);
}
@Override
public ResumeNavigationParams[] newArray(int size) {
return new ResumeNavigationParams[size];
}
};
@Override
public void writeToParcel(Parcel out, int flags) {
}
private void readFromParcel(Parcel in) {
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.navigation;
parcelable StopNavigationParams;

View file

@ -0,0 +1,38 @@
package net.osmand.aidl.navigation;
import android.os.Parcel;
import android.os.Parcelable;
public class StopNavigationParams implements Parcelable {
public StopNavigationParams() {
}
public StopNavigationParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<StopNavigationParams> CREATOR = new Creator<StopNavigationParams>() {
@Override
public StopNavigationParams createFromParcel(Parcel in) {
return new StopNavigationParams(in);
}
@Override
public StopNavigationParams[] newArray(int size) {
return new StopNavigationParams[size];
}
};
@Override
public void writeToParcel(Parcel out, int flags) {
}
private void readFromParcel(Parcel in) {
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.navigation;
parcelable UnmuteNavigationParams;

View file

@ -0,0 +1,38 @@
package net.osmand.aidl.navigation;
import android.os.Parcel;
import android.os.Parcelable;
public class UnmuteNavigationParams implements Parcelable {
public UnmuteNavigationParams() {
}
public UnmuteNavigationParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<UnmuteNavigationParams> CREATOR = new Creator<UnmuteNavigationParams>() {
@Override
public UnmuteNavigationParams createFromParcel(Parcel in) {
return new UnmuteNavigationParams(in);
}
@Override
public UnmuteNavigationParams[] newArray(int size) {
return new UnmuteNavigationParams[size];
}
};
@Override
public void writeToParcel(Parcel out, int flags) {
}
private void readFromParcel(Parcel in) {
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.search;
parcelable SearchParams;

View file

@ -0,0 +1,91 @@
package net.osmand.aidl.search;
import android.os.Parcel;
import android.os.Parcelable;
public class SearchParams implements Parcelable {
public static final int SEARCH_TYPE_POI = 1;
public static final int SEARCH_TYPE_ADDRESS = 2;
public static final int SEARCH_TYPE_ALL = SEARCH_TYPE_POI | SEARCH_TYPE_ADDRESS;
private String searchQuery;
private int searchType;
private double latitude;
private double longitude;
private int radiusLevel = 1;
private int totalLimit = -1;
public SearchParams(String searchQuery, int searchType, double latitude, double longitude, int radiusLevel, int totalLimit) {
this.searchQuery = searchQuery;
this.searchType = searchType;
this.latitude = latitude;
this.longitude = longitude;
this.radiusLevel = radiusLevel;
this.totalLimit = totalLimit;
}
public SearchParams(Parcel in) {
readFromParcel(in);
}
public static final Creator<SearchParams> CREATOR = new Creator<SearchParams>() {
@Override
public SearchParams createFromParcel(Parcel in) {
return new SearchParams(in);
}
@Override
public SearchParams[] newArray(int size) {
return new SearchParams[size];
}
};
public String getSearchQuery() {
return searchQuery;
}
public int getSearchType() {
return searchType;
}
public double getLatitude() {
return latitude;
}
public double getLongitude() {
return longitude;
}
public int getRadiusLevel() {
return radiusLevel;
}
public int getTotalLimit() {
return totalLimit;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeString(searchQuery);
out.writeInt(searchType);
out.writeDouble(latitude);
out.writeDouble(longitude);
out.writeInt(radiusLevel);
out.writeInt(totalLimit);
}
private void readFromParcel(Parcel in) {
searchQuery = in.readString();
searchType = in.readInt();
latitude = in.readDouble();
longitude = in.readDouble();
radiusLevel = in.readInt();
totalLimit = in.readInt();
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -0,0 +1,3 @@
package net.osmand.aidl.search;
parcelable SearchResult;

View file

@ -0,0 +1,96 @@
package net.osmand.aidl.search;
import android.os.Parcel;
import android.os.Parcelable;
import java.util.ArrayList;
import java.util.List;
public class SearchResult implements Parcelable {
private double latitude;
private double longitude;
private String localName;
private String localTypeName;
private String alternateName;
private List<String> otherNames = new ArrayList<>();
public SearchResult(double latitude, double longitude, String localName, String localTypeName,
String alternateName, List<String> otherNames) {
this.latitude = latitude;
this.longitude = longitude;
this.localName = localName;
this.localTypeName = localTypeName;
this.alternateName = alternateName;
if (otherNames != null) {
this.otherNames = otherNames;
}
}
public SearchResult(Parcel in) {
readFromParcel(in);
}
public static final Creator<SearchResult> CREATOR = new Creator<SearchResult>() {
@Override
public SearchResult createFromParcel(Parcel in) {
return new SearchResult(in);
}
@Override
public SearchResult[] newArray(int size) {
return new SearchResult[size];
}
};
public double getLatitude() {
return latitude;
}
public double getLongitude() {
return longitude;
}
public String getLocalName() {
return localName;
}
public String getLocalTypeName() {
return localTypeName;
}
public String getAlternateName() {
return alternateName;
}
public List<String> getOtherNames() {
return otherNames;
}
@Override
public void writeToParcel(Parcel out, int flags) {
out.writeDouble(latitude);
out.writeDouble(longitude);
out.writeString(localName);
out.writeString(localTypeName);
out.writeString(alternateName);
out.writeStringList(otherNames);
}
private void readFromParcel(Parcel in) {
latitude = in.readDouble();
longitude = in.readDouble();
localName = in.readString();
localTypeName = in.readString();
alternateName = in.readString();
in.readStringList(otherNames);
}
@Override
public int describeContents() {
return 0;
}
}

View file

@ -682,7 +682,7 @@ public class FirstUsageWizardFragment extends BaseOsmAndFragment implements OsmA
} }
for (BinaryMapDataObject o : mapDataObjects) { for (BinaryMapDataObject o : mapDataObjects) {
String fullName = osmandRegions.getFullName(o); String fullName = osmandRegions.getFullName(o);
if (fullName.length() > selectedFullName.length()) { if (fullName != null && fullName.length() > selectedFullName.length()) {
selectedFullName = fullName; selectedFullName = fullName;
} }
} }

View file

@ -1,17 +1,23 @@
package net.osmand.plus.helpers; package net.osmand.plus.helpers;
import android.app.Activity; import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface; import android.content.DialogInterface;
import android.content.Intent; import android.content.Intent;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.ParcelFileDescriptor; import android.os.ParcelFileDescriptor;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v7.app.AlertDialog; import android.support.v7.app.AlertDialog;
import net.osmand.AndroidUtils; import net.osmand.AndroidUtils;
import net.osmand.IndexConstants; import net.osmand.IndexConstants;
import net.osmand.Location; import net.osmand.Location;
import net.osmand.PlatformUtil; import net.osmand.PlatformUtil;
import net.osmand.aidl.OsmandAidlApi;
import net.osmand.aidl.search.SearchParams;
import net.osmand.aidl.search.SearchResult;
import net.osmand.data.FavouritePoint; import net.osmand.data.FavouritePoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
@ -23,6 +29,7 @@ import net.osmand.plus.MapMarkersHelper;
import net.osmand.plus.MapMarkersHelper.MapMarker; import net.osmand.plus.MapMarkersHelper.MapMarker;
import net.osmand.plus.OsmandApplication; import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandPlugin; import net.osmand.plus.OsmandPlugin;
import net.osmand.plus.R;
import net.osmand.plus.TargetPointsHelper; import net.osmand.plus.TargetPointsHelper;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.audionotes.AudioVideoNotesPlugin; import net.osmand.plus.audionotes.AudioVideoNotesPlugin;
@ -31,14 +38,30 @@ import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo; import net.osmand.plus.routing.RouteCalculationResult.NextDirectionInfo;
import net.osmand.plus.routing.RouteDirectionInfo; import net.osmand.plus.routing.RouteDirectionInfo;
import net.osmand.plus.routing.RoutingHelper; import net.osmand.plus.routing.RoutingHelper;
import net.osmand.plus.search.listitems.QuickSearchListItem;
import net.osmand.router.TurnType; import net.osmand.router.TurnType;
import net.osmand.search.SearchUICore;
import net.osmand.search.core.ObjectType;
import net.osmand.search.core.SearchSettings;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import java.io.ByteArrayInputStream; import java.io.ByteArrayInputStream;
import java.io.File; import java.io.File;
import java.io.FileDescriptor; import java.io.FileDescriptor;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.lang.ref.WeakReference;
import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List;
import static net.osmand.search.core.ObjectType.CITY;
import static net.osmand.search.core.ObjectType.HOUSE;
import static net.osmand.search.core.ObjectType.POI;
import static net.osmand.search.core.ObjectType.POSTCODE;
import static net.osmand.search.core.ObjectType.STREET;
import static net.osmand.search.core.ObjectType.STREET_INTERSECTION;
import static net.osmand.search.core.ObjectType.VILLAGE;
import static net.osmand.search.core.SearchCoreFactory.MAX_DEFAULT_SEARCH_RADIUS;
public class ExternalApiHelper { public class ExternalApiHelper {
private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(ExternalApiHelper.class); private static final org.apache.commons.logging.Log LOG = PlatformUtil.getLog(ExternalApiHelper.class);
@ -47,6 +70,13 @@ public class ExternalApiHelper {
public static final String API_CMD_NAVIGATE_GPX = "navigate_gpx"; public static final String API_CMD_NAVIGATE_GPX = "navigate_gpx";
public static final String API_CMD_NAVIGATE = "navigate"; public static final String API_CMD_NAVIGATE = "navigate";
public static final String API_CMD_NAVIGATE_SEARCH = "navigate_search";
public static final String API_CMD_PAUSE_NAVIGATION = "pause_navigation";
public static final String API_CMD_RESUME_NAVIGATION = "resume_navigation";
public static final String API_CMD_STOP_NAVIGATION = "stop_navigation";
public static final String API_CMD_MUTE_NAVIGATION = "mute_navigation";
public static final String API_CMD_UNMUTE_NAVIGATION = "unmute_navigation";
public static final String API_CMD_RECORD_AUDIO = "record_audio"; public static final String API_CMD_RECORD_AUDIO = "record_audio";
public static final String API_CMD_RECORD_VIDEO = "record_video"; public static final String API_CMD_RECORD_VIDEO = "record_video";
@ -86,6 +116,7 @@ public class ExternalApiHelper {
public static final String PARAM_START_LON = "start_lon"; public static final String PARAM_START_LON = "start_lon";
public static final String PARAM_DEST_LAT = "dest_lat"; public static final String PARAM_DEST_LAT = "dest_lat";
public static final String PARAM_DEST_LON = "dest_lon"; public static final String PARAM_DEST_LON = "dest_lon";
public static final String PARAM_DEST_SEARCH_QUERY = "dest_search_query";
public static final String PARAM_PROFILE = "profile"; public static final String PARAM_PROFILE = "profile";
public static final String PARAM_VERSION = "version"; public static final String PARAM_VERSION = "version";
@ -118,6 +149,8 @@ public class ExternalApiHelper {
public static final int RESULT_CODE_ERROR_PLUGIN_INACTIVE = 1003; public static final int RESULT_CODE_ERROR_PLUGIN_INACTIVE = 1003;
public static final int RESULT_CODE_ERROR_GPX_NOT_FOUND = 1004; public static final int RESULT_CODE_ERROR_GPX_NOT_FOUND = 1004;
public static final int RESULT_CODE_ERROR_INVALID_PROFILE = 1005; public static final int RESULT_CODE_ERROR_INVALID_PROFILE = 1005;
public static final int RESULT_CODE_ERROR_EMPTY_SEARCH_QUERY = 1006;
public static final int RESULT_CODE_ERROR_START_LOCATION_UNDEFINED = 1007;
private MapActivity mapActivity; private MapActivity mapActivity;
private int resultCode; private int resultCode;
@ -193,12 +226,12 @@ public class ExternalApiHelper {
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
if (!routingHelper.isFollowingMode()) { if (!routingHelper.isFollowingMode()) {
startNavigation(gpxFile, null, null, null, null, null); startNavigation(mapActivity, gpxFile);
} }
} }
}); });
} else { } else {
startNavigation(gpx, null, null, null, null, null); startNavigation(mapActivity, gpx);
} }
} else { } else {
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx); app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
@ -231,7 +264,6 @@ public class ExternalApiHelper {
destName = ""; destName = "";
} }
final LatLon start; final LatLon start;
final PointDescription startDesc; final PointDescription startDesc;
String startLatStr = uri.getQueryParameter(PARAM_START_LAT); String startLatStr = uri.getQueryParameter(PARAM_START_LAT);
@ -246,9 +278,16 @@ public class ExternalApiHelper {
startDesc = null; startDesc = null;
} }
double destLat = Double.parseDouble(uri.getQueryParameter(PARAM_DEST_LAT)); String destLatStr = uri.getQueryParameter(PARAM_DEST_LAT);
double destLon = Double.parseDouble(uri.getQueryParameter(PARAM_DEST_LON)); String destLonStr = uri.getQueryParameter(PARAM_DEST_LON);
final LatLon dest = new LatLon(destLat, destLon); final LatLon dest;
if (!Algorithms.isEmpty(destLatStr) && !Algorithms.isEmpty(destLonStr)) {
double destLat = Double.parseDouble(destLatStr);
double destLon = Double.parseDouble(destLonStr);
dest = new LatLon(destLat, destLon);
} else {
dest = null;
}
final PointDescription destDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, destName); final PointDescription destDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, destName);
boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false); boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false);
@ -261,15 +300,108 @@ public class ExternalApiHelper {
@Override @Override
public void onDismiss(DialogInterface dialog) { public void onDismiss(DialogInterface dialog) {
if (!routingHelper.isFollowingMode()) { if (!routingHelper.isFollowingMode()) {
startNavigation(null, start, startDesc, dest, destDesc, profile); startNavigation(mapActivity, start, startDesc, dest, destDesc, profile);
} }
} }
}); });
} else { } else {
startNavigation(null, start, startDesc, dest, destDesc, profile); startNavigation(mapActivity, start, startDesc, dest, destDesc, profile);
} }
} }
} else if (API_CMD_NAVIGATE_SEARCH.equals(cmd)) {
String profileStr = uri.getQueryParameter(PARAM_PROFILE);
final ApplicationMode profile = ApplicationMode.valueOfStringKey(profileStr, DEFAULT_PROFILE);
boolean validProfile = false;
for (ApplicationMode mode : VALID_PROFILES) {
if (mode == profile) {
validProfile = true;
break;
}
}
final String searchQuery = uri.getQueryParameter(PARAM_DEST_SEARCH_QUERY);
if (Algorithms.isEmpty(searchQuery)) {
resultCode = RESULT_CODE_ERROR_EMPTY_SEARCH_QUERY;
} else if (!validProfile) {
resultCode = RESULT_CODE_ERROR_INVALID_PROFILE;
} else {
String startName = uri.getQueryParameter(PARAM_START_NAME);
if (Algorithms.isEmpty(startName)) {
startName = "";
}
final LatLon start;
final PointDescription startDesc;
String startLatStr = uri.getQueryParameter(PARAM_START_LAT);
String startLonStr = uri.getQueryParameter(PARAM_START_LON);
if (!Algorithms.isEmpty(startLatStr) && !Algorithms.isEmpty(startLonStr)) {
double lat = Double.parseDouble(uri.getQueryParameter(PARAM_START_LAT));
double lon = Double.parseDouble(uri.getQueryParameter(PARAM_START_LON));
start = new LatLon(lat, lon);
startDesc = new PointDescription(PointDescription.POINT_TYPE_LOCATION, startName);
} else {
Location location = app.getLocationProvider().getLastKnownLocation();
if (location != null) {
start = new LatLon(location.getLatitude(), location.getLongitude());
startDesc = new PointDescription(PointDescription.POINT_TYPE_MY_LOCATION, mapActivity.getString(R.string.shared_string_my_location));
} else {
start = null;
startDesc = null;
}
}
if (start == null) {
resultCode = RESULT_CODE_ERROR_START_LOCATION_UNDEFINED;
} else {
boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false);
final RoutingHelper routingHelper = app.getRoutingHelper();
if (routingHelper.isFollowingMode() && !force) {
AlertDialog dlg = mapActivity.getMapActions().stopNavigationActionConfirm();
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
if (!routingHelper.isFollowingMode()) {
searchAndNavigate(mapActivity, start, startDesc, profile, searchQuery);
}
}
});
} else {
searchAndNavigate(mapActivity, start, startDesc, profile, searchQuery);
}
resultCode = Activity.RESULT_OK;
}
}
} else if (API_CMD_PAUSE_NAVIGATION.equals(cmd)) {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (routingHelper.isRouteCalculated() && !routingHelper.isRoutePlanningMode()) {
routingHelper.setRoutePlanningMode(true);
routingHelper.setFollowingMode(false);
routingHelper.setPauseNavigation(true);
resultCode = Activity.RESULT_OK;
}
} else if (API_CMD_RESUME_NAVIGATION.equals(cmd)) {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (routingHelper.isRouteCalculated() && routingHelper.isRoutePlanningMode()) {
routingHelper.setRoutePlanningMode(false);
routingHelper.setFollowingMode(true);
resultCode = Activity.RESULT_OK;
}
} else if (API_CMD_STOP_NAVIGATION.equals(cmd)) {
RoutingHelper routingHelper = mapActivity.getRoutingHelper();
if (routingHelper.isPauseNavigation() || routingHelper.isFollowingMode()) {
mapActivity.getMapLayers().getMapControlsLayer().stopNavigationWithoutConfirm();
resultCode = Activity.RESULT_OK;
}
} else if (API_CMD_MUTE_NAVIGATION.equals(cmd)) {
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(true);
mapActivity.getRoutingHelper().getVoiceRouter().setMute(true);
resultCode = Activity.RESULT_OK;
} else if (API_CMD_UNMUTE_NAVIGATION.equals(cmd)) {
mapActivity.getMyApplication().getSettings().VOICE_MUTE.set(false);
mapActivity.getRoutingHelper().getVoiceRouter().setMute(false);
resultCode = Activity.RESULT_OK;
} else if (API_CMD_RECORD_AUDIO.equals(cmd) } else if (API_CMD_RECORD_AUDIO.equals(cmd)
|| API_CMD_RECORD_VIDEO.equals(cmd) || API_CMD_RECORD_VIDEO.equals(cmd)
|| API_CMD_RECORD_PHOTO.equals(cmd) || API_CMD_RECORD_PHOTO.equals(cmd)
@ -452,7 +584,20 @@ public class ExternalApiHelper {
mapContextMenu.show(new LatLon(lat, lon), pointDescription, object); mapContextMenu.show(new LatLon(lat, lon), pointDescription, object);
} }
private void startNavigation(GPXFile gpx, static public void startNavigation(MapActivity mapActivity,
@NonNull GPXFile gpx) {
startNavigation(mapActivity, gpx, null, null, null, null, null);
}
static public void startNavigation(MapActivity mapActivity,
@Nullable LatLon from, @Nullable PointDescription fromDesc,
@Nullable LatLon to, @Nullable PointDescription toDesc,
@NonNull ApplicationMode mode) {
startNavigation(mapActivity, null, from, fromDesc, to, toDesc, mode);
}
static private void startNavigation(MapActivity mapActivity,
GPXFile gpx,
LatLon from, PointDescription fromDesc, LatLon from, PointDescription fromDesc,
LatLon to, PointDescription toDesc, LatLon to, PointDescription toDesc,
ApplicationMode mode) { ApplicationMode mode) {
@ -481,6 +626,104 @@ public class ExternalApiHelper {
} }
} }
static public void searchAndNavigate(@NonNull MapActivity mapActivity,
@NonNull final LatLon from, @Nullable final PointDescription fromDesc,
@NonNull final ApplicationMode mode, @NonNull final String searchQuery) {
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
OsmandApplication app = mapActivity.getMyApplication();
ProgressDialog dlg = new ProgressDialog(mapActivity);
dlg.setTitle("");
dlg.setMessage(mapActivity.getString(R.string.searching_address));
dlg.show();
final WeakReference<ProgressDialog> dlgRef = new WeakReference<>(dlg);
runSearch(app, searchQuery, SearchParams.SEARCH_TYPE_ALL,
from.getLatitude(), from.getLongitude(), 1, 1, new OsmandAidlApi.SearchCompleteCallback() {
@Override
public void onSearchComplete(final List<SearchResult> resultSet) {
final MapActivity mapActivity = mapActivityRef.get();
if (mapActivity != null) {
mapActivity.getMyApplication().runInUIThread(new Runnable() {
@Override
public void run() {
ProgressDialog dlg = dlgRef.get();
if (dlg != null) {
dlg.dismiss();
}
if (resultSet.size() > 0) {
final SearchResult res = resultSet.get(0);
LatLon to = new LatLon(res.getLatitude(), res.getLongitude());
PointDescription toDesc = new PointDescription(PointDescription.POINT_TYPE_TARGET, res.getLocalName() + ", " + res.getLocalTypeName());
startNavigation(mapActivity, from, fromDesc, to, toDesc, mode);
} else {
mapActivity.getMyApplication().showToastMessage(mapActivity.getString(R.string.search_nothing_found));
}
}
});
}
}
});
}
static public void runSearch(final OsmandApplication app, String searchQuery, int searchType,
double latitude, double longitude, int radiusLevel,
int totalLimit, final OsmandAidlApi.SearchCompleteCallback callback) {
if (radiusLevel < 1) {
radiusLevel = 1;
} else if (radiusLevel > MAX_DEFAULT_SEARCH_RADIUS) {
radiusLevel = MAX_DEFAULT_SEARCH_RADIUS;
}
if (totalLimit <= 0) {
totalLimit = -1;
}
final int limit = totalLimit;
final SearchUICore core = app.getSearchUICore().getCore();
core.setOnResultsComplete(new Runnable() {
@Override
public void run() {
List<SearchResult> resultSet = new ArrayList<>();
SearchUICore.SearchResultCollection resultCollection = core.getCurrentSearchResult();
int count = 0;
for (net.osmand.search.core.SearchResult r : resultCollection.getCurrentSearchResults()) {
String name = QuickSearchListItem.getName(app, r);
String typeName = QuickSearchListItem.getTypeName(app, r);
SearchResult result = new SearchResult(r.location.getLatitude(), r.location.getLongitude(),
name, typeName, r.alternateName, new ArrayList<>(r.otherNames));
resultSet.add(result);
count++;
if (limit != -1 && count >= limit) {
break;
}
}
callback.onSearchComplete(resultSet);
}
});
SearchSettings searchSettings = new SearchSettings(core.getSearchSettings())
.setRadiusLevel(radiusLevel)
.setEmptyQueryAllowed(false)
.setSortByName(false)
.setOriginalLocation(new LatLon(latitude, longitude))
.setTotalLimit(totalLimit);
List<ObjectType> searchTypes = new ArrayList<>();
if ((searchType & SearchParams.SEARCH_TYPE_POI) != 0) {
searchTypes.add(POI);
}
if ((searchType & SearchParams.SEARCH_TYPE_ADDRESS) != 0) {
searchTypes.add(CITY);
searchTypes.add(VILLAGE);
searchTypes.add(POSTCODE);
searchTypes.add(STREET);
searchTypes.add(HOUSE);
searchTypes.add(STREET_INTERSECTION);
}
searchSettings = searchSettings.setSearchTypes(searchTypes.toArray(new ObjectType[searchTypes.size()]));
core.search(searchQuery, false, null, searchSettings);
}
public void testApi(OsmandApplication app, String command) { public void testApi(OsmandApplication app, String command) {
Uri uri = null; Uri uri = null;
Intent intent = null; Intent intent = null;

View file

@ -756,6 +756,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
} }
} }
@Nullable
public WeakReference<MapContextMenuFragment> findMenuFragment() { public WeakReference<MapContextMenuFragment> findMenuFragment() {
Fragment fragment = mapActivity != null Fragment fragment = mapActivity != null
? mapActivity.getSupportFragmentManager().findFragmentByTag(MapContextMenuFragment.TAG) : null; ? mapActivity.getSupportFragmentManager().findFragmentByTag(MapContextMenuFragment.TAG) : null;

View file

@ -1,36 +1,5 @@
package net.osmand.plus.mapcontextmenu; package net.osmand.plus.mapcontextmenu;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
import java.util.List;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.LockableScrollView;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
import net.osmand.plus.views.controls.SingleTapConfirm;
import net.osmand.util.Algorithms;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.annotation.TargetApi; import android.annotation.TargetApi;
@ -66,6 +35,38 @@ import android.widget.OverScroller;
import android.widget.ProgressBar; import android.widget.ProgressBar;
import android.widget.TextView; import android.widget.TextView;
import net.osmand.AndroidUtils;
import net.osmand.data.LatLon;
import net.osmand.data.PointDescription;
import net.osmand.data.QuadPoint;
import net.osmand.data.RotatedTileBox;
import net.osmand.plus.LockableScrollView;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.OsmandSettings;
import net.osmand.plus.R;
import net.osmand.plus.UiUtilities.UpdateLocationViewCache;
import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.base.BaseOsmAndFragment;
import net.osmand.plus.download.DownloadIndexesThread.DownloadEvents;
import net.osmand.plus.mapcontextmenu.MenuController.MenuState;
import net.osmand.plus.mapcontextmenu.MenuController.TitleButtonController;
import net.osmand.plus.mapcontextmenu.MenuController.TitleProgressController;
import net.osmand.plus.mapcontextmenu.controllers.TransportStopController;
import net.osmand.plus.mapcontextmenu.other.MapRouteInfoMenu;
import net.osmand.plus.transport.TransportStopRoute;
import net.osmand.plus.views.AnimateDraggingMapThread;
import net.osmand.plus.views.OsmandMapTileView;
import net.osmand.plus.views.TransportStopsLayer;
import net.osmand.plus.views.controls.HorizontalSwipeConfirm;
import net.osmand.plus.views.controls.SingleTapConfirm;
import net.osmand.util.Algorithms;
import java.util.List;
import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static net.osmand.plus.mapcontextmenu.MenuBuilder.SHADOW_HEIGHT_TOP_DP;
public class MapContextMenuFragment extends BaseOsmAndFragment implements DownloadEvents { public class MapContextMenuFragment extends BaseOsmAndFragment implements DownloadEvents {
public static final String TAG = "MapContextMenuFragment"; public static final String TAG = "MapContextMenuFragment";
@ -1478,7 +1479,8 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
TextView additionalInfoTextView = (TextView) view.findViewById(R.id.additional_info_text_view); TextView additionalInfoTextView = (TextView) view.findViewById(R.id.additional_info_text_view);
CharSequence additionalInfoStr = menu.getAdditionalInfo(); CharSequence additionalInfoStr = menu.getAdditionalInfo();
boolean showAdditionalImage = false; boolean showAdditionalImage = false;
if (!TextUtils.isEmpty(additionalInfoStr)) { boolean showAdditionalInfo = !TextUtils.isEmpty(additionalInfoStr);
if (showAdditionalInfo) {
int colorId = menu.getAdditionalInfoColor(); int colorId = menu.getAdditionalInfoColor();
int additionalInfoIconRes = menu.getAdditionalInfoIconRes(); int additionalInfoIconRes = menu.getAdditionalInfoIconRes();
if (colorId != 0) { if (colorId != 0) {
@ -1495,6 +1497,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
additionalInfoTextView.setVisibility(View.GONE); additionalInfoTextView.setVisibility(View.GONE);
} }
additionalInfoImageView.setVisibility(showAdditionalImage ? View.VISIBLE : View.GONE); additionalInfoImageView.setVisibility(showAdditionalImage ? View.VISIBLE : View.GONE);
boolean showSeparator = showAdditionalInfo && menu.displayDistanceDirection();
view.findViewById(R.id.info_compass_separator)
.setVisibility(showSeparator ? View.VISIBLE : View.GONE);
} }
updateCompassVisibility(); updateCompassVisibility();
updateAdditionalInfoVisibility(); updateAdditionalInfoVisibility();

View file

@ -416,6 +416,9 @@ public class MenuBuilder {
} }
private void startLoadingImages() { private void startLoadingImages() {
if (onlinePhotoCardsRow == null) {
return;
}
onlinePhotoCards = new ArrayList<>(); onlinePhotoCards = new ArrayList<>();
onlinePhotoCardsRow.setProgressCard(); onlinePhotoCardsRow.setProgressCard();
execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(), execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(),
@ -433,7 +436,9 @@ public class MenuBuilder {
if (cardList.size() == 0) { if (cardList.size() == 0) {
cards.add(new NoImagesCard(mapActivity)); cards.add(new NoImagesCard(mapActivity));
} }
if (onlinePhotoCardsRow != null) {
onlinePhotoCardsRow.setCards(cards); onlinePhotoCardsRow.setCards(cards);
}
onlinePhotoCards = cards; onlinePhotoCards = cards;
} }
} }

View file

@ -12,6 +12,8 @@ import android.text.TextUtils;
import net.osmand.aidl.maplayer.point.AMapPoint; import net.osmand.aidl.maplayer.point.AMapPoint;
import net.osmand.data.LatLon; import net.osmand.data.LatLon;
import net.osmand.data.PointDescription; import net.osmand.data.PointDescription;
import net.osmand.plus.OsmAndFormatter;
import net.osmand.plus.OsmandApplication;
import net.osmand.plus.R; import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.mapcontextmenu.MenuBuilder; import net.osmand.plus.mapcontextmenu.MenuBuilder;
@ -24,6 +26,9 @@ import java.io.InputStream;
public class AMapPointMenuController extends MenuController { public class AMapPointMenuController extends MenuController {
private static final float NO_SPEED = -1;
private static final int NO_ICON = 0;
private AMapPoint point; private AMapPoint point;
private Drawable pointDrawable; private Drawable pointDrawable;
@ -74,11 +79,11 @@ public class AMapPointMenuController extends MenuController {
@Override @Override
public Drawable getSecondLineTypeIcon() { public Drawable getSecondLineTypeIcon() {
if (!Algorithms.isEmpty(point.getShortName())) { int id = getPointTypeIconId();
return getIcon(R.drawable.ic_small_group); if (id != NO_ICON) {
} else { return getIcon(id);
return null;
} }
return null;
} }
@NonNull @NonNull
@ -102,11 +107,64 @@ public class AMapPointMenuController extends MenuController {
} }
} }
@Override
public int getAdditionalInfoColorId() {
return R.color.icon_color;
}
@Override
public CharSequence getAdditionalInfoStr() {
MapActivity activity = getMapActivity();
if (activity != null) {
float speed = getPointSpeed();
if (speed != NO_SPEED) {
String formatted = OsmAndFormatter.getFormattedSpeed(speed, activity.getMyApplication());
return activity.getString(R.string.map_widget_speed) + ": " + formatted;
}
}
return super.getAdditionalInfoStr();
}
@Override
public int getAdditionalInfoIconRes() {
if (getPointSpeed() != NO_SPEED) {
return R.drawable.ic_action_speed_16;
}
return super.getAdditionalInfoIconRes();
}
@Override @Override
public boolean needStreetName() { public boolean needStreetName() {
return false; return false;
} }
private int getPointTypeIconId() {
MapActivity activity = getMapActivity();
if (activity != null) {
String iconName = point.getParams().get(AMapPoint.POINT_TYPE_ICON_NAME_PARAM);
if (!TextUtils.isEmpty(iconName)) {
OsmandApplication app = activity.getMyApplication();
return app.getResources().getIdentifier(iconName, "drawable", app.getPackageName());
}
}
if (!TextUtils.isEmpty(point.getShortName())) {
return R.drawable.ic_small_group;
}
return NO_ICON;
}
private float getPointSpeed() {
String speed = point.getParams().get(AMapPoint.POINT_SPEED_PARAM);
if (!TextUtils.isEmpty(speed)) {
try {
return Float.parseFloat(speed);
} catch (NumberFormatException e) {
return NO_SPEED;
}
}
return NO_SPEED;
}
@Nullable @Nullable
private Drawable getPointDrawable() { private Drawable getPointDrawable() {
MapActivity mapActivity = getMapActivity(); MapActivity mapActivity = getMapActivity();

View file

@ -44,16 +44,17 @@ public class MapMultiSelectionMenu extends BaseMenuController {
this.pointDescription = pointDescription; this.pointDescription = pointDescription;
this.object = object; this.object = object;
this.mapActivity = mapActivity; this.mapActivity = mapActivity;
if (mapActivity != null) {
init(); init();
} }
}
protected void init() { protected void init() {
MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
controller = MenuController.getMenuController(mapActivity, latLon, pointDescription, object, MenuType.MULTI_LINE); controller = MenuController.getMenuController(mapActivity, latLon, pointDescription, object, MenuType.MULTI_LINE);
controller.setActive(true); controller.setActive(true);
initTitle(); initTitle();
} }
}
protected void deinit() { protected void deinit() {
controller = null; controller = null;
@ -160,7 +161,10 @@ public class MapMultiSelectionMenu extends BaseMenuController {
private void clearMenu() { private void clearMenu() {
clearSelectedObjects(); clearSelectedObjects();
objects.clear(); objects.clear();
getMapActivity().refreshMap(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
mapActivity.refreshMap();
}
} }
public void show(LatLon latLon, Map<Object, IContextMenuProvider> selectedObjects) { public void show(LatLon latLon, Map<Object, IContextMenuProvider> selectedObjects) {
@ -170,8 +174,11 @@ public class MapMultiSelectionMenu extends BaseMenuController {
this.latLon = latLon; this.latLon = latLon;
createCollection(selectedObjects); createCollection(selectedObjects);
updateNightMode(); updateNightMode();
MapMultiSelectionMenuFragment.showInstance(getMapActivity()); MapActivity mapActivity = getMapActivity();
getMapActivity().refreshMap(); if (mapActivity != null) {
MapMultiSelectionMenuFragment.showInstance(mapActivity);
mapActivity.refreshMap();
}
} }
public boolean isVisible() { public boolean isVisible() {
@ -179,8 +186,14 @@ public class MapMultiSelectionMenu extends BaseMenuController {
return fragment != null; return fragment != null;
} }
@Nullable
public Fragment getFragmentByTag() { public Fragment getFragmentByTag() {
return getMapActivity().getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
return mapActivity.getSupportFragmentManager().findFragmentByTag(MapMultiSelectionMenuFragment.TAG);
} else {
return null;
}
} }
public void hide() { public void hide() {
@ -199,9 +212,12 @@ public class MapMultiSelectionMenu extends BaseMenuController {
public void openContextMenu(@NonNull MenuObject menuObject) { public void openContextMenu(@NonNull MenuObject menuObject) {
IContextMenuProvider provider = selectedObjects.remove(menuObject.getObject()); IContextMenuProvider provider = selectedObjects.remove(menuObject.getObject());
hide(); hide();
ContextMenuLayer contextMenuLayer = getMapActivity().getMapLayers().getContextMenuLayer(); MapActivity mapActivity = getMapActivity();
if (mapActivity != null) {
ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
contextMenuLayer.showContextMenu(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider); contextMenuLayer.showContextMenu(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
} }
}
private void clearSelectedObjects() { private void clearSelectedObjects() {
for(IContextMenuProvider p : selectedObjects.values()) { for(IContextMenuProvider p : selectedObjects.values()) {

View file

@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable;
import android.os.Bundle; import android.os.Bundle;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.support.annotation.Nullable; import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.text.Editable; import android.text.Editable;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextWatcher; import android.text.TextWatcher;
@ -31,6 +32,8 @@ import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
import org.apache.commons.logging.Log; import org.apache.commons.logging.Log;
import java.util.Map;
import gnu.trove.list.array.TIntArrayList; import gnu.trove.list.array.TIntArrayList;
public class BasicEditPoiFragment extends BaseOsmAndFragment public class BasicEditPoiFragment extends BaseOsmAndFragment
@ -123,11 +126,12 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
@Override @Override
public void afterTextChanged(Editable s) { public void afterTextChanged(Editable s) {
if (!getData().isInEdit()) { EditPoiData data = getData();
if (data != null && !data.isInEdit()) {
if (!TextUtils.isEmpty(s)) { if (!TextUtils.isEmpty(s)) {
getData().putTag(tag, s.toString()); data.putTag(tag, s.toString());
} else { } else {
getData().removeTag(tag); data.removeTag(tag);
} }
} }
} }
@ -145,30 +149,29 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
mOpeningHoursAdapter.setOpeningHoursRule(item, position); mOpeningHoursAdapter.setOpeningHoursRule(item, position);
} }
private EditPoiDialogFragment getEditPoiFragment() {
return (EditPoiDialogFragment) getParentFragment();
}
private EditPoiData getData() { private EditPoiData getData() {
return getEditPoiFragment().getEditPoiData(); Fragment parent = getParentFragment();
if (parent != null && parent instanceof EditPoiDialogFragment) {
return ((EditPoiDialogFragment) parent).getEditPoiData();
}
return null;
} }
@Override @Override
public void onFragmentActivated() { public void onFragmentActivated() {
streetEditText.setText(getData().getTagValues() EditPoiData data = getData();
.get(OSMSettings.OSMTagKey.ADDR_STREET.getValue())); if (data == null) {
houseNumberEditText.setText(getData().getTagValues() return;
.get(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue())); }
phoneEditText.setText(getData().getTagValues() Map<String, String> tagValues = data.getTagValues();
.get(OSMSettings.OSMTagKey.PHONE.getValue())); streetEditText.setText(tagValues.get(OSMSettings.OSMTagKey.ADDR_STREET.getValue()));
webSiteEditText.setText(getData().getTagValues() houseNumberEditText.setText(tagValues.get(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()));
.get(OSMSettings.OSMTagKey.WEBSITE.getValue())); phoneEditText.setText(tagValues.get(OSMSettings.OSMTagKey.PHONE.getValue()));
descriptionEditText.setText(getData().getTagValues() webSiteEditText.setText(tagValues.get(OSMSettings.OSMTagKey.WEBSITE.getValue()));
.get(OSMSettings.OSMTagKey.DESCRIPTION.getValue())); descriptionEditText.setText(tagValues.get(OSMSettings.OSMTagKey.DESCRIPTION.getValue()));
OpeningHoursParser.OpeningHours openingHours = OpeningHoursParser.OpeningHours openingHours =
OpeningHoursParser.parseOpenedHoursHandleErrors(getData().getTagValues() OpeningHoursParser.parseOpenedHoursHandleErrors(tagValues
.get(OSMSettings.OSMTagKey.OPENING_HOURS.getValue())); .get(OSMSettings.OSMTagKey.OPENING_HOURS.getValue()));
if (openingHours == null) { if (openingHours == null) {
openingHours = new OpeningHoursParser.OpeningHours(); openingHours = new OpeningHoursParser.OpeningHours();

View file

@ -707,7 +707,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
fragment.show(activity.getSupportFragmentManager(), TAG); fragment.show(activity.getSupportFragmentManager(), TAG);
} else { } else {
Toast.makeText(activity, Toast.makeText(activity,
activity.getString(R.string.poi_error_poi_not_found), activity.getString(R.string.poi_cannot_be_found),
Toast.LENGTH_LONG).show(); Toast.LENGTH_LONG).show();
} }
} }
@ -777,7 +777,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
public void deletePoiWithDialog(final Entity entity) { public void deletePoiWithDialog(final Entity entity) {
if (entity == null) { if (entity == null) {
Toast.makeText(activity, activity.getResources().getString(R.string.poi_error_poi_not_found), Toast.LENGTH_LONG).show(); Toast.makeText(activity, activity.getResources().getString(R.string.poi_cannot_be_found), Toast.LENGTH_LONG).show();
return; return;
} }
AlertDialog.Builder builder = new AlertDialog.Builder(activity); AlertDialog.Builder builder = new AlertDialog.Builder(activity);

View file

@ -33,8 +33,8 @@ public class NativeOsmandLibrary extends NativeLibrary {
if (!isLoaded()) { if (!isLoaded()) {
isNativeSupported = false; isNativeSupported = false;
try { try {
log.debug("Loading native gnustl_shared..."); //$NON-NLS-1$ log.debug("Loading native c++_shared..."); //$NON-NLS-1$
System.loadLibrary("gnustl_shared"); System.loadLibrary("c++_shared");
log.debug("Loading native libraries..."); //$NON-NLS-1$ log.debug("Loading native libraries..."); //$NON-NLS-1$
System.loadLibrary("osmand"); System.loadLibrary("osmand");
log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$ log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$

View file

@ -77,7 +77,7 @@ public class IncrementalChangesManager {
List<String> list = new ArrayList<String>(regionUpdateFiles.monthUpdates.keySet()); List<String> list = new ArrayList<String>(regionUpdateFiles.monthUpdates.keySet());
for (String month : list) { for (String month : list) {
RegionUpdate ru = regionUpdateFiles.monthUpdates.get(month); RegionUpdate ru = regionUpdateFiles.monthUpdates.get(month);
if (ru.obfCreated < dateCreated) { if (ru.obfCreated <= dateCreated) {
log.info("Delete overlapping month update " + ru.file.getName()); log.info("Delete overlapping month update " + ru.file.getName());
resourceManager.closeFile(ru.file.getName()); resourceManager.closeFile(ru.file.getName());
regionUpdateFiles.monthUpdates.remove(month); regionUpdateFiles.monthUpdates.remove(month);
@ -97,7 +97,7 @@ public class IncrementalChangesManager {
if(ru == null) { if(ru == null) {
continue; continue;
} }
if (ru.obfCreated < dateCreated || if (ru.obfCreated <= dateCreated ||
(monthRu != null && ru.obfCreated < monthRu.obfCreated)) { (monthRu != null && ru.obfCreated < monthRu.obfCreated)) {
log.info("Delete overlapping day update " + ru.file.getName()); log.info("Delete overlapping day update " + ru.file.getName());
resourceManager.closeFile(ru.file.getName()); resourceManager.closeFile(ru.file.getName());

View file

@ -645,10 +645,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
if (!app.getSettings().isInternetConnectionAvailable()) { if (!app.getSettings().isInternetConnectionAvailable()) {
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show(); Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
} else { } else {
if (location != null && searchQuery != null) { if (searchQuery != null) {
Bundle args = new Bundle(); Bundle args = new Bundle();
SendSearchQueryBottomSheet fragment = new SendSearchQueryBottomSheet(); SendSearchQueryBottomSheet fragment = new SendSearchQueryBottomSheet();
args.putString(MISSING_SEARCH_LOCATION_KEY, location.toString()); args.putString(MISSING_SEARCH_LOCATION_KEY, String.valueOf(location));
args.putString(MISSING_SEARCH_QUERY_KEY, searchQuery); args.putString(MISSING_SEARCH_QUERY_KEY, searchQuery);
fragment.setArguments(args); fragment.setArguments(args);
fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG); fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG);

View file

@ -17,6 +17,10 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem; import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
import net.osmand.util.Algorithms; import net.osmand.util.Algorithms;
import org.json.JSONException;
import org.json.JSONObject;
import java.text.MessageFormat;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
@ -37,7 +41,7 @@ public class SendSearchQueryBottomSheet extends MenuBottomSheetDialogFragment {
} }
String searchQuery = args.getString(MISSING_SEARCH_QUERY_KEY); String searchQuery = args.getString(MISSING_SEARCH_QUERY_KEY);
String searchLocation = args.getString(MISSING_SEARCH_LOCATION_KEY); String searchLocation = args.getString(MISSING_SEARCH_LOCATION_KEY);
if (Algorithms.isEmpty(searchQuery) || Algorithms.isEmpty(searchLocation)) { if (Algorithms.isEmpty(searchQuery)) {
return; return;
} }
params.put(searchQuery, searchLocation); params.put(searchQuery, searchLocation);
@ -63,15 +67,32 @@ public class SendSearchQueryBottomSheet extends MenuBottomSheetDialogFragment {
@Override @Override
protected void onRightBottomButtonClick() { protected void onRightBottomButtonClick() {
OsmandApplication app = getMyApplication(); final OsmandApplication app = getMyApplication();
if (app != null) { if (app != null) {
if (!app.getSettings().isInternetConnectionAvailable()) { if (!app.getSettings().isInternetConnectionAvailable()) {
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show(); Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
dismiss();
} else { } else {
AndroidNetworkUtils.sendRequestAsync(app, "http://osmand.net/api/missing_search", params, AndroidNetworkUtils.sendRequestAsync(app, "http://osmand.net/api/missing_search", params,
null, true, true, null); null, true, true, new AndroidNetworkUtils.OnRequestResultListener() {
@Override
public void onResult(String result) {
if (result != null && isAdded()) {
try {
JSONObject obj = new JSONObject(result);
if (!obj.has("error")) {
Toast.makeText(app, getString(R.string.thank_you_for_feedback), Toast.LENGTH_SHORT).show();
} else {
Toast.makeText(app, MessageFormat.format(getString(R.string.error_message_pattern), obj.getString("error")), Toast.LENGTH_SHORT).show();
}
} catch (JSONException e) {
} }
} }
dismiss(); dismiss();
} }
});
}
}
}
} }

View file

@ -173,8 +173,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
canvas.drawBitmap(image, null, getDstRect(x, y, smallIconSize / 2), bitmapPaint); canvas.drawBitmap(image, null, getDstRect(x, y, smallIconSize / 2), bitmapPaint);
} else if (pointsType == PointsType.BIG_ICON) { } else if (pointsType == PointsType.BIG_ICON) {
bitmapPaint.setColorFilter(null); bitmapPaint.setColorFilter(null);
// FIXME: vertical offset float vOffset = bigIconBg.getHeight() * 0.91f;
float vOffset = bigIconBg.getHeight() * 0.9f;
int imageCenterY = (int) (y - vOffset + bigIconBg.getHeight() / 2); int imageCenterY = (int) (y - vOffset + bigIconBg.getHeight() / 2);
canvas.drawBitmap(bigIconBg, x - bigIconBg.getWidth() / 2, y - vOffset, bitmapPaint); canvas.drawBitmap(bigIconBg, x - bigIconBg.getWidth() / 2, y - vOffset, bitmapPaint);
canvas.drawBitmap(image, null, getDstRect(x, imageCenterY, bigIconSize / 2), bitmapPaint); canvas.drawBitmap(image, null, getDstRect(x, imageCenterY, bigIconSize / 2), bitmapPaint);

View file

@ -363,6 +363,11 @@ public class MapControlsLayer extends OsmandMapLayer {
} }
} }
public void stopNavigationWithoutConfirm() {
mapRouteInfoMenu.hide();
mapActivity.getMapActions().stopNavigationWithoutConfirm();
}
protected void clickRouteCancel() { protected void clickRouteCancel() {
stopNavigation(); stopNavigation();
} }

View file

@ -10,6 +10,7 @@ import android.graphics.PointF;
import android.os.Build; import android.os.Build;
import android.os.Vibrator; import android.os.Vibrator;
import android.support.annotation.DimenRes; import android.support.annotation.DimenRes;
import android.support.v4.app.Fragment;
import android.support.v4.content.ContextCompat; import android.support.v4.content.ContextCompat;
import android.support.v4.util.Pair; import android.support.v4.util.Pair;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -32,12 +33,15 @@ import net.osmand.plus.R;
import net.osmand.plus.activities.MapActivity; import net.osmand.plus.activities.MapActivity;
import net.osmand.plus.helpers.AndroidUiHelper; import net.osmand.plus.helpers.AndroidUiHelper;
import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.MapContextMenu;
import net.osmand.plus.mapcontextmenu.MapContextMenuFragment;
import net.osmand.plus.mapcontextmenu.other.MapMultiSelectionMenu;
import net.osmand.plus.measurementtool.MeasurementToolLayer; import net.osmand.plus.measurementtool.MeasurementToolLayer;
import net.osmand.plus.quickaction.QuickAction; import net.osmand.plus.quickaction.QuickAction;
import net.osmand.plus.quickaction.QuickActionFactory; import net.osmand.plus.quickaction.QuickActionFactory;
import net.osmand.plus.quickaction.QuickActionRegistry; import net.osmand.plus.quickaction.QuickActionRegistry;
import net.osmand.plus.quickaction.QuickActionsWidget; import net.osmand.plus.quickaction.QuickActionsWidget;
import java.lang.ref.WeakReference;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -381,15 +385,20 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
} }
private void setupQuickActionBtnVisibility() { private void setupQuickActionBtnVisibility() {
MapContextMenu contextMenu = mapActivity.getContextMenu();
MapMultiSelectionMenu multiSelectionMenu = contextMenu.getMultiSelectionMenu();
WeakReference<MapContextMenuFragment> contextMenuMenuFragmentRef = contextMenu.findMenuFragment();
MapContextMenuFragment contextMenuMenuFragment = contextMenuMenuFragmentRef != null ? contextMenuMenuFragmentRef.get() : null;
Fragment multiMenuFragment = multiSelectionMenu.getFragmentByTag();
boolean hideQuickButton = !isLayerOn || boolean hideQuickButton = !isLayerOn ||
contextMenuLayer.isInChangeMarkerPositionMode() || contextMenuLayer.isInChangeMarkerPositionMode() ||
contextMenuLayer.isInGpxDetailsMode() || contextMenuLayer.isInGpxDetailsMode() ||
measurementToolLayer.isInMeasurementMode() || measurementToolLayer.isInMeasurementMode() ||
mapMarkersLayer.isInPlanRouteMode() || mapMarkersLayer.isInPlanRouteMode() ||
mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() || contextMenu.isVisible() && contextMenuMenuFragment != null && !contextMenuMenuFragment.isRemoving() ||
mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() || contextMenu.isVisible() && contextMenuMenuFragment != null && contextMenuMenuFragment.isAdded() ||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() || multiSelectionMenu.isVisible() && multiMenuFragment != null && multiMenuFragment.isAdded() ||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && !mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isRemoving(); multiSelectionMenu.isVisible() && multiMenuFragment != null && !multiMenuFragment.isRemoving();
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE); quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
} }

View file

@ -7,7 +7,7 @@ buildscript {
} }
dependencies { dependencies {
//classpath 'com.android.tools.build:gradle:2.+' //classpath 'com.android.tools.build:gradle:2.+'
classpath 'com.android.tools.build:gradle:3.1.3' classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:3.0.0' classpath 'com.google.gms:google-services:3.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }

View file

@ -17,4 +17,5 @@
# for enableD8=true min sdk must be > 22 # for enableD8=true min sdk must be > 22
# UPDATE: temporairly commented since gradle plugin updated to 3.1.3 and claims INSTALL_FAILED_DEXOPT is fixed # UPDATE: temporairly commented since gradle plugin updated to 3.1.3 and claims INSTALL_FAILED_DEXOPT is fixed
# android.enableD8=false # UPDATE 2: D8 causes problems on arm64 devices with Android 6.0 (API 23)
android.enableD8=false