Fix weird MangaDex login dialog fill-in
This commit is contained in:
parent
d68341aaba
commit
bbc70801db
@ -74,36 +74,37 @@ class MangadexLoginDialog(bundle: Bundle? = null) : DialogController(bundle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun checkLogin() {
|
private fun checkLogin() {
|
||||||
with(binding) {
|
val username = binding.username.text?.toString()
|
||||||
if (username.text.isNullOrBlank() || password.text.isNullOrBlank() || (twoFactorCheck.isChecked && twoFactorEdit.text.isNullOrBlank())) {
|
val password = binding.password.text?.toString()
|
||||||
errorResult()
|
val twoFactor = binding.twoFactorEdit.text?.toString()
|
||||||
root.context.toast(R.string.fields_cannot_be_blank)
|
if (username.isNullOrBlank() || password.isNullOrBlank() || (binding.twoFactorCheck.isChecked && twoFactor.isNullOrBlank())) {
|
||||||
return
|
errorResult()
|
||||||
}
|
binding.root.context.toast(R.string.fields_cannot_be_blank)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
login.progress = 1
|
binding.login.progress = 1
|
||||||
|
|
||||||
dialog?.setCancelable(false)
|
dialog?.setCancelable(false)
|
||||||
dialog?.setCanceledOnTouchOutside(false)
|
dialog?.setCanceledOnTouchOutside(false)
|
||||||
|
|
||||||
scope.launch {
|
scope.launch {
|
||||||
try {
|
try {
|
||||||
val result = source?.login(
|
val result = source?.login(
|
||||||
username.text.toString(),
|
username,
|
||||||
password.text.toString(),
|
password,
|
||||||
twoFactorEdit.text.toString()
|
twoFactor.toString()
|
||||||
) ?: false
|
) ?: false
|
||||||
if (result) {
|
if (result) {
|
||||||
dialog?.dismiss()
|
dialog?.dismiss()
|
||||||
preferences.setTrackCredentials(Injekt.get<TrackManager>().mdList, username.toString(), password.toString())
|
preferences.setTrackCredentials(service, username, password)
|
||||||
root.context.toast(R.string.login_success)
|
binding.root.context.toast(R.string.login_success)
|
||||||
} else {
|
} else {
|
||||||
errorResult()
|
|
||||||
}
|
|
||||||
} catch (error: Exception) {
|
|
||||||
errorResult()
|
errorResult()
|
||||||
error.message?.let { root.context.toast(it) }
|
|
||||||
}
|
}
|
||||||
|
} catch (error: Exception) {
|
||||||
|
errorResult()
|
||||||
|
error.message?.let { binding.root.context.toast(it) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user