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

Add back button in the integrated player #901

Merged
merged 5 commits into from
Nov 25, 2022
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 @@ -16,8 +16,8 @@ import android.view.ViewGroup
import android.view.WindowManager.LayoutParams.BRIGHTNESS_OVERRIDE_NONE
import android.view.WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON
import android.widget.ImageButton
import android.widget.TextView
import androidx.annotation.RequiresApi
import androidx.appcompat.widget.Toolbar
import androidx.core.view.ViewCompat
import androidx.core.view.isVisible
import androidx.core.view.updatePadding
Expand Down Expand Up @@ -57,7 +57,7 @@ class PlayerFragment : Fragment() {
private var _playerControlsBinding: ExoPlayerControlViewBinding? = null
private val playerControlsBinding: ExoPlayerControlViewBinding get() = _playerControlsBinding!!
private val playerControlsView: View get() = playerControlsBinding.root
private val titleTextView: TextView get() = playerControlsBinding.trackTitle
private val toolbar: Toolbar get() = playerControlsBinding.toolbar
private val fullscreenSwitcher: ImageButton get() = playerControlsBinding.fullscreenSwitcher
private var playerMenus: PlayerMenus? = null

Expand Down Expand Up @@ -110,7 +110,7 @@ class PlayerFragment : Fragment() {
}

// Update title and player menus
titleTextView.text = jellyfinMediaSource.name
toolbar.title = jellyfinMediaSource.name
playerMenus?.onQueueItemChanged(queueItem)
}

Expand Down Expand Up @@ -158,6 +158,9 @@ class PlayerFragment : Fragment() {
insets
}

// Handle toolbar back button
toolbar.setNavigationOnClickListener { parentFragmentManager.popBackStack() }

// Create playback menus
playerMenus = PlayerMenus(this, playerBinding, playerControlsBinding)

Expand Down
17 changes: 7 additions & 10 deletions app/src/main/res/layout/exo_player_control_view.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,17 @@
android:layout_height="match_parent"
android:background="@color/playback_controls_background">

<androidx.appcompat.widget.AppCompatTextView
android:id="@+id/track_title"
android:layout_width="match_parent"
<androidx.appcompat.widget.Toolbar
android:id="@+id/toolbar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:ellipsize="end"
android:padding="@dimen/exo_player_controls_display_padding"
android:paddingTop="16dp"
android:textColor="?android:textColorPrimary"
android:textSize="@dimen/exo_title_text_size"
android:textStyle="bold"
android:theme="@style/ThemeOverlay.App.BackButton"
app:contentInsetStartWithNavigation="0dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:text="Star Wars: A New Hope" />
app:navigationIcon="?attr/homeAsUpIndicator"
tools:title="Star Wars: A New Hope" />

<androidx.appcompat.widget.AppCompatImageButton
android:id="@+id/previous_button"
Expand Down
5 changes: 5 additions & 0 deletions app/src/main/res/values/styles.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@

<!-- Settings theme -->
<style name="AppTheme.Settings" />

<!-- Theme Overlays -->
<style name="ThemeOverlay.App.BackButton" parent="">
<item name="colorControlNormal">?android:textColorPrimary</item>
</style>
</resources>