Skip to content

Commit

Permalink
Merge pull request #180 from Block-Network/Dev
Browse files Browse the repository at this point in the history
## 5.2.5
- 添加 歌词大小动态更新
- 添加 自定义图标动态更新
- 添加 自定义文字
- 修复 歌词动效异常
- 修复 设置歌词位置无效
- 修复 点击切换歌词暂停后依然能点击
- 优化 代码
  • Loading branch information
xiaowine authored Apr 9, 2022
2 parents 6bfef8e + 2e4d2ce commit cbde09b
Show file tree
Hide file tree
Showing 10 changed files with 162 additions and 49 deletions.
13 changes: 12 additions & 1 deletion .github/workflows/Android_Dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ jobs:
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_STORE_PASSWORD }}

- name: Sign Release AAB
if: success()
id: sign_release_aab
uses: r0adkll/[email protected]
with:
releaseDirectory: ./app/build/outputs/bundle/release/
signingKeyBase64: ${{ secrets.SIGNING_KEY }}
alias: xiao_wine
keyStorePassword: ${{ secrets.KEY_STORE_PASSWORD }}
keyPassword: ${{ secrets.KEY_STORE_PASSWORD }}

- name: Upload Release APK
uses: actions/upload-artifact@v2
with:
Expand All @@ -74,7 +85,7 @@ jobs:
uses: actions/upload-artifact@v2
with:
name: StatusBarLyric_aab
path: ./app/build/outputs/bundle/release/app-release.aab
path: ${{ steps.sign_release_aab.outputs.signedReleaseFile }}

- name: Upload Debug APK
uses: actions/upload-artifact@v2
Expand Down
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 = 147
versionName = "5.0.0"
versionCode = 157
versionName = "5.2.5"
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
}
Expand Down
73 changes: 53 additions & 20 deletions app/src/main/java/statusbar/lyric/activity/SettingsActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ import android.os.Build
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.util.Log
import android.view.View
import android.widget.ImageView
import android.widget.LinearLayout
import cn.fkj233.ui.activity.MIUIActivity
import cn.fkj233.ui.activity.view.*
import cn.fkj233.ui.dialog.MIUIDialog
Expand All @@ -51,6 +51,7 @@ import statusbar.lyric.BuildConfig
import statusbar.lyric.R
import statusbar.lyric.config.IconConfig
import statusbar.lyric.utils.*
import statusbar.lyric.utils.Utils.indexOfArr
import java.util.*
import kotlin.system.exitProcess

Expand Down Expand Up @@ -368,14 +369,14 @@ class SettingsActivity : MIUIActivity() {
}.show()
})
SeekBarWithText("LSpacing", 0, 200)
val dict: HashMap<String, String> = hashMapOf()
dict["off"] = getString(R.string.Off)
dict["top"] = getString(R.string.top)
dict["lower"] = getString(R.string.lower)
dict["left"] = getString(R.string.left)
dict["right"] = getString(R.string.right)
dict["random"] = getString(R.string.random)
TextWithSpinner(TextV(resId = R.string.LyricsAnimation), SpinnerV(dict[ActivityOwnSP.ownSPConfig.getAnim()]!!) {
val aDicts: HashMap<String, String> = hashMapOf()
aDicts["off"] = getString(R.string.Off)
aDicts["top"] = getString(R.string.top)
aDicts["lower"] = getString(R.string.lower)
aDicts["left"] = getString(R.string.left)
aDicts["right"] = getString(R.string.right)
aDicts["random"] = getString(R.string.random)
TextWithSpinner(TextV(resId = R.string.LyricsAnimation), SpinnerV(aDicts[ActivityOwnSP.ownSPConfig.getAnim()]!!) {
add(getString(R.string.Off)) { ActivityOwnSP.ownSPConfig.setAnim("off") }
add(getString(R.string.top)) { ActivityOwnSP.ownSPConfig.setAnim("top") }
add(getString(R.string.lower)) { ActivityOwnSP.ownSPConfig.setAnim("lower") }
Expand Down Expand Up @@ -420,6 +421,37 @@ class SettingsActivity : MIUIActivity() {
}.show()
}, dataBindingRecv = meiZuStyle.binding.getRecv(2))
SeekBarWithText("LSpeed", 0, 200, defaultProgress = 100, dataBindingRecv = meiZuStyle.binding.getRecv(2))
val lDict: HashMap<String, String> = hashMapOf()
lDict["first"] = getString(R.string.First)
lDict["latest"] = getString(R.string.Latest)
TextWithSpinner(TextV(resId = R.string.LyricViewPosition), SpinnerV(lDict[ActivityOwnSP.ownSPConfig.getLyricViewPosition()]!!) {
add(getString(R.string.First)) { ActivityOwnSP.ownSPConfig.setLyricViewPosition("first") }
add(getString(R.string.Latest)) { ActivityOwnSP.ownSPConfig.setLyricViewPosition("latest") }
})
val cDict: HashMap<String, String> = hashMapOf()
cDict["first"] = getString(R.string.First)
cDict["latest"] = getString(R.string.Latest)
TextWithSpinner(TextV(resId = R.string.CustomizePosition), SpinnerV(cDict[ActivityOwnSP.ownSPConfig.getCustomizeViewPosition()]!!) {
add(getString(R.string.First)) { ActivityOwnSP.ownSPConfig.setCustomizeViewPosition("first") }
add(getString(R.string.Latest)) { ActivityOwnSP.ownSPConfig.setCustomizeViewPosition("latest") }
})
TextSummaryArrow(TextSummaryV(textId = R.string.CustomizeText, onClickListener = {
MIUIDialog(activity) {
setTitle(R.string.CustomizeText)
setEditText(ActivityOwnSP.ownSPConfig.getCustomizeText(),"")
setRButton(R.string.Ok) {
try {
val value = getEditText()
ActivityOwnSP.ownSPConfig.setCustomizeText(value)
} catch (_: Throwable) {
}
dismiss()
}
setLButton(R.string.Cancel) {
dismiss()
}
}.show()
}))
TextSummaryArrow(TextSummaryV(textId = R.string.CustomFont, onClickListener = {
MIUIDialog(activity) {
setTitle(R.string.CustomFont)
Expand Down Expand Up @@ -523,7 +555,14 @@ class SettingsActivity : MIUIActivity() {

register("icon", getString(R.string.IconSettings), true) {
val iconConfig = Utils.getSP(activity, "Icon_Config")?.let { IconConfig(it) }
for (icon in arrayOf("Netease", "KuGou", "QQMusic", "Myplayer", "MiGu", "MiPlayer", "Default")) {
val iconList = arrayOf("Netease", "KuGou", "QQMusic", "Myplayer", "MiGu", "MiPlayer", "Default")
val iconDataBinding = GetDataBinding("") { view, i, any ->
if ((any as String).isNotEmpty()) {
val iconData = any.split("|%|")
if (iconList[i] == iconData[0]) ((view as LinearLayout).getChildAt(0) as RoundCornerImageView).background = BitmapDrawable(Utils.stringToBitmap(if (iconData[1] == "") iconConfig?.getIcon(iconData[0]) else iconData[1])).also { it.setTint(getColor(R.color.customIconColor)) }
}
}
for (icon in iconList) {
Author(BitmapDrawable(Utils.stringToBitmap(iconConfig?.getIcon(icon))).also { it.setTint(getColor(R.color.customIconColor)) }, icon, round = 0f, onClick = {
MIUIDialog(activity) {
setTitle(icon)
Expand All @@ -532,7 +571,8 @@ class SettingsActivity : MIUIActivity() {
setRButton(R.string.Ok) {
if (getEditText().isNotEmpty()) {
try {
iconConfig?.setIcon(icon, getEditText())
iconConfig?.setIcon(icon, getEditText().replace(" ", "").replace("\n", ""))
iconDataBinding.bindingSend.send("$icon|%|${getEditText().replace(" ", "").replace("\n", "")}")
updateConfig = true
dismiss()
return@setRButton
Expand All @@ -541,13 +581,14 @@ class SettingsActivity : MIUIActivity() {
}
ActivityUtils.showToastOnLooper(activity, getString(R.string.InputError))
iconConfig?.setIcon(icon, iconConfig.getDefaultIcon(icon))
iconDataBinding.bindingSend.send("$icon|%|")
ActivityUtils.showToastOnLooper(activity, getString(R.string.InputError))
updateConfig = true
dismiss()
}
setLButton(R.string.Cancel) { dismiss() }
}.show()
})
}, dataBindingRecv = iconDataBinding.binding.getRecv(iconList.indexOfArr(icon)))
}
TextSummaryArrow(TextSummaryV(textId = R.string.MakeIcon, onClickListener = {
val componentName = ComponentName("com.byyoung.setting", "com.byyoung.setting.MediaFile.activitys.ImageBase64Activity")
Expand Down Expand Up @@ -681,13 +722,6 @@ class SettingsActivity : MIUIActivity() {
TextWithSwitch(TextV(resId = R.string.AutoHideNotiIcon), SwitchV("HNoticeIcon"))
TextWithSwitch(TextV(resId = R.string.HideNetWork), SwitchV("HNetSpeed"))
TextWithSwitch(TextV(resId = R.string.AutoHideCarrierName), SwitchV("HCuk"))
val dict: HashMap<String, String> = hashMapOf()
dict["first"] = getString(R.string.First)
dict["latest"] = getString(R.string.Latest)
TextWithSpinner(TextV(resId = R.string.ViewPosition), SpinnerV(dict[ActivityOwnSP.ownSPConfig.getViewPosition()]!!) {
add(getString(R.string.First)) { ActivityOwnSP.ownSPConfig.setViewPosition("first") }
add(getString(R.string.Latest)) { ActivityOwnSP.ownSPConfig.setViewPosition("latest") }
})
Text(resId = R.string.DelayedLoading, onClickListener = {
MIUIDialog(activity) {
setTitle(R.string.DelayedLoading)
Expand Down Expand Up @@ -812,7 +846,6 @@ class SettingsActivity : MIUIActivity() {
}
OPEN_FONT_FILE -> {
data.data?.let {
Log.e("Lyric_Server", data.data?.toString().toString())
activity.sendBroadcast(Intent().apply {
action = "Lyric_Server"
putExtra("Lyric_Type", "copy_font")
Expand Down
22 changes: 18 additions & 4 deletions app/src/main/java/statusbar/lyric/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -192,13 +192,27 @@ class Config {
fun setAnim(str: String) {
config.put("Anim", str)
}
fun getCustomizeText(): String {
return config.optString("CustomizeText", "")
}

fun setCustomizeText(str: String) {
config.put("CustomizeText", str)
}

fun getViewPosition(): String {
return config.optString("ViewPosition", "first")
fun getLyricViewPosition(): String {
return config.optString("LyricViewPosition", "first")
}

fun setLyricViewPosition(str: String) {
config.put("LyricViewPosition", str)
}
fun getCustomizeViewPosition(): String {
return config.optString("CustomizeViewPositio", "first")
}

fun setViewPosition(str: String) {
config.put("ViewPosition", str)
fun setCustomizeViewPosition(str: String) {
config.put("CustomizeViewPositio", str)
}

fun getHook(): String {
Expand Down
62 changes: 52 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 @@ -73,6 +73,7 @@ class SystemUI : BaseHook() {
// base data
lateinit var application: Application
lateinit var clock: TextView
private lateinit var customizeView: TextView
lateinit var lyricSwitchView: LyricSwitchView
private lateinit var iconView: ImageView
private lateinit var lyricLayout: LinearLayout
Expand Down Expand Up @@ -286,11 +287,36 @@ class SystemUI : BaseHook() {

clockParams = clock.layoutParams as LinearLayout.LayoutParams

customizeView = TextView(application).apply {
height = clock.height
visibility = View.VISIBLE
text = config.getCustomizeText()
setTextSize(TypedValue.COMPLEX_UNIT_SHIFT, if (config.getLyricSize() == 0) clock.textSize else config.getLyricSize().toFloat())
isSingleLine = true
try {
val file = File(application.filesDir.path + "/font")
if (file.exists() && file.isFile && file.canRead()) {
typeface = Typeface.createFromFile(application.filesDir.path + "/font")
LogUtils.e(LogMultiLang.fontLoad)
} else {
typeface = clock.typeface
}
} catch (e: Throwable) {
typeface = clock.typeface
runCatching {
val file = File(application.filesDir.path + "/font")
if (file.exists() && file.canWrite()) {
file.delete()
}
}
LogUtils.e("${LogMultiLang.initFontFailed}(${e.message}): ${Log.getStackTraceString(e)}")
}
}
lyricSwitchView = LyricSwitchView(application, config.getLyricStyle()).apply {
width = (displayWidth * 35) / 100
height = clock.height
setTextSize(TypedValue.COMPLEX_UNIT_SHIFT, if (config.getLyricSize() == 0) clock.textSize else config.getLyricSize().toFloat())
setMargins(10, 0, 0, 0)
setMargins(config.getLyricPosition() + 10, config.getLyricHigh(), 0, 0)
setMarqueeRepeatLimit(if (config.getLyricStyle()) 1 else -1)
setSingleLine(true)
setMaxLines(1)
Expand Down Expand Up @@ -325,7 +351,15 @@ class SystemUI : BaseHook() {
lyricLayout = LinearLayout(application).apply {
layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT).also { it.setMargins(config.getLyricPosition(), config.getLyricHigh(), 0, 0) }
addView(iconView)
addView(lyricSwitchView)
if (config.getCustomizeViewPosition() == "first") {
addView(customizeView)
addView(lyricSwitchView)
} else {
addView(lyricSwitchView)
addView(customizeView)
}


}

clockClickable = clock.isClickable
Expand All @@ -340,8 +374,7 @@ class SystemUI : BaseHook() {
showLyric = false
clock.setOnClickListener { // 歌词显示
lyricLayout.visibility = View.VISIBLE // 设置歌词文本
// lyricSwitchView.setSourceText(lyricSwitchView.text)
// 隐藏时钟
lyricSwitchView.setCurrentText(lyricSwitchView.text) // 隐藏时钟
clock.layoutParams = LinearLayout.LayoutParams(0, 0)
showLyric = true
}
Expand All @@ -350,11 +383,11 @@ class SystemUI : BaseHook() {

iconUpdate = Handler(Looper.getMainLooper()) { message ->
if (message.obj == null) {
lyricSwitchView.setMargins(0, 0, 0, 0)
lyricSwitchView.setMargins(config.getLyricPosition(), config.getLyricHigh(), 0, 0)
iconView.visibility = View.GONE
iconView.setImageDrawable(null)
} else {
lyricSwitchView.setMargins(10, 0, 0, 0)
lyricSwitchView.setMargins(config.getLyricPosition() + 10, config.getLyricHigh(), 0, 0)
iconView.visibility = View.VISIBLE
iconView.setImageDrawable(message.obj as Drawable)
}
Expand All @@ -378,6 +411,7 @@ class SystemUI : BaseHook() {

updateTextColor = Handler(Looper.getMainLooper()) { message ->
lyricSwitchView.setTextColor(message.arg1)
customizeView.setTextColor(message.arg1)
true
}

Expand All @@ -404,10 +438,14 @@ class SystemUI : BaseHook() {
style = Paint.Style.FILL_AND_STROKE
strokeWidth = (config.getLyricFontWeight().toFloat() / 100)
}
customizeView.paint.apply {
style = Paint.Style.FILL_AND_STROKE
strokeWidth = (config.getLyricFontWeight().toFloat() / 100)
}
}
}
Utils.setStatusBar(application, false, config)
lyricSwitchView.setSourceText(lyric)
lyricSwitchView.setText(lyric)
true
}

Expand All @@ -418,7 +456,7 @@ class SystemUI : BaseHook() {
clock.layoutParams = clockParams // show clock
if (config.getLyricSwitch()) { // set clock click listener
clock.isClickable = clockClickable
clock.getObjectField("mListenerInfo")?.setObjectField("mOnClickListener", clockOnClickListener)
clock.getObjectField("mListenerInfo")?.setObjectField("mOnClickListener", clockOnClickListener).isNull { clock.setOnClickListener(null) }
}
Utils.setStatusBar(application, true, config) // set miui statusbar
true
Expand All @@ -430,7 +468,7 @@ class SystemUI : BaseHook() {
gravity = Gravity.CENTER
orientation = LinearLayout.HORIZONTAL
(lyricLayout.parent as? ViewGroup)?.removeView(lyricLayout)
if (config.getViewPosition() == "first") addView(lyricLayout, 1) else addView(lyricLayout)
if (config.getLyricViewPosition() == "first") addView(lyricLayout, 1) else addView(lyricLayout)
}
updateConfig()
offLyric(LogMultiLang.initOk)
Expand Down Expand Up @@ -476,7 +514,10 @@ class SystemUI : BaseHook() {
width = config.getIconSize()
height = config.getIconSize()
}
} // lyricSwitchView.setStyle(config.getLyricStyle())
}
if (config.getLyricSize() != 0) {
lyricSwitchView.setTextSize(TypedValue.COMPLEX_UNIT_SHIFT, config.getLyricSize().toFloat())
}
}

private fun offLyric(info: String) { // off Lyric
Expand Down Expand Up @@ -638,6 +679,7 @@ class SystemUI : BaseHook() {
val error = FileUtils(application).copyFile(File(path), application.filesDir.path, "font")
if (error.isEmpty()) {
lyricSwitchView.setTypeface(Typeface.createFromFile(application.filesDir.path + "/font"))
customizeView.typeface = Typeface.createFromFile(application.filesDir.path + "/font")
LogUtils.e(LogMultiLang.fontLoad)
application.sendBroadcast(Intent().apply {
action = "App_Server"
Expand Down
8 changes: 8 additions & 0 deletions app/src/main/java/statusbar/lyric/utils/Utils.kt
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import java.io.IOException
import java.io.PrintWriter
import java.io.StringWriter
import java.util.*
import kotlin.collections.ArrayList


@SuppressLint("StaticFieldLeak")
Expand Down Expand Up @@ -285,4 +286,11 @@ object Utils {
} catch (ignored: Throwable) {
}
}

fun <E> Array<E>.indexOfArr(value: E): Int {
for (index in 0..this.size) {
if (this[index] == value) return index
}
return -1
}
}
Loading

0 comments on commit cbde09b

Please sign in to comment.