diff --git a/OsmAnd-telegram/res/layout/bottom_sheet_disconnect_telegram.xml b/OsmAnd-telegram/res/layout/bottom_sheet_disconnect_telegram.xml new file mode 100644 index 0000000000..a4ea424393 --- /dev/null +++ b/OsmAnd-telegram/res/layout/bottom_sheet_disconnect_telegram.xml @@ -0,0 +1,72 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/OsmAnd-telegram/res/values/dimens.xml b/OsmAnd-telegram/res/values/dimens.xml index 071ea0bcda..d6ecf6c762 100644 --- a/OsmAnd-telegram/res/values/dimens.xml +++ b/OsmAnd-telegram/res/values/dimens.xml @@ -54,6 +54,8 @@ 1.25 -0.03 + 300dp + 22sp diff --git a/OsmAnd-telegram/res/values/strings.xml b/OsmAnd-telegram/res/values/strings.xml index e9108e6495..24d6e5811e 100644 --- a/OsmAnd-telegram/res/values/strings.xml +++ b/OsmAnd-telegram/res/values/strings.xml @@ -1,4 +1,7 @@ + Close + To invoke access from OsmAnd, open Telegram, go to Settings - Privacy and Security - Sessions and terminate that session. + How to disconnect OsmAnd Location Sharing from the Telegram account How to disconnect OsmAnd Location Sharing from Telegram Connected account Account diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/DisconnectTelegramBottomSheet.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/DisconnectTelegramBottomSheet.kt new file mode 100644 index 0000000000..63e1bc5851 --- /dev/null +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/DisconnectTelegramBottomSheet.kt @@ -0,0 +1,60 @@ +package net.osmand.telegram.ui + +import android.os.Bundle +import android.support.design.widget.BottomSheetBehavior +import android.support.v4.app.DialogFragment +import android.support.v4.app.FragmentManager +import android.view.LayoutInflater +import android.view.View +import android.view.ViewGroup +import android.widget.TextView +import net.osmand.telegram.R +import net.osmand.telegram.ui.views.BottomSheetDialog + +class DisconnectTelegramBottomSheet : DialogFragment() { + + override fun onCreateDialog(savedInstanceState: Bundle?) = BottomSheetDialog(context!!) + + override fun onCreateView( + inflater: LayoutInflater, + container: ViewGroup?, + savedInstanceState: Bundle? + ): View? { + val mainView = inflater.inflate(R.layout.bottom_sheet_disconnect_telegram, container, false) + + mainView.findViewById(R.id.scroll_view_container).setOnClickListener { dismiss() } + + BottomSheetBehavior.from(mainView.findViewById(R.id.scroll_view)) + .setBottomSheetCallback(object : BottomSheetBehavior.BottomSheetCallback() { + + override fun onStateChanged(bottomSheet: View, newState: Int) { + if (newState == BottomSheetBehavior.STATE_HIDDEN) { + dismiss() + } + } + + override fun onSlide(bottomSheet: View, slideOffset: Float) {} + }) + + mainView.findViewById(R.id.secondary_btn).apply { + setText(R.string.shared_string_close) + setOnClickListener { dismiss() } + } + + return mainView + } + + companion object { + + private const val TAG = "DisconnectTelegramBottomSheet" + + fun showInstance(fm: FragmentManager): Boolean { + return try { + DisconnectTelegramBottomSheet().show(fm, TAG) + true + } catch (e: RuntimeException) { + false + } + } + } +} diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt index fa6516dfa4..638d8ec22e 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/SettingsDialogFragment.kt @@ -121,8 +121,7 @@ class SettingsDialogFragment : DialogFragment() { mainView.findViewById(R.id.help_icon) .setImageDrawable(uiUtils.getActiveIcon(R.drawable.ic_action_help)) mainView.findViewById(R.id.help_row).setOnClickListener { - // FIXME - Toast.makeText(context, "Logout help", Toast.LENGTH_SHORT).show() + DisconnectTelegramBottomSheet.showInstance(childFragmentManager) } return mainView