Skip to content

Commit

Permalink
# 5.3.2
Browse files Browse the repository at this point in the history
- 修复 调整歌词位置异常
- 修复 尝试修复部分情况不会隐藏歌词
- 修复 部分Android13无法使用
- 添加 仅获取歌词功能
- 添加 图标歌词间隔
- 添加 定时关闭功能
- 添加 歌词/图标透明度
- 添加 遗忘的酷我图标设置
- 添加 插件支持
---
- Fix the abnormal position of lyrics adjustment
- Fix Try to fix some cases that the lyrics will not be hidden
- Fix some Android13 can't be used
- Add only get lyrics function
- Added icon lyrics interval
- Add timer shutdown function
- Added lyrics/icon transparency
- Added Forgotten Cool Me icon setting
- Add plugin support
  • Loading branch information
xiaowine committed Jul 20, 2022
2 parents d03ddc9 + 1b2533c commit e322125
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 133 deletions.
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "blockmiui"]
path = blockmiui
url = https://github.com/577fkj/blockmiui.git

[submodule "xtoast"]
path = xtoast
url = https://github.com/Wine-Network/xToast
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

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 = 32
versionCode = 161
versionName = "5.3.1"
versionCode = 162
versionName = "5.3.2"
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
buildConfigField("String", "BUILD_TIME", "\"$buildTime\"")
Expand Down
207 changes: 115 additions & 92 deletions app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt

Large diffs are not rendered by default.

36 changes: 35 additions & 1 deletion app/src/main/java/statusbar/lyric/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,14 @@ class Config {
config.put("IHigh", i)
}

fun getIconspacing(): Int {
return config.optInt("ISpacing", 5)
}

fun setIconspacing(i: Int) {
config.put("ISpacing", i)
}

fun getLyricAutoOff(): Boolean {
return config.optBoolean("LAutoOff", true)
}
Expand All @@ -128,6 +136,7 @@ class Config {
fun setIconColor(str: String) {
config.put("IColor", str)
}

fun getBackgroundColor(): String {
return config.optString("BackgroundColor", "")
}
Expand Down Expand Up @@ -264,10 +273,35 @@ class Config {
config.put("LyricAutoOffTime", i)
}

fun getTimeOff(): Boolean {
return config.optBoolean("TimeOff", false)
}

fun setTimeOff(bool: Boolean) {
config.put("TimeOff", bool)
}


fun getTimeOffTime(): Int {
return config.optInt("TimeOffTime", 10000)
}

fun setTimeOffTime(i: Int) {
config.put("TimeOffTime", i)
}

fun getAntiBurnTime(): Int {
return config.optInt("AntiBurnTime", 60000)
}

fun setOnlyGetLyric(b: Boolean) {
config.put("OnlyGetLyric", b)
}

fun getOnlyGetLyric(): Boolean {
return config.optBoolean("OnlyGetLyric", false)
}

fun setAntiBurnTime(i: Int) {
config.put("AntiBurnTime", i)
}
Expand Down Expand Up @@ -315,7 +349,7 @@ class Config {
}

fun gerIconList(): Array<String> {
return arrayOf("Netease", "KuGou", "KuGouLite", "QQMusic", "Myplayer", "MiGu", "MiPlayer", "Default")
return arrayOf("Netease", "KuGou", "KuGouLite", "KuWo", "QQMusic", "Myplayer", "MiGu", "MiPlayer", "Default")
}

fun getIcon(str: String): String {
Expand Down
104 changes: 75 additions & 29 deletions app/src/main/java/statusbar/lyric/hook/app/SystemUI.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ import kotlin.system.exitProcess

class SystemUI : BaseHook() {
private val lyricKey = "lyric"
private var lyrics = "lyric"
var texts = ""
var musicServer: ArrayList<String> = arrayListOf("com.kugou", "com.netease.cloudmusic", "com.tencent.qqmusic.service", "cn.kuwo", "remix.myplayer", "cmccwm.mobilemusic", "com.meizu.media.music", "com.tencent.qqmusicplayerprocess.service.QQPlayerServiceNew")

// base data
Expand Down Expand Up @@ -116,11 +118,15 @@ class SystemUI : BaseHook() {
try {
if (config.getLyricService()) {
if (test) return
if (Utils.isServiceRunningList(application, musicServer)) {
if (useSystemMusicActive && !audioManager.isMusicActive) {
offLyric(LogMultiLang.pausePlay)
}
} else {
if (useSystemMusicActive && !audioManager.isMusicActive) {
offLyric(LogMultiLang.pausePlay)
return
}
if (!audioManager.isMusicActive) {
offLyric(LogMultiLang.pausePlay)
return
}
if (!Utils.isServiceRunningList(application, musicServer)) {
offLyric(LogMultiLang.playerOff)
}
} else {
Expand Down Expand Up @@ -158,13 +164,12 @@ class SystemUI : BaseHook() {
var i = 1
var order = true
var iconPos = 0

override fun run() {
iconPos = config.getLyricPosition()
if (order) i += 1 else i -= 1
updateMargins.sendMessage(updateMargins.obtainMessage().also {
it.arg1 = 10 + i
it.arg2 = 0
it.obj = 10 + i
// it.arg2 = config.getLyricHigh()
})
if (i == 0) order = true else if (i == 20) order = false
}
Expand All @@ -173,6 +178,23 @@ class SystemUI : BaseHook() {
return lyricAntiBurnTimer as TimerTask
}

private var timeOffTimer: TimerTask? = null
private fun getTimeOffTimer(): TimerTask {
if (timeOffTimer == null) {
timeOffTimer = object : TimerTask() {
override fun run() {
if (texts == lyrics) {
offLyric(LogMultiLang.TimeOff)
}
texts = lyrics
// text = lyrics
}
}

}
return timeOffTimer as TimerTask
}

private val lockScreenReceiver by lazy { LockScreenReceiver() }
private val lyricReceiver by lazy { LyricReceiver() }

Expand All @@ -182,6 +204,8 @@ class SystemUI : BaseHook() {

override fun hook() {
super.hook()
// Only get lyric

if (config.getUseSystemReverseColor()) systemReverseColor() // use system reverse color

// StatusBarLyric
Expand Down Expand Up @@ -221,19 +245,24 @@ class SystemUI : BaseHook() {
null
}
} else {
val apkInfo = IPackageUtils.getPackageInfoFromAllUsers("com.yeren.ZPTools", 0)
LogUtils.e("apkList: $apkInfo")
val array = if (apkInfo.isNotEmpty()) {
LogUtils.e(LogMultiLang.checkSystem)
if (Settings.System.getInt(application.contentResolver, "clock_style", 0) == 0) {
LogUtils.e("mClockView start")
arrayOf("mClockView", "mStatusClock", "mCenterClock", "mLeftClock", "mRightClock")
val array = try {
val apkInfo = IPackageUtils.getPackageInfoFromAllUsers("com.yeren.ZPTools", 0)
LogUtils.e("apkList: $apkInfo")
if (apkInfo.isNotEmpty()) {
LogUtils.e(LogMultiLang.checkSystem)
if (Settings.System.getInt(application.contentResolver, "clock_style", 0) == 0) {
LogUtils.e("mClockView start")
arrayOf("mClockView", "mStatusClock", "mCenterClock", "mLeftClock", "mRightClock")
} else {
LogUtils.e("mStatusClock start")
arrayOf("mStatusClock", "mClockView", "mCenterClock", "mLeftClock", "mRightClock")
}
} else {
LogUtils.e("mStatusClock start")
arrayOf("mStatusClock", "mClockView", "mCenterClock", "mLeftClock", "mRightClock")
LogUtils.e(LogMultiLang.normalMode)
arrayOf("mClockView", "mStatusClock", "mCenterClock", "mLeftClock", "mRightClock")
}
} else {
LogUtils.e(LogMultiLang.normalMode)
} catch (e: Throwable) {
LogUtils.e("getPackageInfoError: $e \n" + Log.getStackTraceString(e))
arrayOf("mClockView", "mStatusClock", "mCenterClock", "mLeftClock", "mRightClock")
}
var thisField: Field? = null
Expand Down Expand Up @@ -261,6 +290,7 @@ class SystemUI : BaseHook() {
}

private fun lyricInit(clock: TextView?) {

LogUtils.e(LogMultiLang.sendLog)

application.sendBroadcast(Intent().apply {
Expand All @@ -285,6 +315,11 @@ class SystemUI : BaseHook() {

audioManager = application.getSystemService(Context.AUDIO_SERVICE) as AudioManager // audioManager

if (config.getOnlyGetLyric()) {
LogUtils.e(LogMultiLang.OnlyGetLyric)
return
}

// Get display info
val displayMetrics = DisplayMetrics()
(application.getSystemService(Context.WINDOW_SERVICE) as WindowManager).defaultDisplay.getMetrics(displayMetrics)
Expand Down Expand Up @@ -322,7 +357,7 @@ class SystemUI : BaseHook() {
lyricSwitchView = LyricSwitchView(application, config.getLyricStyle()).apply {
height = clock.height
setTextSize(TypedValue.COMPLEX_UNIT_SHIFT, if (config.getLyricSize() == 0) clock.textSize else config.getLyricSize().toFloat())
setMargins(config.getLyricPosition() + 10, config.getLyricHigh(), 0, 0)
setMargins(0, config.getLyricHigh(), 0, 0)
setMarqueeRepeatLimit(if (config.getLyricStyle()) 1 else -1)
setSingleLine(true)
setMaxLines(1)
Expand All @@ -349,7 +384,7 @@ class SystemUI : BaseHook() {

// 创建图标
iconView = ImageView(application).apply {
layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT).also { it.setMargins(0, 7, 0, 0) }
layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT).also { it.setMargins(0, 7, config.getIconspacing(), 0) }
}

// 创建布局
Expand Down Expand Up @@ -398,12 +433,13 @@ class SystemUI : BaseHook() {
}

updateMargins = Handler(Looper.getMainLooper()) { message ->
(lyricLayout.layoutParams as LinearLayout.LayoutParams).setMargins(message.arg1, message.arg2, 0, 0)
// (lyricLayout.layoutParams as LinearLayout.LayoutParams).setMargins(message.arg1, message.arg2, 0, 0)
(lyricLayout.layoutParams as LinearLayout.LayoutParams).leftMargin = message.obj as Int
true
}

updateIconMargins = Handler(Looper.getMainLooper()) { message ->
(iconView.layoutParams as LinearLayout.LayoutParams).setMargins(0, message.arg1, 0, 0)
(iconView.layoutParams as LinearLayout.LayoutParams).setMargins(message.arg1, message.arg2, config.getIconspacing(), 0)
true
}

Expand Down Expand Up @@ -534,11 +570,11 @@ class SystemUI : BaseHook() {
})
} else iconColor = 0
updateMargins.sendMessage(updateMargins.obtainMessage().also {
it.arg1 = config.getLyricPosition()
it.arg2 = config.getLyricHigh()
it.obj = config.getLyricHigh()
})
updateIconMargins.sendMessage(updateMargins.obtainMessage().also {
it.arg1 = config.getIconHigh()
updateIconMargins.sendMessage(updateIconMargins.obtainMessage().also {
it.arg1 = config.getLyricPosition()
it.arg2 = config.getIconHigh()
})
if (config.getIconSize() != 0) {
(iconView.layoutParams as LinearLayout.LayoutParams).apply { // set icon size
Expand All @@ -564,9 +600,14 @@ class SystemUI : BaseHook() {
LogUtils.e(info)
stopTimer()
if (lyricLayout.visibility != View.GONE && config.getLyricAutoOff()) offLyric.sendEmptyMessage(0)
application.sendBroadcast(Intent().apply {
action = "Lyric_Server"
putExtra("Lyric_Type", "stop")
})
}

fun updateLyric(lyric: String, icon: String) {
lyrics = lyric
LogUtils.e(LogMultiLang.sendLog)
if (lyric.isEmpty()) {
offLyric(LogMultiLang.emptyLyric)
Expand Down Expand Up @@ -602,7 +643,7 @@ class SystemUI : BaseHook() {
if (config.getLyricAutoOff()) startTimer(config.getLyricAutoOffTime().toLong(), getAutoOffLyricTimer()) // auto off lyric
if (config.getAntiBurn()) startTimer(config.getAntiBurnTime().toLong(), getLyricAntiBurnTimer()) // Anti burn screen
if (!config.getUseSystemReverseColor()) startTimer(config.getReverseColorTime().toLong(), getAutoLyricColorTimer()) // not use system reverse color

if (config.getTimeOff()) startTimer(config.getTimeOffTime().toLong(), getTimeOffTimer()) // not use system reverse color
if (config.getAnim() == "random") {
val anim = arrayOf("top", "lower", "left", "right")[(Math.random() * 4).toInt()]
lyricSwitchView.inAnimation = Utils.inAnim(anim)
Expand All @@ -628,6 +669,7 @@ class SystemUI : BaseHook() {
autoOffLyricTimer = null
autoLyricColorTimer = null
lyricAntiBurnTimer = null
timeOffTimer = null
timerQueue = arrayListOf()
timer?.cancel()
timer = null
Expand Down Expand Up @@ -690,11 +732,12 @@ class SystemUI : BaseHook() {
var icon = intent.getStringExtra("Lyric_Icon")
when (intent.getStringExtra("Lyric_Type")) {
"hook" -> {
val lyric: String = intent.getStringExtra("Lyric_Data")!!
val lyric = intent.getStringExtra("Lyric_Data") ?: ""
LogUtils.e("${LogMultiLang.recvData}hook: lyric:$lyric icon:$icon")
updateLyric(lyric, icon ?: "Api")
useSystemMusicActive = true
}

"app" -> {
if (icon.isNullOrEmpty()) icon = "Api"
val packName = intent.getStringExtra("Lyric_PackName")
Expand All @@ -707,6 +750,7 @@ class SystemUI : BaseHook() {
updateLyric(lyric ?: "", icon)
LogUtils.e("${LogMultiLang.recvData}app: lyric:$lyric icon:$icon packName:$packName")
}

"app_stop" -> offLyric("${LogMultiLang.recvData}app_stop")
"copy_font" -> {
val path = intent.getStringExtra("Font_Path")
Expand Down Expand Up @@ -741,6 +785,7 @@ class SystemUI : BaseHook() {
})
}
}

"delete_font" -> {
var isOK = false
val file = File(application.filesDir.path + "/font")
Expand All @@ -753,6 +798,7 @@ class SystemUI : BaseHook() {
putExtra("DeleteFont", isOK)
})
}

"update_config" -> updateConfig()
"test" -> ShowDialog().show()
}
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/java/statusbar/lyric/utils/LogMultiLang.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,7 @@ object LogMultiLang {
val sendLog = if (isChinese) "反馈日志请不要截图,Lsp右上角保存成文件反馈" else "Please do not take screenshots of the feedback log, save it as a file feedback in the upper right corner of the Lsp"
val initError = if (isChinese) "初始化失败" else "Init failed"
val initFontFailed = if (isChinese) "初始化自定义字体失败" else "Init custom font failed"
val OnlyGetLyric = if (isChinese) "仅获取歌词" else "Get lyrics only"
val TimeOff = if (isChinese) "歌词定时关闭" else "Lyrics timer off"
// val _ = if (isChinese) "" else ""
}
9 changes: 7 additions & 2 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@
<string name="Off">关闭</string>
<string name="LyricAutoMaxWidth">歌词自适应最大宽度</string>
<string name="LyricsAnimation">歌词动效</string>
<string name="LyricColor">歌词颜色</string>
<string name="LyricColor">歌词颜色和透明度</string>
<string name="BackgroundColor">背景颜色</string>
<string name="IconColor">图标颜色</string>
<string name="IconColor">图标颜色和透明度</string>
<string name="LyricIcon">歌词图标</string>
<string name="LyricSpeed">歌词滚动速度</string>
<string name="AdvancedSettings">高级设置</string>
<string name="ClickLyric">* 点击歌词切换时钟和歌词</string>
<string name="AbScreen">* 防烧屏</string>
<string name="IconHigh">图标上下位置</string>
<string name="IconSpacing">图标歌词间隔</string>
<string name="LyricPos">歌词左右位置</string>
<string name="Default">默认</string>
<string name="UnlockShow">仅解锁显示</string>
Expand All @@ -26,6 +27,9 @@
<string name="AutoHideCarrierName">自动隐藏锁屏运营商名称</string>
<string name="CustomHook">* 自定义 Hook 点 (不懂勿动)</string>
<string name="DebugMode">Debug 模式</string>
<string name="OnlyGetLyric">仅获取歌词</string>
<string name="TimeOff">* 定时关闭</string>
<string name="TimeOffTime">定时关闭时长</string>
<string name="ReStartSystemUI">重启 SystemUI</string>
<string name="ResetModule">重置模块</string>
<string name="About">关于</string>
Expand Down Expand Up @@ -73,6 +77,7 @@
<string name="InputError">输入范围不正确!</string>
<string name="LyricPosTips">-900~900(单位:像素点)</string>
<string name="LyricHighTips">-100~100(单位:像素)</string>
<string name="IconSpacingTips">0~20(单位:像素)</string>
<string name="Ok">确定</string>
<string name="HookSetTips">已设置 Hook 为:\n</string>
<string name="RestartSystemUI">请重启 SystemUI</string>
Expand Down
Loading

0 comments on commit e322125

Please sign in to comment.