Add the application package to the AddOpenAppNavDrawerItemParams

This commit is contained in:
Alex Sytnyk 2018-07-30 16:45:09 +03:00
parent c090c1c148
commit 732f3cff7c
4 changed files with 33 additions and 10 deletions

View file

@ -6,21 +6,24 @@ import android.os.Parcelable;
public class AddOpenAppNavDrawerItemParams implements Parcelable { public class AddOpenAppNavDrawerItemParams implements Parcelable {
private String itemName; private String itemName;
private String appPackage;
private String uri; private String uri;
private int flags; private int flags;
public AddOpenAppNavDrawerItemParams(String itemName, String uri) { public AddOpenAppNavDrawerItemParams(String itemName, String appPackage, String uri) {
this(itemName, uri, -1); this(itemName, appPackage, uri, -1);
} }
public AddOpenAppNavDrawerItemParams(String itemName, String uri, int flags) { public AddOpenAppNavDrawerItemParams(String itemName, String appPackage, String uri, int flags) {
this.itemName = itemName; this.itemName = itemName;
this.appPackage = appPackage;
this.uri = uri; this.uri = uri;
this.flags = flags; this.flags = flags;
} }
protected AddOpenAppNavDrawerItemParams(Parcel in) { protected AddOpenAppNavDrawerItemParams(Parcel in) {
itemName = in.readString(); itemName = in.readString();
appPackage = in.readString();
uri = in.readString(); uri = in.readString();
flags = in.readInt(); flags = in.readInt();
} }
@ -29,6 +32,10 @@ public class AddOpenAppNavDrawerItemParams implements Parcelable {
return itemName; return itemName;
} }
public String getAppPackage() {
return appPackage;
}
public String getUri() { public String getUri() {
return uri; return uri;
} }
@ -40,6 +47,7 @@ public class AddOpenAppNavDrawerItemParams implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(itemName); dest.writeString(itemName);
dest.writeString(appPackage);
dest.writeString(uri); dest.writeString(uri);
dest.writeInt(flags); dest.writeInt(flags);
} }

View file

@ -44,7 +44,14 @@ class TelegramApplication : Application(), OsmandHelperListener {
osmandAidlHelper.listener = object : OsmandAidlHelper.OsmandHelperListener { osmandAidlHelper.listener = object : OsmandAidlHelper.OsmandHelperListener {
override fun onOsmandConnectionStateChanged(connected: Boolean) { override fun onOsmandConnectionStateChanged(connected: Boolean) {
if (connected) { if (connected) {
osmandAidlHelper.addOpenAppNavDrawerItem(getString(R.string.app_name), "osmand_telegram://main_activity", -1) val basePackage = "net.osmand.telegram"
val appPackage = if (BuildConfig.DEBUG) "$basePackage.debug" else basePackage
osmandAidlHelper.addOpenAppNavDrawerItem(
getString(R.string.app_name),
"osmand_telegram://main_activity",
appPackage,
-1
)
} }
} }
} }

View file

@ -868,10 +868,10 @@ class OsmandAidlHelper(private val app: Application) {
return false return false
} }
fun addOpenAppNavDrawerItem(itemName: String, uri: String, flags: Int): Boolean { fun addOpenAppNavDrawerItem(itemName: String, uri: String, appPackage: String, flags: Int): Boolean {
if (mIOsmAndAidlInterface != null) { if (mIOsmAndAidlInterface != null) {
try { try {
return mIOsmAndAidlInterface!!.addOpenAppNavDrawerItem(AddOpenAppNavDrawerItemParams(itemName, uri, flags)) return mIOsmAndAidlInterface!!.addOpenAppNavDrawerItem(AddOpenAppNavDrawerItemParams(itemName, uri, appPackage, flags))
} catch (e: RemoteException) { } catch (e: RemoteException) {
e.printStackTrace() e.printStackTrace()
} }

View file

@ -6,21 +6,24 @@ import android.os.Parcelable;
public class AddOpenAppNavDrawerItemParams implements Parcelable { public class AddOpenAppNavDrawerItemParams implements Parcelable {
private String itemName; private String itemName;
private String appPackage;
private String uri; private String uri;
private int flags; private int flags;
public AddOpenAppNavDrawerItemParams(String itemName, String uri) { public AddOpenAppNavDrawerItemParams(String itemName, String appPackage, String uri) {
this(itemName, uri, -1); this(itemName, appPackage, uri, -1);
} }
public AddOpenAppNavDrawerItemParams(String itemName, String uri, int flags) { public AddOpenAppNavDrawerItemParams(String itemName, String appPackage, String uri, int flags) {
this.itemName = itemName; this.itemName = itemName;
this.appPackage = appPackage;
this.uri = uri; this.uri = uri;
this.flags = flags; this.flags = flags;
} }
protected AddOpenAppNavDrawerItemParams(Parcel in) { protected AddOpenAppNavDrawerItemParams(Parcel in) {
itemName = in.readString(); itemName = in.readString();
appPackage = in.readString();
uri = in.readString(); uri = in.readString();
flags = in.readInt(); flags = in.readInt();
} }
@ -29,6 +32,10 @@ public class AddOpenAppNavDrawerItemParams implements Parcelable {
return itemName; return itemName;
} }
public String getAppPackage() {
return appPackage;
}
public String getUri() { public String getUri() {
return uri; return uri;
} }
@ -40,6 +47,7 @@ public class AddOpenAppNavDrawerItemParams implements Parcelable {
@Override @Override
public void writeToParcel(Parcel dest, int flags) { public void writeToParcel(Parcel dest, int flags) {
dest.writeString(itemName); dest.writeString(itemName);
dest.writeString(appPackage);
dest.writeString(uri); dest.writeString(uri);
dest.writeInt(flags); dest.writeInt(flags);
} }