Fix crash when logging with an url without scheme and improve error and info messages in AccountCredentialsScreen

This commit is contained in:
Shinokuni 2024-08-16 17:28:41 +02:00
parent cbc9d8b3c2
commit 1cb6c92edf
5 changed files with 17 additions and 4 deletions

View File

@ -156,7 +156,10 @@ class AccountCredentialsScreen(
Text(text = state.urlError!!.errorText())
}
account.accountType == AccountType.FEVER -> {
Text(text = stringResource(R.string.provide_full_api))
Text(text = stringResource(R.string.provide_full_url))
}
else -> {
Text(text = stringResource(R.string.provide_root_url))
}
}
},

View File

@ -56,8 +56,14 @@ class AccountCredentialsScreenModel(
mutableState.update { it.copy(isLoginOnGoing = true) }
with(state.value) {
val normalizedUrl = if (!url.contains("https://") && !url.contains("http://")) {
"https://$url"
} else {
url
}
val newAccount = account.copy(
url = url,
url = normalizedUrl,
accountName = name,
login = login,
password = password,

View File

@ -2,6 +2,7 @@ package com.readrops.app.util
import android.content.Context
import com.readrops.api.utils.exceptions.HttpException
import com.readrops.api.utils.exceptions.LoginFailedException
import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.exceptions.UnknownFormatException
import com.readrops.app.R
@ -16,6 +17,7 @@ object ErrorMessage {
is NoSuchFileException -> context.resources.getString(R.string.unable_open_file)
is IOException -> context.resources.getString(R.string.network_failure, exception.message.orEmpty())
is ParseException, is UnknownFormatException -> context.resources.getString(R.string.processing_feed_error)
is LoginFailedException -> context.getString(R.string.login_failed)
else -> "${exception.javaClass.simpleName}: ${exception.message}"
}

View File

@ -218,5 +218,6 @@
<string name="donation_text">"Si vous considérez que mon travail vous est utile et si vous souhaitez me soutenir, vous pouvez me faire une donation. "</string>
<string name="add_feed">Ajouter un flux</string>
<string name="downloaded_file">Fichier téléchargé !</string>
<string name="provide_full_api">Merci de fournir l\'URL entière de l\'API</string>
<string name="provide_full_url">Merci de fournir l\'URL entière de l\'API</string>
<string name="provide_root_url">Merci de fournir l\'URL racine du service</string>
</resources>

View File

@ -231,5 +231,6 @@
<string name="donation_text">I you find my work useful and you would like to support me, you can consider making me a donation.</string>
<string name="add_feed">Add feed</string>
<string name="downloaded_file">Downloaded file!</string>
<string name="provide_full_api">Please provide the full API URL</string>
<string name="provide_full_url">Please provide the full API URL</string>
<string name="provide_root_url">Please provide the service root URL</string>
</resources>