mirror of
https://github.com/SchildiChat/SchildiChat-android.git
synced 2025-01-23 07:40:20 +01:00
Login screens: rename variables
This commit is contained in:
parent
311d8ddf7b
commit
0014e8ef06
@ -158,18 +158,18 @@ class LoginCaptchaFragment @Inject constructor(
|
|||||||
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
|
override fun shouldOverrideUrlLoading(view: WebView?, url: String?): Boolean {
|
||||||
if (url?.startsWith("js:") == true) {
|
if (url?.startsWith("js:") == true) {
|
||||||
var json = url.substring(3)
|
var json = url.substring(3)
|
||||||
var parameters: JavascriptResponse? = null
|
var javascriptResponse: JavascriptResponse? = null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// URL decode
|
// URL decode
|
||||||
json = URLDecoder.decode(json, "UTF-8")
|
json = URLDecoder.decode(json, "UTF-8")
|
||||||
parameters = MoshiProvider.providesMoshi().adapter(JavascriptResponse::class.java).fromJson(json)
|
javascriptResponse = MoshiProvider.providesMoshi().adapter(JavascriptResponse::class.java).fromJson(json)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## shouldOverrideUrlLoading(): failed")
|
Timber.e(e, "## shouldOverrideUrlLoading(): failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
val response = parameters?.response
|
val response = javascriptResponse?.response
|
||||||
if (parameters?.action == "verifyCallback" && response != null) {
|
if (javascriptResponse?.action == "verifyCallback" && response != null) {
|
||||||
loginViewModel.handle(LoginAction.CaptchaDone(response))
|
loginViewModel.handle(LoginAction.CaptchaDone(response))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -196,25 +196,25 @@ class LoginWebFragment @Inject constructor(
|
|||||||
override fun shouldOverrideUrlLoading(view: WebView, url: String?): Boolean {
|
override fun shouldOverrideUrlLoading(view: WebView, url: String?): Boolean {
|
||||||
if (null != url && url.startsWith("js:")) {
|
if (null != url && url.startsWith("js:")) {
|
||||||
var json = url.substring(3)
|
var json = url.substring(3)
|
||||||
var parameters: JavascriptResponse? = null
|
var javascriptResponse: JavascriptResponse? = null
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// URL decode
|
// URL decode
|
||||||
json = URLDecoder.decode(json, "UTF-8")
|
json = URLDecoder.decode(json, "UTF-8")
|
||||||
val adapter = MoshiProvider.providesMoshi().adapter(JavascriptResponse::class.java)
|
val adapter = MoshiProvider.providesMoshi().adapter(JavascriptResponse::class.java)
|
||||||
parameters = adapter.fromJson(json)
|
javascriptResponse = adapter.fromJson(json)
|
||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
Timber.e(e, "## shouldOverrideUrlLoading() : fromJson failed")
|
Timber.e(e, "## shouldOverrideUrlLoading() : fromJson failed")
|
||||||
}
|
}
|
||||||
|
|
||||||
// succeeds to parse parameters
|
// succeeds to parse parameters
|
||||||
if (parameters != null) {
|
if (javascriptResponse != null) {
|
||||||
val action = parameters.action
|
val action = javascriptResponse.action
|
||||||
|
|
||||||
if (signMode == SignMode.SignIn) {
|
if (signMode == SignMode.SignIn) {
|
||||||
try {
|
try {
|
||||||
if (action == "onLogin") {
|
if (action == "onLogin") {
|
||||||
val credentials = parameters.credentials
|
val credentials = javascriptResponse.credentials
|
||||||
if (credentials != null) {
|
if (credentials != null) {
|
||||||
loginViewModel.handle(LoginAction.WebLoginSuccess(credentials))
|
loginViewModel.handle(LoginAction.WebLoginSuccess(credentials))
|
||||||
}
|
}
|
||||||
@ -226,7 +226,7 @@ class LoginWebFragment @Inject constructor(
|
|||||||
// MODE_REGISTER
|
// MODE_REGISTER
|
||||||
// check the required parameters
|
// check the required parameters
|
||||||
if (action == "onRegistered") {
|
if (action == "onRegistered") {
|
||||||
val credentials = parameters.credentials
|
val credentials = javascriptResponse.credentials
|
||||||
if (credentials != null) {
|
if (credentials != null) {
|
||||||
loginViewModel.handle(LoginAction.WebLoginSuccess(credentials))
|
loginViewModel.handle(LoginAction.WebLoginSuccess(credentials))
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user