From b512c67b5d721520a3055539408afe8e575b750e Mon Sep 17 00:00:00 2001 From: len Date: Sat, 11 Mar 2017 16:00:07 +0100 Subject: [PATCH] Fix #704. Dependency updates --- app/build.gradle | 8 +++---- .../data/notification/NotificationReceiver.kt | 24 +++++++++---------- .../tachiyomi/network/OkHttpExtensions.kt | 2 +- .../tachiyomi/ui/reader/ReaderPresenter.kt | 14 +++++++---- .../java/eu/kanade/tachiyomi/util/DiskUtil.kt | 16 +++++++++++++ 5 files changed, 42 insertions(+), 22 deletions(-) diff --git a/app/build.gradle b/app/build.gradle index a45af1ec2e..aea6280e32 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -114,13 +114,13 @@ dependencies { compile "com.android.support:support-annotations:$support_library_version" compile "com.android.support:customtabs:$support_library_version" - compile 'com.android.support.constraint:constraint-layout:1.0.0' + compile 'com.android.support.constraint:constraint-layout:1.0.2' compile 'com.android.support:multidex:1.0.1' // ReactiveX compile 'io.reactivex:rxandroid:1.2.1' - compile 'io.reactivex:rxjava:1.2.6' + compile 'io.reactivex:rxjava:1.2.7' compile 'com.jakewharton.rxrelay:rxrelay:1.2.0' compile 'com.f2prateek.rx.preferences:rx-preferences:1.0.2' compile 'com.github.pwittchen:reactivenetwork:0.7.0' @@ -153,7 +153,7 @@ dependencies { compile 'org.jsoup:jsoup:1.10.2' // Job scheduling - compile 'com.evernote:android-job:1.1.6' + compile 'com.evernote:android-job:1.1.7' compile 'com.google.android.gms:play-services-gcm:10.2.0' // Changelog @@ -193,7 +193,7 @@ dependencies { compile 'com.github.inorichi:FlexibleAdapter:93985fe' // v4.2.0 to be removed compile 'com.nononsenseapps:filepicker:2.5.2' compile 'com.github.amulyakhare:TextDrawable:558677e' - compile 'com.afollestad.material-dialogs:core:0.9.3.0' + compile 'com.afollestad.material-dialogs:core:0.9.4.1' compile 'net.xpece.android:support-preference:1.2.5' compile 'me.zhanghai.android.systemuihelper:library:1.0.0' compile 'de.hdodenhof:circleimageview:2.1.0' diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt index ce4804ab4c..e046510175 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/notification/NotificationReceiver.kt @@ -14,10 +14,7 @@ import eu.kanade.tachiyomi.data.download.DownloadManager import eu.kanade.tachiyomi.data.download.DownloadService import eu.kanade.tachiyomi.data.library.LibraryUpdateService import eu.kanade.tachiyomi.ui.reader.ReaderActivity -import eu.kanade.tachiyomi.util.deleteIfExists -import eu.kanade.tachiyomi.util.getUriCompat -import eu.kanade.tachiyomi.util.notificationManager -import eu.kanade.tachiyomi.util.toast +import eu.kanade.tachiyomi.util.* import uy.kohesive.injekt.injectLazy import java.io.File import eu.kanade.tachiyomi.BuildConfig.APPLICATION_ID as ID @@ -120,7 +117,10 @@ class NotificationReceiver : BroadcastReceiver() { dismissNotification(context, notificationId) // Delete file - File(path).deleteIfExists() + val file = File(path) + file.deleteIfExists() + + DiskUtil.scanMedia(context, file) } /** @@ -180,7 +180,7 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_RESUME_DOWNLOADS } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT) + return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } /** @@ -193,7 +193,7 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_CLEAR_DOWNLOADS } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT) + return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } /** @@ -208,7 +208,7 @@ class NotificationReceiver : BroadcastReceiver() { action = ACTION_DISMISS_NOTIFICATION putExtra(EXTRA_NOTIFICATION_ID, notificationId) } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT) + return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } /** @@ -225,7 +225,7 @@ class NotificationReceiver : BroadcastReceiver() { putExtra(EXTRA_FILE_LOCATION, path) putExtra(EXTRA_NOTIFICATION_ID, notificationId) } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT) + return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } /** @@ -242,7 +242,7 @@ class NotificationReceiver : BroadcastReceiver() { putExtra(EXTRA_FILE_LOCATION, path) putExtra(EXTRA_NOTIFICATION_ID, notificationId) } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT) + return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } /** @@ -258,7 +258,7 @@ class NotificationReceiver : BroadcastReceiver() { putExtra(EXTRA_MANGA_ID, manga.id) putExtra(EXTRA_CHAPTER_ID, chapter.id) } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT) + return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } /** @@ -271,7 +271,7 @@ class NotificationReceiver : BroadcastReceiver() { val intent = Intent(context, NotificationReceiver::class.java).apply { action = ACTION_CANCEL_LIBRARY_UPDATE } - return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_ONE_SHOT) + return PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT) } } } \ No newline at end of file diff --git a/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt index 8016b1ac8a..ba72fb62b7 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/network/OkHttpExtensions.kt @@ -10,7 +10,7 @@ import rx.Subscription import java.util.concurrent.atomic.AtomicBoolean fun Call.asObservable(): Observable { - return Observable.create { subscriber -> + return Observable.unsafeCreate { subscriber -> // Since Call is a one-shot type, clone it for each new subscriber. val call = clone() diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt index 56bcdc9343..96f0184eef 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/reader/ReaderPresenter.kt @@ -607,13 +607,17 @@ class ReaderPresenter : BasePresenter() { } } + DiskUtil.scanMedia(context, destFile) + imageNotifier.onComplete(destFile) } .subscribeOn(Schedulers.io()) - .subscribe({}, - { error -> - Timber.e(error) - imageNotifier.onError(error.message) - }) + .observeOn(AndroidSchedulers.mainThread()) + .subscribe({ + context.toast(R.string.picture_saved) + }, { error -> + Timber.e(error) + imageNotifier.onError(error.message) + }) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt b/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt index e710bbc0fc..851461f53c 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/DiskUtil.kt @@ -1,6 +1,8 @@ package eu.kanade.tachiyomi.util import android.content.Context +import android.content.Intent +import android.net.Uri import android.os.Build import android.os.Environment import android.support.v4.content.ContextCompat @@ -98,6 +100,20 @@ object DiskUtil { return directories } + /** + * Scans the given file so that it can be shown in gallery apps, for example. + */ + fun scanMedia(context: Context, file: File) { + val action = if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) { + Intent.ACTION_MEDIA_MOUNTED + } else { + Intent.ACTION_MEDIA_SCANNER_SCAN_FILE + } + val mediaScanIntent = Intent(action) + mediaScanIntent.data = Uri.fromFile(file) + context.sendBroadcast(mediaScanIntent) + } + /** * Mutate the given filename to make it valid for a FAT filesystem, * replacing any invalid characters with "_". This method doesn't allow hidden files (starting