Do not log for test labs devices.
This commit is contained in:
parent
511553806c
commit
1d9a440ae7
@ -109,7 +109,7 @@ class AddSourceActivity : AppCompatActivity() {
|
|||||||
super.onResume()
|
super.onResume()
|
||||||
val config = Config(this)
|
val config = Config(this)
|
||||||
|
|
||||||
if (config.baseUrl.isEmpty() || !config.baseUrl.isBaseUrlValid(false)) {
|
if (config.baseUrl.isEmpty() || !config.baseUrl.isBaseUrlValid(false, this@AddSourceActivity)) {
|
||||||
mustLoginToAddSource()
|
mustLoginToAddSource()
|
||||||
} else {
|
} else {
|
||||||
handleSpoutsSpinner(spoutsSpinner, api, progress, formContainer)
|
handleSpoutsSpinner(spoutsSpinner, api, progress, formContainer)
|
||||||
|
@ -54,7 +54,6 @@ class LoginActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
handleBaseUrlFail()
|
handleBaseUrlFail()
|
||||||
|
|
||||||
|
|
||||||
settings = getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE)
|
settings = getSharedPreferences(Config.settingsName, Context.MODE_PRIVATE)
|
||||||
userIdentifier = settings.getString("unique_id", "")
|
userIdentifier = settings.getString("unique_id", "")
|
||||||
logErrors = settings.getBoolean("login_debug", false)
|
logErrors = settings.getBoolean("login_debug", false)
|
||||||
@ -145,7 +144,7 @@ class LoginActivity : AppCompatActivity() {
|
|||||||
var cancel = false
|
var cancel = false
|
||||||
var focusView: View? = null
|
var focusView: View? = null
|
||||||
|
|
||||||
if (!url.isBaseUrlValid(logErrors)) {
|
if (!url.isBaseUrlValid(logErrors, this@LoginActivity)) {
|
||||||
urlView.error = getString(R.string.login_url_problem)
|
urlView.error = getString(R.string.login_url_problem)
|
||||||
focusView = urlView
|
focusView = urlView
|
||||||
cancel = true
|
cancel = true
|
||||||
|
@ -2,15 +2,21 @@ package apps.amine.bou.readerforselfoss.utils
|
|||||||
|
|
||||||
import android.content.Context
|
import android.content.Context
|
||||||
import android.preference.PreferenceManager
|
import android.preference.PreferenceManager
|
||||||
|
import android.provider.Settings
|
||||||
import org.acra.ErrorReporter
|
import org.acra.ErrorReporter
|
||||||
|
|
||||||
fun ErrorReporter.maybeHandleSilentException(throwable: Throwable, ctx: Context) {
|
fun ErrorReporter.maybeHandleSilentException(throwable: Throwable, ctx: Context) {
|
||||||
val sharedPref = PreferenceManager.getDefaultSharedPreferences(ctx)
|
val sharedPref = PreferenceManager.getDefaultSharedPreferences(ctx)
|
||||||
if (sharedPref.getBoolean("acra_should_log", false)) {
|
val isTestLab = Settings.System.getString(ctx.contentResolver, "firebase.test.lab") == "true"
|
||||||
|
|
||||||
|
if (sharedPref.getBoolean("acra_should_log", false) && !isTestLab) {
|
||||||
this.handleSilentException(throwable)
|
this.handleSilentException(throwable)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ErrorReporter.doHandleSilentException(throwable: Throwable) {
|
fun ErrorReporter.doHandleSilentException(throwable: Throwable, ctx: Context) {
|
||||||
|
val isTestLab = Settings.System.getString(ctx.contentResolver, "firebase.test.lab") == "true"
|
||||||
|
if (!isTestLab) {
|
||||||
this.handleSilentException(throwable)
|
this.handleSilentException(throwable)
|
||||||
|
}
|
||||||
}
|
}
|
@ -135,7 +135,7 @@ private fun openInBrowser(linkDecoded: String, app: Activity) {
|
|||||||
fun String.isUrlValid(): Boolean =
|
fun String.isUrlValid(): Boolean =
|
||||||
HttpUrl.parse(this) != null && Patterns.WEB_URL.matcher(this).matches()
|
HttpUrl.parse(this) != null && Patterns.WEB_URL.matcher(this).matches()
|
||||||
|
|
||||||
fun String.isBaseUrlValid(logErrors: Boolean): Boolean {
|
fun String.isBaseUrlValid(logErrors: Boolean, ctx: Context): Boolean {
|
||||||
val baseUrl = HttpUrl.parse(this)
|
val baseUrl = HttpUrl.parse(this)
|
||||||
var existsAndEndsWithSlash = false
|
var existsAndEndsWithSlash = false
|
||||||
if (baseUrl != null) {
|
if (baseUrl != null) {
|
||||||
@ -145,7 +145,7 @@ fun String.isBaseUrlValid(logErrors: Boolean): Boolean {
|
|||||||
|
|
||||||
val isValid = Patterns.WEB_URL.matcher(this).matches() && existsAndEndsWithSlash
|
val isValid = Patterns.WEB_URL.matcher(this).matches() && existsAndEndsWithSlash
|
||||||
if (!isValid && logErrors) {
|
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()}"))
|
ACRA.getErrorReporter().doHandleSilentException(java.lang.Exception("Patterns.WEB_URL.matcher(this).matches() == ${Patterns.WEB_URL.matcher(this).matches()} && existsAndEndsWithSlash == $existsAndEndsWithSlash && baseUrl.pathSegments() == ${baseUrl?.pathSegments()}"), ctx)
|
||||||
}
|
}
|
||||||
return isValid
|
return isValid
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user