Manga app shortcuts now return back main activity on up button press

This commit is contained in:
Jays2Kings 2021-04-28 16:38:13 -04:00
parent a30e4ebcbc
commit f5aafebc91
3 changed files with 5 additions and 9 deletions

View File

@ -895,6 +895,7 @@ open class MainActivity : BaseActivity<MainActivityBinding>(), 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"

View File

@ -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)
}

View File

@ -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()
}