diff --git a/app/src/main/java/com/battlelancer/seriesguide/movies/details/MovieDetailsFragment.kt b/app/src/main/java/com/battlelancer/seriesguide/movies/details/MovieDetailsFragment.kt index 68b8514486..4f33cd9f24 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/movies/details/MovieDetailsFragment.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/movies/details/MovieDetailsFragment.kt @@ -108,38 +108,45 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract { binding.textViewMovieGenresLabel.isGone = true binding.labelMovieLastUpdated.isGone = true - // trailer button - binding.buttonMovieTrailer.setOnClickListener { - trailerYoutubeId?.let { ServiceUtils.openYoutube(it, requireContext()) } - } - binding.buttonMovieTrailer.isGone = true - binding.buttonMovieTrailer.isEnabled = false - - // similar movies button - binding.buttonMovieSimilar.apply { - setOnClickListener { - movieDetails?.tmdbMovie() - ?.title - ?.let { - startActivity(SimilarMoviesActivity.intent(requireContext(), tmdbId, it)) - } + // some action buttons + binding.containerMovieButtons.apply { + root.isGone = true + // trailer button + buttonMovieTrailer.apply { + setOnClickListener { + trailerYoutubeId?.let { ServiceUtils.openYoutube(it, requireContext()) } + } + isEnabled = false + } + // similar movies button + buttonMovieSimilar.apply { + setOnClickListener { + movieDetails?.tmdbMovie() + ?.title + ?.let { + startActivity( + SimilarMoviesActivity.intent( + requireContext(), + tmdbId, + it + ) + ) + } + } } - isGone = true + buttonMovieCheckIn.setOnClickListener { onButtonCheckInClick() } + TooltipCompat.setTooltipText( + buttonMovieCheckIn, + buttonMovieCheckIn.contentDescription + ) + StreamingSearch.initButtons( + buttonMovieStreamingSearch, + buttonMovieStreamingSearchInfo, + parentFragmentManager + ) } - - // important action buttons - binding.containerMovieButtons.root.isGone = true - binding.containerMovieButtons.buttonMovieCheckIn.setOnClickListener { onButtonCheckInClick() } - StreamingSearch.initButtons( - binding.containerMovieButtons.buttonMovieStreamingSearch, - binding.containerMovieButtons.buttonMovieStreamingSearchInfo, - parentFragmentManager - ) + // ratings binding.containerRatings.root.isGone = true - TooltipCompat.setTooltipText( - binding.containerMovieButtons.buttonMovieCheckIn, - binding.containerMovieButtons.buttonMovieCheckIn.contentDescription - ) // language button binding.buttonMovieLanguage.isGone = true @@ -151,9 +158,6 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract { MovieLocalizationDialogFragment.show(parentFragmentManager) } - // comments button - binding.buttonMovieComments.isGone = true - // cast and crew setCastVisibility(false) setCrewVisibility(false) @@ -192,7 +196,7 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract { model.watchProvider.observe(viewLifecycleOwner) { watchInfo -> StreamingSearch.configureButton( binding.containerMovieButtons.buttonMovieStreamingSearch, - watchInfo + watchInfo, true ) } @@ -344,11 +348,6 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract { } binding.textViewMovieDate.text = releaseAndRuntime.toString() - // show trailer button (but trailer is loaded separately, just for animation) - binding.buttonMovieTrailer.isGone = false - // movie title should be available now, can show similar movies button - binding.buttonMovieSimilar.isGone = false - // hide check-in if not connected to trakt or hexagon is enabled val isConnectedToTrakt = TraktCredentials.get(requireContext()).hasCredentials() val hideCheckIn = !isConnectedToTrakt || HexagonSettings.isEnabled(requireContext()) @@ -437,7 +436,18 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract { } } - // show button bar + // trakt comments link + binding.containerMovieButtons.buttonMovieComments.apply { + setOnClickListener { v -> + val tmdbId = tmdbId + if (tmdbId > 0) { + val i = TraktCommentsActivity.intentMovie(requireContext(), movieTitle, tmdbId) + Utils.startActivityWithAnimation(activity, i, v) + } + } + } + + // show buttons after configuring them binding.containerMovieButtons.root.isGone = false // language button @@ -496,16 +506,6 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract { binding.textMovieLastUpdated.text = TimeTools.formatToLocalDateAndTime(requireContext(), movieDetails.lastUpdatedMillis) - // trakt comments link - binding.buttonMovieComments.setOnClickListener { v -> - val tmdbId = tmdbId - if (tmdbId > 0) { - val i = TraktCommentsActivity.intentMovie(requireContext(), movieTitle, tmdbId) - Utils.startActivityWithAnimation(activity, i, v) - } - } - binding.buttonMovieComments.isGone = false - // load poster, cache on external storage if (tmdbMovie.poster_path.isNullOrEmpty()) { binding.frameLayoutMoviePoster.isClickable = false @@ -791,7 +791,7 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract { ) { if (videoId != null) { this@MovieDetailsFragment.trailerYoutubeId = videoId - binding.buttonMovieTrailer.isEnabled = true + binding.containerMovieButtons.buttonMovieTrailer.isEnabled = true } } diff --git a/app/src/main/java/com/battlelancer/seriesguide/shows/episodes/EpisodeDetailsFragment.kt b/app/src/main/java/com/battlelancer/seriesguide/shows/episodes/EpisodeDetailsFragment.kt index 4a27fb900f..e4650b03da 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/shows/episodes/EpisodeDetailsFragment.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/shows/episodes/EpisodeDetailsFragment.kt @@ -128,31 +128,32 @@ class EpisodeDetailsFragment : Fragment(), EpisodeActionsContract { bindingRatings!!.textViewRatingsRange.text = getString(R.string.format_rating_range, 10) - StreamingSearch.initButtons( - bindingButtons!!.buttonEpisodeStreamingSearch, - bindingButtons!!.buttonEpisodeStreamingSearchInfo, - parentFragmentManager - ) - - // other bottom buttons - bindingBottom!!.buttonEpisodeShare.setOnClickListener { shareEpisode() } - bindingBottom!!.buttonEpisodeCalendar.setOnClickListener { - val show = show - val episode = episode - if (show != null && episode != null) { - ShareUtils.suggestCalendarEvent( - requireContext(), - show.title, - TextTools.getNextEpisodeString( + // Episode action buttons + bindingButtons!!.apply { + buttonEpisodeShare.setOnClickListener { shareEpisode() } + buttonEpisodeCalendar.setOnClickListener { + val show = show + val episode = episode + if (show != null && episode != null) { + ShareUtils.suggestCalendarEvent( requireContext(), - episode.season, - episode.number, - episodeTitle - ), - episode.firstReleasedMs, - show.runtime - ) + show.title, + TextTools.getNextEpisodeString( + requireContext(), + episode.season, + episode.number, + episodeTitle + ), + episode.firstReleasedMs, + show.runtime + ) + } } + StreamingSearch.initButtons( + buttonEpisodeStreamingSearch, + buttonEpisodeStreamingSearchInfo, + parentFragmentManager + ) } // set up long-press to copy text to clipboard (d-pad friendly vs text selection) @@ -166,7 +167,7 @@ class EpisodeDetailsFragment : Fragment(), EpisodeActionsContract { binding.textviewReleaseDate.copyTextToClipboardOnLongClick() // Once episode is loaded, trigger show loading: so set show observer first. - model.show.observe(viewLifecycleOwner, { show: SgShow2? -> + model.show.observe(viewLifecycleOwner) { show: SgShow2? -> if (show != null) { if (show.tmdbId != null) { model.setShowTmdbId(show.tmdbId) @@ -179,24 +180,24 @@ class EpisodeDetailsFragment : Fragment(), EpisodeActionsContract { } // no data to display binding.root.visibility = View.GONE - }) - model.episode.observe(viewLifecycleOwner, { sgEpisode2: SgEpisode2? -> + } + model.episode.observe(viewLifecycleOwner) { sgEpisode2: SgEpisode2? -> if (sgEpisode2 != null) { model.showId.postValue(sgEpisode2.showId) } else { // no data to display binding.root.visibility = View.GONE } - }) - model.watchProvider.observe(viewLifecycleOwner, { watchInfo: TmdbTools2.WatchInfo? -> + } + model.watchProvider.observe(viewLifecycleOwner) { watchInfo: TmdbTools2.WatchInfo? -> val b = this.binding if (watchInfo != null && b != null) { StreamingSearch.configureButton( b.includeButtons.buttonEpisodeStreamingSearch, - watchInfo + watchInfo, replaceButtonText = true ) } - }) + } } override fun onResume() { @@ -611,6 +612,16 @@ class EpisodeDetailsFragment : Fragment(), EpisodeActionsContract { ) ) } + + // Trakt comments + bindingButtons.buttonEpisodeComments.setOnClickListener { v: View? -> + val episodeId = episodeId + if (episodeId > 0) { + val intent = + TraktCommentsActivity.intentEpisode(requireContext(), episodeTitle, episodeId) + Utils.startActivityWithAnimation(requireActivity(), intent, v) + } + } } private fun updateSecondaryButtons(episode: SgEpisode2, show: SgShow2) { @@ -638,16 +649,6 @@ class EpisodeDetailsFragment : Fragment(), EpisodeActionsContract { TmdbTools.buildEpisodeUrl(show.tmdbId, episode.season, episode.number) ) } - - // Trakt comments - bindingBottom.buttonEpisodeComments.setOnClickListener { v: View? -> - val episodeId = episodeId - if (episodeId > 0) { - val intent = - TraktCommentsActivity.intentEpisode(requireContext(), episodeTitle, episodeId) - Utils.startActivityWithAnimation(requireActivity(), intent, v) - } - } } private fun loadTraktRatings() { diff --git a/app/src/main/java/com/battlelancer/seriesguide/shows/overview/OverviewFragment.kt b/app/src/main/java/com/battlelancer/seriesguide/shows/overview/OverviewFragment.kt index 06ec12d959..129cbc8d4b 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/shows/overview/OverviewFragment.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/shows/overview/OverviewFragment.kt @@ -172,6 +172,15 @@ class OverviewFragment() : Fragment(), EpisodeActionsContract { buttonEpisodeWatched.setOnClickListener { onButtonWatchedClick() } buttonEpisodeCollected.setOnClickListener { onButtonCollectedClick() } buttonEpisodeSkip.setOnClickListener { onButtonSkipClicked() } + buttonEpisodeShare.setOnClickListener { shareEpisode() } + buttonEpisodeCalendar.setOnClickListener { createCalendarEvent() } + buttonEpisodeComments.setOnClickListener { + onButtonCommentsClick(buttonEpisodeComments) + } + initButtons( + buttonEpisodeStreamingSearch, buttonEpisodeStreamingSearchInfo, + parentFragmentManager + ) TooltipCompat.setTooltipText( buttonEpisodeCheckin, @@ -185,10 +194,6 @@ class OverviewFragment() : Fragment(), EpisodeActionsContract { buttonEpisodeSkip, buttonEpisodeSkip.contentDescription ) - initButtons( - buttonEpisodeStreamingSearch, buttonEpisodeStreamingSearchInfo, - parentFragmentManager - ) } // ratings @@ -201,14 +206,6 @@ class OverviewFragment() : Fragment(), EpisodeActionsContract { textViewRatingsRange.text = getString(R.string.format_rating_range, 10) } - with(includeServices.includeMore) { - buttonEpisodeShare.setOnClickListener { shareEpisode() } - buttonEpisodeCalendar.setOnClickListener { createCalendarEvent() } - buttonEpisodeComments.setOnClickListener { - onButtonCommentsClick(buttonEpisodeComments) - } - } - // set up long-press to copy text to clipboard (d-pad friendly vs text selection) textViewEpisodeDescription.copyTextToClipboardOnLongClick() textGuestStars.copyTextToClipboardOnLongClick() @@ -244,7 +241,7 @@ class OverviewFragment() : Fragment(), EpisodeActionsContract { this.binding?.let { StreamingSearch.configureButton( it.includeButtons.buttonEpisodeStreamingSearch, - watchInfo + watchInfo, replaceButtonText = true ) } } @@ -527,18 +524,15 @@ class OverviewFragment() : Fragment(), EpisodeActionsContract { } // dvd number - var isShowingMeta = ViewTools.setLabelValueOrHide( + ViewTools.setLabelValueOrHide( binding.labelDvdNumber, binding.textDvdNumber, episode.dvdNumber ) // guest stars - isShowingMeta = isShowingMeta or ViewTools.setLabelValueOrHide( + ViewTools.setLabelValueOrHide( binding.labelGuestStars, binding.textGuestStars, TextTools.splitPipeSeparatedStrings(episode.guestStars) ) - // hide divider if no meta is visible - binding.dividerOverviewEpisodeDetails.visibility = - if (isShowingMeta) View.VISIBLE else View.GONE // Trakt rating binding.includeRatings.also { diff --git a/app/src/main/java/com/battlelancer/seriesguide/streaming/StreamingSearch.kt b/app/src/main/java/com/battlelancer/seriesguide/streaming/StreamingSearch.kt index 4a681bb674..688111039f 100644 --- a/app/src/main/java/com/battlelancer/seriesguide/streaming/StreamingSearch.kt +++ b/app/src/main/java/com/battlelancer/seriesguide/streaming/StreamingSearch.kt @@ -20,6 +20,7 @@ import com.battlelancer.seriesguide.R import com.battlelancer.seriesguide.tmdbapi.TmdbTools2 import com.battlelancer.seriesguide.util.ViewTools import kotlinx.coroutines.Dispatchers +import java.text.NumberFormat import java.util.Locale import kotlin.coroutines.CoroutineContext @@ -241,7 +242,7 @@ object StreamingSearch { val providerOrNull = watchInfo.provider return if (providerOrNull != null) { val moreText = if (watchInfo.countMore > 0) { - " + " + context.getString(R.string.more, watchInfo.countMore) + " + " + NumberFormat.getIntegerInstance().format(watchInfo.countMore) } else "" val providerText = (providerOrNull.provider_name ?: "") + moreText if (replaceButtonText) { diff --git a/app/src/main/res/layout-w1024dp/fragment_movie.xml b/app/src/main/res/layout-w1024dp/fragment_movie.xml index 45760442e6..4730a70bf0 100644 --- a/app/src/main/res/layout-w1024dp/fragment_movie.xml +++ b/app/src/main/res/layout-w1024dp/fragment_movie.xml @@ -1,4 +1,8 @@ + + + + -