From 2757dca0a9f9ec9517b2f8cfa634dd81a38d312f Mon Sep 17 00:00:00 2001 From: Chumva Date: Fri, 15 Feb 2019 16:41:00 +0200 Subject: [PATCH] Fix editText scroll --- .../osmand/telegram/ui/LoginDialogFragment.kt | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/OsmAnd-telegram/src/net/osmand/telegram/ui/LoginDialogFragment.kt b/OsmAnd-telegram/src/net/osmand/telegram/ui/LoginDialogFragment.kt index 0d2b50665f..4f4c0f77a0 100644 --- a/OsmAnd-telegram/src/net/osmand/telegram/ui/LoginDialogFragment.kt +++ b/OsmAnd-telegram/src/net/osmand/telegram/ui/LoginDialogFragment.kt @@ -23,10 +23,7 @@ import android.view.View import android.view.ViewGroup import android.view.WindowManager import android.view.inputmethod.EditorInfo -import android.widget.Button -import android.widget.ImageView -import android.widget.LinearLayout -import android.widget.TextView +import android.widget.* import net.osmand.PlatformUtil import net.osmand.telegram.R import net.osmand.telegram.utils.AndroidNetworkUtils @@ -116,6 +113,7 @@ class LoginDialogFragment : BaseDialogFragment() { private var showProgress = false private var dismissedManually = false private lateinit var continueButton: Button + private lateinit var scrollView: ScrollView enum class LoginDialogType(val viewId: Int, val editorId: Int, @StringRes val titleId: Int, @StringRes val descriptionId: Int, @@ -149,6 +147,7 @@ class LoginDialogFragment : BaseDialogFragment() { } val view = inflater.inflate(R.layout.login_dialog, container) continueButton = view.findViewById(R.id.continue_button) + scrollView = view.findViewById(R.id.scroll_view) buildDialog(view) view.viewTreeObserver.addOnGlobalLayoutListener { @@ -160,6 +159,7 @@ class LoginDialogFragment : BaseDialogFragment() { if (!softKeyboardShown && softKeyboardVisible) { softKeyboardShown = softKeyboardVisible transformContinueButton(true) + scrollToBottom() } else if (softKeyboardShown && !softKeyboardVisible) { transformContinueButton(false) } @@ -180,6 +180,10 @@ class LoginDialogFragment : BaseDialogFragment() { continueButton.requestLayout() } + private fun scrollToBottom() { + scrollView.post { scrollView.fullScroll(ScrollView.FOCUS_DOWN); } + } + override fun onCreateDialog(savedInstanceState: Bundle?): Dialog { return object : Dialog(requireActivity(), theme) { override fun onBackPressed() { @@ -253,7 +257,11 @@ class LoginDialogFragment : BaseDialogFragment() { titleView?.text = getText(t.titleId) descriptionView?.text = getText(t.descriptionId) - + titleView?.setOnClickListener { + view.findViewById(R.id.scroll_view)?.post { + view.findViewById(R.id.scroll_view).fullScroll(View.FOCUS_DOWN) + } + } layout.visibility = View.VISIBLE val editText: ExtendedEditText? = layout.findViewById(t.editorId) if (editText != null && !showWelcomeDialog) {