From d774c7575a2e5cc5742d504a9f7aa217ac56ed51 Mon Sep 17 00:00:00 2001 From: Chumva Date: Wed, 29 Aug 2018 12:14:20 +0300 Subject: [PATCH] Add missing search and navigation aidl to telegram app --- .../net/osmand/aidl/IOsmAndAidlCallback.aidl | 7 + .../net/osmand/aidl/IOsmAndAidlInterface.aidl | 19 +++ .../aidl/navigation/MuteNavigationParams.aidl | 3 + .../aidl/navigation/MuteNavigationParams.java | 38 ++++++ .../navigation/PauseNavigationParams.aidl | 3 + .../navigation/PauseNavigationParams.java | 38 ++++++ .../navigation/ResumeNavigationParams.aidl | 3 + .../navigation/ResumeNavigationParams.java | 38 ++++++ .../aidl/navigation/StopNavigationParams.aidl | 3 + .../aidl/navigation/StopNavigationParams.java | 38 ++++++ .../navigation/UnmuteNavigationParams.aidl | 3 + .../navigation/UnmuteNavigationParams.java | 38 ++++++ .../net/osmand/aidl/search/SearchParams.aidl | 3 + .../net/osmand/aidl/search/SearchParams.java | 91 +++++++++++++ .../net/osmand/aidl/search/SearchResult.aidl | 3 + .../net/osmand/aidl/search/SearchResult.java | 96 +++++++++++++ .../telegram/helpers/OsmandAidlHelper.kt | 127 +++++++++++++++++- 17 files changed, 549 insertions(+), 2 deletions(-) create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlCallback.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/MuteNavigationParams.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/MuteNavigationParams.java create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/PauseNavigationParams.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/PauseNavigationParams.java create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/ResumeNavigationParams.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/ResumeNavigationParams.java create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/StopNavigationParams.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/StopNavigationParams.java create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/UnmuteNavigationParams.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/navigation/UnmuteNavigationParams.java create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/search/SearchParams.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/search/SearchParams.java create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/search/SearchResult.aidl create mode 100644 OsmAnd-telegram/src/net/osmand/aidl/search/SearchResult.java diff --git a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlCallback.aidl b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlCallback.aidl new file mode 100644 index 0000000000..be9e753336 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlCallback.aidl @@ -0,0 +1,7 @@ +package net.osmand.aidl; + +import net.osmand.aidl.search.SearchResult; + +interface IOsmAndAidlCallback { + void onSearchComplete(in List resultSet); +} \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl index 0987fccfea..22efaa72dd 100644 --- a/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl +++ b/OsmAnd-telegram/src/net/osmand/aidl/IOsmAndAidlInterface.aidl @@ -55,6 +55,17 @@ 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; + // NOTE: Add new methods at the end of file!!! interface IOsmAndAidlInterface { @@ -109,4 +120,12 @@ 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); } \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/MuteNavigationParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/navigation/MuteNavigationParams.aidl new file mode 100644 index 0000000000..d1205adaf3 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/MuteNavigationParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.navigation; + +parcelable MuteNavigationParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/MuteNavigationParams.java b/OsmAnd-telegram/src/net/osmand/aidl/navigation/MuteNavigationParams.java new file mode 100644 index 0000000000..8965c415fa --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/MuteNavigationParams.java @@ -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 CREATOR = new Creator() { + @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; + } +} diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/PauseNavigationParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/navigation/PauseNavigationParams.aidl new file mode 100644 index 0000000000..0a18566304 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/PauseNavigationParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.navigation; + +parcelable PauseNavigationParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/PauseNavigationParams.java b/OsmAnd-telegram/src/net/osmand/aidl/navigation/PauseNavigationParams.java new file mode 100644 index 0000000000..5a28538039 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/PauseNavigationParams.java @@ -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 CREATOR = new Creator() { + @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; + } +} diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/ResumeNavigationParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/navigation/ResumeNavigationParams.aidl new file mode 100644 index 0000000000..4dcf619aaa --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/ResumeNavigationParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.navigation; + +parcelable ResumeNavigationParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/ResumeNavigationParams.java b/OsmAnd-telegram/src/net/osmand/aidl/navigation/ResumeNavigationParams.java new file mode 100644 index 0000000000..d1032dc914 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/ResumeNavigationParams.java @@ -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 CREATOR = new Creator() { + @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; + } +} diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/StopNavigationParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/navigation/StopNavigationParams.aidl new file mode 100644 index 0000000000..5ba45bdf50 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/StopNavigationParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.navigation; + +parcelable StopNavigationParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/StopNavigationParams.java b/OsmAnd-telegram/src/net/osmand/aidl/navigation/StopNavigationParams.java new file mode 100644 index 0000000000..e87d6ed2da --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/StopNavigationParams.java @@ -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 CREATOR = new Creator() { + @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; + } +} diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/UnmuteNavigationParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/navigation/UnmuteNavigationParams.aidl new file mode 100644 index 0000000000..7512bbcf34 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/UnmuteNavigationParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.navigation; + +parcelable UnmuteNavigationParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/navigation/UnmuteNavigationParams.java b/OsmAnd-telegram/src/net/osmand/aidl/navigation/UnmuteNavigationParams.java new file mode 100644 index 0000000000..36819db065 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/navigation/UnmuteNavigationParams.java @@ -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 CREATOR = new Creator() { + @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; + } +} diff --git a/OsmAnd-telegram/src/net/osmand/aidl/search/SearchParams.aidl b/OsmAnd-telegram/src/net/osmand/aidl/search/SearchParams.aidl new file mode 100644 index 0000000000..dfda88c493 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/search/SearchParams.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.search; + +parcelable SearchParams; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/search/SearchParams.java b/OsmAnd-telegram/src/net/osmand/aidl/search/SearchParams.java new file mode 100644 index 0000000000..32447f4b45 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/search/SearchParams.java @@ -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 latutude; + private double longitude; + private int radiusLevel = 1; + private int totalLimit = -1; + + public SearchParams(String searchQuery, int searchType, double latutude, double longitude, int radiusLevel, int totalLimit) { + this.searchQuery = searchQuery; + this.searchType = searchType; + this.latutude = latutude; + this.longitude = longitude; + this.radiusLevel = radiusLevel; + this.totalLimit = totalLimit; + } + + public SearchParams(Parcel in) { + readFromParcel(in); + } + + public static final Creator CREATOR = new Creator() { + @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 getLatutude() { + return latutude; + } + + 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(latutude); + out.writeDouble(longitude); + out.writeInt(radiusLevel); + out.writeInt(totalLimit); + } + + private void readFromParcel(Parcel in) { + searchQuery = in.readString(); + searchType = in.readInt(); + latutude = in.readDouble(); + longitude = in.readDouble(); + radiusLevel = in.readInt(); + totalLimit = in.readInt(); + } + + @Override + public int describeContents() { + return 0; + } +} diff --git a/OsmAnd-telegram/src/net/osmand/aidl/search/SearchResult.aidl b/OsmAnd-telegram/src/net/osmand/aidl/search/SearchResult.aidl new file mode 100644 index 0000000000..caecc7721b --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/search/SearchResult.aidl @@ -0,0 +1,3 @@ +package net.osmand.aidl.search; + +parcelable SearchResult; \ No newline at end of file diff --git a/OsmAnd-telegram/src/net/osmand/aidl/search/SearchResult.java b/OsmAnd-telegram/src/net/osmand/aidl/search/SearchResult.java new file mode 100644 index 0000000000..ef28063355 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/aidl/search/SearchResult.java @@ -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 otherNames = new ArrayList<>(); + + + public SearchResult(double latitude, double longitude, String localName, String localTypeName, + String alternateName, List 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 CREATOR = new Creator() { + @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 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; + } +} diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt index 811b1bc1fb..698c21c48a 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt @@ -7,6 +7,7 @@ import android.content.ServiceConnection import android.net.Uri import android.os.IBinder import android.os.RemoteException +import net.osmand.aidl.IOsmAndAidlCallback import net.osmand.aidl.IOsmAndAidlInterface import net.osmand.aidl.favorite.AFavorite import net.osmand.aidl.favorite.AddFavoriteParams @@ -34,12 +35,13 @@ import net.osmand.aidl.mapwidget.RemoveMapWidgetParams import net.osmand.aidl.mapwidget.UpdateMapWidgetParams import net.osmand.aidl.navdrawer.NavDrawerItem import net.osmand.aidl.navdrawer.SetNavDrawerItemsParams -import net.osmand.aidl.navigation.NavigateGpxParams -import net.osmand.aidl.navigation.NavigateParams +import net.osmand.aidl.navigation.* 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.telegram.TelegramApplication import java.io.File import java.util.* @@ -64,6 +66,25 @@ class OsmandAidlHelper(private val app: TelegramApplication) { fun onOsmandConnectionStateChanged(connected: Boolean) } + private var mSearchCompleteListener: SearchCompleteListener? = null + + interface SearchCompleteListener { + fun onSearchComplete(resultSet: List) + } + + private val mIOsmAndAidlCallback = object : IOsmAndAidlCallback.Stub() { + @Throws(RemoteException::class) + override fun onSearchComplete(resultSet: List) { + if (mSearchCompleteListener != null) { + mSearchCompleteListener!!.onSearchComplete(resultSet) + } + } + } + + fun setSearchCompleteListener(mSearchCompleteListener: SearchCompleteListener) { + this.mSearchCompleteListener = mSearchCompleteListener + } + /** * Class for interacting with the main interface of the service. */ @@ -884,4 +905,106 @@ class OsmandAidlHelper(private val app: TelegramApplication) { } return false } + + + /** + * Put navigation on pause. + */ + fun pauseNavigation(): Boolean { + if (mIOsmAndAidlInterface != null) { + try { + return mIOsmAndAidlInterface!!.pauseNavigation(PauseNavigationParams()) + } catch (e: RemoteException) { + e.printStackTrace() + } + + } + return false + } + + /** + * Resume navigation if it was paused before. + */ + fun resumeNavigation(): Boolean { + if (mIOsmAndAidlInterface != null) { + try { + return mIOsmAndAidlInterface!!.resumeNavigation(ResumeNavigationParams()) + } catch (e: RemoteException) { + e.printStackTrace() + } + + } + return false + } + + /** + * Stop navigation. Removes target / intermediate points and route path from the map. + */ + fun stopNavigation(): Boolean { + if (mIOsmAndAidlInterface != null) { + try { + return mIOsmAndAidlInterface!!.stopNavigation(StopNavigationParams()) + } catch (e: RemoteException) { + e.printStackTrace() + } + + } + return false + } + + /** + * Mute voice guidance. Stays muted until unmute manually or via the api. + */ + fun muteNavigation(): Boolean { + if (mIOsmAndAidlInterface != null) { + try { + return mIOsmAndAidlInterface!!.muteNavigation(MuteNavigationParams()) + } catch (e: RemoteException) { + e.printStackTrace() + } + + } + return false + } + + /** + * Unmute voice guidance. + */ + fun unmuteNavigation(): Boolean { + if (mIOsmAndAidlInterface != null) { + try { + return mIOsmAndAidlInterface!!.unmuteNavigation(UnmuteNavigationParams()) + } catch (e: RemoteException) { + e.printStackTrace() + } + + } + return false + } + + /** + * Run search for POI / Address. + * + * @param searchQuery - search query string. + * @param searchType - type of search. Values: + * SearchParams.SEARCH_TYPE_ALL - all kind of search + * SearchParams.SEARCH_TYPE_POI - POIs only + * SearchParams.SEARCH_TYPE_ADDRESS - addresses only + * + * @param latitude - latitude of original search location. + * @param longitude - longitude of original search location. + * @param radiusLevel - value from 1 to 7. Default value = 1. + * @param totalLimit - limit of returned search result rows. Default value = -1 (unlimited). + */ + fun search(searchQuery: String, searchType: Int, latitude: Double, longitude: Double, radiusLevel: Int, totalLimit: Int): Boolean { + if (mIOsmAndAidlInterface != null) { + try { + return mIOsmAndAidlInterface!!.search(SearchParams(searchQuery, searchType, latitude, longitude, radiusLevel, totalLimit), mIOsmAndAidlCallback) + } catch (e: RemoteException) { + e.printStackTrace() + } + + } + return false + } }