Commit a6877b4e authored by Filipe de Lima Brito's avatar Filipe de Lima Brito

Updates the ServerFragment

parent 62253b1f
...@@ -23,4 +23,5 @@ sealed class ScreenViewEvent(val screenName: String) { ...@@ -23,4 +23,5 @@ sealed class ScreenViewEvent(val screenName: String) {
object Settings : ScreenViewEvent("SettingsFragment") object Settings : ScreenViewEvent("SettingsFragment")
object SignUp : ScreenViewEvent("SignupFragment") object SignUp : ScreenViewEvent("SignupFragment")
object TwoFa : ScreenViewEvent("TwoFAFragment") object TwoFa : ScreenViewEvent("TwoFAFragment")
object OnBoarding : ScreenViewEvent("OnBoardingFragment")
} }
...@@ -7,6 +7,8 @@ import android.view.ViewGroup ...@@ -7,6 +7,8 @@ import android.view.ViewGroup
import androidx.core.view.isVisible import androidx.core.view.isVisible
import androidx.fragment.app.Fragment import androidx.fragment.app.Fragment
import chat.rocket.android.R import chat.rocket.android.R
import chat.rocket.android.analytics.AnalyticsManager
import chat.rocket.android.analytics.event.ScreenViewEvent
import chat.rocket.android.authentication.domain.model.getLoginDeepLinkInfo import chat.rocket.android.authentication.domain.model.getLoginDeepLinkInfo
import chat.rocket.android.authentication.onboarding.presentation.OnBoardingPresenter import chat.rocket.android.authentication.onboarding.presentation.OnBoardingPresenter
import chat.rocket.android.authentication.onboarding.presentation.OnBoardingView import chat.rocket.android.authentication.onboarding.presentation.OnBoardingView
...@@ -23,6 +25,8 @@ import javax.inject.Inject ...@@ -23,6 +25,8 @@ import javax.inject.Inject
class OnBoardingFragment : Fragment(), OnBoardingView { class OnBoardingFragment : Fragment(), OnBoardingView {
@Inject @Inject
lateinit var presenter: OnBoardingPresenter lateinit var presenter: OnBoardingPresenter
@Inject
lateinit var analyticsManager: AnalyticsManager
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
...@@ -38,6 +42,8 @@ class OnBoardingFragment : Fragment(), OnBoardingView { ...@@ -38,6 +42,8 @@ class OnBoardingFragment : Fragment(), OnBoardingView {
super.onViewCreated(view, savedInstanceState) super.onViewCreated(view, savedInstanceState)
setupToobar() setupToobar()
setupOnClickListener() setupOnClickListener()
analyticsManager.logScreenView(ScreenViewEvent.OnBoarding)
} }
private fun setupToobar() { private fun setupToobar() {
......
...@@ -9,8 +9,8 @@ import chat.rocket.android.server.domain.RefreshSettingsInteractor ...@@ -9,8 +9,8 @@ import chat.rocket.android.server.domain.RefreshSettingsInteractor
import chat.rocket.android.server.domain.SaveConnectingServerInteractor import chat.rocket.android.server.domain.SaveConnectingServerInteractor
import chat.rocket.android.server.infraestructure.RocketChatClientFactory 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.extensions.isValidUrl
import chat.rocket.android.util.extension.launchUI import chat.rocket.android.util.extension.launchUI
import chat.rocket.android.util.extensions.isValidUrl
import javax.inject.Inject import javax.inject.Inject
class ServerPresenter @Inject constructor( class ServerPresenter @Inject constructor(
...@@ -33,10 +33,7 @@ class ServerPresenter @Inject constructor( ...@@ -33,10 +33,7 @@ class ServerPresenter @Inject constructor(
} }
fun connect(server: String) { fun connect(server: String) {
//code that leads to login screen (smart lock will be implemented after this) connectToServer(server) { navigator.toLoginOptions(server) }
connectToServer(server) {
navigator.toLoginOptions(server)
}
} }
private fun connectToServer(server: String, block: () -> Unit) { private fun connectToServer(server: String, block: () -> Unit) {
...@@ -66,9 +63,6 @@ class ServerPresenter @Inject constructor( ...@@ -66,9 +63,6 @@ class ServerPresenter @Inject constructor(
} }
fun deepLink(deepLinkInfo: LoginDeepLinkInfo) { fun deepLink(deepLinkInfo: LoginDeepLinkInfo) {
//code that leads to login screen (smart lock will be implemented after this) connectToServer(deepLinkInfo.url) { navigator.toLogin(deepLinkInfo) }
connectToServer(deepLinkInfo.url) {
navigator.toLogin(deepLinkInfo)
}
} }
} }
\ No newline at end of file
...@@ -9,4 +9,15 @@ interface ServerView : LoadingView, MessageView, VersionCheckView { ...@@ -9,4 +9,15 @@ interface ServerView : LoadingView, MessageView, VersionCheckView {
* Shows an invalid server URL message. * Shows an invalid server URL message.
*/ */
fun showInvalidServerUrlMessage() fun showInvalidServerUrlMessage()
/**
* Enables the button to connect to the server when the user inputs a valid url.
*/
fun enableButtonConnect()
/**
* Disables the button to connect to the server when the server address entered by the user
* is not a valid url.
*/
fun disableButtonConnect()
} }
\ No newline at end of file
...@@ -3,6 +3,7 @@ package chat.rocket.android.authentication.server.presentation ...@@ -3,6 +3,7 @@ package chat.rocket.android.authentication.server.presentation
import okhttp3.HttpUrl import okhttp3.HttpUrl
interface VersionCheckView { interface VersionCheckView {
/** /**
* Alerts the user about the server version not meeting the recommended server version. * Alerts the user about the server version not meeting the recommended server version.
*/ */
......
...@@ -227,7 +227,9 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback ...@@ -227,7 +227,9 @@ class CreateChannelFragment : Fragment(), CreateChannelView, ActionMode.Callback
ui { ui {
recycler_view.layoutManager = recycler_view.layoutManager =
LinearLayoutManager(context, RecyclerView.VERTICAL, false) LinearLayoutManager(context, RecyclerView.VERTICAL, false)
recycler_view.addItemDecoration(DividerItemDecoration(it, DividerItemDecoration.HORIZONTAL)) recycler_view.addItemDecoration(
DividerItemDecoration(it, DividerItemDecoration.HORIZONTAL)
)
recycler_view.adapter = adapter recycler_view.adapter = adapter
} }
} }
......
...@@ -14,9 +14,11 @@ import chat.rocket.core.internal.rest.serverInfo ...@@ -14,9 +14,11 @@ import chat.rocket.core.internal.rest.serverInfo
import kotlinx.coroutines.experimental.Job import kotlinx.coroutines.experimental.Job
import timber.log.Timber import timber.log.Timber
abstract class CheckServerPresenter constructor(private val strategy: CancelStrategy, abstract class CheckServerPresenter constructor(
private val strategy: CancelStrategy,
private val factory: RocketChatClientFactory, private val factory: RocketChatClientFactory,
private val view: VersionCheckView) { private val view: VersionCheckView
) {
private lateinit var currentServer: String private lateinit var currentServer: String
private lateinit var client: RocketChatClient private lateinit var client: RocketChatClient
...@@ -49,12 +51,8 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra ...@@ -49,12 +51,8 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra
} catch (ex: Exception) { } catch (ex: Exception) {
Timber.d(ex, "Error getting server info") Timber.d(ex, "Error getting server info")
when (ex) { when (ex) {
is RocketChatInvalidProtocolException -> { is RocketChatInvalidProtocolException -> view.errorInvalidProtocol()
view.errorInvalidProtocol() else -> view.errorCheckingServerVersion()
}
else -> {
view.errorCheckingServerVersion()
}
} }
} }
} }
...@@ -64,6 +62,7 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra ...@@ -64,6 +62,7 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra
val thisServerVersion = serverInfo.version val thisServerVersion = serverInfo.version
val isRequiredVersion = isRequiredServerVersion(thisServerVersion) val isRequiredVersion = isRequiredServerVersion(thisServerVersion)
val isRecommendedVersion = isRecommendedServerVersion(thisServerVersion) val isRecommendedVersion = isRecommendedServerVersion(thisServerVersion)
return if (isRequiredVersion) { return if (isRequiredVersion) {
if (isRecommendedVersion) { if (isRecommendedVersion) {
Timber.i("Your version is nice! (Requires: 0.62.0, Yours: $thisServerVersion)") Timber.i("Your version is nice! (Requires: 0.62.0, Yours: $thisServerVersion)")
...@@ -81,7 +80,10 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra ...@@ -81,7 +80,10 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra
} }
private fun isRecommendedServerVersion(version: String): Boolean { private fun isRecommendedServerVersion(version: String): Boolean {
return isMinimumVersion(version, getVersionDistilled(BuildConfig.RECOMMENDED_SERVER_VERSION)) return isMinimumVersion(
version,
getVersionDistilled(BuildConfig.RECOMMENDED_SERVER_VERSION)
)
} }
private fun isMinimumVersion(version: String, required: VersionInfo): Boolean { private fun isMinimumVersion(version: String, required: VersionInfo): Boolean {
...@@ -115,12 +117,14 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra ...@@ -115,12 +117,14 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra
val major = getVersionNumber(split, 0) val major = getVersionNumber(split, 0)
val minor = getVersionNumber(split, 1) val minor = getVersionNumber(split, 1)
val update = getVersionNumber(split, 2) val update = getVersionNumber(split, 2)
return VersionInfo( return VersionInfo(
major = major, major = major,
minor = minor, minor = minor,
update = update, update = update,
release = release, release = release,
full = version) full = version
)
} }
private fun getVersionNumber(split: List<String>, index: Int): Int { private fun getVersionNumber(split: List<String>, index: Int): Int {
...@@ -133,7 +137,9 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra ...@@ -133,7 +137,9 @@ abstract class CheckServerPresenter constructor(private val strategy: CancelStra
sealed class Version(val version: String) { sealed class Version(val version: String) {
data class VersionOk(private val currentVersion: String) : Version(currentVersion) data class VersionOk(private val currentVersion: String) : Version(currentVersion)
data class RecommendedVersionWarning(private val currentVersion: String) : Version(currentVersion) data class RecommendedVersionWarning(private val currentVersion: String) :
Version(currentVersion)
data class OutOfDateError(private val currentVersion: String) : Version(currentVersion) data class OutOfDateError(private val currentVersion: String) : Version(currentVersion)
} }
} }
\ No newline at end of file
...@@ -3,5 +3,4 @@ ...@@ -3,5 +3,4 @@
android:shape="oval"> android:shape="oval">
<solid android:color="@color/colorAccent" /> <solid android:color="@color/colorAccent" />
</shape> </shape>
...@@ -68,10 +68,12 @@ ...@@ -68,10 +68,12 @@
android:inputType="text|textUri" /> android:inputType="text|textUri" />
</RelativeLayout> </RelativeLayout>
<Button <androidx.appcompat.widget.AppCompatButton
android:id="@+id/button_connect" android:id="@+id/button_connect"
style="@style/Authentication.Button" style="@style/Authentication.Button"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:backgroundTint="@color/colorAuthenticationOnBoardingButtonDisabled"
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"
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
<!-- Authentication colors --> <!-- Authentication colors -->
<color name="colorAuthenticationOnBoardingButtonBorder">#FFE1E5E8</color> <color name="colorAuthenticationOnBoardingButtonBorder">#FFE1E5E8</color>
<color name="colorAuthenticationOnBoardingButtonDisabled">#FFE1E5E8</color>
<color name="colorAuthenticationOnBoardingChevron">#FFCBCED1</color> <color name="colorAuthenticationOnBoardingChevron">#FFCBCED1</color>
<color name="colorAuthenticationOnBoardingSecondaryText">#FF9EA2A8</color> <color name="colorAuthenticationOnBoardingSecondaryText">#FF9EA2A8</color>
......
...@@ -131,7 +131,7 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin ...@@ -131,7 +131,7 @@ https://github.com/RocketChat/java-code-styles/blob/master/CODING_STYLE.md#strin
<string name="msg_no_chat_title">No chat messages</string> <string name="msg_no_chat_title">No chat messages</string>
<string name="msg_no_chat_description">Start conversing to see your\nmessages here.</string> <string name="msg_no_chat_description">Start conversing to see your\nmessages here.</string>
<string name="msg_cancel">CANCEL</string> <string name="msg_cancel">CANCEL</string>
<string name="msg_http_insecure">When using HTTP, you\'re connecting to an insecure server. We don\'t recommend you doing that.</string> <string name="msg_http_insecure">When using HTTP you\'re connecting to an insecure server. We don\'t recommend you doing that.</string>
<string name="msg_error_checking_server_version">An error has occurred while checking your server version, please try again</string> <string name="msg_error_checking_server_version">An error has occurred while checking your server version, please try again</string>
<string name="msg_invalid_server_protocol">The selected protocol is not accepted by this server, try using HTTPS</string> <string name="msg_invalid_server_protocol">The selected protocol is not accepted by this server, try using HTTPS</string>
<string name="msg_image_saved_successfully">Image has been saved to gallery</string> <string name="msg_image_saved_successfully">Image has been saved to gallery</string>
......
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