From 270d959ee05a8b9e03ee4f145667a5ebc81d02fd Mon Sep 17 00:00:00 2001 From: aminecmi Date: Sat, 24 Sep 2022 14:55:06 +0200 Subject: [PATCH] Cleaning. --- .../apps/readerforselfossv2/android/AddSourceActivity.kt | 4 ++-- .../amine/apps/readerforselfossv2/android/LoginActivity.kt | 4 ++-- .../readerforselfossv2/android/fragments/ArticleFragment.kt | 4 ++-- .../amine/apps/readerforselfossv2/android/utils/LinksUtils.kt | 4 ++-- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/AddSourceActivity.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/AddSourceActivity.kt index 0c7093c..3cec99e 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/AddSourceActivity.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/AddSourceActivity.kt @@ -9,7 +9,7 @@ import androidx.constraintlayout.widget.ConstraintLayout import bou.amine.apps.readerforselfossv2.android.databinding.ActivityAddSourceBinding import bou.amine.apps.readerforselfossv2.android.themes.AppColors import bou.amine.apps.readerforselfossv2.android.themes.Toppings -import bou.amine.apps.readerforselfossv2.android.utils.isBaseUrlValid +import bou.amine.apps.readerforselfossv2.android.utils.isBaseUrlInvalid import bou.amine.apps.readerforselfossv2.model.NetworkUnavailableException import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.service.AppSettingsService @@ -84,7 +84,7 @@ class AddSourceActivity : AppCompatActivity(), DIAware { super.onResume() val baseUrl = appSettingsService.getBaseUrl() - if (baseUrl.isEmpty() || !baseUrl.isBaseUrlValid(this@AddSourceActivity)) { + if (baseUrl.isEmpty() || baseUrl.isBaseUrlInvalid(this@AddSourceActivity)) { mustLoginToAddSource() } else { handleSpoutsSpinner(binding.spoutsSpinner, binding.progress, binding.formContainer) 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 c7883b6..be92dd2 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 @@ -14,7 +14,7 @@ import androidx.appcompat.app.AlertDialog import androidx.appcompat.app.AppCompatActivity import bou.amine.apps.readerforselfossv2.android.databinding.ActivityLoginBinding import bou.amine.apps.readerforselfossv2.android.themes.AppColors -import bou.amine.apps.readerforselfossv2.android.utils.isBaseUrlValid +import bou.amine.apps.readerforselfossv2.android.utils.isBaseUrlInvalid import bou.amine.apps.readerforselfossv2.repository.Repository import bou.amine.apps.readerforselfossv2.service.AppSettingsService import com.mikepenz.aboutlibraries.LibsBuilder @@ -122,7 +122,7 @@ class LoginActivity : AppCompatActivity(), DIAware { var cancel = false var focusView: View? = null - if (!url.isBaseUrlValid(this@LoginActivity)) { + if (url.isBaseUrlInvalid(this@LoginActivity)) { binding.urlView.error = getString(R.string.login_url_problem) focusView = binding.urlView cancel = true diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt index f50786a..7e24dea 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/fragments/ArticleFragment.kt @@ -268,8 +268,8 @@ class ArticleFragment : Fragment(), DIAware { private fun getContentFromMercury(customTabsIntent: CustomTabsIntent) { if (repository.isNetworkAvailable()) { - binding.progressBar.visibility = View.VISIBLE - val parser = MercuryApi() + binding.progressBar.visibility = View.VISIBLE + val parser = MercuryApi() parser.parseUrl(url).enqueue( object : Callback { diff --git a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/LinksUtils.kt b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/LinksUtils.kt index 1fc608a..600864b 100644 --- a/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/LinksUtils.kt +++ b/androidApp/src/main/java/bou/amine/apps/readerforselfossv2/android/utils/LinksUtils.kt @@ -163,7 +163,7 @@ private fun openInBrowser(linkDecoded: String, app: Activity) { fun String.isUrlValid(): Boolean = this.toHttpUrlOrNull() != null && Patterns.WEB_URL.matcher(this).matches() -fun String.isBaseUrlValid(ctx: Context): Boolean { +fun String.isBaseUrlInvalid(ctx: Context): Boolean { val baseUrl = this.toHttpUrlOrNull() var existsAndEndsWithSlash = false if (baseUrl != null) { @@ -171,7 +171,7 @@ fun String.isBaseUrlValid(ctx: Context): Boolean { existsAndEndsWithSlash = "" == pathSegments[pathSegments.size - 1] } - return Patterns.WEB_URL.matcher(this).matches() && existsAndEndsWithSlash + return !(Patterns.WEB_URL.matcher(this).matches() && existsAndEndsWithSlash) } fun Context.openInBrowserAsNewTask(i: SelfossModel.Item) {