Skip to content

Commit

Permalink
3.7.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Moriafly committed Jun 13, 2021
1 parent 51f4279 commit 00d7b6e
Show file tree
Hide file tree
Showing 35 changed files with 407 additions and 152 deletions.
5 changes: 4 additions & 1 deletion UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
3.7.0 2021年6月12日

适配耳机线控
播放界面调整
歌词动画优化
修复我喜欢音乐无法获取

3.6.0 2021年6月6日
播放界面 UI 更新~
Expand Down
8 changes: 3 additions & 5 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 734
versionName "3.6.0"
versionCode 736
versionName "3.7.0"

multiDexEnabled true

Expand Down Expand Up @@ -109,7 +109,7 @@ dependencies {
implementation 'androidx.room:room-runtime:2.2.5'
kapt 'androidx.room:room-compiler:2.2.5'
// LyricViewX
implementation 'com.github.Moriafly:LyricViewX:1.2.0-beta02'
implementation 'com.github.Moriafly:LyricViewX:1.2.0'
implementation 'com.github.team403:DsoKotlinExtensions:1.0.0'
// 漂亮的开关
implementation 'com.bitvale:switcher:1.1.1'
Expand All @@ -120,6 +120,4 @@ dependencies {

implementation 'com.github.chrisbanes.photoview:library:1.2.4'

implementation 'com.google.android.material:material:1.2.1'

}
Binary file added app/release/3.7.0-beta01.apk
Binary file not shown.
Binary file added app/release/3.7.0.apk
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": 733,
"versionName": "3.6.0",
"versionCode": 736,
"versionName": "3.7.0",
"outputFile": "app-release.apk"
}
]
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:largeHeap="true"
android:networkSecurityConfig="@xml/network_security_config"
android:requestLegacyExternalStorage="true"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:largeHeap="true"
android:theme="@style/AppTheme"
tools:ignore="UnusedAttribute">
<activity android:name=".ui.activity.LocalMusicActivity"></activity>
<activity android:name=".ui.activity.MemoryActivity" />
<activity android:name=".ui.live.NeteaseCloudMusicApiActivity" />
<activity
Expand Down Expand Up @@ -101,7 +102,6 @@
<service
android:name=".service.MusicService"
android:exported="false" />

</application>

</manifest>
24 changes: 24 additions & 0 deletions app/src/main/java/com/dirror/music/MyApp.kt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
/**
* DsoMusic Copyright (C) 2020-2021 Moriafly
*
* This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
* This is free software, and you are welcome to redistribute it
* under certain conditions; type `show c' for details.
*
* The hypothetical commands `show w' and `show c' should show the appropriate
* parts of the General Public License. Of course, your program's commands
* might be different; for a GUI interface, you would use an "about box".
*
* You should also get your employer (if you work as a programmer) or school,
* if any, to sign a "copyright disclaimer" for the program, if necessary.
* For more information on this, and how to apply and follow the GNU GPL, see
* <https://www.gnu.org/licenses/>.
*
* The GNU General Public License does not permit incorporating your program
* into proprietary programs. If your program is a subroutine library, you
* may consider it more useful to permit linking proprietary applications with
* the library. If this is what you want to do, use the GNU Lesser General
* Public License instead of this License. But first, please read
* <https://www.gnu.org/licenses/why-not-lgpl.html>.
*/

package com.dirror.music

import android.annotation.SuppressLint
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/com/dirror/music/StartActivity.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
package com.dirror.music

26 changes: 25 additions & 1 deletion app/src/main/java/com/dirror/music/music/netease/Playlist.kt
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.dirror.music.music.netease

import android.content.Context
import com.dirror.music.MyApp
import com.dirror.music.api.API_AUTU
import com.dirror.music.api.API_MUSIC_ELEUU
import com.dirror.music.music.compat.CompatSearchData
import com.dirror.music.music.compat.compatSearchDataToStandardPlaylistData
import com.dirror.music.music.netease.data.PlaylistDetail
import com.dirror.music.music.standard.data.StandardSongData
import com.dirror.music.util.*
import com.dso.ext.averageAssignFixLength
Expand Down Expand Up @@ -50,7 +53,7 @@ object Playlist {
success: (ArrayList<StandardSongData>) -> Unit,
failure: () -> Unit
) {
val url = PLAYLIST_URL + playlistId
val url = PLAYLIST_URL + playlistId + "&cookie=${MyApp.userManager.getCloudMusicCookie()}"
MagicHttp.OkHttpManager().getByCache(context, url, { response ->
val trackIds = ArrayList<Long>()
try {
Expand Down Expand Up @@ -121,6 +124,27 @@ object Playlist {
})
}

/**
* 网易云登录成功的用户通过这个接口获取歌单歌曲
*/
fun getPlaylistByCookie(playlistId: Long, success: (ArrayList<StandardSongData>) -> Unit) {
val requestBody = FormBody.Builder()
.add("id", playlistId.toString())
.add("cookie", MyApp.userManager.getCloudMusicCookie())
.build()
MagicHttp.OkHttpManager().newPost("$API_AUTU/playlist/detail", requestBody, { response ->
var playlistDetail: PlaylistDetail? = null
try {
playlistDetail = Gson().fromJson(response, PlaylistDetail::class.java)
} catch (e: Exception) {

}
playlistDetail?.getSongArrayList()?.let { success(it) }
}, {
// failure(ErrorCode.MAGIC_HTTP)
})
}

data class PlaylistData(
val playlist: TrackIds?
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.dirror.music.music.netease
import android.content.ContentValues.TAG
import android.content.Context
import android.util.Log
import com.dirror.music.MyApp
import com.dirror.music.api.*
import com.dirror.music.data.DetailPlaylistData
import com.dirror.music.data.DetailPlaylistInnerData
Expand All @@ -16,6 +17,8 @@ import com.google.gson.Gson

object PlaylistUtil {

private const val TAG = "PlaylistUtil"

@Deprecated("过时")
fun getDetailPlaylist(id: Long, success: (ArrayList<StandardSongData>) -> Unit, failure: (String) -> Unit) {
val url = "$API_MUSIC_ELEUU/playlist/detail?id=$id"
Expand Down Expand Up @@ -83,7 +86,8 @@ object PlaylistUtil {
* 获取歌单信息
*/
fun getPlaylistInfo(context: Context, id: Long, success: (DetailPlaylistInnerData) -> Unit) {
val url = "$API_AUTU/playlist/detail?id=$id"
val url = "$API_AUTU/playlist/detail?id=$id&cookie=${MyApp.userManager.getCloudMusicCookie()}"
Log.i(TAG, "获取歌单信息 $url")
MagicHttp.OkHttpManager().getByCache(context, url, { response ->
try {
val playlistInfo = Gson().fromJson(response, DetailPlaylistData::class.java).playlist
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
package com.dirror.music.music.netease.data

import com.dirror.music.music.standard.data.SOURCE_NETEASE
import com.dirror.music.music.standard.data.StandardSongData

data class PlaylistDetail(
var playlist: Playlist?,
var privileges: ArrayList<Privilege>?
) {
data class Playlist(
var name: String?,
var coverImgUrl: String?,
var creator: Creator?,
var tracks: ArrayList<Track>?
) {
data class Creator(
var nickname: String?,
var avatarUrl: String?
)

data class Track(
var name: String?,
var id: Long?,
var ar: ArrayList<Artist>,
var al: Album?,

) {

data class Artist(
var id: Long?,
var name: String?
) {
fun toCompat(): StandardSongData.StandardArtistData {
return StandardSongData.StandardArtistData(
this.id,
this.name
)
}
}

/** 专辑 */
data class Album(
var id: Long?,
var name: String?,
var picUrl: String?
)

}
}

data class Privilege(
var fee: Int?,
var id: Long?,
var pl: Int?,
var maxbr: Int?,
var flag: Int?
)

fun getSongArrayList(): ArrayList<StandardSongData> {
val standardPlaylistData = ArrayList<StandardSongData>()
// 防止遍历空集合
if (this.playlist?.tracks?.isNotEmpty() == true) {
for ((index, song) in this.playlist?.tracks!!.withIndex()) {
val standardArtistDataList = ArrayList<StandardSongData.StandardArtistData>()
// song.artists
for (i in 0..song.ar.lastIndex) {
val standardArtistData = StandardSongData.StandardArtistData(
song.ar[i].id,
song.ar[i].name
)
standardArtistDataList.add(standardArtistData)
}

val privileges = this.privileges?.get(index)

val standardSongData = StandardSongData(
SOURCE_NETEASE,
song.id.toString(),
song.name,
song.al?.picUrl,
standardArtistDataList,
StandardSongData.NeteaseInfo(
privileges?.fee ?: 0,
privileges?.pl,
privileges?.flag,
privileges?.maxbr
),
null,
null
)
standardPlaylistData.add(standardSongData)
}
}
return standardPlaylistData
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package com.dirror.music.ui.activity

import com.dirror.music.ui.base.BaseActivity

class LocalMusicActivity : BaseActivity() {



}
10 changes: 5 additions & 5 deletions app/src/main/java/com/dirror/music/ui/activity/LoginActivity3.kt
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ class LoginActivity3 : BaseActivity() {
}

override fun initView() {
if (MyApp.mmkv.decodeBool(Config.USER_NETEASE_CLOUD_MUSIC_API_ENABLE, false)) {
binding.btnLoginByPhone.visibility = View.VISIBLE
} else {
binding.btnLoginByPhone.visibility = View.GONE
}
// if (MyApp.mmkv.decodeBool(Config.USER_NETEASE_CLOUD_MUSIC_API_ENABLE, false)) {
// binding.btnLoginByPhone.visibility = View.VISIBLE
// } else {
// binding.btnLoginByPhone.visibility = View.GONE
// }

(binding.btnCancel.layoutParams as ConstraintLayout.LayoutParams).apply {
topMargin = getStatusBarHeight(window, this@LoginActivity3)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import com.dirror.music.R
import com.dirror.music.databinding.ActivityLoginByPhoneBinding
import com.dirror.music.manager.ActivityCollector
import com.dirror.music.ui.base.BaseActivity
import com.dirror.music.ui.live.NeteaseCloudMusicApiActivity
import com.dirror.music.ui.viewmodel.LoginCellphoneViewModel
import com.dirror.music.util.runOnMainThread
import com.dirror.music.util.sky.SkySecure
Expand All @@ -30,6 +31,9 @@ class LoginByPhoneActivity : BaseActivity() {
}

override fun initListener() {
binding.itemNeteaseCloudMusicApi.setOnClickListener {
startActivity(Intent(this, NeteaseCloudMusicApiActivity::class.java))
}
binding.btnLoginByPhone.setOnClickListener {
val phone = binding.etPhone.text.toString()
val password = binding.etPassword.text.toString()
Expand Down
20 changes: 16 additions & 4 deletions app/src/main/java/com/dirror/music/ui/main/MyFragment.kt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import com.dirror.music.ui.main.viewmodel.MainViewModel
import com.dirror.music.ui.main.viewmodel.MyFragmentViewModel
import com.dirror.music.ui.playlist.SongPlaylistActivity
import com.dirror.music.ui.playlist.TAG_NETEASE
import com.dirror.music.ui.playlist.TAG_NETEASE_MY_FAVORITE
import com.dirror.music.util.*
import com.dirror.music.util.extensions.dp

Expand Down Expand Up @@ -65,10 +66,21 @@ class MyFragment : BaseFragment() {
}

myPlaylistAdapter = MyPlaylistAdapter {
val intent = Intent(requireContext(), SongPlaylistActivity::class.java)
intent.putExtra(SongPlaylistActivity.EXTRA_TAG, TAG_NETEASE)
intent.putExtra(SongPlaylistActivity.EXTRA_PLAYLIST_ID, it.id.toString())
requireContext().startActivity(intent)
if (myFragmentViewModel.userPlaylistList.value?.size ?: 0 > 0) {
if (it == myFragmentViewModel.userPlaylistList.value?.get(0)) {
val intent = Intent(requireContext(), SongPlaylistActivity::class.java)
intent.putExtra(SongPlaylistActivity.EXTRA_TAG, TAG_NETEASE_MY_FAVORITE)
intent.putExtra(SongPlaylistActivity.EXTRA_PLAYLIST_ID, it.id.toString())
requireContext().startActivity(intent)
} else {
val intent = Intent(requireContext(), SongPlaylistActivity::class.java)
intent.putExtra(SongPlaylistActivity.EXTRA_TAG, TAG_NETEASE)
intent.putExtra(SongPlaylistActivity.EXTRA_PLAYLIST_ID, it.id.toString())
requireContext().startActivity(intent)
}
}


}

val myFragmentIconAdapter = MyFragmentIconAdapter(requireContext())
Expand Down
Loading

0 comments on commit 00d7b6e

Please sign in to comment.