diff --git a/app/build.gradle b/app/build.gradle index 469ff470..6ae5d562 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -29,7 +29,7 @@ android { applicationId "com.dirror.music" minSdkVersion 23 targetSdkVersion 30 - versionCode 286 + versionCode 287 versionName "2.4.0-alpha" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/com/dirror/music/adapter/DetailPlaylistAdapter.kt b/app/src/main/java/com/dirror/music/adapter/DetailPlaylistAdapter.kt index 70a7471c..5008a9a9 100644 --- a/app/src/main/java/com/dirror/music/adapter/DetailPlaylistAdapter.kt +++ b/app/src/main/java/com/dirror/music/adapter/DetailPlaylistAdapter.kt @@ -12,6 +12,8 @@ import androidx.constraintlayout.widget.ConstraintLayout import androidx.recyclerview.widget.RecyclerView import com.dirror.music.MyApplication import com.dirror.music.R +import com.dirror.music.data.PLAYLIST_TAG_MY_FAVORITE +import com.dirror.music.data.PLAYLIST_TAG_NORMAL import com.dirror.music.music.standard.data.StandardSongData import com.dirror.music.ui.activity.PlayerActivity import com.dirror.music.ui.dialog.SongMenuDialog @@ -20,7 +22,11 @@ import com.dirror.music.util.parseArtist /** * 歌单适配器 */ -class DetailPlaylistAdapter(private val songDataList: ArrayList, private val activity: Activity): RecyclerView.Adapter() { +class DetailPlaylistAdapter + @JvmOverloads + constructor(private val songDataList: ArrayList, + private val activity: Activity, + private val tag: Int = PLAYLIST_TAG_NORMAL): RecyclerView.Adapter() { inner class ViewHolder(view: View): RecyclerView.ViewHolder(view) { val tvNumber: TextView = view.findViewById(R.id.tvNumber) @@ -58,7 +64,7 @@ class DetailPlaylistAdapter(private val songDataList: ArrayList) { + private fun initRecycleView(songList: ArrayList, tag: Int = PLAYLIST_TAG_NORMAL) { runOnMainThread { binding.clLoading.visibility = View.GONE binding.rvPlaylist.layoutManager = LinearLayoutManager(this@PlaylistActivity) // 改变全局变量 - detailPlaylistAdapter = DetailPlaylistAdapter(songList, this@PlaylistActivity) + detailPlaylistAdapter = DetailPlaylistAdapter(songList, this@PlaylistActivity, tag) binding.rvPlaylist.adapter = detailPlaylistAdapter binding.tvPlayAll.text = "播放全部(${songList.size})" binding.lottieLoading.pauseAnimation() diff --git a/app/src/main/java/com/dirror/music/ui/activity/WebActivity.kt b/app/src/main/java/com/dirror/music/ui/activity/WebActivity.kt index e2fc685c..781f86cb 100644 --- a/app/src/main/java/com/dirror/music/ui/activity/WebActivity.kt +++ b/app/src/main/java/com/dirror/music/ui/activity/WebActivity.kt @@ -12,6 +12,10 @@ import com.dirror.music.databinding.ActivityWebBinding class WebActivity : AppCompatActivity() { + companion object { + const val EXTRA_TITLE = "extra_title" + } + private lateinit var binding: ActivityWebBinding @SuppressLint("SetJavaScriptEnabled") @@ -21,6 +25,7 @@ class WebActivity : AppCompatActivity() { setContentView(binding.root) val extraWebUrlStr = intent.getStringExtra("extra_webUrlStr") + val extraTitle = intent.getStringExtra(EXTRA_TITLE) binding.webView.settings.javaScriptEnabled = true // 禁用 JavaScript binding.webView.settings.allowFileAccess = false // 禁止访问私有文件数据 diff --git a/app/src/main/java/com/dirror/music/ui/dialog/AppInfoDialog.kt b/app/src/main/java/com/dirror/music/ui/dialog/AppInfoDialog.kt new file mode 100644 index 00000000..1ef21b96 --- /dev/null +++ b/app/src/main/java/com/dirror/music/ui/dialog/AppInfoDialog.kt @@ -0,0 +1,41 @@ +package com.dirror.music.ui.dialog + +import android.annotation.SuppressLint +import android.content.Context +import android.os.Build +import com.dirror.music.MyApplication +import com.dirror.music.databinding.DialogTextInfoBinding +import com.dirror.music.foyou.sentence.foyoulibrary.FoyouLibrary +import com.dirror.music.room.AppDatabase +import com.dirror.music.util.Secure +import com.dirror.music.util.defaultTypeface +import com.dirror.music.util.getVisionCode +import com.dirror.music.util.getVisionName + +class AppInfoDialog(context: Context) : BaseBottomSheetDialog(context) { + + val binding = DialogTextInfoBinding.inflate(layoutInflater) + + init { + setContentView(binding.root) + } + + @SuppressLint("SetTextI18n") + override fun initView() { + super.initView() + binding.apply { + tvText.typeface = defaultTypeface(MyApplication.context) + tvText.text = """ + [app.ver ] ${getVisionName()} + [app.build ] ${getVisionCode()} + [is debug ] ${Secure.isDebug()} + [foyou.ver ] ${FoyouLibrary.VERSION} + [database.ver] ${AppDatabase.DATABASE_VERSION} + [model ] ${Build.MODEL} + [android.ver ] ${Build.VERSION.RELEASE} + [android.sdk ] ${Build.VERSION.SDK_INT} + """.trimIndent() + } + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/dirror/music/ui/dialog/BaseBottomSheetDialog.kt b/app/src/main/java/com/dirror/music/ui/dialog/BaseBottomSheetDialog.kt new file mode 100644 index 00000000..9dd8aa27 --- /dev/null +++ b/app/src/main/java/com/dirror/music/ui/dialog/BaseBottomSheetDialog.kt @@ -0,0 +1,29 @@ +package com.dirror.music.ui.dialog + +import android.content.Context +import android.os.Bundle +import android.view.Gravity +import android.view.ViewGroup +import com.dirror.music.R +import com.google.android.material.bottomsheet.BottomSheetDialog + +abstract class BaseBottomSheetDialog(context: Context): BottomSheetDialog(context, R.style.style_default_dialog) { + + override fun onCreate(savedInstanceState: Bundle?) { + super.onCreate(savedInstanceState) + window?.setGravity(Gravity.BOTTOM) + window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) + window?.setWindowAnimations(R.style.dialog_animation) + initView() + initListener() + } + + open fun initView() { + + } + + open fun initListener() { + + } + +} \ No newline at end of file diff --git a/app/src/main/java/com/dirror/music/ui/dialog/PlaylistDialog.kt b/app/src/main/java/com/dirror/music/ui/dialog/PlaylistDialog.kt index 617dbd0f..cea54a8b 100644 --- a/app/src/main/java/com/dirror/music/ui/dialog/PlaylistDialog.kt +++ b/app/src/main/java/com/dirror/music/ui/dialog/PlaylistDialog.kt @@ -11,29 +11,20 @@ import com.dirror.music.adapter.PlaylistDialogAdapter import com.dirror.music.databinding.DialogPlayListBinding import com.google.android.material.bottomsheet.BottomSheetDialog -class PlaylistDialog: BottomSheetDialog { +class PlaylistDialog(context: Context): BaseBottomSheetDialog(context) { private var binding: DialogPlayListBinding = DialogPlayListBinding.inflate(layoutInflater) - constructor(context: Context) : this(context, 0) - - constructor(context: Context, themeResId: Int) : super(context, R.style.style_default_dialog) { + init { setContentView(binding.root) - // 设置显示位置 - window?.setGravity(Gravity.BOTTOM) - // 设置大小 - window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) - window?.setWindowAnimations(R.style.dialog_animation) } - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - + override fun initView() { + super.initView() binding.rvPlaylist.layoutManager = LinearLayoutManager(context) MyApplication.musicBinderInterface?.getPlaylist()?.let { binding.rvPlaylist.adapter = PlaylistDialogAdapter(it) binding.tvPlaylist.text = this.context.getString(R.string.playlist_number, it.size) } - } } \ No newline at end of file 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 79de78cb..835bd40a 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 @@ -8,30 +8,36 @@ import android.view.Gravity import android.view.ViewGroup import com.dirror.music.MyApplication import com.dirror.music.R +import com.dirror.music.data.PLAYLIST_TAG_MY_FAVORITE +import com.dirror.music.data.PLAYLIST_TAG_NORMAL 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.util.Secure import com.dirror.music.util.toast +import com.google.android.material.bottomsheet.BottomSheetDialog -class SongMenuDialog(context: Context) : Dialog(context, R.style.style_default_dialog) { +class SongMenuDialog + @JvmOverloads + constructor(context: Context, private val tag: Int = PLAYLIST_TAG_NORMAL) : BaseBottomSheetDialog(context) { private var binding = DialogSongMenuBinding.inflate(layoutInflater) init { setContentView(binding.root) - window?.setGravity(Gravity.BOTTOM) - window?.setLayout(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT) } private lateinit var songData: StandardSongData private lateinit var activity: Activity - override fun onCreate(savedInstanceState: Bundle?) { - super.onCreate(savedInstanceState) - initListener() + + override fun initView() { + super.initView() + } - private fun initListener() { + override fun initListener() { + super.initListener() binding.apply { // 歌曲信息 itemSongInfo.setOnClickListener { @@ -47,10 +53,9 @@ class SongMenuDialog(context: Context) : Dialog(context, R.style.style_default_d } // 歌曲删除 itemDeleteSong.setOnClickListener { - if (Secure.isDebug()) { - toast("开发中") - } else { - toast("测试") + if (tag == PLAYLIST_TAG_MY_FAVORITE) { + MyFavorite.deleteById(songData.id) + toast("删除成功") } } } diff --git a/app/src/main/java/com/dirror/music/util/TopLevelFuncation.kt b/app/src/main/java/com/dirror/music/util/TopLevelFuncation.kt index 3b7a36ca..9d044b6f 100644 --- a/app/src/main/java/com/dirror/music/util/TopLevelFuncation.kt +++ b/app/src/main/java/com/dirror/music/util/TopLevelFuncation.kt @@ -5,6 +5,7 @@ import android.content.ClipData import android.content.ClipboardManager import android.content.Context import android.content.Intent +import android.graphics.Typeface import android.net.Uri import android.os.Bundle import android.os.Handler @@ -163,4 +164,8 @@ fun openJim(context: Context) { } catch (e: Exception) { toast("失败") } +} + +fun defaultTypeface(context: Context): Typeface { + return Typeface.createFromAsset(context.assets, "fonts/Moriafly-Regular.ttf") } \ No newline at end of file diff --git a/app/src/main/res/layout/dialog_song_menu.xml b/app/src/main/res/layout/dialog_song_menu.xml index 77f994bc..33c356bf 100644 --- a/app/src/main/res/layout/dialog_song_menu.xml +++ b/app/src/main/res/layout/dialog_song_menu.xml @@ -3,15 +3,11 @@ xmlns:app="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" - android:background="@drawable/bg_dialog"> + android:background="@drawable/bg_slide_layout"> + + + + + + \ No newline at end of file diff --git a/app/src/main/res/values/dimens.xml b/app/src/main/res/values/dimens.xml index f80e0af3..615987eb 100644 --- a/app/src/main/res/values/dimens.xml +++ b/app/src/main/res/values/dimens.xml @@ -6,6 +6,8 @@ 16sp + 12sp + 4dp 1000 16sp