Added collapsing app bar in Playing queue
This commit is contained in:
parent
09572b2551
commit
a104e42e0c
4 changed files with 21 additions and 33 deletions
|
@ -130,7 +130,7 @@ class PlayingQueueFragment : AbsMusicServiceFragment(R.layout.fragment_playing_q
|
|||
}
|
||||
|
||||
private fun updateCurrentSong() {
|
||||
binding.toolbar.subtitle = getUpNextAndQueueTime()
|
||||
binding.appBarLayout.toolbar.subtitle = getUpNextAndQueueTime()
|
||||
}
|
||||
|
||||
override fun onPlayingMetaChanged() {
|
||||
|
@ -140,7 +140,7 @@ class PlayingQueueFragment : AbsMusicServiceFragment(R.layout.fragment_playing_q
|
|||
private fun updateQueuePosition() {
|
||||
playingQueueAdapter?.setCurrent(MusicPlayerRemote.position)
|
||||
resetToCurrentPosition()
|
||||
binding.toolbar.subtitle = getUpNextAndQueueTime()
|
||||
binding.appBarLayout.toolbar.subtitle = getUpNextAndQueueTime()
|
||||
}
|
||||
|
||||
private fun updateQueue() {
|
||||
|
@ -179,7 +179,7 @@ class PlayingQueueFragment : AbsMusicServiceFragment(R.layout.fragment_playing_q
|
|||
}
|
||||
|
||||
private fun setupToolbar() {
|
||||
binding.toolbar.subtitle = getUpNextAndQueueTime()
|
||||
binding.appBarLayout.toolbar.subtitle = getUpNextAndQueueTime()
|
||||
binding.clearQueue.backgroundTintList = ColorStateList.valueOf(accentColor())
|
||||
ColorStateList.valueOf(
|
||||
MaterialValueHelper.getPrimaryTextColor(
|
||||
|
@ -190,10 +190,13 @@ class PlayingQueueFragment : AbsMusicServiceFragment(R.layout.fragment_playing_q
|
|||
binding.clearQueue.setTextColor(this)
|
||||
binding.clearQueue.iconTint = this
|
||||
}
|
||||
binding.toolbar.apply {
|
||||
binding.appBarLayout.pinWhenScrolled()
|
||||
binding.appBarLayout.toolbar.apply {
|
||||
setNavigationOnClickListener {
|
||||
findNavController().navigateUp()
|
||||
}
|
||||
setTitle(R.string.now_playing_queue)
|
||||
setTitleTextAppearance(context, R.style.ToolbarTextAppearanceNormal)
|
||||
setNavigationIcon(R.drawable.ic_keyboard_backspace_black)
|
||||
ToolbarContentTintHelper.colorBackButton(this)
|
||||
}
|
||||
|
|
|
@ -5,10 +5,12 @@ import android.content.res.Configuration
|
|||
import android.util.AttributeSet
|
||||
import android.view.LayoutInflater
|
||||
import androidx.appcompat.widget.Toolbar
|
||||
import androidx.core.view.updateLayoutParams
|
||||
import code.name.monkey.retromusic.databinding.CollapsingAppbarLayoutBinding
|
||||
import code.name.monkey.retromusic.databinding.SimpleAppbarLayoutBinding
|
||||
import code.name.monkey.retromusic.util.PreferenceUtil
|
||||
import com.google.android.material.appbar.AppBarLayout
|
||||
import com.google.android.material.appbar.AppBarLayout.LayoutParams.SCROLL_FLAG_NO_SCROLL
|
||||
import com.google.android.material.shape.MaterialShapeDrawable
|
||||
import dev.chrisbanes.insetter.applyInsetter
|
||||
|
||||
|
@ -44,6 +46,12 @@ class TopAppBarLayout @JvmOverloads constructor(
|
|||
}
|
||||
}
|
||||
|
||||
fun pinWhenScrolled() {
|
||||
simpleAppbarBinding?.root?.updateLayoutParams<LayoutParams> {
|
||||
scrollFlags = SCROLL_FLAG_NO_SCROLL
|
||||
}
|
||||
}
|
||||
|
||||
val toolbar: Toolbar
|
||||
get() = if (mode == AppBarMode.COLLAPSING) {
|
||||
collapsingAppbarBinding?.toolbar!!
|
||||
|
|
|
@ -19,23 +19,12 @@
|
|||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
<code.name.monkey.retromusic.views.TopAppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
style="?appBarLayoutStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:liftOnScroll="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_collapseMode="pin"
|
||||
app:navigationIcon="@drawable/ic_keyboard_backspace_black"
|
||||
app:title="@string/queue"
|
||||
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
android:fitsSystemWindows="true" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
|
|
|
@ -7,24 +7,12 @@
|
|||
android:background="?attr/colorSurface"
|
||||
android:fitsSystemWindows="true">
|
||||
|
||||
<com.google.android.material.appbar.AppBarLayout
|
||||
<code.name.monkey.retromusic.views.TopAppBarLayout
|
||||
android:id="@+id/appBarLayout"
|
||||
style="?appBarLayoutStyle"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:fitsSystemWindows="true"
|
||||
app:liftOnScroll="true">
|
||||
|
||||
<com.google.android.material.appbar.MaterialToolbar
|
||||
android:id="@+id/toolbar"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_collapseMode="pin"
|
||||
app:navigationIcon="@drawable/ic_keyboard_backspace_black"
|
||||
app:title="@string/queue"
|
||||
app:titleTextAppearance="@style/ToolbarTextAppearanceNormal"
|
||||
tools:ignore="UnusedAttribute" />
|
||||
|
||||
</com.google.android.material.appbar.AppBarLayout>
|
||||
android:fitsSystemWindows="true" />
|
||||
|
||||
<androidx.recyclerview.widget.RecyclerView
|
||||
android:id="@+id/recyclerView"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue