From f4eea2a4e75f96a73842610d3e4f7a9eb87b9405 Mon Sep 17 00:00:00 2001 From: xiao_wine Date: Mon, 9 Jan 2023 21:25:23 +0800 Subject: [PATCH 1/5] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dapple=20music=E6=AD=8C?= =?UTF-8?q?=E8=AF=8D=E5=B9=BF=E6=92=AD=E5=8F=82=E6=95=B0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E6=97=A0=E6=B3=95=E6=98=BE=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/Android.yml | 4 ++-- app/src/main/java/statusbar/lyric/hook/app/AppleMusic.kt | 2 +- app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt | 4 ++-- app/src/main/java/statusbar/lyric/utils/Utils.kt | 4 ++-- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/Android.yml b/.github/workflows/Android.yml index 768de260..01e57b55 100644 --- a/.github/workflows/Android.yml +++ b/.github/workflows/Android.yml @@ -11,10 +11,10 @@ jobs: steps: - uses: actions/checkout@v2 - - name: set up JDK 11 + - name: set up JDK 17 uses: actions/setup-java@v2 with: - java-version: '11' + java-version: '17' distribution: 'adopt' cache: gradle diff --git a/app/src/main/java/statusbar/lyric/hook/app/AppleMusic.kt b/app/src/main/java/statusbar/lyric/hook/app/AppleMusic.kt index 282a9068..0ef34741 100644 --- a/app/src/main/java/statusbar/lyric/hook/app/AppleMusic.kt +++ b/app/src/main/java/statusbar/lyric/hook/app/AppleMusic.kt @@ -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 } } diff --git a/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt b/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt index 0cc92e9f..9f6afeb8 100644 --- a/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt +++ b/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt @@ -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) { diff --git a/app/src/main/java/statusbar/lyric/utils/Utils.kt b/app/src/main/java/statusbar/lyric/utils/Utils.kt index ffffb4d3..c2f337cf 100644 --- a/app/src/main/java/statusbar/lyric/utils/Utils.kt +++ b/app/src/main/java/statusbar/lyric/utils/Utils.kt @@ -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") From 05fc516ecf6e6013ea45e76771e7f6519d476b5f Mon Sep 17 00:00:00 2001 From: xiao_wine Date: Mon, 9 Jan 2023 21:40:21 +0800 Subject: [PATCH 2/5] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=EF=BC=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt b/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt index 9f6afeb8..b4086045 100644 --- a/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt +++ b/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt @@ -124,7 +124,7 @@ class SystemUI : BaseHook() { try { if (config.getLyricService()) { if (test) return - if (useSystemMusicActive) { + if (!useSystemMusicActive) { // offLyric(LogMultiLang.pausePlay) return } From efd1c37cb8c12feb1079e049964884f4a18c6de7 Mon Sep 17 00:00:00 2001 From: xiao_wine Date: Tue, 10 Jan 2023 12:24:03 +0800 Subject: [PATCH 3/5] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=8F=99=E8=BF=B0=20?= =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=8E=B7=E5=8F=96=E9=9F=B3=E4=B9=90=E6=A0=87?= =?UTF-8?q?=E9=A2=98=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lyric/activity/SettingsActivity.kt | 1 + .../java/statusbar/lyric/config/Config.kt | 7 +++++ .../java/statusbar/lyric/hook/app/SystemUI.kt | 16 +++++++----- .../statusbar/lyric/utils/ActivityUtils.kt | 26 +++++++++---------- app/src/main/res/values-zh-rCN/strings.xml | 4 +-- app/src/main/res/values-zh-rTW/strings.xml | 4 +-- app/src/main/res/values/strings.xml | 4 +-- 7 files changed, 35 insertions(+), 27 deletions(-) diff --git a/app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt b/app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt index c4f6f0ad..9c9b1136 100644 --- a/app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt +++ b/app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt @@ -1176,6 +1176,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}") diff --git a/app/src/main/java/statusbar/lyric/config/Config.kt b/app/src/main/java/statusbar/lyric/config/Config.kt index 84f54c67..52b72241 100644 --- a/app/src/main/java/statusbar/lyric/config/Config.kt +++ b/app/src/main/java/statusbar/lyric/config/Config.kt @@ -351,6 +351,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) diff --git a/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt b/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt index b4086045..6ce843d4 100644 --- a/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt +++ b/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt @@ -243,13 +243,15 @@ class SystemUI : BaseHook() { 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 - 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.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) + } } } } diff --git a/app/src/main/java/statusbar/lyric/utils/ActivityUtils.kt b/app/src/main/java/statusbar/lyric/utils/ActivityUtils.kt index ee070db1..2a423fd6 100644 --- a/app/src/main/java/statusbar/lyric/utils/ActivityUtils.kt +++ b/app/src/main/java/statusbar/lyric/utils/ActivityUtils.kt @@ -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 @@ -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()) } @@ -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" diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index 255a928b..d2ed6520 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -32,7 +32,7 @@ 仅获取歌词而不显示在状态栏 * 定时关闭 定时关闭时长 - * 强制显示歌词标题 + * 强制显示音乐标题 重启 SystemUI 重置模块 关于 @@ -61,7 +61,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 没在此范围的版本不一定能使用,但在此范围的版本一定能使用 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index 8c876374..d698702a 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -32,7 +32,7 @@ 僅獲取歌詞而不顯示在狀態欄 * 定時關閉 定時關閉時長 - * 強制顯示歌詞標題 + * 強制顯示音樂標題 重啟 SystemUI 重置模塊 關於 @@ -61,7 +61,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 沒在次範圍的版本不一定能使用,但在次範圍的版本一定能使用 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e088081c..dba15366 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -33,7 +33,7 @@ Get lyrics only without displaying them in the status bar * Time off Timed off time - * Force the lyric title to appear + * Force the music title to appear Restart SystemUI Reset module About @@ -62,7 +62,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 From 43d7cf0215fad4590623ef2c13577131d98a24e9 Mon Sep 17 00:00:00 2001 From: xiao_wine Date: Tue, 10 Jan 2023 15:23:33 +0800 Subject: [PATCH 4/5] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E5=81=9C=E6=AD=A2?= =?UTF-8?q?=E9=9A=90=E8=97=8F=E6=AD=8C=E8=AF=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../lyric/activity/SettingsActivity.kt | 7 +++-- .../java/statusbar/lyric/config/Config.kt | 3 ++ .../java/statusbar/lyric/hook/app/SystemUI.kt | 28 +++++++++++-------- app/src/main/res/values-zh-rCN/strings.xml | 7 +++-- app/src/main/res/values-zh-rTW/strings.xml | 7 +++-- app/src/main/res/values/strings.xml | 7 +++-- 6 files changed, 35 insertions(+), 24 deletions(-) diff --git a/app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt b/app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt index 9c9b1136..4fda94d1 100644 --- a/app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt +++ b/app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt @@ -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) { diff --git a/app/src/main/java/statusbar/lyric/config/Config.kt b/app/src/main/java/statusbar/lyric/config/Config.kt index 52b72241..dda925f8 100644 --- a/app/src/main/java/statusbar/lyric/config/Config.kt +++ b/app/src/main/java/statusbar/lyric/config/Config.kt @@ -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) diff --git a/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt b/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt index 6ce843d4..2de109b8 100644 --- a/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt +++ b/app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt @@ -240,15 +240,19 @@ 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 - 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 + + "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 + if (config.getJudgementTitle()) { + offLyric("test") + } + if (config.getGetTitle()) { isFirstEntry = true Utils.sendLyric(mContext, lsatName, icon) } @@ -264,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 { @@ -285,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 @@ -295,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 diff --git a/app/src/main/res/values-zh-rCN/strings.xml b/app/src/main/res/values-zh-rCN/strings.xml index d2ed6520..20dfa4de 100644 --- a/app/src/main/res/values-zh-rCN/strings.xml +++ b/app/src/main/res/values-zh-rCN/strings.xml @@ -28,11 +28,12 @@ * 自定义 Hook 点 (不懂勿动) 部分Hook点\nmStatusClock mClockView mLeftClock mCenterClock mRightClock Debug 模式 - 仅获取歌词 + * 仅获取歌词 仅获取歌词而不显示在状态栏 - * 定时关闭 - 定时关闭时长 + * 定时隐藏歌词 + 定时隐藏歌词时长 * 强制显示音乐标题 + * 增强停止隐藏歌词 重启 SystemUI 重置模块 关于 diff --git a/app/src/main/res/values-zh-rTW/strings.xml b/app/src/main/res/values-zh-rTW/strings.xml index d698702a..9c0ae511 100644 --- a/app/src/main/res/values-zh-rTW/strings.xml +++ b/app/src/main/res/values-zh-rTW/strings.xml @@ -28,11 +28,12 @@ * 自定義Hook點 (不懂勿動) 部分Hook點\nmStatusClock mClockView mLeftClock mCenterClock mRightClock Debug 模式 - 僅獲取歌詞 + * 僅獲取歌詞 僅獲取歌詞而不顯示在狀態欄 - * 定時關閉 - 定時關閉時長 + * 定時隱藏歌詞 + 定時隱藏歌詞時長 * 強制顯示音樂標題 + * 增強停止隱藏歌詞 重啟 SystemUI 重置模塊 關於 diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dba15366..78b17976 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -29,11 +29,12 @@ * Custom Hook (do not move if you don\'t understand) Some Hook Points\nmStatusClock mClockView mLeftClock mCenterClock mRightClock Debug mode - Get lyrics only + * Get lyrics only Get lyrics only without displaying them in the status bar - * Time off - Timed off time + * Time Hide lyric + Timed Hide lyric time * Force the music title to appear + * Enhanced stop hiding lyrics Restart SystemUI Reset module About From 2620786436807f177e68669975664516283e06b1 Mon Sep 17 00:00:00 2001 From: xiao_wine Date: Tue, 10 Jan 2023 15:50:17 +0800 Subject: [PATCH 5/5] 5.4.2 --- app/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/build.gradle.kts b/app/build.gradle.kts index 1b6852fd..ad0354e7 100644 --- a/app/build.gradle.kts +++ b/app/build.gradle.kts @@ -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\"")