mirror of
https://github.com/antebudimir/tempus.git
synced 2025-12-31 17:43:32 +00:00
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:
commit
5c5316055c
4 changed files with 29 additions and 0 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -313,6 +313,8 @@
|
|||
<string name="settings_podcast_summary">If enabled, show the podcast section. Restart the app for it to take full effect.</string>
|
||||
<string name="settings_audio_quality">Show audio quality</string>
|
||||
<string name="settings_audio_quality_summary">The bitrate and audio format will be shown for each audio track.</string>
|
||||
<string name="settings_song_rating">Show song star rating</string>
|
||||
<string name="settings_song_rating_summary">If enabled, hides 5 star rating for track on song page\n\n*Requires App restart</string>
|
||||
<string name="settings_item_rating">Show item rating</string>
|
||||
<string name="settings_item_rating_summary">If enabled, the item\'s rating and whether it is marked as a favorite will be displayed.</string>
|
||||
<string name="settings_queue_syncing_countdown">Sync timer</string>
|
||||
|
|
|
|||
|
|
@ -57,6 +57,12 @@
|
|||
android:summary="@string/settings_audio_quality_summary"
|
||||
android:key="audio_quality_per_item" />
|
||||
|
||||
<SwitchPreference
|
||||
android:title="@string/settings_song_rating"
|
||||
android:defaultValue="false"
|
||||
android:summary="@string/settings_song_rating_summary"
|
||||
android:key="song_rating_per_item" />
|
||||
|
||||
<SwitchPreference
|
||||
android:title="@string/settings_item_rating"
|
||||
android:defaultValue="false"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue