feat: setting to show/hide 5 star rating on playerview (#59)

First pass, I was not able to get the setting to update without having to restart the app. My attempt at using live data was missing something so I will have to revisit this when I get a better hang of it.
This commit is contained in:
eddyizm 2025-08-25 20:42:09 -07:00 committed by GitHub
commit 5c5316055c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 29 additions and 0 deletions

View file

@ -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();