Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ public class CurrentlyPlayingContext extends AbstractModelObject {
private final CurrentlyPlayingType currentlyPlayingType;
/** Allows to update the user interface based on which playback actions are available. */
private final Actions actions;
/** If smart shuffle is on or off. */
private final Boolean smart_shuffle;

private CurrentlyPlayingContext(final Builder builder) {
super(builder);
Expand All @@ -52,6 +54,7 @@ private CurrentlyPlayingContext(final Builder builder) {
this.item = builder.item;
this.currentlyPlayingType = builder.currentlyPlayingType;
this.actions = builder.actions;
this.smart_shuffle = builder.smart_shuffle;
}

/**
Expand Down Expand Up @@ -81,6 +84,15 @@ public Boolean getShuffle_state() {
return shuffle_state;
}

/**
* Get smart shuffle state of the device.
*
* @return If smart shuffle is on or off.
*/
public Boolean getSmart_shuffle() {
return smart_shuffle;
}

/**
* Get the context from where the currently playing item is played from.
*
Expand Down Expand Up @@ -149,7 +161,7 @@ public String toString() {
return "CurrentlyPlayingContext(device=" + device + ", repeat_state=" + repeat_state + ", shuffle_state="
+ shuffle_state + ", context=" + context + ", timestamp=" + timestamp + ", progress_ms=" + progress_ms
+ ", is_playing=" + is_playing + ", item=" + item + ", currentlyPlayingType=" + currentlyPlayingType
+ ", actions=" + actions + ")";
+ ", actions=" + actions + ", smart_shuffle=" + smart_shuffle + ")";
}

@Override
Expand All @@ -171,6 +183,7 @@ public static final class Builder extends AbstractModelObject.Builder {
private IPlaylistItem item;
private CurrentlyPlayingType currentlyPlayingType;
private Actions actions;
private Boolean smart_shuffle;

/**
* Default constructor.
Expand Down Expand Up @@ -289,6 +302,17 @@ public Builder setActions(Actions actions) {
return this;
}

/**
* The smart shuffle setter.
*
* @param smart_shuffle If smart shuffle is on or off.
* @return A {@link CurrentlyPlayingContext.Builder}.
*/
public Builder setSmart_shuffle(Boolean smart_shuffle) {
this.smart_shuffle = smart_shuffle;
return this;
}

@Override
public CurrentlyPlayingContext build() {
return new CurrentlyPlayingContext(this);
Expand Down Expand Up @@ -361,6 +385,10 @@ public CurrentlyPlayingContext createModelObject(JsonObject jsonObject) {
? new Actions.JsonUtil().createModelObject(
jsonObject.getAsJsonObject("actions"))
: null)
.setSmart_shuffle(
hasAndNotNull(jsonObject, "smart_shuffle")
? jsonObject.get("smart_shuffle").getAsBoolean()
: null)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,5 +92,6 @@
}
},
"repeat_state": "off",
"shuffle_state": false
"shuffle_state": false,
"smart_shuffle": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,6 @@
"toggling_shuffle": true
}
},
"is_playing": true
"is_playing": true,
"smart_shuffle": false
}
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@ public void shouldReturnDefault(final CurrentlyPlayingContext currentlyPlayingCo
assertEquals(
2,
currentlyPlayingContext.getActions().getDisallows().getDisallowedActions().size());
assertFalse(
currentlyPlayingContext.getSmart_shuffle());
}

@Test
Expand Down Expand Up @@ -140,6 +142,8 @@ public void shouldReturnDefaultEpisode(final CurrentlyPlayingContext currentlyPl
assertEquals(
4,
currentlyPlayingContext.getActions().getDisallows().getDisallowedActions().size());
assertFalse(
currentlyPlayingContext.getSmart_shuffle());
}

@Test
Expand Down