Skip to content

Commit

Permalink
Add back button in the integrated player (#901)
Browse files Browse the repository at this point in the history
* added back button in the exo player

* fixed the margin on the left of the title

* Fix whitespace issues

* Use resource reference for color

* Move toolbar button handling to onViewCreated

Co-authored-by: Maxr1998 <[email protected]>
  • Loading branch information
susonthapa and Maxr1998 authored Nov 25, 2022
1 parent eee80e3 commit a10c54a
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 13 deletions.
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>

0 comments on commit a10c54a

Please sign in to comment.