Bug fixes (#49)

* Version updates.

* Fixed 'Calling startActivity() from outside of an Activity'

* Fixes #47

* Anydpi icons causing crashes.
This commit is contained in:
Amine Bou 2017-07-14 09:29:25 +02:00 committed by GitHub
parent 90a8fac8d4
commit f2e38a4203
19 changed files with 34 additions and 41 deletions

View File

@ -90,9 +90,9 @@ dependencies {
compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support.constraint:constraint-layout:1.0.2'
// Firebase + crashlytics // Firebase + crashlytics
compile 'com.google.firebase:firebase-core:11.0.1' compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-config:11.0.1' compile 'com.google.firebase:firebase-config:11.0.2'
compile 'com.google.firebase:firebase-invites:11.0.1' compile 'com.google.firebase:firebase-invites:11.0.2'
compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') { compile('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
transitive = true transitive = true
} }
@ -128,7 +128,7 @@ dependencies {
compile 'com.github.stkent:amplify:1.5.0' compile 'com.github.stkent:amplify:1.5.0'
// For the article reader // For the article reader
compile 'com.klinkerapps:drag-dismiss-activity:1.4.1' compile 'com.klinkerapps:drag-dismiss-activity:1.4.2'
// Drawer // Drawer
compile('com.mikepenz:materialdrawer:5.9.3@aar') { compile('com.mikepenz:materialdrawer:5.9.3@aar') {

View File

@ -22,6 +22,7 @@ import apps.amine.bou.readerforselfoss.api.mercury.MercuryApi
import apps.amine.bou.readerforselfoss.api.mercury.ParsedContent import apps.amine.bou.readerforselfoss.api.mercury.ParsedContent
import apps.amine.bou.readerforselfoss.utils.buildCustomTabsIntent import apps.amine.bou.readerforselfoss.utils.buildCustomTabsIntent
import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper import apps.amine.bou.readerforselfoss.utils.customtabs.CustomTabActivityHelper
import apps.amine.bou.readerforselfoss.utils.openItemUrl
import apps.amine.bou.readerforselfoss.utils.shareLink import apps.amine.bou.readerforselfoss.utils.shareLink
import com.ftinc.scoop.Scoop import com.ftinc.scoop.Scoop
@ -84,10 +85,12 @@ class ReaderActivity : DragDismissActivity() {
} }
browserBtn.setOnClickListener { browserBtn.setOnClickListener {
val intent = Intent(Intent.ACTION_VIEW) this@ReaderActivity.openItemUrl(
intent.flags = Intent.FLAG_ACTIVITY_NEW_TASK response.body()!!.url,
intent.data = Uri.parse(response.body()!!.url) customTabsIntent,
startActivity(intent) false,
false,
this@ReaderActivity)
} }
hideProgressBar() hideProgressBar()

View File

@ -212,7 +212,7 @@ class ItemCardAdapter(private val app: Activity,
helper.bindCustomTabsService(app) helper.bindCustomTabsService(app)
mView.setOnClickListener { mView.setOnClickListener {
c.openItemUrl(items[adapterPosition], c.openItemUrl(items[adapterPosition].getLinkDecoded(),
customTabsIntent, customTabsIntent,
internalBrowser, internalBrowser,
articleViewer, articleViewer,

View File

@ -223,7 +223,7 @@ class ItemListAdapter(private val app: Activity,
if (!clickBehavior) { if (!clickBehavior) {
mView.setOnClickListener { mView.setOnClickListener {
c.openItemUrl(items[adapterPosition], c.openItemUrl(items[adapterPosition].getLinkDecoded(),
customTabsIntent, customTabsIntent,
internalBrowser, internalBrowser,
articleViewer, articleViewer,
@ -236,7 +236,7 @@ class ItemListAdapter(private val app: Activity,
} else { } else {
mView.setOnClickListener { actionBarShowHide() } mView.setOnClickListener { actionBarShowHide() }
mView.setOnLongClickListener { mView.setOnLongClickListener {
c.openItemUrl(items[adapterPosition], c.openItemUrl(items[adapterPosition].getLinkDecoded(),
customTabsIntent, customTabsIntent,
internalBrowser, internalBrowser,
articleViewer, articleViewer,

View File

@ -206,7 +206,7 @@ public class SettingsActivity extends AppCompatPreferenceActivity {
public void onHeaderClick(Header header, int position) { public void onHeaderClick(Header header, int position) {
super.onHeaderClick(header, position); super.onHeaderClick(header, position);
if (header.id == R.id.theme_change) { if (header.id == R.id.theme_change) {
getBaseContext().startActivity(ScoopSettingsActivity.createIntent(getApplicationContext())); getApplicationContext().startActivity(ScoopSettingsActivity.createIntent(getApplicationContext()));
finish(); finish();
} }
} }

View File

@ -50,15 +50,13 @@ fun Context.buildCustomTabsIntent(): CustomTabsIntent {
return intentBuilder.build() return intentBuilder.build()
} }
fun Context.openItemUrl(i: Item, fun Context.openItemUrl(linkDecoded: String,
customTabsIntent: CustomTabsIntent, customTabsIntent: CustomTabsIntent,
internalBrowser: Boolean, internalBrowser: Boolean,
articleViewer: Boolean, articleViewer: Boolean,
app: Activity) { app: Activity) {
if (!internalBrowser) { if (!internalBrowser) {
val intent = Intent(Intent.ACTION_VIEW) openInBrowser(linkDecoded, app)
intent.data = Uri.parse(i.getLinkDecoded())
app.startActivity(intent)
} else { } else {
if (articleViewer) { if (articleViewer) {
val intent = Intent(this, ReaderActivity::class.java) val intent = Intent(this, ReaderActivity::class.java)
@ -68,15 +66,25 @@ fun Context.openItemUrl(i: Item,
.setDragElasticity(DragDismissIntentBuilder.DragElasticity.NORMAL) // Larger elasticities will make it easier to dismiss. .setDragElasticity(DragDismissIntentBuilder.DragElasticity.NORMAL) // Larger elasticities will make it easier to dismiss.
.build(intent) .build(intent)
intent.putExtra("url", i.getLinkDecoded()) intent.putExtra("url", linkDecoded)
app.startActivity(intent) app.startActivity(intent)
} else { } else {
CustomTabActivityHelper.openCustomTab(app, customTabsIntent, Uri.parse(i.getLinkDecoded()) try {
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)
}
} }
} }
} }
private fun openInBrowser(linkDecoded: String, app: Activity) {
val intent = Intent(Intent.ACTION_VIEW)
intent.data = Uri.parse(linkDecoded)
app.startActivity(intent)
}

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M11,17h2v-6h-2v6zM12,2C6.48,2 2,6.48 2,12s4.48,10 10,10 10,-4.48 10,-10S17.52,2 12,2zM12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8 8,3.59 8,8 -3.59,8 -8,8zM11,9h2L13,7h-2v2z"/>
</vector>

View File

@ -1,9 +0,0 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#FF000000"
android:pathData="M19.43,12.98c0.04,-0.32 0.07,-0.64 0.07,-0.98s-0.03,-0.66 -0.07,-0.98l2.11,-1.65c0.19,-0.15 0.24,-0.42 0.12,-0.64l-2,-3.46c-0.12,-0.22 -0.39,-0.3 -0.61,-0.22l-2.49,1c-0.52,-0.4 -1.08,-0.73 -1.69,-0.98l-0.38,-2.65C14.46,2.18 14.25,2 14,2h-4c-0.25,0 -0.46,0.18 -0.49,0.42l-0.38,2.65c-0.61,0.25 -1.17,0.59 -1.69,0.98l-2.49,-1c-0.23,-0.09 -0.49,0 -0.61,0.22l-2,3.46c-0.13,0.22 -0.07,0.49 0.12,0.64l2.11,1.65c-0.04,0.32 -0.07,0.65 -0.07,0.98s0.03,0.66 0.07,0.98l-2.11,1.65c-0.19,0.15 -0.24,0.42 -0.12,0.64l2,3.46c0.12,0.22 0.39,0.3 0.61,0.22l2.49,-1c0.52,0.4 1.08,0.73 1.69,0.98l0.38,2.65c0.03,0.24 0.24,0.42 0.49,0.42h4c0.25,0 0.46,-0.18 0.49,-0.42l0.38,-2.65c0.61,-0.25 1.17,-0.59 1.69,-0.98l2.49,1c0.23,0.09 0.49,0 0.61,-0.22l2,-3.46c0.12,-0.22 0.07,-0.49 -0.12,-0.64l-2.11,-1.65zM12,15.5c-1.93,0 -3.5,-1.57 -3.5,-3.5s1.57,-3.5 3.5,-3.5 3.5,1.57 3.5,3.5 -1.57,3.5 -3.5,3.5z"/>
</vector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 355 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 339 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 725 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 606 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 907 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

@ -1,7 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules. // Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript { buildscript {
ext.kotlin_version = '1.1.3' ext.kotlin_version = '1.1.3-2'
repositories { repositories {
maven { url 'https://maven.google.com' } maven { url 'https://maven.google.com' }
jcenter() jcenter()