Allow to share images when reading online. Move chapter cache to external cache dir. Dependency updates.

This commit is contained in:
len
2016-11-29 21:37:35 +01:00
parent 86b8712dd1
commit d30c019b89
12 changed files with 51 additions and 71 deletions

View File

@@ -14,23 +14,29 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.data.preference.getOrDefault
import eu.kanade.tachiyomi.data.updater.UpdateCheckerJob
import it.gmariotti.changelibs.library.view.ChangeLogRecyclerView
import java.io.File
class ChangelogDialogFragment : DialogFragment() {
companion object {
fun show(preferences: PreferencesHelper, fragmentManager: FragmentManager) {
fun show(context: Context, preferences: PreferencesHelper, fm: FragmentManager) {
val oldVersion = preferences.lastVersionCode().getOrDefault()
if (oldVersion < BuildConfig.VERSION_CODE) {
preferences.lastVersionCode().set(BuildConfig.VERSION_CODE)
ChangelogDialogFragment().show(fragmentManager, "changelog")
ChangelogDialogFragment().show(fm, "changelog")
// FIXME Ugly check to restore jobs. Remove me in a few months :D
// TODO better upgrades management
if (oldVersion < 14) {
// Restore jobs after upgrading to evernote's job scheduler.
if (BuildConfig.INCLUDE_UPDATER && preferences.automaticUpdates()) {
UpdateCheckerJob.setupTask()
}
LibraryUpdateJob.setupTask()
}
if (oldVersion < 15) {
// Delete internal chapter cache dir.
File(context.cacheDir, "chapter_disk_cache").deleteRecursively()
}
}
}
}

View File

@@ -11,8 +11,8 @@ import eu.kanade.tachiyomi.data.preference.PreferencesHelper
import eu.kanade.tachiyomi.ui.backup.BackupFragment
import eu.kanade.tachiyomi.ui.base.activity.BaseActivity
import eu.kanade.tachiyomi.ui.catalogue.CatalogueFragment
import eu.kanade.tachiyomi.ui.latest_updates.LatestUpdatesFragment
import eu.kanade.tachiyomi.ui.download.DownloadFragment
import eu.kanade.tachiyomi.ui.latest_updates.LatestUpdatesFragment
import eu.kanade.tachiyomi.ui.library.LibraryFragment
import eu.kanade.tachiyomi.ui.recent_updates.RecentChaptersFragment
import eu.kanade.tachiyomi.ui.recently_read.RecentlyReadFragment
@@ -79,7 +79,7 @@ class MainActivity : BaseActivity() {
setSelectedDrawerItem(startScreenId)
// Show changelog if needed
ChangelogDialogFragment.show(preferences, supportFragmentManager)
ChangelogDialogFragment.show(this, preferences, supportFragmentManager)
}
}

View File

@@ -480,7 +480,7 @@ class ReaderActivity : BaseRxActivity<ReaderPresenter>() {
val intent = Intent(Intent.ACTION_SEND).apply {
putExtra(Intent.EXTRA_STREAM, page.uri)
flags = Intent.FLAG_ACTIVITY_NEW_TASK
flags = Intent.FLAG_ACTIVITY_NEW_TASK or Intent.FLAG_GRANT_READ_URI_PERMISSION
type = "image/*"
}
startActivity(Intent.createChooser(intent, getString(R.string.action_share)))

View File

@@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer.pager
import android.content.Context
import android.graphics.PointF
import android.os.Build
import android.util.AttributeSet
import android.view.MotionEvent
import android.view.View
@@ -24,7 +23,6 @@ import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
import rx.subjects.PublishSubject
import rx.subjects.SerializedSubject
import java.io.File
import java.util.concurrent.TimeUnit
class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet? = null)
@@ -216,12 +214,7 @@ class PageView @JvmOverloads constructor(context: Context, attrs: AttributeSet?
return
}
val file = if (Build.VERSION.SDK_INT < 21 || UniFile.isFileUri(uri)) {
UniFile.fromFile(File(uri.path))
} else {
// Tree uri returns the root folder
UniFile.fromSingleUri(context, uri)
}!!
val file = UniFile.fromUri(context, uri)
if (!file.exists()) {
page.status = Page.ERROR
return

View File

@@ -1,6 +1,5 @@
package eu.kanade.tachiyomi.ui.reader.viewer.webtoon
import android.os.Build
import android.support.v7.widget.RecyclerView
import android.view.MotionEvent
import android.view.View
@@ -20,7 +19,6 @@ import rx.Subscription
import rx.android.schedulers.AndroidSchedulers
import rx.subjects.PublishSubject
import rx.subjects.SerializedSubject
import java.io.File
import java.util.concurrent.TimeUnit
/**
@@ -250,12 +248,7 @@ class WebtoonHolder(private val view: View, private val adapter: WebtoonAdapter)
return
}
val file = if (Build.VERSION.SDK_INT < 21 || UniFile.isFileUri(uri)) {
UniFile.fromFile(File(uri.path))
} else {
// Tree uri returns the root folder
UniFile.fromSingleUri(context, uri)
}!!
val file = UniFile.fromUri(context, uri)
if (!file.exists()) {
page?.status = Page.ERROR
return

View File

@@ -116,7 +116,7 @@ class SettingsDownloadsFragment : SettingsFragment() {
@Suppress("NewApi")
context.contentResolver.takePersistableUriPermission(uri, flags)
val file = UniFile.fromTreeUri(context, uri)
val file = UniFile.fromUri(context, uri)
preferences.downloadsDirectory().set(file.uri.toString())
}
}