Skip to content

Commit

Permalink
Minor refactoring/bump to 4.3.6
Browse files Browse the repository at this point in the history
Signed-off-by: enricocid <enrico2588@gmail.com>
  • Loading branch information
enricocid committed Dec 15, 2020
1 parent 1d0d042 commit 43bd31d
Show file tree
Hide file tree
Showing 24 changed files with 281 additions and 274 deletions.
4 changes: 1 addition & 3 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ If you think you should be listed, don't hesitate to notify me! :)

- [**TacoTheDank**](https://github.com/TacoTheDank) for upgrades to gradle, java 1.8, translations and improvements [247](https://github.com/enricocid/Music-Player-GO/issues/247), [248](https://github.com/enricocid/Music-Player-GO/pull/248)

- [**bullhead**](https://github.com/bullheadandplato) for its equalizer implementation: I learned so much about how an equalizer works
- [**bullhead**](https://github.com/bullheadandplato) for dialog titles blinking cursor [fixes (https://github.com/enricocid/Music-Player-GO/pull/121) and its equalizer implementation: I learned so much about how an equalizer works

- [**svgrepo.com**](https://www.svgrepo.com/) for the [compact disc](https://www.svgrepo.com/svg/181020/compact-disc-music) icon, opportunely modified (background color).
This work is licensed under a [CC 0](https://creativecommons.org/share-your-work/public-domain/cc0/) license
Expand All @@ -32,8 +32,6 @@ This work is licensed under a [CC 0](https://creativecommons.org/share-your-work

- [**Johnett Mathew**](https://github.com/Johnett) for these [fixes](https://github.com/enricocid/Music-Player-GO/pull/149)

- [**bullhead**](https://github.com/bullheadandplato) for dialog titles blinking cursor [fixes](https://github.com/enricocid/Music-Player-GO/pull/121)

- [**Ricardo**](https://github.com/RickyM7) for [multiple reports](https://github.com/enricocid/Music-Player-GO/issues/220)

- [**seventhsonmizo**](https://github.com/seventhsonmizo) for Android Q [issue](https://github.com/enricocid/Music-Player-GO/issues/110) report and debugging
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Latest Release -->
<a href="https://github.com/enricocid/Music-Player-GO/releases">
<img alt="GitHub release"
src="https://img.shields.io/static/v1?label=Tag&message=v4.3.5&color=58F5D1">
src="https://img.shields.io/static/v1?label=Tag&message=v4.3.6&color=58F5D1">
</a>
<!-- Minimum SDK -->
<a>
Expand Down
4 changes: 4 additions & 0 deletions fastlane/metadata/android/en-US/changelogs/158.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Fix crash on boot while initializing the equalizer
- Fix crash due to embedded covers option
- Added a floating button on "all music" tab to shuffle songs
- Code improvements (thanks TacoTheDank)
5 changes: 5 additions & 0 deletions fastlane/metadata/android/it/changelogs/158.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
- Corretto un crash all'apertura della app che si verificava alla scorretta
inizializzazione dell'equalizzatore
- Corretto un crash dovuto all'opzione delle copertine
- Aggiunto un pulsante flottante nella tab delle canzoni per mescolarle
- Miglioramenti codice (grazie TacoTheDank)
4 changes: 2 additions & 2 deletions project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.iven.musicplayergo"
minSdkVersion 21
targetSdkVersion 30
versionCode 157
versionName "4.3.5"
versionCode 158
versionName "4.3.6"

vectorDrawables.useSupportLibrary true
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ImageButton
import androidx.core.content.ContextCompat
import androidx.recyclerview.widget.RecyclerView
import com.iven.musicplayergo.R
import com.iven.musicplayergo.extensions.decodeColor
import com.iven.musicplayergo.extensions.handleViewVisibility
import com.iven.musicplayergo.goPreferences
import com.iven.musicplayergo.helpers.ThemeHelper
Expand Down Expand Up @@ -41,7 +41,7 @@ class AccentsAdapter(private val activity: Activity) :
itemView.run {

val circle = findViewById<ImageButton>(R.id.circle)
val accent = color.decodeColor(activity)
val accent = ContextCompat.getColor(activity, color)
ThemeHelper.updateIconTint(circle, accent)
ThemeHelper.createColouredRipple(activity, accent, R.drawable.ripple_oval).apply {
itemView.background = this
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.text.parseAsHtml
import androidx.recyclerview.widget.RecyclerView
import com.afollestad.materialdialogs.MaterialDialog
import com.iven.musicplayergo.R
import com.iven.musicplayergo.extensions.toFormattedDuration
import com.iven.musicplayergo.extensions.toSpanned
import com.iven.musicplayergo.goPreferences
import com.iven.musicplayergo.helpers.DialogHelper
import com.iven.musicplayergo.models.Music
Expand Down Expand Up @@ -69,7 +69,7 @@ class LovedSongsAdapter(
isSeekBar = false
),
lovedSong?.duration?.toFormattedDuration(isAlbum = false, isSeekBar = false)
).toSpanned()
).parseAsHtml()
subtitle.text =
ctx.getString(R.string.artist_and_album, lovedSong?.artist, lovedSong?.album)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.core.text.parseAsHtml
import androidx.recyclerview.widget.RecyclerView
import com.afollestad.materialdialogs.MaterialDialog
import com.iven.musicplayergo.R
import com.iven.musicplayergo.extensions.startSongFromQueue
import com.iven.musicplayergo.extensions.toFormattedDuration
import com.iven.musicplayergo.extensions.toSpanned
import com.iven.musicplayergo.helpers.DialogHelper
import com.iven.musicplayergo.helpers.ThemeHelper
import com.iven.musicplayergo.models.Music
Expand Down Expand Up @@ -85,7 +85,7 @@ class QueueAdapter(
isSeekBar = false
),
song.duration.toFormattedDuration(isAlbum = false, isSeekBar = false)
).toSpanned()
).parseAsHtml()

subtitle.text =
context.getString(R.string.artist_and_album, song.artist, song.album)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,17 @@ fun MediaPlayerHolder.startSongFromQueue(song: Music?, launchedBy: String) {
mediaPlayerInterface.onQueueStartedOrEnded(true)
}
setCurrentSong(
song,
queueSongs,
isFromQueue = true,
launchedBy
song,
queueSongs,
isFromQueue = true,
launchedBy
)
initMediaPlayer(song)
}

fun Long.toContentUri(): Uri = ContentUris.withAppendedId(
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
this
MediaStore.Audio.Media.EXTERNAL_CONTENT_URI,
this
)

fun Uri.toBitrate(context: Context): Pair<Int, Int>? {
Expand Down Expand Up @@ -70,7 +70,7 @@ fun Music.getCover(context: Context): Bitmap? {

if (picture != null) {
BitmapFactory
.decodeByteArray(picture, 0, picture.size)
.decodeByteArray(picture, 0, picture.size)
} else {
null
}
Expand All @@ -96,23 +96,23 @@ fun Long.toFormattedDuration(isAlbum: Boolean, isSeekBar: Boolean) = try {

if (minutes < 60) {
String.format(
Locale.getDefault(), defaultFormat,
minutes,
seconds - TimeUnit.MINUTES.toSeconds(minutes)
Locale.getDefault(), defaultFormat,
minutes,
seconds - TimeUnit.MINUTES.toSeconds(minutes)
)
} else {
// https://stackoverflow.com/a/9027379
when {
isSeekBar -> String.format(
"%02d:%02d:%02d",
hours,
minutes - TimeUnit.HOURS.toMinutes(hours),
seconds - TimeUnit.MINUTES.toSeconds(minutes)
"%02d:%02d:%02d",
hours,
minutes - TimeUnit.HOURS.toMinutes(hours),
seconds - TimeUnit.MINUTES.toSeconds(minutes)
)
else -> String.format(
"%02dh:%02dm",
hours,
minutes - TimeUnit.HOURS.toMinutes(hours)
"%02dh:%02dm",
hours,
minutes - TimeUnit.HOURS.toMinutes(hours)
)
}
}
Expand All @@ -134,23 +134,23 @@ fun Int.toFormattedTrack() = try {
}

fun Int.toFormattedYear(resources: Resources) =
if (this != 0) {
toString()
} else {
resources.getString(R.string.unknown_year)
}
if (this != 0) {
toString()
} else {
resources.getString(R.string.unknown_year)
}

fun Music.toSavedMusic(playerPosition: Int, savedLaunchedBy: String) =
Music(
artist,
year,
track,
title,
displayName,
duration,
album,
relativePath,
id,
savedLaunchedBy,
playerPosition
)
Music(
artist,
year,
track,
title,
displayName,
duration,
album,
relativePath,
id,
savedLaunchedBy,
playerPosition
)
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,15 @@ import android.annotation.SuppressLint
import android.content.Context
import android.graphics.Bitmap
import android.text.SpannableString
import android.text.Spanned
import android.text.style.ForegroundColorSpan
import android.view.MenuItem
import android.view.View
import android.view.ViewAnimationUtils
import android.view.ViewTreeObserver
import android.widget.ImageView
import android.widget.Toast
import androidx.annotation.ColorInt
import androidx.core.animation.doOnEnd
import androidx.core.content.ContextCompat
import androidx.core.text.parseAsHtml
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.commit
Expand Down Expand Up @@ -120,11 +117,6 @@ fun ImageView.loadCover(
}
}

@ColorInt
fun Int.decodeColor(context: Context) = ContextCompat.getColor(context, this)

fun String.toSpanned(): Spanned = this.parseAsHtml()

// Extension to set menu items text color
fun MenuItem.setTitleColor(color: Int) {
SpannableString(title).apply {
Expand Down Expand Up @@ -203,7 +195,7 @@ fun View.createCircularReveal(isErrorFragment: Boolean, show: Boolean): Animator
start()
}

val windowBackground = R.color.windowBackground.decodeColor(context)
val windowBackground = ContextCompat.getColor(context, R.color.windowBackground)
val closeColor = ThemeHelper.resolveColorAttr(context, R.attr.colorControlHighlight)
val accent = if (!show) {
windowBackground
Expand All @@ -212,7 +204,7 @@ fun View.createCircularReveal(isErrorFragment: Boolean, show: Boolean): Animator
}

val startColor = if (isErrorFragment) {
R.color.red.decodeColor(context)
ContextCompat.getColor(context, R.color.red)
} else {
accent
}
Expand All @@ -232,7 +224,7 @@ fun View.createCircularReveal(isErrorFragment: Boolean, show: Boolean): Animator
background =
ThemeHelper.createColouredRipple(
context,
R.color.red.decodeColor(context),
ContextCompat.getColor(context, R.color.red),
R.drawable.ripple
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,17 +136,24 @@ class AllMusicFragment : Fragment(R.layout.fragment_all_music), SearchView.OnQue

setupIndicatorFastScrollerView()

val fabRotateAnimator = getRotateAnimatorForFab()

mAllMusicFragmentBinding.shuffleFab.setOnClickListener {
fabRotateAnimator.doOnEnd {
mUIControlInterface.onShuffleSongs(
null,
null,
mAllMusic,
mAllMusic?.size!! < 30,
GoConstants.ARTIST_VIEW
)
ObjectAnimator.ofFloat(
it,
View.ROTATION,
0f,
360f
).apply {
duration = 750
start()
doOnEnd {
mUIControlInterface.onShuffleSongs(
null,
null,
mAllMusic,
mAllMusic?.size!! < 30,
GoConstants.ARTIST_VIEW
)
}
}
}

Expand Down Expand Up @@ -184,7 +191,7 @@ class AllMusicFragment : Fragment(R.layout.fragment_all_music), SearchView.OnQue
}
}

setMenuOnItemClickListener(requireActivity(), this)
setMenuOnItemClickListener(this)
}
}
}
Expand Down Expand Up @@ -259,22 +266,12 @@ class AllMusicFragment : Fragment(R.layout.fragment_all_music), SearchView.OnQue
mAllMusicFragmentBinding.allMusicRv.setPadding(0, 0, rvPaddingEnd, 0)
}

private fun getRotateAnimatorForFab() = ObjectAnimator.ofFloat(
mAllMusicFragmentBinding.shuffleFab,
View.ROTATION,
0f,
360f
).apply {
duration = 750
start()
}

private fun handleIndicatorFastScrollerViewVisibility() {
mAllMusicFragmentBinding.fastscroller.handleViewVisibility(sIsFastScrollerVisible)
mAllMusicFragmentBinding.fastscrollerThumb.handleViewVisibility(sIsFastScrollerVisible)
}

private fun setMenuOnItemClickListener(context: Context, menu: Menu) {
private fun setMenuOnItemClickListener(menu: Menu) {

mAllMusicFragmentBinding.searchToolbar.setOnMenuItemClickListener {

Expand All @@ -293,7 +290,7 @@ class AllMusicFragment : Fragment(R.layout.fragment_all_music), SearchView.OnQue

mSortMenuItem.setTitleColor(
ThemeHelper.resolveColorAttr(
context,
requireActivity(),
android.R.attr.textColorPrimary
)
)
Expand Down
Loading

0 comments on commit 43bd31d

Please sign in to comment.