From f5aafebc91df8233cea036ee1154a6f7bc8d38fc Mon Sep 17 00:00:00 2001 From: Jays2Kings Date: Wed, 28 Apr 2021 16:38:13 -0400 Subject: [PATCH] Manga app shortcuts now return back main activity on up button press --- .../main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt | 1 + .../java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt | 6 +++--- .../eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt | 7 +------ 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt index af0965dfa5..ea52c53a16 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/MainActivity.kt @@ -895,6 +895,7 @@ open class MainActivity : BaseActivity(), DownloadServiceLi const val SHORTCUT_BROWSE = "eu.kanade.tachiyomi.SHOW_BROWSE" const val SHORTCUT_DOWNLOADS = "eu.kanade.tachiyomi.SHOW_DOWNLOADS" const val SHORTCUT_MANGA = "eu.kanade.tachiyomi.SHOW_MANGA" + const val SHORTCUT_MANGA_BACK = "eu.kanade.tachiyomi.SHOW_MANGA_BACK" const val SHORTCUT_UPDATE_NOTES = "eu.kanade.tachiyomi.SHOW_UPDATE_NOTES" const val SHORTCUT_SOURCE = "eu.kanade.tachiyomi.SHOW_SOURCE" const val SHORTCUT_READER_SETTINGS = "eu.kanade.tachiyomi.READER_SETTINGS" diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt index a1835293e2..f2e50d6e66 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/main/SearchActivity.kt @@ -107,7 +107,7 @@ class SearchActivity : MainActivity() { router.replaceTopController(GlobalSearchController(query, filter).withFadeTransaction()) } } - SHORTCUT_MANGA -> { + SHORTCUT_MANGA, SHORTCUT_MANGA_BACK -> { val extras = intent.extras ?: return false router.replaceTopController( RouterTransaction.with(MangaDetailsController(extras)) @@ -136,13 +136,13 @@ class SearchActivity : MainActivity() { } companion object { - fun openMangaIntent(context: Context, id: Long) = Intent( + fun openMangaIntent(context: Context, id: Long?, canReturnToMain: Boolean = false) = Intent( context, SearchActivity::class .java ) .apply { - action = SHORTCUT_MANGA + action = if (canReturnToMain) SHORTCUT_MANGA_BACK else SHORTCUT_MANGA putExtra(MangaDetailsController.MANGA_EXTRA, id) } diff --git a/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt b/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt index 34a40618a4..db449e83bd 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/util/manga/MangaShortcutManager.kt @@ -19,7 +19,6 @@ import eu.kanade.tachiyomi.source.SourceManager import eu.kanade.tachiyomi.source.icon import eu.kanade.tachiyomi.ui.main.MainActivity import eu.kanade.tachiyomi.ui.main.SearchActivity -import eu.kanade.tachiyomi.ui.manga.MangaDetailsController import eu.kanade.tachiyomi.ui.recents.RecentsPresenter import eu.kanade.tachiyomi.ui.source.browse.BrowseSourceController import eu.kanade.tachiyomi.util.system.launchIO @@ -79,12 +78,8 @@ class MangaShortcutManager( else Icon.createWithResource(context, R.drawable.ic_book_24dp) ) .setIntent( - Intent( - context, - SearchActivity::class.java - ).setAction(MainActivity.SHORTCUT_MANGA) + SearchActivity.openMangaIntent(context, item.id, true) .addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_SINGLE_TOP) - .putExtra(MangaDetailsController.MANGA_EXTRA, item.id) ) .build() }