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

Commit

Permalink
江流宛转绕芳甸
Browse files Browse the repository at this point in the history
  • Loading branch information
Moriafly committed Mar 16, 2021
1 parent f34a27f commit a418ae0
Show file tree
Hide file tree
Showing 24 changed files with 273 additions and 181 deletions.
15 changes: 5 additions & 10 deletions UPDATE.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,14 @@
何处春江无月明 版本
江流宛转绕芳甸 版本

####

适配 Flyme 状态栏歌词
支持重启应用恢复先前的歌单,当前歌曲
适配安卓 4.4
协议弹窗

####

网络优化
优化滑动体验
界面优化
优化安装包大小
移除在线反馈功能
其他优化

####

修复当列表为 1,引发的闪退问题
修复部分机型启动服务失败的问题

12 changes: 7 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ android {

defaultConfig {
applicationId "com.dirror.music"
minSdkVersion 21
minSdkVersion 19
targetSdkVersion 30
versionCode 679
versionName "何处春江无月明"
versionCode 680
versionName "江流宛转绕芳甸"

multiDexEnabled true

Expand Down Expand Up @@ -83,14 +83,14 @@ dependencies {
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation "androidx.drawerlayout:drawerlayout:1.1.1"

implementation 'com.squareup.okhttp3:okhttp:4.9.0'
// 适配安卓 4.4 不要更新
implementation 'com.squareup.okhttp3:okhttp:3.12.0'
implementation 'com.google.code.gson:gson:2.8.6'

implementation 'com.eightbitlab:blurview:1.6.3'
implementation 'androidx.lifecycle:lifecycle-runtime-ktx:2.2.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.3.2'
implementation 'androidx.palette:palette-ktx:1.0.0'
implementation 'cn.bmob.android:bmob-sdk:3.7.8'
implementation 'io.reactivex.rxjava2:rxjava:2.2.11'
implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'
implementation 'com.squareup.okio:okio:2.10.0'
Expand Down Expand Up @@ -119,4 +119,6 @@ dependencies {
implementation 'com.bitvale:switcher:1.1.1'
// coil 图片加载库
implementation 'io.coil-kt:coil:1.1.1'

implementation 'com.android.support:multidex:1.0.3'
}
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": 679,
"versionName": "婵炶揪绲惧ú鏍囬埡鍛強闁靛濡囧銈夋煛閸愵亜校婵狅拷閿熶粙鏌¢崟鑸靛",
"versionCode": 680,
"versionName": "濠殿喖婀遍崰鎰矈閿旀拝鎷风憴鍕灱婵炴潙妫涚槐鎺楀即閳ユ壙锝夋煟椤喗瀚�",
"outputFile": "app-release.apk"
}
]
Expand Down
Binary file not shown.
17 changes: 10 additions & 7 deletions app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MEDIA_CONTENT_CONTROL"
<uses-permission
android:name="android.permission.MEDIA_CONTENT_CONTROL"
tools:ignore="ProtectedPermissions" />

<application
Expand All @@ -27,8 +28,9 @@
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme"
tools:targetApi="n">
<activity android:name=".ui.activity.UserCloudActivity"></activity>
tools:ignore="UnusedAttribute">
<activity android:name=".ui.activity.AgreementActivity" />
<activity android:name=".ui.activity.UserCloudActivity" />
<activity android:name=".ui.activity.SponsorActivity" />
<activity android:name=".ui.activity.TopListActivity" />
<activity android:name=".ui.activity.RecommendActivity" />
Expand Down Expand Up @@ -88,10 +90,11 @@
android:name=".service.MusicService"
android:exported="false" />

<provider
android:name="cn.bmob.v3.util.BmobContentProvider"
android:authorities="com.dirror.music.BmobContentProvider"
android:exported="false" />
<receiver android:name="androidx.media.session.MediaButtonReceiver">
<intent-filter>
<action android:name="android.intent.action.MEDIA_BUTTON" />
</intent-filter>
</receiver>
</application>

</manifest>
38 changes: 29 additions & 9 deletions app/src/main/java/com/dirror/music/MyApplication.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ package com.dirror.music
import android.app.Application
import android.content.Context
import android.content.Intent
import android.os.Build
import androidx.annotation.Keep
import androidx.lifecycle.MutableLiveData
import cn.bmob.v3.Bmob
import androidx.multidex.MultiDex
import com.dirror.music.manager.ActivityManager
import com.dirror.music.manager.CloudMusicManager
import com.dirror.music.manager.UserManager
import com.dirror.music.room.AppDatabase
import com.dirror.music.service.MusicControllerInterface
import com.dirror.music.service.MusicService
import com.dirror.music.service.MusicServiceConnection
import com.dirror.music.util.*
import com.dirror.music.util.Config
import com.dirror.music.util.DarkThemeUtil
import com.dirror.music.util.Secure
import com.dirror.music.util.toast
import com.tencent.mmkv.MMKV
import com.umeng.analytics.MobclickAgent
import com.umeng.commonsdk.UMConfigure


/**
* 自定义 Application
* @author Moriafly
Expand Down Expand Up @@ -47,20 +51,38 @@ class MyApplication : Application() {
lateinit var appDatabase: AppDatabase
}



/* 获取 Bmob */
private external fun getBmobAppKey(): String

/* 获取友盟 */
private external fun getUmAppKey(): String

override fun attachBaseContext(base: Context?) {
super.attachBaseContext(base)
MultiDex.install(this)
}

override fun onCreate() {
super.onCreate()
// 全局 context
context = applicationContext
// MMKV 初始化
MMKV.initialize(this)
// val rootDir: String = MMKV.getRootDir()
// toast(rootDir)
// toast(filesDir.absolutePath)
// if (Build.VERSION.SDK_INT == 19) {
// // MMKV.initialize(cacheDir.absolutePath + "/mmkv") { libName ->
// ReLinker.loadLibrary(context, "libmmkv", object : LoadListener {
// override fun success() { /* Yay */
// MMKV.initialize(context)
// }
//
// override fun failure(t: Throwable) { /* Boo */
// }
// })
// } else {
MMKV.initialize(context)
// }
config = Config()
// 管理初始化
userManager = UserManager()
Expand All @@ -82,8 +104,6 @@ class MyApplication : Application() {
*/
private fun checkSecure() {
if (Secure.isSecure()) {
// 初始化 Bmob
Bmob.initialize(this, getBmobAppKey())
// 初始化友盟
UMConfigure.init(context, getUmAppKey(), "", UMConfigure.DEVICE_TYPE_PHONE, "")
// 选用 AUTO 页面采集模式
Expand All @@ -101,7 +121,7 @@ class MyApplication : Application() {
private fun startMusicService() {
// 通过 Service 播放音乐,混合启动
val intent = Intent(this, MusicService::class.java)
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.O) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
startForegroundService(intent)
} else {
startService(intent)
Expand Down
33 changes: 0 additions & 33 deletions app/src/main/java/com/dirror/music/bmob/BmobManager.kt

This file was deleted.

20 changes: 0 additions & 20 deletions app/src/main/java/com/dirror/music/bmob/FeedbackData.kt

This file was deleted.

3 changes: 3 additions & 0 deletions app/src/main/java/com/dirror/music/room/PlayQueueDao.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,7 @@ interface PlayQueueDao {
@Query("delete from PlayQueueData where id = :id")
fun deleteById(id: String): Int

@Query("delete from PlayQueueData")
fun clear()

}
2 changes: 1 addition & 1 deletion app/src/main/java/com/dirror/music/service/MusicService.kt
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ open class MusicService : BaseMediaService() {

override fun setPlaylist(songListData: ArrayList<StandardSongData>) {
PlayQueue.setNormal(songListData)
if (mode == MODE_RANDOM) {
if (mode == MODE_RANDOM && !recover) {
PlayQueue.random()
}
}
Expand Down
7 changes: 4 additions & 3 deletions app/src/main/java/com/dirror/music/service/PlayQueue.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@ import androidx.lifecycle.MutableLiveData
import com.dirror.music.MyApplication
import com.dirror.music.music.standard.data.StandardSongData
import com.dirror.music.room.PlayQueueData
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.launch
import kotlin.collections.ArrayList
import kotlin.concurrent.thread

/**
* 播放队列
Expand Down Expand Up @@ -52,9 +53,9 @@ object PlayQueue {
* 保存歌单到数据库
*/
private fun savePlayQueue() {
thread {
GlobalScope.launch {
MyApplication.appDatabase.playQueueDao().loadAll().forEach {
MyApplication.appDatabase.playQueueDao().deleteById(it.songData.id?:"")
MyApplication.appDatabase.playQueueDao().deleteById(it.songData.id ?: "")
}
currentQueue.value?.forEach {
MyApplication.appDatabase.playQueueDao().insert(PlayQueueData(it))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ class AboutActivity : BaseActivity() {
itemJoinQQGroup.setOnClickListener {
joinQQGroup(this@AboutActivity, QQ_GROUP_KEY)
}

moriafly.setOnLongClickListener {
toast("Moriafly settings reset")
MyApplication.config.mmkv.encode(Config.SHOW_AGREEMENT, true)
return@setOnLongClickListener true
}
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
package com.dirror.music.ui.activity

import android.content.Intent
import android.graphics.Bitmap
import com.dirror.music.MyApplication
import com.dirror.music.databinding.ActivityAgreementBinding
import com.dirror.music.manager.ActivityCollector
import com.dirror.music.ui.base.BaseActivity
import com.dirror.music.util.Config
import com.dirror.music.util.Secure

class AgreementActivity : BaseActivity() {

private lateinit var binding: ActivityAgreementBinding

override fun initBinding() {
binding = ActivityAgreementBinding.inflate(layoutInflater)
setContentView(binding.root)
}

override fun initListener() {
binding.btnAgree.setOnClickListener {
MyApplication.config.mmkv.encode(Config.SHOW_AGREEMENT, false)
val intent = Intent(this, MainActivity::class.java)
startActivity(intent)
finish()
}

binding.btnExit.setOnClickListener {
MyApplication.musicController.value?.stopMusicService()
ActivityCollector.finishAll()

object : Thread() {
override fun run() {
super.run()
sleep(500)
Secure.killMyself()
}
}.start()
}
}

}
24 changes: 0 additions & 24 deletions app/src/main/java/com/dirror/music/ui/activity/FeedbackActivity.kt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package com.dirror.music.ui.activity

import com.dirror.music.MyApplication
import com.dirror.music.bmob.BmobManager
import com.dirror.music.databinding.ActivityFeedbackBinding
import com.dirror.music.ui.base.BaseActivity
import com.dirror.music.util.singleClick
import com.dirror.music.util.toast

class FeedbackActivity : BaseActivity() {

Expand All @@ -21,27 +18,6 @@ class FeedbackActivity : BaseActivity() {
}

override fun initListener() {
binding.btnUpload.setOnClickListener {
singleClick {
val feedback = binding.etFeedback.text.toString()
val contact = binding.etContact.text.toString()
when {
feedback.length < 10 -> toast("反馈内容不少于 10 个字符")
contact.isEmpty() -> toast("请输入联系方式")
else -> {
// 上传反馈内容
BmobManager().uploadFeedback(feedback, contact, {
// 上传成功
toast("上传成功,感谢反馈")
finish()
}, {
// 上传失败
toast("上传失败,请稍后重试")
})
}
}
}
}
binding.itemHelpDocument.setOnClickListener {
MyApplication.activityManager.startWebActivity(this, HELP_URL)
}
Expand Down
Loading

0 comments on commit a418ae0

Please sign in to comment.