Commit e8b13bce authored by Abhishek Aggarwal's avatar Abhishek Aggarwal
Browse files

AccountManager: compute domain on text change instead of focus change

parent e32e019b
Pipeline #185967 passed with stage
in 5 minutes and 51 seconds
......@@ -44,6 +44,10 @@ android {
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
dataBinding.enabled = true
flavorDimensions "distribution"
......
......@@ -31,8 +31,6 @@ object Constants {
const val AUTH_TOKEN_TYPE = "oauth2-access-token"
const val EELO_SYNC_SCHEME = "https://"
const val EELO_SYNC_HOST = "ecloud.global"
const val E_SYNC_URL = EELO_SYNC_SCHEME + "e.email"
const val EELO_SYNC_URL = EELO_SYNC_SCHEME + EELO_SYNC_HOST
const val E_SYNC_URL = "e.email"
}
......@@ -7,6 +7,7 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Toast
import androidx.core.widget.doOnTextChanged
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders
import foundation.e.accountmanager.Constants
......@@ -49,15 +50,17 @@ class EeloAuthenticatorFragment : Fragment() {
v.root.server_toggle_button.setOnClickListener() { expandCollapse() }
v.root.urlpwd_user_name.setOnFocusChangeListener() { v, hasFocus ->
if (!hasFocus) {
if (v.urlpwd_user_name.text.toString().contains("@")) {
val dns = v.urlpwd_user_name.text.toString().substringAfter("@")
val pre_custom_url = "https://" + dns
requireView().urlpwd_server_uri.setText(pre_custom_url)
} else {
requireView().urlpwd_server_uri.setText("")
v.root.urlpwd_user_name.doOnTextChanged { text, _, _, _ ->
if (text.toString().contains("@")) {
var dns = text.toString().substringAfter("@")
if (dns == Constants.E_SYNC_URL) {
dns = Constants.EELO_SYNC_HOST
}
val pre_custom_url = "https://$dns"
requireView().urlpwd_server_uri.setText(pre_custom_url)
} else {
requireView().urlpwd_server_uri.setText("")
}
}
......@@ -115,11 +118,7 @@ class EeloAuthenticatorFragment : Fragment() {
private fun validate(): Boolean {
var valid = false
var serverUrl = requireView().urlpwd_server_uri.text.toString()
if (serverUrl == Constants.E_SYNC_URL) {
serverUrl = Constants.EELO_SYNC_URL
}
val serverUrl = requireView().urlpwd_server_uri.text.toString()
fun validateUrl() {
......
Supports Markdown
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