From 0377c5e939012b7ebcff2fc4f9b877d97aefc391 Mon Sep 17 00:00:00 2001 From: eddyizm Date: Sun, 24 Aug 2025 18:55:36 -0700 Subject: [PATCH] feat: setting to show/hide 5 star rating on playerview --- .../ui/fragment/PlayerControllerFragment.java | 15 +++++++++++++++ .../cappielloantonio/tempo/util/Preferences.kt | 6 ++++++ app/src/main/res/values/strings.xml | 2 ++ app/src/main/res/xml/global_preferences.xml | 6 ++++++ 4 files changed, 29 insertions(+) diff --git a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerControllerFragment.java b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerControllerFragment.java index a07d58ec..99f3c4ca 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerControllerFragment.java +++ b/app/src/main/java/com/cappielloantonio/tempo/ui/fragment/PlayerControllerFragment.java @@ -8,6 +8,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.Button; import android.widget.ImageButton; +import android.widget.LinearLayout; import android.widget.TextView; import android.widget.ToggleButton; import android.widget.RatingBar; @@ -66,6 +67,7 @@ public class PlayerControllerFragment extends Fragment { private ConstraintLayout playerQuickActionView; private ImageButton playerOpenQueueButton; private ImageButton playerTrackInfo; + private LinearLayout ratingContainer; private MainActivity activity; private PlayerBottomSheetViewModel playerBottomSheetViewModel; @@ -123,6 +125,8 @@ public class PlayerControllerFragment extends Fragment { playerOpenQueueButton = bind.getRoot().findViewById(R.id.player_open_queue_button); playerTrackInfo = bind.getRoot().findViewById(R.id.player_info_track); songRatingBar = bind.getRoot().findViewById(R.id.song_rating_bar); + ratingContainer = bind.getRoot().findViewById(R.id.rating_container); + checkAndSetRatingContainerVisibility(); } private void initQuickActionView() { @@ -430,6 +434,17 @@ public class PlayerControllerFragment extends Fragment { playerMediaCoverViewPager.setCurrentItem(1, true); } + private void checkAndSetRatingContainerVisibility() { + if (ratingContainer == null) return; + + if (Preferences.showItemStarRating()) { + ratingContainer.setVisibility(View.VISIBLE); + } + else { + ratingContainer.setVisibility(View.GONE); + } + } + private void setPlaybackParameters(MediaBrowser mediaBrowser) { Button playbackSpeedButton = bind.getRoot().findViewById(R.id.player_playback_speed_button); float currentSpeed = Preferences.getPlaybackSpeed(); diff --git a/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt b/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt index e7a4c459..c7bfe993 100644 --- a/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt +++ b/app/src/main/java/com/cappielloantonio/tempo/util/Preferences.kt @@ -63,6 +63,7 @@ object Preferences { private const val ALWAYS_ON_DISPLAY = "always_on_display" private const val AUDIO_QUALITY_PER_ITEM = "audio_quality_per_item" private const val HOME_SECTOR_LIST = "home_sector_list" + private const val SONG_RATING_PER_ITEM = "song_rating_per_item" private const val RATING_PER_ITEM = "rating_per_item" private const val NEXT_UPDATE_CHECK = "next_update_check" private const val CONTINUOUS_PLAY = "continuous_play" @@ -486,6 +487,11 @@ object Preferences { App.getInstance().preferences.edit().putString(HOME_SECTOR_LIST, Gson().toJson(extension)).apply() } + @JvmStatic + fun showItemStarRating(): Boolean { + return App.getInstance().preferences.getBoolean(SONG_RATING_PER_ITEM, false) + } + @JvmStatic fun showItemRating(): Boolean { return App.getInstance().preferences.getBoolean(RATING_PER_ITEM, false) diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 9b6a76d1..b2b953ee 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -312,6 +312,8 @@ If enabled, show the podcast section. Restart the app for it to take full effect. Show audio quality The bitrate and audio format will be shown for each audio track. + Show song star rating + If enabled, hides 5 star rating for track on song page\n\n*Requires App restart Show item rating If enabled, the item\'s rating and whether it is marked as a favorite will be displayed. Sync timer diff --git a/app/src/main/res/xml/global_preferences.xml b/app/src/main/res/xml/global_preferences.xml index c90779b2..ddbcc1a7 100644 --- a/app/src/main/res/xml/global_preferences.xml +++ b/app/src/main/res/xml/global_preferences.xml @@ -57,6 +57,12 @@ android:summary="@string/settings_audio_quality_summary" android:key="audio_quality_per_item" /> + +