ChooseOsmAndBottomSheet in progress

This commit is contained in:
Alex Sytnyk 2018-08-31 17:36:25 +03:00
parent 7ebea3048c
commit 8203052e86
2 changed files with 63 additions and 1 deletions

View file

@ -0,0 +1,62 @@
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 ChooseOsmAndBottomSheet : 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_choose_osmand, 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) {}
})
// TODO: inflate AppConn items
mainView.findViewById<TextView>(R.id.secondary_btn).apply {
setText(R.string.shared_string_cancel)
setOnClickListener { dismiss() }
}
return mainView
}
companion object {
private const val TAG = "ChooseOsmAndBottomSheet"
fun showInstance(fm: FragmentManager): Boolean {
return try {
ChooseOsmAndBottomSheet().show(fm, TAG)
true
} catch (e: RuntimeException) {
false
}
}
}
}

View file

@ -209,7 +209,7 @@ class LiveNowTabFragment : Fragment(), TelegramListener, TelegramIncomingMessage
updateOpenOsmAndIcon()
}
installedApps.size > 1 -> {
// TODO: open "Choose OsmAnd" dialog
fragmentManager?.also { ChooseOsmAndBottomSheet.showInstance(it) }
}
}
}