Temporary workaround for #83.
This commit is contained in:
parent
e1476c5840
commit
0812259470
@ -4,6 +4,8 @@
|
|||||||
|
|
||||||
- Fixed logs not working.
|
- Fixed logs not working.
|
||||||
|
|
||||||
|
- Temporary workaround handling opening invalid urls. Waiting to solve #83.
|
||||||
|
|
||||||
**1.5.3.05**
|
**1.5.3.05**
|
||||||
|
|
||||||
- Fixed an issue on older versions of Android.
|
- Fixed an issue on older versions of Android.
|
||||||
|
@ -8,6 +8,7 @@ import android.graphics.BitmapFactory
|
|||||||
import android.net.Uri
|
import android.net.Uri
|
||||||
import android.support.customtabs.CustomTabsIntent
|
import android.support.customtabs.CustomTabsIntent
|
||||||
import android.util.Patterns
|
import android.util.Patterns
|
||||||
|
import android.widget.Toast
|
||||||
import apps.amine.bou.readerforselfoss.R
|
import apps.amine.bou.readerforselfoss.R
|
||||||
import apps.amine.bou.readerforselfoss.ReaderActivity
|
import apps.amine.bou.readerforselfoss.ReaderActivity
|
||||||
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
|
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
|
||||||
@ -54,30 +55,34 @@ fun Context.openItemUrl(linkDecoded: String,
|
|||||||
articleViewer: Boolean,
|
articleViewer: Boolean,
|
||||||
app: Activity) {
|
app: Activity) {
|
||||||
|
|
||||||
if (!internalBrowser || !linkDecoded.isUrlValid()) {
|
if (!linkDecoded.isUrlValid()) {
|
||||||
openInBrowser(linkDecoded, app)
|
Toast.makeText(this, this.getString(R.string.cant_open_invalid_url), Toast.LENGTH_LONG).show()
|
||||||
} else {
|
} else {
|
||||||
if (articleViewer) {
|
if (!internalBrowser) {
|
||||||
val intent = Intent(this, ReaderActivity::class.java)
|
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
|
.setFullscreenOnTablets(true) // defaults to false, tablets will have padding on each side
|
||||||
.setDragElasticity(DragDismissIntentBuilder.DragElasticity.NORMAL) // Larger elasticities will make it easier to dismiss.
|
.setDragElasticity(DragDismissIntentBuilder.DragElasticity.NORMAL) // Larger elasticities will make it easier to dismiss.
|
||||||
.setDrawUnderStatusBar(true)
|
.setDrawUnderStatusBar(true)
|
||||||
.build(intent)
|
.build(intent)
|
||||||
|
|
||||||
intent.putExtra("url", linkDecoded)
|
intent.putExtra("url", linkDecoded)
|
||||||
app.startActivity(intent)
|
app.startActivity(intent)
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
CustomTabActivityHelper.openCustomTab(app, customTabsIntent, Uri.parse(linkDecoded)
|
CustomTabActivityHelper.openCustomTab(app, customTabsIntent, Uri.parse(linkDecoded)
|
||||||
) { _, uri ->
|
) { _, uri ->
|
||||||
val intent = Intent(Intent.ACTION_VIEW, uri)
|
val intent = Intent(Intent.ACTION_VIEW, uri)
|
||||||
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK
|
||||||
startActivity(intent)
|
startActivity(intent)
|
||||||
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
openInBrowser(linkDecoded, app)
|
||||||
}
|
}
|
||||||
} catch (e: Exception) {
|
|
||||||
openInBrowser(linkDecoded, app)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -155,4 +155,5 @@
|
|||||||
<string name="login_everything_off">No api call will be logged</string>
|
<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="pref_general_infinite_loading_title">(BETA) Load more articles on scroll</string>
|
||||||
<string name="translation">Translation</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>
|
</resources>
|
Loading…
Reference in New Issue
Block a user