From 76396438bcd02e69e275ae3b4ecf54c522bfee44 Mon Sep 17 00:00:00 2001 From: veliymolfar Date: Thu, 9 Jan 2020 14:23:42 +0200 Subject: [PATCH 1/2] widget updates fix / open MyLocationFragment on widget tap --- OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt | 7 +++++-- .../src/net/osmand/telegram/helpers/ShowLocationHelper.kt | 2 ++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt index 77ea8f28dc..0d66b7fd7b 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt @@ -225,10 +225,10 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis updateWidgetHandler?.postDelayed({ if (isUsedByMyLocation(usedBy)) { val sharingStatus = app().settings.sharingStatusChanges.last() - val isSending = sharingStatus.statusType == TelegramSettings.SharingStatusType.SENDING + var isSending = sharingStatus.statusType == TelegramSettings.SharingStatusType.SENDING val sharingChats = app().settings.getShareLocationChats() var oldestTime = 0L - if (sharingChats.isNotEmpty()) { + if (sharingChats.isNotEmpty() && app().shareLocationHelper.sharingLocation) { sharingChats.forEach { id -> val bufferMessages = app().locationMessages.getBufferedMessagesForChat(id) if (bufferMessages.isNotEmpty()) { @@ -240,6 +240,9 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis oldestTime = 0L } } + } else { + isSending = false + oldestTime = -1 } log.info("oldest buffered msg time: $oldestTime | isSending: $isSending") app().showLocationHelper.addOrUpdateStatusWidget(oldestTime, isSending) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt index 9ff378af15..0fdb748018 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/ShowLocationHelper.kt @@ -14,6 +14,7 @@ import net.osmand.telegram.R import net.osmand.telegram.TelegramApplication import net.osmand.telegram.helpers.OsmandAidlHelper.ContextMenuButtonsListener import net.osmand.telegram.helpers.TelegramUiHelper.ListItem +import net.osmand.telegram.ui.OPEN_MY_LOCATION_TAB_KEY import net.osmand.telegram.utils.AndroidUtils import net.osmand.telegram.utils.OsmandFormatter import net.osmand.telegram.utils.OsmandLocationUtils @@ -255,6 +256,7 @@ class ShowLocationHelper(private val app: TelegramApplication) { private fun getStatusWidgetIntent(): Intent { val startIntent = app.packageManager.getLaunchIntentForPackage(app.packageName) startIntent.addCategory(Intent.CATEGORY_LAUNCHER) + startIntent.putExtra(OPEN_MY_LOCATION_TAB_KEY,true) return startIntent } From 0a3b170c07807450530f46145623a213c7c7a457 Mon Sep 17 00:00:00 2001 From: veliymolfar Date: Fri, 10 Jan 2020 12:05:44 +0200 Subject: [PATCH 2/2] clean up --- OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt | 1 - 1 file changed, 1 deletion(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt index 0d66b7fd7b..4915133e42 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramService.kt @@ -244,7 +244,6 @@ class TelegramService : Service(), LocationListener, TelegramIncomingMessagesLis isSending = false oldestTime = -1 } - log.info("oldest buffered msg time: $oldestTime | isSending: $isSending") app().showLocationHelper.addOrUpdateStatusWidget(oldestTime, isSending) } startWidgetUpdates()