Skip to content

Commit

Permalink
Merge release 7.52-rc-4 into main (#1563)
Browse files Browse the repository at this point in the history
Co-authored-by: Philip Simpson <[email protected]>
Co-authored-by: Matt Chowning <[email protected]>
  • Loading branch information
3 people authored Nov 24, 2023
1 parent a97a249 commit 73cf37b
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -215,13 +215,25 @@ class PlayerContainerFragment : BaseFragment(), HasBackstack {
}

fun onPlayerOpen() {
((childFragmentManager.fragments.firstOrNull { it is BookmarksFragment }) as? BookmarksFragment)
?.onPlayerOpen()
try {
if (isAdded) {
((childFragmentManager.fragments.firstOrNull { it is BookmarksFragment }) as? BookmarksFragment)
?.onPlayerOpen()
}
} catch (e: IllegalStateException) {
Timber.e(e)
}
}

fun onPlayerClose() {
((childFragmentManager.fragments.firstOrNull { it is BookmarksFragment }) as? BookmarksFragment)
?.onPlayerClose()
try {
if (isAdded) {
((childFragmentManager.fragments.firstOrNull { it is BookmarksFragment }) as? BookmarksFragment)
?.onPlayerClose()
}
} catch (e: IllegalStateException) {
Timber.e(e)
}
}

fun openPlayer(sourceView: SourceView? = null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -652,6 +652,23 @@ class PodcastFragment : BaseFragment(), Toolbar.OnMenuItemClickListener {
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
super.onViewCreated(view, savedInstanceState)
binding?.setupMultiSelect()

if (FeatureFlag.isEnabled(Feature.BOOKMARKS_ENABLED)) {
viewLifecycleOwner.lifecycleScope.launch {
viewLifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
multiSelectBookmarksHelper.showEditBookmarkPage
.collect { show ->
if (show) onEditBookmarkClick()
}
}
}
}
}

private fun onEditBookmarkClick() {
viewModel.buildBookmarkArguments { arguments ->
startActivity(arguments.getIntent(requireContext()))
}
}

private fun FragmentPodcastBinding.setupMultiSelect() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.toLiveData
import androidx.lifecycle.viewModelScope
import au.com.shiftyjelly.pocketcasts.analytics.AnalyticsEvent
import au.com.shiftyjelly.pocketcasts.analytics.AnalyticsTrackerWrapper
import au.com.shiftyjelly.pocketcasts.analytics.EpisodeAnalytics
Expand All @@ -18,6 +19,7 @@ import au.com.shiftyjelly.pocketcasts.models.entity.Podcast
import au.com.shiftyjelly.pocketcasts.models.entity.PodcastEpisode
import au.com.shiftyjelly.pocketcasts.models.to.PodcastGrouping
import au.com.shiftyjelly.pocketcasts.models.type.EpisodesSortType
import au.com.shiftyjelly.pocketcasts.player.view.bookmark.BookmarkArguments
import au.com.shiftyjelly.pocketcasts.podcasts.helper.search.BookmarkSearchHandler
import au.com.shiftyjelly.pocketcasts.podcasts.helper.search.EpisodeSearchHandler
import au.com.shiftyjelly.pocketcasts.podcasts.helper.search.SearchHandler
Expand All @@ -26,6 +28,7 @@ import au.com.shiftyjelly.pocketcasts.preferences.model.BookmarksSortType
import au.com.shiftyjelly.pocketcasts.preferences.model.BookmarksSortTypeForPodcast
import au.com.shiftyjelly.pocketcasts.repositories.bookmark.BookmarkManager
import au.com.shiftyjelly.pocketcasts.repositories.chromecast.CastManager
import au.com.shiftyjelly.pocketcasts.repositories.di.IoDispatcher
import au.com.shiftyjelly.pocketcasts.repositories.download.DownloadManager
import au.com.shiftyjelly.pocketcasts.repositories.playback.PlaybackManager
import au.com.shiftyjelly.pocketcasts.repositories.podcast.EpisodeManager
Expand All @@ -48,6 +51,7 @@ import io.reactivex.rxkotlin.Observables
import io.reactivex.rxkotlin.addTo
import io.reactivex.rxkotlin.subscribeBy
import io.reactivex.schedulers.Schedulers
import kotlinx.coroutines.CoroutineDispatcher
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
Expand Down Expand Up @@ -80,6 +84,7 @@ class PodcastViewModel
private val multiSelectBookmarksHelper: MultiSelectBookmarksHelper,
private val settings: Settings,
private val podcastAndEpisodeDetailsCoordinator: PodcastAndEpisodeDetailsCoordinator,
@IoDispatcher private val ioDispatcher: CoroutineDispatcher,
) : ViewModel(), CoroutineScope {

private val disposables = CompositeDisposable()
Expand Down Expand Up @@ -412,6 +417,27 @@ class PodcastViewModel
}
}

fun buildBookmarkArguments(onSuccess: (BookmarkArguments) -> Unit) {
multiSelectBookmarksHelper.selectedListLive.value?.firstOrNull()?.let { bookmark ->
val episodeUuid = bookmark.episodeUuid
viewModelScope.launch(ioDispatcher) {
val podcast = podcastManager.findPodcastByUuidSuspend(bookmark.podcastUuid)
val backgroundColor =
if (podcast == null) 0xFF000000.toInt() else theme.playerBackgroundColor(podcast)
val tintColor =
if (podcast == null) 0xFFFFFFFF.toInt() else theme.playerHighlightColor(podcast)
val arguments = BookmarkArguments(
bookmarkUuid = bookmark.uuid,
episodeUuid = episodeUuid,
timeSecs = bookmark.timeSecs,
backgroundColor = backgroundColor,
tintColor = tintColor
)
onSuccess(arguments)
}
}
}

fun multiSelectSelectNone() {
val uiState = uiState.value as? UiState.Loaded ?: return
when (uiState.showTab) {
Expand Down
4 changes: 2 additions & 2 deletions version.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
versionName=7.52-rc-3
versionCode=9166
versionName=7.52-rc-4
versionCode=9167

0 comments on commit 73cf37b

Please sign in to comment.