Add missing search and navigation aidl to telegram app
This commit is contained in:
parent
7a712a9a28
commit
d774c7575a
17 changed files with 549 additions and 2 deletions
|
@ -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,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);
|
||||
}
|
|
@ -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 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.search;
|
||||
|
||||
parcelable SearchParams;
|
91
OsmAnd-telegram/src/net/osmand/aidl/search/SearchParams.java
Normal file
91
OsmAnd-telegram/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 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<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 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;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
package net.osmand.aidl.search;
|
||||
|
||||
parcelable SearchResult;
|
96
OsmAnd-telegram/src/net/osmand/aidl/search/SearchResult.java
Normal file
96
OsmAnd-telegram/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;
|
||||
}
|
||||
}
|
|
@ -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<SearchResult>)
|
||||
}
|
||||
|
||||
private val mIOsmAndAidlCallback = object : IOsmAndAidlCallback.Stub() {
|
||||
@Throws(RemoteException::class)
|
||||
override fun onSearchComplete(resultSet: List<SearchResult>) {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue