diff --git a/.idea/dictionaries/24568.xml b/.idea/dictionaries/24568.xml
index 54d5b0c5..6187a926 100644
--- a/.idea/dictionaries/24568.xml
+++ b/.idea/dictionaries/24568.xml
@@ -2,6 +2,7 @@
mmkv
+ netease
\ No newline at end of file
diff --git a/.idea/misc.xml b/.idea/misc.xml
index f99ad97b..359ee88e 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -1,5 +1,12 @@
+
+
+
\ No newline at end of file
diff --git a/UPDATE.md b/UPDATE.md
index cb20032a..5f1b7b9b 100644
--- a/UPDATE.md
+++ b/UPDATE.md
@@ -1,3 +1,9 @@
+3.11.4 2021年11月18日
+修复 API 失效引起的拉取歌单 / 搜索失败的问题
+当用户配置了网易云 API 时, 这些接口也会使用这个配置
+优化横屏状态栏、导航栏显示区域适配
+优化加载歌单失败提示语
+
3.11.3 2021年11月13日
修复本地歌曲播放失败问题,感谢 kqwyf 的反馈
更新 Kotlin 版本至 1.5.31
diff --git a/app/build.gradle b/app/build.gradle
index ebde918c..bb4fec97 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -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
diff --git a/app/release/3.11.3(750).apk b/app/release/3.11.4(751).apk
similarity index 61%
rename from app/release/3.11.3(750).apk
rename to app/release/3.11.4(751).apk
index bcda664d..e1779927 100644
Binary files a/app/release/3.11.3(750).apk and b/app/release/3.11.4(751).apk differ
diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json
index 9198f8f0..7aa23db7 100644
--- a/app/release/output-metadata.json
+++ b/app/release/output-metadata.json
@@ -10,8 +10,8 @@
{
"type": "SINGLE",
"filters": [],
- "versionCode": 750,
- "versionName": "3.11.3",
+ "versionCode": 751,
+ "versionName": "3.11.4",
"outputFile": "app-release.apk"
}
]
diff --git a/app/src/main/java/com/dirror/music/App.kt b/app/src/main/java/com/dirror/music/App.kt
index 5c762682..ccca48e7 100644
--- a/app/src/main/java/com/dirror/music/App.kt
+++ b/app/src/main/java/com/dirror/music/App.kt
@@ -22,6 +22,8 @@
* .
*/
+@file:Suppress("unused", "UNUSED_PARAMETER")
+
package com.dirror.music
import android.annotation.SuppressLint
@@ -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()
-
- 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
@@ -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()
+
+ 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
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/dirror/music/ui/player/PlayerActivity.kt b/app/src/main/java/com/dirror/music/ui/player/PlayerActivity.kt
index 7d8f9127..546cd37a 100644
--- a/app/src/main/java/com/dirror/music/ui/player/PlayerActivity.kt
+++ b/app/src/main/java/com/dirror/music/ui/player/PlayerActivity.kt
@@ -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
// 是否是横屏状态
@@ -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)
@@ -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()
@@ -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)
@@ -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) // 指定渐变色
-// })
}
})
@@ -603,13 +577,35 @@ class PlayerActivity : SlideBackActivity() {
playViewModel.normalColor.value?.let { it1 -> binding.ivLike.setColorFilter(it1) }
}
})
-
- navigationBarHeight.observe(this@PlayerActivity, {
- binding.clBottom.updateLayoutParams {
- 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 {
+ topMargin = top
+ }
}
})
+ systemWindowInsetBottom.observe(this@PlayerActivity, { bottom ->
+ if (isLandScape) {
+ binding.llBase?.let {
+ it.updateLayoutParams {
+ bottomMargin = bottom
+ }
+ }
+ } else {
+ binding.clBottom.updateLayoutParams {
+ bottomToBottom = ConstraintLayout.LayoutParams.PARENT_ID
+ bottomMargin = bottom
+ }
+ }
+
+ })
}
}
@@ -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"
+ }
+
}
\ No newline at end of file
diff --git a/app/src/main/java/com/dirror/music/ui/player/PlayerViewModel.kt b/app/src/main/java/com/dirror/music/ui/player/PlayerViewModel.kt
index 6e42dba0..cf551fad 100644
--- a/app/src/main/java/com/dirror/music/ui/player/PlayerViewModel.kt
+++ b/app/src/main/java/com/dirror/music/ui/player/PlayerViewModel.kt
@@ -30,8 +30,10 @@ class PlayerViewModel: ViewModel() {
var rotation = 0f
var rotationBackground = 0f
- /** 状态栏高度 */
- var navigationBarHeight = MutableLiveData()
+ val systemWindowInsetTop = MutableLiveData()
+ val systemWindowInsetLeft = MutableLiveData()
+ val systemWindowInsetRight = MutableLiveData()
+ val systemWindowInsetBottom = MutableLiveData()
// 播放模式
var playMode = MutableLiveData().also {
diff --git a/app/src/main/java/com/dirror/music/ui/playlist/SongPlaylistViewModel.kt b/app/src/main/java/com/dirror/music/ui/playlist/SongPlaylistViewModel.kt
index 227223a4..0996e62a 100644
--- a/app/src/main/java/com/dirror/music/ui/playlist/SongPlaylistViewModel.kt
+++ b/app/src/main/java/com/dirror/music/ui/playlist/SongPlaylistViewModel.kt
@@ -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
@@ -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}")
diff --git a/app/src/main/res/layout-land/activity_player.xml b/app/src/main/res/layout-land/activity_player.xml
index 01894fe6..8edb6845 100644
--- a/app/src/main/res/layout-land/activity_player.xml
+++ b/app/src/main/res/layout-land/activity_player.xml
@@ -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"