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

View file

@ -41,10 +41,17 @@ class TelegramApplication : Application(), OsmandHelperListener {
settings = TelegramSettings(this)
uiUtils = UiUtils(this)
osmandAidlHelper = OsmandAidlHelper(this)
osmandAidlHelper.listener = object : OsmandAidlHelper.OsmandHelperListener {
osmandAidlHelper.listener = object : OsmandAidlHelper.OsmandHelperListener {
override fun onOsmandConnectionStateChanged(connected: Boolean) {
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
}
fun addOpenAppNavDrawerItem(itemName: String, uri: String, flags: Int): Boolean {
fun addOpenAppNavDrawerItem(itemName: String, uri: String, appPackage: String, flags: Int): Boolean {
if (mIOsmAndAidlInterface != null) {
try {
return mIOsmAndAidlInterface!!.addOpenAppNavDrawerItem(AddOpenAppNavDrawerItemParams(itemName, uri, flags))
return mIOsmAndAidlInterface!!.addOpenAppNavDrawerItem(AddOpenAppNavDrawerItemParams(itemName, uri, appPackage, flags))
} catch (e: RemoteException) {
e.printStackTrace()
}

View file

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