Skip to content

Commit

Permalink
Fix code and bump
Browse files Browse the repository at this point in the history
Signed-off-by: enricocid <enrico2588@gmail.com>
  • Loading branch information
enricocid committed Dec 3, 2018
1 parent 3011284 commit 028a391
Show file tree
Hide file tree
Showing 14 changed files with 63 additions and 176 deletions.
2 changes: 2 additions & 0 deletions FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ This frequently asked questions will be continually updated to accommodate new i

It is a lightweight and ads free music player that plays music from local library. It has colorful, simple and 'unified' UI.

**What about features requests?**
Not all requests will be taken into consideration as the player mainly reflects my needs! If I add the label 'feature request' on a issue then it will be worked, but it may require time!

**Does Music Player GO uses equalizer?**

Expand Down
23 changes: 10 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

###### Very slim music player with low memory footprint!
###### Now available in Kotlin language
###### Current version: (96) 3.4.2
###### Current version: (97) 3.5
###### Material Design Icon by Julian Javier Gomez, Axinen Design (https://plus.google.com/u/0/+AxinenDesign)


Expand All @@ -18,7 +18,7 @@

# Screenshots

![Screenshots](https://raw.githubusercontent.com/enricocid/Music-Player-GO/master/screenshots_v3-4.png)
![Screenshots](https://raw.githubusercontent.com/enricocid/Music-Player-GO/master/screenshots_v3-5.png)


# Download
Expand All @@ -37,23 +37,23 @@ You can also get the app from **IzzyOnDroid** repository! To add this repo to Yo

- Colorful, simple and 'unified' UI: no need to navigate between screens;
- Awesome typeface: Raleway + Roboto condensed;
- Expandable bottom panel containing the player controls and the settings (if expanded):
- Played song info: clicking on it You can open the played Artist's page/album or open/close the Artist's page You're exploring (when not playing). The text is scrollable on long click;
- Skip to previous song (long click to enable reset 1x);
- Expandable bottom panel: player controls/settings:
- Played song info: a click opens the played Artist's page;
- Skip to previous song (long click enables 1x);
- Play/pause;
- Skip to next song;
- Music organized by Artist (the Artists names are scrollable on long click);
- 'Revealable' Artist's page: albums + songs (the selected album title and songs titles are scrollable on long click);
- Music organized by Artist;
- Revealable Artist's page: albums/songs;
- Colorful alphabetic scrollbar;
- Search bar (which can be disabled);
- Dark status bar icons (available from Android Marshmallow);

### Settings at hand:

- Dynamic shuffle button: randomly plays the device or the Artist songs (when the Artist's page is 'revealed');
- Dynamic shuffle button: randomly plays the device/Artist songs;
- System equalizer (if present on the device);
- Themes (light and inverted);
- Search bar visibility;
- Themes (light and inverted) toggle;
- Search bar visibility toggle;
- Link to git page;
- 16 awesome UI accents!;

Expand Down Expand Up @@ -96,9 +96,6 @@ You can also get the app from **IzzyOnDroid** repository! To add this repo to Yo

- **olayhemy** (ttps://github.com/olayhemy) for FAQ

- **Bruno Trovo** (@brunotrovo - https://github.com/brunotrovo) for part of the custom dialog:
https://medium.com/@brunotrovo/android-creating-custom-dialogs-201003052f1c

- **Prabhakar Thota** (@myinnos - https://github.com/myinnos) for part of the alphabetic index bar code:
https://github.com/myinnos/AlphabetIndex-Fast-Scroll-RecyclerView

Expand Down
4 changes: 2 additions & 2 deletions project/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ android {
applicationId "com.iven.musicplayergo"
minSdkVersion 21
targetSdkVersion 28
versionCode 96
versionName "3.4.2"
versionCode 97
versionName "3.5"
}
buildTypes {
release {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import android.os.Bundle
import android.view.View
import android.widget.Toast
import androidx.appcompat.app.AppCompatActivity
import androidx.core.content.ContextCompat
import androidx.fragment.app.FragmentManager
import androidx.fragment.app.FragmentTransaction
import com.iven.musicplayergo.uihelpers.PreferencesHelper
Expand Down
31 changes: 17 additions & 14 deletions project/app/src/main/java/com/iven/musicplayergo/MainFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,13 @@ class MainFragment : Fragment() {
mColorsRecyclerView.adapter = colorsAdapter

colorsAdapter.onColorClick = { accent ->
mMusicNotificationManager.accent = ContextCompat.getColor(mActivity, accent)
if (mMediaPlayerHolder.isMediaPlayer) {
mMusicNotificationManager.notificationManager.notify(
NOTIFICATION_ID,
mMusicNotificationManager.createNotification()
)
}
PreferencesHelper(mActivity).setThemeAccent(accent)
}
}
Expand Down Expand Up @@ -382,19 +389,15 @@ class MainFragment : Fragment() {
mArtistsDetailsDiscCount.text = getString(R.string.albums, MusicUtils.getArtistDiscsCount(notSortedArtistDiscs))

//set the albums list
if (!::mAlbumsAdapter.isInitialized) {
//one-time adapter initialization
mAlbumsRecyclerView.setHasFixedSize(true)
mAlbumsLayoutManager = LinearLayoutManager(mActivity, RecyclerView.HORIZONTAL, false)
mAlbumsRecyclerView.layoutManager = mAlbumsLayoutManager
mAlbumsAdapter = AlbumsAdapter(
mSelectedArtistAlbums,
ContextCompat.getColor(mActivity, mAccent!!)
)
mAlbumsRecyclerView.adapter = mAlbumsAdapter
} else {
mAlbumsAdapter.swapAlbums(mSelectedArtistAlbums)
}
//one-time adapter initialization
mAlbumsRecyclerView.setHasFixedSize(true)
mAlbumsLayoutManager = LinearLayoutManager(mActivity, RecyclerView.HORIZONTAL, false)
mAlbumsRecyclerView.layoutManager = mAlbumsLayoutManager
mAlbumsAdapter = AlbumsAdapter(
mSelectedArtistAlbums,
ContextCompat.getColor(mActivity, mAccent!!)
)
mAlbumsRecyclerView.adapter = mAlbumsAdapter

mAlbumsAdapter.onAlbumClick = { album ->
setAlbumSongs(album)
Expand Down Expand Up @@ -718,7 +721,7 @@ class MainFragment : Fragment() {
mMediaPlayerHolder = mPlayerService.mediaPlayerHolder!!
mMediaPlayerHolder.mainFragment = this@MainFragment
mMusicNotificationManager = mPlayerService.musicNotificationManager
mMusicNotificationManager.mAccent = ContextCompat.getColor(mActivity, mAccent!!)
mMusicNotificationManager.accent = ContextCompat.getColor(mActivity, mAccent!!)
loadMusic()
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,12 @@ import com.iven.musicplayergo.R
import com.iven.musicplayergo.music.Album
import kotlinx.android.synthetic.main.album_item.view.*

class AlbumsAdapter(albums: List<Album>, private val accent: Int) :
class AlbumsAdapter(private val albums: List<Album>, private val accent: Int) :
RecyclerView.Adapter<AlbumsAdapter.AlbumsHolder>() {

var onAlbumClick: ((String) -> Unit)? = null

private var mAlbums = albums
private var mSelectedAlbum: String? = null

private var mSelectedPosition = 0

init {
Expand All @@ -29,22 +27,17 @@ class AlbumsAdapter(albums: List<Album>, private val accent: Int) :
mSelectedPosition = newSelectedPosition
}

fun swapAlbums(albums: List<Album>) {
mAlbums = albums
notifyDataSetChanged()
}

override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): AlbumsHolder {
return AlbumsHolder(LayoutInflater.from(parent.context).inflate(R.layout.album_item, parent, false))
}

override fun getItemCount(): Int {
return mAlbums.size
return albums.size
}

override fun onBindViewHolder(holder: AlbumsHolder, position: Int) {
val title = mAlbums[holder.adapterPosition].title
val year = mAlbums[holder.adapterPosition].year
val title = albums[holder.adapterPosition].title
val year = albums[holder.adapterPosition].year
holder.bindItems(title, year)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.media.AudioFocusRequest
import android.media.AudioManager
import android.media.MediaPlayer
import android.os.Build
import android.os.Handler
import android.os.PowerManager
import com.iven.musicplayergo.MainActivity
import com.iven.musicplayergo.MainFragment
Expand Down Expand Up @@ -55,6 +56,7 @@ class MediaPlayerHolder(private val playerService: PlayerService) : MediaPlayer.
//audio focus
private var mAudioManager: AudioManager = playerService.getSystemService(AUDIO_SERVICE) as AudioManager
private lateinit var mAudioFocusRequestOreo: AudioFocusRequest
private val mHandler = Handler()

private var mCurrentAudioFocusState = AUDIO_NO_FOCUS_NO_DUCK
private var sPlayOnFocusGain: Boolean = false
Expand Down Expand Up @@ -168,16 +170,16 @@ class MediaPlayerHolder(private val playerService: PlayerService) : MediaPlayer.
}

private fun getAudioFocusResult(): Int {

return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
mAudioFocusRequestOreo = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN)
.setAudioAttributes(
AudioAttributes.Builder()
.setUsage(AudioAttributes.USAGE_MEDIA)
mAudioFocusRequestOreo = AudioFocusRequest.Builder(AudioManager.AUDIOFOCUS_GAIN).run {
setAudioAttributes(AudioAttributes.Builder().run {
setUsage(AudioAttributes.USAGE_MEDIA)
.setContentType(AudioAttributes.CONTENT_TYPE_MUSIC)
.build()
)
.build()
})
setOnAudioFocusChangeListener(mOnAudioFocusChangeListener, mHandler)
build()
}
mAudioManager.requestAudioFocus(mAudioFocusRequestOreo)
} else {
mAudioManager.requestAudioFocus(
Expand Down Expand Up @@ -378,22 +380,18 @@ class MediaPlayerHolder(private val playerService: PlayerService) : MediaPlayer.
*/
private fun configurePlayerState() {

if (mCurrentAudioFocusState == AUDIO_NO_FOCUS_NO_DUCK) {
// We don't have audio focus and can't duck, so we have to pause
pauseMediaPlayer()
} else {

if (mCurrentAudioFocusState == AUDIO_NO_FOCUS_CAN_DUCK) {
// We're permitted to play, but only if we 'duck', ie: play softly
mediaPlayer!!.setVolume(VOLUME_DUCK, VOLUME_DUCK)
} else {
mediaPlayer!!.setVolume(VOLUME_NORMAL, VOLUME_NORMAL)
}

// If we were playing when we lost focus, we need to resume playing.
if (sPlayOnFocusGain) {
resumeMediaPlayer()
sPlayOnFocusGain = false
when (mCurrentAudioFocusState) {
AUDIO_NO_FOCUS_NO_DUCK -> pauseMediaPlayer()
else -> {
when (mCurrentAudioFocusState) {
AUDIO_NO_FOCUS_CAN_DUCK -> mediaPlayer!!.setVolume(VOLUME_DUCK, VOLUME_DUCK)
else -> mediaPlayer!!.setVolume(VOLUME_NORMAL, VOLUME_NORMAL)
}
// If we were playing when we lost focus, we need to resume playing.
if (sPlayOnFocusGain) {
resumeMediaPlayer()
sPlayOnFocusGain = false
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import android.graphics.drawable.VectorDrawable
import android.os.Build
import androidx.annotation.RequiresApi
import androidx.core.app.NotificationCompat
import androidx.core.content.ContextCompat
import androidx.media.app.NotificationCompat.MediaStyle
import com.iven.musicplayergo.MainActivity
import com.iven.musicplayergo.PlayerService
Expand All @@ -36,7 +37,7 @@ class MusicNotificationManager(private val playerService: PlayerService) {
var notificationBuilder: NotificationCompat.Builder? = null

//accent
var mAccent: Int = R.color.blue
var accent: Int = R.color.blue

//https://gist.github.com/Gnzlt/6ddc846ef68c587d559f1e1fcd0900d3
private fun getLargeIcon(): Bitmap {
Expand All @@ -48,7 +49,7 @@ class MusicNotificationManager(private val playerService: PlayerService) {
val canvas = Canvas(bitmap)

vectorDrawable.setBounds(0, 0, canvas.width, canvas.height)
vectorDrawable.setTint(mAccent)
vectorDrawable.setTint(accent)
vectorDrawable.alpha = 150
vectorDrawable.draw(canvas)

Expand Down Expand Up @@ -89,7 +90,7 @@ class MusicNotificationManager(private val playerService: PlayerService) {
.setShowWhen(false)
.setSmallIcon(R.drawable.music_notification)
.setLargeIcon(getLargeIcon())
.setColor(mAccent)
.setColor(accent)
.setContentTitle(spanned)
.setContentText(song.album)
.setContentIntent(contentIntent)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ class PreferencesHelper(private val activity: Activity) {
fun getAccent(): Int {
accent = getPreference(TAG_ACCENT_PREF).getInt(
TAG_ACCENT_VALUE,
R.color.red
R.color.blue
)
return accent!!
}
Expand Down
34 changes: 0 additions & 34 deletions project/app/src/main/res/drawable-v24/ic_launcher_foreground.xml

This file was deleted.

Loading

0 comments on commit 028a391

Please sign in to comment.