diff --git a/CHANGELOG.md b/CHANGELOG.md index 8ee68c4c3b1..83fa47fa71f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,8 +13,10 @@ ([#1234](https://github.com/Automattic/pocket-casts-android/pull/1234)) * Improved handling of enabling/disabling new episode notifications ([#1264](https://github.com/Automattic/pocket-casts-android/pull/1264)) - * Fixed the artwork not appearing on the onboarding page + * Fixed the artwork not appearing on the onboarding page ([#1299](https://github.com/Automattic/pocket-casts-android/pull/1299)) + * Improved multi-select toolbars setup + ([#1338](https://github.com/Automattic/pocket-casts-android/pull/1338)) 7.46 ----- diff --git a/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/bookmark/BookmarksPage.kt b/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/bookmark/BookmarksPage.kt index 90b62356ffa..989e6eb59f8 100644 --- a/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/bookmark/BookmarksPage.kt +++ b/modules/features/player/src/main/java/au/com/shiftyjelly/pocketcasts/player/view/bookmark/BookmarksPage.kt @@ -181,7 +181,7 @@ private fun BookmarksView( isSelected = state.isSelected, onPlayClick = onPlayClick, modifier = Modifier - .pointerInput(state.isSelected(bookmark)) { + .pointerInput(bookmark.adapterId) { detectTapGestures( onLongPress = { onRowLongPressed(bookmark) }, onTap = { state.onRowClick(bookmark) } diff --git a/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/view/podcast/PodcastFragment.kt b/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/view/podcast/PodcastFragment.kt index 5d5de9d6754..d017b17aee5 100644 --- a/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/view/podcast/PodcastFragment.kt +++ b/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/view/podcast/PodcastFragment.kt @@ -21,6 +21,8 @@ import au.com.shiftyjelly.pocketcasts.analytics.AnalyticsEvent import au.com.shiftyjelly.pocketcasts.analytics.AnalyticsTrackerWrapper import au.com.shiftyjelly.pocketcasts.analytics.FirebaseAnalyticsTracker import au.com.shiftyjelly.pocketcasts.analytics.SourceView +import au.com.shiftyjelly.pocketcasts.featureflag.Feature +import au.com.shiftyjelly.pocketcasts.featureflag.FeatureFlag import au.com.shiftyjelly.pocketcasts.localization.extensions.getStringPlural import au.com.shiftyjelly.pocketcasts.models.entity.BaseEpisode import au.com.shiftyjelly.pocketcasts.models.entity.Bookmark @@ -74,6 +76,7 @@ import au.com.shiftyjelly.pocketcasts.views.helper.UiUtil import au.com.shiftyjelly.pocketcasts.views.multiselect.MultiSelectBookmarksHelper import au.com.shiftyjelly.pocketcasts.views.multiselect.MultiSelectEpisodesHelper import au.com.shiftyjelly.pocketcasts.views.multiselect.MultiSelectHelper +import au.com.shiftyjelly.pocketcasts.views.multiselect.MultiSelectToolbar import dagger.hilt.android.AndroidEntryPoint import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers @@ -644,17 +647,32 @@ class PodcastFragment : BaseFragment(), Toolbar.OnMenuItemClickListener, Corouti binding.episodesRecyclerView.requestFocus() - multiSelectEpisodesHelper.setUp() - multiSelectBookmarksHelper.setUp() - return binding.root } - fun MultiSelectHelper.setUp() { + override fun onViewCreated(view: View, savedInstanceState: Bundle?) { + super.onViewCreated(view, savedInstanceState) + binding?.setupMultiSelect() + } + + private fun FragmentPodcastBinding.setupMultiSelect() { + multiSelectEpisodesHelper.setUp(multiSelectEpisodesToolbar) + if (FeatureFlag.isEnabled(Feature.BOOKMARKS_ENABLED)) { + multiSelectBookmarksHelper.setUp(multiSelectBookmarksToolbar) + } + } + + fun MultiSelectHelper.setUp(multiSelectToolbar: MultiSelectToolbar) { + multiSelectToolbar.setup( + lifecycleOwner = viewLifecycleOwner, + multiSelectHelper = this, + menuRes = null, + fragmentManager = parentFragmentManager, + ) isMultiSelectingLive.observe(viewLifecycleOwner) { val episodeContainerFragment = parentFragmentManager.findFragmentByTag(EPISODE_CARD) if (episodeContainerFragment != null) return@observe - binding?.multiSelectToolbar?.isVisible = it + multiSelectToolbar.isVisible = it binding?.toolbar?.isVisible = !it adapter?.notifyDataSetChanged() } @@ -747,13 +765,6 @@ class PodcastFragment : BaseFragment(), Toolbar.OnMenuItemClickListener, Corouti addPaddingForEpisodeSearch(state.episodes) when (state.showTab) { PodcastTab.EPISODES -> { - binding?.multiSelectToolbar?.setup( - lifecycleOwner = viewLifecycleOwner, - multiSelectHelper = multiSelectEpisodesHelper, - menuRes = null, - fragmentManager = parentFragmentManager, - ) - adapter?.setEpisodes( episodes = state.episodes, showingArchived = state.showingArchived, @@ -767,13 +778,6 @@ class PodcastFragment : BaseFragment(), Toolbar.OnMenuItemClickListener, Corouti ) } PodcastTab.BOOKMARKS -> { - binding?.multiSelectToolbar?.setup( - lifecycleOwner = viewLifecycleOwner, - multiSelectHelper = multiSelectBookmarksHelper, - menuRes = null, - fragmentManager = parentFragmentManager, - ) - adapter?.setBookmarks( bookmarks = state.bookmarks, searchTerm = state.searchBookmarkTerm, diff --git a/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/view/podcast/adapter/BookmarkViewHolder.kt b/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/view/podcast/adapter/BookmarkViewHolder.kt index 1417198253a..4cd16ecd7e1 100644 --- a/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/view/podcast/adapter/BookmarkViewHolder.kt +++ b/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/view/podcast/adapter/BookmarkViewHolder.kt @@ -27,7 +27,7 @@ class BookmarkViewHolder( isSelected = data.isSelected, onPlayClick = { data.onBookmarkPlayClicked(it) }, modifier = Modifier - .pointerInput(data.isSelected(data.bookmark)) { + .pointerInput(data.bookmark.adapterId) { detectTapGestures( onLongPress = { data.onBookmarkRowLongPress(data.bookmark) }, onTap = { data.onBookmarkRowClick(data.bookmark, bindingAdapterPosition) } diff --git a/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/viewmodel/PodcastViewModel.kt b/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/viewmodel/PodcastViewModel.kt index 53e750e9c9a..63ac779266d 100644 --- a/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/viewmodel/PodcastViewModel.kt +++ b/modules/features/podcasts/src/main/java/au/com/shiftyjelly/pocketcasts/podcasts/viewmodel/PodcastViewModel.kt @@ -193,6 +193,10 @@ class PodcastViewModel } fun onTabClicked(tab: PodcastTab) { + when (tab) { + PodcastTab.EPISODES -> multiSelectBookmarksHelper.closeMultiSelect() + PodcastTab.BOOKMARKS -> multiSelectEpisodesHelper.closeMultiSelect() + } analyticsTracker.track(AnalyticsEvent.PODCASTS_SCREEN_TAB_TAPPED, mapOf("value" to tab.analyticsValue)) _uiState.value = (uiState.value as? UiState.Loaded)?.copy(showTab = tab) } diff --git a/modules/features/podcasts/src/main/res/layout/fragment_podcast.xml b/modules/features/podcasts/src/main/res/layout/fragment_podcast.xml index b79f4fa4242..21b41e4afb5 100644 --- a/modules/features/podcasts/src/main/res/layout/fragment_podcast.xml +++ b/modules/features/podcasts/src/main/res/layout/fragment_podcast.xml @@ -35,7 +35,15 @@ app:popupTheme="@style/ThemeOverlay.AppCompat.Light" /> + +