client

Clone or download

Made full screen only, added haptic feedback for android/ios

Modified Files

M pom.xml
+6 −0
--- 'a/pom.xml'
+++ b/pom.xml
@@ -82,6 +82,11 @@
<artifactId>browser</artifactId>
<version>4.0.10</version>
</dependency>
+ <dependency>
+ <groupId>com.gluonhq.attach</groupId>
+ <artifactId>vibration</artifactId>
+ <version>4.0.10</version>
+ </dependency>
</dependencies>
<repositories>
@@ -130,6 +135,7 @@
<list>lifecycle</list>
<list>storage</list>
<list>browser</list>
+ <list>vibration</list>
</attachList>
<reflectionList>
<list>java.util.logging.FileHandler</list>
--- 'a/src/android/AndroidManifest.xml'
+++ b/src/android/AndroidManifest.xml
@@ -4,6 +4,7 @@
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WRITE_INTERNAL_STORAGE" />
+ <uses-permission android:name="android.permission.VIBRATE"/>
<application android:label='Stream-Pi Client' android:icon="@mipmap/ic_launcher" android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:requestLegacyExternalStorage="true" android:keepScreenOn="true">
--- 'a/src/main/java/com/stream_pi/client/connection/Client.java'
+++ b/src/main/java/com/stream_pi/client/connection/Client.java
@@ -732,23 +732,12 @@ public class Client extends Thread{
Config.getInstance().setNickName(sep[0]);
- String oldWidth = Config.getInstance().getStartupWindowWidth()+"";
- String oldHeight = Config.getInstance().getStartupWindowHeight()+"";
-
- Config.getInstance().setStartupWindowSize(
- Double.parseDouble(sep[1]),
- Double.parseDouble(sep[2])
- );
-
- Config.getInstance().setStartupProfileID(sep[3]);
+ Config.getInstance().setStartupProfileID(sep[1]);
String oldThemeFullName = Config.getInstance().getCurrentThemeFullName();
- Config.getInstance().setCurrentThemeFullName(sep[4]);
-
- if(!oldHeight.equals(sep[2]) || !oldWidth.equals(sep[1]) || !oldThemeFullName.equals(sep[4]))
- Platform.runLater(clientListener::init);
+ Config.getInstance().setCurrentThemeFullName(sep[2]);
Config.getInstance().save();
--- 'a/src/main/java/com/stream_pi/client/controller/Controller.java'
+++ b/src/main/java/com/stream_pi/client/controller/Controller.java
@@ -1,5 +1,6 @@
package com.stream_pi.client.controller;
+import com.gluonhq.attach.vibration.VibrationService;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.client.connection.Client;
import com.stream_pi.client.io.Config;
@@ -22,6 +23,7 @@ import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.scene.Node;
+import javafx.scene.input.KeyCombination;
import javafx.util.Duration;
import java.io.*;
@@ -48,14 +50,18 @@ public class Controller extends Base
if(firstRun)
initBase();
+ //Full Screen
+
+
if(getClientInfo().getPlatform()!= com.stream_pi.util.platform.Platform.ANDROID)
{
- getStage().setWidth(getConfig().getStartupWindowWidth());
- getStage().setHeight(getConfig().getStartupWindowHeight());
getStage().centerOnScreen();
+ getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
+ getStage().setFullScreen(true);
setupFlags();
}
+
applyDefaultTheme();
@@ -101,7 +107,10 @@ public class Controller extends Base
if(firstRun)
{
- setupClientConnection();
+ if(getConfig().isConnectOnStartup())
+ {
+ setupClientConnection();
+ }
firstRun = false;
}
@@ -292,6 +301,14 @@ public class Controller extends Base
@Override
public void onNormalActionClicked(String profileID, String actionID) {
try {
+
+ //Vibrate for android/iOS
+
+ if(getConfig().isVibrateOnActionClicked())
+ {
+ VibrationService.create().ifPresent(VibrationService::vibrate);
+ }
+
client.onActionClicked(profileID, actionID);
} catch (SevereException e) {
e.printStackTrace();
--- 'a/src/main/java/com/stream_pi/client/io/Config.java'
+++ b/src/main/java/com/stream_pi/client/io/Config.java
@@ -169,16 +169,6 @@ public class Config {
return XMLConfigHelper.getStringProperty(getClientElement(), "icons-path", getDefaultIconsPath(), false, true, document, configFile);
}
- public double getStartupWindowWidth()
- {
- return XMLConfigHelper.getDoubleProperty((Element) getClientElement().getElementsByTagName("startup-window-size").item(0), "width", getDefaultStartupWindowWidth(), false, true, document, configFile);
- }
-
- public double getStartupWindowHeight()
- {
- return XMLConfigHelper.getDoubleProperty((Element) getClientElement().getElementsByTagName("startup-window-size").item(0), "height", getDefaultStartupWindowHeight(), false, true, document, configFile);
- }
-
//Setters
@@ -213,24 +203,6 @@ public class Config {
getClientElement().getElementsByTagName("themes-path").item(0).setTextContent(themesPath);
}
- //client > startup-window-size
- public void setStartupWindowSize(double width, double height)
- {
- setStartupWindowWidth(width);
- setStartupWindowHeight(height);
- }
-
- public void setStartupWindowWidth(double width)
- {
- ((Element) getClientElement().getElementsByTagName("startup-window-size").item(0))
- .getElementsByTagName("width").item(0).setTextContent(width+"");
- }
-
- public void setStartupWindowHeight(double height)
- {
- ((Element) getClientElement().getElementsByTagName("startup-window-size").item(0))
- .getElementsByTagName("height").item(0).setTextContent(height+"");
- }
@@ -300,11 +272,6 @@ public class Config {
return false;
}
- public boolean getDefaultFullscreen()
- {
- return true;
- }
-
public boolean getDefaultIsShowCursor()
{
return true;
@@ -328,16 +295,20 @@ public class Config {
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot", getDefaultStartOnBoot(), false, true, document, configFile);
}
+
+ public boolean isFirstTimeUse()
+ {
+ return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile);
+ }
- public boolean isFullscreen()
+ public boolean isVibrateOnActionClicked()
{
- return XMLConfigHelper.getBooleanProperty(getOthersElement(), "fullscreen", getDefaultFullscreen(), false, true, document, configFile);
+ return XMLConfigHelper.getBooleanProperty(getOthersElement(), "vibrate-on-action-clicked", false, false, true, document, configFile);
}
-
- public boolean isFirstTimeUse()
+ public boolean isConnectOnStartup()
{
- return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile);
+ return XMLConfigHelper.getBooleanProperty(getOthersElement(), "connect-on-startup", false, false, true, document, configFile);
}
@@ -361,4 +332,14 @@ public class Config {
getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+"");
}
+ public void setVibrateOnActionClicked(boolean value)
+ {
+ getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(value+"");
+ }
+
+ public void setConnectOnStartup(boolean value)
+ {
+ getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(value+"");
+ }
+
}
--- 'a/src/main/java/com/stream_pi/client/window/Base.java'
+++ b/src/main/java/com/stream_pi/client/window/Base.java
@@ -163,7 +163,6 @@ public abstract class Base extends Stack
getChildren().clear();
getChildren().addAll(alertStackPane);
-
initLogger();
checkPrePathDirectory();
@@ -307,18 +306,6 @@ public abstract class Base extends Stack
public void setupFlags()
{
- //Full Screen
- if(getConfig().isFullscreen())
- {
- getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH);
- getStage().setFullScreen(true);
- }
- else
- {
- getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("Esc"));
- getStage().setFullScreen(false);
- }
-
//Cursor
if(getConfig().isShowCursor())
{
--- 'a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java'
+++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java
@@ -25,8 +25,6 @@ public class FinalConfigPane extends VBo
private TextField clientNicknameTextField;
private TextField serverIPHostNameTextField;
private TextField serverPortTextField;
- private TextField displayWidthTextField;
- private TextField displayHeightTextField;
private Button nextButton;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
@@ -50,25 +48,14 @@ public class FinalConfigPane extends VBo
serverIPHostNameTextField = new TextField();
serverPortTextField = new TextField();
- displayWidthTextField = new TextField();
- displayHeightTextField = new TextField();
-
HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField);
HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField);
HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField);
- HBoxInputBox displayWidthInputBox = new HBoxInputBox("Display Width", displayWidthTextField);
- HBoxInputBox displayHeightInputBox = new HBoxInputBox("Display Height", displayHeightTextField);
Platform platform = ClientInfo.getInstance().getPlatform();
- if(platform == Platform.ANDROID ||
- platform == Platform.IOS)
- {
- displayWidthInputBox.setVisible(false);
- displayHeightInputBox.setVisible(false);
- }
- VBox v = new VBox(clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox,
- displayWidthInputBox, displayHeightInputBox);
+
+ VBox v = new VBox(clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox);
v.setSpacing(10.0);
ScrollPane scrollPane = new ScrollPane(v);
@@ -115,35 +102,6 @@ public class FinalConfigPane extends VBo
errors.append("* Server IP should be a number.\n");
}
- double width=-1,height=-1;
-
- if(ClientInfo.getInstance().getPlatform() != Platform.ANDROID)
- {
- try
- {
- width = Double.parseDouble(displayWidthTextField.getText());
-
- if(width < 0)
- errors.append("* Display Width should be above 0.\n");
- }
- catch (NumberFormatException exception)
- {
- errors.append("* Display Width should be a number.\n");
- }
-
- try
- {
- height = Double.parseDouble(displayHeightTextField.getText());
-
- if(height < 0)
- errors.append("* Display Height should be above 0.\n");
- }
- catch (NumberFormatException exception)
- {
- errors.append("* Display Height should be a number.\n");
- }
- }
-
if(errors.toString().isEmpty())
{
try
@@ -153,19 +111,10 @@ public class FinalConfigPane extends VBo
Config.getInstance().setServerPort(port);
Config.getInstance().setFirstTimeUse(false);
- Platform platform = ClientInfo.getInstance().getPlatform();
- if(platform != Platform.ANDROID &&
- platform != Platform.IOS)
- {
- Config.getInstance().setStartupWindowSize(
- width, height
- );
- }
-
-
Config.getInstance().save();
clientListener.init();
+ clientListener.setupClientConnection();
}
catch(SevereException e)
--- 'a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java'
+++ b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java
@@ -3,8 +3,10 @@ package com.stream_pi.client.window.sett
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
+import java.util.function.Consumer;
import com.gluonhq.attach.browser.BrowserService;
+import com.gluonhq.attach.vibration.VibrationService;
import com.stream_pi.client.connection.ClientListener;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.info.ClientInfo;
@@ -44,9 +46,6 @@ public class SettingsBase extends VBox {
private StreamPiComboBox<ClientProfile> clientProfileComboBox;
private StreamPiComboBox<Theme> themeComboBox;
- private TextField displayWidthTextField;
- private TextField displayHeightTextField;
-
private TextField nickNameTextField;
private Button closeButton;
@@ -56,8 +55,10 @@ public class SettingsBase extends VBox {
private ToggleButton startOnBootToggleButton;
+ private ToggleButton connectOnStartupToggleButton;
+ private ToggleButton vibrateOnActionPressToggleButton;
+
private ToggleButton showCursorToggleButton;
- private ToggleButton fullScreenToggleButton;
private ClientListener clientListener;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
@@ -112,9 +113,6 @@ public class SettingsBase extends VBox {
}
});
- displayHeightTextField = new TextField();
- displayWidthTextField = new TextField();
-
themesPathTextField = new TextField();
iconsPathTextField = new TextField();
profilesPathTextField = new TextField();
@@ -122,12 +120,15 @@ public class SettingsBase extends VBox {
startOnBootToggleButton = new ToggleButton("Start On Boot");
startOnBootToggleButton.managedProperty().bind(startOnBootToggleButton.visibleProperty());
+ vibrateOnActionPressToggleButton = new ToggleButton("Vibrate On Action Press");
+ vibrateOnActionPressToggleButton.managedProperty().bind(vibrateOnActionPressToggleButton.visibleProperty());
+
+ connectOnStartupToggleButton = new ToggleButton("Connect On Startup");
+ connectOnStartupToggleButton.managedProperty().bind(connectOnStartupToggleButton.visibleProperty());
+
showCursorToggleButton = new ToggleButton("Show Cursor");
showCursorToggleButton.managedProperty().bind(showCursorToggleButton.visibleProperty());
- fullScreenToggleButton = new ToggleButton("Full Screen");
- fullScreenToggleButton.managedProperty().bind(fullScreenToggleButton.visibleProperty());
-
int prefWidth = 200;
Label licenseLabel = new Label("This software is licensed to GNU GPLv3. Check StreamPi Server > settings > About to see full License Statement.");
@@ -148,12 +149,6 @@ public class SettingsBase extends VBox {
profilesPathInputBox.managedProperty().bind(profilesPathInputBox.visibleProperty());
- HBoxInputBox screenHeightInputBox = new HBoxInputBox("Screen Height", displayHeightTextField, prefWidth);
- screenHeightInputBox.managedProperty().bind(screenHeightInputBox.visibleProperty());
-
-
- HBoxInputBox screenWidthInputBox = new HBoxInputBox("Screen Width", displayWidthTextField, prefWidth);
- screenWidthInputBox.managedProperty().bind(screenWidthInputBox.visibleProperty());
com.stream_pi.util.platform.Platform platform = ClientInfo.getInstance().getPlatform();
if(platform == Platform.ANDROID ||
@@ -165,10 +160,10 @@ public class SettingsBase extends VBox {
startOnBootToggleButton.setVisible(false);
showCursorToggleButton.setVisible(false);
- fullScreenToggleButton.setVisible(false);
-
- screenHeightInputBox.setVisible(false);
- screenWidthInputBox.setVisible(false);
+ }
+ else
+ {
+ vibrateOnActionPressToggleButton.setVisible(false);
}
checkForUpdatesButton = new Button("Check for updates");
@@ -188,8 +183,6 @@ public class SettingsBase extends VBox {
SpaceFiller.horizontal(),
themeComboBox
),
- screenHeightInputBox,
- screenWidthInputBox,
themesPathInputBox,
iconsPathInputBox,
profilesPathInputBox
@@ -205,10 +198,11 @@ public class SettingsBase extends VBox {
}
vBox.getChildren().addAll(
+ connectOnStartupToggleButton,
+ vibrateOnActionPressToggleButton,
checkForUpdatesButton,
startOnBootToggleButton,
showCursorToggleButton,
- fullScreenToggleButton,
licenseLabel,
versionLabel
);
@@ -357,10 +351,12 @@ public class SettingsBase extends VBox {
public void loadData() throws SevereException
{
- nickNameTextField.setText(Config.getInstance().getClientNickName());
+ Config config = Config.getInstance();
- serverHostNameOrIPTextField.setText(Config.getInstance().getSavedServerHostNameOrIP());
- serverPortTextField.setText(Config.getInstance().getSavedServerPort()+"");
+ nickNameTextField.setText(config.getClientNickName());
+
+ serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP());
+ serverPortTextField.setText(config.getSavedServerPort()+"");
clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles());
@@ -390,17 +386,16 @@ public class SettingsBase extends VBox {
themeComboBox.setCurrentSelectedItemIndex(ind2);
- displayWidthTextField.setText(Config.getInstance().getStartupWindowWidth()+"");
- displayHeightTextField.setText(Config.getInstance().getStartupWindowHeight()+"");
+ themesPathTextField.setText(config.getThemesPath());
+ iconsPathTextField.setText(config.getIconsPath());
+ profilesPathTextField.setText(config.getProfilesPath());
- themesPathTextField.setText(Config.getInstance().getThemesPath());
- iconsPathTextField.setText(Config.getInstance().getIconsPath());
- profilesPathTextField.setText(Config.getInstance().getProfilesPath());
+ startOnBootToggleButton.setSelected(config.isStartOnBoot());
- startOnBootToggleButton.setSelected(Config.getInstance().isStartOnBoot());
+ showCursorToggleButton.setSelected(config.isShowCursor());
- fullScreenToggleButton.setSelected(Config.getInstance().isFullscreen());
- showCursorToggleButton.setSelected(Config.getInstance().isShowCursor());
+ connectOnStartupToggleButton.setSelected(config.isConnectOnStartup());
+ vibrateOnActionPressToggleButton.setSelected(config.isVibrateOnActionClicked());
}
public void onSaveButtonClicked()
@@ -420,31 +415,6 @@ public class SettingsBase extends VBox {
errors.append("* Server IP should be a number.\n");
}
- double width = -1;
- try
- {
- width = Double.parseDouble(displayWidthTextField.getText());
-
- if(width < 0)
- errors.append("* Display Width should be above 0.\n");
- }
- catch (NumberFormatException exception)
- {
- errors.append("* Display Width should be a number.\n");
- }
-
- double height = -1;
- try
- {
- height = Double.parseDouble(displayHeightTextField.getText());
-
- if(height < 0)
- errors.append("* Display Height should be above 0.\n");
- }
- catch (NumberFormatException exception)
- {
- errors.append("* Display Height should be a number.\n");
- }
if(serverHostNameOrIPTextField.getText().isBlank())
{
@@ -473,34 +443,30 @@ public class SettingsBase extends VBox {
boolean breakConnection = false;
- if(!Config.getInstance().getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName()))
+ Config config = Config.getInstance();
+
+ if(!config.getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName()))
{
breakConnection = true;
toBeReloaded = true;
}
- Config.getInstance().setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName());
+ config.setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName());
- if(width != Config.getInstance().getStartupWindowWidth() || height != Config.getInstance().getStartupWindowHeight())
- toBeReloaded = true;
-
- Config.getInstance().setStartupWindowSize(width, height);
-
-
- if(!Config.getInstance().getClientNickName().equals(nickNameTextField.getText()))
+ if(!config.getClientNickName().equals(nickNameTextField.getText()))
breakConnection = true;
- Config.getInstance().setNickName(nickNameTextField.getText());
+ config.setNickName(nickNameTextField.getText());
- if(port != Config.getInstance().getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(Config.getInstance().getSavedServerHostNameOrIP()))
+ if(port != config.getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP()))
breakConnection = true;
- Config.getInstance().setServerPort(port);
- Config.getInstance().setServerHostNameOrIP(serverHostNameOrIPTextField.getText());
+ config.setServerPort(port);
+ config.setServerHostNameOrIP(serverHostNameOrIPTextField.getText());
boolean startOnBoot = startOnBootToggleButton.isSelected();
- if(Config.getInstance().isStartOnBoot() != startOnBoot)
+ if(config.isStartOnBoot() != startOnBoot)
{
if(ClientInfo.getInstance().getRunnerFileName() == null)
{
@@ -524,36 +490,45 @@ public class SettingsBase extends VBox {
}
}
- Config.getInstance().setStartOnBoot(startOnBoot);
+ config.setStartOnBoot(startOnBoot);
- if(Config.getInstance().isFullscreen() != fullScreenToggleButton.isSelected() ||
- Config.getInstance().isShowCursor() != showCursorToggleButton.isSelected())
- toBeReloaded = true;
+ config.setShowCursor(showCursorToggleButton.isSelected());
- Config.getInstance().setFullscreen(fullScreenToggleButton.isSelected());
- Config.getInstance().setShowCursor(showCursorToggleButton.isSelected());
-
-
- if(!Config.getInstance().getThemesPath().equals(themesPathTextField.getText()))
+ if(!config.getThemesPath().equals(themesPathTextField.getText()))
toBeReloaded = true;
- Config.getInstance().setThemesPath(themesPathTextField.getText());
+ config.setThemesPath(themesPathTextField.getText());
- if(!Config.getInstance().getIconsPath().equals(iconsPathTextField.getText()))
+ if(!config.getIconsPath().equals(iconsPathTextField.getText()))
toBeReloaded = true;
- Config.getInstance().setIconsPath(iconsPathTextField.getText());
+ config.setIconsPath(iconsPathTextField.getText());
- if(!Config.getInstance().getProfilesPath().equals(profilesPathTextField.getText()))
+ if(!config.getProfilesPath().equals(profilesPathTextField.getText()))
toBeReloaded = true;
- Config.getInstance().setProfilesPath(profilesPathTextField.getText());
+ config.setProfilesPath(profilesPathTextField.getText());
+
+ config.setConnectOnStartup(connectOnStartupToggleButton.isSelected());
+
+ boolean isVibrateOnActionClicked = vibrateOnActionPressToggleButton.isSelected();
+
+ if(config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked)
+ {
+ if(VibrationService.create().isEmpty())
+ {
+ isVibrateOnActionClicked = false;
+ new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show();
+ }
+ }
+
+ config.setVibrateOnActionClicked(isVibrateOnActionClicked);
- Config.getInstance().save();
+ config.save();
loadData();
--- 'a/src/main/java/module-info.java'
+++ b/src/main/java/module-info.java
@@ -9,6 +9,7 @@ module com.stream_pi.client {
requires com.gluonhq.attach.util;
requires com.gluonhq.attach.storage;
requires com.gluonhq.attach.browser;
+ requires com.gluonhq.attach.vibration;
requires java.xml;
Binary files 'a/src/main/resources/com/stream_pi/client/Default.zip' and b/src/main/resources/com/stream_pi/client/Default.zip differ