diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a79a8f..c62b0de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,8 @@ - Fixed logs not working. +- Temporary workaround handling opening invalid urls. Waiting to solve #83. + **1.5.3.05** - Fixed an issue on older versions of Android. diff --git a/app/src/main/java/apps/amine/bou/readerforselfoss/utils/LinksUtils.kt b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/LinksUtils.kt index 1bb72e9..e037a58 100644 --- a/app/src/main/java/apps/amine/bou/readerforselfoss/utils/LinksUtils.kt +++ b/app/src/main/java/apps/amine/bou/readerforselfoss/utils/LinksUtils.kt @@ -8,6 +8,7 @@ import android.graphics.BitmapFactory import android.net.Uri import android.support.customtabs.CustomTabsIntent import android.util.Patterns +import android.widget.Toast import apps.amine.bou.readerforselfoss.R import apps.amine.bou.readerforselfoss.ReaderActivity import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper @@ -54,30 +55,34 @@ fun Context.openItemUrl(linkDecoded: String, articleViewer: Boolean, app: Activity) { - if (!internalBrowser || !linkDecoded.isUrlValid()) { - openInBrowser(linkDecoded, app) + if (!linkDecoded.isUrlValid()) { + Toast.makeText(this, this.getString(R.string.cant_open_invalid_url), Toast.LENGTH_LONG).show() } else { - if (articleViewer) { - val intent = Intent(this, ReaderActivity::class.java) + if (!internalBrowser) { + openInBrowser(linkDecoded, app) + } else { + if (articleViewer) { + val intent = Intent(this, ReaderActivity::class.java) - DragDismissIntentBuilder(this) + DragDismissIntentBuilder(this) .setFullscreenOnTablets(true) // defaults to false, tablets will have padding on each side .setDragElasticity(DragDismissIntentBuilder.DragElasticity.NORMAL) // Larger elasticities will make it easier to dismiss. .setDrawUnderStatusBar(true) .build(intent) - intent.putExtra("url", linkDecoded) - app.startActivity(intent) - } else { - try { - CustomTabActivityHelper.openCustomTab(app, customTabsIntent, Uri.parse(linkDecoded) - ) { _, uri -> - val intent = Intent(Intent.ACTION_VIEW, uri) - intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK - startActivity(intent) + intent.putExtra("url", linkDecoded) + app.startActivity(intent) + } else { + try { + CustomTabActivityHelper.openCustomTab(app, customTabsIntent, Uri.parse(linkDecoded) + ) { _, uri -> + val intent = Intent(Intent.ACTION_VIEW, uri) + intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK + startActivity(intent) + } + } catch (e: Exception) { + openInBrowser(linkDecoded, app) } - } catch (e: Exception) { - openInBrowser(linkDecoded, app) } } } diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index ac8647d..f0a3f93 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -155,4 +155,5 @@ No api call will be logged (BETA) Load more articles on scroll Translation + The item url is invalid. I\'m looking into solving this issue so the app won\'t crash. \ No newline at end of file