diff --git a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt index 6804f10f5a..34a8060b17 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/TelegramSettings.kt @@ -162,6 +162,13 @@ class TelegramSettings(private val app: TelegramApplication) { fun getShowOnMapChatsCount() = showOnMapChats.size + fun clear() { + stopSharingLocationToChats() + val prefs = app.getSharedPreferences(SETTINGS_NAME, Context.MODE_PRIVATE) + val edit = prefs.edit() + edit.clear().apply() + } + fun save() { val prefs = app.getSharedPreferences(SETTINGS_NAME, Context.MODE_PRIVATE) val edit = prefs.edit() diff --git a/OsmAnd-telegram/src/net/osmand/telegram/helpers/MessagesDbHelper.kt b/OsmAnd-telegram/src/net/osmand/telegram/helpers/MessagesDbHelper.kt index 6e505bc9aa..dcd4d67c46 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/helpers/MessagesDbHelper.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/helpers/MessagesDbHelper.kt @@ -35,11 +35,15 @@ class MessagesDbHelper(val app: TelegramApplication) { } fun saveMessages() { - sqliteHelper.clearMessages() + clearMessages() synchronized(messages) { sqliteHelper.addMessages(messages) } } + + fun clearMessages() { + sqliteHelper.clearMessages() + } private fun addMessage(chatId: Long, messageId: Long) { synchronized(messages) { diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt index a307f301a9..696e09c21a 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/MainActivity.kt @@ -271,6 +271,8 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene fun logoutTelegram(silent: Boolean = false) { if (telegramHelper.getTelegramAuthorizationState() == TelegramHelper.TelegramAuthorizationState.READY) { if (app.isInternetConnectionAvailable) { + app.messagesDbHelper.clearMessages() + settings.clear() telegramHelper.logout() } else { Toast.makeText(this, R.string.logout_no_internet_msg, Toast.LENGTH_SHORT).show()