Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add timeout auto close lyric. #528

Merged
merged 1 commit into from
Jan 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/src/main/kotlin/statusbar/lyric/config/Config.kt
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,13 @@ class Config {
set(value) {
config.put("limitVisibilityChange", value)
}
var timeoutRestore: Boolean
get() {
return config.opt("timeoutRestore", true)
}
set(value) {
config.put("timeoutRestore", value)
}
var longClickStatusBarStop: Boolean
get() {
return config.opt("longClickStatusBarStop", false)
Expand Down
24 changes: 23 additions & 1 deletion app/src/main/kotlin/statusbar/lyric/hook/module/SystemUILyric.kt
Original file line number Diff line number Diff line change
Expand Up @@ -611,18 +611,19 @@ class SystemUILyric : BaseHook() {
isHiding = false
hideFocusNotifyIfNeed()
}
"statusBar state is showing.".log()
} else if (!statusbarShowing) {
isHiding = true
hideLyric()
showFocusNotifyIfNeed()
"statusBar state is hiding".log()
}
} else {
if (!(isOS2FocusNotifyShowing || isOS1FocusNotifyShowing || isClickHide)) {
isHiding = false
hideFocusNotifyIfNeed()
}
}
"statusBar state is ${if (statusbarShowing) "show" else "hide"}".log()
}

private fun autoHideStatusBarInFullScreenModeIfNeed() {
Expand Down Expand Up @@ -699,6 +700,19 @@ class SystemUILyric : BaseHook() {
val TITLE_SHOW_READY: Int = 0
val TITLE_SHOW_WAITING: Int = 1
val TITLE_SHOWING: Int = 2
val TIMEOUT_RESTORE: Int = 3
val timeoutRestoreHandler: Handler by lazy {
object : Handler(Looper.getMainLooper()) {
override fun handleMessage(msg: Message) {
if (msg.what == TIMEOUT_RESTORE && isPlaying && config.timeoutRestore) {
hideLyric()
playingApp = ""
lastLyric = ""
"timeout restore!!".log()
}
}
}
}
val titleShowHandler: Handler by lazy {
object : Handler(Looper.getMainLooper()) {
var titleData: TitleData = TitleData("", "")
Expand Down Expand Up @@ -776,7 +790,12 @@ class SystemUILyric : BaseHook() {
lastLyric = lyric
playingApp = lyricData.extraData.packageName
changeLyricStateIfInFullScreenMode()

if (isHiding) return
if (timeoutRestoreHandler.hasMessages(TIMEOUT_RESTORE)) {
timeoutRestoreHandler.removeMessages(TIMEOUT_RESTORE)
timeoutRestoreHandler.sendEmptyMessageDelayed(TIMEOUT_RESTORE, 10000L)
} else timeoutRestoreHandler.sendEmptyMessageDelayed(TIMEOUT_RESTORE, 10000L)
hideFocusNotifyIfNeed()
changeIcon(lyricData.extraData)
changeLyric(lastLyric, lyricData.extraData.delay)
Expand All @@ -794,6 +813,9 @@ class SystemUILyric : BaseHook() {
lastLyric = ""
hideLyric()
showFocusNotifyIfNeed()
if (timeoutRestoreHandler.hasMessages(TIMEOUT_RESTORE)) {
timeoutRestoreHandler.removeMessages(TIMEOUT_RESTORE)
}
}
})
registerLyricListener(context, BuildConfig.API_VERSION, lyricReceiver)
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/kotlin/statusbar/lyric/ui/page/ExtendPage.kt
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ fun ExtendPage(navController: NavController, currentStartDestination: MutableSta
val clickStatusBarToHideLyric = remember { mutableStateOf(config.clickStatusBarToHideLyric) }
val slideStatusBarCutSongs = remember { mutableStateOf(config.slideStatusBarCutSongs) }
val limitVisibilityChange = remember { mutableStateOf(config.limitVisibilityChange) }
val timeoutRestore = remember { mutableStateOf(config.timeoutRestore) }
val dynamicLyricSpeed = remember { mutableStateOf(config.dynamicLyricSpeed) }
val titleSwitch = remember { mutableStateOf(config.titleSwitch) }
val titleShowWithSameLyric = remember { mutableStateOf(config.titleShowWithSameLyric) }
Expand Down Expand Up @@ -280,6 +281,14 @@ fun ExtendPage(navController: NavController, currentStartDestination: MutableSta
config.limitVisibilityChange = it
}
)
SuperSwitch(
title = stringResource(R.string.timeout_restore),
checked = timeoutRestore.value,
onCheckedChange = {
timeoutRestore.value = it
config.timeoutRestore = it
}
)
SuperSwitch(
title = stringResource(R.string.dynamic_lyric_speed),
checked = dynamicLyricSpeed.value,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ fun SystemSpecialPage(navController: NavController, currentStartDestination: Mut
val mMiuiPadOptimize = remember { mutableStateOf(config.mMiuiPadOptimize) }
val hideCarrier = remember { mutableStateOf(config.hideCarrier) }
val mHyperOSTexture = remember { mutableStateOf(config.mHyperOSTexture) }
val mHideFocusedNotice = remember { mutableStateOf(config.automateFocusedNotice) }
val mAutomateFocusedNotice = remember { mutableStateOf(config.automateFocusedNotice) }
val showDialog = remember { mutableStateOf(false) }
val showRadioDialog = remember { mutableStateOf(false) }
val showCornerDialog = remember { mutableStateOf(false) }
Expand Down Expand Up @@ -192,9 +192,9 @@ fun SystemSpecialPage(navController: NavController, currentStartDestination: Mut
) {
SuperSwitch(
title = stringResource(R.string.automate_focused_notice),
checked = mHideFocusedNotice.value,
checked = mAutomateFocusedNotice.value,
onCheckedChange = {
mHideFocusedNotice.value = it
mAutomateFocusedNotice.value = it
config.automateFocusedNotice = it
}
)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-ja/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<string name="hide_notification_icon">自動で通知アイコンを隠す</string>
<string name="limit_visibility_change">可視性の変更を制限</string>
<string name="limit_visibility_change_tips">一部のシステムの特性で時計が表示される問題は防ぐことができます</string>
<string name="timeout_restore">タイムアウト時にステータスバーを閉じる歌詞</string>
<string name="hide_lyric_when_lock_screen">ロック画面で歌詞を隠す</string>
<string name="choose_page_tips">ステータスバーのレイアウトを変更する他のモジュールを先に閉じた後に、このページでフックポイントを選択することを推奨します。\n効果的なフックポイントの選択: ステータスバーにはモジュール名が表示され、時間は非表示になります。</string>
<string name="hide_carrier">キャリアを隠す</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<string name="hide_notification_icon">隐藏通知图标</string>
<string name="limit_visibility_change">限制可见性更改</string>
<string name="limit_visibility_change_tips">可以防止部分系统的特性导致有时间会出现</string>
<string name="timeout_restore">超时关闭状态栏歌词</string>
<string name="hide_lyric_when_lock_screen">锁定屏幕时隐藏歌词</string>
<string name="choose_page_tips">建议先关闭其他修改状态栏布局的模块后,再来此页面选择锚点\n\n有效的锚点选择:状态栏显示模块名字,并有白色背景\n\n选择锚点后,返回关闭锚点模式,重启系统模式即锚点设置完成</string>
<string name="hide_carrier">隐藏运营商</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<string name="hide_notification_icon">隱藏通知圖示</string>
<string name="limit_visibility_change">限制可見性更改</string>
<string name="limit_visibility_change_tips">可以防止部分系統的特性導致有時間會出現</string>
<string name="timeout_restore">超時關閉狀態列歌詞</string>
<string name="hide_lyric_when_lock_screen">鎖定螢幕時隱藏歌詞</string>
<string name="choose_page_tips">建議先關閉其他修改狀態欄布局的模組後,再來此頁面選擇錨點\n\n有效的錨點選擇:狀態欄顯示模組名字,並有白色背景\n\n選擇錨點後,返回關閉錨點模式,重啟系統模式即錨點設置完成</string>
<string name="hide_carrier">隱藏運營商</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@
<string name="hide_notification_icon">Automatically hide notification icons</string>
<string name="limit_visibility_change">Limit Visibility Change</string>
<string name="limit_visibility_change_tips">It can prevent the characteristics of some systems from causing time to appear</string>
<string name="timeout_restore">Timeout closure status bar lyrics</string>
<string name="hide_lyric_when_lock_screen">Hide Lyric When Lock Screen</string>
<string name="choose_page_tips">It is recommended to close other modules that modify the layout of the status bar first, and then come to this page to select Hook Points\nEffective Hook Point Selection: The status bar displays the module name, and the time is hidden</string>
<string name="hide_carrier">Hide Carrier</string>
Expand Down
Loading