Skip to content

Commit

Permalink
5.4.2
Browse files Browse the repository at this point in the history
添加 增强停止隐藏歌词
优化 Apple Music支持范围
优化 获取音乐标题功能
  • Loading branch information
xiaowine authored Jan 10, 2023
2 parents c56a3ea + 2620786 commit e96929b
Show file tree
Hide file tree
Showing 10 changed files with 66 additions and 47 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ android {
applicationId = "statusbar.lyric"
minSdk = 26
targetSdk = 33
versionCode = 164
versionName = "5.4.1"
versionCode = 165
versionName = "5.4.2"
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
buildConfigField("String", "BUILD_TIME", "\"$buildTime\"")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -732,12 +732,13 @@ class SettingsActivity : MIUIActivity() {
}

register("advancedSettings", getString(R.string.AdvancedSettings), true) {
TextSummaryWithSwitch(TextSummaryV(textId = R.string.JudgementTitle), SwitchV("JudgementTitle"))
TextSummaryWithSwitch(TextSummaryV(textId = R.string.GetTitle), SwitchV("GetTitle"))
TextSummaryWithSwitch(TextSummaryV(textId = R.string.OnlyGetLyric, tipsId = R.string.OnlyGetLyricTips), SwitchV("OnlyGetLyric"))
TextWithSwitch(TextV(textId = R.string.TimeOff), SwitchV("TimeOff"))
TextSummaryArrow(TextSummaryV(textId = R.string.TimeOffTime, onClickListener = {
TextWithSwitch(TextV(textId = R.string.TimeHide), SwitchV("TimeOff"))
TextSummaryArrow(TextSummaryV(textId = R.string.TimeHideTime, onClickListener = {
MIUIDialog(activity) {
setTitle(R.string.TimeOffTime)
setTitle(R.string.TimeHideTime)
setMessage(R.string.AntiBurnTimeTips)
setEditText(ActivityOwnSP.ownSPConfig.getTimeOffTime().toString(), "10000")
setRButton(R.string.Ok) {
Expand Down Expand Up @@ -1176,6 +1177,7 @@ class SettingsActivity : MIUIActivity() {
}
Timer().schedule(UpdateConfigTask(), 0, 1000)
ActivityUtils.getNotice(activity)
ActivityUtils.setMusicList(activity, ActivityOwnSP.ownSPConfig)
if (ActivityOwnSP.ownSPConfig.getCheckUpdate()) ActivityUtils.getUpdate(activity)
AppCenter.start(application, Utils.appCenterKey, Analytics::class.java, Crashes::class.java)
Analytics.trackEvent("Module Version:${BuildConfig.VERSION_NAME} | Android:${Build.VERSION.SDK_INT}")
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/java/statusbar/lyric/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ class Config {
fun getGetTitle(): Boolean {
return config.optBoolean("GetTitle", false)
}
fun getJudgementTitle(): Boolean {
return config.optBoolean("JudgementTitle", true)
}

fun setLyricService(bool: Boolean) {
config.put("LService", bool)
Expand Down Expand Up @@ -351,6 +354,13 @@ class Config {
fun getBlockLyric(): String {
return config.optString("BlockLyric", "")
}
fun setMusicList(str: String) {
config.put("MusicList", str)
}

fun getMusicList(): String {
return config.optString("MusicList", "")
}

fun setBlockLyricOff(bool: Boolean) {
config.put("BlockLyricOff", bool)
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/java/statusbar/lyric/hook/app/AppleMusic.kt
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ class AppleMusic internal constructor(lpparam: LoadPackageParam) {
curInfo = curLyrics.getLyricByPosition(currentPosition)
}
if (lastLyrics != curInfo!!.lyricStr) {
sendLyric(context, curInfo!!.lyricStr, "APM")
sendLyric(context, curInfo!!.lyricStr, "APM", true, "com.apple.android.music")
lastLyrics = curInfo!!.lyricStr
}
}
Expand Down
26 changes: 16 additions & 10 deletions app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,8 @@ class SystemUI : BaseHook() {
try {
if (config.getLyricService()) {
if (test) return
if (useSystemMusicActive && !audioManager.isMusicActive) {
offLyric(LogMultiLang.pausePlay)
if (!useSystemMusicActive) {
// offLyric(LogMultiLang.pausePlay)
return
}
if (!audioManager.isMusicActive) {
Expand Down Expand Up @@ -240,16 +240,22 @@ class SystemUI : BaseHook() {
"com.android.systemui.statusbar.phone.NotificationIconContainer".findClassOrNull()?.hookAfterAllConstructors {
notificationIconContainer = it.thisObject as FrameLayout
}.isNull { LogUtils.e("Not find NotificationIconContainer") }
if (config.getGetTitle()) {
"com.android.systemui.statusbar.NotificationMediaManager".findClassOrNull()?.hookAfterMethod("updateMediaMetaData", Boolean::class.java, Boolean::class.java) {
val mContext = it.thisObject.getObjectField("mContext") as Context

"com.android.systemui.statusbar.NotificationMediaManager".findClassOrNull()?.hookAfterMethod("updateMediaMetaData", Boolean::class.java, Boolean::class.java) {
val mContext = it.thisObject.getObjectField("mContext") as Context
if (config.getMusicList().split("|").contains(mContext.packageName)) {
val mMediaMetadata = it.thisObject.getObjectField("mMediaMetadata") as MediaMetadata?
mMediaMetadata.isNotNull {
val value = mMediaMetadata!!.getString(MediaMetadata.METADATA_KEY_TITLE)
if (lsatName != value) {
lsatName = value
isFirstEntry = true
Utils.sendLyric(mContext, lsatName, icon)
if (config.getJudgementTitle()) {
offLyric("test")
}
if (config.getGetTitle()) {
isFirstEntry = true
Utils.sendLyric(mContext, lsatName, icon)
}
}
}
}
Expand All @@ -262,7 +268,7 @@ class SystemUI : BaseHook() {
try {
param.thisObject.javaClass.getField(config.getHook())
} catch (e: NoSuchFieldError) {
LogUtils.e(config.getHook() + " ${LogMultiLang.fieldFail}: " + e + "\n" + Utils.dumpNoSuchFieldError(e))
LogUtils.e(config.getHook() + " ${LogMultiLang.fieldFail}: $e\n${Utils.dumpNoSuchFieldError(e)}")
null
}
} else {
Expand All @@ -283,7 +289,7 @@ class SystemUI : BaseHook() {
arrayOf("mClockView", "mStatusClock", "mLeftClock", "mCenterClock", "mRightClock")
}
} catch (e: Throwable) {
LogUtils.e("getPackageInfoError: $e \n" + Log.getStackTraceString(e))
LogUtils.e("getPackageInfoError: $e \n${Log.getStackTraceString(e)}")
arrayOf("mClockView", "mStatusClock", "mLeftClock", "mCenterClock", "mRightClock")
}
var thisField: Field? = null
Expand All @@ -293,7 +299,7 @@ class SystemUI : BaseHook() {
LogUtils.e("${LogMultiLang.tries} $field ${LogMultiLang.fieldSuccess}")
break
} catch (e: NoSuchFieldError) {
LogUtils.e("${LogMultiLang.tries} $field ${LogMultiLang.fieldFail}: $e\n" + Log.getStackTraceString(e))
LogUtils.e("${LogMultiLang.tries} $field ${LogMultiLang.fieldFail}: $e\n${Log.getStackTraceString(e)}")
}
}
thisField
Expand Down
26 changes: 12 additions & 14 deletions app/src/main/java/statusbar/lyric/utils/ActivityUtils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@

package statusbar.lyric.utils


import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.res.TypedArray
import android.net.Uri
import android.os.Bundle
import android.os.Handler
Expand All @@ -36,11 +38,13 @@ import org.json.JSONException
import org.json.JSONObject
import statusbar.lyric.BuildConfig
import statusbar.lyric.R
import statusbar.lyric.config.Config
import statusbar.lyric.utils.Utils.isNotNull
import java.io.BufferedReader
import java.io.InputStreamReader
import java.net.URL


object ActivityUtils {
private val handler by lazy { Handler(Looper.getMainLooper()) }

Expand Down Expand Up @@ -148,30 +152,24 @@ object ActivityUtils {
bundle.putString("value", value)
message.data = bundle
handler.sendMessage(message)
}else {
} else {
if (ActivityOwnSP.ownSPConfig.getDebug()) showToastOnLooper(activity, activity.getString(R.string.GetNewNoticeError))
}
}.start()
}

fun getTips(activity: Activity) {
val handler = Handler(Looper.getMainLooper()) { message: Message ->

false
}
fun setMusicList(activity: Activity, config: Config) {
Thread {
val value: String? = getHttp("https://app.xiaowine.cc/app/updateTime.txt")
if (value.isNotNull()) {
val message = handler.obtainMessage()
val bundle = Bundle()
bundle.putString("value", value)
message.data = bundle
handler.sendMessage(message)
var str = ""
val mArray = activity.resources.getStringArray(R.array.need_module)
mArray.forEach {
str = "${it}|${str}"
}
config.setMusicList(str)
}.start()
}

fun getHttp(Url: String): String? {
private fun getHttp(Url: String): String? {
try {
val connection = URL(Url).openConnection() as java.net.HttpURLConnection
connection.requestMethod = "GET"
Expand Down
4 changes: 2 additions & 2 deletions app/src/main/java/statusbar/lyric/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -250,8 +250,8 @@ object Utils {
}

@JvmStatic
fun sendLyric(context: Context, lyric: String?, icon: String?, useSystemMusicActive: Boolean, packName: String?) {
context.sendBroadcast(Intent().apply {
fun sendLyric(context: Context?, lyric: String?, icon: String?, useSystemMusicActive: Boolean, packName: String?) {
context?.sendBroadcast(Intent().apply {
action = "Lyric_Server"
putExtra("Lyric_Data", lyric)
putExtra("Lyric_Type", "app")
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
<string name="CustomHook">* 自定义 Hook 点 (不懂勿动)</string>
<string name="CustomHookTips">部分Hook点\nmStatusClock mClockView mLeftClock mCenterClock mRightClock</string>
<string name="DebugMode">Debug 模式</string>
<string name="OnlyGetLyric">仅获取歌词</string>
<string name="OnlyGetLyric">* 仅获取歌词</string>
<string name="OnlyGetLyricTips">仅获取歌词而不显示在状态栏</string>
<string name="TimeOff">* 定时关闭</string>
<string name="TimeOffTime">定时关闭时长</string>
<string name="GetTitle">* 强制显示歌词标题</string>
<string name="TimeHide">* 定时隐藏歌词</string>
<string name="TimeHideTime">定时隐藏歌词时长</string>
<string name="GetTitle">* 强制显示音乐标题</string>
<string name="JudgementTitle">* 增强停止隐藏歌词</string>
<string name="ReStartSystemUI">重启 SystemUI</string>
<string name="ResetModule">重置模块</string>
<string name="About">关于</string>
Expand Down Expand Up @@ -61,7 +62,7 @@
- 小米音乐 4.6.0 ~ 4.11.1.0(车载蓝牙歌词模式)\n
- RPlayer 未知 ~ 现今(状态栏歌词模式)\n
- 洛雪音乐 未知 ~ 现今(API模式或桌面歌词模式)\n
- Apple Music 仅3.10.2\n\n
- Apple Music 3.10 ~ 4.0.0\n\n

没在此范围的版本不一定能使用,但在此范围的版本一定能使用
</string>
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,12 @@
<string name="CustomHook">* 自定義Hook點 (不懂勿動)</string>
<string name="CustomHookTips">部分Hook點\nmStatusClock mClockView mLeftClock mCenterClock mRightClock</string>
<string name="DebugMode">Debug 模式</string>
<string name="OnlyGetLyric">僅獲取歌詞</string>
<string name="OnlyGetLyric">* 僅獲取歌詞</string>
<string name="OnlyGetLyricTips">僅獲取歌詞而不顯示在狀態欄</string>
<string name="TimeOff">* 定時關閉</string>
<string name="TimeOffTime">定時關閉時長</string>
<string name="GetTitle">* 強制顯示歌詞標題</string>
<string name="TimeHide">* 定時隱藏歌詞</string>
<string name="TimeHideTime">定時隱藏歌詞時長</string>
<string name="GetTitle">* 強制顯示音樂標題</string>
<string name="JudgementTitle">* 增強停止隱藏歌詞</string>
<string name="ReStartSystemUI">重啟 SystemUI</string>
<string name="ResetModule">重置模塊</string>
<string name="About">關於</string>
Expand Down Expand Up @@ -61,7 +62,7 @@
- 小米音樂 4.6.0 ~ 4.11.1.0(車載藍牙歌詞模式)\n
- RPlayer 未知 ~ 現今(狀態欄歌詞模式)\n\n
- 洛雪音樂 未知 ~ 現今(API模式或桌面歌詞模式)\n
- Apple Music 僅3.10.2\n\n
- Apple Music 3.10 ~ 4.0.0\n\n

沒在次範圍的版本不一定能使用,但在次範圍的版本一定能使用
</string>
Expand Down
11 changes: 6 additions & 5 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
<string name="CustomHook">* Custom Hook (do not move if you don\'t understand)</string>
<string name="CustomHookTips">Some Hook Points\nmStatusClock mClockView mLeftClock mCenterClock mRightClock</string>
<string name="DebugMode">Debug mode</string>
<string name="OnlyGetLyric">Get lyrics only</string>
<string name="OnlyGetLyric">* Get lyrics only</string>
<string name="OnlyGetLyricTips">Get lyrics only without displaying them in the status bar</string>
<string name="TimeOff">* Time off</string>
<string name="TimeOffTime">Timed off time</string>
<string name="GetTitle">* Force the lyric title to appear</string>
<string name="TimeHide">* Time Hide lyric</string>
<string name="TimeHideTime">Timed Hide lyric time</string>
<string name="GetTitle">* Force the music title to appear</string>
<string name="JudgementTitle">* Enhanced stop hiding lyrics</string>
<string name="ReStartSystemUI">Restart SystemUI</string>
<string name="ResetModule">Reset module</string>
<string name="About">About</string>
Expand Down Expand Up @@ -62,7 +63,7 @@
- Mi Music 4.6.0 ~ 4.11.1.0 (car Bluetooth lyrics mode)\n
- RPlayer unknown ~ now (status bar lyrics mode)\n
- LX Music unknown ~ now(API mode or Desktop lyrics mode)\n
- Apple Music only 3.10.2\n\n
- Apple Music 3.10 ~ 4.0.0\n\n

Versions not in this range may not be available, but versions in this range will definitely work
</string>
Expand Down

0 comments on commit e96929b

Please sign in to comment.