Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Layout show buttons in horizontal wrapping chains #959

Merged
merged 4 commits into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,6 @@ class AddShowDialogFragment : AppCompatDialogFragment() {
StreamingSearch.initButtons(
buttonAddStreamingSearch, buttonAddStreamingSearchInfo, parentFragmentManager
)
textViewAddStreamingSearch.isGone = true
buttonNegative.apply {
setText(R.string.dismiss)
setOnClickListener { dismiss() }
Expand Down Expand Up @@ -166,11 +165,7 @@ class AddShowDialogFragment : AppCompatDialogFragment() {
}
model.watchProvider.observe(this) { watchInfo ->
this.binding?.buttonAddStreamingSearch?.let {
val providerInfo = StreamingSearch.configureButton(it, watchInfo, false)
this.binding?.textViewAddStreamingSearch?.apply {
text = providerInfo
isGone = providerInfo == null
}
StreamingSearch.configureButton(it, watchInfo, true)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -219,13 +219,17 @@ object StreamingSearch {
}
}

/**
* Set [replaceButtonText] to instead of appending on a new line replace button text with
* watch provider info.
*/
@SuppressLint("SetTextI18n")
@JvmStatic
fun configureButton(
button: Button,
watchInfo: TmdbTools2.WatchInfo,
addToButtonText: Boolean = true
): String? {
replaceButtonText: Boolean = false
) {
val context = button.context
val urlOrNull = watchInfo.url
if (urlOrNull != null) {
Expand All @@ -240,14 +244,14 @@ object StreamingSearch {
" + " + context.getString(R.string.more, watchInfo.countMore)
} else ""
val providerText = (providerOrNull.provider_name ?: "") + moreText
if (addToButtonText) {
if (replaceButtonText) {
button.text = providerText
} else {
button.text = context.getString(R.string.action_stream) +
"\n" + providerText
}
providerText
} else {
button.setText(R.string.action_stream)
null
}
}

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/buttons_episode.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/action_stream_info"
android:src="@drawable/ic_info_control_24dp"
android:src="@drawable/ic_settings_control_24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down
2 changes: 1 addition & 1 deletion app/src/main/res/layout/buttons_movie.xml
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/action_stream_info"
android:src="@drawable/ic_info_control_24dp"
android:src="@drawable/ic_settings_control_24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

Expand Down
141 changes: 67 additions & 74 deletions app/src/main/res/layout/dialog_addshow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -80,27 +80,82 @@

</RelativeLayout>

<Button
android:id="@+id/buttonAddTrailer"
style="@style/Widget.SeriesGuide.Button.Outlined"
android:layout_width="wrap_content"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayoutAddButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/containerShowInfo"
android:layout_marginLeft="@dimen/default_padding"
android:layout_marginTop="@dimen/default_padding"
android:layout_marginRight="@dimen/default_padding"
android:text="@string/trailer"
app:icon="@drawable/ic_movie_white_24dp"
app:iconGravity="start" />
android:layout_marginStart="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp">

<androidx.constraintlayout.helper.widget.Flow
android:layout_width="0dp"
android:layout_height="wrap_content"
app:constraint_referenced_ids="buttonAddTrailer,buttonAddDisplaySimilar,containerAddStreamingSearch"
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/buttonAddTrailer"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/trailer"
app:icon="@drawable/ic_movie_white_24dp"
app:iconGravity="start" />

<Button
android:id="@+id/buttonAddDisplaySimilar"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawablePadding="@dimen/default_padding"
android:text="@string/title_similar_shows"
app:icon="@drawable/ic_search_white_24dp"
app:iconGravity="start" />

<!-- To keep config button close, wrap in LinearLayout. -->
<LinearLayout
android:id="@+id/containerAddStreamingSearch"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">

<Button
android:id="@+id/buttonAddStreamingSearch"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/action_stream"
android:text="@string/action_stream"
app:icon="@drawable/ic_play_arrow_black_24dp" />

<Button
android:id="@+id/buttonAddStreamingSearchInfo"
style="@style/Widget.SeriesGuide.Button.IconButton.Outlined"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:contentDescription="@string/action_stream_info"
app:icon="@drawable/ic_settings_control_24dp" />

</LinearLayout>

</androidx.constraintlayout.widget.ConstraintLayout>

<Button
android:id="@+id/buttonAddLanguage"
style="@style/Widget.SeriesGuide.Button.Borderless.Default"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/buttonAddTrailer"
android:layout_below="@+id/constraintLayoutAddButtons"
android:layout_marginLeft="@dimen/default_padding"
android:layout_marginTop="@dimen/default_padding"
android:layout_marginRight="@dimen/default_padding"
app:icon="@drawable/ic_language_white_24dp"
app:iconGravity="start"
Expand Down Expand Up @@ -176,68 +231,6 @@
android:text="@string/trakt"
android:textAppearance="@style/TextAppearance.SeriesGuide.Caption" />

<Button
android:id="@+id/buttonAddDisplaySimilar"
style="@style/Widget.SeriesGuide.Button.Borderless.Caption"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textViewAddRatingLabel"
android:layout_marginLeft="@dimen/default_padding"
android:layout_marginTop="@dimen/default_padding"
android:layout_marginRight="@dimen/default_padding"
android:drawablePadding="@dimen/default_padding"
android:text="@string/title_similar_shows"
app:icon="@drawable/ic_search_white_24dp"
app:iconGravity="start" />

<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/containerAddStreamingSearch"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/buttonAddDisplaySimilar"
android:layout_marginStart="@dimen/default_padding"
android:layout_marginEnd="@dimen/default_padding"
android:maxWidth="@dimen/max_width_text_size_body">

<!-- MaterialButton ignores line breaks here (wtf?), so use separate TextView. -->
<Button
android:id="@+id/buttonAddStreamingSearch"
style="@style/Widget.SeriesGuide.Button.Borderless.Caption"
android:layout_width="0dp"
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/buttonAddStreamingSearchInfo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />

<TextView
android:id="@+id/textViewAddStreamingSearch"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="36dp"
android:contentDescription="@string/action_stream"
android:textAppearance="@style/TextAppearance.SeriesGuide.Caption.Narrow"
app:layout_constraintEnd_toStartOf="@+id/buttonAddStreamingSearchInfo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/buttonAddStreamingSearch"
tools:text="Watch provider + 1 more" />

<ImageButton
android:id="@+id/buttonAddStreamingSearchInfo"
style="?attr/borderlessButtonStyle"
android:layout_width="48dp"
android:layout_height="48dp"
android:background="?attr/selectableItemBackgroundBorderless"
android:contentDescription="@string/action_stream_info"
android:src="@drawable/ic_info_control_24dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

</RelativeLayout>
</ScrollView>

Expand Down
96 changes: 56 additions & 40 deletions app/src/main/res/layout/fragment_show_narrow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -162,48 +162,64 @@

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

<Button
android:id="@+id/buttonShowTrailer"
style="@style/Widget.SeriesGuide.Button.Borderless.Sheet"
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/constraintLayoutShowButtons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/trailer"
app:icon="@drawable/ic_movie_white_24dp"
app:iconGravity="start" />

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

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

<Button
android:id="@+id/buttonShowComments"
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:layout_width="match_parent"
android:layout_height="1dp"
android:layout_marginLeft="@dimen/large_padding"
android:layout_marginRight="@dimen/large_padding"
android:background="?attr/sgColorDivider" />
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp">

<androidx.constraintlayout.helper.widget.Flow
android:layout_width="0dp"
android:layout_height="wrap_content"
app:constraint_referenced_ids="buttonShowTrailer,buttonShowSimilar,buttonShowShare,buttonShowComments"
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/buttonShowTrailer"
style="@style/Widget.SeriesGuide.Button.Outlined.Icon"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/trailer"
app:icon="@drawable/ic_movie_white_24dp"
app:iconGravity="start" />

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

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

<Button
android:id="@+id/buttonShowComments"
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" />

</androidx.constraintlayout.widget.ConstraintLayout>

<include
android:id="@+id/containerRatings"
Expand Down
Loading