Add landscape support to PlaybackFragment
Add a landscape layout to PlaybackFragment. Signed-off-by: OxygenCobalt <alexyx@tutanota.com>
This commit is contained in:
parent
9b22fcb8e6
commit
fca42f2cb0
5 changed files with 237 additions and 11 deletions
|
@ -45,16 +45,18 @@ class CompactPlaybackFragment : Fragment() {
|
||||||
hideAll(binding)
|
hideAll(binding)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.root.setOnClickListener {
|
binding.root.apply {
|
||||||
|
setOnClickListener {
|
||||||
findNavController().navigate(
|
findNavController().navigate(
|
||||||
MainFragmentDirections.actionGoToPlayback()
|
MainFragmentDirections.actionGoToPlayback()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
binding.root.setOnLongClickListener {
|
setOnLongClickListener {
|
||||||
playbackModel.navToItem(playbackModel.song.value!!)
|
playbackModel.navToItem(playbackModel.song.value!!)
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// --- VIEWMODEL SETUP ---
|
// --- VIEWMODEL SETUP ---
|
||||||
|
|
||||||
|
@ -89,7 +91,6 @@ class CompactPlaybackFragment : Fragment() {
|
||||||
// leak.
|
// leak.
|
||||||
val playbackControls = requireView().findViewById<ImageButton>(R.id.playback_controls)
|
val playbackControls = requireView().findViewById<ImageButton>(R.id.playback_controls)
|
||||||
|
|
||||||
// Observe the changes to isPlaying for
|
|
||||||
val iconPauseToPlay = ContextCompat.getDrawable(
|
val iconPauseToPlay = ContextCompat.getDrawable(
|
||||||
requireContext(), R.drawable.ic_pause_to_play
|
requireContext(), R.drawable.ic_pause_to_play
|
||||||
) as AnimatedVectorDrawable
|
) as AnimatedVectorDrawable
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/root_layout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
|
|
226
app/src/main/res/layout-land/fragment_playback.xml
Normal file
226
app/src/main/res/layout-land/fragment_playback.xml
Normal file
|
@ -0,0 +1,226 @@
|
||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<layout 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"
|
||||||
|
tools:context=".playback.PlaybackFragment">
|
||||||
|
|
||||||
|
<data>
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="song"
|
||||||
|
type="org.oxycblt.auxio.music.Song" />
|
||||||
|
|
||||||
|
<variable
|
||||||
|
name="playbackModel"
|
||||||
|
type="org.oxycblt.auxio.playback.PlaybackViewModel" />
|
||||||
|
</data>
|
||||||
|
|
||||||
|
|
||||||
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
|
android:id="@+id/playback_layout"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:animateLayoutChanges="true"
|
||||||
|
android:background="@color/background"
|
||||||
|
android:fitsSystemWindows="true">
|
||||||
|
|
||||||
|
<androidx.appcompat.widget.Toolbar
|
||||||
|
android:id="@+id/playback_toolbar"
|
||||||
|
style="@style/Toolbar.Style.Icon"
|
||||||
|
android:elevation="0dp"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:menu="@menu/menu_playback"
|
||||||
|
app:navigationIcon="@drawable/ic_down"
|
||||||
|
app:title="@string/label_playback" />
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/playback_cover"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="0dp"
|
||||||
|
android:layout_margin="@dimen/margin_mid_large"
|
||||||
|
android:contentDescription="@{@string/description_album_cover(song.name)}"
|
||||||
|
android:elevation="@dimen/elevation_normal"
|
||||||
|
android:outlineProvider="bounds"
|
||||||
|
app:coverArt="@{song}"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
app:layout_constraintDimensionRatio="1:1"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/playback_toolbar"
|
||||||
|
tools:src="@drawable/ic_song" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/playback_song"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/margin_mid_large"
|
||||||
|
android:ellipsize="marquee"
|
||||||
|
android:focusable="true"
|
||||||
|
android:fontFamily="@font/inter_semibold"
|
||||||
|
android:marqueeRepeatLimit="marquee_forever"
|
||||||
|
android:onClick="@{() -> playbackModel.navToItem(playbackModel.song)}"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="@{song.name}"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Headline6"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/playback_artist"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/playback_cover"
|
||||||
|
app:layout_constraintVertical_chainStyle="packed"
|
||||||
|
tools:text="Song Name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/playback_artist"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/margin_mid_large"
|
||||||
|
android:layout_marginEnd="@dimen/margin_mid_large"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:onClick="@{() -> playbackModel.navToItem(playbackModel.song.album.artist)}"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="@{song.album.artist.name}"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/playback_album"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/playback_song"
|
||||||
|
tools:text="Artist Name" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/playback_album"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/margin_mid_large"
|
||||||
|
android:layout_marginEnd="@dimen/margin_mid_large"
|
||||||
|
android:layout_marginBottom="16dp"
|
||||||
|
android:ellipsize="end"
|
||||||
|
android:onClick="@{() -> playbackModel.navToItem(playbackModel.song.album)}"
|
||||||
|
android:singleLine="true"
|
||||||
|
android:text="@{song.album.name}"
|
||||||
|
android:textAppearance="@style/TextAppearance.MaterialComponents.Subtitle1"
|
||||||
|
android:textColor="?android:attr/textColorSecondary"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/playback_seek_bar"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/playback_artist"
|
||||||
|
tools:text="Album Name" />
|
||||||
|
|
||||||
|
<SeekBar
|
||||||
|
android:id="@+id/playback_seek_bar"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:clickable="true"
|
||||||
|
android:focusable="true"
|
||||||
|
android:paddingStart="@dimen/margin_mid_large"
|
||||||
|
android:paddingEnd="@dimen/margin_mid_large"
|
||||||
|
android:progressBackgroundTint="?android:attr/colorControlNormal"
|
||||||
|
android:progressTint="?attr/colorPrimary"
|
||||||
|
android:splitTrack="false"
|
||||||
|
android:thumbOffset="@dimen/offset_thumb"
|
||||||
|
android:thumbTint="?attr/colorPrimary"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/playback_duration_current"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/playback_album"
|
||||||
|
tools:progress="70" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/playback_duration_current"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="@dimen/margin_mid_large"
|
||||||
|
android:layout_marginBottom="@dimen/margin_medium"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/playback_play_pause"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/playback_seek_bar"
|
||||||
|
tools:text="11:38" />
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/playback_song_duration"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginEnd="@dimen/margin_mid_large"
|
||||||
|
android:layout_marginBottom="@dimen/margin_medium"
|
||||||
|
android:text="@{song.formattedDuration}"
|
||||||
|
app:layout_constraintBottom_toTopOf="@+id/playback_play_pause"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
tools:text="16:16" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/playback_play_pause"
|
||||||
|
android:layout_width="@dimen/size_play_pause"
|
||||||
|
android:layout_height="@dimen/size_play_pause"
|
||||||
|
android:background="@drawable/ui_circular_button"
|
||||||
|
android:backgroundTint="?attr/colorPrimary"
|
||||||
|
android:contentDescription="@{playbackModel.isPlaying ? @string/description_pause : @string/description_play}"
|
||||||
|
android:foregroundTint="@color/background"
|
||||||
|
android:onClick="@{() -> playbackModel.invertPlayingStatus()}"
|
||||||
|
android:tint="@color/background"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/playback_cover"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintHorizontal_bias="0.5"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/playback_cover"
|
||||||
|
app:layout_constraintTop_toBottomOf="@+id/playback_duration_current"
|
||||||
|
tools:src="@drawable/ic_play_to_pause" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/playback_skip_next"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
android:layout_width="@dimen/size_play_pause_compact"
|
||||||
|
android:layout_height="@dimen/size_play_pause_compact"
|
||||||
|
android:layout_marginStart="@dimen/margin_mid_large"
|
||||||
|
android:background="@drawable/ui_unbounded_ripple"
|
||||||
|
android:contentDescription="@string/description_skip_next"
|
||||||
|
android:onClick="@{() -> playbackModel.skipNext()}"
|
||||||
|
android:src="@drawable/ic_skip_next_large"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/playback_play_pause"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/playback_play_pause" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/playback_skip_prev"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
android:layout_width="@dimen/size_play_pause_compact"
|
||||||
|
android:layout_height="@dimen/size_play_pause_compact"
|
||||||
|
android:layout_marginEnd="@dimen/margin_mid_large"
|
||||||
|
android:background="@drawable/ui_unbounded_ripple"
|
||||||
|
android:contentDescription="@string/description_skip_prev"
|
||||||
|
android:onClick="@{() -> playbackModel.skipPrev()}"
|
||||||
|
android:src="@drawable/ic_skip_prev_large"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/playback_play_pause"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/playback_play_pause" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/playback_shuffle"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
android:layout_width="@dimen/size_play_pause_compact"
|
||||||
|
android:layout_height="@dimen/size_play_pause_compact"
|
||||||
|
android:layout_marginStart="@dimen/margin_mid_large"
|
||||||
|
android:background="@drawable/ui_unbounded_ripple"
|
||||||
|
android:contentDescription="@{playbackModel.isShuffling() ? @string/description_shuffle_off : @string/description_shuffle_on"
|
||||||
|
android:onClick="@{() -> playbackModel.invertShuffleStatus()}"
|
||||||
|
android:src="@drawable/ic_shuffle_large"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
|
||||||
|
app:layout_constraintStart_toEndOf="@+id/playback_skip_next"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/playback_play_pause" />
|
||||||
|
|
||||||
|
<ImageButton
|
||||||
|
android:id="@+id/playback_loop"
|
||||||
|
style="@style/Widget.AppCompat.Button.Borderless"
|
||||||
|
android:layout_width="@dimen/size_play_pause_compact"
|
||||||
|
android:layout_height="@dimen/size_play_pause_compact"
|
||||||
|
android:layout_marginEnd="@dimen/margin_mid_large"
|
||||||
|
android:background="@drawable/ui_unbounded_ripple"
|
||||||
|
android:contentDescription="@string/description_change_loop"
|
||||||
|
android:onClick="@{() -> playbackModel.incrementLoopStatus()}"
|
||||||
|
android:src="@drawable/ic_loop_large"
|
||||||
|
app:layout_constraintBottom_toBottomOf="@+id/playback_play_pause"
|
||||||
|
app:layout_constraintEnd_toStartOf="@+id/playback_skip_prev"
|
||||||
|
app:layout_constraintTop_toTopOf="@+id/playback_play_pause" />
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
</layout>
|
|
@ -16,7 +16,6 @@
|
||||||
</data>
|
</data>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/root_layout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:animateLayoutChanges="true"
|
android:animateLayoutChanges="true"
|
||||||
|
|
|
@ -51,6 +51,7 @@
|
||||||
<style name="TextAppearance.Toolbar.Header" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
|
<style name="TextAppearance.Toolbar.Header" parent="TextAppearance.Widget.AppCompat.Toolbar.Title">
|
||||||
<item name="android:fontFamily">@font/inter_black</item>
|
<item name="android:fontFamily">@font/inter_black</item>
|
||||||
<item name="android:textColor">?attr/colorPrimary</item>
|
<item name="android:textColor">?attr/colorPrimary</item>
|
||||||
|
<item name="android:textSize">20sp</item>
|
||||||
</style>
|
</style>
|
||||||
|
|
||||||
<!-- Title theme for Detail Fragments -->
|
<!-- Title theme for Detail Fragments -->
|
||||||
|
|
Loading…
Reference in a new issue