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

Commit

Permalink
修复 A12 部分问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Moriafly committed Dec 24, 2021
1 parent 85633b4 commit 81fc0d1
Show file tree
Hide file tree
Showing 10 changed files with 176 additions and 41 deletions.
117 changes: 117 additions & 0 deletions .idea/codeStyles/Project.xml

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

5 changes: 5 additions & 0 deletions .idea/codeStyles/codeStyleConfig.xml

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

6 changes: 6 additions & 0 deletions .idea/copyright/Dso_Music.xml

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

1 change: 1 addition & 0 deletions .idea/misc.xml

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

4 changes: 3 additions & 1 deletion UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
TODO 插件支持

3.12.0 2021年12月19日
3.12.1 2021年12月24日
升级目标 API 31(Android 12),Gradle 7.3
引入 Jetpack Compose
酷我源 - 又可以听杰伦了,感谢 yshj0919
会员可以听 VIP 歌曲
修复云盘读取错误
侧栏优化

3.11.4 2021年11月18日
Expand Down
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ android {
applicationId "com.dirror.music"
minSdkVersion 21
targetSdkVersion 31
versionCode 753
versionName "3.12.0"
versionCode 754
versionName "3.12.1"

multiDexEnabled true

Expand Down
5 changes: 3 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:ignore="UnusedAttribute">
<activity android:name=".ui.activity.LocalMusicActivity"></activity>
<activity android:name=".ui.activity.LocalMusicActivity" />
<activity android:name=".ui.activity.MemoryActivity" />
<activity android:name=".ui.live.NeteaseCloudMusicApiActivity" />
<activity
Expand Down Expand Up @@ -104,7 +104,8 @@

<service
android:name=".service.MusicService"
android:exported="false" />
android:exported="false"
android:stopWithTask="true" />
</application>

</manifest>
60 changes: 32 additions & 28 deletions app/src/main/java/com/dirror/music/service/MusicService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

package com.dirror.music.service

import android.annotation.SuppressLint
import android.app.*
import android.content.Context
import android.content.Intent
Expand Down Expand Up @@ -67,22 +68,7 @@ import kotlin.coroutines.suspendCoroutine
* @author Moriafly
* @since 2020/9
*/
open class MusicService : BaseMediaService() {

companion object {
private val TAG = this::class.java.simpleName

/* Flyme 状态栏歌词 TICKER 一直显示 */
private const val FLAG_ALWAYS_SHOW_TICKER = 0x1000000

/* 只更新 Flyme 状态栏歌词 */
private const val FLAG_ONLY_UPDATE_TICKER = 0x2000000

/* MSG 状态栏歌词 */
private const val MSG_STATUS_BAR_LYRIC = 0

private const val MEDIA_SESSION_PLAYBACK_SPEED = 1f
}
class MusicService : BaseMediaService() {

/* Dso Music 音乐控制器 */
private val musicController by lazy { MusicController() }
Expand Down Expand Up @@ -165,22 +151,19 @@ open class MusicService : BaseMediaService() {
private var isPausedByTransientLossOfFocus = false

override fun onCreate() {
// 在 super.onCreate() 前
// 初始化通知管理
notificationManager = getSystemService(Context.NOTIFICATION_SERVICE) as NotificationManager // 通知管理
super.onCreate()
updateNotification(false)
}

override fun initChannel() {
// 通知渠道
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
// Create the NotificationChannel
val name = "Dso Music Notification"
val descriptionText = "Dso Music 音乐通知"
val name = "Dso Music 音乐通知"
val descriptionText = "用来显示音频控制器通知"
val importance = NotificationManager.IMPORTANCE_LOW
val channel = NotificationChannel(CHANNEL_ID, name, importance)
channel.description = descriptionText
notificationManager?.createNotificationChannel(channel)
}
super.onCreate()
updateNotification(false)
}

override fun initAudioFocus() {
Expand Down Expand Up @@ -781,6 +764,7 @@ open class MusicService : BaseMediaService() {
}
}

@SuppressLint("UnspecifiedImmutableFlag")
private fun getPendingIntentActivity(): PendingIntent {
val intentMain = Intent(this, MainActivity::class.java)
val intentPlayer = Intent(this, PlayerActivity::class.java)
Expand Down Expand Up @@ -810,11 +794,16 @@ open class MusicService : BaseMediaService() {
return buildServicePendingIntent(this, 4, intent)
}

@SuppressLint("UnspecifiedImmutableFlag")
private fun buildServicePendingIntent(context: Context, requestCode: Int, intent: Intent): PendingIntent {
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.getService(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
return if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
PendingIntent.getForegroundService(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
} else {
PendingIntent.getService(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT)
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
PendingIntent.getService(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT or PendingIntent.FLAG_IMMUTABLE)
} else {
PendingIntent.getService(context, requestCode, intent, PendingIntent.FLAG_UPDATE_CURRENT)
}
}
}

Expand Down Expand Up @@ -957,4 +946,19 @@ open class MusicService : BaseMediaService() {
}

}

companion object {
private val TAG = this::class.java.simpleName

/* Flyme 状态栏歌词 TICKER 一直显示 */
private const val FLAG_ALWAYS_SHOW_TICKER = 0x1000000

/* 只更新 Flyme 状态栏歌词 */
private const val FLAG_ONLY_UPDATE_TICKER = 0x2000000

/* MSG 状态栏歌词 */
private const val MSG_STATUS_BAR_LYRIC = 0

private const val MEDIA_SESSION_PLAYBACK_SPEED = 1f
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ abstract class BaseMediaService: Service() {

override fun onCreate() {
super.onCreate()
initChannel()
initMediaSession()
initAudioFocus()
}
Expand All @@ -45,13 +44,6 @@ abstract class BaseMediaService: Service() {

}

/**
* 初始化通道
*/
open fun initChannel() {

}

/**
* 初始化音频焦点
*/
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/layout/activity_about.xml
Original file line number Diff line number Diff line change
Expand Up @@ -164,12 +164,19 @@ Dso Music 软件内不提供歌曲下载,只提供在线音乐试听,请支
android:layout_width="match_parent"
android:layout_height="40dp" />

<com.dirror.music.widget.ValueView
app:text="代码"
app:value="chen310"
android:layout_width="match_parent"
android:layout_height="40dp" />

<com.dirror.music.widget.ValueView
app:text="代码"
app:value="can-dy-jack"
android:layout_width="match_parent"
android:layout_height="40dp" />


<TextView
android:text="@string/contact_author"
style="@style/style_settings_title"/>
Expand Down

0 comments on commit 81fc0d1

Please sign in to comment.