From f3080b6277c6c8bc550fd4d4405a46029742719e Mon Sep 17 00:00:00 2001 From: len Date: Sun, 10 Sep 2017 12:29:04 +0200 Subject: [PATCH] Actually convert file uri to content uri --- app/src/main/java/eu/kanade/tachiyomi/App.kt | 4 ---- app/src/main/java/eu/kanade/tachiyomi/Migrations.kt | 10 ++++++++++ .../eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt | 12 +++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/App.kt b/app/src/main/java/eu/kanade/tachiyomi/App.kt index 8a8a1852c..9fd73b878 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/App.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/App.kt @@ -3,7 +3,6 @@ package eu.kanade.tachiyomi import android.app.Application import android.content.Context import android.content.res.Configuration -import android.os.StrictMode import android.support.multidex.MultiDex import com.evernote.android.job.JobManager import eu.kanade.tachiyomi.data.backup.BackupCreatorJob @@ -33,9 +32,6 @@ open class App : Application() { if (BuildConfig.DEBUG) Timber.plant(Timber.DebugTree()) - // Disable file uri exposure detection - StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder().build()) - setupAcra() setupJobManager() diff --git a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt index de568c725..a35521d98 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/Migrations.kt @@ -45,6 +45,16 @@ object Migrations { } } } + if (oldVersion < 26) { + // Delete external chapter cache dir. + val extCache = context.externalCacheDir + if (extCache != null) { + val chapterCache = File(extCache, "chapter_disk_cache") + if (chapterCache.exists()) { + chapterCache.deleteRecursively() + } + } + } return true } return false diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt index 70ee64520..1c73097af 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderActivity.kt @@ -27,10 +27,7 @@ import eu.kanade.tachiyomi.ui.reader.viewer.pager.horizontal.LeftToRightReader import eu.kanade.tachiyomi.ui.reader.viewer.pager.horizontal.RightToLeftReader import eu.kanade.tachiyomi.ui.reader.viewer.pager.vertical.VerticalReader import eu.kanade.tachiyomi.ui.reader.viewer.webtoon.WebtoonReader -import eu.kanade.tachiyomi.util.GLUtil -import eu.kanade.tachiyomi.util.SharedData -import eu.kanade.tachiyomi.util.plusAssign -import eu.kanade.tachiyomi.util.toast +import eu.kanade.tachiyomi.util.* import eu.kanade.tachiyomi.widget.SimpleAnimationListener import eu.kanade.tachiyomi.widget.SimpleSeekBarListener import kotlinx.android.synthetic.main.reader_activity.* @@ -42,6 +39,7 @@ import rx.android.schedulers.AndroidSchedulers import rx.subscriptions.CompositeSubscription import timber.log.Timber import uy.kohesive.injekt.injectLazy +import java.io.File import java.text.DecimalFormat import java.util.concurrent.TimeUnit @@ -572,8 +570,12 @@ class ReaderActivity : BaseRxActivity() { if (page.status != Page.READY) return + var uri = page.uri ?: return + if (uri.toString().startsWith("file://")) { + uri = File(uri.toString().substringAfter("file://")).getUriCompat(this) + } val intent = Intent(Intent.ACTION_SEND).apply { - putExtra(Intent.EXTRA_STREAM, page.uri) + putExtra(Intent.EXTRA_STREAM, uri) flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION type = "image/*" }