Skip to content

Commit

Permalink
Merge pull request #960 from UweTrottmann/more-outline-buttons
Browse files Browse the repository at this point in the history
More outline buttons
  • Loading branch information
UweTrottmann authored Dec 7, 2023
2 parents 17b7847 + ba77a75 commit c229c6f
Show file tree
Hide file tree
Showing 57 changed files with 510 additions and 566 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -151,9 +158,6 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract {
MovieLocalizationDialogFragment.show(parentFragmentManager)
}

// comments button
binding.buttonMovieComments.isGone = true

// cast and crew
setCastVisibility(false)
setCrewVisibility(false)
Expand Down Expand Up @@ -192,7 +196,7 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract {
model.watchProvider.observe(viewLifecycleOwner) { watchInfo ->
StreamingSearch.configureButton(
binding.containerMovieButtons.buttonMovieStreamingSearch,
watchInfo
watchInfo, true
)
}

Expand Down Expand Up @@ -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())
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -791,7 +791,7 @@ class MovieDetailsFragment : Fragment(), MovieActionsContract {
) {
if (videoId != null) {
this@MovieDetailsFragment.trailerYoutubeId = videoId
binding.buttonMovieTrailer.isEnabled = true
binding.containerMovieButtons.buttonMovieTrailer.isEnabled = true
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)
Expand All @@ -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() {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -185,10 +194,6 @@ class OverviewFragment() : Fragment(), EpisodeActionsContract {
buttonEpisodeSkip,
buttonEpisodeSkip.contentDescription
)
initButtons(
buttonEpisodeStreamingSearch, buttonEpisodeStreamingSearchInfo,
parentFragmentManager
)
}

// ratings
Expand All @@ -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()
Expand Down Expand Up @@ -244,7 +241,7 @@ class OverviewFragment() : Fragment(), EpisodeActionsContract {
this.binding?.let {
StreamingSearch.configureButton(
it.includeButtons.buttonEpisodeStreamingSearch,
watchInfo
watchInfo, replaceButtonText = true
)
}
}
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) {
Expand Down
Loading

0 comments on commit c229c6f

Please sign in to comment.