Fix Slider thumb size

This commit is contained in:
h4h13 2020-03-01 20:53:19 +05:30
parent 20e71f355a
commit 19c7b826f4
25 changed files with 98 additions and 64 deletions

View file

@ -67,6 +67,11 @@ android {
versionName defaultConfig.versionName + "_" + getDate() versionName defaultConfig.versionName + "_" + getDate()
dimension "default" dimension "default"
} }
nofont {
versionCode defaultConfig.versionCode + 10000
versionName defaultConfig.versionName + "_" + getDate()
dimension "default"
}
} }
packagingOptions { packagingOptions {

Binary file not shown.

View file

@ -21,6 +21,7 @@ import code.name.monkey.retromusic.helper.PlayPauseButtonOnClickHandler
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.SliderReadTimeLabelFormatter
import code.name.monkey.retromusic.util.ViewUtil import code.name.monkey.retromusic.util.ViewUtil
import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.* import kotlinx.android.synthetic.main.fragment_adaptive_player_playback_controls.*
@ -233,6 +234,7 @@ class AdaptivePlaybackControlsFragment : AbsPlayerControlsFragment() {
} }
override fun setUpProgressSlider() { override fun setUpProgressSlider() {
progressSlider.setLabelFormatter(SliderReadTimeLabelFormatter())
progressSlider.addOnChangeListener { _, value, fromUser -> progressSlider.addOnChangeListener { _, value, fromUser ->
if (fromUser) { if (fromUser) {
MusicPlayerRemote.seekTo(value.toInt()) MusicPlayerRemote.seekTo(value.toInt())

View file

@ -25,6 +25,7 @@ import android.view.ViewGroup
import androidx.appcompat.widget.Toolbar import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.ThemeStore import code.name.monkey.appthemehelper.ThemeStore
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.TintHelper import code.name.monkey.appthemehelper.util.TintHelper
import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper import code.name.monkey.appthemehelper.util.ToolbarContentTintHelper
import code.name.monkey.retromusic.R import code.name.monkey.retromusic.R
@ -97,6 +98,8 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
false false
) )
volumeSeekBar.progressColor = ThemeStore.accentColor(requireContext()) volumeSeekBar.progressColor = ThemeStore.accentColor(requireContext())
volumeSeekBar.arcColor = ColorUtil
.withAlpha(ThemeStore.accentColor(requireContext()), 0.25f)
setUpPlayPauseFab() setUpPlayPauseFab()
setUpPrevNext() setUpPrevNext()
setUpPlayerToolbar() setUpPlayerToolbar()
@ -116,7 +119,6 @@ class CirclePlayerFragment : AbsPlayerFragment(), Callback, OnAudioVolumeChanged
private fun setUpPlayPauseFab() { private fun setUpPlayPauseFab() {
TintHelper.setTintAuto(playPauseButton, ThemeStore.accentColor(requireContext()), false) TintHelper.setTintAuto(playPauseButton, ThemeStore.accentColor(requireContext()), false)
//TintHelper.setTintAuto(playPauseButton, ATHUtil.resolveColor(requireContext(), R.attr.colorSurface), true)
playPauseButton.setOnClickListener(PlayPauseButtonOnClickHandler()) playPauseButton.setOnClickListener(PlayPauseButtonOnClickHandler())
} }

View file

@ -62,7 +62,6 @@ class FullPlaybackControlsFragment : AbsPlayerControlsFragment(),
songTotalTime.setTextColor(Color.WHITE) songTotalTime.setTextColor(Color.WHITE)
songCurrentProgress.setTextColor(Color.WHITE) songCurrentProgress.setTextColor(Color.WHITE)
title.isSelected = true title.isSelected = true
} }

View file

@ -14,15 +14,12 @@
package code.name.monkey.retromusic.fragments.player.lockscreen package code.name.monkey.retromusic.fragments.player.lockscreen
import android.animation.ObjectAnimator
import android.graphics.PorterDuff import android.graphics.PorterDuff
import android.os.Bundle import android.os.Bundle
import android.view.LayoutInflater import android.view.LayoutInflater
import android.view.View import android.view.View
import android.view.ViewGroup import android.view.ViewGroup
import android.view.animation.DecelerateInterpolator import android.view.animation.DecelerateInterpolator
import android.view.animation.LinearInterpolator
import android.widget.SeekBar
import code.name.monkey.appthemehelper.util.ATHUtil import code.name.monkey.appthemehelper.util.ATHUtil
import code.name.monkey.appthemehelper.util.ColorUtil import code.name.monkey.appthemehelper.util.ColorUtil
import code.name.monkey.appthemehelper.util.MaterialValueHelper import code.name.monkey.appthemehelper.util.MaterialValueHelper
@ -34,7 +31,6 @@ import code.name.monkey.retromusic.fragments.base.AbsPlayerControlsFragment
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.misc.SimpleOnSeekbarChangeListener
import code.name.monkey.retromusic.service.MusicService import code.name.monkey.retromusic.service.MusicService
import code.name.monkey.retromusic.util.MusicUtil import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil import code.name.monkey.retromusic.util.PreferenceUtil
@ -133,6 +129,8 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
volumeFragment?.setTintable(colorFinal) volumeFragment?.setTintable(colorFinal)
ViewUtil.setProgressDrawable(progressSlider, colorFinal, true) ViewUtil.setProgressDrawable(progressSlider, colorFinal, true)
updateRepeatState()
updateShuffleState()
updatePrevNextColor() updatePrevNextColor()
val isDark = ColorUtil.isColorLight(colorFinal) val isDark = ColorUtil.isColorLight(colorFinal)
@ -237,29 +235,22 @@ class LockScreenPlayerControlsFragment : AbsPlayerControlsFragment() {
} }
} }
override fun setUpProgressSlider() {
progressSlider.setOnSeekBarChangeListener(object : SimpleOnSeekbarChangeListener() {
override fun onProgressChanged(seekBar: SeekBar, progress: Int, fromUser: Boolean) {
if (fromUser) {
MusicPlayerRemote.seekTo(progress)
onUpdateProgressViews(
MusicPlayerRemote.songProgressMillis,
MusicPlayerRemote.songDurationMillis
)
}
}
})
}
override fun onUpdateProgressViews(progress: Int, total: Int) { override fun onUpdateProgressViews(progress: Int, total: Int) {
progressSlider.max = total progressSlider.valueTo = total.toFloat()
progressSlider.value = progress.toFloat()
val animator = ObjectAnimator.ofInt(progressSlider, "progress", progress)
animator.duration = SLIDER_ANIMATION_TIME
animator.interpolator = LinearInterpolator()
animator.start()
songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong()) songTotalTime.text = MusicUtil.getReadableDurationString(total.toLong())
songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong()) songCurrentProgress.text = MusicUtil.getReadableDurationString(progress.toLong())
} }
override fun setUpProgressSlider() {
progressSlider.addOnChangeListener { _, value, fromUser ->
if (fromUser) {
MusicPlayerRemote.seekTo(value.toInt())
onUpdateProgressViews(
MusicPlayerRemote.songProgressMillis,
MusicPlayerRemote.songDurationMillis
)
}
}
}
} }

View file

@ -41,9 +41,10 @@ object SongMenuHelper {
R.id.action_set_as_ringtone -> { R.id.action_set_as_ringtone -> {
if (RingtoneManager.requiresDialog(activity)) { if (RingtoneManager.requiresDialog(activity)) {
RingtoneManager.getDialog(activity) RingtoneManager.getDialog(activity)
} else {
val ringtoneManager = RingtoneManager(activity)
ringtoneManager.setRingtone(song)
} }
val ringtoneManager = RingtoneManager(activity)
ringtoneManager.setRingtone(song)
return true return true
} }
R.id.action_share -> { R.id.action_share -> {

View file

@ -43,7 +43,6 @@ class RingtoneManager(val context: Context) {
return return
} }
try { try {
val cursor = resolver.query( val cursor = resolver.query(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI, MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
@ -65,7 +64,6 @@ class RingtoneManager(val context: Context) {
} }
companion object { companion object {
private const val TAG = "RingtoneManager"
fun requiresDialog(context: Context): Boolean { fun requiresDialog(context: Context): Boolean {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
@ -89,6 +87,5 @@ class RingtoneManager(val context: Context) {
negativeButton(android.R.string.cancel) negativeButton(android.R.string.cancel)
} }
} }
} }
} }

View file

@ -0,0 +1,30 @@
package code.name.monkey.retromusic.util
import com.google.android.material.slider.Slider
import java.util.*
class SliderReadTimeLabelFormatter : Slider.LabelFormatter {
override fun getFormattedValue(value: Float): String {
var minutes: Long = value.toLong() / 1000 / 60
val seconds: Long = value.toLong() / 1000 % 60
return if (minutes < 60) {
String.format(
Locale.getDefault(),
"%01d:%02d",
minutes,
seconds
)
} else {
val hours = minutes / 60
minutes %= 60
String.format(
Locale.getDefault(),
"%d:%02d:%02d",
hours,
minutes,
seconds
)
}
}
}

View file

@ -29,16 +29,12 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="8dp" android:layout_marginTop="8dp"
android:value="1.0f"
android:valueFrom="-0.1f"
android:valueTo="1.0f"
app:labelBehavior="gone"
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:trackHeight="3dp" app:haloRadius="0dp"
tools:valueFrom="0.0" app:thumbRadius="@dimen/slider_thumb_radius"
tools:valueTo="11.0" /> app:trackHeight="@dimen/slider_track_height" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/songTotalTime" android:id="@+id/songTotalTime"

View file

@ -43,22 +43,17 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="8" android:layout_weight="8"
android:splitTrack="false" android:splitTrack="false"
android:value="1.0f"
android:valueFrom="0.0f"
android:valueTo="1.0f"
app:haloColor="@color/md_white_semi_transparent" app:haloColor="@color/md_white_semi_transparent"
app:haloRadius="0dp"
app:labelBehavior="gone" app:labelBehavior="gone"
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:thumbColor="@color/md_white_1000" app:thumbColor="@color/md_white_1000"
app:thumbRadius="@dimen/slider_thumb_radius"
app:trackColorActive="@color/md_white_1000" app:trackColorActive="@color/md_white_1000"
app:trackColorInactive="@color/md_white_semi_transparent" app:trackColorInactive="@color/md_white_semi_transparent"
app:trackHeight="3dp" app:trackHeight="@dimen/slider_track_height" />
tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20"
tools:valueFrom="0.0"
tools:valueTo="11.0" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView
android:id="@+id/songTotalTime" android:id="@+id/songTotalTime"

View file

@ -61,11 +61,13 @@
android:paddingStart="20dp" android:paddingStart="20dp"
android:paddingEnd="20dp" android:paddingEnd="20dp"
app:haloColor="@color/md_white_semi_transparent" app:haloColor="@color/md_white_semi_transparent"
app:haloRadius="0dp"
app:labelBehavior="gone" app:labelBehavior="gone"
app:thumbColor="@color/md_white_1000" app:thumbColor="@color/md_white_1000"
app:thumbRadius="@dimen/slider_thumb_radius"
app:trackColorActive="@color/md_white_1000" app:trackColorActive="@color/md_white_1000"
app:trackColorInactive="@color/md_white_semi_transparent" app:trackColorInactive="@color/md_white_semi_transparent"
app:trackHeight="2dp" app:trackHeight="@dimen/slider_track_height"
tools:progress="20" /> tools:progress="20" />
<com.google.android.material.textview.MaterialTextView <com.google.android.material.textview.MaterialTextView

View file

@ -32,7 +32,8 @@
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:trackHeight="3dp" app:thumbRadius="@dimen/slider_thumb_radius"
app:trackHeight="@dimen/slider_track_height"
tools:ignore="RtlHardcoded,UnusedAttribute" tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20" /> tools:progress="20" />

View file

@ -35,8 +35,7 @@
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:thumbRadius="8dp" app:trackHeight="@dimen/slider_track_height"
app:trackHeight="3dp"
tools:ignore="RtlHardcoded,UnusedAttribute" tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20" /> tools:progress="20" />

View file

@ -88,15 +88,16 @@
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginTop="16dp" android:layout_marginTop="16dp"
app:haloColor="@color/md_white_semi_transparent" app:haloRadius="0dp"
app:labelBehavior="gone" app:labelBehavior="gone"
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toBottomOf="@id/text" app:layout_constraintTop_toBottomOf="@id/text"
app:thumbColor="@color/md_white_1000" app:thumbColor="@color/md_white_1000"
app:thumbRadius="@dimen/slider_thumb_radius"
app:trackColorActive="@color/md_white_1000" app:trackColorActive="@color/md_white_1000"
app:trackColorInactive="@color/md_white_semi_transparent" app:trackColorInactive="@color/md_white_semi_transparent"
app:trackHeight="3dp" app:trackHeight="@dimen/slider_track_height"
tools:ignore="RtlHardcoded,UnusedAttribute" tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20" /> tools:progress="20" />

View file

@ -25,19 +25,15 @@
tools:ignore="RtlHardcoded,RtlSymmetry" tools:ignore="RtlHardcoded,RtlSymmetry"
tools:text="00:22" /> tools:text="00:22" />
<androidx.appcompat.widget.AppCompatSeekBar <com.google.android.material.slider.Slider
android:id="@+id/progressSlider" android:id="@+id/progressSlider"
style="@style/Widget.MaterialProgressBar.ProgressBar.Horizontal"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_weight="8"
android:maxHeight="3dp"
android:progressDrawable="@drawable/color_progress_seek"
android:splitTrack="false"
android:thumb="@drawable/switch_thumb_material"
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:thumbRadius="@dimen/slider_thumb_radius"
app:trackHeight="@dimen/slider_track_height"
tools:ignore="RtlHardcoded,UnusedAttribute" tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20" /> tools:progress="20" />

View file

@ -33,7 +33,8 @@
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:trackHeight="3dp" app:thumbRadius="@dimen/slider_thumb_radius"
app:trackHeight="@dimen/slider_track_height"
tools:ignore="RtlHardcoded,UnusedAttribute" tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20" /> tools:progress="20" />

View file

@ -43,7 +43,8 @@
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:trackHeight="3dp" app:thumbRadius="@dimen/slider_thumb_radius"
app:trackHeight="@dimen/slider_track_height"
tools:ignore="RtlHardcoded,UnusedAttribute" tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20" /> tools:progress="20" />

View file

@ -31,6 +31,7 @@
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:thumbRadius="@dimen/slider_thumb_radius"
app:trackHeight="3dp" app:trackHeight="3dp"
tools:ignore="RtlHardcoded,UnusedAttribute" tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20" /> tools:progress="20" />

View file

@ -32,7 +32,8 @@
app:layout_constraintEnd_toStartOf="@id/songTotalTime" app:layout_constraintEnd_toStartOf="@id/songTotalTime"
app:layout_constraintStart_toEndOf="@id/songCurrentProgress" app:layout_constraintStart_toEndOf="@id/songCurrentProgress"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
app:trackHeight="3dp" app:thumbRadius="@dimen/slider_thumb_radius"
app:trackHeight="@dimen/slider_track_height"
tools:ignore="RtlHardcoded,UnusedAttribute" tools:ignore="RtlHardcoded,UnusedAttribute"
tools:progress="20" /> tools:progress="20" />

View file

@ -37,7 +37,7 @@
app:layout_constraintHorizontal_bias="0.5" app:layout_constraintHorizontal_bias="0.5"
app:layout_constraintStart_toEndOf="@+id/volumeDown" app:layout_constraintStart_toEndOf="@+id/volumeDown"
app:layout_constraintTop_toTopOf="@+id/volumeDown" app:layout_constraintTop_toTopOf="@+id/volumeDown"
app:thumbRadius="8dp" app:thumbRadius="@dimen/slider_thumb_radius"
app:trackHeight="2dp" /> app:trackHeight="2dp" />
<androidx.appcompat.widget.AppCompatImageView <androidx.appcompat.widget.AppCompatImageView

View file

@ -50,4 +50,6 @@
<dimen name="bottom_sheet_peek_2_height">32dp</dimen> <dimen name="bottom_sheet_peek_2_height">32dp</dimen>
<dimen name="list_pref_guideline_begin">56dp</dimen> <dimen name="list_pref_guideline_begin">56dp</dimen>
<dimen name="pref_title_padding">72dp</dimen> <dimen name="pref_title_padding">72dp</dimen>
<dimen name="slider_thumb_radius">6dp</dimen>
<dimen name="slider_track_height">3dp</dimen>
</resources> </resources>

View file

@ -198,4 +198,11 @@
<item name="cornerFamily">rounded</item> <item name="cornerFamily">rounded</item>
<item name="cornerSize">78dp</item> <item name="cornerSize">78dp</item>
</style> </style>
<style name="RetroSliderTooltip" parent="Widget.MaterialComponents.Tooltip">
<item name="backgroundColor">@color/md_white_1000</item>
<item name="background">@color/md_white_1000</item>
<item name="android:background">@color/md_white_1000</item>
<item name="android:textColor">@color/md_red_400</item>
</style>
</resources> </resources>

View file

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<font-family xmlns:android="http://schemas.android.com/apk/res/android">
</font-family>

Binary file not shown.

After

Width:  |  Height:  |  Size: 3 MiB