Update mini player for tablet

main
Hemanth S 2020-05-21 23:52:48 +05:30
parent 9bbaad4104
commit ae63b6798f
4 changed files with 103 additions and 70 deletions

View File

@ -14,12 +14,14 @@ import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.extensions.textColorPrimary import code.name.monkey.retromusic.extensions.textColorPrimary
import code.name.monkey.retromusic.extensions.textColorSecondary import code.name.monkey.retromusic.extensions.textColorSecondary
import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment import code.name.monkey.retromusic.fragments.base.AbsMusicServiceFragment
import code.name.monkey.retromusic.glide.SongGlideRequest
import code.name.monkey.retromusic.helper.MusicPlayerRemote import code.name.monkey.retromusic.helper.MusicPlayerRemote
import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper import code.name.monkey.retromusic.helper.MusicProgressViewUpdateHelper
import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.RetroUtil import code.name.monkey.retromusic.util.RetroUtil
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import com.bumptech.glide.Glide
import kotlinx.android.synthetic.main.fragment_mini_player.* import kotlinx.android.synthetic.main.fragment_mini_player.*
import kotlin.math.abs import kotlin.math.abs
@ -58,6 +60,7 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
actionPrevious.visibility = View.VISIBLE actionPrevious.visibility = View.VISIBLE
actionNext?.visibility = View.VISIBLE actionNext?.visibility = View.VISIBLE
actionPrevious?.visibility = View.VISIBLE actionPrevious?.visibility = View.VISIBLE
} else { } else {
actionNext.visibility = actionNext.visibility =
if (PreferenceUtil.getInstance(requireContext()).isExtraControls) View.VISIBLE else View.GONE if (PreferenceUtil.getInstance(requireContext()).isExtraControls) View.VISIBLE else View.GONE
@ -93,6 +96,19 @@ open class MiniPlayerFragment : AbsMusicServiceFragment(), MusicProgressViewUpda
miniPlayerTitle.isSelected = true miniPlayerTitle.isSelected = true
miniPlayerTitle.text = builder miniPlayerTitle.text = builder
if (RetroUtil.isTablet()) {
image?.let {
SongGlideRequest.Builder.from(
Glide.with(requireContext()),
MusicPlayerRemote.currentSong
).checkIgnoreMediaStore(requireContext())
.ignoreMediaStore(PreferenceUtil.isAllowedToDownloadMetadata(requireContext()))
.asBitmap()
.build()
.into(it)
}
}
} }
override fun onServiceConnected() { override fun onServiceConnected() {

View File

@ -38,7 +38,6 @@ class SongsFragment :
} }
override fun createLayoutManager(): GridLayoutManager { override fun createLayoutManager(): GridLayoutManager {
println("createLayoutManager: ${getGridSize()}")
return GridLayoutManager(requireActivity(), getGridSize()).apply { return GridLayoutManager(requireActivity(), getGridSize()).apply {
spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() { spanSizeLookup = object : GridLayoutManager.SpanSizeLookup() {
override fun getSpanSize(position: Int): Int { override fun getSpanSize(position: Int): Int {
@ -118,7 +117,6 @@ class SongsFragment :
} }
companion object { companion object {
@JvmField @JvmField
var TAG: String = SongsFragment::class.java.simpleName var TAG: String = SongsFragment::class.java.simpleName

View File

@ -1,90 +1,109 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/miniPlayerContent" android:id="@+id/miniPlayerContent"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="@dimen/bottom_sheet_peek_1_height" android:layout_height="@dimen/mini_player_height"
android:background="?attr/colorSurface" android:background="?attr/colorSurface"
android:clickable="true" android:clickable="true"
android:focusable="true" android:focusable="true"
android:transitionName="@string/transition_mini_player" android:transitionName="@string/transition_mini_player"
tools:ignore="UnusedAttribute"> tools:ignore="UnusedAttribute">
<LinearLayout <com.google.android.material.card.MaterialCardView
android:layout_width="match_parent" android:id="@+id/imageContainer"
android:layout_height="match_parent" android:layout_width="wrap_content"
android:orientation="horizontal"> android:layout_height="wrap_content"
android:layout_marginStart="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/miniPlayerImage" android:id="@+id/image"
android:layout_width="24dp" android:layout_width="38dp"
android:layout_height="24dp" android:layout_height="38dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_margin="16dp"
android:scaleType="centerCrop" android:scaleType="centerCrop"
app:srcCompat="@drawable/ic_keyboard_arrow_up_24dp"
app:tint="?attr/colorControlNormal"
tools:ignore="ContentDescription" />
<com.google.android.material.textview.MaterialTextView
android:id="@+id/miniPlayerTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:gravity="center"
android:marqueeRepeatLimit="marquee_forever"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="@style/TextViewNormal"
android:textColor="?android:attr/textColorPrimary"
tools:text="Song name and details" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/actionPrevious"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:background="?roundSelector"
android:padding="8dp"
app:srcCompat="@drawable/ic_skip_previous_white_24dp"
app:tint="?attr/colorControlNormal" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/miniPlayerPlayPauseButton"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:background="?roundSelector"
android:scaleType="center"
app:srcCompat="@drawable/ic_pause_white_24dp"
app:tint="?attr/colorControlNormal"
tools:ignore="ContentDescription" tools:ignore="ContentDescription"
tools:tint="?attr/colorControlNormal" /> tools:src="@drawable/default_album_art" />
</com.google.android.material.card.MaterialCardView>
<com.google.android.material.textview.MaterialTextView
android:id="@+id/miniPlayerTitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:ellipsize="marquee"
android:focusable="true"
android:focusableInTouchMode="true"
android:freezesText="true"
android:marqueeRepeatLimit="marquee_forever"
android:paddingHorizontal="16dp"
android:scrollHorizontally="true"
android:singleLine="true"
android:textAppearance="@style/TextViewNormal"
android:textColor="?android:attr/textColorPrimary"
app:layout_constrainedWidth="true"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/actionPrevious"
app:layout_constraintStart_toEndOf="@id/imageContainer"
app:layout_constraintTop_toTopOf="parent"
tools:text="Song name and details" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/actionPrevious"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:background="?roundSelector"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toStartOf="@id/miniPlayerPlayPauseButton"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_skip_previous_white_24dp"
app:tint="?attr/colorControlNormal" />
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView
android:id="@+id/actionNext" android:id="@+id/miniPlayerPlayPauseButton"
android:layout_width="40dp" android:layout_width="40dp"
android:layout_height="40dp" android:layout_height="40dp"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp" android:background="?roundSelector"
android:background="?roundSelector" android:scaleType="center"
android:padding="8dp" app:layout_constraintBottom_toBottomOf="parent"
app:srcCompat="@drawable/ic_skip_next_white_24dp" app:layout_constraintEnd_toStartOf="@id/actionNext"
app:tint="?attr/colorControlNormal" /> app:layout_constraintTop_toTopOf="parent"
</LinearLayout> app:srcCompat="@drawable/ic_pause_white_24dp"
app:tint="?attr/colorControlNormal"
tools:ignore="ContentDescription"
tools:tint="?attr/colorControlNormal" />
<androidx.appcompat.widget.AppCompatImageView
android:id="@+id/actionNext"
android:layout_width="40dp"
android:layout_height="40dp"
android:layout_gravity="center_vertical"
android:layout_marginEnd="16dp"
android:background="?roundSelector"
android:padding="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:srcCompat="@drawable/ic_skip_next_white_24dp"
app:tint="?attr/colorControlNormal" />
<ProgressBar <ProgressBar
android:id="@+id/progressBar" android:id="@+id/progressBar"
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal" style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
android:layout_width="match_parent" android:layout_width="0dp"
android:layout_height="3dp" android:layout_height="3dp"
android:progress="20" /> android:progress="20"
</FrameLayout> app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>