Changed style for main shuffle button to be less conspicuous.
This commit is contained in:
parent
b2d26a8127
commit
2b9eb789e8
|
@ -1,13 +1,20 @@
|
|||
package com.github.apognu.otter.fragments
|
||||
|
||||
import android.content.Context
|
||||
import android.graphics.Rect
|
||||
import android.graphics.drawable.Drawable
|
||||
import android.os.Bundle
|
||||
import android.text.SpannableString
|
||||
import android.text.Spanned
|
||||
import android.text.style.DynamicDrawableSpan
|
||||
import android.view.View
|
||||
import android.view.animation.AccelerateDecelerateInterpolator
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import androidx.core.content.ContextCompat
|
||||
import androidx.core.os.bundleOf
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.recyclerview.widget.RecyclerView
|
||||
import androidx.swiperefreshlayout.widget.CircularProgressDrawable
|
||||
import androidx.transition.Fade
|
||||
import androidx.transition.Slide
|
||||
import com.github.apognu.otter.R
|
||||
|
@ -115,7 +122,15 @@ class AlbumsFragment : FunkwhaleFragment<Album, AlbumsAdapter>() {
|
|||
artist.text = artistName
|
||||
|
||||
play.setOnClickListener {
|
||||
val loaderAnimation = LoadingFlotingActionButton.start(play)
|
||||
val loader = CircularProgressDrawable(requireContext()).apply {
|
||||
setColorSchemeColors(ContextCompat.getColor(requireContext(), android.R.color.white))
|
||||
strokeWidth = 4f
|
||||
}
|
||||
|
||||
loader.start()
|
||||
|
||||
play.icon = loader
|
||||
play.isClickable = false
|
||||
|
||||
GlobalScope.launch(IO) {
|
||||
artistTracksRepository.fetch(Repository.Origin.Network.origin)
|
||||
|
@ -127,7 +142,8 @@ class AlbumsFragment : FunkwhaleFragment<Album, AlbumsAdapter>() {
|
|||
CommandBus.send(Command.ReplaceQueue(it))
|
||||
|
||||
withContext(Main) {
|
||||
LoadingFlotingActionButton.stop(play, loaderAnimation)
|
||||
play.icon = requireContext().getDrawable(R.drawable.play)
|
||||
play.isClickable = true
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
package com.github.apognu.otter.views
|
||||
|
||||
import android.animation.Animator
|
||||
import android.animation.ObjectAnimator
|
||||
import android.graphics.Rect
|
||||
import android.view.View
|
||||
import android.view.ViewGroup
|
||||
import androidx.transition.TransitionValues
|
||||
import androidx.transition.Visibility
|
||||
|
||||
class ExplodeReveal : Visibility() {
|
||||
private val SCREEN_BOUNDS = "screenBounds"
|
||||
|
||||
private val locations = IntArray(2)
|
||||
|
||||
override fun captureStartValues(transitionValues: TransitionValues) {
|
||||
super.captureStartValues(transitionValues)
|
||||
|
||||
capture(transitionValues)
|
||||
}
|
||||
|
||||
override fun captureEndValues(transitionValues: TransitionValues) {
|
||||
super.captureEndValues(transitionValues)
|
||||
|
||||
capture(transitionValues)
|
||||
}
|
||||
|
||||
override fun onAppear(sceneRoot: ViewGroup, view: View, startValues: TransitionValues?, endValues: TransitionValues?): Animator? {
|
||||
if (endValues == null) return null
|
||||
|
||||
val bounds = endValues.values[SCREEN_BOUNDS] as Rect
|
||||
|
||||
val endY = view.translationY
|
||||
val distance = calculateDistance(sceneRoot, bounds)
|
||||
val startY = endY + distance
|
||||
|
||||
return ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, startY, endY)
|
||||
}
|
||||
|
||||
override fun onDisappear(sceneRoot: ViewGroup, view: View, startValues: TransitionValues?, endValues: TransitionValues?): Animator? {
|
||||
if (startValues == null) return null
|
||||
|
||||
val bounds = startValues.values[SCREEN_BOUNDS] as Rect
|
||||
|
||||
val startY = view.translationY
|
||||
val distance = calculateDistance(sceneRoot, bounds)
|
||||
val endY = startY + distance
|
||||
|
||||
return ObjectAnimator.ofFloat(view, View.TRANSLATION_Y, startY, endY)
|
||||
}
|
||||
|
||||
private fun capture(transitionValues: TransitionValues) {
|
||||
transitionValues.view.also {
|
||||
it.getLocationOnScreen(locations)
|
||||
|
||||
val left = locations[0]
|
||||
val top = locations[1]
|
||||
val right = left + it.width
|
||||
val bottom = top + it.height
|
||||
|
||||
transitionValues.values[SCREEN_BOUNDS] = Rect(left, top, right, bottom)
|
||||
}
|
||||
}
|
||||
|
||||
private fun calculateDistance(sceneRoot: View, viewBounds: Rect): Int {
|
||||
sceneRoot.getLocationOnScreen(locations)
|
||||
|
||||
val sceneRootY = locations[1]
|
||||
|
||||
return when (epicenter) {
|
||||
is Rect -> return when {
|
||||
viewBounds.top <= (epicenter as Rect).top -> sceneRootY - (epicenter as Rect).top
|
||||
else -> sceneRootY + sceneRoot.height - (epicenter as Rect).bottom
|
||||
}
|
||||
|
||||
else -> -sceneRoot.height
|
||||
}
|
||||
}
|
||||
}
|
|
@ -6,30 +6,6 @@ import android.graphics.drawable.Drawable
|
|||
import android.view.View
|
||||
import android.widget.ImageView
|
||||
import com.github.apognu.otter.R
|
||||
import com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
|
||||
object LoadingFlotingActionButton {
|
||||
fun start(button: ExtendedFloatingActionButton): ObjectAnimator {
|
||||
button.isEnabled = false
|
||||
button.setIconResource(R.drawable.fab_spinner)
|
||||
button.shrink()
|
||||
|
||||
return ObjectAnimator.ofFloat(button, View.ROTATION, 0f, 360f).apply {
|
||||
duration = 500
|
||||
repeatCount = ObjectAnimator.INFINITE
|
||||
start()
|
||||
}
|
||||
}
|
||||
|
||||
fun stop(button: ExtendedFloatingActionButton, animator: ObjectAnimator) {
|
||||
animator.cancel()
|
||||
|
||||
button.isEnabled = true
|
||||
button.setIconResource(R.drawable.play)
|
||||
button.rotation = 0.0f
|
||||
button.extend()
|
||||
}
|
||||
}
|
||||
|
||||
object LoadingImageView {
|
||||
fun start(context: Context?, image: ImageView): ObjectAnimator? {
|
||||
|
|
|
@ -56,20 +56,23 @@
|
|||
app:layout_constraintVertical_bias="0"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/play"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:elevation="10dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:text="@string/playback_shuffle"
|
||||
android:textColor="@android:color/white"
|
||||
app:icon="@drawable/play"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@android:color/white"
|
||||
app:layout_constraintBottom_toBottomOf="@id/cover"
|
||||
app:layout_constraintLeft_toLeftOf="@id/cover"
|
||||
app:layout_constraintRight_toRightOf="@id/cover"
|
||||
app:layout_constraintTop_toBottomOf="@id/cover" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cover"
|
||||
app:rippleColor="@color/ripple" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@
|
|||
<ImageView
|
||||
android:id="@+id/cover"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="100dp"
|
||||
android:layout_height="250dp"
|
||||
android:layout_margin="8dp"
|
||||
android:contentDescription="@string/alt_album_cover"
|
||||
android:scaleType="centerCrop"
|
||||
|
@ -56,6 +56,7 @@
|
|||
android:id="@+id/covers"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:layout_margin="8dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@ -128,12 +129,13 @@
|
|||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/play"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:elevation="10dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:text="@string/playback_shuffle"
|
||||
android:textColor="@android:color/white"
|
||||
app:icon="@drawable/play"
|
||||
|
@ -141,7 +143,8 @@
|
|||
app:layout_constraintBottom_toBottomOf="@id/cover"
|
||||
app:layout_constraintLeft_toLeftOf="@id/cover"
|
||||
app:layout_constraintRight_toRightOf="@id/cover"
|
||||
app:layout_constraintTop_toBottomOf="@id/cover" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cover"
|
||||
app:rippleColor="@color/ripple" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -54,20 +54,23 @@
|
|||
app:layout_constraintVertical_bias="0"
|
||||
tools:src="@tools:sample/avatars" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/play"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:elevation="10dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:text="@string/playback_shuffle"
|
||||
android:textColor="@android:color/white"
|
||||
app:icon="@drawable/play"
|
||||
app:iconSize="24dp"
|
||||
app:iconTint="@android:color/white"
|
||||
app:layout_constraintBottom_toBottomOf="@id/cover"
|
||||
app:layout_constraintLeft_toLeftOf="@id/cover"
|
||||
app:layout_constraintRight_toRightOf="@id/cover"
|
||||
app:layout_constraintTop_toBottomOf="@id/cover" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cover"
|
||||
app:rippleColor="@color/ripple" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
|
@ -49,18 +49,20 @@
|
|||
android:layout_marginBottom="16dp"
|
||||
android:text="@string/favorites" />
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/play"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_centerHorizontal="true"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginTop="8dp"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:elevation="10dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:text="@string/playback_shuffle"
|
||||
android:textColor="@android:color/white"
|
||||
app:icon="@drawable/play"
|
||||
app:iconTint="@android:color/white" />
|
||||
app:iconTint="@android:color/white"
|
||||
app:rippleColor="@color/ripple" />
|
||||
|
||||
</RelativeLayout>
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@
|
|||
android:id="@+id/covers"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="250dp"
|
||||
android:padding="8dp"
|
||||
android:layout_margin="8dp"
|
||||
android:visibility="gone"
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
@ -131,12 +131,13 @@
|
|||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
<com.google.android.material.floatingactionbutton.ExtendedFloatingActionButton
|
||||
<com.google.android.material.button.MaterialButton
|
||||
android:id="@+id/play"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:backgroundTint="@color/colorPrimary"
|
||||
android:elevation="10dp"
|
||||
android:paddingHorizontal="16dp"
|
||||
android:paddingVertical="8dp"
|
||||
android:text="@string/playback_shuffle"
|
||||
android:textColor="@android:color/white"
|
||||
app:icon="@drawable/play"
|
||||
|
@ -144,7 +145,8 @@
|
|||
app:layout_constraintBottom_toBottomOf="@id/cover"
|
||||
app:layout_constraintLeft_toLeftOf="@id/cover"
|
||||
app:layout_constraintRight_toRightOf="@id/cover"
|
||||
app:layout_constraintTop_toBottomOf="@id/cover" />
|
||||
app:layout_constraintTop_toBottomOf="@id/cover"
|
||||
app:rippleColor="@color/ripple" />
|
||||
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
|
|
Loading…
Reference in New Issue