[Now Playing: Circle] Replaced SeekArc with Circular Seekbar

[Now Playing: Circle] Replaced SeekArc with Circular Seekbar
This commit is contained in:
Prathamesh More 2021-12-14 22:48:48 +05:30
parent 87eb3c08c3
commit 268e077ab5
7 changed files with 91 additions and 90 deletions

View file

@ -160,5 +160,6 @@ dependencies {
implementation 'com.github.dhaval2404:imagepicker:2.1'
implementation 'me.zhanghai.android.fastscroll:library:1.1.7'
implementation 'cat.ereza:customactivityoncrash:2.3.0'
implementation 'me.tankery.lib:circularSeekBar:1.3.2'
debugImplementation 'com.github.amitshekhariitbhu:Android-Debug-Database:1.0.6'
}

View file

@ -1,4 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<bool name="md3_available">true</bool>
<bool name="allowBackup">false</bool>
</resources>

View file

@ -22,7 +22,7 @@
<application
android:name=".App"
android:allowBackup="true"
android:allowBackup="@bool/allowBackup"
android:configChanges="locale|layoutDirection"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"

View file

@ -18,6 +18,7 @@ import android.animation.ObjectAnimator
import android.content.Context
import android.graphics.Color
import android.graphics.PorterDuff
import android.graphics.drawable.ColorDrawable
import android.media.AudioManager
import android.os.Bundle
import android.view.LayoutInflater
@ -28,10 +29,7 @@ import android.view.animation.LinearInterpolator
import android.widget.SeekBar
import androidx.appcompat.widget.Toolbar
import code.name.monkey.appthemehelper.ThemeStore
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.ToolbarContentTintHelper
import code.name.monkey.appthemehelper.util.*
import code.name.monkey.retromusic.R
import code.name.monkey.retromusic.databinding.FragmentCirclePlayerBinding
import code.name.monkey.retromusic.extensions.*
@ -50,10 +48,9 @@ import code.name.monkey.retromusic.util.MusicUtil
import code.name.monkey.retromusic.util.PreferenceUtil
import code.name.monkey.retromusic.util.ViewUtil
import code.name.monkey.retromusic.util.color.MediaNotificationProcessor
import code.name.monkey.retromusic.views.SeekArc
import code.name.monkey.retromusic.views.SeekArc.OnSeekArcChangeListener
import code.name.monkey.retromusic.volume.AudioVolumeObserver
import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener
import me.tankery.lib.circularseekbar.CircularSeekBar
/**
* Created by hemanths on 2020-01-06.
@ -61,7 +58,7 @@ import code.name.monkey.retromusic.volume.OnAudioVolumeChangedListener
class CirclePlayerFragment : AbsPlayerFragment(R.layout.fragment_circle_player), Callback,
OnAudioVolumeChangedListener,
OnSeekArcChangeListener {
CircularSeekBar.OnCircularSeekBarChangeListener {
private lateinit var progressViewUpdateHelper: MusicProgressViewUpdateHelper
private var audioVolumeObserver: AudioVolumeObserver? = null
@ -121,11 +118,17 @@ class CirclePlayerFragment : AbsPlayerFragment(R.layout.fragment_circle_player),
ThemeStore.accentColor(requireContext()),
false
)
binding.volumeSeekBar.progressColor = accentColor()
binding.volumeSeekBar.arcColor = ColorUtil.withAlpha(accentColor(), 0.25f)
binding.volumeSeekBar.circleProgressColor = accentColor()
binding.volumeSeekBar.circleColor = ColorUtil.withAlpha(accentColor(), 0.25f)
setUpPlayPauseFab()
setUpPrevNext()
setUpPlayerToolbar()
binding.albumCoverOverlay.background = ColorDrawable(
MaterialValueHelper.getPrimaryTextColor(
requireContext(),
accentColor().isColorLight
)
)
}
private fun setUpPrevNext() {
@ -169,9 +172,11 @@ class CirclePlayerFragment : AbsPlayerFragment(R.layout.fragment_circle_player),
audioVolumeObserver?.register(AudioManager.STREAM_MUSIC, this)
val audioManager = audioManager
binding.volumeSeekBar.max = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC)
binding.volumeSeekBar.progress = audioManager.getStreamVolume(AudioManager.STREAM_MUSIC)
binding.volumeSeekBar.setOnSeekArcChangeListener(this)
binding.volumeSeekBar.max =
audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC).toFloat()
binding.volumeSeekBar.progress =
audioManager.getStreamVolume(AudioManager.STREAM_MUSIC).toFloat()
binding.volumeSeekBar.setOnSeekBarChangeListener(this)
}
override fun onPause() {
@ -249,8 +254,8 @@ class CirclePlayerFragment : AbsPlayerFragment(R.layout.fragment_circle_player),
}
override fun onAudioVolumeChanged(currentVolume: Int, maxVolume: Int) {
_binding?.volumeSeekBar?.max = maxVolume
_binding?.volumeSeekBar?.progress = currentVolume
_binding?.volumeSeekBar?.max = maxVolume.toFloat()
_binding?.volumeSeekBar?.progress = currentVolume.toFloat()
}
override fun onDestroyView() {
@ -261,15 +266,16 @@ class CirclePlayerFragment : AbsPlayerFragment(R.layout.fragment_circle_player),
_binding = null
}
override fun onProgressChanged(seekArc: SeekArc?, progress: Int, fromUser: Boolean) {
override fun onProgressChanged(seekBar: CircularSeekBar?, progress: Float, fromUser: Boolean) {
val audioManager = audioManager
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress, 0)
audioManager.setStreamVolume(AudioManager.STREAM_MUSIC, progress.toInt(), 0)
}
override fun onStartTrackingTouch(seekArc: SeekArc?) {
override fun onStartTrackingTouch(seekBar: CircularSeekBar?) {
}
override fun onStopTrackingTouch(seekArc: SeekArc?) {
override fun onStopTrackingTouch(seekBar: CircularSeekBar?) {
}
fun setUpProgressSlider() {

View file

@ -54,54 +54,46 @@
app:navigationIcon="@drawable/ic_keyboard_arrow_down_black"
tools:layout_editor_absoluteY="24dp" />
<code.name.monkey.retromusic.views.RetroShapeableImageView
android:id="@+id/album_cover"
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="28dp"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="@id/volumeSeekBar"
app:layout_constraintEnd_toEndOf="@id/volumeSeekBar"
app:layout_constraintStart_toStartOf="@id/volumeSeekBar"
app:layout_constraintTop_toTopOf="@id/volumeSeekBar">
<code.name.monkey.retromusic.views.RetroShapeableImageView
android:id="@+id/album_cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="@id/guideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/playerToolbar"
tools:srcCompat="@tools:sample/backgrounds/scenic[6]" />
<code.name.monkey.retromusic.views.RetroShapeableImageView
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_margin="28dp"
android:id="@+id/album_cover_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:background="?colorSurface"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="@id/guideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/playerToolbar" />
android:scaleType="centerCrop" />
</FrameLayout>
<code.name.monkey.retromusic.views.SeekArc
<me.tankery.lib.circularseekbar.CircularSeekBar
android:id="@+id/volumeSeekBar"
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
android:padding="24dp"
app:arcColor="?android:attr/colorControlHighlight"
app:arcWidth="4dp"
android:layout_width="wrap_content"
android:layout_height="300dp"
app:cs_circle_stroke_width="4dp"
app:cs_end_angle="60"
app:cs_move_outside_circle="true"
app:cs_pointer_color="@color/md_grey_200"
app:cs_pointer_halo_width="0dp"
app:cs_pointer_stroke_width="20dp"
app:cs_start_angle="120"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintDimensionRatio="1:1"
app:layout_constraintEnd_toEndOf="@id/guideline"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@id/playerToolbar"
app:progressWidth="4dp"
app:rotation="180"
app:roundEdges="true"
app:startAngle="30"
app:sweepAngle="300"
app:touchInside="false"
tools:progress="50" />
<com.google.android.material.floatingactionbutton.FloatingActionButton

View file

@ -81,45 +81,45 @@
app:layout_constraintTop_toBottomOf="@+id/titleContainer"
tools:text="@tools:sample/lorem/random" />
<FrameLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:padding="10dp"
app:layout_constraintBottom_toBottomOf="@id/volumeSeekBar"
app:layout_constraintEnd_toEndOf="@id/volumeSeekBar"
app:layout_constraintStart_toStartOf="@id/volumeSeekBar"
app:layout_constraintTop_toTopOf="@id/volumeSeekBar">
<code.name.monkey.retromusic.views.RetroShapeableImageView
android:id="@+id/album_cover"
android:layout_width="276dp"
android:layout_height="276dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/backgrounds/scenic[6]" />
<code.name.monkey.retromusic.views.RetroShapeableImageView
android:layout_width="276dp"
android:layout_height="276dp"
android:alpha="0.5"
android:background="?colorSurface"
android:scaleType="centerCrop"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<code.name.monkey.retromusic.views.SeekArc
android:id="@+id/volumeSeekBar"
android:id="@+id/album_cover_overlay"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:alpha="0.5"
android:scaleType="centerCrop" />
</FrameLayout>
<me.tankery.lib.circularseekbar.CircularSeekBar
android:id="@+id/volumeSeekBar"
android:layout_width="wrap_content"
android:layout_height="300dp"
android:padding="28dp"
app:arcColor="?android:attr/colorControlHighlight"
app:arcWidth="4dp"
app:cs_circle_stroke_width="4dp"
app:cs_end_angle="60"
app:cs_move_outside_circle="true"
app:cs_pointer_color="@color/md_grey_200"
app:cs_pointer_halo_width="0dp"
app:cs_pointer_stroke_width="20dp"
app:cs_start_angle="120"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:progressWidth="4dp"
app:rotation="180"
app:roundEdges="true"
app:startAngle="30"
app:sweepAngle="300"
app:touchInside="false"
tools:progress="50" />
<com.google.android.material.floatingactionbutton.FloatingActionButton
@ -165,7 +165,7 @@
android:textColor="?android:attr/textColorSecondary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="@+id/volumeSeekBar"
app:layout_constraintTop_toBottomOf="@+id/album_cover" />
app:layout_constraintTop_toBottomOf="@+id/volumeSeekBar" />
<androidx.appcompat.widget.AppCompatSeekBar

View file

@ -29,4 +29,5 @@
<bool name="colored_notification_available">true</bool>
<integer name="overScrollMode">2</integer>
<bool name="allowBackup">true</bool>
</resources>