Skip to content

Commit

Permalink
Movie details: group most buttons in chain.
Browse files Browse the repository at this point in the history
Use smaller headline text for title on large layouts as well.
  • Loading branch information
UweTrottmann committed Dec 7, 2023
1 parent 8e29a0f commit 04ce064
Show file tree
Hide file tree
Showing 5 changed files with 152 additions and 248 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
54 changes: 6 additions & 48 deletions app/src/main/res/layout-w1024dp/fragment_movie.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- SPDX-License-Identifier: Apache-2.0 -->
<!-- Copyright 2016-2018, 2020, 2022, 2023 Uwe Trottmann -->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
Expand Down Expand Up @@ -78,7 +82,7 @@
android:layout_toRightOf="@id/frameLayoutMoviePoster"
android:background="?attr/selectableItemBackground"
android:focusable="true"
android:textAppearance="@style/TextAppearance.SeriesGuide.Headline5"
android:textAppearance="@style/TextAppearance.SeriesGuide.Headline6"
tools:text="Awesome Movie Title" />

<TextView
Expand All @@ -94,31 +98,6 @@
android:textAppearance="@style/TextAppearance.SeriesGuide.Caption"
tools:text="20 Oct 2013" />

<Button
android:id="@+id/buttonMovieTrailer"
style="@style/Widget.SeriesGuide.Button.Borderless.Default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textViewMovieDate"
android:layout_marginRight="@dimen/large_padding"
android:layout_toRightOf="@id/frameLayoutMoviePoster"
android:text="@string/trailer"
app:icon="@drawable/ic_movie_white_24dp"
app:iconGravity="start" />

<Button
android:id="@+id/buttonMovieSimilar"
style="@style/Widget.SeriesGuide.Button.Borderless.Default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/buttonMovieTrailer"
android:layout_marginRight="@dimen/large_padding"
android:layout_marginBottom="@dimen/large_padding"
android:layout_toRightOf="@id/frameLayoutMoviePoster"
android:text="@string/title_similar_movies"
app:icon="@drawable/ic_search_white_24dp"
app:iconGravity="start" />

</RelativeLayout>

<include
Expand Down Expand Up @@ -225,32 +204,11 @@
android:layout_marginBottom="@dimen/default_padding"
android:background="?attr/sgColorDivider" />

<Button
android:id="@+id/buttonMovieComments"
style="@style/Widget.SeriesGuide.Button.Borderless.Sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/dividerMovie2"
android:text="@string/comments"
app:icon="@drawable/ic_forum_black_24dp"
app:iconGravity="start" />

<View
android:id="@+id/dividerMovie3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_below="@+id/buttonMovieComments"
android:layout_marginLeft="72dp"
android:layout_marginTop="@dimen/default_padding"
android:layout_marginRight="@dimen/large_padding"
android:layout_marginBottom="@dimen/default_padding"
android:background="?attr/sgColorDivider" />

<LinearLayout
android:id="@+id/containerMovieActions"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/dividerMovie3"
android:layout_below="@id/dividerMovie2"
android:orientation="vertical" />

</RelativeLayout>
Expand Down
80 changes: 22 additions & 58 deletions app/src/main/res/layout-w590dp/fragment_movie.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- SPDX-License-Identifier: Apache-2.0 -->
<!-- Copyright 2016-2018, 2020, 2022, 2023 Uwe Trottmann -->

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rootLayoutMovie"
android:layout_width="match_parent"
android:layout_height="match_parent"
Expand Down Expand Up @@ -33,8 +37,8 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:animateLayoutChanges="true"
android:paddingBottom="@dimen/large_padding"
android:paddingTop="@dimen/large_padding">
android:paddingTop="@dimen/large_padding"
android:paddingBottom="@dimen/large_padding">

<!-- Wrap in container to support reeeeally long movie titles. -->
<RelativeLayout
Expand All @@ -61,51 +65,29 @@

</com.google.android.material.card.MaterialCardView>

<Button
android:id="@+id/buttonMovieTrailer"
style="@style/Widget.SeriesGuide.Button.Borderless.Default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginRight="@dimen/padding_button"
android:text="@string/trailer"
app:icon="@drawable/ic_movie_white_24dp"
app:iconGravity="start" />

<Button
android:id="@+id/buttonMovieSimilar"
style="@style/Widget.SeriesGuide.Button.Borderless.Default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentEnd="true"
android:layout_marginRight="@dimen/padding_button"
android:layout_below="@id/buttonMovieTrailer"
android:text="@string/title_similar_movies"
app:icon="@drawable/ic_search_white_24dp"
app:iconGravity="start" />

<TextView
android:id="@+id/textViewMovieTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/default_padding"
android:layout_marginTop="@dimen/inline_padding"
android:layout_marginRight="@dimen/inline_padding"
android:layout_toRightOf="@id/frameLayoutMoviePoster"
android:layout_toLeftOf="@id/buttonMovieSimilar"
android:layout_alignParentEnd="true"
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_toEndOf="@id/frameLayoutMoviePoster"
android:background="?attr/selectableItemBackground"
android:focusable="true"
android:textAppearance="@style/TextAppearance.SeriesGuide.Headline5"
android:textAppearance="@style/TextAppearance.SeriesGuide.Headline6"
tools:text="Awesome Movie Title" />

<TextView
android:id="@+id/textViewMovieDate"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textViewMovieTitle"
android:layout_marginLeft="@dimen/default_padding"
android:layout_marginRight="@dimen/large_padding"
android:layout_toRightOf="@id/frameLayoutMoviePoster"
android:layout_alignParentEnd="true"
android:layout_marginStart="@dimen/default_padding"
android:layout_marginEnd="@dimen/large_padding"
android:layout_toEndOf="@id/frameLayoutMoviePoster"
android:background="?attr/selectableItemBackground"
android:focusable="true"
android:textAppearance="@style/TextAppearance.SeriesGuide.Caption"
Expand All @@ -116,8 +98,9 @@
layout="@layout/buttons_movie"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/buttonMovieSimilar"
android:layout_toRightOf="@id/frameLayoutMoviePoster" />
android:layout_below="@+id/textViewMovieDate"
android:layout_marginTop="8dp"
android:layout_toEndOf="@id/frameLayoutMoviePoster" />

</RelativeLayout>

Expand Down Expand Up @@ -155,8 +138,8 @@
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/large_padding"
android:layout_marginRight="@dimen/large_padding"
android:layout_marginTop="@dimen/large_padding"
android:layout_marginRight="@dimen/large_padding"
android:background="?attr/sgColorDivider" />

<include
Expand Down Expand Up @@ -214,31 +197,12 @@
android:id="@+id/dividerMovie3"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/default_padding"
android:layout_marginLeft="@dimen/large_padding"
android:layout_marginRight="@dimen/large_padding"
android:layout_marginBottom="@dimen/default_padding"
android:background="?attr/sgColorDivider"
tools:ignore="UnknownIdInLayout" />

<Button
android:id="@+id/buttonMovieComments"
style="@style/Widget.SeriesGuide.Button.Borderless.Sheet"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/comments"
app:icon="@drawable/ic_forum_black_24dp"
app:iconGravity="start" />

<View
android:id="@+id/dividerMovie4"
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginBottom="@dimen/default_padding"
android:layout_marginLeft="72dp"
android:layout_marginRight="@dimen/large_padding"
android:layout_marginTop="@dimen/default_padding"
android:background="?attr/sgColorDivider" />

<LinearLayout
android:id="@+id/containerMovieActions"
android:layout_width="match_parent"
Expand Down
Loading

0 comments on commit 04ce064

Please sign in to comment.