client
Clone or download
Modified Files
<?xml version='1.0'?>
<?xml version='1.0'?>
<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='com.StreamPi.Client' android:versionCode='1' android:versionName='1.0'>
<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='com.StreamPi.Client' android:versionCode='1' android:versionName='1.0.0'>
<supports-screens android:xlargeScreens="true"/>
<supports-screens android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
<application android:label='StreamPi Client' android:icon="@mipmap/ic_launcher" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
<application android:label='StreamPi Client' android:icon="@mipmap/ic_launcher" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:requestLegacyExternalStorage="true" android:keepScreenOn="true">
android:requestLegacyExternalStorage="true" android:keepScreenOn="true">
<activity android:name='com.gluonhq.helloandroid.MainActivity' android:configChanges="orientation|keyboardHidden">
<activity android:name='com.gluonhq.helloandroid.MainActivity' android:configChanges="orientation|keyboardHidden">
<intent-filter>
<intent-filter>
<category android:name='android.intent.category.LAUNCHER'/>
<category android:name='android.intent.category.LAUNCHER'/>
<action android:name='android.intent.action.MAIN'/>
<action android:name='android.intent.action.MAIN'/>
</intent-filter>
</intent-filter>
</activity>
</activity>
<activity android:name="com.gluonhq.impl.attach.android.PermissionRequestActivity" />
<activity android:name="com.gluonhq.impl.attach.android.PermissionRequestActivity" />
<activity android:name='com.gluonhq.helloandroid.PermissionRequestActivity'/>
<activity android:name='com.gluonhq.helloandroid.PermissionRequestActivity'/>
</application>
</application>
</manifest>
</manifest>
package com.stream_pi.client.window.firsttimeuse;
package com.stream_pi.client.window.firsttimeuse;
import com.stream_pi.client.connection.ClientListener;
import com.stream_pi.client.connection.ClientListener;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.SpaceFiller;
import com.stream_pi.util.uihelper.SpaceFiller;
import com.stream_pi.util.uihelper.SpaceFiller.FillerType;
import com.stream_pi.util.uihelper.SpaceFiller.FillerType;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.platform.Platform;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.control.Button;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.TextField;
import javafx.scene.control.TextField;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
public class FinalConfigPane extends VBox
public class FinalConfigPane extends VBox
{
{
private TextField clientNicknameTextField;
private TextField clientNicknameTextField;
private TextField serverIPHostNameTextField;
private TextField serverIPHostNameTextField;
private TextField serverPortTextField;
private TextField serverPortTextField;
private TextField displayWidthTextField;
private TextField displayWidthTextField;
private TextField displayHeightTextField;
private TextField displayHeightTextField;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ClientListener clientListener;
private ClientListener clientListener;
public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener)
public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener)
{
{
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.clientListener = clientListener;
this.clientListener = clientListener;
getStyleClass().add("first_time_use_pane_final_config");
getStyleClass().add("first_time_use_pane_final_config");
Label label = new Label("Thats it. Now just a little bit and then youre set!");
Label label = new Label("Thats it. Now just a little bit and then you're set!");
label.setWrapText(true);
label.setWrapText(true);
VBox.setVgrow(label, Priority.ALWAYS);
VBox.setVgrow(label, Priority.ALWAYS);
label.getStyleClass().add("first_time_use_pane_final_config_label");
label.getStyleClass().add("first_time_use_pane_final_config_label");
clientNicknameTextField = new TextField();
clientNicknameTextField = new TextField();
serverIPHostNameTextField = new TextField();
serverIPHostNameTextField = new TextField();
serverPortTextField = new TextField();
serverPortTextField = new TextField();
displayWidthTextField = new TextField();
displayWidthTextField = new TextField();
displayHeightTextField = new TextField();
displayHeightTextField = new TextField();
HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField);
HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField);
HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField);
HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField);
HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField);
HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField);
HBoxInputBox displayWidthInputBox = new HBoxInputBox("Display Width", displayWidthTextField);
HBoxInputBox displayWidthInputBox = new HBoxInputBox("Display Width", displayWidthTextField);
HBoxInputBox displayHeightInputBox = new HBoxInputBox("Display Height", displayHeightTextField);
HBoxInputBox displayHeightInputBox = new HBoxInputBox("Display Height", displayHeightTextField);
if(ClientInfo.getInstance().getPlatformType() == Platform.ANDROID)
if(ClientInfo.getInstance().getPlatformType() == Platform.ANDROID)
{
{
displayWidthInputBox.setVisible(false);
displayWidthInputBox.setVisible(false);
displayHeightInputBox.setVisible(false);
displayHeightInputBox.setVisible(false);
}
}
Button confirmButton = new Button("Confirm");
Button confirmButton = new Button("Confirm");
confirmButton.setOnAction(event -> onConfirmButtonClicked());
confirmButton.setOnAction(event -> onConfirmButtonClicked());
HBox bBar = new HBox(confirmButton);
HBox bBar = new HBox(confirmButton);
bBar.setAlignment(Pos.CENTER_RIGHT);
bBar.setAlignment(Pos.CENTER_RIGHT);
VBox v = new VBox(clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox,
VBox v = new VBox(clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox,
displayWidthInputBox, displayHeightInputBox);
displayWidthInputBox, displayHeightInputBox);
v.setSpacing(10.0);
v.setSpacing(10.0);
ScrollPane scrollPane = new ScrollPane(v);
ScrollPane scrollPane = new ScrollPane(v);
scrollPane.getStyleClass().add("first_time_use_final_config_pane_scroll_pane");
scrollPane.getStyleClass().add("first_time_use_final_config_pane_scroll_pane");
v.prefWidthProperty().bind(scrollPane.widthProperty().subtract(25));
v.prefWidthProperty().bind(scrollPane.widthProperty().subtract(25));
getChildren().addAll(label, scrollPane,new SpaceFiller(FillerType.VBox), bBar);
getChildren().addAll(label, scrollPane,new SpaceFiller(FillerType.VBox), bBar);
setSpacing(10.0);
setSpacing(10.0);
setVisible(false);
setVisible(false);
}
}
private void onConfirmButtonClicked()
private void onConfirmButtonClicked()
{
{
StringBuilder errors = new StringBuilder();
StringBuilder errors = new StringBuilder();
if(clientNicknameTextField.getText().isBlank())
if(clientNicknameTextField.getText().isBlank())
{
{
errors.append("* Nick name cannot be blank.\n");
errors.append("* Nick name cannot be blank.\n");
}
}
if(serverIPHostNameTextField.getText().isBlank())
if(serverIPHostNameTextField.getText().isBlank())
{
{
errors.append("* Server IP cannot be empty.\n");
errors.append("* Server IP cannot be empty.\n");
}
}
int port = -1;
int port = -1;
try
try
{
{
port = Integer.parseInt(serverPortTextField.getText());
port = Integer.parseInt(serverPortTextField.getText());
if(port < 1024)
if(port < 1024)
errors.append("* Server IP should be above 1024.\n");
errors.append("* Server IP should be above 1024.\n");
}
}
catch (NumberFormatException exception)
catch (NumberFormatException exception)
{
{
errors.append("* Server IP should be a number.\n");
errors.append("* Server IP should be a number.\n");
}
}
double width=-1,height=-1;
double width=-1,height=-1;
if(ClientInfo.getInstance().getPlatformType() != Platform.ANDROID)
if(ClientInfo.getInstance().getPlatformType() != Platform.ANDROID)
{
{
try
try
{
{
width = Double.parseDouble(displayWidthTextField.getText());
width = Double.parseDouble(displayWidthTextField.getText());
if(width < 0)
if(width < 0)
errors.append("* Display Width should be above 0.\n");
errors.append("* Display Width should be above 0.\n");
}
}
catch (NumberFormatException exception)
catch (NumberFormatException exception)
{
{
errors.append("* Display Width should be a number.\n");
errors.append("* Display Width should be a number.\n");
}
}
try
try
{
{
height = Double.parseDouble(displayHeightTextField.getText());
height = Double.parseDouble(displayHeightTextField.getText());
if(height < 0)
if(height < 0)
errors.append("* Display Height should be above 0.\n");
errors.append("* Display Height should be above 0.\n");
}
}
catch (NumberFormatException exception)
catch (NumberFormatException exception)
{
{
errors.append("* Display Height should be a number.\n");
errors.append("* Display Height should be a number.\n");
}
}
}
}
if(errors.toString().isEmpty())
if(errors.toString().isEmpty())
{
{
try
try
{
{
Config.getInstance().setNickName(clientNicknameTextField.getText());
Config.getInstance().setNickName(clientNicknameTextField.getText());
Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText());
Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText());
Config.getInstance().setServerPort(port);
Config.getInstance().setServerPort(port);
Config.getInstance().setFirstTimeUse(false);
Config.getInstance().setFirstTimeUse(false);
if(ClientInfo.getInstance().getPlatformType() != Platform.ANDROID)
if(ClientInfo.getInstance().getPlatformType() != Platform.ANDROID)
{
{
Config.getInstance().setStartupWindowSize(
Config.getInstance().setStartupWindowSize(
width, height
width, height
);
);
}
}
Config.getInstance().save();
Config.getInstance().save();
clientListener.init();
clientListener.init();
}
}
catch(SevereException e)
catch(SevereException e)
{
{
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
}
}
else
else
{
{
new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors.toString(), StreamPiAlertType.ERROR).show();
new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors.toString(), StreamPiAlertType.ERROR).show();
}
}
}
}
}
}
package com.stream_pi.client.window.firsttimeuse;
package com.stream_pi.client.window.firsttimeuse;
import com.stream_pi.client.info.License;
import com.stream_pi.client.info.License;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.control.TextArea;
import javafx.scene.control.TextArea;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
public class LicensePane extends VBox {
public class LicensePane extends VBox {
public LicensePane()
public LicensePane()
{
{
getStyleClass().add("first_time_use_pane_license");
getStyleClass().add("first_time_use_pane_license");
Label label = new Label("By Clicking on 'Next', you agree with the license.");
Label label = new Label("By clicking on 'Next' you agree with the Stream-Pi license, and, the license('s) of the library('s) used/included with this software.");
label.prefWidthProperty().bind(widthProperty());
label.prefWidthProperty().bind(widthProperty());
label.setWrapText(true);
label.setWrapText(true);
TextArea licenseTextArea = new TextArea(License.getLicense());
TextArea licenseTextArea = new TextArea(License.getLicense());
licenseTextArea.setWrapText(false);
licenseTextArea.setWrapText(false);
licenseTextArea.setEditable(false);
licenseTextArea.setEditable(false);
licenseTextArea.prefWidthProperty().bind(widthProperty());
licenseTextArea.prefWidthProperty().bind(widthProperty());
VBox.setVgrow(licenseTextArea, Priority.ALWAYS);
VBox.setVgrow(licenseTextArea, Priority.ALWAYS);
getChildren().addAll(label, licenseTextArea);
getChildren().addAll(label, licenseTextArea);
}
}
}
}
package com.stream_pi.client.window.firsttimeuse;
package com.stream_pi.client.window.firsttimeuse;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.control.Label;
import javafx.scene.control.Label;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
public class WelcomePane extends VBox{
public class WelcomePane extends VBox{
public WelcomePane()
public WelcomePane()
{
{
getStyleClass().add("first_time_use_pane_welcome");
getStyleClass().add("first_time_use_pane_welcome");
Label welcomeLabel = new Label("Welcome!");
Label welcomeLabel = new Label("Welcome!");
welcomeLabel.getStyleClass().add("first_time_use_welcome_pane_welcome_label");
welcomeLabel.getStyleClass().add("first_time_use_welcome_pane_welcome_label");
Label nextToContinue = new Label("Click on Next to continue with the setup.");
Label nextToContinue = new Label("Please click \"Next\" to start the Setup process");
nextToContinue.getStyleClass().add("first_time_use_welcome_pane_next_to_continue_label");
nextToContinue.getStyleClass().add("first_time_use_welcome_pane_next_to_continue_label");
setAlignment(Pos.CENTER);
setAlignment(Pos.CENTER);
setSpacing(5.0);
setSpacing(5.0);
getChildren().addAll(welcomeLabel, nextToContinue);
getChildren().addAll(welcomeLabel, nextToContinue);
setVisible(false);
setVisible(false);
}
}
}
}
package com.stream_pi.client.window.settings;
package com.stream_pi.client.window.settings;
import java.io.File;
import java.io.File;
import com.stream_pi.client.connection.ClientListener;
import com.stream_pi.client.connection.ClientListener;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.profile.ClientProfile;
import com.stream_pi.client.profile.ClientProfile;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.client.window.ExceptionAndAlertHandler;
import com.stream_pi.themeapi.Theme;
import com.stream_pi.themeapi.Theme;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.combobox.StreamPiComboBox;
import com.stream_pi.util.combobox.StreamPiComboBox;
import com.stream_pi.util.combobox.StreamPiComboBoxFactory;
import com.stream_pi.util.combobox.StreamPiComboBoxFactory;
import com.stream_pi.util.combobox.StreamPiComboBoxListener;
import com.stream_pi.util.combobox.StreamPiComboBoxListener;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.MinorException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.SpaceFiller;
import com.stream_pi.util.uihelper.SpaceFiller;
import com.stream_pi.util.startatboot.SoftwareType;
import com.stream_pi.util.startatboot.SoftwareType;
import com.stream_pi.util.startatboot.StartAtBoot;
import com.stream_pi.util.startatboot.StartAtBoot;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.control.*;
import javafx.scene.control.*;
import javafx.scene.layout.HBox;
import javafx.scene.layout.HBox;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
public class SettingsBase extends VBox {
public class SettingsBase extends VBox {
private TextField serverPortTextField;
private TextField serverPortTextField;
private TextField serverHostNameOrIPTextField;
private TextField serverHostNameOrIPTextField;
private StreamPiComboBox<ClientProfile> clientProfileComboBox;
private StreamPiComboBox<ClientProfile> clientProfileComboBox;
private StreamPiComboBox<Theme> themeComboBox;
private StreamPiComboBox<Theme> themeComboBox;
private TextField displayWidthTextField;
private TextField displayWidthTextField;
private TextField displayHeightTextField;
private TextField displayHeightTextField;
private TextField nickNameTextField;
private TextField nickNameTextField;
private Button closeButton;
private Button closeButton;
private Button saveButton;
private Button saveButton;
private Button connectDisconnectButton;
private Button connectDisconnectButton;
private Button shutdownButton;
private Button shutdownButton;
private ToggleButton startOnBootToggleButton;
private ToggleButton startOnBootToggleButton;
private ToggleButton showCursorToggleButton;
private ToggleButton showCursorToggleButton;
private ToggleButton fullScreenToggleButton;
private ToggleButton fullScreenToggleButton;
private ClientListener clientListener;
private ClientListener clientListener;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private TextField themesPathTextField;
private TextField themesPathTextField;
private TextField iconsPathTextField;
private TextField iconsPathTextField;
private TextField profilesPathTextField;
private TextField profilesPathTextField;
public SettingsBase(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) {
public SettingsBase(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) {
getStyleClass().add("settings_base");
getStyleClass().add("settings_base");
this.clientListener = clientListener;
this.clientListener = clientListener;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
serverPortTextField = new TextField();
serverPortTextField = new TextField();
serverHostNameOrIPTextField = new TextField();
serverHostNameOrIPTextField = new TextField();
nickNameTextField = new TextField();
nickNameTextField = new TextField();
clientProfileComboBox = new StreamPiComboBox<>();
clientProfileComboBox = new StreamPiComboBox<>();
clientProfileComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory<ClientProfile>()
clientProfileComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory<ClientProfile>()
{
{
@Override
@Override
public String getOptionDisplayText(ClientProfile object)
public String getOptionDisplayText(ClientProfile object)
{
{
return object.getName();
return object.getName();
}
}
});
});
clientProfileComboBox.setStreamPiComboBoxListener(new StreamPiComboBoxListener<ClientProfile>(){
clientProfileComboBox.setStreamPiComboBoxListener(new StreamPiComboBoxListener<ClientProfile>(){
@Override
@Override
public void onNewItemSelected(ClientProfile selectedItem)
public void onNewItemSelected(ClientProfile selectedItem)
{
{
clientListener.renderProfile(selectedItem);
clientListener.renderProfile(selectedItem);
}
}
});
});
themeComboBox = new StreamPiComboBox<>();
themeComboBox = new StreamPiComboBox<>();
themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory<Theme>()
themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory<Theme>()
{
{
@Override
@Override
public String getOptionDisplayText(Theme object)
public String getOptionDisplayText(Theme object)
{
{
return object.getShortName();
return object.getShortName();
}
}
});
});
displayHeightTextField = new TextField();
displayHeightTextField = new TextField();
displayWidthTextField = new TextField();
displayWidthTextField = new TextField();
themesPathTextField = new TextField();
themesPathTextField = new TextField();
iconsPathTextField = new TextField();
iconsPathTextField = new TextField();
profilesPathTextField = new TextField();
profilesPathTextField = new TextField();
startOnBootToggleButton = new ToggleButton("Start On Boot");
startOnBootToggleButton = new ToggleButton("Start On Boot");
startOnBootToggleButton.managedProperty().bind(startOnBootToggleButton.visibleProperty());
startOnBootToggleButton.managedProperty().bind(startOnBootToggleButton.visibleProperty());
showCursorToggleButton = new ToggleButton("Show Cursor");
showCursorToggleButton = new ToggleButton("Show Cursor");
showCursorToggleButton.managedProperty().bind(showCursorToggleButton.visibleProperty());
showCursorToggleButton.managedProperty().bind(showCursorToggleButton.visibleProperty());
fullScreenToggleButton = new ToggleButton("Full Screen");
fullScreenToggleButton = new ToggleButton("Full Screen");
fullScreenToggleButton.managedProperty().bind(fullScreenToggleButton.visibleProperty());
fullScreenToggleButton.managedProperty().bind(fullScreenToggleButton.visibleProperty());
int prefWidth = 200;
int prefWidth = 200;
Label licenseLabel = new Label("This software is licensed to GNU GPLv3. Check StreamPi Server > settings > About to see full License Statement.");
Label licenseLabel = new Label("This software is licensed to GNU GPLv3. Check StreamPi Server > settings > About to see full License Statement.");
licenseLabel.setWrapText(true);
licenseLabel.setWrapText(true);
Label versionLabel = new Label(ClientInfo.getInstance().getReleaseStatus().getUIName() +" "+ClientInfo.getInstance().getVersion().getText());
Label versionLabel = new Label(ClientInfo.getInstance().getReleaseStatus().getUIName() +" "+ClientInfo.getInstance().getVersion().getText());
HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", themesPathTextField, prefWidth);
HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", themesPathTextField, prefWidth);
themesPathInputBox.managedProperty().bind(themesPathInputBox.visibleProperty());
themesPathInputBox.managedProperty().bind(themesPathInputBox.visibleProperty());
HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", iconsPathTextField, prefWidth);
HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", iconsPathTextField, prefWidth);
iconsPathInputBox.managedProperty().bind(iconsPathInputBox.visibleProperty());
iconsPathInputBox.managedProperty().bind(iconsPathInputBox.visibleProperty());
HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", profilesPathTextField, prefWidth);
HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", profilesPathTextField, prefWidth);
profilesPathInputBox.managedProperty().bind(profilesPathInputBox.visibleProperty());
profilesPathInputBox.managedProperty().bind(profilesPathInputBox.visibleProperty());
HBoxInputBox screenHeightInputBox = new HBoxInputBox("Screen Height", displayHeightTextField, prefWidth);
HBoxInputBox screenHeightInputBox = new HBoxInputBox("Screen Height", displayHeightTextField, prefWidth);
screenHeightInputBox.managedProperty().bind(screenHeightInputBox.visibleProperty());
screenHeightInputBox.managedProperty().bind(screenHeightInputBox.visibleProperty());
HBoxInputBox screenWidthInputBox = new HBoxInputBox("Screen Width", displayWidthTextField, prefWidth);
HBoxInputBox screenWidthInputBox = new HBoxInputBox("Screen Width", displayWidthTextField, prefWidth);
screenWidthInputBox.managedProperty().bind(screenWidthInputBox.visibleProperty());
screenWidthInputBox.managedProperty().bind(screenWidthInputBox.visibleProperty());
if(ClientInfo.getInstance().getPlatformType() == com.stream_pi.util.platform.Platform.ANDROID)
if(ClientInfo.getInstance().getPlatformType() == com.stream_pi.util.platform.Platform.ANDROID)
{
{
themesPathInputBox.setVisible(false);
themesPathInputBox.setVisible(false);
iconsPathInputBox.setVisible(false);
iconsPathInputBox.setVisible(false);
profilesPathInputBox.setVisible(false);
profilesPathInputBox.setVisible(false);
startOnBootToggleButton.setVisible(false);
startOnBootToggleButton.setVisible(false);
showCursorToggleButton.setVisible(false);
showCursorToggleButton.setVisible(false);
fullScreenToggleButton.setVisible(false);
fullScreenToggleButton.setVisible(false);
screenHeightInputBox.setVisible(false);
screenHeightInputBox.setVisible(false);
screenWidthInputBox.setVisible(false);
screenWidthInputBox.setVisible(false);
}
}
VBox vBox = new VBox(
VBox vBox = new VBox(
new HBoxInputBox("Nick Name", nickNameTextField, prefWidth),
new HBoxInputBox("Device Name", nickNameTextField, prefWidth),
new HBoxInputBox("Host Name/IP", serverHostNameOrIPTextField, prefWidth),
new HBoxInputBox("Host Name/IP", serverHostNameOrIPTextField, prefWidth),
new HBoxInputBox("Port", serverPortTextField, prefWidth),
new HBoxInputBox("Port", serverPortTextField, prefWidth),
new HBox(
new HBox(
new Label("Current profile"),
new Label("Current profile"),
new SpaceFiller(SpaceFiller.FillerType.HBox),
new SpaceFiller(SpaceFiller.FillerType.HBox),
clientProfileComboBox
clientProfileComboBox
),
),
new HBox(
new HBox(
new Label("Theme"),
new Label("Theme"),
new SpaceFiller(SpaceFiller.FillerType.HBox),
new SpaceFiller(SpaceFiller.FillerType.HBox),
themeComboBox
themeComboBox
),
),
screenHeightInputBox,
screenHeightInputBox,
screenWidthInputBox,
screenWidthInputBox,
themesPathInputBox,
themesPathInputBox,
iconsPathInputBox,
iconsPathInputBox,
profilesPathInputBox,
profilesPathInputBox,
startOnBootToggleButton,
startOnBootToggleButton,
showCursorToggleButton,
showCursorToggleButton,
fullScreenToggleButton,
fullScreenToggleButton,
licenseLabel,
licenseLabel,
versionLabel
versionLabel
);
);
vBox.getStyleClass().add("settings_base_vbox");
vBox.getStyleClass().add("settings_base_vbox");
vBox.setSpacing(5.0);
vBox.setSpacing(5.0);
vBox.setPadding(new Insets(5));
vBox.setPadding(new Insets(5));
ScrollPane scrollPane = new ScrollPane();
ScrollPane scrollPane = new ScrollPane();
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED);
VBox.setVgrow(scrollPane, Priority.ALWAYS);
VBox.setVgrow(scrollPane, Priority.ALWAYS);
scrollPane.getStyleClass().add("settings_base_scroll_pane");
scrollPane.getStyleClass().add("settings_base_scroll_pane");
scrollPane.setContent(vBox);
scrollPane.setContent(vBox);
vBox.setMinWidth(300);
vBox.setMinWidth(300);
vBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(25));
vBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(25));
Label settingsLabel = new Label("Settings");
Label settingsLabel = new Label("Settings");
settingsLabel.setPadding(new Insets(5,0,0,5));
settingsLabel.setPadding(new Insets(5,0,0,5));
settingsLabel.getStyleClass().add("settings_heading_label");
settingsLabel.getStyleClass().add("settings_heading_label");
saveButton = new Button("Save");
saveButton = new Button("Save");
saveButton.setOnAction(event->onSaveButtonClicked());
saveButton.setOnAction(event->onSaveButtonClicked());
closeButton = new Button("Close");
closeButton = new Button("Close");
connectDisconnectButton = new Button("Connect");
connectDisconnectButton = new Button("Connect");
connectDisconnectButton.setOnAction(event -> onConnectDisconnectButtonClicked());
connectDisconnectButton.setOnAction(event -> onConnectDisconnectButtonClicked());
shutdownButton = new Button("Shutdown");
shutdownButton = new Button("Shutdown");
shutdownButton.setOnAction(event -> onShutdownButtonClicked());
shutdownButton.setOnAction(event -> onShutdownButtonClicked());
Button exitButton = new Button("Exit");
Button exitButton = new Button("Exit");
exitButton.setOnAction(event -> onExitButtonClicked());
exitButton.setOnAction(event -> onExitButtonClicked());
HBox buttonBar = new HBox(connectDisconnectButton, saveButton, exitButton, closeButton);
HBox buttonBar = new HBox(connectDisconnectButton, saveButton, exitButton, closeButton);
buttonBar.getStyleClass().add("settings_button_bar");
buttonBar.getStyleClass().add("settings_button_bar");
if(ClientInfo.getInstance().getPlatformType() == com.stream_pi.util.platform.Platform.LINUX &&
if(ClientInfo.getInstance().getPlatformType() == com.stream_pi.util.platform.Platform.LINUX &&
ClientInfo.getInstance().isShowShutDownButton())
ClientInfo.getInstance().isShowShutDownButton())
{
{
buttonBar.getChildren().add(shutdownButton);
buttonBar.getChildren().add(shutdownButton);
}
}
buttonBar.setPadding(new Insets(0,5,5,0));
buttonBar.setPadding(new Insets(0,5,5,0));
buttonBar.setSpacing(5.0);
buttonBar.setSpacing(5.0);
buttonBar.setAlignment(Pos.CENTER_RIGHT);
buttonBar.setAlignment(Pos.CENTER_RIGHT);
setSpacing(5.0);
setSpacing(5.0);
getChildren().addAll(
getChildren().addAll(
settingsLabel,
settingsLabel,
scrollPane,
scrollPane,
buttonBar
buttonBar
);
);
}
}
public void onExitButtonClicked()
public void onExitButtonClicked()
{
{
clientListener.onCloseRequest();
clientListener.onCloseRequest();
Platform.exit();
Platform.exit();
}
}
public void setDisableStatus(boolean status)
public void setDisableStatus(boolean status)
{
{
saveButton.setDisable(status);
saveButton.setDisable(status);
connectDisconnectButton.setDisable(status);
connectDisconnectButton.setDisable(status);
}
}
public void onShutdownButtonClicked()
public void onShutdownButtonClicked()
{
{
clientListener.onCloseRequest();
clientListener.onCloseRequest();
try {
try {
Runtime.getRuntime().exec("sudo halt");
Runtime.getRuntime().exec("sudo halt");
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
}
}
public void onConnectDisconnectButtonClicked()
public void onConnectDisconnectButtonClicked()
{
{
try
try
{
{
if(clientListener.isConnected())
if(clientListener.isConnected())
clientListener.disconnect("Client disconnected from settings");
clientListener.disconnect("Client disconnected from settings");
else
else
clientListener.setupClientConnection();
clientListener.setupClientConnection();
}
}
catch (SevereException e)
catch (SevereException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
}
}
public void setConnectDisconnectButtonStatus()
public void setConnectDisconnectButtonStatus()
{
{
Platform.runLater(()->{
Platform.runLater(()->{
setDisableStatus(false);
setDisableStatus(false);
if(clientListener.isConnected())
if(clientListener.isConnected())
connectDisconnectButton.setText("Disconnect");
connectDisconnectButton.setText("Disconnect");
else
else
connectDisconnectButton.setText("Connect");
connectDisconnectButton.setText("Connect");
});
});
}
}
public Button getCloseButton() {
public Button getCloseButton() {
return closeButton;
return closeButton;
}
}
public void loadData() throws SevereException
public void loadData() throws SevereException
{
{
nickNameTextField.setText(Config.getInstance().getClientNickName());
nickNameTextField.setText(Config.getInstance().getClientNickName());
serverHostNameOrIPTextField.setText(Config.getInstance().getSavedServerHostNameOrIP());
serverHostNameOrIPTextField.setText(Config.getInstance().getSavedServerHostNameOrIP());
serverPortTextField.setText(Config.getInstance().getSavedServerPort()+"");
serverPortTextField.setText(Config.getInstance().getSavedServerPort()+"");
clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles());
clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles());
int ind = 0;
int ind = 0;
for(int i = 0;i<clientProfileComboBox.getOptions().size();i++)
for(int i = 0;i<clientProfileComboBox.getOptions().size();i++)
{
{
if(clientProfileComboBox.getOptions().get(i).getID().equals(clientListener.getCurrentProfile().getID()))
if(clientProfileComboBox.getOptions().get(i).getID().equals(clientListener.getCurrentProfile().getID()))
{
{
ind = i;
ind = i;
break;
break;
}
}
}
}
clientProfileComboBox.setCurrentSelectedItemIndex(ind);
clientProfileComboBox.setCurrentSelectedItemIndex(ind);
themeComboBox.setOptions(clientListener.getThemes().getThemeList());
themeComboBox.setOptions(clientListener.getThemes().getThemeList());
int ind2 = 0;
int ind2 = 0;
for(int i = 0;i<themeComboBox.getOptions().size();i++)
for(int i = 0;i<themeComboBox.getOptions().size();i++)
{
{
if(themeComboBox.getOptions().get(i).getFullName().equals(clientListener.getCurrentTheme().getFullName()))
if(themeComboBox.getOptions().get(i).getFullName().equals(clientListener.getCurrentTheme().getFullName()))
{
{
ind2 = i;
ind2 = i;
break;
break;
}
}
}
}
themeComboBox.setCurrentSelectedItemIndex(ind2);
themeComboBox.setCurrentSelectedItemIndex(ind2);
displayWidthTextField.setText(Config.getInstance().getStartupWindowWidth()+"");
displayWidthTextField.setText(Config.getInstance().getStartupWindowWidth()+"");
displayHeightTextField.setText(Config.getInstance().getStartupWindowHeight()+"");
displayHeightTextField.setText(Config.getInstance().getStartupWindowHeight()+"");
themesPathTextField.setText(Config.getInstance().getThemesPath());
themesPathTextField.setText(Config.getInstance().getThemesPath());
iconsPathTextField.setText(Config.getInstance().getIconsPath());
iconsPathTextField.setText(Config.getInstance().getIconsPath());
profilesPathTextField.setText(Config.getInstance().getProfilesPath());
profilesPathTextField.setText(Config.getInstance().getProfilesPath());
startOnBootToggleButton.setSelected(Config.getInstance().isStartOnBoot());
startOnBootToggleButton.setSelected(Config.getInstance().isStartOnBoot());
fullScreenToggleButton.setSelected(Config.getInstance().isFullscreen());
fullScreenToggleButton.setSelected(Config.getInstance().isFullscreen());
showCursorToggleButton.setSelected(Config.getInstance().isShowCursor());
showCursorToggleButton.setSelected(Config.getInstance().isShowCursor());
}
}
public void onSaveButtonClicked()
public void onSaveButtonClicked()
{
{
StringBuilder errors = new StringBuilder();
StringBuilder errors = new StringBuilder();
int port = -1;
int port = -1;
try
try
{
{
port = Integer.parseInt(serverPortTextField.getText());
port = Integer.parseInt(serverPortTextField.getText());
if(port < 1024)
if(port < 1024)
errors.append("* Server IP should be above 1024.\n");
errors.append("* Server IP should be above 1024.\n");
}
}
catch (NumberFormatException exception)
catch (NumberFormatException exception)
{
{
errors.append("* Server IP should be a number.\n");
errors.append("* Server IP should be a number.\n");
}
}
double width = -1;
double width = -1;
try
try
{
{
width = Double.parseDouble(displayWidthTextField.getText());
width = Double.parseDouble(displayWidthTextField.getText());
if(width < 0)
if(width < 0)
errors.append("* Display Width should be above 0.\n");
errors.append("* Display Width should be above 0.\n");
}
}
catch (NumberFormatException exception)
catch (NumberFormatException exception)
{
{
errors.append("* Display Width should be a number.\n");
errors.append("* Display Width should be a number.\n");
}
}
double height = -1;
double height = -1;
try
try
{
{
height = Double.parseDouble(displayHeightTextField.getText());
height = Double.parseDouble(displayHeightTextField.getText());
if(height < 0)
if(height < 0)
errors.append("* Display Height should be above 0.\n");
errors.append("* Display Height should be above 0.\n");
}
}
catch (NumberFormatException exception)
catch (NumberFormatException exception)
{
{
errors.append("* Display Height should be a number.\n");
errors.append("* Display Height should be a number.\n");
}
}
if(serverHostNameOrIPTextField.getText().isBlank())
if(serverHostNameOrIPTextField.getText().isBlank())
{
{
errors.append("* Server IP cannot be empty.\n");
errors.append("* Server IP cannot be empty.\n");
}
}
if(nickNameTextField.getText().isBlank())
if(nickNameTextField.getText().isBlank())
{
{
errors.append("* Nick name cannot be blank.\n");
errors.append("* Nick name cannot be blank.\n");
}
}
if(!errors.toString().isEmpty())
if(!errors.toString().isEmpty())
{
{
exceptionAndAlertHandler.handleMinorException(new MinorException(
exceptionAndAlertHandler.handleMinorException(new MinorException(
"You made mistakes",
"You made mistakes",
"Please fix the errors and try again :\n"+errors.toString()
"Please fix the errors and try again :\n"+errors.toString()
));
));
return;
return;
}
}
try {
try {
boolean toBeReloaded = false;
boolean toBeReloaded = false;
boolean breakConnection = false;
boolean breakConnection = false;
if(!Config.getInstance().getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName()))
if(!Config.getInstance().getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName()))
toBeReloaded = true;
toBeReloaded = true;
Config.getInstance().setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName());
Config.getInstance().setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName());
if(width != Config.getInstance().getStartupWindowWidth() || height != Config.getInstance().getStartupWindowHeight())
if(width != Config.getInstance().getStartupWindowWidth() || height != Config.getInstance().getStartupWindowHeight())
toBeReloaded = true;
toBeReloaded = true;
Config.getInstance().setStartupWindowSize(width, height);
Config.getInstance().setStartupWindowSize(width, height);
if(!Config.getInstance().getClientNickName().equals(nickNameTextField.getText()))
if(!Config.getInstance().getClientNickName().equals(nickNameTextField.getText()))
breakConnection = true;
breakConnection = true;
Config.getInstance().setNickName(nickNameTextField.getText());
Config.getInstance().setNickName(nickNameTextField.getText());
if(port != Config.getInstance().getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(Config.getInstance().getSavedServerHostNameOrIP()))
if(port != Config.getInstance().getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(Config.getInstance().getSavedServerHostNameOrIP()))
breakConnection = true;
breakConnection = true;
Config.getInstance().setServerPort(port);
Config.getInstance().setServerPort(port);
Config.getInstance().setServerHostNameOrIP(serverHostNameOrIPTextField.getText());
Config.getInstance().setServerHostNameOrIP(serverHostNameOrIPTextField.getText());
boolean startOnBoot = startOnBootToggleButton.isSelected();
boolean startOnBoot = startOnBootToggleButton.isSelected();
if(Config.getInstance().isStartOnBoot() != startOnBoot)
if(Config.getInstance().isStartOnBoot() != startOnBoot)
{
{
if(ClientInfo.getInstance().getRunnerFileName() == null)
if(ClientInfo.getInstance().getRunnerFileName() == null)
{
{
new StreamPiAlert("Uh Oh", "No Runner File Name Specified as startup arguments. Cant set run at boot.", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Uh Oh", "No Runner File Name Specified as startup arguments. Cant set run at boot.", StreamPiAlertType.ERROR).show();
startOnBoot = false;
startOnBoot = false;
}
}
else
else
{
{
StartAtBoot startAtBoot = new StartAtBoot(SoftwareType.CLIENT, ClientInfo.getInstance().getPlatformType());
StartAtBoot startAtBoot = new StartAtBoot(SoftwareType.CLIENT, ClientInfo.getInstance().getPlatformType());
if(startOnBoot)
if(startOnBoot)
{
{
startAtBoot.create(new File(ClientInfo.getInstance().getRunnerFileName()));
startAtBoot.create(new File(ClientInfo.getInstance().getRunnerFileName()));
}
}
else
else
{
{
boolean result = startAtBoot.delete();
boolean result = startAtBoot.delete();
if(!result)
if(!result)
new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show();
}
}
}
}
}
}
Config.getInstance().setStartOnBoot(startOnBoot);
Config.getInstance().setStartOnBoot(startOnBoot);
if(Config.getInstance().isFullscreen() != fullScreenToggleButton.isSelected() ||
if(Config.getInstance().isFullscreen() != fullScreenToggleButton.isSelected() ||
Config.getInstance().isShowCursor() != showCursorToggleButton.isSelected())
Config.getInstance().isShowCursor() != showCursorToggleButton.isSelected())
toBeReloaded = true;
toBeReloaded = true;
Config.getInstance().setFullscreen(fullScreenToggleButton.isSelected());
Config.getInstance().setFullscreen(fullScreenToggleButton.isSelected());
Config.getInstance().setShowCursor(showCursorToggleButton.isSelected());
Config.getInstance().setShowCursor(showCursorToggleButton.isSelected());
if(!Config.getInstance().getThemesPath().equals(themesPathTextField.getText()))
if(!Config.getInstance().getThemesPath().equals(themesPathTextField.getText()))
toBeReloaded = true;
toBeReloaded = true;
Config.getInstance().setThemesPath(themesPathTextField.getText());
Config.getInstance().setThemesPath(themesPathTextField.getText());
if(!Config.getInstance().getIconsPath().equals(iconsPathTextField.getText()))
if(!Config.getInstance().getIconsPath().equals(iconsPathTextField.getText()))
toBeReloaded = true;
toBeReloaded = true;
Config.getInstance().setIconsPath(iconsPathTextField.getText());
Config.getInstance().setIconsPath(iconsPathTextField.getText());
if(!Config.getInstance().getProfilesPath().equals(profilesPathTextField.getText()))
if(!Config.getInstance().getProfilesPath().equals(profilesPathTextField.getText()))
toBeReloaded = true;
toBeReloaded = true;
Config.getInstance().setProfilesPath(profilesPathTextField.getText());
Config.getInstance().setProfilesPath(profilesPathTextField.getText());
Config.getInstance().save();
Config.getInstance().save();
loadData();
loadData();
if(breakConnection)
if(breakConnection)
{
{
if(clientListener.isConnected())
if(clientListener.isConnected())
clientListener.disconnect("Client connection settings were changed.");
clientListener.disconnect("Client connection settings were changed.");
}
}
if(toBeReloaded)
if(toBeReloaded)
{
{
clientListener.init();
clientListener.init();
clientListener.renderRootDefaultProfile();
clientListener.renderRootDefaultProfile();
}
}
}
}
catch (SevereException e)
catch (SevereException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
}
}