From df820cac5595264e0ae688d1efcc22070c71f301 Mon Sep 17 00:00:00 2001 From: veliymolfar Date: Fri, 10 Jan 2020 11:10:40 +0200 Subject: [PATCH] back to osmand button fix --- .../telegram/ui/MyLocationTabFragment.kt | 30 ++++++++++++------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt index edce5b6032..b0955553ec 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/MyLocationTabFragment.kt @@ -244,16 +244,7 @@ class MyLocationTabFragment : Fragment(), TelegramListener { } } - backToOsmAndBtn = mainView.findViewById(R.id.back_to_osmand).apply { - setOnClickListener { - val startIntent = app.packageManager.getLaunchIntentForPackage("net.osmand.plus") - if (startIntent != null) { - startIntent.addCategory(Intent.CATEGORY_LAUNCHER) - startActivity(startIntent) - } - } - } - + backToOsmAndBtn = mainView.findViewById(R.id.back_to_osmand) lastChatsInfo = settings.lastChatsInfo return mainView @@ -494,6 +485,25 @@ class MyLocationTabFragment : Fragment(), TelegramListener { if (sharingMode) 0 else AppBarLayout.LayoutParams.SCROLL_FLAG_SCROLL stopSharingSwitcher.isChecked = true appBarScrollRange = -1 + updateBackToOsmBtn() + } + + private fun updateBackToOsmBtn() { + val pckg = app.settings.appToConnectPackage + backToOsmAndBtn.apply { + visibility = if (pckg.isNotEmpty() && sharingMode && AndroidUtils.isAppInstalled(app, pckg)) { + setOnClickListener { + val startIntent = app.packageManager.getLaunchIntentForPackage(pckg) + if (startIntent != null) { + startIntent.addCategory(Intent.CATEGORY_LAUNCHER) + startActivity(startIntent) + } + } + View.VISIBLE + } else { + View.GONE + } + } } private fun updateSharingStatus() {