Skip to content

Commit

Permalink
Outline buttons: use in overview and episode details for sec. actions.
Browse files Browse the repository at this point in the history
  • Loading branch information
UweTrottmann committed Dec 7, 2023
1 parent 24e21f8 commit 1a950d0
Show file tree
Hide file tree
Showing 8 changed files with 168 additions and 184 deletions.
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 Down Expand Up @@ -193,7 +194,7 @@ class EpisodeDetailsFragment : Fragment(), EpisodeActionsContract {
if (watchInfo != null && b != null) {
StreamingSearch.configureButton(
b.includeButtons.buttonEpisodeStreamingSearch,
watchInfo
watchInfo, replaceButtonText = true
)
}
}
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
129 changes: 80 additions & 49 deletions app/src/main/res/layout/buttons_episode.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>

<!-- SPDX-License-Identifier: Apache-2.0 -->
<!-- Copyright 2014-2021, 2023 Uwe Trottmann -->

<!-- Will never be a root layout, overdraw is expected -->
<!-- Need to define root ID in include tag or view binding breaks. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
Expand Down Expand Up @@ -47,69 +50,97 @@

</LinearLayout>

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

<Button
android:id="@+id/buttonEpisodeCheckin"
style="@style/Widget.SeriesGuide.Button.Borderless.Caption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/padding_button"
android:layout_marginRight="@dimen/padding_button"
android:contentDescription="@string/checkin"
android:gravity="center_vertical|start"
android:nextFocusUp="@+id/buttonEpisodeWatched"
android:text="@string/checkin"
app:icon="@drawable/ic_checkin_black_24dp" />

<Button
android:id="@+id/buttonEpisodeWatchedUpTo"
style="@style/Widget.SeriesGuide.Button.Borderless.Caption"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="@dimen/padding_button"
android:layout_marginRight="@dimen/padding_button"
android:contentDescription="@string/action_watched_up_to"
android:gravity="center_vertical|start"
android:text="@string/action_watched_up_to"
app:icon="@drawable/ic_watch_all_black_24dp" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/containerEpisodeStreamingSearch"
android:id="@+id/constraintLayoutEpisodeButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="@dimen/padding_button"
android:layout_marginEnd="@dimen/padding_button">
android:layout_marginStart="16dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="16dp">

<androidx.constraintlayout.helper.widget.Flow
android:layout_width="0dp"
android:layout_height="wrap_content"
app:constraint_referenced_ids="buttonEpisodeCheckin,buttonEpisodeWatchedUpTo,buttonEpisodeShare,buttonEpisodeCalendar,buttonEpisodeComments,buttonEpisodeStreamingSearch,buttonEpisodeStreamingSearchInfo"
app:flow_horizontalBias="0"
app:flow_horizontalGap="4dp"
app:flow_horizontalStyle="packed"
app:flow_wrapMode="chain"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<Button
android:id="@+id/buttonEpisodeCheckin"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/checkin"
android:nextFocusUp="@+id/buttonEpisodeWatched"
android:text="@string/checkin"
app:icon="@drawable/ic_checkin_black_24dp"
app:iconGravity="start" />

<Button
android:id="@+id/buttonEpisodeWatchedUpTo"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/action_watched_up_to"
android:text="@string/action_watched_up_to"
app:icon="@drawable/ic_watch_all_black_24dp"
app:iconGravity="start" />

<Button
android:id="@+id/buttonEpisodeShare"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/share"
app:icon="@drawable/ic_share_white_24dp"
app:iconGravity="start" />

<Button
android:id="@+id/buttonEpisodeCalendar"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/addtocalendar"
app:icon="@drawable/ic_event_white_24dp"
app:iconGravity="start" />

<Button
android:id="@+id/buttonEpisodeComments"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/comments"
app:icon="@drawable/ic_forum_black_24dp"
app:iconGravity="start" />

<Button
android:id="@+id/buttonEpisodeStreamingSearch"
style="@style/Widget.SeriesGuide.Button.Borderless.Caption"
android:layout_width="0dp"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/action_stream"
android:gravity="center_vertical|start"
android:text="@string/action_stream"
app:icon="@drawable/ic_play_arrow_black_24dp"
app:layout_constraintEnd_toStartOf="@+id/buttonEpisodeStreamingSearchInfo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
app:iconGravity="start" />

<ImageButton
<!-- Note: can not wrap in LinearLayout to keep close to search button as it would
grow out of bounds if long. -->
<Button
android:id="@+id/buttonEpisodeStreamingSearchInfo"
style="?attr/borderlessButtonStyle"
style="@style/Widget.SeriesGuide.Button.IconButton.Outlined"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:layout_height="wrap_content"
android:layout_marginLeft="0dp"
android:contentDescription="@string/action_stream_info"
android:src="@drawable/ic_settings_control_24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
android:insetLeft="0dp"
android:insetRight="8dp"
app:icon="@drawable/ic_settings_control_24dp" />

</androidx.constraintlayout.widget.ConstraintLayout>

Expand Down
Loading

0 comments on commit 1a950d0

Please sign in to comment.