diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt index 5e85b17bf..d41450035 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/DownloadManager.kt @@ -47,8 +47,6 @@ class DownloadManager( private val threadsSubject = BehaviorSubject.create() private var threadsSubscription: Subscription? = null - private var notificationSubscription: Subscription? = null - val queue = DownloadQueue() val imageFilenameRegex = "[^\\sa-zA-Z0-9.-]".toRegex() @@ -68,12 +66,6 @@ class DownloadManager( downloadNotifier.multipleDownloadThreads = it > 1 } - notificationSubscription = preferences.showMangaDownloadNotification().asObservable() - .subscribe { - downloadNotifier.onClear() - downloadNotifier.showNotification = it - } - downloadsSubscription = downloadsQueueSubject.flatMap { Observable.from(it) } .lift(DynamicConcurrentMergeOperator({ downloadChapter(it) }, threadsSubject)) .onBackpressureBuffer() @@ -115,10 +107,6 @@ class DownloadManager( threadsSubscription?.unsubscribe() } - if (notificationSubscription != null) { - notificationSubscription?.unsubscribe() - } - } // Create a download object for every chapter and add them to the downloads queue diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/download/ImageNotifier.kt b/app/src/main/java/eu/kanade/tachiyomi/data/download/ImageNotifier.kt index 990c5a187..1f413c5cb 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/download/ImageNotifier.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/download/ImageNotifier.kt @@ -1,10 +1,13 @@ package eu.kanade.tachiyomi.data.download import android.content.Context +import android.graphics.Bitmap import android.support.v4.app.NotificationCompat +import com.bumptech.glide.Glide +import com.bumptech.glide.request.animation.GlideAnimation +import com.bumptech.glide.request.target.SimpleTarget import eu.kanade.tachiyomi.Constants import eu.kanade.tachiyomi.R -import eu.kanade.tachiyomi.util.decodeSampledBitmap import eu.kanade.tachiyomi.util.notificationManager import java.io.File @@ -61,8 +64,27 @@ class ImageNotifier(private val context: Context) { } setContentTitle(context.getString(R.string.picture_saved)) setSmallIcon(R.drawable.ic_insert_photo_black_24dp) - setLargeIcon(file.decodeSampledBitmap(100, 100)) - setStyle(NotificationCompat.BigPictureStyle().bigPicture(file.decodeSampledBitmap(1024, 1024))) + Glide.with(context).load(file).asBitmap().into(object : SimpleTarget(100, 100) { + /** + * The method that will be called when the resource load has finished. + * @param resource the loaded resource. + */ + override fun onResourceReady(resource: Bitmap?, glideAnimation: GlideAnimation?) { + setLargeIcon(resource) + context.notificationManager.notify(notificationId, notificationBuilder.build()) + } + }) + Glide.with(context).load(file).asBitmap().into(object : SimpleTarget(512, 384) { + /** + * The method that will be called when the resource load has finished. + * @param resource the loaded resource. + */ + override fun onResourceReady(resource: Bitmap?, glideAnimation: GlideAnimation?) { + setStyle(NotificationCompat.BigPictureStyle().bigPicture(resource)) + context.notificationManager.notify(notificationId, notificationBuilder.build()) + } + }) + setAutoCancel(true) // Clear old actions if they exist diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt index fe9c092ef..46b07458f 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferenceKeys.kt @@ -72,10 +72,6 @@ class PreferenceKeys(context: Context) { val removeAfterMarkedAsRead = context.getString(R.string.pref_remove_after_marked_as_read_key) - val showMangaDownloadNotification = context.getString(R.string.pref_notifications_manga_download_key) - - val showSavePageNotification = context.getString(R.string.pref_notifications_single_page_key) - val libraryUpdateInterval = context.getString(R.string.pref_library_update_interval_key) val libraryUpdateRestriction = context.getString(R.string.pref_library_update_restriction_key) diff --git a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt index 6e4ade899..c18c1cd0a 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/data/preference/PreferencesHelper.kt @@ -122,10 +122,6 @@ class PreferencesHelper(context: Context) { fun removeAfterMarkedAsRead() = prefs.getBoolean(keys.removeAfterMarkedAsRead, false) - fun showMangaDownloadNotification() = rxPrefs.getBoolean(keys.showMangaDownloadNotification, true) - - fun showSavePageNotification() = prefs.getBoolean(keys.showSavePageNotification, false) - fun libraryUpdateInterval() = rxPrefs.getInteger(keys.libraryUpdateInterval, 0) fun libraryUpdateRestriction() = prefs.getStringSet(keys.libraryUpdateRestriction, emptySet()) 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 bd440bb5f..073888a9c 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 @@ -610,10 +610,7 @@ class ReaderPresenter : BasePresenter() { //Check if file doesn't already exist if (destFile.exists()) { - if (prefs.showSavePageNotification()) imageNotifier.onComplete(destFile) - else - context.toast(context.getString(R.string.page_downloaded, destFile.path)) } else { if (inputFile.exists()) { // Copy file @@ -624,10 +621,7 @@ class ReaderPresenter : BasePresenter() { { imageNotifier.onComplete(it) }, { error -> Timber.e(error.message) - if (prefs.showSavePageNotification()) imageNotifier.onError(error.message) - else - context.toast(error.message) }) } } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/FileExtensions.kt b/app/src/main/java/eu/kanade/tachiyomi/util/FileExtensions.kt deleted file mode 100644 index 44ba46f1e..000000000 --- a/app/src/main/java/eu/kanade/tachiyomi/util/FileExtensions.kt +++ /dev/null @@ -1,40 +0,0 @@ -package eu.kanade.tachiyomi.util - -import android.graphics.Bitmap -import android.graphics.BitmapFactory -import java.io.File - -fun File.decodeSampledBitmap(reqWidth: Int, reqHeight: Int): Bitmap { - // First decode with inJustDecodeBounds=true to check dimensions - val options = BitmapFactory.Options() - options.inJustDecodeBounds = true - BitmapFactory.decodeFile(this.absolutePath, options) - - // Calculate inSampleSize - options.inSampleSize = calculateInSampleSize(options, reqWidth, reqHeight) - - // Decode bitmap with inSampleSize set - options.inJustDecodeBounds = false; - return BitmapFactory.decodeFile(this.absolutePath, options) -} - -fun calculateInSampleSize(options: BitmapFactory.Options, reqWidth: Int, reqHeight: Int): Int { - // Raw height and width of image - val height = options.outHeight - val width = options.outWidth - var inSampleSize = 1 - - if (height > reqHeight || width > reqWidth) { - - val halfHeight = height / 2 - val halfWidth = width / 2 - - // Calculate the largest inSampleSize value that is a power of 2 and keeps both - // height and width larger than the requested height and width. - while (halfHeight / inSampleSize >= reqHeight && halfWidth / inSampleSize >= reqWidth) { - inSampleSize *= 2 - } - } - - return inSampleSize -} \ No newline at end of file diff --git a/app/src/main/res/values/arrays.xml b/app/src/main/res/values/arrays.xml index 52405f3a4..b491208c3 100644 --- a/app/src/main/res/values/arrays.xml +++ b/app/src/main/res/values/arrays.xml @@ -176,8 +176,8 @@ @string/set_as_cover - @string/share_image - @string/save_image + @string/action_share + @string/action_save diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 169672072..52d5ac8d3 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -59,6 +59,7 @@ Sort Install Share + Save Deleting… @@ -282,8 +283,6 @@ Custom filter Set as cover - Share image - Save image Cover updated Page copied to %1$s Downloading… diff --git a/app/src/main/res/xml/pref_downloads.xml b/app/src/main/res/xml/pref_downloads.xml index d21305ac8..8eff6f5ba 100644 --- a/app/src/main/res/xml/pref_downloads.xml +++ b/app/src/main/res/xml/pref_downloads.xml @@ -40,21 +40,6 @@ android:summary="%s" android:title="@string/pref_remove_after_read" /> - - - - - - - \ No newline at end of file diff --git a/build.gradle b/build.gradle index 5995e49e8..319ddb2e7 100644 --- a/build.gradle +++ b/build.gradle @@ -18,4 +18,4 @@ allprojects { jcenter() maven { url "https://jitpack.io" } } -} \ No newline at end of file +}