client

Clone or download

Added somewhat autoreconnect stuff

Modified Files

/*
/*
Config.java
Config.java
Contributor(s) : Debayan Sutradhar (@rnayabed)
Contributor(s) : Debayan Sutradhar (@rnayabed)
handler for config.xml
handler for config.xml
*/
*/
package com.stream_pi.client.io;
package com.stream_pi.client.io;
import java.io.File;
import java.io.File;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.transform.Result;
import javax.xml.transform.Result;
import javax.xml.transform.Source;
import javax.xml.transform.Source;
import javax.xml.transform.Transformer;
import javax.xml.transform.Transformer;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.TransformerFactory;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import javax.xml.transform.stream.StreamResult;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.xmlconfighelper.XMLConfigHelper;
import com.stream_pi.util.xmlconfighelper.XMLConfigHelper;
import org.w3c.dom.Document;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Element;
public class Config
public class Config
{
{
private static Config instance = null;
private static Config instance = null;
private final File configFile;
private final File configFile;
private Document document;
private Document document;
private Config() throws SevereException
private Config() throws SevereException
{
{
try
try
{
{
configFile = new File(ClientInfo.getInstance().getPrePath()+"config.xml");
configFile = new File(ClientInfo.getInstance().getPrePath()+"config.xml");
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
document = docBuilder.parse(configFile);
document = docBuilder.parse(configFile);
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
throw new SevereException("Config", "unable to read config.xml");
throw new SevereException("Config", "unable to read config.xml");
}
}
}
}
public static synchronized Config getInstance() throws SevereException
public static synchronized Config getInstance() throws SevereException
{
{
if(instance == null)
if(instance == null)
instance = new Config();
instance = new Config();
return instance;
return instance;
}
}
public void save() throws SevereException
public void save() throws SevereException
{
{
try
try
{
{
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Transformer transformer = TransformerFactory.newInstance().newTransformer();
Result output = new StreamResult(configFile);
Result output = new StreamResult(configFile);
Source input = new DOMSource(document);
Source input = new DOMSource(document);
transformer.transform(input, output);
transformer.transform(input, output);
}
}
catch (Exception e)
catch (Exception e)
{
{
throw new SevereException("Config", "unable to save config.xml");
throw new SevereException("Config", "unable to save config.xml");
}
}
}
}
//Client Element
//Client Element
public Element getClientElement()
public Element getClientElement()
{
{
return (Element) document.getElementsByTagName("client").item(0);
return (Element) document.getElementsByTagName("client").item(0);
}
}
//Default Values
//Default Values
public String getDefaultClientNickName()
public String getDefaultClientNickName()
{
{
return "Stream-Pi Client";
return "Stream-Pi Client";
}
}
public String getDefaultStartupProfileID()
public String getDefaultStartupProfileID()
{
{
return "default";
return "default";
}
}
public String getDefaultCurrentThemeFullName()
public String getDefaultCurrentThemeFullName()
{
{
return "com.stream_pi.defaultlight";
return "com.stream_pi.defaultlight";
}
}
public String getDefaultThemesPath()
public String getDefaultThemesPath()
{
{
return ClientInfo.getInstance().getPrePath()+"Themes/";
return ClientInfo.getInstance().getPrePath()+"Themes/";
}
}
public String getDefaultProfilesPath()
public String getDefaultProfilesPath()
{
{
return ClientInfo.getInstance().getPrePath()+"Profiles/";
return ClientInfo.getInstance().getPrePath()+"Profiles/";
}
}
public String getDefaultIconsPath()
public String getDefaultIconsPath()
{
{
return ClientInfo.getInstance().getPrePath()+"Icons/";
return ClientInfo.getInstance().getPrePath()+"Icons/";
}
}
public int getDefaultStartupWindowWidth()
public int getDefaultStartupWindowWidth()
{
{
return 800;
return 800;
}
}
public int getDefaultStartupWindowHeight()
public int getDefaultStartupWindowHeight()
{
{
return 400;
return 400;
}
}
//Getters
//Getters
public String getClientNickName()
public String getClientNickName()
{
{
return XMLConfigHelper.getStringProperty(getClientElement(), "nickname", getDefaultClientNickName(), false, true, document, configFile);
return XMLConfigHelper.getStringProperty(getClientElement(), "nickname", getDefaultClientNickName(), false, true, document, configFile);
}
}
public String getStartupProfileID()
public String getStartupProfileID()
{
{
return XMLConfigHelper.getStringProperty(getClientElement(), "startup-profile", getDefaultStartupProfileID(), false, true, document, configFile);
return XMLConfigHelper.getStringProperty(getClientElement(), "startup-profile", getDefaultStartupProfileID(), false, true, document, configFile);
}
}
public String getCurrentThemeFullName()
public String getCurrentThemeFullName()
{
{
return XMLConfigHelper.getStringProperty(getClientElement(), "current-theme-full-name", getDefaultCurrentThemeFullName(), false, true, document, configFile);
return XMLConfigHelper.getStringProperty(getClientElement(), "current-theme-full-name", getDefaultCurrentThemeFullName(), false, true, document, configFile);
}
}
public String getThemesPath()
public String getThemesPath()
{
{
Platform platform = ClientInfo.getInstance().getPlatform();
Platform platform = ClientInfo.getInstance().getPlatform();
if(platform != Platform.ANDROID &&
if(platform != Platform.ANDROID &&
platform != Platform.IOS)
platform != Platform.IOS)
return ClientInfo.getInstance().getPrePath() + "Themes/";
return ClientInfo.getInstance().getPrePath() + "Themes/";
return XMLConfigHelper.getStringProperty(getClientElement(), "themes-path", getDefaultThemesPath(), false, true, document, configFile);
return XMLConfigHelper.getStringProperty(getClientElement(), "themes-path", getDefaultThemesPath(), false, true, document, configFile);
}
}
public String getProfilesPath()
public String getProfilesPath()
{
{
Platform platform = ClientInfo.getInstance().getPlatform();
Platform platform = ClientInfo.getInstance().getPlatform();
if(platform != Platform.ANDROID &&
if(platform != Platform.ANDROID &&
platform != Platform.IOS)
platform != Platform.IOS)
return ClientInfo.getInstance().getPrePath() + "Profiles/";
return ClientInfo.getInstance().getPrePath() + "Profiles/";
return XMLConfigHelper.getStringProperty(getClientElement(), "profiles-path", getDefaultProfilesPath(), false, true, document, configFile);
return XMLConfigHelper.getStringProperty(getClientElement(), "profiles-path", getDefaultProfilesPath(), false, true, document, configFile);
}
}
public String getIconsPath()
public String getIconsPath()
{
{
Platform platform = ClientInfo.getInstance().getPlatform();
Platform platform = ClientInfo.getInstance().getPlatform();
if(platform != Platform.ANDROID &&
if(platform != Platform.ANDROID &&
platform != Platform.IOS)
platform != Platform.IOS)
return ClientInfo.getInstance().getPrePath() + "Icons/";
return ClientInfo.getInstance().getPrePath() + "Icons/";
return XMLConfigHelper.getStringProperty(getClientElement(), "icons-path", getDefaultIconsPath(), false, true, document, configFile);
return XMLConfigHelper.getStringProperty(getClientElement(), "icons-path", getDefaultIconsPath(), false, true, document, configFile);
}
}
//Setters
//Setters
public void setNickName(String nickName)
public void setNickName(String nickName)
{
{
getClientElement().getElementsByTagName("nickname").item(0).setTextContent(nickName);
getClientElement().getElementsByTagName("nickname").item(0).setTextContent(nickName);
}
}
public void setStartupProfileID(String id)
public void setStartupProfileID(String id)
{
{
getClientElement().getElementsByTagName("startup-profile").item(0).setTextContent(id);
getClientElement().getElementsByTagName("startup-profile").item(0).setTextContent(id);
}
}
public void setCurrentThemeFullName(String name)
public void setCurrentThemeFullName(String name)
{
{
getClientElement().getElementsByTagName("current-theme-full-name").item(0).setTextContent(name);
getClientElement().getElementsByTagName("current-theme-full-name").item(0).setTextContent(name);
}
}
public void setProfilesPath(String profilesPath)
public void setProfilesPath(String profilesPath)
{
{
getClientElement().getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath);
getClientElement().getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath);
}
}
public void setIconsPath(String iconsPath)
public void setIconsPath(String iconsPath)
{
{
getClientElement().getElementsByTagName("icons-path").item(0).setTextContent(iconsPath);
getClientElement().getElementsByTagName("icons-path").item(0).setTextContent(iconsPath);
}
}
public void setThemesPath(String themesPath)
public void setThemesPath(String themesPath)
{
{
getClientElement().getElementsByTagName("themes-path").item(0).setTextContent(themesPath);
getClientElement().getElementsByTagName("themes-path").item(0).setTextContent(themesPath);
}
}
//comms-server
//comms-server
public Element getCommsServerElement()
public Element getCommsServerElement()
{
{
return (Element) document.getElementsByTagName("comms-server").item(0);
return (Element) document.getElementsByTagName("comms-server").item(0);
}
}
public String getDefaultSavedServerHostNameOrIP()
public String getDefaultSavedServerHostNameOrIP()
{
{
return "127.0.0.1";
return "127.0.0.1";
}
}
public int getDefaultSavedServerPort()
public int getDefaultSavedServerPort()
{
{
return -1;
return -1;
}
}
public int getDefaultAutoReconnectTimeInterval()
{
return 300;
}
public String getSavedServerHostNameOrIP()
public String getSavedServerHostNameOrIP()
{
{
return XMLConfigHelper.getStringProperty(getCommsServerElement(), "hostname-ip", getDefaultSavedServerHostNameOrIP(), false, true, document, configFile);
return XMLConfigHelper.getStringProperty(getCommsServerElement(), "hostname-ip", getDefaultSavedServerHostNameOrIP(), false, true, document, configFile);
}
}
public int getSavedServerPort()
public int getSavedServerPort()
{
{
return XMLConfigHelper.getIntProperty(getCommsServerElement(), "port", getDefaultSavedServerPort(), false, true, document, configFile);
return XMLConfigHelper.getIntProperty(getCommsServerElement(), "port", getDefaultSavedServerPort(), false, true, document, configFile);
}
}
public int getAutoReconnectTimeInterval()
{
return XMLConfigHelper.getIntProperty(getCommsServerElement(), "auto-reconnect-interval", getDefaultSavedServerPort(), false, true, document, configFile);
}
public void setServerHostNameOrIP(String hostNameOrIP)
public void setServerHostNameOrIP(String hostNameOrIP)
{
{
getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP);
getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP);
}
}
public void setServerPort(int port)
public void setServerPort(int port)
{
{
getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(port+"");
getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(port+"");
}
}
//others
//others
public Element getOthersElement()
public Element getOthersElement()
{
{
return (Element) document.getElementsByTagName("others").item(0);
return (Element) document.getElementsByTagName("others").item(0);
}
}
//others-default
//others-default
public boolean getDefaultStartOnBoot()
public boolean getDefaultStartOnBoot()
{
{
return false;
return false;
}
}
public boolean getDefaultIsShowCursor()
public boolean getDefaultIsShowCursor()
{
{
return true;
return true;
}
}
public boolean getDefaultFirstTimeUse()
public boolean getDefaultFirstTimeUse()
{
{
return true;
return true;
}
}
public boolean isShowCursor()
public boolean isShowCursor()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "show-cursor", getDefaultIsShowCursor(), false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "show-cursor", getDefaultIsShowCursor(), false, true, document, configFile);
}
}
public boolean isStartOnBoot()
public boolean isStartOnBoot()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot", getDefaultStartOnBoot(), false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot", getDefaultStartOnBoot(), false, true, document, configFile);
}
}
public boolean isFirstTimeUse()
public boolean isFirstTimeUse()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile);
}
}
public boolean isVibrateOnActionClicked()
public boolean isVibrateOnActionClicked()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "vibrate-on-action-clicked", false, false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "vibrate-on-action-clicked", false, false, true, document, configFile);
}
}
public boolean isConnectOnStartup()
public boolean isConnectOnStartup()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "connect-on-startup", false, false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "connect-on-startup", false, false, true, document, configFile);
}
}
public boolean getIsFullScreenMode()
public boolean getIsFullScreenMode()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "full-screen-mode", false, false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "full-screen-mode", false, false, true, document, configFile);
}
}
public void setStartOnBoot(boolean value)
public void setStartOnBoot(boolean value)
{
{
getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+"");
}
}
public void setShowCursor(boolean value)
public void setShowCursor(boolean value)
{
{
getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(value+"");
}
}
public void setFullscreen(boolean value)
public void setFullscreen(boolean value)
{
{
getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(value+"");
}
}
public void setFirstTimeUse(boolean value)
public void setFirstTimeUse(boolean value)
{
{
getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+"");
}
}
public void setVibrateOnActionClicked(boolean value)
public void setVibrateOnActionClicked(boolean value)
{
{
getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(value+"");
}
}
public void setConnectOnStartup(boolean value)
public void setConnectOnStartup(boolean value)
{
{
getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(value+"");
}
}
public void setIsFullScreenMode(boolean value)
public void setIsFullScreenMode(boolean value)
{
{
getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(value+"");
}
}
}
}
package com.stream_pi.client.window.settings;
package com.stream_pi.client.window.settings;
import java.io.File;
import java.io.File;
import java.io.IOException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URISyntaxException;
import java.util.function.Consumer;
import java.util.function.Consumer;
import com.gluonhq.attach.browser.BrowserService;
import com.gluonhq.attach.browser.BrowserService;
import com.gluonhq.attach.vibration.VibrationService;
import com.gluonhq.attach.vibration.VibrationService;
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.theme_api.Theme;
import com.stream_pi.theme_api.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.checkforupdates.CheckForUpdates;
import com.stream_pi.util.checkforupdates.CheckForUpdates;
import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick;
import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick;
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.platform.Platform;
import com.stream_pi.util.platform.Platform;
import com.stream_pi.util.platform.PlatformType;
import com.stream_pi.util.platform.PlatformType;
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.StartAtBoot;
import com.stream_pi.util.startatboot.StartAtBoot;
import javafx.application.HostServices;
import javafx.application.HostServices;
import javafx.concurrent.Task;
import javafx.concurrent.Task;
import javafx.event.ActionEvent;
import javafx.event.ActionEvent;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.CacheHint;
import javafx.scene.CacheHint;
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 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 connectOnStartupToggleButton;
private ToggleButton connectOnStartupToggleButton;
private ToggleButton vibrateOnActionPressToggleButton;
private ToggleButton vibrateOnActionPressToggleButton;
private ToggleButton fullScreenModeToggleButton;
private ToggleButton fullScreenModeToggleButton;
private ToggleButton showCursorToggleButton;
private ToggleButton showCursorToggleButton;
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;
private TextField autoReconnectTimeTextField;
private final Button checkForUpdatesButton;
private final Button checkForUpdatesButton;
private HostServices hostServices;
private HostServices hostServices;
public SettingsBase(ExceptionAndAlertHandler exceptionAndAlertHandler,
public SettingsBase(ExceptionAndAlertHandler exceptionAndAlertHandler,
ClientListener clientListener, HostServices hostServices)
ClientListener clientListener, HostServices hostServices)
{
{
getStyleClass().add("settings_base");
getStyleClass().add("settings_base");
this.hostServices = hostServices;
this.hostServices = hostServices;
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, true);
clientListener.renderProfile(selectedItem, true);
}
}
});
});
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();
}
}
});
});
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());
fullScreenModeToggleButton = new ToggleButton("Full Screen");
fullScreenModeToggleButton = new ToggleButton("Full Screen");
fullScreenModeToggleButton.managedProperty().bind(fullScreenModeToggleButton.visibleProperty());
fullScreenModeToggleButton.managedProperty().bind(fullScreenModeToggleButton.visibleProperty());
vibrateOnActionPressToggleButton = new ToggleButton("Vibrate On Action Press");
vibrateOnActionPressToggleButton = new ToggleButton("Vibrate On Action Press");
vibrateOnActionPressToggleButton.managedProperty().bind(vibrateOnActionPressToggleButton.visibleProperty());
vibrateOnActionPressToggleButton.managedProperty().bind(vibrateOnActionPressToggleButton.visibleProperty());
connectOnStartupToggleButton = new ToggleButton("Connect On Startup");
connectOnStartupToggleButton = new ToggleButton("Connect On Startup");
connectOnStartupToggleButton.managedProperty().bind(connectOnStartupToggleButton.visibleProperty());
connectOnStartupToggleButton.managedProperty().bind(connectOnStartupToggleButton.visibleProperty());
showCursorToggleButton = new ToggleButton("Show Cursor");
showCursorToggleButton = new ToggleButton("Show Cursor");
showCursorToggleButton.managedProperty().bind(showCursorToggleButton.visibleProperty());
showCursorToggleButton.managedProperty().bind(showCursorToggleButton.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());
checkForUpdatesButton = new Button("Check for updates");
checkForUpdatesButton = new Button("Check for updates");
checkForUpdatesButton.setOnAction(event->checkForUpdates());
checkForUpdatesButton.setOnAction(event->checkForUpdates());
autoReconnectTimeTextField = new TextField();
VBox vBox = new VBox(
VBox vBox = new VBox(
new HBoxInputBox("Device 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"),
SpaceFiller.horizontal(),
SpaceFiller.horizontal(),
clientProfileComboBox
clientProfileComboBox
),
),
new HBox(
new HBox(
new Label("Theme"),
new Label("Theme"),
SpaceFiller.horizontal(),
SpaceFiller.horizontal(),
themeComboBox
themeComboBox
),
),
themesPathInputBox,
themesPathInputBox,
iconsPathInputBox,
iconsPathInputBox,
profilesPathInputBox
profilesPathInputBox
);
);
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());
Button exitButton = new Button("Exit");
Button exitButton = new Button("Exit");
exitButton.setOnAction(event -> onExitButtonClicked());
exitButton.setOnAction(event -> onExitButtonClicked());
HBox buttonBar = new HBox(connectDisconnectButton, saveButton);
HBox buttonBar = new HBox(connectDisconnectButton, saveButton);
shutdownButton = new Button("Shutdown");
shutdownButton = new Button("Shutdown");
shutdownButton.managedProperty().bind(shutdownButton.visibleProperty());
shutdownButton.managedProperty().bind(shutdownButton.visibleProperty());
shutdownButton.setOnAction(event -> onShutdownButtonClicked());
shutdownButton.setOnAction(event -> onShutdownButtonClicked());
vBox.getChildren().addAll(
vBox.getChildren().addAll(
shutdownButton,
shutdownButton,
fullScreenModeToggleButton,
fullScreenModeToggleButton,
connectOnStartupToggleButton,
connectOnStartupToggleButton,
vibrateOnActionPressToggleButton,
vibrateOnActionPressToggleButton,
checkForUpdatesButton,
checkForUpdatesButton,
startOnBootToggleButton,
startOnBootToggleButton,
showCursorToggleButton,
showCursorToggleButton,
licenseLabel,
licenseLabel,
versionLabel
versionLabel
);
);
buttonBar.getChildren().add(closeButton);
buttonBar.getChildren().add(closeButton);
buttonBar.getStyleClass().add("settings_button_bar");
buttonBar.getStyleClass().add("settings_button_bar");
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
);
);
setCache(true);
setCache(true);
setCacheHint(CacheHint.SPEED);
setCacheHint(CacheHint.SPEED);
//Perform platform checks
//Perform platform checks
Platform platform = ClientInfo.getInstance().getPlatform();
Platform platform = ClientInfo.getInstance().getPlatform();
if(platform == Platform.ANDROID ||
if(platform == Platform.ANDROID ||
platform == Platform.IOS)
platform == Platform.IOS)
{
{
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);
fullScreenModeToggleButton.setVisible(false);
fullScreenModeToggleButton.setVisible(false);
}
}
else
else
{
{
if(!ClientInfo.getInstance().isShowShutDownButton())
if(!ClientInfo.getInstance().isShowShutDownButton())
{
{
shutdownButton.setVisible(false);
shutdownButton.setVisible(false);
}
}
vibrateOnActionPressToggleButton.setVisible(false);
vibrateOnActionPressToggleButton.setVisible(false);
buttonBar.getChildren().add(exitButton);
buttonBar.getChildren().add(exitButton);
}
}
if(!ClientInfo.getInstance().isShowFullScreenToggleButton())
if(!ClientInfo.getInstance().isShowFullScreenToggleButton())
{
{
fullScreenModeToggleButton.setVisible(false);
fullScreenModeToggleButton.setVisible(false);
}
}
}
}
private void checkForUpdates()
private void checkForUpdates()
{
{
new CheckForUpdates(checkForUpdatesButton,
new CheckForUpdates(checkForUpdatesButton,
PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() {
PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() {
@Override
@Override
public void handle(ActionEvent actionEvent) {
public void handle(ActionEvent actionEvent) {
Platform platform = ClientInfo.getInstance().getPlatform();
Platform platform = ClientInfo.getInstance().getPlatform();
if(platform == Platform.ANDROID || platform == Platform.IOS)
if(platform == Platform.ANDROID || platform == Platform.IOS)
{
{
BrowserService.create().ifPresentOrElse(s->
BrowserService.create().ifPresentOrElse(s->
{
{
try
try
{
{
s.launchExternalBrowser(getURL());
s.launchExternalBrowser(getURL());
}
}
catch (Exception e )
catch (Exception e )
{
{
exceptionAndAlertHandler.handleMinorException(
exceptionAndAlertHandler.handleMinorException(
new MinorException("Cant start browser!")
new MinorException("Cant start browser!")
);
);
}
}
},()-> exceptionAndAlertHandler.handleMinorException(
},()-> exceptionAndAlertHandler.handleMinorException(
new MinorException("Sorry!","No browser detected.")
new MinorException("Sorry!","No browser detected.")
));
));
}
}
else
else
{
{
hostServices.showDocument(getURL());
hostServices.showDocument(getURL());
}
}
}
}
});
});
}
}
public void onExitButtonClicked()
public void onExitButtonClicked()
{
{
clientListener.onCloseRequest();
clientListener.onCloseRequest();
javafx.application.Platform.exit();
javafx.application.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()
{
{
javafx.application.Platform.runLater(()->{
javafx.application.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
{
{
Config config = Config.getInstance();
Config config = Config.getInstance();
nickNameTextField.setText(config.getClientNickName());
nickNameTextField.setText(config.getClientNickName());
serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP());
serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP());
serverPortTextField.setText(config.getSavedServerPort()+"");
serverPortTextField.setText(config.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);
themesPathTextField.setText(config.getThemesPath());
themesPathTextField.setText(config.getThemesPath());
iconsPathTextField.setText(config.getIconsPath());
iconsPathTextField.setText(config.getIconsPath());
profilesPathTextField.setText(config.getProfilesPath());
profilesPathTextField.setText(config.getProfilesPath());
startOnBootToggleButton.setSelected(config.isStartOnBoot());
startOnBootToggleButton.setSelected(config.isStartOnBoot());
fullScreenModeToggleButton.setSelected(config.getIsFullScreenMode());
fullScreenModeToggleButton.setSelected(config.getIsFullScreenMode());
showCursorToggleButton.setSelected(config.isShowCursor());
showCursorToggleButton.setSelected(config.isShowCursor());
connectOnStartupToggleButton.setSelected(config.isConnectOnStartup());
connectOnStartupToggleButton.setSelected(config.isConnectOnStartup());
vibrateOnActionPressToggleButton.setSelected(config.isVibrateOnActionClicked());
vibrateOnActionPressToggleButton.setSelected(config.isVibrateOnActionClicked());
}
}
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");
else if(port > 65535)
else if(port > 65535)
errors.append("* Server Port must be lesser than 65535\n");
errors.append("* Server Port must be lesser than 65535\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");
}
}
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 syncWithServer = false;
boolean syncWithServer = false;
Config config = Config.getInstance();
Config config = Config.getInstance();
if(!config.getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName()))
if(!config.getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName()))
{
{
syncWithServer = true;
syncWithServer = true;
toBeReloaded = true;
toBeReloaded = true;
}
}
config.setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName());
config.setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName());
if(!config.getClientNickName().equals(nickNameTextField.getText()))
if(!config.getClientNickName().equals(nickNameTextField.getText()))
{
{
syncWithServer = true;
syncWithServer = true;
}
}
config.setNickName(nickNameTextField.getText());
config.setNickName(nickNameTextField.getText());
if(port != config.getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP()))
if(port != config.getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP()))
{
{
syncWithServer = true;
syncWithServer = true;
}
}
config.setServerPort(port);
config.setServerPort(port);
config.setServerHostNameOrIP(serverHostNameOrIPTextField.getText());
config.setServerHostNameOrIP(serverHostNameOrIPTextField.getText());
boolean isFullScreen = fullScreenModeToggleButton.isSelected();
boolean isFullScreen = fullScreenModeToggleButton.isSelected();
if(config.getIsFullScreenMode() != isFullScreen)
if(config.getIsFullScreenMode() != isFullScreen)
{
{
toBeReloaded = true;
toBeReloaded = true;
}
}
config.setIsFullScreenMode(isFullScreen);
config.setIsFullScreenMode(isFullScreen);
boolean startOnBoot = startOnBootToggleButton.isSelected();
boolean startOnBoot = startOnBootToggleButton.isSelected();
if(config.isStartOnBoot() != startOnBoot)
if(config.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(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform());
StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform());
if(startOnBoot)
if(startOnBoot)
{
{
startAtBoot.create(new File(ClientInfo.getInstance().getRunnerFileName()),
startAtBoot.create(new File(ClientInfo.getInstance().getRunnerFileName()),
ClientInfo.getInstance().isXMode());
ClientInfo.getInstance().isXMode());
}
}
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.setStartOnBoot(startOnBoot);
config.setStartOnBoot(startOnBoot);
config.setShowCursor(showCursorToggleButton.isSelected());
config.setShowCursor(showCursorToggleButton.isSelected());
if(!config.getThemesPath().equals(themesPathTextField.getText()))
if(!config.getThemesPath().equals(themesPathTextField.getText()))
toBeReloaded = true;
toBeReloaded = true;
config.setThemesPath(themesPathTextField.getText());
config.setThemesPath(themesPathTextField.getText());
if(!config.getIconsPath().equals(iconsPathTextField.getText()))
if(!config.getIconsPath().equals(iconsPathTextField.getText()))
toBeReloaded = true;
toBeReloaded = true;
config.setIconsPath(iconsPathTextField.getText());
config.setIconsPath(iconsPathTextField.getText());
if(!config.getProfilesPath().equals(profilesPathTextField.getText()))
if(!config.getProfilesPath().equals(profilesPathTextField.getText()))
toBeReloaded = true;
toBeReloaded = true;
config.setProfilesPath(profilesPathTextField.getText());
config.setProfilesPath(profilesPathTextField.getText());
config.setConnectOnStartup(connectOnStartupToggleButton.isSelected());
config.setConnectOnStartup(connectOnStartupToggleButton.isSelected());
boolean isVibrateOnActionClicked = vibrateOnActionPressToggleButton.isSelected();
boolean isVibrateOnActionClicked = vibrateOnActionPressToggleButton.isSelected();
if(config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked)
if(config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked)
{
{
if(VibrationService.create().isEmpty())
if(VibrationService.create().isEmpty())
{
{
isVibrateOnActionClicked = false;
isVibrateOnActionClicked = false;
new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show();
new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show();
}
}
}
}
config.setVibrateOnActionClicked(isVibrateOnActionClicked);
config.setVibrateOnActionClicked(isVibrateOnActionClicked);
config.save();
config.save();
loadData();
loadData();
if(syncWithServer)
if(syncWithServer)
{
{
if(clientListener.isConnected())
if(clientListener.isConnected())
{
{
clientListener.getClient().updateClientDetails();
clientListener.getClient().updateClientDetails();
}
}
}
}
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);
}
}
}
}
}
}