Skip to content

Commit

Permalink
opt: add Focus notification lyrics isClickStatusBarClock switch
Browse files Browse the repository at this point in the history
  • Loading branch information
lingqiqi5211 committed Dec 2, 2024
1 parent 5123b3e commit 215276b
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,17 @@ abstract class MusicBaseHook : BaseHook() {
fun sendNotification(text: String) {
// logE("sendNotification: " + context.packageName + ": " + text)
createNotificationChannel()
val isClickClock = mPrefsMap.getBoolean("system_ui_statusbar_music_click_clock")
val launchIntent = context.packageManager.getLaunchIntentForPackage(context.packageName)
val bitmap = context.packageManager.getActivityIcon(launchIntent!!).toBitmap()
val builder = NotificationCompat.Builder(context, CHANNEL_ID)
val intent = Intent("$CHANNEL_ID.actions.switchClockStatus")
val pendingIntent =
// 需要重启音乐软件生效
val pendingIntent = if (isClickClock) {
PendingIntent.getBroadcast(context, 0, intent, PendingIntent.FLAG_IMMUTABLE)
} else {
PendingIntent.getActivity(context, 0, launchIntent, PendingIntent.FLAG_MUTABLE)
}
builder.setContentTitle(text)
builder.setSmallIcon(IconCompat.createWithBitmap(bitmap))
builder.setTicker(text).setPriority(NotificationCompat.PRIORITY_LOW)
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -925,6 +925,8 @@
<string name="system_ui_statusbar_music_cusiom_title">显示设置</string>
<string name="system_ui_statusbar_music_hide_clock_title">隐藏状态栏时钟</string>
<string name="system_ui_statusbar_music_hide_clock_desc">显示焦点歌词时隐藏状态栏时钟,并调整下拉通知中心的动画</string>
<string name="system_ui_statusbar_music_click_clock_title">点按显示时钟</string>
<string name="system_ui_statusbar_music_click_clock_desc">单击焦点歌词事件变更为显示状态栏时钟,反之隐藏,开关需要重启音乐软件才能生效</string>
<string name="system_ui_statusbar_music_speed_title">歌词滚动速率</string>
<string name="system_ui_statusbar_music_scroll_delay_title">歌词滚动延迟</string>
<string name="system_ui_statusbar_music_width_title">歌词末尾垫宽</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -904,6 +904,8 @@
<string name="system_ui_statusbar_music_cusiom_title">Display settings</string>
<string name="system_ui_statusbar_music_hide_clock_title">Hide status bar clock</string>
<string name="system_ui_statusbar_music_hide_clock_desc">Hide the status bar clock when showing focused lyrics, and adjust the animation of the dropdown Notification shade.</string>
<string name="system_ui_statusbar_music_click_clock_title">Click to show clock</string>
<string name="system_ui_statusbar_music_click_clock_desc">Click the focus lyrics event to change the status bar clock to display, otherwise hide it. The switch needs to restart the corresponding music software to take effect.</string>
<string name="system_ui_statusbar_music_speed_title">Lyrics scroll rate</string>
<string name="system_ui_statusbar_music_scroll_delay_title">Lyrics scroll delay</string>
<string name="system_ui_statusbar_music_width_title">Add whitespace at the end of lyrics</string>
Expand Down
7 changes: 7 additions & 0 deletions app/src/main/res/xml/system_ui_status_bar_music.xml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@
android:summary="@string/system_ui_statusbar_music_hide_clock_desc"
android:title="@string/system_ui_statusbar_music_hide_clock_title" />

<SwitchPreference
android:defaultValue="false"
android:dependency="prefs_key_system_ui_statusbar_music_hide_clock"
android:key="prefs_key_system_ui_statusbar_music_click_clock"
android:summary="@string/system_ui_statusbar_music_click_clock_desc"
android:title="@string/system_ui_statusbar_music_click_clock_title" />

<SeekBarPreferenceCompat
android:defaultValue="18"
android:key="prefs_key_system_ui_statusbar_music_speed"
Expand Down

0 comments on commit 215276b

Please sign in to comment.