Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
janniklaskeck committed Nov 18, 2016
2 parents 193c004 + 97cd214 commit 6d1b98b
Show file tree
Hide file tree
Showing 40 changed files with 641 additions and 442 deletions.
2 changes: 1 addition & 1 deletion .classpath
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<attribute name="FROM_GRADLE_MODEL" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.buildship.core.gradleclasspathcontainer"/>
<classpathentry kind="output" path="bin"/>
</classpath>
8 changes: 4 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ ext {
richtextfxVersion = "0.6.10"
fontawesomefxVersion = "8.9"
controlsfxVersion = "8.40.12"
gsonVersion = "2.7"
gsonVersion = "2.8.0"
httpclientVersion = "4.5.2"
slf4jVersion = "1.7.21"
log4jVersion = "2.6.2"
log4jVersion = "2.7"
junitVersion = "4.12"
}

Expand Down Expand Up @@ -93,8 +93,8 @@ launch4j {
supportUrl = "https://github.com/westerwave/livestreamer_twitch_gui"
copyright = "MIT LICENSE"
language = "ENGLISH_US"
initialHeapSize = 128
maxHeapSize = 384
initialHeapSize = 64
maxHeapSize = 512
}

license {
Expand Down
9 changes: 4 additions & 5 deletions src/main/java/app/lsgui/gui/chat/ChatController.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public void initialize() {

private void sendMessage(final String message) {
if (!"".equals(message)) {
final String twitchUsername = Settings.getInstance().getTwitchUser();
final String twitchUsername = Settings.getInstance().twitchUserProperty().get();
final int start = this.chatTextArea.getText().length();
final int end = start + twitchUsername.length() + 1;
this.client.sendMessage(this.client.getChannel(), message);
Expand All @@ -100,10 +100,9 @@ private void sendMessage(final String message) {

public void connect(final String channel) {
final String twitchIrc = "irc.chat.twitch.tv";
if (!"".equals(Settings.getInstance().getTwitchUser()) && !"".equals(Settings.getInstance().getTwitchOAuth())) {
final String user = Settings.getInstance().getTwitchUser();
final String oauth = Settings.getInstance().getTwitchOAuth();

final String user = Settings.getInstance().twitchUserProperty().get();
final String oauth = Settings.getInstance().twitchOAuthProperty().get();
if (!"".equals(user) && !"".equals(oauth)) {
this.client.setUserName(user);
this.client.setChannel(channel);
this.clientConnect(twitchIrc, oauth);
Expand Down
3 changes: 1 addition & 2 deletions src/main/java/app/lsgui/gui/chat/ChatWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ private void setupStage(final Parent root) {
this.setTitle(this.channel + " - Livestreamer GUI Chat v" + LsGuiUtils.readVersionProperty());
this.getIcons().add(new Image(getClass().getResourceAsStream("/icon.jpg")));
final Scene scene = new Scene(root);
scene.getStylesheets().add(ChatWindow.class
.getResource("/styles/" + Settings.getInstance().getWindowStyle() + ".css").toExternalForm());
scene.getStylesheets().add(Settings.getInstance().getCurrentStyleSheet());
this.setScene(scene);
this.initModality(Modality.NONE);
this.show();
Expand Down
38 changes: 24 additions & 14 deletions src/main/java/app/lsgui/gui/main/LsGuiController.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@

import app.lsgui.gui.main.infopanel.ChannelInfoPanel;
import app.lsgui.gui.main.list.ChannelList;
import app.lsgui.gui.main.toolbar.QualityComboBox;
import app.lsgui.gui.main.toolbar.ServiceComboBox;
import app.lsgui.gui.main.toolbar.TopToolBar;
import app.lsgui.model.IChannel;
import app.lsgui.model.IService;
import app.lsgui.utils.Settings;
import javafx.application.Platform;
import javafx.fxml.FXML;
import javafx.scene.layout.BorderPane;

Expand Down Expand Up @@ -69,33 +74,38 @@ private void setupChannelList() {
this.channelList.getListView().getSelectionModel().selectedItemProperty()
.addListener((observable, oldValue, newValue) -> {
if (newValue != null) {
final QualityComboBox qualityComboBox = this.topToolBar.getQualityComboBox();
qualityComboBox.itemsProperty().bind(newValue.getAvailableQualities());
if (qualityComboBox.getItems().size() > 1) {
final String quality = Settings.getInstance().getQuality().get();
if (qualityComboBox.getItems().contains(quality)) {
qualityComboBox.getSelectionModel().select(quality);
} else {
qualityComboBox.getSelectionModel().select("Best");
}
} else {
qualityComboBox.getSelectionModel().select(0);
}
this.bindAndSelect(newValue);
}
});
final ServiceComboBox serviceComboBox = this.topToolBar.getServiceComboBox();
final IService service = serviceComboBox.getSelectionModel().getSelectedItem();
this.channelList.getStreams().bind(service.getChannelProperty());
this.channelList.channelListProperty().bind(service.getChannelProperty());
this.channelList.getListView().setUserData(service);
this.contentBorderPane.setLeft(this.channelList);
}

private void bindAndSelect(final IChannel newValue) {
final QualityComboBox qualityComboBox = this.topToolBar.getQualityComboBox();
qualityComboBox.itemsProperty().bind(newValue.getAvailableQualities());
if (qualityComboBox.getItems().size() > 1) {
final String quality = Settings.getInstance().qualityProperty().get();
if (qualityComboBox.getItems().contains(quality)) {
Platform.runLater(
() -> qualityComboBox.getSelectionModel().select(quality));
} else {
qualityComboBox.getSelectionModel().select(Settings.DEFAULT_QUALITY);
}
} else {
qualityComboBox.getSelectionModel().select(0);
}
}

private void setupChannelInfoPanel() {
LOGGER.debug("Initialize ChannelInfoPanel");
final ServiceComboBox serviceComboBox = this.topToolBar.getServiceComboBox();
final QualityComboBox qualityComboBox = this.topToolBar.getQualityComboBox();
final ChannelInfoPanel channelInfoPanel = new ChannelInfoPanel(serviceComboBox, qualityComboBox);
channelInfoPanel.getChannelProperty().bind(this.channelList.getSelectedChannelProperty());
channelInfoPanel.getChannelProperty().bind(this.channelList.selectedChannelProperty());
this.contentBorderPane.setCenter(channelInfoPanel);
}

Expand Down
7 changes: 3 additions & 4 deletions src/main/java/app/lsgui/gui/main/LsGuiWindow.java
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ private void setupStage(final Parent root, final Stage primaryStage) {
primaryStage.setOnCloseRequest(event -> {
Settings.getInstance().saveSettings();
Iterator<Map.Entry<IChannel, TwitchChannelUpdateService>> it = ((TwitchService) Settings.getInstance()
.getStreamServices().get(0)).getUpdateServices().entrySet().iterator();
.servicesProperty().get(0)).getUpdateServices().entrySet().iterator();
while (it.hasNext()) {
it.next();
it.remove();
Expand All @@ -117,15 +117,14 @@ private void setupStage(final Parent root, final Stage primaryStage) {
primaryStage.setOnHiding(event -> {
Settings.getInstance().saveSettings();
Iterator<Map.Entry<IChannel, TwitchChannelUpdateService>> it = ((TwitchService) Settings.getInstance()
.getStreamServices().get(0)).getUpdateServices().entrySet().iterator();
.servicesProperty().get(0)).getUpdateServices().entrySet().iterator();
while (it.hasNext()) {
it.next();
it.remove();
}
Platform.exit();
});
LsGuiWindow.getRootStage().getScene().getStylesheets().add(LsGuiWindow.class
.getResource("/styles/" + Settings.getInstance().getWindowStyle() + ".css").toExternalForm());
LsGuiWindow.getRootStage().getScene().getStylesheets().add(Settings.getInstance().getCurrentStyleSheet());
}

public static final synchronized Stage getRootStage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ private void bindToTwitchChannel(final TwitchChannel selectedChannel) {
}

private void bindToGenericChannel(final IChannel channel) {
this.channelDescription.textProperty().bind(channel.getName());
this.channelDescription.textProperty().bind(channel.getDisplayName());
this.previewImageView.imageProperty().unbind();
this.channelUptime.textProperty().unbind();
this.channelUptime.setGraphic(null);
Expand Down
6 changes: 3 additions & 3 deletions src/main/java/app/lsgui/gui/main/list/ChannelCell.java
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ protected final void updateItem(final IChannel channel, final boolean isEmpty) {
setGraphic(createReminderCheckBox(channel));
setContentDisplay(ContentDisplay.LEFT);
setContextMenu(this.createContextMenu(channel));
textProperty().bind(channel.getName());
textProperty().bind(channel.getDisplayName());
setOnMouseClicked(mouseEvent -> {
final int doubleClickAmount = 2;
if (mouseEvent.getButton() == MouseButton.PRIMARY && mouseEvent.getClickCount() == doubleClickAmount) {
Expand Down Expand Up @@ -136,7 +136,7 @@ private static CheckBox createReminderCheckBox(final IChannel channel) {
private ContextMenu createContextMenu(final IChannel channel) {
final ContextMenu contextMenu = new ContextMenu();
final MenuItem delete = new MenuItem();
delete.textProperty().set("Delete " + channel.getName().get());
delete.textProperty().set("Delete " + channel.getDisplayName().get());
delete.setOnAction(event -> {
final IService service = (IService) this.getListView().getUserData();
LsGuiUtils.removeChannelFromService(channel, service);
Expand Down Expand Up @@ -182,7 +182,7 @@ private ContextMenu createContextMenu(final IChannel channel) {
private void startLivestreamerStream(final IChannel channel) {
final IService service = (IService) this.getListView().getUserData();
final String url = LsGuiUtils.buildUrl(service.getUrl().get(), channel.getName().get());
final String quality = Settings.getInstance().getQuality().get();
final String quality = Settings.getInstance().qualityProperty().get();
LivestreamerUtils.startLivestreamer(url, quality);
LOGGER.info("Starting Stream for {}", channel.getName().get());
}
Expand Down
17 changes: 2 additions & 15 deletions src/main/java/app/lsgui/gui/main/list/ChannelList.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
package app.lsgui.gui.main.list;

import java.io.IOException;
import java.util.List;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -34,7 +33,6 @@
import javafx.beans.property.ObjectProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.beans.property.SimpleObjectProperty;
import javafx.collections.FXCollections;
import javafx.fxml.FXML;
import javafx.fxml.FXMLLoader;
import javafx.scene.control.ListView;
Expand Down Expand Up @@ -75,27 +73,16 @@ private void setupChannelList() {
this.channelListView.setCellFactory(listView -> new ChannelCell());
}

public ListProperty<IChannel> getStreams() {
public ListProperty<IChannel> channelListProperty() {
return this.channelListProperty;
}

public void setChannels(final List<IChannel> channels) {
this.channelListProperty.set(FXCollections.observableList(channels));
}

public ListView<IChannel> getListView() {
return this.channelListView;
}

public void setListView(final ListView<IChannel> channelList) {
this.channelListView = channelList;
}

public ObjectProperty<IChannel> getSelectedChannelProperty() {
public ObjectProperty<IChannel> selectedChannelProperty() {
return this.selectedChannelProperty;
}

public void setSelectedChannelProperty(final ObjectProperty<IChannel> channelProperty) {
this.selectedChannelProperty = channelProperty;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package app.lsgui.gui.main;
package app.lsgui.gui.main.toolbar;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -39,9 +39,9 @@ public QualityComboBox() {

public void initialize() {
getSelectionModel().selectedItemProperty().addListener((obs, oldValue, newValue) -> {
if (!OFFLINEQUALITY.equals(newValue)) {
if (newValue != null && !OFFLINEQUALITY.equals(newValue)) {
LOGGER.debug("Set selected Quality to {}", newValue);
Settings.getInstance().getQuality().set(newValue);
Settings.getInstance().qualityProperty().set(newValue);
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package app.lsgui.gui.main;
package app.lsgui.gui.main.toolbar;

import app.lsgui.model.IService;
import javafx.scene.control.ListCell;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package app.lsgui.gui.main;
package app.lsgui.gui.main.toolbar;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -41,10 +41,10 @@ public ServiceComboBox() {
}

public void initialize(final ServiceOperator serviceOperator) {
if (Settings.getInstance().getStreamServices().isEmpty()) {
Settings.getInstance().getStreamServices().add(new TwitchService("Twitch.tv", "http://twitch.tv/"));
if (Settings.getInstance().servicesProperty().isEmpty()) {
Settings.getInstance().servicesProperty().add(new TwitchService("Twitch.tv", "http://twitch.tv/"));
}
itemsProperty().bind(Settings.getInstance().getStreamServices());
itemsProperty().bind(Settings.getInstance().servicesProperty());
setCellFactory(listView -> new ServiceCell());
setConverter(new StringConverter<IService>() {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package app.lsgui.gui.main;
package app.lsgui.gui.main.toolbar;

import app.lsgui.model.IService;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package app.lsgui.gui.main;
package app.lsgui.gui.main.toolbar;

import org.controlsfx.control.PopOver;
import org.slf4j.Logger;
Expand Down Expand Up @@ -166,7 +166,7 @@ private void importFollowedChannels() {

private void changeService(final IService newService) {
LOGGER.debug("Change Service to {}", newService.getName().get());
this.channelList.getStreams().bind(newService.getChannelProperty());
this.channelList.channelListProperty().bind(newService.getChannelProperty());
this.channelList.getListView().setUserData(newService);
if (TwitchUtils.isTwitchService(newService)) {
this.importButton.setDisable(false);
Expand Down
Loading

0 comments on commit 6d1b98b

Please sign in to comment.