Added loging url validation.
This commit is contained in:
parent
600adc81b5
commit
d8478ebb01
@ -1,16 +1,8 @@
|
||||
buildscript {
|
||||
}
|
||||
|
||||
ext {
|
||||
configuration = [
|
||||
buildDate: new Date()
|
||||
]
|
||||
// This will make me able to build multiple times a day. May break thinks. I may forget it.
|
||||
todaysBuilds = "1"
|
||||
}
|
||||
|
||||
def gitVersion() {
|
||||
def process = "git for-each-ref refs/tags --sort=-authordate --format='%(refname:short)' --count=1".execute()
|
||||
def process = "git for-each-ref refs/tags --sort=-taggerdate --format='%(refname:short)' --count=1".execute()
|
||||
return process.text.replaceAll("'", "").substring(1).replaceAll("\\.", "").trim()
|
||||
}
|
||||
|
||||
|
@ -109,7 +109,7 @@ class AddSourceActivity : AppCompatActivity() {
|
||||
super.onResume()
|
||||
val config = Config(this)
|
||||
|
||||
if (config.baseUrl.isEmpty() || !config.baseUrl.isBaseUrlValid()) {
|
||||
if (config.baseUrl.isEmpty() || !config.baseUrl.isBaseUrlValid(false)) {
|
||||
mustLoginToAddSource()
|
||||
} else {
|
||||
handleSpoutsSpinner(spoutsSpinner, api, progress, formContainer)
|
||||
|
@ -145,7 +145,7 @@ class LoginActivity : AppCompatActivity() {
|
||||
var cancel = false
|
||||
var focusView: View? = null
|
||||
|
||||
if (!url.isBaseUrlValid()) {
|
||||
if (!url.isBaseUrlValid(logErrors)) {
|
||||
urlView.error = getString(R.string.login_url_problem)
|
||||
focusView = urlView
|
||||
cancel = true
|
||||
|
@ -9,4 +9,8 @@ fun ErrorReporter.maybeHandleSilentException(throwable: Throwable, ctx: Context)
|
||||
if (sharedPref.getBoolean("acra_should_log", false)) {
|
||||
this.handleSilentException(throwable)
|
||||
}
|
||||
}
|
||||
|
||||
fun ErrorReporter.doHandleSilentException(throwable: Throwable) {
|
||||
this.handleSilentException(throwable)
|
||||
}
|
@ -19,6 +19,7 @@ import apps.amine.bou.readerforselfoss.ReaderActivity
|
||||
import apps.amine.bou.readerforselfoss.api.selfoss.Item
|
||||
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
|
||||
import okhttp3.HttpUrl
|
||||
import org.acra.ACRA
|
||||
|
||||
fun Context.buildCustomTabsIntent(): CustomTabsIntent {
|
||||
|
||||
@ -134,7 +135,7 @@ private fun openInBrowser(linkDecoded: String, app: Activity) {
|
||||
fun String.isUrlValid(): Boolean =
|
||||
HttpUrl.parse(this) != null && Patterns.WEB_URL.matcher(this).matches()
|
||||
|
||||
fun String.isBaseUrlValid(): Boolean {
|
||||
fun String.isBaseUrlValid(logErrors: Boolean): Boolean {
|
||||
val baseUrl = HttpUrl.parse(this)
|
||||
var existsAndEndsWithSlash = false
|
||||
if (baseUrl != null) {
|
||||
@ -142,7 +143,11 @@ fun String.isBaseUrlValid(): Boolean {
|
||||
existsAndEndsWithSlash = "" == pathSegments[pathSegments.size - 1]
|
||||
}
|
||||
|
||||
return Patterns.WEB_URL.matcher(this).matches() && existsAndEndsWithSlash
|
||||
val isValid = Patterns.WEB_URL.matcher(this).matches() && existsAndEndsWithSlash
|
||||
if (!isValid && logErrors) {
|
||||
ACRA.getErrorReporter().doHandleSilentException(java.lang.Exception("Patterns.WEB_URL.matcher(this).matches() == ${Patterns.WEB_URL.matcher(this).matches()} && existsAndEndsWithSlash == $existsAndEndsWithSlash && baseUrl.pathSegments() == ${baseUrl?.pathSegments()}"))
|
||||
}
|
||||
return isValid
|
||||
}
|
||||
|
||||
fun Context.openInBrowserAsNewTask(i: Item) {
|
||||
|
Loading…
Reference in New Issue
Block a user