Commit ed3b28c1 authored by Lucio Maciel's avatar Lucio Maciel

Fix some issues.

parent 0d5bbd04
...@@ -6,7 +6,9 @@ import chat.rocket.android.authentication.login.ui.LoginFragment ...@@ -6,7 +6,9 @@ import chat.rocket.android.authentication.login.ui.LoginFragment
import chat.rocket.android.authentication.signup.ui.SignupFragment import chat.rocket.android.authentication.signup.ui.SignupFragment
import chat.rocket.android.authentication.twofactor.ui.TwoFAFragment import chat.rocket.android.authentication.twofactor.ui.TwoFAFragment
import chat.rocket.android.authentication.ui.AuthenticationActivity import chat.rocket.android.authentication.ui.AuthenticationActivity
import chat.rocket.android.authentication.ui.newServerIntent
import chat.rocket.android.main.ui.MainActivity import chat.rocket.android.main.ui.MainActivity
import chat.rocket.android.server.ui.changeServerIntent
import chat.rocket.android.util.extensions.addFragmentBackStack import chat.rocket.android.util.extensions.addFragmentBackStack
import chat.rocket.android.webview.ui.webViewIntent import chat.rocket.android.webview.ui.webViewIntent
...@@ -40,7 +42,13 @@ class AuthenticationNavigator(internal val activity: AuthenticationActivity) { ...@@ -40,7 +42,13 @@ class AuthenticationNavigator(internal val activity: AuthenticationActivity) {
activity.finish() activity.finish()
} }
fun toChatList(serverUrl: String) {
activity.startActivity(activity.changeServerIntent(serverUrl))
activity.finish()
}
fun toServerScreen() { fun toServerScreen() {
TODO("not implemented") //To change body of created functions use File | Settings | File Templates. activity.startActivity(activity.newServerIntent())
activity.finish()
} }
} }
\ No newline at end of file
...@@ -4,6 +4,7 @@ import chat.rocket.android.authentication.presentation.AuthenticationNavigator ...@@ -4,6 +4,7 @@ import chat.rocket.android.authentication.presentation.AuthenticationNavigator
import chat.rocket.android.core.lifecycle.CancelStrategy import chat.rocket.android.core.lifecycle.CancelStrategy
import chat.rocket.android.helper.NetworkHelper import chat.rocket.android.helper.NetworkHelper
import chat.rocket.android.helper.UrlHelper import chat.rocket.android.helper.UrlHelper
import chat.rocket.android.server.domain.GetAccountsInteractor
import chat.rocket.android.server.domain.RefreshSettingsInteractor import chat.rocket.android.server.domain.RefreshSettingsInteractor
import chat.rocket.android.server.domain.SaveCurrentServerInteractor import chat.rocket.android.server.domain.SaveCurrentServerInteractor
import chat.rocket.android.util.extensions.launchUI import chat.rocket.android.util.extensions.launchUI
...@@ -14,12 +15,20 @@ class ServerPresenter @Inject constructor(private val view: ServerView, ...@@ -14,12 +15,20 @@ class ServerPresenter @Inject constructor(private val view: ServerView,
private val strategy: CancelStrategy, private val strategy: CancelStrategy,
private val navigator: AuthenticationNavigator, private val navigator: AuthenticationNavigator,
private val serverInteractor: SaveCurrentServerInteractor, private val serverInteractor: SaveCurrentServerInteractor,
private val refreshSettingsInteractor: RefreshSettingsInteractor) { private val refreshSettingsInteractor: RefreshSettingsInteractor,
private val getAccountsInteractor: GetAccountsInteractor) {
fun connect(server: String) { fun connect(server: String) {
if (!UrlHelper.isValidUrl(server)) { if (!UrlHelper.isValidUrl(server)) {
view.showInvalidServerUrlMessage() view.showInvalidServerUrlMessage()
} else { } else {
launchUI(strategy) { launchUI(strategy) {
// Check if we already have an account for this server...
val account = getAccountsInteractor.get().firstOrNull { it.serverUrl == server }
if (account != null) {
navigator.toChatList(server)
return@launchUI
}
if (NetworkHelper.hasInternetAccess()) { if (NetworkHelper.hasInternetAccess()) {
view.showLoading() view.showLoading()
try { try {
......
...@@ -75,7 +75,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp ...@@ -75,7 +75,7 @@ class MainActivity : AppCompatActivity(), MainView, HasActivityInjector, HasSupp
} }
override fun closeServerSelection() { override fun closeServerSelection() {
view_navigation.getHeaderView(0).account_container.performClick()
} }
private var expanded = false private var expanded = false
......
...@@ -27,7 +27,7 @@ ...@@ -27,7 +27,7 @@
android:digits="0123456789abcdefghijklmnopqrstuvwxyz.-/:" android:digits="0123456789abcdefghijklmnopqrstuvwxyz.-/:"
android:inputType="textUri" android:inputType="textUri"
android:paddingEnd="0dp" android:paddingEnd="0dp"
android:paddingStart="2dp" /> android:paddingStart="4dp" />
<TextView <TextView
android:id="@+id/text_server_protocol" android:id="@+id/text_server_protocol"
......
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