From fb4085315384f169099b63168281b74df2834a2b Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Mon, 3 Sep 2018 14:30:40 +0300 Subject: [PATCH] Add compatibility with OsmAnd Nightly --- .../src/net/osmand/telegram/TelegramSettings.kt | 16 +++++++++++++--- .../osmand/telegram/helpers/OsmandAidlHelper.kt | 1 + .../osmand/telegram/ui/SettingsDialogFragment.kt | 3 +++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt index 29117fd487..d0b680bb30 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt @@ -330,19 +330,29 @@ class TelegramSettings(private val app: TelegramApplication) { @DrawableRes val iconId: Int, @DrawableRes val whiteIconId: Int, val title: String, - val appPackage: String + val appPackage: String, + val showOnlyInstalled: Boolean ) { OSMAND_PLUS( R.drawable.ic_logo_osmand_plus, R.drawable.ic_action_osmand_plus, "OsmAnd+", - OsmandAidlHelper.OSMAND_PLUS_PACKAGE_NAME + OsmandAidlHelper.OSMAND_PLUS_PACKAGE_NAME, + false ), OSMAND_FREE( R.drawable.ic_logo_osmand_free, R.drawable.ic_action_osmand_free, "OsmAnd", - OsmandAidlHelper.OSMAND_FREE_PACKAGE_NAME + OsmandAidlHelper.OSMAND_FREE_PACKAGE_NAME, + false + ), + OSMAND_NIGHTLY( + R.drawable.ic_logo_osmand_free, + R.drawable.ic_action_osmand_free, + "OsmAnd Nightly", + OsmandAidlHelper.OSMAND_NIGHTLY_PACKAGE_NAME, + true ); companion object { diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt index 6252ae4250..edac62b427 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/OsmandAidlHelper.kt @@ -51,6 +51,7 @@ class OsmandAidlHelper(private val app: TelegramApplication) { companion object { const val OSMAND_FREE_PACKAGE_NAME = "net.osmand" const val OSMAND_PLUS_PACKAGE_NAME = "net.osmand.plus" + const val OSMAND_NIGHTLY_PACKAGE_NAME = "net.osmand.dev" const val UPDATE_TIME_MS = 5000L } diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt index ef155eb345..c33dc5c49d 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt @@ -56,6 +56,9 @@ class SettingsDialogFragment : BaseDialogFragment() { for (appConn in TelegramSettings.AppConnect.values()) { val pack = appConn.appPackage val installed = AndroidUtils.isAppInstalled(context!!, pack) + if (!installed && appConn.showOnlyInstalled) { + continue + } inflater.inflate(R.layout.item_with_rb_and_btn, container, false).apply { findViewById(R.id.icon).setImageDrawable(uiUtils.getIcon(appConn.iconId)) findViewById(R.id.title).text = appConn.title