Skip to content

Commit

Permalink
7.0.1 (#458)
Browse files Browse the repository at this point in the history
- 修复 无法设置图标上边距
- 修复 悬浮标题背景颜色无法设置
- 修复 部分系统无法隐藏通知图标
- lyricEndMargins 默认修改为7
- 添加 歌词添加位置
- 修复无法输入渐变色
- 优化 图标样式页面中重启系统界面 Card 跳动
- 优化 标题间距
- 优化 竖屏下页面切换动画
- 修复 扩展选项界面字重错误
- 修复 重置配置 Dialog 文案
- 添加 横屏下右侧显示 Logo
- 优化 标题监听 解决蓝牙歌词导致歌词被当作标题
- 修复 屏幕缺口黑边
- 修复 歌词设置宽度过大时无法滚动

---------

Co-authored-by: Void_Empty <[email protected]>
Co-authored-by: xiao_wine <[email protected]>
  • Loading branch information
3 people authored Oct 2, 2024
1 parent 866d467 commit d49f2d5
Show file tree
Hide file tree
Showing 18 changed files with 174 additions and 89 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ android {
applicationId = "statusbar.lyric"
minSdk = 26
targetSdk = 35
versionCode = 700
versionName = "7.0.0"
versionCode = 701
versionName = "7.0.1"
aaptOptions.cruncherEnabled = false
dependenciesInfo.includeInApk = false
buildConfigField("long", "BUILD_TIME", "$buildTime")
Expand Down
15 changes: 12 additions & 3 deletions app/src/main/kotlin/statusbar/lyric/App.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package statusbar.lyric
import android.content.res.Configuration
import androidx.compose.animation.core.CubicBezierEasing
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInHorizontally
import androidx.compose.animation.slideOutHorizontally
Expand All @@ -11,10 +12,13 @@ import androidx.compose.foundation.layout.BoxWithConstraints
import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.size
import androidx.compose.material3.Icon
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.platform.LocalConfiguration
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.unit.dp
import androidx.navigation.compose.NavHost
import androidx.navigation.compose.composable
Expand Down Expand Up @@ -54,7 +58,7 @@ fun App() {
@Composable
fun PortraitLayout() {
val windowWidth = getWindowSize().width
val easing = CubicBezierEasing(0.12f, 0.88f, 0.2f, 1f)
val easing = CubicBezierEasing(0.12f, 0.38f, 0.2f, 1f)
val navController = rememberNavController()
NavHost(
navController = navController,
Expand Down Expand Up @@ -130,7 +134,7 @@ fun LandscapeLayout() {
)
},
) {
composable("EmptyPage") { EmptyPage() }
composable("EmptyPage", exitTransition = { fadeOut() }, popEnterTransition = { fadeIn()}) { EmptyPage() }
composable("MenuPage") { MenuPage(navController) }
composable("ChoosePage") { ChoosePage(navController) }
composable("TestPage") { TestPage(navController) }
Expand All @@ -148,6 +152,11 @@ fun EmptyPage() {
modifier = Modifier.fillMaxSize(),
contentAlignment = Alignment.Center
) {
// Empty page
Icon(
painter = painterResource(R.drawable.ic_launcher_foreground),
contentDescription = null,
tint = MiuixTheme.colorScheme.secondary,
modifier = Modifier.size(256.dp)
)
}
}
13 changes: 5 additions & 8 deletions app/src/main/kotlin/statusbar/lyric/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,16 @@ class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)

enableEdgeToEdge()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
window.isNavigationBarContrastEnforced = false
}

context = this
isLoad = isHook()
init()

setContent {

DisposableEffect(isSystemInDarkTheme()) {
enableEdgeToEdge()
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) {
window.isNavigationBarContrastEnforced = false
}
onDispose {}
}
App()
}
}
Expand Down
9 changes: 8 additions & 1 deletion app/src/main/kotlin/statusbar/lyric/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ class Config {
var lyricEndMargins: Int
get() {

return config.opt("lyricEnd", if (XposedOwnSP.config.mHyperOSTexture) 20 else 0)
return config.opt("lyricEnd", if (XposedOwnSP.config.mHyperOSTexture) 20 else 7)
}
set(value) {
config.put("lyricEnd", value)
Expand Down Expand Up @@ -494,6 +494,13 @@ class Config {
set(value) {
config.put("changeAllIcons", value)
}
var viewLocation: Int
get() {
return config.opt("viewLocation", 0)
}
set(value) {
config.put("viewLocation", value)
}

private val defIconHashMap by lazy {
HashMap<String, String>().apply {
Expand Down
47 changes: 24 additions & 23 deletions app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ import cn.lyric.getter.api.tools.Tools.base64ToDrawable
import cn.lyric.getter.api.tools.Tools.registerLyricListener
import com.github.kyuubiran.ezxhelper.ClassUtils.loadClassOrNull
import com.github.kyuubiran.ezxhelper.EzXHelper.moduleRes
import com.github.kyuubiran.ezxhelper.HookFactory
import com.github.kyuubiran.ezxhelper.HookFactory.`-Static`.createHook
import com.github.kyuubiran.ezxhelper.ObjectHelper.Companion.objectHelper
import com.github.kyuubiran.ezxhelper.finders.ConstructorFinder.`-Static`.constructorFinder
Expand Down Expand Up @@ -279,27 +280,26 @@ class SystemUILyric : BaseHook() {
}
if (config.hideNotificationIcon) {
moduleRes.getString(R.string.hide_notification_icon).log()
fun HookFactory.hideNoticeIcon() {
after { hookParam ->
val clazz = hookParam.thisObject::class.java
if (clazz.simpleName == "NotificationIconAreaController") {
hookParam.thisObject.objectHelper {
mNotificationIconArea = this.getObjectOrNullAs<View>("mNotificationIconArea")!!
}
} else {
mNotificationIconArea = clazz.superclass.getField("mNotificationIconArea").get(hookParam.thisObject) as View
}
}
}
loadClassOrNull("com.android.systemui.statusbar.phone.NotificationIconAreaController").isNotNull {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
it.constructorFinder().first().createHook {
after { hookParam ->
hookParam.thisObject.objectHelper {
mNotificationIconArea = this.getObjectOrNullAs<View>("mNotificationIconArea")!!
}
}
hideNoticeIcon()
}
} else {
it.methodFinder().filterByName("initializeNotificationAreaViews").first().createHook {
after { hookParam ->
val clazz = hookParam.thisObject::class.java
if (clazz.simpleName == "NotificationIconAreaController") {
hookParam.thisObject.objectHelper {
mNotificationIconArea = this.getObjectOrNullAs<View>("mNotificationIconArea")!!
}
} else {
mNotificationIconArea = clazz.superclass.getField("mNotificationIconArea").get(hookParam.thisObject) as View
}
}
hideNoticeIcon()
}
}
}
Expand Down Expand Up @@ -408,11 +408,10 @@ class SystemUILyric : BaseHook() {
val firstLoad = lyricLayout.parent.isNull()
goMainThread(1) {
runCatching { (lyricLayout.parent as ViewGroup).removeView(lyricLayout) }
targetView.addView(lyricLayout, 0)
if (config.lyricWidth == 0) {
lyricView.setMaxLyricViewWidth(targetView.width.toFloat() - if (config.iconSwitch) config.iconStartMargins.toFloat() + iconView.width else 0f)
if (config.viewLocation == 0) {
targetView.addView(lyricLayout, 0)
} else {
lyricView.setMaxLyricViewWidth(scaleWidth().toFloat() + config.lyricEndMargins + config.lyricStartMargins)
targetView.addView(lyricLayout)
}
if (isHyperOS && config.mHyperOSTexture) {
val blurRadio = config.mHyperOSTextureRadio
Expand Down Expand Up @@ -530,8 +529,6 @@ class SystemUILyric : BaseHook() {
}
if (config.lyricWidth == 0) {
lyricView.setMaxLyricViewWidth(targetView.width.toFloat() - if (config.iconSwitch) config.iconStartMargins.toFloat() + iconView.width else 0f)
} else {
lyricView.setMaxLyricViewWidth(scaleWidth().toFloat() + config.lyricEndMargins + config.lyricStartMargins)
}
}

Expand Down Expand Up @@ -572,9 +569,13 @@ class SystemUILyric : BaseHook() {
}
}
if (config.lyricWidth == 0) {
setMaxLyricViewWidth(targetView.width.toFloat() - if (config.iconSwitch) config.iconStartMargins.toFloat() + iconView.width else 0f)
lyricView.setMaxLyricViewWidth(targetView.width.toFloat() - if (config.iconSwitch) config.iconStartMargins.toFloat() + iconView.width else 0f)
} else {
setMaxLyricViewWidth(scaleWidth().toFloat() + config.lyricEndMargins + config.lyricStartMargins)
var width = scaleWidth().toFloat() + config.lyricEndMargins + config.lyricStartMargins
if (width > targetView.width) {
width = targetView.width.toFloat()
}
lyricView.setMaxLyricViewWidth(width)
}
setLetterSpacings(config.lyricLetterSpacing / 100f)
strokeWidth(config.lyricStrokeWidth / 100f)
Expand Down
19 changes: 19 additions & 0 deletions app/src/main/kotlin/statusbar/lyric/tools/ActivityTools.kt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import android.os.Looper
import android.widget.Toast
import statusbar.lyric.MainActivity.Companion.context
import statusbar.lyric.R
import statusbar.lyric.config.ActivityOwnSP.config
import statusbar.lyric.data.Data
import statusbar.lyric.tools.LogTools.log
import kotlin.system.exitProcess
Expand Down Expand Up @@ -82,6 +83,24 @@ object ActivityTools {
unit(value)
}

fun colorSCheck(value: String, unit: (String) -> Unit, default: String = "") {
if (value.isEmpty()) {
unit(default)
} else {
try {
value.split(",").forEach {
if (it.isNotEmpty()) {
Color.parseColor(it.trim())
}
}
} catch (e: Exception) {
showToastOnLooper(context.getString(R.string.color_error))
return
}
}
unit(value)
}

fun checkInstalled(pkgName: String): ApplicationInfo? {
return try {
context.packageManager.getApplicationInfo(pkgName, PackageManager.GET_META_DATA)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import android.media.session.PlaybackState
import android.service.notification.NotificationListenerService

open class SystemMediaSessionListener(context: Context) {
private var artist: String? = null
private var mediaSessionManager: MediaSessionManager? = null
private val activeControllers = mutableListOf<MediaController>()

Expand Down Expand Up @@ -68,7 +69,11 @@ open class SystemMediaSessionListener(context: Context) {
// 显示媒体元数据
private fun displayMediaMetadata(metadata: MediaMetadata) {
val title = metadata.getString(MediaMetadata.METADATA_KEY_TITLE) ?: "Unknown Title"
onTitleChanged(title)
val artist = metadata.getString(MediaMetadata.METADATA_KEY_ARTIST) ?: "Unknown Artist"
if (this.artist != artist) {
this.artist = artist
onTitleChanged(title)
}
}

fun cleanup() {
Expand Down
2 changes: 1 addition & 1 deletion app/src/main/kotlin/statusbar/lyric/ui/page/ChoosePage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fun ChoosePage(navController: NavController) {
topAppBarScrollBehavior = scrollBehavior
) {
item {
Column {
Column(Modifier.padding(top = 18.dp)) {
dataList.forEach { data ->
Card(
modifier = Modifier
Expand Down
35 changes: 23 additions & 12 deletions app/src/main/kotlin/statusbar/lyric/ui/page/ExtendPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ import top.yukonga.miuix.kmp.utils.getWindowSize
@Composable
fun ExtendPage(navController: NavController) {
val scrollBehavior = MiuixScrollBehavior(rememberTopAppBarState())
val viewLocationOptions = listOf(
stringResource(R.string.title_gravity_start),
stringResource(R.string.title_gravity_end)
)

val viewLocationSelectedOption = remember { mutableIntStateOf(config.viewLocation) }
val hideTime = remember { mutableStateOf(config.hideTime) }
val hideNotificationIcon = remember { mutableStateOf(config.hideNotificationIcon) }
val hideLyricWhenLockScreen = remember { mutableStateOf(config.hideLyricWhenLockScreen) }
Expand Down Expand Up @@ -117,7 +123,7 @@ fun ExtendPage(navController: NavController) {
topAppBarScrollBehavior = scrollBehavior
) {
item {
Column {
Column(Modifier.padding(top = 16.dp)) {
Text(
modifier = Modifier.padding(horizontal = 28.dp, vertical = 8.dp),
text = stringResource(R.string.module_extend),
Expand All @@ -129,8 +135,18 @@ fun ExtendPage(navController: NavController) {
modifier = Modifier
.fillMaxWidth()
.padding(horizontal = 12.dp)
.padding(bottom = 6.dp)
.padding(bottom = 12.dp)
) {
SuperDropdown(
title = stringResource(R.string.view_location),
items = viewLocationOptions,
titleColor = MiuixTheme.colorScheme.primary,
selectedIndex = viewLocationSelectedOption.intValue,
onSelectedIndexChange = { newOption ->
viewLocationSelectedOption.intValue = newOption
config.viewLocation = newOption
},
)
SuperSwitch(
title = stringResource(R.string.hide_time),
checked = hideTime.value,
Expand Down Expand Up @@ -225,7 +241,8 @@ fun ExtendPage(navController: NavController) {
)
}
SmallTitle(
text = stringResource(R.string.module_fifth)
text = stringResource(R.string.module_fifth),
modifier = Modifier.padding(top = 6.dp)
)
Card(
modifier = Modifier
Expand Down Expand Up @@ -300,12 +317,8 @@ fun ExtendPage(navController: NavController) {
.padding(top = 6.dp, bottom = 12.dp)
) {
BasicComponent(
leftAction = {
Text(
text = stringResource(R.string.reset_system_ui),
color = Color.Red
)
},
title = stringResource(R.string.reset_system_ui),
titleColor = Color.Red,
onClick = {
showDialog.value = true
}
Expand Down Expand Up @@ -501,9 +514,7 @@ fun TitleBgColorDialog(showDialog: MutableState<Boolean>) {
value = value.value,
maxLines = 1,
onValueChange = {
if (it.isEmpty()) {
value.value = it
}
value.value = it
}
)
Row(
Expand Down
11 changes: 7 additions & 4 deletions app/src/main/kotlin/statusbar/lyric/ui/page/HomePage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ fun HomePage(navController: NavController) {
topAppBarScrollBehavior = scrollBehavior
) {
item {
Column {
Column(Modifier.padding(top = 18.dp)) {
Card(
modifier = Modifier
.fillMaxWidth()
Expand Down Expand Up @@ -178,7 +178,8 @@ fun HomePage(navController: NavController) {
) {
Column {
SmallTitle(
text = stringResource(R.string.module_first)
text = stringResource(R.string.module_first),
modifier = Modifier.padding(top = 6.dp)
)
Card(
modifier = Modifier
Expand All @@ -203,7 +204,8 @@ fun HomePage(navController: NavController) {
) {
Column {
SmallTitle(
text = stringResource(R.string.module_second)
text = stringResource(R.string.module_second),
modifier = Modifier.padding(top = 6.dp)
)
Card(
modifier = Modifier
Expand Down Expand Up @@ -233,7 +235,8 @@ fun HomePage(navController: NavController) {
) {
Column {
SmallTitle(
text = stringResource(R.string.module_third)
text = stringResource(R.string.module_third),
modifier = Modifier.padding(top = 6.dp)
)
Card(
modifier = Modifier
Expand Down
Loading

0 comments on commit d49f2d5

Please sign in to comment.