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( ...@@ -73,6 +73,8 @@ class OnBoardingPresenter @Inject constructor(
view.showLoading() view.showLoading()
try { try {
withContext(DefaultDispatcher) { withContext(DefaultDispatcher) {
refreshSettingsInteractor.refresh(serverUrl)
setupConnectionInfo(serverUrl) setupConnectionInfo(serverUrl)
// preparing next fragment before showing it // preparing next fragment before showing it
...@@ -80,7 +82,6 @@ class OnBoardingPresenter @Inject constructor( ...@@ -80,7 +82,6 @@ class OnBoardingPresenter @Inject constructor(
checkIfLoginFormIsEnabled() checkIfLoginFormIsEnabled()
checkIfCreateNewAccountIsEnabled() checkIfCreateNewAccountIsEnabled()
refreshSettingsInteractor.refresh(serverUrl)
serverInteractor.save(serverUrl) serverInteractor.save(serverUrl)
block() block()
......
...@@ -12,6 +12,8 @@ import chat.rocket.android.server.infraestructure.RocketChatClientFactory ...@@ -12,6 +12,8 @@ import chat.rocket.android.server.infraestructure.RocketChatClientFactory
import chat.rocket.android.server.presentation.CheckServerPresenter import chat.rocket.android.server.presentation.CheckServerPresenter
import chat.rocket.android.util.extension.launchUI import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.isValidUrl import chat.rocket.android.util.extensions.isValidUrl
import kotlinx.coroutines.experimental.DefaultDispatcher
import kotlinx.coroutines.experimental.withContext
import javax.inject.Inject import javax.inject.Inject
class ServerPresenter @Inject constructor( class ServerPresenter @Inject constructor(
...@@ -74,30 +76,33 @@ class ServerPresenter @Inject constructor( ...@@ -74,30 +76,33 @@ class ServerPresenter @Inject constructor(
} }
} }
private fun connectToServer(server: String, block: () -> Unit) { private fun connectToServer(serverUrl: String, block: () -> Unit) {
if (!server.isValidUrl()) { if (!serverUrl.isValidUrl()) {
view.showInvalidServerUrlMessage() view.showInvalidServerUrlMessage()
} else { } else {
launchUI(strategy) { launchUI(strategy) {
// Check if we already have an account for this server... // 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) { if (account != null) {
navigator.toChatList(server) navigator.toChatList(serverUrl)
return@launchUI return@launchUI
} }
view.showLoading() view.showLoading()
try { try {
refreshSettingsInteractor.refresh(server) withContext(DefaultDispatcher) {
serverInteractor.save(server) refreshSettingsInteractor.refresh(serverUrl)
setupConnectionInfo(serverUrl)
setupConnectionInfo(server) // preparing next fragment before showing it
checkEnabledAccounts(serverUrl)
checkIfLoginFormIsEnabled()
checkIfCreateNewAccountIsEnabled()
// preparing next fragment before showing it serverInteractor.save(serverUrl)
checkEnabledAccounts(server)
checkIfLoginFormIsEnabled()
checkIfCreateNewAccountIsEnabled()
block() block()
}
} catch (ex: Exception) { } catch (ex: Exception) {
view.showMessage(ex) view.showMessage(ex)
} finally { } finally {
......
...@@ -55,7 +55,7 @@ class ServerFragment : Fragment(), ServerView { ...@@ -55,7 +55,7 @@ class ServerFragment : Fragment(), ServerView {
private lateinit var serverUrlDisposable: Disposable private lateinit var serverUrlDisposable: Disposable
private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener { private val layoutListener = ViewTreeObserver.OnGlobalLayoutListener {
text_server_url.isCursorVisible = text_server_url.isCursorVisible =
KeyboardHelper.isSoftKeyboardShown(constraint_layout.rootView) KeyboardHelper.isSoftKeyboardShown(scroll_view.rootView)
} }
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
...@@ -72,7 +72,7 @@ class ServerFragment : Fragment(), ServerView { ...@@ -72,7 +72,7 @@ class ServerFragment : Fragment(), ServerView {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) { override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
constraint_layout.viewTreeObserver.addOnGlobalLayoutListener(layoutListener) scroll_view.viewTreeObserver.addOnGlobalLayoutListener(layoutListener)
setupToolbar() setupToolbar()
setupSpinner() setupSpinner()
setupOnClickListener() setupOnClickListener()
...@@ -88,7 +88,7 @@ class ServerFragment : Fragment(), ServerView { ...@@ -88,7 +88,7 @@ class ServerFragment : Fragment(), ServerView {
override fun onDestroyView() { override fun onDestroyView() {
super.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... // Reset deep link info, so user can come back and log to another server...
deepLinkInfo = null deepLinkInfo = null
unsubscribeEditText() unsubscribeEditText()
......
<?xml version="1.0" encoding="utf-8"?> <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/constraint_layout" android:id="@+id/scroll_view"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="@color/colorWhite" android:background="@color/colorWhite"
android:focusableInTouchMode="true"
android:padding="@dimen/screen_edge_left_and_right_margins" android:padding="@dimen/screen_edge_left_and_right_margins"
tools:context=".authentication.server.ui.ServerFragment"> tools:context=".authentication.server.ui.ServerFragment">
<ImageView <androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/image_server" android:layout_width="match_parent"
android:layout_width="wrap_content" android:layout_height="wrap_content">
android:layout_height="wrap_content"
android:src="@drawable/ic_server"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<TextView <ImageView
android:id="@+id/text_sign_in_to_your_server" android:id="@+id/image_server"
style="@style/Authentication.Headline.TextView" android:layout_width="wrap_content"
android:layout_marginTop="8dp" android:layout_height="wrap_content"
android:text="@string/title_sign_in_your_server" android:src="@drawable/ic_server"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/image_server" /> app:layout_constraintTop_toTopOf="parent"
tools:ignore="ContentDescription" />
<RelativeLayout <TextView
android:id="@+id/server_url_container" android:id="@+id/text_sign_in_to_your_server"
android:layout_width="0dp" style="@style/Authentication.Headline.TextView"
android:layout_height="48dp" android:layout_marginTop="8dp"
android:layout_marginTop="24dp" android:text="@string/title_sign_in_your_server"
android:background="@drawable/rounded_border" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintTop_toBottomOf="@+id/image_server" />
app:layout_constraintTop_toBottomOf="@+id/text_sign_in_to_your_server">
<Spinner <RelativeLayout
android:id="@+id/spinner_server_protocol" android:id="@+id/server_url_container"
android:layout_width="100dp" android:layout_width="0dp"
android:layout_height="match_parent" android:layout_height="48dp"
android:popupBackground="@color/colorWhite" /> android:layout_marginTop="24dp"
android:background="@drawable/rounded_border"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/text_sign_in_to_your_server">
<EditText <Spinner
android:id="@+id/text_server_url" android:id="@+id/spinner_server_protocol"
style="@style/Authentication.Text.Hint" android:layout_width="100dp"
android:layout_width="match_parent" android:layout_height="match_parent"
android:layout_height="wrap_content" android:popupBackground="@color/colorWhite" />
android:layout_centerVertical="true"
android:layout_marginStart="6dp" <EditText
android:layout_marginEnd="16dp" android:id="@+id/text_server_url"
android:layout_toEndOf="@+id/spinner_server_protocol" style="@style/Authentication.Text.Hint"
android:background="@color/colorWhite" android:layout_width="match_parent"
android:cursorVisible="false" android:layout_height="wrap_content"
android:hint="@string/server_hint_url" android:layout_centerVertical="true"
android:imeOptions="actionDone" android:layout_marginStart="6dp"
android:inputType="text|textUri" /> android:layout_marginEnd="16dp"
</RelativeLayout> android:layout_toEndOf="@+id/spinner_server_protocol"
android:background="@color/colorWhite"
android:cursorVisible="false"
android:hint="@string/server_hint_url"
android:imeOptions="actionDone"
android:inputType="text|textUri" />
</RelativeLayout>
<Button <Button
android:id="@+id/button_connect" android:id="@+id/button_connect"
style="@style/Authentication.Button.Flat" style="@style/Authentication.Button.Flat"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:backgroundTint="@color/colorAuthenticationButtonDisabled" android:backgroundTint="@color/colorAuthenticationButtonDisabled"
android:enabled="false" android:enabled="false"
android:text="@string/action_connect" android:text="@string/action_connect"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/server_url_container" /> app:layout_constraintTop_toBottomOf="@+id/server_url_container" />
<com.wang.avi.AVLoadingIndicatorView <com.wang.avi.AVLoadingIndicatorView
android:id="@+id/view_loading" android:id="@+id/view_loading"
style="@style/Authentication.AVLoadingIndicatorView" style="@style/Authentication.AVLoadingIndicatorView"
android:visibility="gone" android:visibility="gone"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="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