diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt index 4c40d9a365..1eda69b2dd 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramApplication.kt @@ -14,7 +14,7 @@ import net.osmand.telegram.notifications.NotificationHelper import net.osmand.telegram.utils.AndroidUtils import net.osmand.telegram.utils.UiUtils -class TelegramApplication : Application(), OsmandHelperListener { +class TelegramApplication : Application() { val telegramHelper = TelegramHelper.instance lateinit var settings: TelegramSettings private set @@ -42,7 +42,25 @@ class TelegramApplication : Application(), OsmandHelperListener { telegramHelper.messageActiveTimeSec = settings.locHistoryTime uiUtils = UiUtils(this) osmandAidlHelper = OsmandAidlHelper(this) - osmandAidlHelper.listener = this + osmandAidlHelper.listener = object : OsmandHelperListener { + override fun onOsmandConnectionStateChanged(connected: Boolean) { + if (connected) { + osmandAidlHelper.clearNavDrawerItems("net.osmand.telegram") + osmandAidlHelper.clearNavDrawerItems("net.osmand.telegram.debug") + osmandAidlHelper.setNavDrawerItems( + applicationContext.packageName, + listOf(getString(R.string.app_name_short)), + listOf("osmand_telegram://main_activity"), + listOf("ic_action_location_sharing_app"), + listOf(-1) + ) + showLocationHelper.setupMapLayer() + showLocationHelper.addDirectionContextMenuButton() + showLocationHelper.startShowingLocation() + showLocationHelper.addOrUpdateStatusWidget(-1, false) + } + } + } osmandAidlHelper.setUpdatesListener(object : UpdatesListener { override fun update() { if (settings.hasAnyChatToShowOnMap()) { @@ -124,24 +142,6 @@ class TelegramApplication : Application(), OsmandHelperListener { return internetConnectionAvailable } - override fun onOsmandConnectionStateChanged(connected: Boolean) { - if (connected) { - osmandAidlHelper.clearNavDrawerItems("net.osmand.telegram") - osmandAidlHelper.clearNavDrawerItems("net.osmand.telegram.debug") - osmandAidlHelper.setNavDrawerItems( - applicationContext.packageName, - listOf(getString(R.string.app_name_short)), - listOf("osmand_telegram://main_activity"), - listOf("ic_action_location_sharing_app"), - listOf(-1) - ) - showLocationHelper.setupMapLayer() - showLocationHelper.addDirectionContextMenuButton() - showLocationHelper.startShowingLocation() - showLocationHelper.addOrUpdateStatusWidget(-1, false) - } - } - private fun startTelegramService(intent: Int, serviceOffInterval: Long = 0) { var i = intent var interval = serviceOffInterval