Skip to content

Commit

Permalink
修复播放队列与实际不一致;优化歌词字体颜色
Browse files Browse the repository at this point in the history
  • Loading branch information
rRemix committed Feb 20, 2019
1 parent 3013a4e commit 90d5563
Show file tree
Hide file tree
Showing 5 changed files with 28 additions and 84 deletions.
8 changes: 4 additions & 4 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ android {
applicationId "remix.myplayer"
minSdkVersion 17
targetSdkVersion 26
versionCode 1500
versionName "1.5.0.0"
versionCode 1501
versionName "1.5.0.1-debug"

flavorDimensions "default"
vectorDrawables.useSupportLibrary = true
ndk {
abiFilters 'armeabi-v7a'
// abiFilters 'armeabi-v7a', 'x86'
// abiFilters 'armeabi-v7a'
abiFilters 'armeabi-v7a', 'x86'
}
externalNativeBuild {
cmake {
Expand Down
81 changes: 15 additions & 66 deletions app/src/main/java/remix/myplayer/appwidgets/AppWidgetSkin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,18 @@ package remix.myplayer.appwidgets

import android.support.annotation.ColorInt
import android.support.annotation.DrawableRes

import remix.myplayer.App
import remix.myplayer.R
import remix.myplayer.service.MusicService
import remix.myplayer.util.ColorUtil
import remix.myplayer.util.Constants
import remix.myplayer.util.SPUtil

enum class AppWidgetSkin private constructor(@param:ColorInt var titleColor: Int, @param:ColorInt var artistColor: Int,
@param:ColorInt var progressColor: Int, @param:ColorInt var btnColor: Int, @param:DrawableRes var background: Int,
@param:DrawableRes
// public Bitmap getTimerBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),mTimerRes);
// }
//
// public Bitmap getNextBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),mNextRes);
// }
//
// public Bitmap getPrevBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),mPrevRes);
// }
//
// public Bitmap getLoveBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),mLoveRes);
// }
//
// public Bitmap getModeBitmap(){
// return MusicService.getPlayModel() == Constants.PLAY_LOOP ? getModeNormalBitmap() :
// MusicService.getPlayModel() == Constants.PLAY_REPEATONE ? getModeRepeatBitmap() : getModeShuffleBitmap();
// }
//
// private Bitmap getModeRepeatBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),mModeRepeatRes);
// }
//
// private Bitmap getModeNormalBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),mModeNormalRes);
// }
//
// private Bitmap getModeShuffleBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),mModeShuffleRes);
// }
//
// public Bitmap getPlayPauseBitmap(){
// return MusicService.isPlaying() ? getPauseBitmap() : getPlayBitmap();
// }
//
// private Bitmap getPlayBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),mPlayRes);
// }
//
// private Bitmap getPauseBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),mPauseRes);
// }
//
// public Bitmap getLovedBitmap(){
// return BitmapFactory.decodeResource(App.getContext().getResources(),R.drawable.widget_btn_like_prs);
// }

val timerRes: Int, @param:DrawableRes val nextRes: Int, @param:DrawableRes val prevRes: Int,
@param:DrawableRes val loveRes: Int, @param:DrawableRes val modeRepeatRes: Int, @param:DrawableRes val modeNormalRes: Int, @param:DrawableRes val modeShuffleRes: Int,
@param:DrawableRes val playRes: Int, @param:DrawableRes val pauseRes: Int) {
enum class AppWidgetSkin(@param:ColorInt var titleColor: Int, @param:ColorInt var artistColor: Int,
@param:ColorInt var progressColor: Int, @param:ColorInt var btnColor: Int,
@param:DrawableRes var background: Int, @param:DrawableRes val timerRes: Int,
@param:DrawableRes val nextRes: Int, @param:DrawableRes val prevRes: Int,
@param:DrawableRes val loveRes: Int, @param:DrawableRes val modeRepeatRes: Int,
@param:DrawableRes val modeNormalRes: Int, @param:DrawableRes val modeShuffleRes: Int,
@param:DrawableRes val playRes: Int, @param:DrawableRes val pauseRes: Int) {
WHITE_1F(ColorUtil.getColor(R.color.appwidget_title_color_white_1f),
ColorUtil.getColor(R.color.appwidget_artist_color_white_1f),
ColorUtil.getColor(R.color.appwidget_progress_color_white_1f),
Expand All @@ -86,13 +36,12 @@ enum class AppWidgetSkin private constructor(@param:ColorInt var titleColor: Int
val lovedRes: Int
get() = R.drawable.widget_btn_like_prs

val modeRes: Int
get() {
val playModel = SPUtil.getValue(App.getContext(), SPUtil.SETTING_KEY.NAME, SPUtil.SETTING_KEY.PLAY_MODEL, Constants.PLAY_LOOP)
return when (playModel) {
Constants.PLAY_SHUFFLE -> modeShuffleRes
Constants.PLAY_REPEAT -> modeRepeatRes
else -> modeNormalRes
}
fun getModeRes(service: MusicService): Int {
val playModel = service.playModel
return when (playModel) {
Constants.PLAY_SHUFFLE -> modeShuffleRes
Constants.PLAY_REPEAT -> modeRepeatRes
else -> modeNormalRes
}
}
}
6 changes: 3 additions & 3 deletions app/src/main/java/remix/myplayer/appwidgets/BaseAppwidget.kt
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ abstract class BaseAppwidget
// updateSkin(remoteViews);
updatePlayPause(service, remoteViews)
updateLove(service,remoteViews, song)
updateModel(remoteViews)
updateModel(service,remoteViews)
updateNextAndPrev(remoteViews)
updateProgress(service, remoteViews, song)
updateTimer(remoteViews)
Expand All @@ -174,9 +174,9 @@ abstract class BaseAppwidget
remoteViews.setImageViewResource(R.id.appwidget_prev, skin.prevRes)
}

private fun updateModel(remoteViews: RemoteViews) {
private fun updateModel(service: MusicService,remoteViews: RemoteViews) {
//播放模式
remoteViews.setImageViewResource(R.id.appwidget_model, skin.modeRes)
remoteViews.setImageViewResource(R.id.appwidget_model, skin.getModeRes(service))
}

private fun updatePlayPause(service: MusicService, remoteViews: RemoteViews) {
Expand Down
15 changes: 5 additions & 10 deletions app/src/main/java/remix/myplayer/service/MusicService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -116,18 +116,13 @@ class MusicService : BaseService(), Playback, MusicEventCallback {
/**
* 设置播放模式并更新下一首歌曲
*/
//保存正在播放和下一首歌曲
var playModel: Int = PLAY_LOOP
set(newPlayModel) {
if (newPlayModel == field) {
return
}
updateAppwidget()
desktopWidgetTask?.run()
SPUtil.putValue(this, SPUtil.SETTING_KEY.NAME, SPUtil.SETTING_KEY.PLAY_MODEL, newPlayModel)
SPUtil.putValue(this, SPUtil.SETTING_KEY.NAME, SPUtil.SETTING_KEY.NEXT_SONG_ID, nextId)
SPUtil.putValue(this, SPUtil.SETTING_KEY.NAME, SPUtil.SETTING_KEY.LAST_SONG_ID, currentId)
if (playModel == PLAY_SHUFFLE) {
randomQueue.clear()
if (newPlayModel == PLAY_SHUFFLE) {
makeShuffleList(currentId)
}
field = newPlayModel
Expand Down Expand Up @@ -1601,8 +1596,7 @@ class MusicService : BaseService(), Playback, MusicEventCallback {
super.onError(e)
}
})
//默认全部歌曲为播放列表
playQueue.addAll(allSong)

//通知栏样式
SPUtil.putValue(this, SPUtil.SETTING_KEY.NAME, SPUtil.SETTING_KEY.NOTIFY_STYLE_CLASSIC,
Build.VERSION.SDK_INT < Build.VERSION_CODES.N)
Expand All @@ -1618,7 +1612,8 @@ class MusicService : BaseService(), Playback, MusicEventCallback {
}

if (playQueue.isEmpty()) {
playQueue.addAll(allSong)
//默认全部歌曲为播放列表
setPlayQueue(allSong)
}

//摇一摇
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/remix/myplayer/theme/ThemeStore.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ public static int getTextColorPrimaryReverse() {
@ColorInt
public static int getTextColorSecondary() {
return ColorUtil.getColor(
isLightTheme() ? R.color.light_text_color_primary : R.color.dark_text_color_primary);
isLightTheme() ? R.color.light_text_color_secondary : R.color.dark_text_color_secondary);
}

@ColorInt
Expand Down

0 comments on commit 90d5563

Please sign in to comment.