diff --git a/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadService.kt b/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadService.kt index 5354155ca..5b468da64 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadService.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/download/DownloadService.kt @@ -34,7 +34,6 @@ import com.hippo.ehviewer.client.EhUtils import com.hippo.ehviewer.client.data.BaseGalleryInfo import com.hippo.ehviewer.dao.DownloadInfo import com.hippo.ehviewer.ui.MainActivity -import com.hippo.ehviewer.ui.screen.DownloadsFragment import com.hippo.ehviewer.util.FileUtils import com.hippo.ehviewer.util.ReadableTime import com.hippo.ehviewer.util.SimpleHandler @@ -187,7 +186,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener, CoroutineSc clearIntent.action = ACTION_CLEAR val piClear = PendingIntent.getService(this, 0, clearIntent, PendingIntent.FLAG_IMMUTABLE) val bundle = Bundle() - bundle.putString(DownloadsFragment.KEY_ACTION, DownloadsFragment.ACTION_CLEAR_DOWNLOAD_SERVICE) + bundle.putString(KEY_ACTION, ACTION_CLEAR_DOWNLOAD_SERVICE) val activityIntent = Intent(this, MainActivity::class.java) activityIntent.action = ACTION_START_DOWNLOADSCENE activityIntent.putExtra(ACTION_START_DOWNLOADSCENE_ARGS, bundle) @@ -243,7 +242,7 @@ class DownloadService : Service(), DownloadManager.DownloadListener, CoroutineSc } ensureDownloadingBuilder() val bundle = Bundle() - bundle.putLong(DownloadsFragment.KEY_GID, info.gid) + bundle.putLong(KEY_GID, info.gid) val activityIntent = Intent(this, MainActivity::class.java) activityIntent.action = ACTION_START_DOWNLOADSCENE activityIntent.putExtra(ACTION_START_DOWNLOADSCENE_ARGS, bundle) @@ -540,6 +539,8 @@ class DownloadService : Service(), DownloadManager.DownloadListener, CoroutineSc const val KEY_LABEL = "label" const val KEY_GID = "gid" const val KEY_GID_LIST = "gid_list" + const val KEY_ACTION = "action" + const val ACTION_CLEAR_DOWNLOAD_SERVICE = "clear_download_service" private const val ID_DOWNLOADING = 1 private const val ID_DOWNLOADED = 2 private const val ID_509 = 3 diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/MainActivity.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/MainActivity.kt index c7561a6de..aad83e9cf 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/MainActivity.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/MainActivity.kt @@ -290,7 +290,10 @@ class MainActivity : EhActivity() { } } DownloadService.ACTION_START_DOWNLOADSCENE -> { - val args = intent.getBundleExtra(DownloadService.ACTION_START_DOWNLOADSCENE_ARGS) + val args = intent.getBundleExtra(DownloadService.ACTION_START_DOWNLOADSCENE_ARGS)!! + if (args.getString(DownloadService.KEY_ACTION) == DownloadService.ACTION_CLEAR_DOWNLOAD_SERVICE) { + DownloadService.clear() + } navigator.navigate(DownloadsScreenDestination) } } @@ -401,7 +404,7 @@ class MainActivity : EhActivity() { }, selected = currentDestination === direction, onClick = { - navController.navigate(direction.route) + navigator.navigate(direction) closeDrawer() }, modifier = Modifier.padding(horizontal = 12.dp), diff --git a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt index 9268ef88d..7f82094ee 100644 --- a/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt +++ b/app/src/main/kotlin/com/hippo/ehviewer/ui/screen/DownloadsScreen.kt @@ -695,9 +695,3 @@ fun DownloadsScreen(navigator: DestinationsNavigator) = composing(navigator) { } } } - -object DownloadsFragment { - const val KEY_GID = "gid" - const val KEY_ACTION = "action" - const val ACTION_CLEAR_DOWNLOAD_SERVICE = "clear_download_service" -}