Skip to content
This repository has been archived by the owner on Aug 23, 2024. It is now read-only.

Commit

Permalink
3.11.4
Browse files Browse the repository at this point in the history
修复 API 失效引起的拉取歌单 / 搜索失败的问题
当用户配置了网易云 API 时, 这些接口也会使用这个配置
优化横屏状态栏、导航栏显示区域适配
优化加载歌单失败提示语
  • Loading branch information
Moriafly committed Nov 18, 2021
1 parent 64fa057 commit 92af6e6
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 77 deletions.
1 change: 1 addition & 0 deletions .idea/dictionaries/24568.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
3.11.4 2021年11月18日
修复 API 失效引起的拉取歌单 / 搜索失败的问题
当用户配置了网易云 API 时, 这些接口也会使用这个配置
优化横屏状态栏、导航栏显示区域适配
优化加载歌单失败提示语

3.11.3 2021年11月13日
修复本地歌曲播放失败问题,感谢 kqwyf 的反馈
更新 Kotlin 版本至 1.5.31
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
applicationId "com.dirror.music"
minSdkVersion 21
targetSdkVersion 30
versionCode 750
versionName "3.11.3"
versionCode 751
versionName "3.11.4"

multiDexEnabled true

Expand Down
Binary file not shown.
4 changes: 2 additions & 2 deletions app/release/output-metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
{
"type": "SINGLE",
"filters": [],
"versionCode": 750,
"versionName": "3.11.3",
"versionCode": 751,
"versionName": "3.11.4",
"outputFile": "app-release.apk"
}
]
Expand Down
58 changes: 30 additions & 28 deletions app/src/main/java/com/dirror/music/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
* <https://www.gnu.org/licenses/why-not-lgpl.html>.
*/

@file:Suppress("unused", "UNUSED_PARAMETER")

package com.dirror.music

import android.annotation.SuppressLint
Expand Down Expand Up @@ -52,36 +54,8 @@ import kotlin.coroutines.EmptyCoroutineContext
* @since 2021-7-13
*/
@Keep
@SuppressLint("StaticFieldLeak")
class App : Application() {

companion object {

private val TAG = this::class.java.simpleName

const val UM_APP_KEY = "5fb38e09257f6b73c0961382"

lateinit var mmkv: MMKV

lateinit var context: Context

var musicController = MutableLiveData<MusicService.MusicController?>()

val musicServiceConnection by lazy { MusicServiceConnection() } // 音乐服务连接

@Deprecated("过时,使用 StartActivity")
lateinit var activityManager: ActivityManager

lateinit var cloudMusicManager: CloudMusicManager

val coroutineScope = CoroutineScope(EmptyCoroutineContext)

/** 数据库 */
lateinit var appDatabase: AppDatabase

lateinit var realIP: String
}

override fun onCreate() {
super.onCreate()
// 全局 context
Expand Down Expand Up @@ -150,4 +124,32 @@ class App : Application() {
bindService(intent, musicServiceConnection, BIND_AUTO_CREATE)
}

companion object {

private val TAG = this::class.java.simpleName

const val UM_APP_KEY = "5fb38e09257f6b73c0961382"

lateinit var mmkv: MMKV

@SuppressLint("StaticFieldLeak")
lateinit var context: Context

var musicController = MutableLiveData<MusicService.MusicController?>()

val musicServiceConnection by lazy { MusicServiceConnection() } // 音乐服务连接

@Deprecated("过时,使用 StartActivity")
lateinit var activityManager: ActivityManager

lateinit var cloudMusicManager: CloudMusicManager

val coroutineScope = CoroutineScope(EmptyCoroutineContext)

/** 数据库 */
lateinit var appDatabase: AppDatabase

lateinit var realIP: String
}

}
89 changes: 49 additions & 40 deletions app/src/main/java/com/dirror/music/ui/player/PlayerActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,6 @@ import com.dso.ext.colorMix
*/
class PlayerActivity : SlideBackActivity() {

companion object {
private const val MUSIC_BROADCAST_ACTION = "com.dirror.music.MUSIC_BROADCAST"
private const val DELAY_MILLIS = 500L

// Handle 消息,播放进度
private const val MSG_PROGRESS = 0

// 动画循环时长
private const val DURATION_CD = 27_500L
private const val ANIMATION_REPEAT_COUNTS = -1
private const val ANIMATION_PROPERTY_NAME = "rotation"
}

private lateinit var binding: ActivityPlayerBinding

// 是否是横屏状态
Expand Down Expand Up @@ -129,7 +116,10 @@ class PlayerActivity : SlideBackActivity() {
override fun initBinding() {
binding = ActivityPlayerBinding.inflate(layoutInflater)
binding.root.setOnApplyWindowInsetsListener { _, insets ->
playViewModel.navigationBarHeight.value = insets.systemWindowInsetBottom
playViewModel.systemWindowInsetTop.value = insets.systemWindowInsetTop
playViewModel.systemWindowInsetLeft.value = insets.systemWindowInsetLeft
playViewModel.systemWindowInsetRight.value = insets.systemWindowInsetRight
playViewModel.systemWindowInsetBottom.value = insets.systemWindowInsetBottom
insets
}
setContentView(binding.root)
Expand All @@ -153,19 +143,13 @@ class PlayerActivity : SlideBackActivity() {
val configuration = this.resources.configuration //获取设置的配置信息
if (configuration.orientation == Configuration.ORIENTATION_LANDSCAPE) {
isLandScape = true
// 横屏隐藏状态栏
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
window.insetsController?.hide(WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE)
}
}
// 页面状态栏适配
binding.titleBar?.let {
(it.layoutParams as ConstraintLayout.LayoutParams).apply {
topToTop = ConstraintLayout.LayoutParams.PARENT_ID
topMargin = getStatusBarHeight(window, this@PlayerActivity)
}
// // 横屏隐藏状态栏
// if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.R) {
// window.insetsController?.hide(WindowInsetsController.BEHAVIOR_SHOW_BARS_BY_SWIPE)
// }
}


binding.apply {
// 时长右对齐
ttvDuration.setAlignRight()
Expand Down Expand Up @@ -527,11 +511,6 @@ class PlayerActivity : SlideBackActivity() {
// 颜色观察
color.observe(this@PlayerActivity, {
binding.apply {
// if (heart.value == true) {
// ivLike.setColorFilter(R.color.colorAppThemeColor.asColor(this@PlayerActivity))
// } else {
// ivLike.setColorFilter(it)
// }
val darkMode = DarkThemeUtil.isDarkTheme(this@PlayerActivity)
val secondColor = if (darkMode) {
Color.rgb(45, 45, 45)
Expand All @@ -544,11 +523,6 @@ class PlayerActivity : SlideBackActivity() {
it.colorMix(Color.WHITE, Color.WHITE, Color.WHITE)
}


// ivLyricsBackground.setImageDrawable(GradientDrawable().apply{
// this.gradientType = GradientDrawable.LINEAR_GRADIENT // 指定渲染角度
// this.colors = intArrayOf(mixColor, secondColor, secondColor, secondColor) // 指定渐变色
// })
}

})
Expand Down Expand Up @@ -603,13 +577,35 @@ class PlayerActivity : SlideBackActivity() {
playViewModel.normalColor.value?.let { it1 -> binding.ivLike.setColorFilter(it1) }
}
})

navigationBarHeight.observe(this@PlayerActivity, {
binding.clBottom.updateLayoutParams<ConstraintLayout.LayoutParams> {
bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID
bottomMargin = it
systemWindowInsetTop.observe(this@PlayerActivity, { top ->
// 页面状态栏适配
binding.titleBar?.let {
(it.layoutParams as ConstraintLayout.LayoutParams).apply {
topToTop = ConstraintLayout.LayoutParams.PARENT_ID
topMargin = top
}
}
binding.llBase?.let {
it.updateLayoutParams<ConstraintLayout.LayoutParams> {
topMargin = top
}
}
})
systemWindowInsetBottom.observe(this@PlayerActivity, { bottom ->
if (isLandScape) {
binding.llBase?.let {
it.updateLayoutParams<ConstraintLayout.LayoutParams> {
bottomMargin = bottom
}
}
} else {
binding.clBottom.updateLayoutParams<ConstraintLayout.LayoutParams> {
bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID
bottomMargin = bottom
}
}

})
}
}

Expand Down Expand Up @@ -671,4 +667,17 @@ class PlayerActivity : SlideBackActivity() {
return super.onKeyDown(keyCode, event)
}

companion object {
private const val MUSIC_BROADCAST_ACTION = "com.dirror.music.MUSIC_BROADCAST"
private const val DELAY_MILLIS = 500L

// Handle 消息,播放进度
private const val MSG_PROGRESS = 0

// 动画循环时长
private const val DURATION_CD = 27_500L
private const val ANIMATION_REPEAT_COUNTS = -1
private const val ANIMATION_PROPERTY_NAME = "rotation"
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ class PlayerViewModel: ViewModel() {
var rotation = 0f
var rotationBackground = 0f

/** 状态栏高度 */
var navigationBarHeight = MutableLiveData<Int>()
val systemWindowInsetTop = MutableLiveData<Int>()
val systemWindowInsetLeft = MutableLiveData<Int>()
val systemWindowInsetRight = MutableLiveData<Int>()
val systemWindowInsetBottom = MutableLiveData<Int>()

// 播放模式
var playMode = MutableLiveData<Int>().also {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.dirror.music.ui.playlist
import android.util.Log
import androidx.lifecycle.MutableLiveData
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.dirror.music.data.SearchType
import com.dirror.music.manager.User
import com.dirror.music.music.local.MyFavorite
Expand Down Expand Up @@ -136,11 +137,11 @@ class SongPlaylistViewModel : ViewModel() {
}

private fun getPlaylist(id: Long, useCache: Boolean) {
GlobalScope.launch {
viewModelScope.launch {
Api.getPlayList(id, useCache).let { packed ->
withContext(Dispatchers.Main) {
if (packed.songs.isEmpty()) {
toast("歌单内容获取失败")
toast("歌单内容获取失败,尝试更换 NeteaseCloudMusicApi")
}
songList.value = packed.songs
Log.d(TAG, "getPlaylist finished, isCache:${packed.isCache}, size:${packed.songs.size}")
Expand Down
1 change: 0 additions & 1 deletion app/src/main/res/layout-land/activity_player.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
android:id="@+id/llBase"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="8dp"
android:orientation="horizontal"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
Expand Down

0 comments on commit 92af6e6

Please sign in to comment.