Compare commits
28 commits
Author | SHA1 | Date | |
---|---|---|---|
|
d1161ce5d3 | ||
|
76d87db4a3 | ||
|
e23e835e75 | ||
|
2f6d331c42 | ||
|
c8bee8f39b | ||
|
191a3ef99d | ||
|
562cc114e0 | ||
|
381656f032 | ||
|
222e4f3c01 | ||
|
965d60aadb | ||
|
386b9ce5db | ||
|
2095f843be | ||
|
b167096be1 | ||
|
750cb432b0 | ||
|
b700856c14 | ||
|
e6ae64877a | ||
|
b037b98c11 | ||
|
ba1b92ee68 | ||
|
a0dd42e1e8 | ||
|
13fcd309c0 | ||
|
4c554f8fa2 | ||
|
e654d02241 | ||
|
c6d47c2f3f | ||
|
07ed7d8b72 | ||
|
83f88fa62a | ||
|
ed9c9d1949 | ||
|
c3318556f6 | ||
|
65153ba598 |
47 changed files with 1554 additions and 306 deletions
|
@ -401,6 +401,10 @@ public class SearchUICore {
|
|||
}
|
||||
|
||||
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 SearchPhrase phrase = this.phrase.generateNewPhrase(text, searchSettings);
|
||||
this.phrase = phrase;
|
||||
|
|
1
OsmAnd/.gitignore
vendored
1
OsmAnd/.gitignore
vendored
|
@ -27,6 +27,7 @@ local.properties
|
|||
raw/
|
||||
obj/
|
||||
libgnustl/
|
||||
libc++/
|
||||
cpd.xml
|
||||
jni/Local.mk
|
||||
out/
|
||||
|
|
|
@ -103,7 +103,7 @@ android {
|
|||
}
|
||||
|
||||
legacy {
|
||||
jniLibs.srcDirs = ["libgnustl"]
|
||||
jniLibs.srcDirs = ["libc++"]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -311,14 +311,12 @@ task cleanupDuplicatesInCore() {
|
|||
dependsOn buildOsmAndCore
|
||||
// doesn't work for legacy debug builds
|
||||
doLast {
|
||||
file("libgnustl/armeabi").mkdirs()
|
||||
file("libs/armeabi/libgnustl_shared.so").renameTo(file("libgnustl/armeabi/libgnustl_shared.so"))
|
||||
file("libgnustl/armeabi-v7a").mkdirs()
|
||||
file("libs/armeabi-v7a/libgnustl_shared.so").renameTo(file("libgnustl/armeabi-v7a/libgnustl_shared.so"))
|
||||
file("libgnustl/mips").mkdirs()
|
||||
file("libs/mips/libgnustl_shared.so").renameTo(file("libgnustl/mips/libgnustl_shared.so"))
|
||||
file("libgnustl/x86").mkdirs()
|
||||
file("libs/x86/libgnustl_shared.so").renameTo(file("libgnustl/x86/libgnustl_shared.so"))
|
||||
file("libc++/armeabi-v7a").mkdirs()
|
||||
file("libs/armeabi-v7a/libc++_shared.so").renameTo(file("libc++/armeabi-v7a/libc++_shared.so"))
|
||||
file("libc++/arm64-v8a").mkdirs()
|
||||
file("libs/arm64-v8a/libc++_shared.so").renameTo(file("libc++/arm64-v8a/libc++_shared.so"))
|
||||
file("libc++/x86").mkdirs()
|
||||
file("libs/x86/libc++_shared.so").renameTo(file("libc++/x86/libc++_shared.so"))
|
||||
}
|
||||
}
|
||||
afterEvaluate {
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
APP_STL := gnustl_shared
|
||||
# APP_STL := c++_shared
|
||||
# APP_STL := gnustl_shared
|
||||
APP_STL := c++_shared
|
||||
APP_CPPFLAGS := -std=c++11 -fexceptions -frtti
|
||||
APP_SHORT_COMMANDS := true
|
||||
|
||||
|
|
3
OsmAnd/libs/.gitignore
vendored
3
OsmAnd/libs/.gitignore
vendored
|
@ -1,4 +1,5 @@
|
|||
armeabi/
|
||||
x86/
|
||||
armeabi-v7a/
|
||||
mips/
|
||||
mips/
|
||||
arm64-v8a/
|
|
@ -99,26 +99,26 @@
|
|||
android:paddingTop="3dp">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/nearby_routes_within_text_view"
|
||||
style="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||
android:textSize="@dimen/default_sub_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
osmand:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<GridView
|
||||
android:layout_gravity="center_vertical"
|
||||
android:id="@+id/transport_stop_nearby_routes_grid"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:columnWidth="@dimen/context_menu_transport_grid_item_width"
|
||||
android:horizontalSpacing="@dimen/context_menu_transport_grid_spacing"
|
||||
android:numColumns="auto_fit"
|
||||
android:verticalSpacing="@dimen/context_menu_transport_grid_spacing"
|
||||
android:visibility="gone" />
|
||||
android:visibility="gone"/>
|
||||
</LinearLayout>
|
||||
|
||||
<LinearLayout
|
||||
|
@ -126,82 +126,93 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height= "wrap_content"
|
||||
android:layout_marginBottom="@dimen/context_menu_direction_margin"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:gravity="top"
|
||||
android:orientation="horizontal"
|
||||
android:paddingTop="3dp"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingLeft="@dimen/context_menu_padding_margin_default"
|
||||
android:paddingRight="@dimen/context_menu_padding_margin_default">
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/additional_info_row"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/context_menu_line3"
|
||||
style="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Some really long string"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/additional_info_image_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:paddingTop="1dp"
|
||||
android:paddingRight="@dimen/context_menu_padding_margin_small"
|
||||
tools:src="@drawable/ic_action_opening_hour_16"/>
|
||||
android:layout_marginBottom="@dimen/context_menu_direction_margin"
|
||||
android:layout_marginTop="@dimen/context_menu_padding_margin_tiny"
|
||||
android:gravity="top"
|
||||
android:orientation="horizontal"
|
||||
android:paddingBottom="3dp"
|
||||
android:paddingLeft="@dimen/context_menu_padding_margin_default"
|
||||
android:paddingRight="@dimen/context_menu_padding_margin_default"
|
||||
android:paddingTop="3dp">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/additional_info_text_view"
|
||||
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"
|
||||
tools:text="Closed till 10:00"/>
|
||||
|
||||
<LinearLayout
|
||||
android:id="@+id/compass_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/direction"
|
||||
android:layout_width="@dimen/directionIconSize"
|
||||
android:layout_height="@dimen/directionIconSize"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="1sp"
|
||||
tools:src="@drawable/ic_direction_arrow"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance"
|
||||
<LinearLayout
|
||||
android:id="@+id/additional_info_row"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="100500 km"
|
||||
tools:textColor="?android:textColorSecondary"/>
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<net.osmand.plus.widgets.TextViewEx
|
||||
android:id="@+id/context_menu_line3"
|
||||
style="@style/TextAppearance.ContextMenuSubtitle"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginEnd="@dimen/context_menu_padding_margin_small"
|
||||
android:layout_marginRight="@dimen/context_menu_padding_margin_small"
|
||||
android:layout_weight="1"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
osmand:typeface="@string/font_roboto_medium"
|
||||
tools:text="Some really long string"/>
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/additional_info_image_view"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="top"
|
||||
android:paddingRight="@dimen/context_menu_padding_margin_small"
|
||||
android:paddingTop="1dp"
|
||||
tools:src="@drawable/ic_action_opening_hour_16"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/additional_info_text_view"
|
||||
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"
|
||||
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
|
||||
android:id="@+id/compass_layout"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="horizontal">
|
||||
|
||||
<ImageView
|
||||
android:id="@+id/direction"
|
||||
android:layout_width="@dimen/directionIconSize"
|
||||
android:layout_height="@dimen/directionIconSize"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginTop="1sp"
|
||||
tools:src="@drawable/ic_direction_arrow"/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/distance"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_gravity="center_vertical"
|
||||
android:layout_marginLeft="2dp"
|
||||
android:layout_marginStart="2dp"
|
||||
android:textSize="@dimen/default_desc_text_size"
|
||||
tools:text="100500 km"
|
||||
tools:textColor="?android:textColorSecondary"/>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
|
@ -723,13 +734,13 @@
|
|||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
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:lines="1"
|
||||
android:maxLines="1"
|
||||
android:scaleType="center"
|
||||
android:singleLine="true"
|
||||
android:textColor="@color/abc_primary_text_material_dark"
|
||||
android:textSize="@dimen/abc_text_size_large_material"
|
||||
tools:text="Toolbar"
|
||||
tools:visibility="visible"/>
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
android:gravity="center_vertical"
|
||||
android:lines="1"
|
||||
android:singleLine="true"
|
||||
android:text="5 selected"
|
||||
tools:text="5 selected"
|
||||
android:textColor="@color/color_white"
|
||||
android:textSize="@dimen/default_list_text_size_large"/>
|
||||
|
||||
|
@ -237,7 +237,7 @@
|
|||
android:paddingLeft="@dimen/bottom_sheet_content_margin"
|
||||
android:paddingRight="@dimen/bottom_sheet_content_margin"
|
||||
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"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
||||
|
@ -264,7 +264,7 @@
|
|||
android:paddingLeft="@dimen/context_menu_padding_margin_small"
|
||||
android:paddingRight="@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:textSize="@dimen/default_desc_text_size"
|
||||
osmand:typeface="@string/font_roboto_medium" />
|
||||
|
|
|
@ -11,6 +11,9 @@
|
|||
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">
|
||||
• 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
|
||||
|
@ -23,7 +26,6 @@
|
|||
<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/>
|
||||
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="shared_string_world">World</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="poi_edit_title">Edit 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_title">Delete POI</string>
|
||||
<string name="poi_remove_success">POI deleted</string>
|
||||
|
|
7
OsmAnd/src/net/osmand/aidl/IOsmAndAidlCallback.aidl
Normal file
7
OsmAnd/src/net/osmand/aidl/IOsmAndAidlCallback.aidl
Normal file
|
@ -0,0 +1,7 @@
|
|||
package net.osmand.aidl;
|
||||
|
||||
import net.osmand.aidl.search.SearchResult;
|
||||
|
||||
interface IOsmAndAidlCallback {
|
||||
void onSearchComplete(in List<SearchResult> resultSet);
|
||||
}
|
|
@ -55,6 +55,18 @@ import net.osmand.aidl.maplayer.point.ShowMapPointParams;
|
|||
|
||||
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!!!
|
||||
|
||||
interface IOsmAndAidlInterface {
|
||||
|
@ -109,4 +121,13 @@ interface IOsmAndAidlInterface {
|
|||
boolean showMapPoint(in ShowMapPointParams 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);
|
||||
}
|
|
@ -1,5 +1,6 @@
|
|||
package net.osmand.aidl;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
|
@ -18,6 +19,7 @@ import android.view.View;
|
|||
import android.widget.ArrayAdapter;
|
||||
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.aidl.favorite.AFavorite;
|
||||
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.mapmarker.AMapMarker;
|
||||
import net.osmand.aidl.mapwidget.AMapWidget;
|
||||
import net.osmand.aidl.search.SearchResult;
|
||||
import net.osmand.data.FavouritePoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.AppInitializer;
|
||||
import net.osmand.plus.ApplicationMode;
|
||||
import net.osmand.plus.ContextMenuAdapter;
|
||||
import net.osmand.plus.ContextMenuItem;
|
||||
|
@ -44,11 +48,12 @@ import net.osmand.plus.MapMarkersHelper;
|
|||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
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.audionotes.AudioVideoNotesPlugin;
|
||||
import net.osmand.plus.dialogs.ConfigureMapMenu;
|
||||
import net.osmand.plus.helpers.ColorDialogs;
|
||||
import net.osmand.plus.helpers.ExternalApiHelper;
|
||||
import net.osmand.plus.monitoring.OsmandMonitoringPlugin;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.views.AidlMapLayer;
|
||||
|
@ -73,6 +78,7 @@ import java.io.FileNotFoundException;
|
|||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedHashMap;
|
||||
|
@ -101,6 +107,7 @@ public class OsmandAidlApi {
|
|||
private static final String AIDL_DATA = "aidl_data";
|
||||
private static final String AIDL_URI = "aidl_uri";
|
||||
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";
|
||||
|
||||
|
@ -117,6 +124,12 @@ public class OsmandAidlApi {
|
|||
|
||||
private static final String AIDL_NAVIGATE = "aidl_navigate";
|
||||
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;
|
||||
|
||||
|
@ -135,14 +148,14 @@ public class OsmandAidlApi {
|
|||
private Map<String, TextInfoWidget> widgetControls = new ConcurrentHashMap<>();
|
||||
private Map<String, AMapLayer> layers = 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) {
|
||||
this.app = app;
|
||||
}
|
||||
|
||||
public void onCreateMapActivity(final MapActivity mapActivity) {
|
||||
public void onCreateMapActivity(MapActivity mapActivity) {
|
||||
registerRefreshMapReceiver(mapActivity);
|
||||
registerSetMapLocationReceiver(mapActivity);
|
||||
registerAddMapWidgetReceiver(mapActivity);
|
||||
|
@ -155,9 +168,15 @@ public class OsmandAidlApi {
|
|||
registerStopRecordingReceiver(mapActivity);
|
||||
registerNavigateReceiver(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()) {
|
||||
if(b == null) {
|
||||
continue;
|
||||
|
@ -168,43 +187,51 @@ public class OsmandAidlApi {
|
|||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
mapActivity.refreshMap();
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
};
|
||||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN);
|
||||
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
|
||||
int zoom = intent.getIntExtra(AIDL_ZOOM, 0);
|
||||
boolean animated = intent.getBooleanExtra(AIDL_ANIMATED, false);
|
||||
if (!Double.isNaN(lat) && !Double.isNaN(lon)) {
|
||||
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
if (zoom == 0) {
|
||||
zoom = mapView.getZoom();
|
||||
} else {
|
||||
zoom = zoom > mapView.getMaxZoom() ? mapView.getMaxZoom() : zoom;
|
||||
zoom = zoom < mapView.getMinZoom() ? mapView.getMinZoom() : zoom;
|
||||
}
|
||||
if (animated) {
|
||||
mapView.getAnimatedDraggingThread().startMoving(lat, lon, zoom, true);
|
||||
} else {
|
||||
mapView.setLatLon(lat, lon);
|
||||
mapView.setIntZoom(zoom);
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null) {
|
||||
double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN);
|
||||
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
|
||||
int zoom = intent.getIntExtra(AIDL_ZOOM, 0);
|
||||
boolean animated = intent.getBooleanExtra(AIDL_ANIMATED, false);
|
||||
if (!Double.isNaN(lat) && !Double.isNaN(lon)) {
|
||||
OsmandMapTileView mapView = mapActivity.getMapView();
|
||||
if (zoom == 0) {
|
||||
zoom = mapView.getZoom();
|
||||
} else {
|
||||
zoom = zoom > mapView.getMaxZoom() ? mapView.getMaxZoom() : zoom;
|
||||
zoom = zoom < mapView.getMinZoom() ? mapView.getMinZoom() : zoom;
|
||||
}
|
||||
if (animated) {
|
||||
mapView.getAnimatedDraggingThread().startMoving(lat, lon, zoom, true);
|
||||
} else {
|
||||
mapView.setLatLon(lat, lon);
|
||||
mapView.setIntZoom(zoom);
|
||||
}
|
||||
}
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
};
|
||||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
String widgetId = intent.getStringExtra(AIDL_OBJECT_ID);
|
||||
if (widgetId != null) {
|
||||
if (mapActivity != null && widgetId != null) {
|
||||
AMapWidget widget = widgets.get(widgetId);
|
||||
if (widget != null) {
|
||||
MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer();
|
||||
|
@ -252,12 +281,14 @@ public class OsmandAidlApi {
|
|||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
String widgetId = intent.getStringExtra(AIDL_OBJECT_ID);
|
||||
if (widgetId != null) {
|
||||
if (mapActivity != null && widgetId != null) {
|
||||
MapInfoLayer layer = mapActivity.getMapLayers().getMapInfoLayer();
|
||||
TextInfoWidget widgetControl = widgetControls.get(widgetId);
|
||||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
String layerId = intent.getStringExtra(AIDL_OBJECT_ID);
|
||||
if (layerId != null) {
|
||||
if (mapActivity != null && layerId != null) {
|
||||
AMapLayer layer = layers.get(layerId);
|
||||
if (layer != null) {
|
||||
OsmandMapLayer mapLayer = mapLayers.get(layerId);
|
||||
|
@ -310,12 +343,14 @@ public class OsmandAidlApi {
|
|||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
String layerId = intent.getStringExtra(AIDL_OBJECT_ID);
|
||||
if (layerId != null) {
|
||||
if (mapActivity != null && layerId != null) {
|
||||
OsmandMapLayer mapLayer = mapLayers.remove(layerId);
|
||||
if (mapLayer != null) {
|
||||
mapActivity.getMapView().removeLayer(mapLayer);
|
||||
|
@ -327,12 +362,14 @@ public class OsmandAidlApi {
|
|||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
|
||||
if (plugin != null) {
|
||||
if (mapActivity != null && plugin != null) {
|
||||
double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN);
|
||||
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
|
||||
plugin.takePhoto(lat, lon, mapActivity, false, true);
|
||||
|
@ -342,12 +379,14 @@ public class OsmandAidlApi {
|
|||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
|
||||
if (plugin != null) {
|
||||
if (mapActivity != null && plugin != null) {
|
||||
double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN);
|
||||
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
|
||||
plugin.recordVideo(lat, lon, mapActivity, true);
|
||||
|
@ -357,12 +396,14 @@ public class OsmandAidlApi {
|
|||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
|
||||
if (plugin != null) {
|
||||
if (mapActivity != null && plugin != null) {
|
||||
double lat = intent.getDoubleExtra(AIDL_LATITUDE, Double.NaN);
|
||||
double lon = intent.getDoubleExtra(AIDL_LONGITUDE, Double.NaN);
|
||||
plugin.recordAudio(lat, lon, mapActivity);
|
||||
|
@ -372,12 +413,14 @@ public class OsmandAidlApi {
|
|||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
final AudioVideoNotesPlugin plugin = OsmandPlugin.getEnabledPlugin(AudioVideoNotesPlugin.class);
|
||||
if (plugin != null) {
|
||||
if (mapActivity != null && plugin != null) {
|
||||
plugin.stopRecording(mapActivity, false);
|
||||
}
|
||||
}
|
||||
|
@ -385,7 +428,8 @@ public class OsmandAidlApi {
|
|||
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() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
|
@ -398,7 +442,8 @@ public class OsmandAidlApi {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if (validProfile) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null && validProfile) {
|
||||
String startName = intent.getStringExtra(AIDL_START_NAME);
|
||||
if (Algorithms.isEmpty(startName)) {
|
||||
startName = "";
|
||||
|
@ -433,13 +478,14 @@ public class OsmandAidlApi {
|
|||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (!routingHelper.isFollowingMode()) {
|
||||
startNavigation(mapActivity, null, start, startDesc, dest, destDesc, profile);
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null && !routingHelper.isFollowingMode()) {
|
||||
ExternalApiHelper.startNavigation(mapActivity, start, startDesc, dest, destDesc, profile);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
startNavigation(mapActivity, null, start, startDesc, dest, destDesc, profile);
|
||||
ExternalApiHelper.startNavigation(mapActivity, start, startDesc, dest, destDesc, profile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -447,51 +493,120 @@ public class OsmandAidlApi {
|
|||
registerReceiver(navigateReceiver, mapActivity, AIDL_NAVIGATE);
|
||||
}
|
||||
|
||||
private void registerNavigateGpxReceiver(final MapActivity mapActivity) {
|
||||
BroadcastReceiver navigateGpxReceiver = new BroadcastReceiver() {
|
||||
private void registerNavigateSearchReceiver(MapActivity mapActivity) {
|
||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||
BroadcastReceiver navigateSearchReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
boolean force = intent.getBooleanExtra(AIDL_FORCE, false);
|
||||
|
||||
GPXFile gpx = null;
|
||||
if (intent.getStringExtra(AIDL_DATA) != null) {
|
||||
String gpxStr = intent.getStringExtra(AIDL_DATA);
|
||||
if (!Algorithms.isEmpty(gpxStr)) {
|
||||
gpx = GPXUtilities.loadGPXFile(mapActivity, new ByteArrayInputStream(gpxStr.getBytes()));
|
||||
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 = "";
|
||||
}
|
||||
} else if (intent.getParcelableExtra(AIDL_URI) != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
Uri gpxUri = intent.getParcelableExtra(AIDL_URI);
|
||||
|
||||
ParcelFileDescriptor gpxParcelDescriptor = null;
|
||||
try {
|
||||
gpxParcelDescriptor = mapActivity.getContentResolver().openFileDescriptor(gpxUri, "r");
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
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 (gpxParcelDescriptor != null) {
|
||||
FileDescriptor fileDescriptor = gpxParcelDescriptor.getFileDescriptor();
|
||||
gpx = GPXUtilities.loadGPXFile(mapActivity, new FileInputStream(fileDescriptor));
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
if (gpx != null) {
|
||||
final RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (routingHelper.isFollowingMode() && !force) {
|
||||
final GPXFile gpxFile = gpx;
|
||||
AlertDialog dlg = mapActivity.getMapActions().stopNavigationActionConfirm();
|
||||
dlg.setOnDismissListener(new DialogInterface.OnDismissListener() {
|
||||
private void registerNavigateGpxReceiver(MapActivity mapActivity) {
|
||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||
BroadcastReceiver navigateGpxReceiver = new BroadcastReceiver() {
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
MapActivity mapActivity = mapActivityRef.get();
|
||||
if (mapActivity != null) {
|
||||
boolean force = intent.getBooleanExtra(AIDL_FORCE, false);
|
||||
GPXFile gpx = null;
|
||||
if (intent.getStringExtra(AIDL_DATA) != null) {
|
||||
String gpxStr = intent.getStringExtra(AIDL_DATA);
|
||||
if (!Algorithms.isEmpty(gpxStr)) {
|
||||
gpx = GPXUtilities.loadGPXFile(mapActivity, new ByteArrayInputStream(gpxStr.getBytes()));
|
||||
}
|
||||
} else if (intent.getParcelableExtra(AIDL_URI) != null) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
|
||||
Uri gpxUri = intent.getParcelableExtra(AIDL_URI);
|
||||
|
||||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (!routingHelper.isFollowingMode()) {
|
||||
startNavigation(mapActivity, gpxFile, null, null, null, null, null);
|
||||
}
|
||||
ParcelFileDescriptor gpxParcelDescriptor = null;
|
||||
try {
|
||||
gpxParcelDescriptor = mapActivity.getContentResolver().openFileDescriptor(gpxUri, "r");
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
startNavigation(mapActivity, gpx, null, null, null, null, null);
|
||||
if (gpxParcelDescriptor != null) {
|
||||
FileDescriptor fileDescriptor = gpxParcelDescriptor.getFileDescriptor();
|
||||
gpx = GPXUtilities.loadGPXFile(mapActivity, new FileInputStream(fileDescriptor));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (gpx != null) {
|
||||
final RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (routingHelper.isFollowingMode() && !force) {
|
||||
final GPXFile gpxFile = gpx;
|
||||
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.startNavigation(mapActivity, gpxFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
ExternalApiHelper.startNavigation(mapActivity, gpx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -499,34 +614,88 @@ public class OsmandAidlApi {
|
|||
registerReceiver(navigateGpxReceiver, mapActivity, AIDL_NAVIGATE_GPX);
|
||||
}
|
||||
|
||||
private void startNavigation(MapActivity mapActivity,
|
||||
GPXFile gpx,
|
||||
LatLon from, PointDescription fromDesc,
|
||||
LatLon to, PointDescription toDesc,
|
||||
ApplicationMode mode) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (gpx == null) {
|
||||
app.getSettings().APPLICATION_MODE.set(mode);
|
||||
final TargetPointsHelper targets = mapActivity.getMyApplication().getTargetPointsHelper();
|
||||
targets.removeAllWayPoints(false, true);
|
||||
targets.navigateToPoint(to, true, -1, toDesc);
|
||||
}
|
||||
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());
|
||||
private void registerPauseNavigationReceiver(MapActivity mapActivity) {
|
||||
final WeakReference<MapActivity> mapActivityRef = new WeakReference<>(mapActivity);
|
||||
BroadcastReceiver pauseNavigationReceiver = 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(true);
|
||||
routingHelper.setFollowingMode(false);
|
||||
routingHelper.setPauseNavigation(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
mapActivity.getMapViewTrackingUtilities().backToLocationImpl();
|
||||
app.getSettings().FOLLOW_THE_ROUTE.set(true);
|
||||
routingHelper.setFollowingMode(true);
|
||||
routingHelper.setRoutePlanningMode(false);
|
||||
mapActivity.getMapViewTrackingUtilities().switchToRoutePlanningMode();
|
||||
app.getRoutingHelper().notifyIfRouteIsCalculated();
|
||||
routingHelper.setCurrentLocation(app.getLocationProvider().getLastKnownLocation(), false);
|
||||
}
|
||||
};
|
||||
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.setFollowingMode(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
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) {
|
||||
|
@ -547,7 +716,7 @@ public class OsmandAidlApi {
|
|||
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) {
|
||||
|
||||
@Override
|
||||
|
@ -898,6 +1067,7 @@ public class OsmandAidlApi {
|
|||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
private void finishGpxImport(boolean destinationExists, File destination, String color, boolean show) {
|
||||
int col = ConfigureMapMenu.GpxAppearanceAdapter.parseTrackColor(
|
||||
app.getRendererRegistry().getCurrentSelectedRenderer(), color);
|
||||
|
@ -1039,6 +1209,7 @@ public class OsmandAidlApi {
|
|||
return false;
|
||||
}
|
||||
|
||||
@SuppressLint("StaticFieldLeak")
|
||||
boolean showGpx(String fileName) {
|
||||
if (!Algorithms.isEmpty(fileName)) {
|
||||
File f = app.getAppPath(IndexConstants.GPX_INDEX_DIR + fileName);
|
||||
|
@ -1191,6 +1362,54 @@ public class OsmandAidlApi {
|
|||
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) {
|
||||
Intent intent = new Intent();
|
||||
intent.setAction(AIDL_NAVIGATE_GPX);
|
||||
|
@ -1201,6 +1420,28 @@ public class OsmandAidlApi {
|
|||
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) {
|
||||
if (!TextUtils.isEmpty(appPackage) && items != null) {
|
||||
if (items.isEmpty()) {
|
||||
|
@ -1339,4 +1580,8 @@ public class OsmandAidlApi {
|
|||
this.flags = flags;
|
||||
}
|
||||
}
|
||||
|
||||
public interface SearchCompleteCallback {
|
||||
void onSearchComplete(List<SearchResult> resultSet);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,10 +2,12 @@ package net.osmand.aidl;
|
|||
|
||||
import android.app.Service;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.os.IBinder;
|
||||
import android.os.RemoteException;
|
||||
|
||||
import net.osmand.PlatformUtil;
|
||||
import net.osmand.aidl.OsmandAidlApi.SearchCompleteCallback;
|
||||
import net.osmand.aidl.calculateroute.CalculateRouteParams;
|
||||
import net.osmand.aidl.favorite.AddFavoriteParams;
|
||||
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.UpdateMapWidgetParams;
|
||||
import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams;
|
||||
import net.osmand.aidl.navigation.MuteNavigationParams;
|
||||
import net.osmand.aidl.navigation.NavigateGpxParams;
|
||||
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.StartVideoRecordingParams;
|
||||
import net.osmand.aidl.note.StopRecordingParams;
|
||||
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.util.Algorithms;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class OsmandAidlService extends Service {
|
||||
|
||||
private static final Log LOG = PlatformUtil.getLog(OsmandAidlService.class);
|
||||
|
||||
private static final String DATA_KEY_RESULT_SET = "resultSet";
|
||||
|
||||
OsmandApplication getApp() {
|
||||
return (OsmandApplication) getApplication();
|
||||
}
|
||||
|
@ -71,7 +84,6 @@ public class OsmandAidlService extends Service {
|
|||
|
||||
private void handleException(Exception e) {
|
||||
LOG.error("AIDL e.getMessage()", e);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -442,7 +454,10 @@ public class OsmandAidlService extends Service {
|
|||
@Override
|
||||
public boolean navigate(NavigateParams params) throws RemoteException {
|
||||
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) {
|
||||
handleException(e);
|
||||
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
|
||||
public boolean setNavDrawerItems(SetNavDrawerItemsParams params) throws RemoteException {
|
||||
try {
|
||||
|
@ -468,5 +533,41 @@ public class OsmandAidlService extends Service {
|
|||
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;
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import java.util.Map;
|
|||
|
||||
public class AMapPoint implements Parcelable {
|
||||
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 shortName;
|
||||
|
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.navigation;
|
||||
|
||||
parcelable MuteNavigationParams;
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.navigation;
|
||||
|
||||
parcelable NavigateSearchParams;
|
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.navigation;
|
||||
|
||||
parcelable PauseNavigationParams;
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.navigation;
|
||||
|
||||
parcelable ResumeNavigationParams;
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.navigation;
|
||||
|
||||
parcelable StopNavigationParams;
|
|
@ -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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.navigation;
|
||||
|
||||
parcelable UnmuteNavigationParams;
|
|
@ -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;
|
||||
}
|
||||
}
|
3
OsmAnd/src/net/osmand/aidl/search/SearchParams.aidl
Normal file
3
OsmAnd/src/net/osmand/aidl/search/SearchParams.aidl
Normal file
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.search;
|
||||
|
||||
parcelable SearchParams;
|
91
OsmAnd/src/net/osmand/aidl/search/SearchParams.java
Normal file
91
OsmAnd/src/net/osmand/aidl/search/SearchParams.java
Normal 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;
|
||||
}
|
||||
}
|
3
OsmAnd/src/net/osmand/aidl/search/SearchResult.aidl
Normal file
3
OsmAnd/src/net/osmand/aidl/search/SearchResult.aidl
Normal file
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.search;
|
||||
|
||||
parcelable SearchResult;
|
96
OsmAnd/src/net/osmand/aidl/search/SearchResult.java
Normal file
96
OsmAnd/src/net/osmand/aidl/search/SearchResult.java
Normal 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;
|
||||
}
|
||||
}
|
|
@ -682,7 +682,7 @@ public class FirstUsageWizardFragment extends BaseOsmAndFragment implements OsmA
|
|||
}
|
||||
for (BinaryMapDataObject o : mapDataObjects) {
|
||||
String fullName = osmandRegions.getFullName(o);
|
||||
if (fullName.length() > selectedFullName.length()) {
|
||||
if (fullName != null && fullName.length() > selectedFullName.length()) {
|
||||
selectedFullName = fullName;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,17 +1,23 @@
|
|||
package net.osmand.plus.helpers;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.ProgressDialog;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.net.Uri;
|
||||
import android.os.Build;
|
||||
import android.os.ParcelFileDescriptor;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v7.app.AlertDialog;
|
||||
|
||||
import net.osmand.AndroidUtils;
|
||||
import net.osmand.IndexConstants;
|
||||
import net.osmand.Location;
|
||||
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.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
|
@ -23,6 +29,7 @@ import net.osmand.plus.MapMarkersHelper;
|
|||
import net.osmand.plus.MapMarkersHelper.MapMarker;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.OsmandPlugin;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.TargetPointsHelper;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
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.RouteDirectionInfo;
|
||||
import net.osmand.plus.routing.RoutingHelper;
|
||||
import net.osmand.plus.search.listitems.QuickSearchListItem;
|
||||
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 java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileDescriptor;
|
||||
import java.io.FileInputStream;
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
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 {
|
||||
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 = "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_VIDEO = "record_video";
|
||||
|
@ -86,6 +116,7 @@ public class ExternalApiHelper {
|
|||
public static final String PARAM_START_LON = "start_lon";
|
||||
public static final String PARAM_DEST_LAT = "dest_lat";
|
||||
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_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_GPX_NOT_FOUND = 1004;
|
||||
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 int resultCode;
|
||||
|
@ -193,12 +226,12 @@ public class ExternalApiHelper {
|
|||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (!routingHelper.isFollowingMode()) {
|
||||
startNavigation(gpxFile, null, null, null, null, null);
|
||||
startNavigation(mapActivity, gpxFile);
|
||||
}
|
||||
}
|
||||
});
|
||||
} else {
|
||||
startNavigation(gpx, null, null, null, null, null);
|
||||
startNavigation(mapActivity, gpx);
|
||||
}
|
||||
} else {
|
||||
app.getSelectedGpxHelper().setGpxFileToDisplay(gpx);
|
||||
|
@ -231,7 +264,6 @@ public class ExternalApiHelper {
|
|||
destName = "";
|
||||
}
|
||||
|
||||
|
||||
final LatLon start;
|
||||
final PointDescription startDesc;
|
||||
String startLatStr = uri.getQueryParameter(PARAM_START_LAT);
|
||||
|
@ -246,9 +278,16 @@ public class ExternalApiHelper {
|
|||
startDesc = null;
|
||||
}
|
||||
|
||||
double destLat = Double.parseDouble(uri.getQueryParameter(PARAM_DEST_LAT));
|
||||
double destLon = Double.parseDouble(uri.getQueryParameter(PARAM_DEST_LON));
|
||||
final LatLon dest = new LatLon(destLat, destLon);
|
||||
String destLatStr = uri.getQueryParameter(PARAM_DEST_LAT);
|
||||
String destLonStr = uri.getQueryParameter(PARAM_DEST_LON);
|
||||
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);
|
||||
|
||||
boolean force = uri.getBooleanQueryParameter(PARAM_FORCE, false);
|
||||
|
@ -261,15 +300,108 @@ public class ExternalApiHelper {
|
|||
@Override
|
||||
public void onDismiss(DialogInterface dialog) {
|
||||
if (!routingHelper.isFollowingMode()) {
|
||||
startNavigation(null, start, startDesc, dest, destDesc, profile);
|
||||
startNavigation(mapActivity, start, startDesc, dest, destDesc, profile);
|
||||
}
|
||||
}
|
||||
});
|
||||
} 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)
|
||||
|| API_CMD_RECORD_VIDEO.equals(cmd)
|
||||
|| API_CMD_RECORD_PHOTO.equals(cmd)
|
||||
|
@ -452,10 +584,23 @@ public class ExternalApiHelper {
|
|||
mapContextMenu.show(new LatLon(lat, lon), pointDescription, object);
|
||||
}
|
||||
|
||||
private void startNavigation(GPXFile gpx,
|
||||
LatLon from, PointDescription fromDesc,
|
||||
LatLon to, PointDescription toDesc,
|
||||
ApplicationMode mode) {
|
||||
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 to, PointDescription toDesc,
|
||||
ApplicationMode mode) {
|
||||
OsmandApplication app = mapActivity.getMyApplication();
|
||||
RoutingHelper routingHelper = app.getRoutingHelper();
|
||||
if (gpx == null) {
|
||||
|
@ -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) {
|
||||
Uri uri = null;
|
||||
Intent intent = null;
|
||||
|
|
|
@ -756,6 +756,7 @@ public class MapContextMenu extends MenuTitleController implements StateChangedL
|
|||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public WeakReference<MapContextMenuFragment> findMenuFragment() {
|
||||
Fragment fragment = mapActivity != null
|
||||
? mapActivity.getSupportFragmentManager().findFragmentByTag(MapContextMenuFragment.TAG) : null;
|
||||
|
|
|
@ -1,36 +1,5 @@
|
|||
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.AnimatorListenerAdapter;
|
||||
import android.annotation.TargetApi;
|
||||
|
@ -66,6 +35,38 @@ import android.widget.OverScroller;
|
|||
import android.widget.ProgressBar;
|
||||
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 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);
|
||||
CharSequence additionalInfoStr = menu.getAdditionalInfo();
|
||||
boolean showAdditionalImage = false;
|
||||
if (!TextUtils.isEmpty(additionalInfoStr)) {
|
||||
boolean showAdditionalInfo = !TextUtils.isEmpty(additionalInfoStr);
|
||||
if (showAdditionalInfo) {
|
||||
int colorId = menu.getAdditionalInfoColor();
|
||||
int additionalInfoIconRes = menu.getAdditionalInfoIconRes();
|
||||
if (colorId != 0) {
|
||||
|
@ -1495,6 +1497,10 @@ public class MapContextMenuFragment extends BaseOsmAndFragment implements Downlo
|
|||
additionalInfoTextView.setVisibility(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();
|
||||
updateAdditionalInfoVisibility();
|
||||
|
|
|
@ -416,6 +416,9 @@ public class MenuBuilder {
|
|||
}
|
||||
|
||||
private void startLoadingImages() {
|
||||
if (onlinePhotoCardsRow == null) {
|
||||
return;
|
||||
}
|
||||
onlinePhotoCards = new ArrayList<>();
|
||||
onlinePhotoCardsRow.setProgressCard();
|
||||
execute(new GetImageCardsTask(mapActivity, getLatLon(), getAdditionalCardParams(),
|
||||
|
@ -433,7 +436,9 @@ public class MenuBuilder {
|
|||
if (cardList.size() == 0) {
|
||||
cards.add(new NoImagesCard(mapActivity));
|
||||
}
|
||||
onlinePhotoCardsRow.setCards(cards);
|
||||
if (onlinePhotoCardsRow != null) {
|
||||
onlinePhotoCardsRow.setCards(cards);
|
||||
}
|
||||
onlinePhotoCards = cards;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,6 +12,8 @@ import android.text.TextUtils;
|
|||
import net.osmand.aidl.maplayer.point.AMapPoint;
|
||||
import net.osmand.data.LatLon;
|
||||
import net.osmand.data.PointDescription;
|
||||
import net.osmand.plus.OsmAndFormatter;
|
||||
import net.osmand.plus.OsmandApplication;
|
||||
import net.osmand.plus.R;
|
||||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.mapcontextmenu.MenuBuilder;
|
||||
|
@ -24,6 +26,9 @@ import java.io.InputStream;
|
|||
|
||||
public class AMapPointMenuController extends MenuController {
|
||||
|
||||
private static final float NO_SPEED = -1;
|
||||
private static final int NO_ICON = 0;
|
||||
|
||||
private AMapPoint point;
|
||||
|
||||
private Drawable pointDrawable;
|
||||
|
@ -74,11 +79,11 @@ public class AMapPointMenuController extends MenuController {
|
|||
|
||||
@Override
|
||||
public Drawable getSecondLineTypeIcon() {
|
||||
if (!Algorithms.isEmpty(point.getShortName())) {
|
||||
return getIcon(R.drawable.ic_small_group);
|
||||
} else {
|
||||
return null;
|
||||
int id = getPointTypeIconId();
|
||||
if (id != NO_ICON) {
|
||||
return getIcon(id);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@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
|
||||
public boolean needStreetName() {
|
||||
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
|
||||
private Drawable getPointDrawable() {
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
|
|
|
@ -44,15 +44,16 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
this.pointDescription = pointDescription;
|
||||
this.object = object;
|
||||
this.mapActivity = mapActivity;
|
||||
if (mapActivity != null) {
|
||||
init();
|
||||
}
|
||||
init();
|
||||
}
|
||||
|
||||
protected void init() {
|
||||
controller = MenuController.getMenuController(mapActivity, latLon, pointDescription, object, MenuType.MULTI_LINE);
|
||||
controller.setActive(true);
|
||||
initTitle();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
controller = MenuController.getMenuController(mapActivity, latLon, pointDescription, object, MenuType.MULTI_LINE);
|
||||
controller.setActive(true);
|
||||
initTitle();
|
||||
}
|
||||
}
|
||||
|
||||
protected void deinit() {
|
||||
|
@ -160,7 +161,10 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
private void clearMenu() {
|
||||
clearSelectedObjects();
|
||||
objects.clear();
|
||||
getMapActivity().refreshMap();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
public void show(LatLon latLon, Map<Object, IContextMenuProvider> selectedObjects) {
|
||||
|
@ -170,8 +174,11 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
this.latLon = latLon;
|
||||
createCollection(selectedObjects);
|
||||
updateNightMode();
|
||||
MapMultiSelectionMenuFragment.showInstance(getMapActivity());
|
||||
getMapActivity().refreshMap();
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
MapMultiSelectionMenuFragment.showInstance(mapActivity);
|
||||
mapActivity.refreshMap();
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isVisible() {
|
||||
|
@ -179,8 +186,14 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
return fragment != null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
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() {
|
||||
|
@ -199,8 +212,11 @@ public class MapMultiSelectionMenu extends BaseMenuController {
|
|||
public void openContextMenu(@NonNull MenuObject menuObject) {
|
||||
IContextMenuProvider provider = selectedObjects.remove(menuObject.getObject());
|
||||
hide();
|
||||
ContextMenuLayer contextMenuLayer = getMapActivity().getMapLayers().getContextMenuLayer();
|
||||
contextMenuLayer.showContextMenu(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
|
||||
MapActivity mapActivity = getMapActivity();
|
||||
if (mapActivity != null) {
|
||||
ContextMenuLayer contextMenuLayer = mapActivity.getMapLayers().getContextMenuLayer();
|
||||
contextMenuLayer.showContextMenu(menuObject.getLatLon(), menuObject.getPointDescription(), menuObject.getObject(), provider);
|
||||
}
|
||||
}
|
||||
|
||||
private void clearSelectedObjects() {
|
||||
|
|
|
@ -5,6 +5,7 @@ import android.graphics.drawable.Drawable;
|
|||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.text.Editable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextWatcher;
|
||||
|
@ -31,6 +32,8 @@ import net.osmand.util.OpeningHoursParser.BasicOpeningHourRule;
|
|||
|
||||
import org.apache.commons.logging.Log;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import gnu.trove.list.array.TIntArrayList;
|
||||
|
||||
public class BasicEditPoiFragment extends BaseOsmAndFragment
|
||||
|
@ -123,11 +126,12 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
|
|||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {
|
||||
if (!getData().isInEdit()) {
|
||||
EditPoiData data = getData();
|
||||
if (data != null && !data.isInEdit()) {
|
||||
if (!TextUtils.isEmpty(s)) {
|
||||
getData().putTag(tag, s.toString());
|
||||
data.putTag(tag, s.toString());
|
||||
} else {
|
||||
getData().removeTag(tag);
|
||||
data.removeTag(tag);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -145,30 +149,29 @@ public class BasicEditPoiFragment extends BaseOsmAndFragment
|
|||
mOpeningHoursAdapter.setOpeningHoursRule(item, position);
|
||||
}
|
||||
|
||||
|
||||
private EditPoiDialogFragment getEditPoiFragment() {
|
||||
return (EditPoiDialogFragment) getParentFragment();
|
||||
}
|
||||
|
||||
private EditPoiData getData() {
|
||||
return getEditPoiFragment().getEditPoiData();
|
||||
Fragment parent = getParentFragment();
|
||||
if (parent != null && parent instanceof EditPoiDialogFragment) {
|
||||
return ((EditPoiDialogFragment) parent).getEditPoiData();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFragmentActivated() {
|
||||
streetEditText.setText(getData().getTagValues()
|
||||
.get(OSMSettings.OSMTagKey.ADDR_STREET.getValue()));
|
||||
houseNumberEditText.setText(getData().getTagValues()
|
||||
.get(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()));
|
||||
phoneEditText.setText(getData().getTagValues()
|
||||
.get(OSMSettings.OSMTagKey.PHONE.getValue()));
|
||||
webSiteEditText.setText(getData().getTagValues()
|
||||
.get(OSMSettings.OSMTagKey.WEBSITE.getValue()));
|
||||
descriptionEditText.setText(getData().getTagValues()
|
||||
.get(OSMSettings.OSMTagKey.DESCRIPTION.getValue()));
|
||||
EditPoiData data = getData();
|
||||
if (data == null) {
|
||||
return;
|
||||
}
|
||||
Map<String, String> tagValues = data.getTagValues();
|
||||
streetEditText.setText(tagValues.get(OSMSettings.OSMTagKey.ADDR_STREET.getValue()));
|
||||
houseNumberEditText.setText(tagValues.get(OSMSettings.OSMTagKey.ADDR_HOUSE_NUMBER.getValue()));
|
||||
phoneEditText.setText(tagValues.get(OSMSettings.OSMTagKey.PHONE.getValue()));
|
||||
webSiteEditText.setText(tagValues.get(OSMSettings.OSMTagKey.WEBSITE.getValue()));
|
||||
descriptionEditText.setText(tagValues.get(OSMSettings.OSMTagKey.DESCRIPTION.getValue()));
|
||||
|
||||
OpeningHoursParser.OpeningHours openingHours =
|
||||
OpeningHoursParser.parseOpenedHoursHandleErrors(getData().getTagValues()
|
||||
OpeningHoursParser.parseOpenedHoursHandleErrors(tagValues
|
||||
.get(OSMSettings.OSMTagKey.OPENING_HOURS.getValue()));
|
||||
if (openingHours == null) {
|
||||
openingHours = new OpeningHoursParser.OpeningHours();
|
||||
|
|
|
@ -707,7 +707,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
fragment.show(activity.getSupportFragmentManager(), TAG);
|
||||
} else {
|
||||
Toast.makeText(activity,
|
||||
activity.getString(R.string.poi_error_poi_not_found),
|
||||
activity.getString(R.string.poi_cannot_be_found),
|
||||
Toast.LENGTH_LONG).show();
|
||||
}
|
||||
}
|
||||
|
@ -777,7 +777,7 @@ public class EditPoiDialogFragment extends BaseOsmAndDialogFragment {
|
|||
|
||||
public void deletePoiWithDialog(final Entity entity) {
|
||||
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;
|
||||
}
|
||||
AlertDialog.Builder builder = new AlertDialog.Builder(activity);
|
||||
|
|
|
@ -33,8 +33,8 @@ public class NativeOsmandLibrary extends NativeLibrary {
|
|||
if (!isLoaded()) {
|
||||
isNativeSupported = false;
|
||||
try {
|
||||
log.debug("Loading native gnustl_shared..."); //$NON-NLS-1$
|
||||
System.loadLibrary("gnustl_shared");
|
||||
log.debug("Loading native c++_shared..."); //$NON-NLS-1$
|
||||
System.loadLibrary("c++_shared");
|
||||
log.debug("Loading native libraries..."); //$NON-NLS-1$
|
||||
System.loadLibrary("osmand");
|
||||
log.debug("Creating NativeOsmandLibrary instance..."); //$NON-NLS-1$
|
||||
|
|
|
@ -77,7 +77,7 @@ public class IncrementalChangesManager {
|
|||
List<String> list = new ArrayList<String>(regionUpdateFiles.monthUpdates.keySet());
|
||||
for (String month : list) {
|
||||
RegionUpdate ru = regionUpdateFiles.monthUpdates.get(month);
|
||||
if (ru.obfCreated < dateCreated) {
|
||||
if (ru.obfCreated <= dateCreated) {
|
||||
log.info("Delete overlapping month update " + ru.file.getName());
|
||||
resourceManager.closeFile(ru.file.getName());
|
||||
regionUpdateFiles.monthUpdates.remove(month);
|
||||
|
@ -97,7 +97,7 @@ public class IncrementalChangesManager {
|
|||
if(ru == null) {
|
||||
continue;
|
||||
}
|
||||
if (ru.obfCreated < dateCreated ||
|
||||
if (ru.obfCreated <= dateCreated ||
|
||||
(monthRu != null && ru.obfCreated < monthRu.obfCreated)) {
|
||||
log.info("Delete overlapping day update " + ru.file.getName());
|
||||
resourceManager.closeFile(ru.file.getName());
|
||||
|
|
|
@ -645,10 +645,10 @@ public class QuickSearchDialogFragment extends DialogFragment implements OsmAndC
|
|||
if (!app.getSettings().isInternetConnectionAvailable()) {
|
||||
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
|
||||
} else {
|
||||
if (location != null && searchQuery != null) {
|
||||
if (searchQuery != null) {
|
||||
Bundle args = new Bundle();
|
||||
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);
|
||||
fragment.setArguments(args);
|
||||
fragment.show(mapActivity.getSupportFragmentManager(), SendSearchQueryBottomSheet.TAG);
|
||||
|
|
|
@ -17,6 +17,10 @@ import net.osmand.plus.base.bottomsheetmenu.SimpleBottomSheetItem;
|
|||
import net.osmand.plus.base.bottomsheetmenu.simpleitems.TitleItem;
|
||||
import net.osmand.util.Algorithms;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
@ -37,7 +41,7 @@ public class SendSearchQueryBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
}
|
||||
String searchQuery = args.getString(MISSING_SEARCH_QUERY_KEY);
|
||||
String searchLocation = args.getString(MISSING_SEARCH_LOCATION_KEY);
|
||||
if (Algorithms.isEmpty(searchQuery) || Algorithms.isEmpty(searchLocation)) {
|
||||
if (Algorithms.isEmpty(searchQuery)) {
|
||||
return;
|
||||
}
|
||||
params.put(searchQuery, searchLocation);
|
||||
|
@ -63,15 +67,32 @@ public class SendSearchQueryBottomSheet extends MenuBottomSheetDialogFragment {
|
|||
|
||||
@Override
|
||||
protected void onRightBottomButtonClick() {
|
||||
OsmandApplication app = getMyApplication();
|
||||
final OsmandApplication app = getMyApplication();
|
||||
if (app != null) {
|
||||
if (!app.getSettings().isInternetConnectionAvailable()) {
|
||||
Toast.makeText(app, R.string.internet_not_available, Toast.LENGTH_LONG).show();
|
||||
dismiss();
|
||||
} else {
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -173,8 +173,7 @@ public class AidlMapLayer extends OsmandMapLayer implements IContextMenuProvider
|
|||
canvas.drawBitmap(image, null, getDstRect(x, y, smallIconSize / 2), bitmapPaint);
|
||||
} else if (pointsType == PointsType.BIG_ICON) {
|
||||
bitmapPaint.setColorFilter(null);
|
||||
// FIXME: vertical offset
|
||||
float vOffset = bigIconBg.getHeight() * 0.9f;
|
||||
float vOffset = bigIconBg.getHeight() * 0.91f;
|
||||
int imageCenterY = (int) (y - vOffset + bigIconBg.getHeight() / 2);
|
||||
canvas.drawBitmap(bigIconBg, x - bigIconBg.getWidth() / 2, y - vOffset, bitmapPaint);
|
||||
canvas.drawBitmap(image, null, getDstRect(x, imageCenterY, bigIconSize / 2), bitmapPaint);
|
||||
|
|
|
@ -363,6 +363,11 @@ public class MapControlsLayer extends OsmandMapLayer {
|
|||
}
|
||||
}
|
||||
|
||||
public void stopNavigationWithoutConfirm() {
|
||||
mapRouteInfoMenu.hide();
|
||||
mapActivity.getMapActions().stopNavigationWithoutConfirm();
|
||||
}
|
||||
|
||||
protected void clickRouteCancel() {
|
||||
stopNavigation();
|
||||
}
|
||||
|
|
|
@ -10,6 +10,7 @@ import android.graphics.PointF;
|
|||
import android.os.Build;
|
||||
import android.os.Vibrator;
|
||||
import android.support.annotation.DimenRes;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.content.ContextCompat;
|
||||
import android.support.v4.util.Pair;
|
||||
import android.view.MotionEvent;
|
||||
|
@ -32,12 +33,15 @@ import net.osmand.plus.R;
|
|||
import net.osmand.plus.activities.MapActivity;
|
||||
import net.osmand.plus.helpers.AndroidUiHelper;
|
||||
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.quickaction.QuickAction;
|
||||
import net.osmand.plus.quickaction.QuickActionFactory;
|
||||
import net.osmand.plus.quickaction.QuickActionRegistry;
|
||||
import net.osmand.plus.quickaction.QuickActionsWidget;
|
||||
|
||||
import java.lang.ref.WeakReference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
@ -381,15 +385,20 @@ public class MapQuickActionLayer extends OsmandMapLayer implements QuickActionRe
|
|||
}
|
||||
|
||||
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 ||
|
||||
contextMenuLayer.isInChangeMarkerPositionMode() ||
|
||||
contextMenuLayer.isInGpxDetailsMode() ||
|
||||
measurementToolLayer.isInMeasurementMode() ||
|
||||
mapMarkersLayer.isInPlanRouteMode() ||
|
||||
mapActivity.getContextMenu().isVisible() && !mapActivity.getContextMenu().findMenuFragment().get().isRemoving() ||
|
||||
mapActivity.getContextMenu().isVisible() && mapActivity.getContextMenu().findMenuFragment().get().isAdded() ||
|
||||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isAdded() ||
|
||||
mapActivity.getContextMenu().getMultiSelectionMenu().isVisible() && !mapActivity.getContextMenu().getMultiSelectionMenu().getFragmentByTag().isRemoving();
|
||||
contextMenu.isVisible() && contextMenuMenuFragment != null && !contextMenuMenuFragment.isRemoving() ||
|
||||
contextMenu.isVisible() && contextMenuMenuFragment != null && contextMenuMenuFragment.isAdded() ||
|
||||
multiSelectionMenu.isVisible() && multiMenuFragment != null && multiMenuFragment.isAdded() ||
|
||||
multiSelectionMenu.isVisible() && multiMenuFragment != null && !multiMenuFragment.isRemoving();
|
||||
quickActionButton.setVisibility(hideQuickButton ? View.GONE : View.VISIBLE);
|
||||
}
|
||||
|
||||
|
|
|
@ -7,7 +7,7 @@ buildscript {
|
|||
}
|
||||
dependencies {
|
||||
//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 "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
|
|
|
@ -17,4 +17,5 @@
|
|||
|
||||
# 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
|
||||
# android.enableD8=false
|
||||
# UPDATE 2: D8 causes problems on arm64 devices with Android 6.0 (API 23)
|
||||
android.enableD8=false
|
||||
|
|
Loading…
Reference in a new issue