diff --git a/app/src/main/kotlin/statusbar/lyric/config/Config.kt b/app/src/main/kotlin/statusbar/lyric/config/Config.kt index b066f82f..f9b676ee 100644 --- a/app/src/main/kotlin/statusbar/lyric/config/Config.kt +++ b/app/src/main/kotlin/statusbar/lyric/config/Config.kt @@ -66,7 +66,7 @@ class Config { } var outLog: Boolean get() { - return if (BuildConfig.DEBUG) true else config.opt("outlog", true) + return if (BuildConfig.DEBUG) true else config.opt("outlog", false) } set(value) { config.put("outlog", value) diff --git a/app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt b/app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt index 87e7eff3..a09b26d3 100644 --- a/app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt +++ b/app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt @@ -193,6 +193,7 @@ class SystemUILyric : BaseHook() { private lateinit var mNotificationIconArea: View private lateinit var mCarrierLabel: View private lateinit var mPadClockView: View + private val realTargetWidth by lazy { targetView.width.toFloat() - if (config.iconSwitch) config.iconStartMargins.toFloat() + iconView.width else 0f } private val lyricView: LyricSwitchView by lazy { object : LyricSwitchView(context) { override fun onSizeChanged(w: Int, h: Int, oldw: Int, oldh: Int) { @@ -204,7 +205,10 @@ class SystemUILyric : BaseHook() { } else if (colors.size < 2) { setTextColor(colors[0]) } else { - val textShader = LinearGradient(0f, 0f, width.toFloat(), 0f, colors.toIntArray(), null, Shader.TileMode.CLAMP) + val textShader = LinearGradient( + 0f, 0f, width.toFloat(), + 0f, colors.toIntArray(), null, Shader.TileMode.CLAMP + ) setLinearGradient(textShader) } } @@ -225,7 +229,10 @@ class SystemUILyric : BaseHook() { LinearLayout(context).apply { orientation = LinearLayout.HORIZONTAL gravity = Gravity.CENTER - layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT) + layoutParams = LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, + LinearLayout.LayoutParams.MATCH_PARENT + ) addView(iconView) addView(lyricView) visibility = View.GONE @@ -391,7 +398,8 @@ class SystemUILyric : BaseHook() { } MotionEvent.ACTION_UP -> { - val isMove = abs(point.y - motionEvent.rawY.toInt()) > 50 || abs(point.x - motionEvent.rawX.toInt()) > 50 + val isMove = + abs(point.y - motionEvent.rawY.toInt()) > 50 || abs(point.x - motionEvent.rawX.toInt()) > 50 val isLongChick = motionEvent.eventTime - motionEvent.downTime > 500 when (isMove) { true -> { @@ -511,9 +519,10 @@ class SystemUILyric : BaseHook() { } } - val shouldShowMethod = loadClassOrNull("com.android.systemui.statusbar.phone.FocusedNotifPromptController").ifNotNull { - it.declaredMethods.firstOrNull { method -> method.name == "shouldShow" } - } + val shouldShowMethod = + loadClassOrNull("com.android.systemui.statusbar.phone.FocusedNotifPromptController").ifNotNull { + it.declaredMethods.firstOrNull { method -> method.name == "shouldShow" } + } if (shouldShowMethod != null) { canHideFocusNotify = true (shouldShowMethod as Method).createHook { @@ -663,12 +672,10 @@ class SystemUILyric : BaseHook() { shouldIgnore = false } } else { - !(focusedNotify!!.getObjectField("mIsHeadsUpShowing") as Boolean - || mCurrentNotifyBean == null || mCurrentNotifyBean.getObjectField("headsUp") as Boolean || - (TextUtils.equals( - mCurrentNotifyBean.getObjectField("packageName") as CharSequence, - focusedNotify!!.getObjectField("mTopActivityPackageName") as CharSequence - ) && !(focusedNotify!!.getObjectField("mRequestHide") as Boolean))) + !(focusedNotify!!.getObjectField("mIsHeadsUpShowing") as Boolean || mCurrentNotifyBean.getObjectField("headsUp") as Boolean || (TextUtils.equals( + mCurrentNotifyBean.getObjectField("packageName") as CharSequence, + focusedNotify!!.getObjectField("mTopActivityPackageName") as CharSequence + ) && !(focusedNotify!!.getObjectField("mRequestHide") as Boolean))) } } @@ -741,17 +748,16 @@ class SystemUILyric : BaseHook() { val blurRadio = config.mHyperOSTextureRadio val cornerRadius = cornerRadius(config.mHyperOSTextureCorner.toFloat()) val blendModes = arrayOf( - intArrayOf(106, Color.parseColor(config.mHyperOSTextureBgColor)), intArrayOf(3, Color.parseColor(config.mHyperOSTextureBgColor)) + intArrayOf(106, Color.parseColor(config.mHyperOSTextureBgColor)), + intArrayOf(3, Color.parseColor(config.mHyperOSTextureBgColor)) ) lyricLayout.setBackgroundBlur(blurRadio, cornerRadius, blendModes) } if (config.lyricWidth == 0) { - lyricView.setMaxLyricViewWidth(targetView.width.toFloat() - if (config.iconSwitch) config.iconStartMargins.toFloat() + iconView.width else 0f) + lyricView.setMaxLyricViewWidth(realTargetWidth) } else { var width = scaleWidth().toFloat() + config.lyricEndMargins + config.lyricStartMargins - if (width > targetView.width) { - width = targetView.width.toFloat() - } + if (width > realTargetWidth) width = realTargetWidth lyricView.setMaxLyricViewWidth(width) } themeMode = (context.resources.configuration.uiMode and Configuration.UI_MODE_NIGHT_MASK) @@ -876,9 +882,6 @@ class SystemUILyric : BaseHook() { config.getDefaultIcon(it.packageName) } } - if (config.lyricWidth == 0) { - lyricView.setMaxLyricViewWidth(targetView.width.toFloat() - if (config.iconSwitch) config.iconStartMargins.toFloat() + iconView.width else 0f) - } } private fun hideLyric(anim: Boolean = true) { @@ -906,8 +909,16 @@ class SystemUILyric : BaseHook() { config.update() goMainThread(delay) { lyricView.apply { - setTextSize(TypedValue.COMPLEX_UNIT_SHIFT, if (config.lyricSize == 0) clockView.textSize else config.lyricSize.toFloat()) - setPadding(config.lyricStartMargins, config.lyricTopMargins, config.lyricEndMargins, config.lyricBottomMargins) + setTextSize( + TypedValue.COMPLEX_UNIT_SHIFT, + if (config.lyricSize == 0) clockView.textSize else config.lyricSize.toFloat() + ) + setPadding( + config.lyricStartMargins, + config.lyricTopMargins, + config.lyricEndMargins, + config.lyricBottomMargins + ) if (config.lyricGradientColor.isEmpty()) { if (config.lyricColor.isEmpty()) { when (config.lyricColorScheme) { @@ -919,12 +930,10 @@ class SystemUILyric : BaseHook() { } } if (config.lyricWidth == 0) { - lyricView.setMaxLyricViewWidth(targetView.width.toFloat() - if (config.iconSwitch) config.iconStartMargins.toFloat() + iconView.width else 0f) + lyricView.setMaxLyricViewWidth(realTargetWidth) } else { var width = scaleWidth().toFloat() + config.lyricEndMargins + config.lyricStartMargins - if (width > targetView.width) { - width = targetView.width.toFloat() - } + if (width > realTargetWidth) width = realTargetWidth lyricView.setMaxLyricViewWidth(width) } setLetterSpacings(config.lyricLetterSpacing / 100f) @@ -942,14 +951,17 @@ class SystemUILyric : BaseHook() { setBackgroundColor(Color.parseColor(config.lyricBackgroundColor)) } } else { - config.lyricBackgroundColor.trim().split(",").map { Color.parseColor(it.trim()) }.let { colors -> - val gradientDrawable = GradientDrawable( - GradientDrawable.Orientation.LEFT_RIGHT, colors.toIntArray() - ).apply { - if (config.lyricBackgroundRadius != 0) cornerRadius = config.lyricBackgroundRadius.toFloat() + config.lyricBackgroundColor.trim().split(",").map { Color.parseColor(it.trim()) } + .let { colors -> + val gradientDrawable = GradientDrawable( + GradientDrawable.Orientation.LEFT_RIGHT, colors.toIntArray() + ).apply { + if (config.lyricBackgroundRadius != 0) { + cornerRadius = config.lyricBackgroundRadius.toFloat() + } + } + background = gradientDrawable } - background = gradientDrawable - } } } @@ -975,7 +987,10 @@ class SystemUILyric : BaseHook() { iconView.showView() iconSwitch = true iconView.apply { - layoutParams = LinearLayout.LayoutParams(LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.MATCH_PARENT).apply { + layoutParams = LinearLayout.LayoutParams( + LinearLayout.LayoutParams.WRAP_CONTENT, + LinearLayout.LayoutParams.MATCH_PARENT + ).apply { setMargins(config.iconStartMargins, config.iconTopMargins, 0, config.iconBottomMargins) if (config.iconSize == 0) { width = clockView.height / 2 diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 6a4ab49d..1c0b6527 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,8 +2,8 @@ androidGradlePlugin = "8.7.3" androidx-coreKtx = "1.15.0" androidx-activity-compose = "1.9.3" -androidx-compose-foundation = "1.7.5" -androidx-navigation-compose = "2.8.4" +androidx-compose-foundation = "1.7.6" +androidx-navigation-compose = "2.8.5" ezXHelper = "2.2.0" haze = "1.1.1" kotlin = "2.1.0" @@ -11,7 +11,6 @@ lyricGetterApi = "6.0.0" miuix = "0.3.2" xposed = "82" - [libraries] androidx-compose-foundation = { group = "androidx.compose.foundation", name = "foundation", version.ref = "androidx-compose-foundation" } androidx-core-ktx = { module = "androidx.core:core-ktx", version.ref = "androidx-coreKtx" }