diff --git a/app/build.gradle b/app/build.gradle index 45f6a33c..6a8c712c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,8 +29,8 @@ android { applicationId "com.dirror.music" minSdkVersion 23 targetSdkVersion 30 - versionCode 290 - versionName "2.4.0-beta" + versionCode 291 + versionName "2.4.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro index cbf36db5..0a0c4810 100644 --- a/app/proguard-rules.pro +++ b/app/proguard-rules.pro @@ -22,6 +22,7 @@ -keep class com.dirror.music.music.** { *; } -keep class com.dirror.music.data.** { *; } +-keep class com.dirror.music.room.** { *; } -ignorewarnings diff --git a/app/release/2.3.6.apk b/app/release/2.4.0.apk similarity index 79% rename from app/release/2.3.6.apk rename to app/release/2.4.0.apk index f4586346..068e1dac 100644 Binary files a/app/release/2.3.6.apk and b/app/release/2.4.0.apk differ diff --git a/app/release/output-metadata.json b/app/release/output-metadata.json index 4fa2ca78..611affc7 100644 --- a/app/release/output-metadata.json +++ b/app/release/output-metadata.json @@ -10,8 +10,8 @@ { "type": "SINGLE", "filters": [], - "versionCode": 283, - "versionName": "2.3.6", + "versionCode": 291, + "versionName": "2.4.0", "outputFile": "app-release.apk" } ] diff --git a/app/src/main/java/com/dirror/music/ui/activity/PlaylistActivity2.kt b/app/src/main/java/com/dirror/music/ui/activity/PlaylistActivity2.kt index f9ebb3d3..fd11d589 100644 --- a/app/src/main/java/com/dirror/music/ui/activity/PlaylistActivity2.kt +++ b/app/src/main/java/com/dirror/music/ui/activity/PlaylistActivity2.kt @@ -5,10 +5,15 @@ import android.content.BroadcastReceiver import android.content.Context import android.content.Intent import android.content.IntentFilter +import android.graphics.Bitmap import android.view.View import androidx.activity.viewModels import androidx.constraintlayout.widget.ConstraintLayout +import androidx.core.content.ContextCompat +import androidx.core.graphics.drawable.toBitmap import androidx.recyclerview.widget.LinearLayoutManager +import com.bumptech.glide.Glide +import com.bumptech.glide.request.RequestOptions import com.dirror.music.MyApplication import com.dirror.music.R import com.dirror.music.adapter.DetailPlaylistAdapter @@ -19,8 +24,10 @@ import com.dirror.music.music.standard.SongPicture import com.dirror.music.music.standard.data.SOURCE_NETEASE import com.dirror.music.ui.base.BaseActivity import com.dirror.music.ui.dialog.PlaylistDialog +import com.dirror.music.ui.dialog.SongMenuDialog import com.dirror.music.ui.viewmodel.PlaylistViewModel import com.dirror.music.util.* +import jp.wasabeef.glide.transformations.BlurTransformation /** * 新版 Playlist @@ -37,6 +44,7 @@ class PlaylistActivity2: BaseActivity() { // 音乐广播接收 private lateinit var musicBroadcastReceiver: MusicBroadcastReceiver + private lateinit var updatePlaylistReceiver: UpdatePlaylistReceiver private var detailPlaylistAdapter = DetailPlaylistAdapter(ArrayList(), this) @@ -72,13 +80,30 @@ class PlaylistActivity2: BaseActivity() { playlistViewModel.updatePlaylist() binding.rvPlaylist.layoutManager = LinearLayoutManager(this@PlaylistActivity2) + + var rvPlaylistScrollY = 0 + binding.rvPlaylist.setOnScrollChangeListener { _, _, _, _, oldScrollY -> + rvPlaylistScrollY += oldScrollY + if (rvPlaylistScrollY < 0) { + if (binding.titleBar.text == getString(R.string.playlist)) { + binding.titleBar.setTitleBarText(binding.tvName.text.toString()) + } + } else { + binding.titleBar.setTitleBarText(getString(R.string.playlist)) + } + } } override fun initBroadcastReceiver() { - val intentFilter = IntentFilter() // Intent 过滤器 + var intentFilter = IntentFilter() // Intent 过滤器 intentFilter.addAction("com.dirror.music.MUSIC_BROADCAST") // 只接收 "com.dirror.foyou.MUSIC_BROADCAST" 标识广播 musicBroadcastReceiver = MusicBroadcastReceiver() // registerReceiver(musicBroadcastReceiver, intentFilter) // 注册接收器 + + intentFilter = IntentFilter() + intentFilter.addAction(SongMenuDialog.BROADCAST_UPDATE_PLAYLIST) + updatePlaylistReceiver = UpdatePlaylistReceiver() + registerReceiver(updatePlaylistReceiver, intentFilter) // 注册接收器 } override fun initListener() { @@ -122,6 +147,9 @@ class PlaylistActivity2: BaseActivity() { tag.observe(this@PlaylistActivity2, { if (tag.value == PLAYLIST_TAG_MY_FAVORITE) { binding.tvName.text = getString(R.string.my_favorite_songs) + ContextCompat.getDrawable(this@PlaylistActivity2, R.drawable.ic_bq_love_music_filter)?.let { it1 -> + setPicture(it1.toBitmap()) + } } }) } @@ -135,6 +163,12 @@ class PlaylistActivity2: BaseActivity() { } } + inner class UpdatePlaylistReceiver: BroadcastReceiver() { + override fun onReceive(context: Context, intent: Intent) { + playlistViewModel.updatePlaylist() + } + } + private fun refreshPlayState() { if (MyApplication.musicBinderInterface?.getPlayState() == true) { binding.includePlay.ivPlay.setImageResource(R.drawable.ic_bq_control_pause) @@ -167,6 +201,21 @@ class PlaylistActivity2: BaseActivity() { super.onDestroy() // 解绑 unregisterReceiver(musicBroadcastReceiver) + unregisterReceiver(updatePlaylistReceiver) + } + + /** + * 设置图片 + */ + private fun setPicture(bitmap: Bitmap) { + runOnMainThread { + binding.ivCover.setImageBitmap(bitmap) + Glide.with(MyApplication.context) + .load(bitmap) + .placeholder(binding.ivBackground.drawable) + .apply(RequestOptions.bitmapTransform(BlurTransformation(50, 10))) + .into(binding.ivBackground) + } } diff --git a/app/src/main/java/com/dirror/music/ui/dialog/PlayerMenuMoreDialog.kt b/app/src/main/java/com/dirror/music/ui/dialog/PlayerMenuMoreDialog.kt index 5c553b2a..49bcffad 100644 --- a/app/src/main/java/com/dirror/music/ui/dialog/PlayerMenuMoreDialog.kt +++ b/app/src/main/java/com/dirror/music/ui/dialog/PlayerMenuMoreDialog.kt @@ -58,6 +58,7 @@ class PlayerMenuMoreDialog(context: Context) : BaseBottomSheetDialog(context) { // 播放历史 itemPlayHistory.setOnClickListener { it.context.startActivity(Intent(it.context, PlayHistoryActivity::class.java)) + dismiss() } // 反馈 itemFeedback.setOnClickListener { diff --git a/app/src/main/java/com/dirror/music/ui/dialog/SongMenuDialog.kt b/app/src/main/java/com/dirror/music/ui/dialog/SongMenuDialog.kt index bfc51d08..f610e019 100644 --- a/app/src/main/java/com/dirror/music/ui/dialog/SongMenuDialog.kt +++ b/app/src/main/java/com/dirror/music/ui/dialog/SongMenuDialog.kt @@ -9,6 +9,7 @@ import com.dirror.music.databinding.DialogSongMenuBinding import com.dirror.music.music.local.MyFavorite import com.dirror.music.music.standard.data.StandardSongData import com.dirror.music.ui.base.BaseBottomSheetDialog +import com.dirror.music.util.BroadcastUtil import com.dirror.music.util.toast class SongMenuDialog @@ -18,6 +19,10 @@ class SongMenuDialog private val songData: StandardSongData, private val tag: Int = PLAYLIST_TAG_NORMAL) : BaseBottomSheetDialog(context) { + companion object { + const val BROADCAST_UPDATE_PLAYLIST = "com.dirror.music.UPDATE_PLAYLIST" + } + private var binding = DialogSongMenuBinding.inflate(layoutInflater) init { @@ -49,6 +54,7 @@ class SongMenuDialog if (tag == PLAYLIST_TAG_MY_FAVORITE) { MyFavorite.deleteById(songData.id) toast("删除成功") + BroadcastUtil.send(this@SongMenuDialog.context, BROADCAST_UPDATE_PLAYLIST) dismiss() } } diff --git a/app/src/main/java/com/dirror/music/util/BroadcastUtil.kt b/app/src/main/java/com/dirror/music/util/BroadcastUtil.kt new file mode 100644 index 00000000..7dd78b62 --- /dev/null +++ b/app/src/main/java/com/dirror/music/util/BroadcastUtil.kt @@ -0,0 +1,14 @@ +package com.dirror.music.util + +import android.content.Context +import android.content.Intent + +object BroadcastUtil { + + fun send(context: Context, action: String) { + val intent = Intent(action) + intent.setPackage(context.packageName) + context.sendBroadcast(intent) + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/dirror/music/util/UpdateUtil.kt b/app/src/main/java/com/dirror/music/util/UpdateUtil.kt index cf3668f7..ed15218b 100644 --- a/app/src/main/java/com/dirror/music/util/UpdateUtil.kt +++ b/app/src/main/java/com/dirror/music/util/UpdateUtil.kt @@ -21,7 +21,7 @@ object UpdateUtil { UpdateDialog(activity, updateData).show() } else { if (showLastedToast) { - toast("已是最新版本\n服务器版本:${updateData.code}") + toast("已是最新版本\n服务器版本:${updateData.name}(${updateData.code})") } } }