From c1ee775ee63a0f4364fb0186f27a753eb399ef04 Mon Sep 17 00:00:00 2001 From: schup011 Date: Thu, 23 May 2024 08:49:33 +0200 Subject: [PATCH 01/11] Added options for displaying song info of classical music (composer, band, conductor) --- .../org/ngo/squeezer/NowPlayingFragment.java | 91 ++++++++++++++++++- .../java/uk/org/ngo/squeezer/Preferences.java | 35 +++++++ .../itemlist/JiveItemListActivity.java | 27 +++++- .../java/uk/org/ngo/squeezer/model/Song.java | 11 +++ .../main/res/layout/now_playing_include.xml | 27 +++++- .../src/main/res/menu/plugin_list_menu.xml | 19 ++++ Squeezer/src/main/res/values-de/strings.xml | 9 +- Squeezer/src/main/res/values/strings.xml | 9 ++ Squeezer/src/main/res/values/styles.xml | 12 +++ build.gradle | 2 +- 10 files changed, 233 insertions(+), 9 deletions(-) diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java index ed63f7aeb..4f720134b 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java @@ -125,10 +125,15 @@ public class NowPlayingFragment extends Fragment implements OnCrollerChangeList private TextView artistText; private TextView trackText; + private TextView conductorText; + private TextView composerText; private JiveItem albumItem; private JiveItem artistItem; + private JiveItem conductorItem; + private JiveItem composerItem; + @Nullable private View btnContextMenu; @@ -281,10 +286,12 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, mFullHeightLayout = (container.getLayoutParams().height == ViewGroup.LayoutParams.MATCH_PARENT); Preferences preferences = Squeezer.getPreferences(); boolean largeArtwork = preferences.isLargeArtwork(); + if (mFullHeightLayout) { v = inflater.inflate(largeArtwork ? R.layout.now_playing_fragment_full_large_artwork : R.layout.now_playing_fragment_full, container, false); artistText = v.findViewById(R.id.artistname); + conductorText = v.findViewById(R.id.conductorname); albumText = v.findViewById(R.id.albumname); shuffleButton = v.findViewById(R.id.shuffle); repeatButton = v.findViewById(R.id.repeat); @@ -292,6 +299,8 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, totalTime = v.findViewById(R.id.totaltime); showRemainingTime = preferences.isShowRemainingTime(); slider = v.findViewById(R.id.seekbar); + artistText.requestFocus(); + if (largeArtwork) { albumArt = v.findViewById(R.id.album); v.findViewById(R.id.icon).setVisibility(View.GONE); @@ -321,6 +330,7 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, } trackText = v.findViewById(R.id.trackname); + composerText = v.findViewById(R.id.composer); playPauseButton = v.findViewById(R.id.pause); nextButton = v.findViewById(R.id.next); @@ -355,6 +365,18 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, } }); + composerText.setOnClickListener(v14 -> { + if (composerItem != null) { + JiveItemListActivity.show(mActivity, composerItem, composerItem.goAction); + } + }); + + conductorText.setOnClickListener(v15 -> { + if (conductorItem != null) { + JiveItemListActivity.show(mActivity, conductorItem, conductorItem.goAction); + } + }); + final GestureDetectorCompat detector = new GestureDetectorCompat(mActivity, new OnSwipeListener() { @Override public boolean onSwipeDown() { @@ -713,7 +735,7 @@ private void updateUiFromPlayerState(@NonNull PlayerState playerState) { @UiThread private void updateSongInfo(@NonNull PlayerState playerState) { updateTimeDisplayTo(playerState.getTrackElapsed(), playerState.getCurrentSongDuration()); - + Preferences preferences = Squeezer.getPreferences(); CurrentPlaylistItem song = playerState.getCurrentSong(); if (song == null) { // Create empty song if this is called (via _HandshakeComplete) before status is received @@ -729,17 +751,78 @@ private void updateSongInfo(@NonNull PlayerState playerState) { boolean canSkip = !((playerState.getCurrentPlaylistTracksNum() == 1) && !playerState.isRemote()); nextButton.setEnabled(canSkip); prevButton.setEnabled(canSkip); + boolean classicalMusicTags = preferences.displayClassicalMusicTags(); if (mFullHeightLayout) { btnContextMenu.setVisibility(View.VISIBLE); - artistText.setText(song.songInfo.getArtist()); - albumText.setText(song.songInfo.album); + composerText.setText(Util.joinSkipEmpty(":", song.songInfo.getComposer(), " ")) ; + boolean addComposerLine = preferences.addComposerLine(); + boolean addConductorLine = preferences.addConductorLine(); + if (!addComposerLine) { + composerText.setVisibility(View.GONE); + } + else { + composerText.setVisibility(View.VISIBLE); + } + + if (classicalMusicTags) { + if (song.songInfo.getArtist() == "") { + artistText.setVisibility(View.GONE); + } + else if (song.songInfo.getBand()!="") { + if (song.songInfo.getArtist().contains(",")) { + artistText.setText(getString(R.string.soloists, song.songInfo.getArtist())); + } + else { + artistText.setText(getString(R.string.soloist, song.songInfo.getArtist())); + } + artistText.setVisibility(View.VISIBLE); + } + else { + artistText.setText(song.songInfo.getArtist()); + artistText.setVisibility(View.VISIBLE); + } + } + else { + artistText.setText(song.songInfo.getArtist()); + artistText.setVisibility(View.VISIBLE); + } + + if (addConductorLine) { + albumText.setText(song.songInfo.getBand()); + if (classicalMusicTags && song.songInfo.getBand()=="") { + albumText.setVisibility(View.GONE); + } + else { + albumText.setVisibility(View.VISIBLE); + } + } + else { + albumText.setText(song.songInfo.album); + albumText.setVisibility(View.VISIBLE); + } + + if (!addConductorLine || song.songInfo.getConductor() == "") { + conductorText.setVisibility(View.GONE); + } + else if (addConductorLine) { + if (classicalMusicTags) { + conductorText.setText(getString(R.string.conductor, song.songInfo.getConductor())); + } + else { + conductorText.setText(song.songInfo.getConductor()); + } + conductorText.setVisibility(View.VISIBLE); + } + requireService().pluginItems(song.moreAction, new IServiceItemListCallback<>() { @Override public void onItemsReceived(int count, int start, Map parameters, List items, Class dataType) { albumItem = findBrowseAction(items, "album_id"); - artistItem = findBrowseAction(items, "artist_id"); + artistItem = findBrowseAction(items, "artist_ids"); + composerItem = findBrowseAction(items, "composer_ids"); + conductorItem = findBrowseAction(items, "conductor_ids"); } @Override diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/Preferences.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/Preferences.java index 4b55644fc..d77b6ccef 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/Preferences.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/Preferences.java @@ -147,6 +147,15 @@ public final class Preferences { // Preferred maximum info per item for a given list layout public static final String KEY_MAX_LINES_FORMAT = "squeezer.%s.maxLines"; + // Add line above track title for showing composer + public static final String KEY_COMPOSER_LINE = "squeezer.add_composer_line"; + + // Add line below artist line for showing conductor and use album line for band + public static final String KEY_CONDUCTOR_LINE = "squeezer.add_conductor_line"; + + // Display artists as "soloists", explicitly show "conductor", and + // collapse band, soloist and conductor lines if not used + public static final String KEY_CLASSICAL_MUSIC_TAGS = "squeezer.display_classical_music_tags"; // Use flat icons or legacy LMS icons public static final String KEY_FLAT_ICONS = "squeezer.use_flat_icons"; @@ -218,6 +227,7 @@ public final class Preferences { // Number of minutes for the custom sleep duration. private static final String KEY_SLEEP_MINUTES = "squeezer.sleep_minutes"; + private final Context context; private final SharedPreferences sharedPreferences; private final int defaultCliPort; @@ -596,6 +606,31 @@ public void setMaxLines(ArtworkListLayout listLayout, int maxLines) { sharedPreferences.edit().putInt(String.format(KEY_MAX_LINES_FORMAT, listLayout.name()), maxLines).apply(); } + + public boolean addComposerLine() { + return sharedPreferences.getBoolean(KEY_COMPOSER_LINE, false); + } + + public void addComposerLine(boolean b) { + sharedPreferences.edit().putBoolean(Preferences.KEY_COMPOSER_LINE, b).apply(); + } + + public boolean addConductorLine() { + return sharedPreferences.getBoolean(KEY_CONDUCTOR_LINE, false); + } + + public void addConductorLine(boolean b) { + sharedPreferences.edit().putBoolean(Preferences.KEY_CONDUCTOR_LINE, b).apply(); + } + + public boolean displayClassicalMusicTags() { + return sharedPreferences.getBoolean(KEY_CLASSICAL_MUSIC_TAGS, false); + } + + public void displayClassicalMusicTags(boolean b) { + sharedPreferences.edit().putBoolean(Preferences.KEY_CLASSICAL_MUSIC_TAGS, b).apply(); + } + public boolean useFlatIcons() { return sharedPreferences.getBoolean(KEY_FLAT_ICONS, true); } diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/itemlist/JiveItemListActivity.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/itemlist/JiveItemListActivity.java index 4a389b739..d32caaef9 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/itemlist/JiveItemListActivity.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/itemlist/JiveItemListActivity.java @@ -107,6 +107,11 @@ public class JiveItemListActivity extends BaseListActivity parentViewHolder; @@ -597,6 +602,9 @@ public boolean onCreateOptionsMenu(Menu menu) { menuItemOneLine = viewMenu.findItem(R.id.menu_item_one_line); menuItemTwoLines = viewMenu.findItem(R.id.menu_item_two_lines); menuItemAllInfo = viewMenu.findItem(R.id.menu_item_all_lines); + menuItemComposerLine = viewMenu.findItem(R.id.menu_item_composer_line); + menuItemConductorLine = viewMenu.findItem(R.id.menu_item_conductor_line); + menuItemClassicalMusicTags = viewMenu.findItem(R.id.menu_item_classical_music_tags); menuItemFlatIcons = viewMenu.findItem(R.id.menu_item_flat_icons); return super.onCreateOptionsMenu(menu); } @@ -669,6 +677,21 @@ public boolean onOptionsItemSelected(MenuItem item) { } else if (itemId == R.id.menu_item_all_lines) { setMaxLines(0); return true; + } else if (itemId == R.id.menu_item_composer_line) { + Squeezer.getPreferences().addComposerLine(!menuItemComposerLine.isChecked()); + updateViewMenuItems(getListLayout(), window.windowStyle); + getItemAdapter().notifyItemRangeChanged(0, getItemAdapter().getItemCount()); + return true; + } else if (itemId == R.id.menu_item_conductor_line) { + Squeezer.getPreferences().addConductorLine(!menuItemConductorLine.isChecked()); + updateViewMenuItems(getListLayout(), window.windowStyle); + getItemAdapter().notifyItemRangeChanged(0, getItemAdapter().getItemCount()); + return true; + } else if (itemId == R.id.menu_item_classical_music_tags) { + Squeezer.getPreferences().displayClassicalMusicTags(!menuItemClassicalMusicTags.isChecked()); + updateViewMenuItems(getListLayout(), window.windowStyle); + getItemAdapter().notifyItemRangeChanged(0, getItemAdapter().getItemCount()); + return true; } else if (itemId == R.id.menu_item_flat_icons) { Squeezer.getPreferences().useFlatIcons(!menuItemFlatIcons.isChecked()); getItemAdapter().notifyItemRangeChanged(0, getItemAdapter().getItemCount()); @@ -704,7 +727,9 @@ private void updateViewMenuItems(ArtworkListLayout listLayout, Window.WindowStyl menuItemAllInfo.setChecked(true); break; } - + menuItemComposerLine.setChecked(preferences.addComposerLine()); + menuItemConductorLine.setChecked(preferences.addConductorLine()); + menuItemClassicalMusicTags.setChecked(preferences.displayClassicalMusicTags()); menuItemFlatIcons.setChecked(preferences.useFlatIcons()); } } diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/model/Song.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/model/Song.java index 1773d8a6e..572389341 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/model/Song.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/model/Song.java @@ -126,6 +126,17 @@ public String getArtist() { return TextUtils.join(", ", artists); } + public String getBand() { + return TextUtils.join(", ", bands); + } + + public String getConductor() { + return TextUtils.join(", ", conductors); + } + + public String getComposer() { + return TextUtils.join(", ", composers); + } public String getAlbumArtists() { return TextUtils.join(", ", albumArtists); } diff --git a/Squeezer/src/main/res/layout/now_playing_include.xml b/Squeezer/src/main/res/layout/now_playing_include.xml index f5fd440ef..3c5ca509c 100644 --- a/Squeezer/src/main/res/layout/now_playing_include.xml +++ b/Squeezer/src/main/res/layout/now_playing_include.xml @@ -32,17 +32,31 @@ will not change size when then the layout is recalculated, and the text continues to scroll. --> + + + + @@ -81,6 +95,15 @@ app:layout_constraintEnd_toStartOf="@+id/context_menu" style="@style/SqueezerWidget.NowPlaying.ArtistName" /> + + + + + + + diff --git a/Squeezer/src/main/res/values-de/strings.xml b/Squeezer/src/main/res/values-de/strings.xml index 0d7428736..41bfdcad0 100644 --- a/Squeezer/src/main/res/values-de/strings.xml +++ b/Squeezer/src/main/res/values-de/strings.xml @@ -33,6 +33,11 @@ Erscheinungsbild Dunkel Hell, dunkle Aktionsleiste + Komponist anzeigen + Trackinfo für klassiche Musik + Orchester und Dirigent anzeigen + Flache Icons + Nicht nachfragen Vor dem Löschen der Wiedergabeliste Benutzername (optional) @@ -112,7 +117,9 @@ Unbekanntes Album Unbekannter Künstler Unbekannter Künstler/Album - + Dirigent: %s + Solist: %s + Solisten: %s Individuelle Alarme können aktiviert werden. Alle Alarme wurden daktiviert diff --git a/Squeezer/src/main/res/values/strings.xml b/Squeezer/src/main/res/values/strings.xml index d5ac8c9ed..61aff853a 100644 --- a/Squeezer/src/main/res/values/strings.xml +++ b/Squeezer/src/main/res/values/strings.xml @@ -40,6 +40,9 @@ No Yes Show clock when idle + Show composer + Classical music information + Show band and conductor Flat icons When clearing a playlist do not ask for confirmation @@ -126,6 +129,12 @@ Unknown album Unknown artist Unknown artist/album + Conductor: %s + Soloist: %s + Soloists: %s + + + Individual alarms can be enabled diff --git a/Squeezer/src/main/res/values/styles.xml b/Squeezer/src/main/res/values/styles.xml index 359047ff7..1517cbee9 100644 --- a/Squeezer/src/main/res/values/styles.xml +++ b/Squeezer/src/main/res/values/styles.xml @@ -117,9 +117,11 @@ + + + + @@ -186,7 +185,6 @@ From 1f80b45466a9e07a45d4da8dc04fced8eedec783 Mon Sep 17 00:00:00 2001 From: schup011 Date: Wed, 5 Jun 2024 20:27:10 +0200 Subject: [PATCH 06/11] Cleanups and file renaming --- .../java/uk/org/ngo/squeezer/NowPlayingActivity.java | 9 ++------- .../java/uk/org/ngo/squeezer/NowPlayingFragment.java | 2 +- .../src/main/java/uk/org/ngo/squeezer/Preferences.java | 2 -- .../org/ngo/squeezer/itemlist/JiveItemListActivity.java | 4 ++-- .../menu/{plugin_list_menu.xml => jiveitemlist_menu.xml} | 1 - .../{plugin_nowplaying_menu.xml => nowplaying_menu.xml} | 4 ++-- 6 files changed, 7 insertions(+), 15 deletions(-) rename Squeezer/src/main/res/menu/{plugin_list_menu.xml => jiveitemlist_menu.xml} (99%) rename Squeezer/src/main/res/menu/{plugin_nowplaying_menu.xml => nowplaying_menu.xml} (97%) diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingActivity.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingActivity.java index ff3cc7a59..cc9fd74e8 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingActivity.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingActivity.java @@ -35,12 +35,10 @@ public class NowPlayingActivity extends BaseActivity { * Called when the activity is first created. */ - private MenuItem menuItemComposerLine; private MenuItem menuItemConductorLine; private MenuItem menuItemClassicalMusicTags; - @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -68,10 +66,9 @@ public static void show(Context context) { @Override public boolean onCreateOptionsMenu(Menu menu) { - Menu trackInfoMenu; - getMenuInflater().inflate(R.menu.plugin_nowplaying_menu, menu); + getMenuInflater().inflate(R.menu.nowplaying_menu, menu); trackInfoMenu = menu.findItem(R.id.menu_nowplaying_trackinfo).getSubMenu(); MenuCompat.setGroupDividerEnabled(trackInfoMenu, true); @@ -113,10 +110,10 @@ public boolean onOptionsItemSelected(MenuItem item) { NowPlayingActivity.show(this); return true; } + return super.onOptionsItemSelected(item); } - private void updateTrackInfoMenuItems() { if (menuItemComposerLine != null) { Preferences preferences = Squeezer.getPreferences(); @@ -127,7 +124,6 @@ private void updateTrackInfoMenuItems() { } } - @Override public void onPause() { if (isFinishing()) { @@ -136,5 +132,4 @@ public void onPause() { super.onPause(); } - } diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java index fdf65f6e8..9d3261926 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java @@ -299,7 +299,6 @@ public View onCreateView(@NonNull LayoutInflater inflater, ViewGroup container, totalTime = v.findViewById(R.id.totaltime); showRemainingTime = preferences.isShowRemainingTime(); slider = v.findViewById(R.id.seekbar); - artistText.requestFocus(); if (largeArtwork) { albumArt = v.findViewById(R.id.album); @@ -734,6 +733,7 @@ private void updateUiFromPlayerState(@NonNull PlayerState playerState) { @UiThread private void updateSongInfo(@NonNull PlayerState playerState) { updateTimeDisplayTo(playerState.getTrackElapsed(), playerState.getCurrentSongDuration()); + Preferences preferences = Squeezer.getPreferences(); CurrentPlaylistItem song = playerState.getCurrentSong(); if (song == null) { diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/Preferences.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/Preferences.java index 7bf1cc20f..5a633b66c 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/Preferences.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/Preferences.java @@ -234,7 +234,6 @@ public final class Preferences { // Number of minutes for the custom sleep duration. private static final String KEY_SLEEP_MINUTES = "squeezer.sleep_minutes"; - private final Context context; private final SharedPreferences sharedPreferences; private final int defaultCliPort; @@ -628,7 +627,6 @@ public void setMaxLines(ArtworkListLayout listLayout, int maxLines) { sharedPreferences.edit().putInt(String.format(KEY_MAX_LINES_FORMAT, listLayout.name()), maxLines).apply(); } - public boolean addComposerLine() { return sharedPreferences.getBoolean(KEY_COMPOSER_LINE, false); } diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/itemlist/JiveItemListActivity.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/itemlist/JiveItemListActivity.java index 0107ba67e..137710686 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/itemlist/JiveItemListActivity.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/itemlist/JiveItemListActivity.java @@ -107,7 +107,6 @@ public class JiveItemListActivity extends BaseListActivity parentViewHolder; @@ -580,7 +579,7 @@ public void onDialogDismissed(DialogInterface dialog) { @Override public boolean onCreateOptionsMenu(Menu menu) { - getMenuInflater().inflate(R.menu.plugin_list_menu, menu); + getMenuInflater().inflate(R.menu.jiveitemlist_menu, menu); viewMenu = menu.findItem(R.id.menu_item_view).getSubMenu(); MenuCompat.setGroupDividerEnabled(viewMenu, true); menuItemLight = viewMenu.findItem(R.id.menu_item_light); @@ -697,6 +696,7 @@ private void updateViewMenuItems(ArtworkListLayout listLayout, Window.WindowStyl menuItemAllInfo.setChecked(true); break; } + menuItemFlatIcons.setChecked(preferences.useFlatIcons()); } } diff --git a/Squeezer/src/main/res/menu/plugin_list_menu.xml b/Squeezer/src/main/res/menu/jiveitemlist_menu.xml similarity index 99% rename from Squeezer/src/main/res/menu/plugin_list_menu.xml rename to Squeezer/src/main/res/menu/jiveitemlist_menu.xml index f9f9925e3..772493aa4 100644 --- a/Squeezer/src/main/res/menu/plugin_list_menu.xml +++ b/Squeezer/src/main/res/menu/jiveitemlist_menu.xml @@ -80,7 +80,6 @@ app:showAsAction="never" /> - diff --git a/Squeezer/src/main/res/menu/plugin_nowplaying_menu.xml b/Squeezer/src/main/res/menu/nowplaying_menu.xml similarity index 97% rename from Squeezer/src/main/res/menu/plugin_nowplaying_menu.xml rename to Squeezer/src/main/res/menu/nowplaying_menu.xml index e745a9a52..f911bceff 100644 --- a/Squeezer/src/main/res/menu/plugin_nowplaying_menu.xml +++ b/Squeezer/src/main/res/menu/nowplaying_menu.xml @@ -42,8 +42,8 @@ android:id="@+id/menu_item_classical_music_tags" android:title="@string/settings_band_instead_album" app:showAsAction="never" - /> - + /> + From 82c4f95befd599741aef73cfa04527b192891c36 Mon Sep 17 00:00:00 2001 From: schup011 Date: Wed, 5 Jun 2024 20:38:18 +0200 Subject: [PATCH 07/11] Cleanup --- Squeezer/src/main/res/layout/now_playing_include.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/Squeezer/src/main/res/layout/now_playing_include.xml b/Squeezer/src/main/res/layout/now_playing_include.xml index e8fa24d50..485b6b0fa 100644 --- a/Squeezer/src/main/res/layout/now_playing_include.xml +++ b/Squeezer/src/main/res/layout/now_playing_include.xml @@ -38,7 +38,6 @@ reset. Wrapping the trackname TextView in a LinearLayout means that the TextView will not change size when then the layout is recalculated, and the text continues to scroll. --> - From 67024ea713d0cf127ce46613cf33ff9f0d47cc8e Mon Sep 17 00:00:00 2001 From: schup011 Date: Mon, 10 Jun 2024 09:33:06 +0200 Subject: [PATCH 08/11] - Corrected string comparisons - Further code improvements --- .../org/ngo/squeezer/NowPlayingFragment.java | 25 ++++++------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java index 9d3261926..547d544af 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java @@ -750,19 +750,14 @@ private void updateSongInfo(@NonNull PlayerState playerState) { boolean canSkip = !((playerState.getCurrentPlaylistTracksNum() == 1) && !playerState.isRemote()); nextButton.setEnabled(canSkip); prevButton.setEnabled(canSkip); - boolean classicalMusicTags = preferences.displayClassicalMusicTags(); if (mFullHeightLayout) { btnContextMenu.setVisibility(View.VISIBLE); composerText.setText(Util.joinSkipEmpty(":", song.songInfo.getComposer(), " ")) ; boolean addComposerLine = preferences.addComposerLine(); boolean addConductorLine = preferences.addConductorLine(); - if (!addComposerLine) { - composerText.setVisibility(View.GONE); - } - else { - composerText.setVisibility(View.VISIBLE); - } + boolean classicalMusicTags = preferences.displayClassicalMusicTags(); + composerText.setVisibility(addComposerLine ? View.VISIBLE : View.GONE); if (classicalMusicTags) { if (TextUtils.isEmpty(song.songInfo.getArtist())) { @@ -773,8 +768,7 @@ private void updateSongInfo(@NonNull PlayerState playerState) { else if (!TextUtils.isEmpty(song.songInfo.getBand())) { // Show description of soloists, depending on whether there is // one or more of them - if (song.songInfo.getArtist().contains(",")) { - + if (song.songInfo.artists.length>1) { artistText.setText(getString(R.string.soloists, song.songInfo.getArtist())); } else { @@ -795,14 +789,11 @@ else if (!TextUtils.isEmpty(song.songInfo.getBand())) { if (addConductorLine) { // show band instead of album albumText.setText(song.songInfo.getBand()); - if (classicalMusicTags && song.songInfo.getBand()=="") { - // remove album line if there is no band - albumText.setVisibility(View.GONE); - } - else { - albumText.setVisibility(View.VISIBLE); - } - if (!classicalMusicTags && song.songInfo.getBand()=="") { + + // remove album line if there is no band + albumText.setVisibility((classicalMusicTags && TextUtils.isEmpty(song.songInfo.getBand())) ? View.GONE : View.VISIBLE); + + if (!classicalMusicTags && TextUtils.isEmpty(song.songInfo.getBand())) { // don't show "Unknown album" if line is intended // for showing the band and there is no band albumText.setText(" "); From 8afc9c610a1948cc87307f5256452ce08fd371ce Mon Sep 17 00:00:00 2001 From: schup011 Date: Tue, 11 Jun 2024 20:01:29 +0200 Subject: [PATCH 09/11] - Added composer, band, conductor for now playing mini layout. - Removed colon after composer -> more "universal" appearance. --- .../org/ngo/squeezer/NowPlayingFragment.java | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java index 547d544af..003a23830 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/NowPlayingFragment.java @@ -743,7 +743,6 @@ private void updateSongInfo(@NonNull PlayerState playerState) { // TODO handle button remapping (buttons in status response) if (!song.getName().isEmpty()) { - trackText.setText(song.getName()); // don't remove rew and fwd for remote tracks, because a single track playlist // is not an indication that fwd and rwd are invalid actions @@ -751,13 +750,17 @@ private void updateSongInfo(@NonNull PlayerState playerState) { nextButton.setEnabled(canSkip); prevButton.setEnabled(canSkip); + boolean addComposerLine = preferences.addComposerLine(); + boolean addConductorLine = preferences.addConductorLine(); + boolean classicalMusicTags = preferences.displayClassicalMusicTags(); + + trackText.setText(addComposerLine && !mFullHeightLayout ? Util.joinSkipEmpty(": ", song.songInfo.getComposer(), song.getName()) : song.getName()); + if (mFullHeightLayout) { btnContextMenu.setVisibility(View.VISIBLE); - composerText.setText(Util.joinSkipEmpty(":", song.songInfo.getComposer(), " ")) ; - boolean addComposerLine = preferences.addComposerLine(); - boolean addConductorLine = preferences.addConductorLine(); - boolean classicalMusicTags = preferences.displayClassicalMusicTags(); - composerText.setVisibility(addComposerLine ? View.VISIBLE : View.GONE); + + composerText.setText(song.songInfo.getComposer()); + composerText.setVisibility(addComposerLine && !TextUtils.isEmpty(song.songInfo.getComposer()) ? View.VISIBLE : View.GONE); if (classicalMusicTags) { if (TextUtils.isEmpty(song.songInfo.getArtist())) { @@ -820,7 +823,8 @@ else if (!TextUtils.isEmpty(song.songInfo.getBand())) { // remove line if it should not be shown conductorText.setVisibility(View.GONE); } - + artistText.setSelected(true); + albumText.setSelected(true); requireService().pluginItems(song.moreAction, new IServiceItemListCallback<>() { @Override @@ -837,7 +841,13 @@ public Object getClient() { } }); } else { - artistAlbumText.setText(song.artistAlbum()); + if (addConductorLine) { + artistAlbumText.setText(Util.joinSkipEmpty(" - ", song.songInfo.getArtist(), song.songInfo.getBand(),song.songInfo.getConductor())); + } + else { + artistAlbumText.setText(song.artistAlbum()); + } + artistAlbumText.setSelected(true); } } else { trackText.setText(""); From f8839d8c06afc40c578429ff9de193b7f9e47d2d Mon Sep 17 00:00:00 2001 From: schup011 Date: Tue, 11 Jun 2024 20:28:31 +0200 Subject: [PATCH 10/11] - Make album, artist and combined line (mini layout) marquee. --- Squeezer/src/main/res/values/styles.xml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Squeezer/src/main/res/values/styles.xml b/Squeezer/src/main/res/values/styles.xml index 42d641153..de82b089a 100644 --- a/Squeezer/src/main/res/values/styles.xml +++ b/Squeezer/src/main/res/values/styles.xml @@ -174,12 +174,12 @@ @style/SqueezerTextAppearance.NowPlaying.SongName - - @@ -203,7 +203,7 @@ @style/SqueezerTextAppearance.NowPlayingMini.SongName - From b65c256909d2408703ee49efb8df9c38c382da39 Mon Sep 17 00:00:00 2001 From: schup011 Date: Tue, 11 Jun 2024 20:43:14 +0200 Subject: [PATCH 11/11] - Added composer, band/conductor and classical music tags settings to global settings --- .../uk/org/ngo/squeezer/SettingsFragment.java | 13 +++++++++++ Squeezer/src/main/res/values-de/strings.xml | 13 +++++++++++ Squeezer/src/main/res/values/strings.xml | 12 ++++++++++ Squeezer/src/main/res/xml/preferences.xml | 23 +++++++++++++++++++ 4 files changed, 61 insertions(+) diff --git a/Squeezer/src/main/java/uk/org/ngo/squeezer/SettingsFragment.java b/Squeezer/src/main/java/uk/org/ngo/squeezer/SettingsFragment.java index 9cca81584..7bd403b8f 100644 --- a/Squeezer/src/main/java/uk/org/ngo/squeezer/SettingsFragment.java +++ b/Squeezer/src/main/java/uk/org/ngo/squeezer/SettingsFragment.java @@ -81,6 +81,8 @@ public void onCreatePreferences(Bundle savedInstanceState, String rootKey) { fillDisplayPreferences(preferences); + fillNowPlayingPreferences(preferences); + fillUserInterfacePreferences(preferences); fillScrobblePreferences(sharedPreferences); @@ -187,6 +189,17 @@ private void fillDisplayPreferences(Preferences preferences) { fillEnumPreference(screensaverPref, Preferences.ScreensaverMode.class, preferences.getScreensaverMode()); } + private void fillNowPlayingPreferences(Preferences preferences) { + final SwitchPreferenceCompat addComposerLine = findPreference(Preferences.KEY_COMPOSER_LINE); + addComposerLine.setChecked(preferences.addComposerLine()); + + final SwitchPreferenceCompat addConductorLine = findPreference(Preferences.KEY_CONDUCTOR_LINE); + addConductorLine.setChecked(preferences.addConductorLine()); + + final SwitchPreferenceCompat displayClassicalMusicAppearance = findPreference(Preferences.KEY_CLASSICAL_MUSIC_TAGS); + displayClassicalMusicAppearance.setChecked(preferences.displayClassicalMusicTags()); + } + private void fillUserInterfacePreferences(Preferences preferences) { final SwitchPreferenceCompat clearPlaylistConfirmation = findPreference(Preferences.KEY_CLEAR_PLAYLIST_CONFIRMATION); clearPlaylistConfirmation.setChecked(preferences.isClearPlaylistConfirmation()); diff --git a/Squeezer/src/main/res/values-de/strings.xml b/Squeezer/src/main/res/values-de/strings.xml index 3fa1c6f9a..3b0d9018d 100644 --- a/Squeezer/src/main/res/values-de/strings.xml +++ b/Squeezer/src/main/res/values-de/strings.xml @@ -118,6 +118,19 @@ Dirigent: %s Solist: %s Solisten: %s + + + NowPlaying Titel-Informationen + Zeige Komponist nicht an + Zeige Komponist vor dem Track-Titel + Anzeige des Komponisten + Zeige Band / Orchester und Dirigent nicht an + Zeige Band / Orchester statt Album, sowie Dirigent auf separater Zeile + Anzeige von Band / Orchester und Dirigent + Normale Anzeige + Angepasst auf klassische Musik, mit Beschriftung von Dirigent und Solisten + Anzeige der Titel-Informationen + Individuelle Alarme können aktiviert werden Alle Alarme wurden deaktiviert diff --git a/Squeezer/src/main/res/values/strings.xml b/Squeezer/src/main/res/values/strings.xml index 3701e6509..6f64581db 100644 --- a/Squeezer/src/main/res/values/strings.xml +++ b/Squeezer/src/main/res/values/strings.xml @@ -138,6 +138,18 @@ Soloist: %s Soloists: %s + + NowPlaying track information + Don\'t show composer + Show composer in front of the track title + Composer information + Don\'t show band/orchestra and conductor + Show band/orchestra instead of album and show conductor on separate line + Band/orchestra and conductor information + Normal behavior + Adapted to classical music, including description of conductor and soloists + Appearance of track information + Individual alarms can be enabled All alarms are disabled diff --git a/Squeezer/src/main/res/xml/preferences.xml b/Squeezer/src/main/res/xml/preferences.xml index 240be0505..1b00bf2eb 100644 --- a/Squeezer/src/main/res/xml/preferences.xml +++ b/Squeezer/src/main/res/xml/preferences.xml @@ -46,6 +46,29 @@ android:summary="%s"/> + + + + + + + + + +