Create DisconnectTelegramBottomSheet and related stuff
This commit is contained in:
parent
9b9690be1a
commit
2cee8dd5a2
5 changed files with 138 additions and 2 deletions
|
@ -0,0 +1,72 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<LinearLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||
xmlns:tools="http://schemas.android.com/tools"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:orientation="vertical"
|
||||
tools:layout_gravity="bottom">
|
||||
|
||||
<android.support.design.widget.CoordinatorLayout
|
||||
android:id="@+id/scroll_view_container"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<android.support.v4.widget.NestedScrollView
|
||||
android:id="@+id/scroll_view"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:behavior_hideable="true"
|
||||
app:behavior_peekHeight="@dimen/bottom_sheet_peek_height"
|
||||
app:layout_behavior="@string/bottom_sheet_behavior">
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/card_bg_color"
|
||||
android:orientation="vertical">
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
android:text="@string/disconnect_from_telegram"
|
||||
android:textColor="?android:textColorPrimary"
|
||||
android:textSize="@dimen/list_item_title_text_size"
|
||||
app:firstBaselineToTopHeight="25sp"
|
||||
app:typeface="@string/font_roboto_medium"/>
|
||||
|
||||
<net.osmand.telegram.ui.views.TextViewEx
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingLeft="@dimen/content_padding_standard"
|
||||
android:paddingRight="@dimen/content_padding_standard"
|
||||
android:text="@string/disconnect_from_telegram_desc"
|
||||
android:textColor="?android:attr/textColorSecondary"
|
||||
android:textSize="@dimen/list_item_description_text_size"
|
||||
app:firstBaselineToTopHeight="20sp"
|
||||
app:lastBaselineToBottomHeight="16sp"
|
||||
app:typeface="@string/font_roboto_regular"/>
|
||||
|
||||
</LinearLayout>
|
||||
|
||||
</android.support.v4.widget.NestedScrollView>
|
||||
|
||||
</android.support.design.widget.CoordinatorLayout>
|
||||
|
||||
<FrameLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:background="?attr/card_bg_color">
|
||||
|
||||
<include
|
||||
layout="@layout/secondary_btn"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_margin="@dimen/content_padding_half"/>
|
||||
|
||||
</FrameLayout>
|
||||
|
||||
</LinearLayout>
|
|
@ -54,6 +54,8 @@
|
|||
<dimen name="text_description_line_spacing_multiplier" format="float">1.25</dimen>
|
||||
<dimen name="title_letter_spacing" format="float">-0.03</dimen>
|
||||
|
||||
<dimen name="bottom_sheet_peek_height">300dp</dimen>
|
||||
|
||||
<!-- Text sizes -->
|
||||
|
||||
<dimen name="dialog_title_text_size">22sp</dimen>
|
||||
|
|
|
@ -1,4 +1,7 @@
|
|||
<resources>
|
||||
<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>
|
||||
<string name="logout_help_desc">How to disconnect OsmAnd Location Sharing from Telegram</string>
|
||||
<string name="connected_account">Connected account</string>
|
||||
<string name="shared_string_account">Account</string>
|
||||
|
|
|
@ -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<View>(R.id.scroll_view_container).setOnClickListener { dismiss() }
|
||||
|
||||
BottomSheetBehavior.from(mainView.findViewById<View>(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<TextView>(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
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -121,8 +121,7 @@ class SettingsDialogFragment : DialogFragment() {
|
|||
mainView.findViewById<ImageView>(R.id.help_icon)
|
||||
.setImageDrawable(uiUtils.getActiveIcon(R.drawable.ic_action_help))
|
||||
mainView.findViewById<View>(R.id.help_row).setOnClickListener {
|
||||
// FIXME
|
||||
Toast.makeText(context, "Logout help", Toast.LENGTH_SHORT).show()
|
||||
DisconnectTelegramBottomSheet.showInstance(childFragmentManager)
|
||||
}
|
||||
|
||||
return mainView
|
||||
|
|
Loading…
Reference in a new issue