From b14b34441b93aff950bfaeae64ae48ed7ceeb0ff Mon Sep 17 00:00:00 2001 From: davide Date: Mon, 25 Jul 2022 15:20:36 +0200 Subject: [PATCH] Update api login information with user input --- .../apps/readerforselfossv2/android/LoginActivity.kt | 8 +------- .../apps/readerforselfossv2/repository/Repository.kt | 4 +++- .../readerforselfossv2/repository/RepositoryImpl.kt | 12 ++++++++++-- .../service/ApiDetailsServiceImpl.kt | 1 - 4 files changed, 14 insertions(+), 11 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/LoginActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/LoginActivity.kt index e78f2e1..62e11ae 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/LoginActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/LoginActivity.kt @@ -203,13 +203,7 @@ class LoginActivity() : AppCompatActivity(), DIAware { } else { showProgress(true) - settings.putString("url", url) - settings.putString("login", login) - settings.putString("httpUserName", httpLogin) - settings.putString("password", password) - settings.putString("httpPassword", httpPassword) - settings.putBoolean("isSelfSignedCert", isWithSelfSignedCert) - repository.refreshLoginInformation() + repository.refreshLoginInformation(url, login, password, httpLogin, httpPassword, isWithSelfSignedCert) if (this@LoginActivity.isNetworkAvailable(this@LoginActivity.findViewById(R.id.loginForm))) { CoroutineScope(Dispatchers.IO).launch { diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt index 40d22e2..2df1995 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/Repository.kt @@ -35,5 +35,7 @@ interface Repository { suspend fun deleteSource(id: Int): Boolean suspend fun updateRemote(): Boolean suspend fun login(): Boolean - fun refreshLoginInformation() + fun refreshLoginInformation(url: String, login: String, password: String, + httpLogin: String, httpPassword: String, + isSelfSignedCert: Boolean) } \ No newline at end of file diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt index 34cdbcc..de0375c 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/repository/RepositoryImpl.kt @@ -275,9 +275,17 @@ class RepositoryImpl(private val api: SelfossApi, private val apiDetails: ApiDet return result } - override fun refreshLoginInformation() { + override fun refreshLoginInformation(url: String, login: String, password: String, + httpLogin: String, httpPassword: String, + isSelfSignedCert: Boolean) { + settings.putString("url", url) + settings.putString("login", login) + settings.putString("httpUserName", httpLogin) + settings.putString("password", password) + settings.putString("httpPassword", httpPassword) + settings.putBoolean("isSelfSignedCert", isSelfSignedCert) + baseUrl = url api.refreshLoginInformation() - baseUrl = apiDetails.getBaseUrl() } private suspend fun updateApiVersion() { diff --git a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/ApiDetailsServiceImpl.kt b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/ApiDetailsServiceImpl.kt index a09a8dc..6256094 100644 --- a/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/ApiDetailsServiceImpl.kt +++ b/shared/src/commonMain/kotlin/bou/amine/apps/readerforselfossv2/service/ApiDetailsServiceImpl.kt @@ -47,7 +47,6 @@ class ApiDetailsServiceImpl : ApiDetailsService { _password = settings.getString("password", "") _userName = settings.getString("login", "") _baseUrl = settings.getString("url", "") - _baseUrl = settings.getString("url", "") _apiVersion = settings.getInt("apiVersionMajor", -1) } } \ No newline at end of file