Skip to content

Commit

Permalink
Option to hide buttons in player notification
Browse files Browse the repository at this point in the history
  • Loading branch information
z-huang committed Oct 30, 2022
1 parent 41bf223 commit a5b37e6
Show file tree
Hide file tree
Showing 19 changed files with 59 additions and 7 deletions.
7 changes: 6 additions & 1 deletion app/src/main/java/com/zionhuang/music/playback/SongPlayer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ class SongPlayer(

override fun getCustomActions(player: Player): List<String> {
val actions = mutableListOf<String>()
if (player.currentMetadata != null) {
if (player.currentMetadata != null && context.sharedPreferences.getBoolean(context.getString(R.string.pref_notification_more_action), true)) {
actions.add(if (currentSong == null) ACTION_ADD_TO_LIBRARY else ACTION_REMOVE_FROM_LIBRARY)
actions.add(if (currentSong?.song?.liked == true) ACTION_UNLIKE else ACTION_LIKE)
}
Expand Down Expand Up @@ -393,6 +393,11 @@ class SongPlayer(
}
}
}
scope.launch {
context.sharedPreferences.booleanFlow(context.getString(R.string.pref_notification_more_action), true).collectLatest {
playerNotificationManager.invalidate()
}
}
if (context.sharedPreferences.getBoolean(context.getString(R.string.pref_persistent_queue), true)) {
runCatching {
context.filesDir.resolve(PERSISTENT_QUEUE_FILE).inputStream().use { fis ->
Expand Down
10 changes: 10 additions & 0 deletions app/src/main/res/drawable/ic_notifications.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:tint="?colorControlNormal"
android:viewportWidth="24"
android:viewportHeight="24">
<path
android:fillColor="@android:color/white"
android:pathData="M12,22c1.1,0 2,-0.9 2,-2h-4c0,1.1 0.89,2 2,2zM18,16v-5c0,-3.07 -1.64,-5.64 -4.5,-6.32L13.5,4c0,-0.83 -0.67,-1.5 -1.5,-1.5s-1.5,0.67 -1.5,1.5v0.68C7.63,5.36 6,7.92 6,11v5l-2,2v1h16v-1l-2,-2z" />
</vector>
2 changes: 2 additions & 0 deletions app/src/main/res/values-es-rUS/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">Añadir automáticamente la canción a la biblioteca</string>
<string name="pref_auto_add_song_summary">Añadir canción a la biblioteca cuando termine de reproducirse</string>
<string name="pref_expand_on_play_title">Expandir reproductor inferior cuando comience la reproducción</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Privacy</string>
<string name="pref_pause_search_history_title">Pause search history</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-es/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">Agregar canción automáticamente a la biblioteca</string>
<string name="pref_auto_add_song_summary">Agregue una canción a su biblioteca cuando termine de reproducirse</string>
<string name="pref_expand_on_play_title">Expandir reproductor inferior al reproducir</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Privacy</string>
<string name="pref_pause_search_history_title">Pause search history</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fa-rIR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">افزودن خودکار آهنگ به کتاب‌خانه</string>
<string name="pref_auto_add_song_summary">افزودن آهنگ به کتاب‌خانه پس از اتمام پخش</string>
<string name="pref_expand_on_play_title">گسترش پخش‌کننده‌ی پایین هنگام پخش</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">حریم‌خصوصی</string>
<string name="pref_pause_search_history_title">متوقف‌کردن تاریخچه جستجو</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fi-rFI/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">Automaattinen vienti kirjastoon</string>
<string name="pref_auto_add_song_summary">Lisää kappale kirjastoon automaattisesti, kun se on soitettu</string>
<string name="pref_expand_on_play_title">Laajenna alapalkki toistaessa</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Privacy</string>
<string name="pref_pause_search_history_title">Pause search history</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-fr-rFR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">Ajout automatique de chansons à la bibliothèque</string>
<string name="pref_auto_add_song_summary">Add song to your library when it completes playing</string>
<string name="pref_expand_on_play_title">Ajouter la chanson à votre bibliothèque lorsqu\'elle est terminée.</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Privacy</string>
<string name="pref_pause_search_history_title">Pause search history</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-hu/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">Dal auto. hozzáadása a könyvtárhoz</string>
<string name="pref_auto_add_song_summary">Adja hozzá a dalt a könyvtárához, amikor a lejátszás befejeződött</string>
<string name="pref_expand_on_play_title">Bontsa ki az alsó lejátszót lejátszás közben</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Adatvédelem</string>
<string name="pref_pause_search_history_title">Keresési előzmények szüneteltetése</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-it/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">Aggiunta automatica nella libreria</string>
<string name="pref_auto_add_song_summary">Aggiungi la canzone nella tua libreria quando viene terminato l\'ascolto</string>
<string name="pref_expand_on_play_title">Espandi il riproduttore in basso quando inizia un ascolto</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Privacy</string>
<string name="pref_pause_search_history_title">Sospendi la cronologia delle ricerche</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ja-rJP/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">曲を自動でライブラリに追加</string>
<string name="pref_auto_add_song_summary">再生が終了したら曲をライブラリに追加する</string>
<string name="pref_expand_on_play_title">再生時にボトムプレイヤーを展開する</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">プライバシー</string>
<string name="pref_pause_search_history_title">履歴の記録を一時停止</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ko-rKR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">라이브러리에 노래 자동 추가</string>
<string name="pref_auto_add_song_summary">재생이 완료되면 라이브러리에 노래 추가</string>
<string name="pref_expand_on_play_title">플레이 시 하단 플레이어 확장</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Privacy</string>
<string name="pref_pause_search_history_title">Pause search history</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-ml-rIN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">ലൈബ്രറിയിലേക്ക് പാട്ട് സ്വയമേവ ചേർക്കുക</string>
<string name="pref_auto_add_song_summary">നിങ്ങളുടെ ലൈബ്രറി പ്ലേ ചെയ്യുമ്പോൾ പാട്ട് ചേർക്കുക</string>
<string name="pref_expand_on_play_title">താഴെയുള്ള പ്ലേയർ വികസിപ്പിക്കുക</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">സ്വകാര്യത</string>
<string name="pref_pause_search_history_title">തിരയൽ ചരിത്രം താൽക്കാലികമായി നിർത്തുക</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-pt-rBR/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">Adicionar música à biblioteca automaticamente</string>
<string name="pref_auto_add_song_summary">Adicionar música à sua biblioteca quando terminar de ser reproduzida</string>
<string name="pref_expand_on_play_title">Expandir player ao reproduzir</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Privacidade</string>
<string name="pref_pause_search_history_title">Pausar histórico de pesquisa</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-sv-rSE/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">Lägg till låt i biblioteket automatiskt</string>
<string name="pref_auto_add_song_summary">Lägg till låten i biblioteket efter det spelats klart</string>
<string name="pref_expand_on_play_title">Utöka bottenspelaren vid låtspel</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Privacy</string>
<string name="pref_pause_search_history_title">Pause search history</string>
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 @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">自动将音乐添加到媒体库</string>
<string name="pref_auto_add_song_summary">播放结束时添加到媒体库</string>
<string name="pref_expand_on_play_title">播放音乐时展开播放器</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">隐私</string>
<string name="pref_pause_search_history_title">暂停搜索记录</string>
Expand Down
2 changes: 2 additions & 0 deletions app/src/main/res/values-zh-rTW/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">自動將音樂加入媒體庫</string>
<string name="pref_auto_add_song_summary">在結束播放時加入你的音樂</string>
<string name="pref_expand_on_play_title">在點擊音樂時展開播放器</string>
<string name="pref_notification_more_action_title">在通知顯示更多按鈕</string>
<string name="pref_notification_more_action_summary">顯示「加入媒體庫」和「喜歡」按鈕</string>

<string name="pref_privacy_title">隱私</string>
<string name="pref_pause_search_history_title">暫停搜尋紀錄</string>
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/constants.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<string name="pref_auto_download" translatable="false">AUTO_DOWNLOAD</string>
<string name="pref_auto_add_song" translatable="false">AUTO_ADD_SONG</string>
<string name="pref_expand_on_play" translatable="false">EXPAND_ON_PLAY</string>
<string name="pref_notification_more_action" translatable="false">NOTIFICATION_MORE_ACTION</string>
<string name="pref_equalizer" translatable="false">EQUALIZER</string>

<string name="pref_open_saf" translatable="false">OPEN_SAF</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 @@ -58,6 +58,8 @@
<string name="pref_auto_add_song_title">Auto add song to library</string>
<string name="pref_auto_add_song_summary">Add song to your library when it completes playing</string>
<string name="pref_expand_on_play_title">Expand bottom player on play</string>
<string name="pref_notification_more_action_title">More actions in notification</string>
<string name="pref_notification_more_action_summary">Show add to library and like buttons</string>

<string name="pref_privacy_title">Privacy</string>
<string name="pref_pause_search_history_title">Pause search history</string>
Expand Down
18 changes: 12 additions & 6 deletions app/src/main/res/xml/pref_general.xml
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<SwitchPreferenceCompat
android:defaultValue="false"
app:icon="@drawable/ic_save_alt"
app:key="@string/pref_auto_download"
app:summary="@string/pref_auto_download_summary"
app:title="@string/pref_auto_download_title" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_library_add"
android:key="@string/pref_auto_add_song"
android:summary="@string/pref_auto_add_song_summary"
android:title="@string/pref_auto_add_song_title" />
<SwitchPreferenceCompat
android:defaultValue="false"
app:icon="@drawable/ic_save_alt"
app:key="@string/pref_auto_download"
app:summary="@string/pref_auto_download_summary"
app:title="@string/pref_auto_download_title" />
<SwitchPreferenceCompat
android:defaultValue="false"
android:icon="@drawable/ic_open_in_full"
android:key="@string/pref_expand_on_play"
android:title="@string/pref_expand_on_play_title" />
<SwitchPreferenceCompat
android:defaultValue="true"
android:icon="@drawable/ic_notifications"
android:key="@string/pref_notification_more_action"
android:summary="@string/pref_notification_more_action_summary"
android:title="@string/pref_notification_more_action_title" />
</PreferenceScreen>

0 comments on commit a5b37e6

Please sign in to comment.