mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-11-28 17:19:00 +03:00
fix extension update notification leading to wrong tab
This commit is contained in:
parent
812ab126d0
commit
45d2af0173
4 changed files with 31 additions and 4 deletions
|
@ -57,7 +57,7 @@ class AnimeExtensionUpdateJob(private val context: Context, workerParams: Worker
|
|||
setContentText(extNames)
|
||||
setStyle(NotificationCompat.BigTextStyle().bigText(extNames))
|
||||
setSmallIcon(R.drawable.ic_extension_24dp)
|
||||
setContentIntent(NotificationReceiver.openExtensionsPendingActivity(context))
|
||||
setContentIntent(NotificationReceiver.openAnimeExtensionsPendingActivity(context))
|
||||
setAutoCancel(true)
|
||||
},
|
||||
)
|
||||
|
|
|
@ -811,6 +811,20 @@ class NotificationReceiver : BroadcastReceiver() {
|
|||
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [PendingIntent] that opens the extensions controller.
|
||||
*
|
||||
* @param context context of application
|
||||
* @return [PendingIntent]
|
||||
*/
|
||||
internal fun openAnimeExtensionsPendingActivity(context: Context): PendingIntent {
|
||||
val intent = Intent(context, MainActivity::class.java).apply {
|
||||
action = MainActivity.SHORTCUT_ANIMEEXTENSIONS
|
||||
addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
|
||||
}
|
||||
return PendingIntent.getActivity(context, 0, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns [PendingIntent] that starts a share activity for a backup file.
|
||||
*
|
||||
|
|
|
@ -26,11 +26,15 @@ class BrowseController : FullComposeController<BrowsePresenter>, RootController
|
|||
@Suppress("unused")
|
||||
constructor(bundle: Bundle? = null) : this(bundle?.getBoolean(TO_EXTENSIONS_EXTRA) ?: false)
|
||||
|
||||
constructor(toExtensions: Boolean = false) : super(
|
||||
bundleOf(TO_EXTENSIONS_EXTRA to toExtensions),
|
||||
constructor(toExtensions: Boolean = false, toAnimeExtensions: Boolean = false) : super(
|
||||
bundleOf(
|
||||
TO_EXTENSIONS_EXTRA to toExtensions,
|
||||
TO_ANIMEEXTENSIONS_EXTRA to toAnimeExtensions,
|
||||
),
|
||||
)
|
||||
|
||||
private val toExtensions = args.getBoolean(TO_EXTENSIONS_EXTRA, false)
|
||||
private val toAnimeExtensions = args.getBoolean(TO_ANIMEEXTENSIONS_EXTRA, false)
|
||||
|
||||
override fun createPresenter() = BrowsePresenter()
|
||||
|
||||
|
@ -49,7 +53,7 @@ class BrowseController : FullComposeController<BrowsePresenter>, RootController
|
|||
migrateAnimeSourcesTab(router, presenter.migrationAnimeSourcesPresenter),
|
||||
migrateSourcesTab(router, presenter.migrationSourcesPresenter),
|
||||
),
|
||||
startIndex = 1.takeIf { toExtensions },
|
||||
startIndex = 2.takeIf { toAnimeExtensions } ?: 3.takeIf { toExtensions },
|
||||
searchQuery = query,
|
||||
onChangeSearchQuery = { presenter.extensionsPresenter.search(it) },
|
||||
incognitoMode = presenter.isIncognitoMode,
|
||||
|
@ -71,3 +75,4 @@ class BrowseController : FullComposeController<BrowsePresenter>, RootController
|
|||
}
|
||||
|
||||
private const val TO_EXTENSIONS_EXTRA = "to_extensions"
|
||||
private const val TO_ANIMEEXTENSIONS_EXTRA = "to_animeextensions"
|
||||
|
|
|
@ -452,6 +452,13 @@ class MainActivity : BaseActivity() {
|
|||
setSelectedNavItem(R.id.nav_browse)
|
||||
router.pushController(BrowseController(toExtensions = true))
|
||||
}
|
||||
SHORTCUT_ANIMEEXTENSIONS -> {
|
||||
if (router.backstackSize > 1) {
|
||||
router.popToRoot()
|
||||
}
|
||||
setSelectedNavItem(R.id.nav_browse)
|
||||
router.pushController(BrowseController(toAnimeExtensions = true))
|
||||
}
|
||||
SHORTCUT_MANGA -> {
|
||||
val extras = intent.extras ?: return false
|
||||
val fgController = router.backstack.lastOrNull()?.controller as? MangaController
|
||||
|
@ -741,6 +748,7 @@ class MainActivity : BaseActivity() {
|
|||
const val SHORTCUT_ANIME_DOWNLOADS = "eu.kanade.tachiyomi.SHOW_ANIME_DOWNLOADS"
|
||||
const val SHORTCUT_MANGA = "eu.kanade.tachiyomi.SHOW_MANGA"
|
||||
const val SHORTCUT_ANIME = "eu.kanade.tachiyomi.SHOW_ANIME"
|
||||
const val SHORTCUT_ANIMEEXTENSIONS = "eu.kanade.tachiyomi.ANIMEEXTENSIONS"
|
||||
const val SHORTCUT_EXTENSIONS = "eu.kanade.tachiyomi.EXTENSIONS"
|
||||
|
||||
const val INTENT_SEARCH = "eu.kanade.tachiyomi.SEARCH"
|
||||
|
|
Loading…
Reference in a new issue