Merge pull request #5877 from osmandapp/telegram_logout
Show Welcome screen after log out
This commit is contained in:
commit
b032a2aff3
3 changed files with 19 additions and 10 deletions
|
@ -1,4 +1,5 @@
|
|||
<resources>
|
||||
<string name="logout_no_internet_msg">To properly log out from your Telegram account, the Internet is needed.</string>
|
||||
<string name="shared_string_close">Close</string>
|
||||
<string name="disconnect_from_telegram_desc">To invoke access from OsmAnd, open Telegram, go to Settings - Privacy and Security - Sessions and terminate that session.</string>
|
||||
<string name="disconnect_from_telegram">How to disconnect OsmAnd Location Sharing from the Telegram account</string>
|
||||
|
|
|
@ -184,6 +184,11 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
runOnUi {
|
||||
val fm = supportFragmentManager
|
||||
when (newTelegramAuthorizationState) {
|
||||
TelegramAuthorizationState.LOGGING_OUT -> LoginDialogFragment.showWelcomeDialog(fm)
|
||||
TelegramAuthorizationState.CLOSED -> {
|
||||
telegramHelper.init()
|
||||
telegramHelper.requestAuthorizationState()
|
||||
}
|
||||
TelegramAuthorizationState.READY -> LoginDialogFragment.dismiss(fm)
|
||||
else -> Unit
|
||||
}
|
||||
|
@ -258,9 +263,13 @@ class MainActivity : AppCompatActivity(), TelegramListener, ActionButtonsListene
|
|||
// FIXME: update UI
|
||||
}
|
||||
|
||||
private fun logoutTelegram(silent: Boolean = false) {
|
||||
fun logoutTelegram(silent: Boolean = false) {
|
||||
if (telegramHelper.getTelegramAuthorizationState() == TelegramHelper.TelegramAuthorizationState.READY) {
|
||||
telegramHelper.logout()
|
||||
if (app.isInternetConnectionAvailable) {
|
||||
telegramHelper.logout()
|
||||
} else {
|
||||
Toast.makeText(this, R.string.logout_no_internet_msg, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
} else if (!silent) {
|
||||
Toast.makeText(this, R.string.not_logged_in, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
|
|
|
@ -11,10 +11,12 @@ import android.view.Gravity
|
|||
import android.view.LayoutInflater
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import android.widget.*
|
||||
import android.widget.ArrayAdapter
|
||||
import android.widget.ImageView
|
||||
import android.widget.RadioButton
|
||||
import android.widget.TextView
|
||||
import net.osmand.telegram.*
|
||||
import net.osmand.telegram.helpers.OsmandAidlHelper
|
||||
import net.osmand.telegram.helpers.TelegramHelper
|
||||
import net.osmand.telegram.helpers.TelegramUiHelper
|
||||
import net.osmand.telegram.utils.AndroidUtils
|
||||
import net.osmand.telegram.utils.OsmandFormatter
|
||||
|
@ -156,12 +158,9 @@ class SettingsDialogFragment : DialogFragment() {
|
|||
}
|
||||
}
|
||||
|
||||
private fun logoutTelegram(silent: Boolean = false) {
|
||||
if (telegramHelper.getTelegramAuthorizationState() == TelegramHelper.TelegramAuthorizationState.READY) {
|
||||
telegramHelper.logout()
|
||||
} else if (!silent) {
|
||||
Toast.makeText(context, R.string.not_logged_in, Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
private fun logoutTelegram() {
|
||||
val act = activity ?: return
|
||||
(act as MainActivity).logoutTelegram()
|
||||
}
|
||||
|
||||
private inner class SendMyLocPref : DurationPref(
|
||||
|
|
Loading…
Reference in a new issue