mirror of
				https://github.com/mihonapp/mihon.git
				synced 2025-10-30 22:07:57 +01:00 
			
		
		
		
	Fix #704. Dependency updates
This commit is contained in:
		| @@ -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) | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @@ -10,7 +10,7 @@ import rx.Subscription | ||||
| import java.util.concurrent.atomic.AtomicBoolean | ||||
|  | ||||
| fun Call.asObservable(): Observable<Response> { | ||||
|     return Observable.create { subscriber -> | ||||
|     return Observable.unsafeCreate { subscriber -> | ||||
|         // Since Call is a one-shot type, clone it for each new subscriber. | ||||
|         val call = clone() | ||||
|  | ||||
|   | ||||
| @@ -607,13 +607,17 @@ class ReaderPresenter : BasePresenter<ReaderActivity>() { | ||||
|                         } | ||||
|                     } | ||||
|  | ||||
|                     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) | ||||
|                 }) | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -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 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user