Temporary workaround for #83.

This commit is contained in:
Amine 2017-10-23 15:09:23 +02:00
parent e1476c5840
commit 0812259470
3 changed files with 24 additions and 16 deletions

View File

@ -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.

View File

@ -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)
}
}
}

View File

@ -155,4 +155,5 @@
<string name="login_everything_off">No api call will be logged</string>
<string name="pref_general_infinite_loading_title">(BETA) Load more articles on scroll</string>
<string name="translation">Translation</string>
<string name="cant_open_invalid_url">The item url is invalid. I\'m looking into solving this issue so the app won\'t crash.</string>
</resources>