Browse Source

Changed style for main shuffle button to be less conspicuous.

housekeeping/remove-warnings
Antoine POPINEAU 4 years ago
parent
commit
2b9eb789e8
No known key found for this signature in database
GPG Key ID: A78AC64694F84063
  1. 20
      app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt
  2. 79
      app/src/main/java/com/github/apognu/otter/views/ExplodeReveal.kt
  3. 24
      app/src/main/java/com/github/apognu/otter/views/LoaderViews.kt
  4. 9
      app/src/main/res/layout-land/fragment_albums.xml
  5. 11
      app/src/main/res/layout-land/fragment_tracks.xml
  6. 9
      app/src/main/res/layout/fragment_albums.xml
  7. 10
      app/src/main/res/layout/fragment_favorites.xml
  8. 10
      app/src/main/res/layout/fragment_tracks.xml

20
app/src/main/java/com/github/apognu/otter/fragments/AlbumsFragment.kt

@ -1,13 +1,20 @@ @@ -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>() { @@ -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>() { @@ -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
}
}
}

79
app/src/main/java/com/github/apognu/otter/views/ExplodeReveal.kt

@ -1,79 +0,0 @@ @@ -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
}
}
}

24
app/src/main/java/com/github/apognu/otter/views/LoaderViews.kt

@ -6,30 +6,6 @@ import android.graphics.drawable.Drawable @@ -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? {

9
app/src/main/res/layout-land/fragment_albums.xml

@ -56,20 +56,23 @@ @@ -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>

11
app/src/main/res/layout-land/fragment_tracks.xml

@ -40,7 +40,7 @@ @@ -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 @@ @@ -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 @@ @@ -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 @@ @@ -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>

9
app/src/main/res/layout/fragment_albums.xml

@ -54,20 +54,23 @@ @@ -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>

10
app/src/main/res/layout/fragment_favorites.xml

@ -49,18 +49,20 @@ @@ -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>

10
app/src/main/res/layout/fragment_tracks.xml

@ -58,7 +58,7 @@ @@ -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 @@ @@ -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 @@ @@ -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…
Cancel
Save