Commit 08f0588f authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Adds scrolling to the server view.

parent 7465f525
......@@ -73,6 +73,8 @@ class OnBoardingPresenter @Inject constructor(
view.showLoading()
try {
withContext(DefaultDispatcher) {
refreshSettingsInteractor.refresh(serverUrl)
setupConnectionInfo(serverUrl)
// preparing next fragment before showing it
......@@ -80,7 +82,6 @@ class OnBoardingPresenter @Inject constructor(
checkIfLoginFormIsEnabled()
checkIfCreateNewAccountIsEnabled()
refreshSettingsInteractor.refresh(serverUrl)
serverInteractor.save(serverUrl)
block()
......
......@@ -12,6 +12,8 @@ import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.server.presentation.CheckServerPresenter
import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.isValidUrl
import kotlinx.coroutines.experimental.DefaultDispatcher
import kotlinx.coroutines.experimental.withContext
import javax.inject.Inject
class ServerPresenter @Inject constructor(
......@@ -74,30 +76,33 @@ class ServerPresenter @Inject constructor(
}
}
private fun connectToServer(server: String, block: () -> Unit) {
if (!server.isValidUrl()) {
private fun connectToServer(serverUrl: String, block: () -> Unit) {
if (!serverUrl.isValidUrl()) {
view.showInvalidServerUrlMessage()
} else {
launchUI(strategy) {
// Check if we already have an account for this server...
val account = getAccountsInteractor.get().firstOrNull { it.serverUrl == server }
val account = getAccountsInteractor.get().firstOrNull { it.serverUrl == serverUrl }
if (account != null) {
navigator.toChatList(server)
navigator.toChatList(serverUrl)
return@launchUI
}
view.showLoading()
try {
refreshSettingsInteractor.refresh(server)
serverInteractor.save(server)
withContext(DefaultDispatcher) {
refreshSettingsInteractor.refresh(serverUrl)
setupConnectionInfo(server)
setupConnectionInfo(serverUrl)
// preparing next fragment before showing it
checkEnabledAccounts(server)
checkEnabledAccounts(serverUrl)
checkIfLoginFormIsEnabled()
checkIfCreateNewAccountIsEnabled()
serverInteractor.save(serverUrl)
block()
}
} catch (ex: Exception) {
view.showMessage(ex)
} finally {
......
......@@ -55,7 +55,7 @@ class ServerFragment : Fragment(), ServerView {
private lateinit var serverUrlDisposable: Disposable
private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener {
text_server_url.isCursorVisible =
KeyboardHelper.isSoftKeyboardShown(constraint_layout.rootView)
KeyboardHelper.isSoftKeyboardShown(scroll_view.rootView)
}
override fun onCreate(savedInstanceState: Bundle?) {
......@@ -72,7 +72,7 @@ class ServerFragment : Fragment(), ServerView {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
constraint_layout.viewTreeObserver.addOnGlobalLayoutListener(layoutListener)
scroll_view.viewTreeObserver.addOnGlobalLayoutListener(layoutListener)
setupToolbar()
setupSpinner()
setupOnClickListener()
......@@ -88,7 +88,7 @@ class ServerFragment : Fragment(), ServerView {
override fun onDestroyView() {
super.onDestroyView()
constraint_layout.viewTreeObserver.removeOnGlobalLayoutListener(layoutListener)
scroll_view.viewTreeObserver.removeOnGlobalLayoutListener(layoutListener)
// Reset deep link info, so user can come back and log to another server...
deepLinkInfo = null
unsubscribeEditText()
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
<ScrollView 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:id="@+id/constraint_layout"
android:id="@+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhite"
android:focusableInTouchMode="true"
android:padding="@dimen/screen_edge_left_and_right_margins"
tools:context=".authentication.server.ui.ServerFragment">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<ImageView
android:id="@+id/image_server"
android:layout_width="wrap_content"
......@@ -80,4 +82,5 @@
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</ScrollView>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment