Commit 41bccfd0 authored by Lucio Maciel's avatar Lucio Maciel

Fix deeplinking when only providing the host.

parent e0e2f924
...@@ -11,8 +11,8 @@ import timber.log.Timber ...@@ -11,8 +11,8 @@ import timber.log.Timber
@Parcelize @Parcelize
data class LoginDeepLinkInfo( data class LoginDeepLinkInfo(
val url: String, val url: String,
val userId: String, val userId: String?,
val token: String val token: String?
) : Parcelable ) : Parcelable
fun Intent.getLoginDeepLinkInfo(): LoginDeepLinkInfo? { fun Intent.getLoginDeepLinkInfo(): LoginDeepLinkInfo? {
......
...@@ -141,10 +141,15 @@ class LoginPresenter @Inject constructor( ...@@ -141,10 +141,15 @@ class LoginPresenter @Inject constructor(
fun authenticateWithDeepLink(deepLinkInfo: LoginDeepLinkInfo) { fun authenticateWithDeepLink(deepLinkInfo: LoginDeepLinkInfo) {
val serverUrl = deepLinkInfo.url val serverUrl = deepLinkInfo.url
setupConnectionInfo(serverUrl) setupConnectionInfo(serverUrl)
if (deepLinkInfo.userId != null && deepLinkInfo.token != null) {
deepLinkUserId = deepLinkInfo.userId deepLinkUserId = deepLinkInfo.userId
deepLinkToken = deepLinkInfo.token deepLinkToken = deepLinkInfo.token
tokenRepository.save(serverUrl, Token(deepLinkUserId, deepLinkToken)) tokenRepository.save(serverUrl, Token(deepLinkUserId, deepLinkToken))
doAuthentication(TYPE_LOGIN_DEEP_LINK) doAuthentication(TYPE_LOGIN_DEEP_LINK)
} else {
// If we don't have the login credentials, just go through normal setup and user input.
setupView()
}
} }
private fun setupConnectionInfo(serverUrl: String) { private fun setupConnectionInfo(serverUrl: String) {
......
...@@ -104,6 +104,8 @@ class ServerFragment : Fragment(), ServerView { ...@@ -104,6 +104,8 @@ class ServerFragment : Fragment(), ServerView {
override fun onDestroyView() { override fun onDestroyView() {
super.onDestroyView() super.onDestroyView()
// reset deep link info, so user can come back and log to another server...
deepLinkInfo = null
relative_layout.viewTreeObserver.removeOnGlobalLayoutListener(layoutListener) relative_layout.viewTreeObserver.removeOnGlobalLayoutListener(layoutListener)
} }
...@@ -144,9 +146,9 @@ class ServerFragment : Fragment(), ServerView { ...@@ -144,9 +146,9 @@ class ServerFragment : Fragment(), ServerView {
hideLoading() hideLoading()
AlertDialog.Builder(it) AlertDialog.Builder(it)
.setMessage(getString(R.string.msg_ver_not_recommended, BuildConfig.RECOMMENDED_SERVER_VERSION)) .setMessage(getString(R.string.msg_ver_not_recommended, BuildConfig.RECOMMENDED_SERVER_VERSION))
.setPositiveButton(R.string.msg_ok, { _, _ -> .setPositiveButton(R.string.msg_ok) { _, _ ->
performConnect() performConnect()
}) }
.create() .create()
.show() .show()
} }
......
...@@ -56,9 +56,7 @@ class AuthenticationActivity : AppCompatActivity(), HasSupportFragmentInjector { ...@@ -56,9 +56,7 @@ class AuthenticationActivity : AppCompatActivity(), HasSupportFragmentInjector {
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
super.onActivityResult(requestCode, resultCode, data) super.onActivityResult(requestCode, resultCode, data)
val currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container) val currentFragment = supportFragmentManager.findFragmentById(R.id.fragment_container)
if (currentFragment != null) { currentFragment?.onActivityResult(requestCode, resultCode, data)
currentFragment.onActivityResult(requestCode, resultCode, data)
}
} }
override fun supportFragmentInjector(): AndroidInjector<Fragment> { override fun supportFragmentInjector(): AndroidInjector<Fragment> {
......
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