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.stream_pi.client' android:versionCode='1' android:versionName='1.0.0 EA+3'>
<manifest xmlns:android='http://schemas.android.com/apk/res/android' package='com.streampi.client' android:versionCode='1' android:versionName='1.0.0 EA+3'>
<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" />
<uses-permission android:name="android.permission.VIBRATE"/>
<uses-permission android:name="android.permission.VIBRATE"/>
<application android:label='Stream-Pi Client' android:icon="@mipmap/ic_launcher"
<application android:label='Stream-Pi Client' android:icon="@mipmap/ic_launcher"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
android:theme="@android:style/Theme.NoTitleBar.Fullscreen"
>
>
<activity android:name='com.gluonhq.helloandroid.MainActivity'
<activity android:name='com.gluonhq.helloandroid.MainActivity'
android:configChanges="orientation|keyboardHidden">
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.controller;
package com.stream_pi.client.controller;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.client.connection.Client;
import com.stream_pi.client.connection.Client;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.profile.ClientProfile;
import com.stream_pi.client.profile.ClientProfile;
import com.stream_pi.client.profile.ClientProfiles;
import com.stream_pi.client.profile.ClientProfiles;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener;
import com.stream_pi.theme_api.Theme;
import com.stream_pi.theme_api.Theme;
import com.stream_pi.theme_api.Themes;
import com.stream_pi.theme_api.Themes;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import javafx.geometry.Orientation;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ExecutorService;
public interface ClientListener
public interface ClientListener
{
{
void onActionFailed(String profileID, String actionID);
void onActionFailed(String profileID, String actionID);
void onActionClicked(String profileID, String actionID, boolean toggleState);
void onActionClicked(String profileID, String actionID, boolean toggleState);
ClientProfiles getClientProfiles();
ClientProfiles getClientProfiles();
Themes getThemes();
Themes getThemes();
String getDefaultThemeFullName();
String getDefaultThemeFullName();
Client getClient();
Client getClient();
void renderRootDefaultProfile();
void renderRootDefaultProfile();
void setConnected(boolean isConnected);
void setConnected(boolean isConnected);
boolean isConnected();
boolean isConnected();
void renderProfile(ClientProfile clientProfile, boolean freshRender);
void renderProfile(ClientProfile clientProfile, boolean freshRender);
void clearActionBox(int col, int row);
void clearActionBox(int col, int row);
void addBlankActionBox(int col, int row);
void addBlankActionBox(int col, int row);
void renderAction(String currentProfileID, Action action);
void renderAction(String currentProfileID, Action action);
void refreshGridIfCurrentProfile(String currentProfileID);
void refreshGridIfCurrentProfile(String currentProfileID);
ActionBox getActionBox(int col, int row);
ActionBox getActionBox(int col, int row);
ClientProfile getCurrentProfile();
ClientProfile getCurrentProfile();
String getCurrentParent();
String getCurrentParent();
Theme getCurrentTheme();
Theme getCurrentTheme();
void initLogger() throws SevereException;
void initLogger() throws SevereException;
void init();
void init();
void disconnect(String message) throws SevereException;
void disconnect(String message) throws SevereException;
void setupClientConnection();
void setupClientConnection();
void setupClientConnection(Runnable onConnect);
void setupClientConnection(Runnable onConnect);
void updateSettingsConnectDisconnectButton();
void updateSettingsConnectDisconnectButton();
void onCloseRequest();
void onCloseRequest();
void loadSettings();
void loadSettings();
double getStageWidth();
double getStageWidth();
double getStageHeight();
double getStageHeight();
void onDisconnect();
void onDisconnect();
boolean getToggleStatus(String profileID, String actionID);
boolean getToggleStatus(String profileID, String actionID);
ActionBox getActionBoxByProfileAndID(String profileID, String actionID);
ActionBox getActionBoxByProfileAndID(String profileID, String actionID);
void openURL(String URL);
void openURL(String URL);
void factoryReset();
void factoryReset();
void exitApp();
void exitApp();
ExecutorService getExecutor();
ExecutorService getExecutor();
Orientation getCurrentOrientation();
}
}
package com.stream_pi.client.controller;
package com.stream_pi.client.controller;
import com.gluonhq.attach.browser.BrowserService;
import com.gluonhq.attach.browser.BrowserService;
import com.gluonhq.attach.orientation.OrientationService;
import com.gluonhq.attach.orientation.OrientationService;
import com.gluonhq.attach.vibration.VibrationService;
import com.gluonhq.attach.vibration.VibrationService;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.client.connection.Client;
import com.stream_pi.client.connection.Client;
import com.stream_pi.client.info.StartupFlags;
import com.stream_pi.client.info.StartupFlags;
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.profile.ClientProfiles;
import com.stream_pi.client.profile.ClientProfiles;
import com.stream_pi.client.window.Base;
import com.stream_pi.client.window.Base;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener;
import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlert;
import com.stream_pi.util.alert.StreamPiAlertListener;
import com.stream_pi.util.alert.StreamPiAlertListener;
import com.stream_pi.util.alert.StreamPiAlertType;
import com.stream_pi.util.alert.StreamPiAlertType;
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.gluonhq.attach.lifecycle.LifecycleService;
import com.gluonhq.attach.lifecycle.LifecycleService;
import com.gluonhq.attach.util.Services;
import com.gluonhq.attach.util.Services;
import com.stream_pi.util.iohelper.IOHelper;
import com.stream_pi.util.iohelper.IOHelper;
import com.stream_pi.util.platform.PlatformType;
import com.stream_pi.util.platform.PlatformType;
import com.stream_pi.util.startatboot.StartAtBoot;
import com.stream_pi.util.startatboot.StartAtBoot;
import javafx.animation.Interpolator;
import javafx.animation.Interpolator;
import javafx.animation.KeyFrame;
import javafx.animation.KeyFrame;
import javafx.animation.KeyValue;
import javafx.animation.KeyValue;
import javafx.animation.Timeline;
import javafx.animation.Timeline;
import javafx.application.Platform;
import javafx.application.Platform;
import javafx.beans.InvalidationListener;
import javafx.beans.InvalidationListener;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ChangeListener;
import javafx.beans.value.ObservableValue;
import javafx.geometry.Orientation;
import javafx.geometry.Orientation;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.input.KeyCombination;
import javafx.scene.input.KeyCombination;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.StackPane;
import javafx.stage.Screen;
import javafx.stage.Screen;
import javafx.util.Duration;
import javafx.util.Duration;
import java.io.*;
import java.io.*;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Executors;
import java.util.logging.Level;
import java.util.logging.Level;
public class Controller extends Base
public class Controller extends Base
{
{
private Client client;
private Client client;
public Controller()
public Controller()
{
{
client = null;
client = null;
}
}
private boolean firstRun = true;
private boolean firstRun = true;
private ScreenSaver screenSaver = null;
private ScreenSaver screenSaver = null;
@Override
@Override
public void init()
public void init()
{
{
try
try
{
{
if(firstRun)
if(firstRun)
initBase();
initBase();
if (screenSaver != null)
if (screenSaver != null)
{
{
screenSaver.stop();
screenSaver.stop();
getChildren().remove(screenSaver);
getChildren().remove(screenSaver);
}
}
screenSaver = new ScreenSaver(getConfig().isScreenSaverEnabled(), this, getConfig().getScreenSaverTimeout());
screenSaver = new ScreenSaver(getConfig().isScreenSaverEnabled(), this, getConfig().getScreenSaverTimeout());
getChildren().add(screenSaver);
getChildren().add(screenSaver);
screenSaver.toBack();
screenSaver.toBack();
if(getClientInfo().getPlatform() != com.stream_pi.util.platform.Platform.ANDROID)
if(getClientInfo().getPlatform() != com.stream_pi.util.platform.Platform.ANDROID)
{
{
if(getConfig().isStartOnBoot())
if(getConfig().isStartOnBoot())
{
{
if(StartupFlags.IS_X_MODE != getConfig().isStartupXMode())
if(StartupFlags.IS_X_MODE != getConfig().isStartupXMode())
{
{
StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform());
StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform());
boolean result = startAtBoot.delete();
boolean result = startAtBoot.delete();
if(!result)
if(!result)
new StreamPiAlert("Uh Oh!", "Unable to delete the previous starter file.\n" +
new StreamPiAlert("Uh Oh!", "Unable to delete the previous starter file.\n" +
"This was probably because you ran Stream-Pi as root before. Restart stream pi as root, " +
"This was probably because you ran Stream-Pi as root before. Restart stream pi as root, " +
"delete the old starter file, then exit and restart Stream-Pi as normal user.", StreamPiAlertType.ERROR).show();
"delete the old starter file, then exit and restart Stream-Pi as normal user.", StreamPiAlertType.ERROR).show();
else
else
{
{
if(StartupFlags.RUNNER_FILE_NAME == null)
if(StartupFlags.RUNNER_FILE_NAME == null)
{
{
new StreamPiAlert("Uh Oh!",
new StreamPiAlert("Uh Oh!",
"It looks like the runner file name for startup isn't specified in " +
"It looks like the runner file name for startup isn't specified in " +
"startup arguments. The start on boot functionality will be turned off.").show();
"startup arguments. The start on boot functionality will be turned off.").show();
getConfig().setStartOnBoot(false);
getConfig().setStartOnBoot(false);
}
}
else
else
{
{
startAtBoot.create(new File(StartupFlags.RUNNER_FILE_NAME),
startAtBoot.create(new File(StartupFlags.RUNNER_FILE_NAME),
StartupFlags.IS_X_MODE);
StartupFlags.IS_X_MODE);
getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE);
getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE);
}
}
}
}
}
}
}
}
setupFlags();
setupFlags();
if(!getConfig().getIsFullScreenMode())
if(!getConfig().getIsFullScreenMode())
{
{
getStage().setWidth(getConfig().getStartupWindowWidth());
getStage().setWidth(getConfig().getStartupWindowWidth());
getStage().setHeight(getConfig().getStartupWindowHeight());
getStage().setHeight(getConfig().getStartupWindowHeight());
}
}
}
}
applyDefaultTheme();
applyDefaultTheme();
setupDashWindow();
setupDashWindow();
getStage().show();
getStage().show();
requestFocus();
requestFocus();
if(Config.getInstance().isFirstTimeUse())
if(Config.getInstance().isFirstTimeUse())
return;
return;
setupSettingsWindowsAnimations();
setupSettingsWindowsAnimations();
getDashboardPane().getSettingsButton().setOnAction(event -> {
getDashboardPane().getSettingsButton().setOnAction(event -> {
openSettingsTimeLine.play();
openSettingsTimeLine.play();
});
});
getSettingsPane().getCloseButton().setOnAction(event -> {
getSettingsPane().getCloseButton().setOnAction(event -> {
closeSettingsTimeLine.play();
closeSettingsTimeLine.play();
});
});
setClientProfiles(new ClientProfiles(new File(getConfig().getProfilesPath()), getConfig().getStartupProfileID()));
setClientProfiles(new ClientProfiles(new File(getConfig().getProfilesPath()), getConfig().getStartupProfileID()));
if(getClientProfiles().getLoadingErrors().size() > 0)
if(getClientProfiles().getLoadingErrors().size() > 0)
{
{
StringBuilder errors = new StringBuilder("Please rectify the following errors and try again");
StringBuilder errors = new StringBuilder("Please rectify the following errors and try again");
for(MinorException exception : getClientProfiles().getLoadingErrors())
for(MinorException exception : getClientProfiles().getLoadingErrors())
{
{
errors.append("\n * ")
errors.append("\n * ")
.append(exception.getMessage());
.append(exception.getMessage());
}
}
throw new MinorException("Profiles", errors.toString());
throw new MinorException("Profiles", errors.toString());
}
}
renderRootDefaultProfile();
renderRootDefaultProfile();
loadSettings();
loadSettings();
if(firstRun)
if(firstRun)
{
{
if(getConfig().isConnectOnStartup())
if(getConfig().isConnectOnStartup())
{
{
setupClientConnection();
setupClientConnection();
}
}
firstRun = false;
firstRun = false;
}
}
if(!getClientInfo().isPhone())
if(!getClientInfo().isPhone())
{
{
getStage().widthProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer());
getStage().widthProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer());
getStage().heightProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer());
getStage().heightProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer());
}
}
if(getClientInfo().isPhone() && getConfig().isInvertRowsColsOnDeviceRotate())
{
OrientationService.create().ifPresent(orientationService -> {
if(orientationService.getOrientation().isPresent())
{
setCurrentOrientation(orientationService.getOrientation().get());
orientationService.orientationProperty().addListener((observableValue, oldOrientation, newOrientation) -> {
setCurrentOrientation(newOrientation);
getDashboardPane().renderProfile(
getCurrentProfile(),
getCurrentParent(),
true
);
});
}
});
}
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
handleMinorException(e);
handleMinorException(e);
}
}
}
}
private Orientation currentOrientation;
@Override
public Orientation getCurrentOrientation()
{
return currentOrientation;
}
private void setCurrentOrientation(Orientation currentOrientation)
{
this.currentOrientation = currentOrientation;
}
public void syncClientSizeDetailsWithServer()
public void syncClientSizeDetailsWithServer()
{
{
if(isConnected())
if(isConnected())
{
{
try {
try {
client.sendClientScreenDetails();
client.sendClientScreenDetails();
} catch (SevereException e) {
} catch (SevereException e) {
e.printStackTrace();
e.printStackTrace();
}
}
}
}
}
}
@Override
@Override
public void setupClientConnection()
public void setupClientConnection()
{
{
setupClientConnection(null);
setupClientConnection(null);
}
}
@Override
@Override
public void setupClientConnection(Runnable onConnect)
public void setupClientConnection(Runnable onConnect)
{
{
if(getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) //probably already connecting
if(getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) //probably already connecting
return;
return;
Platform.runLater(()->getSettingsPane().getGeneralTab().setDisableStatus(true));
Platform.runLater(()->getSettingsPane().getGeneralTab().setDisableStatus(true));
client = new Client(getConfig().getSavedServerHostNameOrIP(), getConfig().getSavedServerPort(), this, this, onConnect);
client = new Client(getConfig().getSavedServerHostNameOrIP(), getConfig().getSavedServerPort(), this, this, onConnect);
}
}
@Override
@Override
public void updateSettingsConnectDisconnectButton() {
public void updateSettingsConnectDisconnectButton() {
getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus();
getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus();
}
}
@Override
@Override
public void disconnect(String message) throws SevereException {
public void disconnect(String message) throws SevereException {
client.disconnect(message);
client.disconnect(message);
}
}
public void setupDashWindow()
public void setupDashWindow()
{
{
getStage().setTitle("Stream-Pi Client");
getStage().setTitle("Stream-Pi Client");
getStage().setOnCloseRequest(e->{
getStage().setOnCloseRequest(e->{
onCloseRequest();
onCloseRequest();
exitApp();
exitApp();
});
});
}
}
@Override
@Override
public void onCloseRequest()
public void onCloseRequest()
{
{
try
try
{
{
if(isConnected())
if(isConnected())
client.exit();
client.exit();
screenSaver.stop();
screenSaver.stop();
if(!getClientInfo().isPhone() && !getConfig().getIsFullScreenMode())
if(!getClientInfo().isPhone() && !getConfig().getIsFullScreenMode())
{
{
getConfig().setStartupWindowSize(getStageWidth(), getStageHeight());
getConfig().setStartupWindowSize(getStageWidth(), getStageHeight());
getConfig().save();
getConfig().save();
}
}
}
}
catch (SevereException e)
catch (SevereException e)
{
{
handleSevereException(e);
handleSevereException(e);
}
}
finally
finally
{
{
getLogger().info("Shut down");
getLogger().info("Shut down");
closeLogger();
closeLogger();
Config.nullify();
Config.nullify();
}
}
}
}
@Override
@Override
public void exitApp()
public void exitApp()
{
{
getExecutor().shutdown();
getExecutor().shutdown();
if (ClientInfo.getInstance().getPlatform() == com.stream_pi.util.platform.Platform.ANDROID)
if (ClientInfo.getInstance().getPlatform() == com.stream_pi.util.platform.Platform.ANDROID)
{
{
Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown);
Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown);
}
}
else
else
{
{
Platform.exit();
Platform.exit();
}
}
}
}
@Override
@Override
public void loadSettings() {
public void loadSettings() {
try {
try {
getSettingsPane().getGeneralTab().loadData();
getSettingsPane().getGeneralTab().loadData();
} catch (SevereException e) {
} catch (SevereException e) {
e.printStackTrace();
e.printStackTrace();
handleSevereException(e);
handleSevereException(e);
}
}
}
}
@Override
@Override
public Client getClient() {
public Client getClient() {
return client;
return client;
}
}
@Override
@Override
public void onDisconnect() {
public void onDisconnect() {
Platform.runLater(()->getDashboardPane().getActionGridPane().toggleOffAllToggleActions());
Platform.runLater(()->getDashboardPane().getActionGridPane().toggleOffAllToggleActions());
}
}
@Override
@Override
public boolean getToggleStatus(String profileID, String actionID)
public boolean getToggleStatus(String profileID, String actionID)
{
{
return getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus();
return getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus();
}
}
private Timeline openSettingsTimeLine;
private Timeline openSettingsTimeLine;
private Timeline closeSettingsTimeLine;
private Timeline closeSettingsTimeLine;
private void setupSettingsWindowsAnimations()
private void setupSettingsWindowsAnimations()
{
{
Node settingsNode = getSettingsPane();
Node settingsNode = getSettingsPane();
Node dashboardNode = getDashboardPane();
Node dashboardNode = getDashboardPane();
openSettingsTimeLine = new Timeline();
openSettingsTimeLine = new Timeline();
openSettingsTimeLine.setCycleCount(1);
openSettingsTimeLine.setCycleCount(1);
openSettingsTimeLine.getKeyFrames().addAll(
openSettingsTimeLine.getKeyFrames().addAll(
new KeyFrame(Duration.millis(0.0D),
new KeyFrame(Duration.millis(0.0D),
new KeyValue(settingsNode.opacityProperty(),
new KeyValue(settingsNode.opacityProperty(),
0.0D, Interpolator.EASE_IN)),
0.0D, Interpolator.EASE_IN)),
new KeyFrame(Duration.millis(90.0D),
new KeyFrame(Duration.millis(90.0D),
new KeyValue(settingsNode.opacityProperty(),
new KeyValue(settingsNode.opacityProperty(),
1.0D, Interpolator.LINEAR)),
1.0D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(0.0D),
new KeyFrame(Duration.millis(0.0D),
new KeyValue(dashboardNode.opacityProperty(),
new KeyValue(dashboardNode.opacityProperty(),
1.0D, Interpolator.LINEAR)),
1.0D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(90.0D),
new KeyFrame(Duration.millis(90.0D),
new KeyValue(dashboardNode.opacityProperty(),
new KeyValue(dashboardNode.opacityProperty(),
0.0D, Interpolator.LINEAR))
0.0D, Interpolator.LINEAR))
);
);
openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront());
openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront());
closeSettingsTimeLine = new Timeline();
closeSettingsTimeLine = new Timeline();
closeSettingsTimeLine.setCycleCount(1);
closeSettingsTimeLine.setCycleCount(1);
closeSettingsTimeLine.getKeyFrames().addAll(
closeSettingsTimeLine.getKeyFrames().addAll(
new KeyFrame(Duration.millis(0.0D),
new KeyFrame(Duration.millis(0.0D),
new KeyValue(settingsNode.opacityProperty(),
new KeyValue(settingsNode.opacityProperty(),
1.0D, Interpolator.LINEAR)),
1.0D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(90.0D),
new KeyFrame(Duration.millis(90.0D),
new KeyValue(settingsNode.opacityProperty(),
new KeyValue(settingsNode.opacityProperty(),
0.0D, Interpolator.LINEAR)),
0.0D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(0.0D),
new KeyFrame(Duration.millis(0.0D),
new KeyValue(dashboardNode.opacityProperty(),
new KeyValue(dashboardNode.opacityProperty(),
0.0D, Interpolator.LINEAR)),
0.0D, Interpolator.LINEAR)),
new KeyFrame(Duration.millis(90.0D),
new KeyFrame(Duration.millis(90.0D),
new KeyValue(dashboardNode.opacityProperty(),
new KeyValue(dashboardNode.opacityProperty(),
1.0D, Interpolator.LINEAR))
1.0D, Interpolator.LINEAR))
);
);
closeSettingsTimeLine.setOnFinished(event1 -> {
closeSettingsTimeLine.setOnFinished(event1 -> {
dashboardNode.toFront();
dashboardNode.toFront();
Platform.runLater(()-> {
Platform.runLater(()-> {
try {
try {
getSettingsPane().getGeneralTab().loadData();
getSettingsPane().getGeneralTab().loadData();
} catch (SevereException e) {
} catch (SevereException e) {
e.printStackTrace();
e.printStackTrace();
handleSevereException(e);
handleSevereException(e);
}
}
});
});
});
});
}
}
@Override
@Override
public void handleMinorException(MinorException e)
public void handleMinorException(MinorException e)
{
{
getLogger().log(Level.SEVERE, e.getMessage(), e);
getLogger().log(Level.SEVERE, e.getMessage(), e);
e.printStackTrace();
e.printStackTrace();
Platform.runLater(()-> genNewAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.WARNING).show());
Platform.runLater(()-> genNewAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.WARNING).show());
}
}
@Override
@Override
public void handleSevereException(SevereException e)
public void handleSevereException(SevereException e)
{
{
getLogger().log(Level.SEVERE, e.getMessage(), e);
getLogger().log(Level.SEVERE, e.getMessage(), e);
e.printStackTrace();
e.printStackTrace();
Platform.runLater(()->
Platform.runLater(()->
{
{
StreamPiAlert alert = genNewAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.ERROR);
StreamPiAlert alert = genNewAlert(e.getTitle(), e.getShortMessage(), StreamPiAlertType.ERROR);
alert.setOnClicked(new StreamPiAlertListener()
alert.setOnClicked(new StreamPiAlertListener()
{
{
@Override
@Override
public void onClick(String txt)
public void onClick(String txt)
{
{
onCloseRequest();
onCloseRequest();
exitApp();
exitApp();
}
}
});
});
alert.show();
alert.show();
});
});
}
}
@Override
@Override
public void onAlert(String title, String body, StreamPiAlertType alertType) {
public void onAlert(String title, String body, StreamPiAlertType alertType) {
Platform.runLater(()-> genNewAlert(title, body, alertType).show());
Platform.runLater(()-> genNewAlert(title, body, alertType).show());
}
}
public StreamPiAlert genNewAlert(String title, String message, StreamPiAlertType alertType)
public StreamPiAlert genNewAlert(String title, String message, StreamPiAlertType alertType)
{
{
return new StreamPiAlert(title, message, alertType);
return new StreamPiAlert(title, message, alertType);
}
}
private boolean isConnected = false;
private boolean isConnected = false;
@Override
@Override
public void onActionFailed(String profileID, String actionID) {
public void onActionFailed(String profileID, String actionID) {
Platform.runLater(()-> getDashboardPane().getActionGridPane().actionFailed(profileID, actionID));
Platform.runLater(()-> getDashboardPane().getActionGridPane().actionFailed(profileID, actionID));
}
}
@Override
@Override
public void onActionClicked(String profileID, String actionID, boolean toggleState)
public void onActionClicked(String profileID, String actionID, boolean toggleState)
{
{
try {
try {
vibratePhone();
vibratePhone();
client.onActionClicked(profileID, actionID, toggleState);
client.onActionClicked(profileID, actionID, toggleState);
} catch (SevereException e) {
} catch (SevereException e) {
e.printStackTrace();
e.printStackTrace();
handleSevereException(e);
handleSevereException(e);
}
}
}
}
public void vibratePhone()
public void vibratePhone()
{
{
if(getConfig().isVibrateOnActionClicked())
if(getConfig().isVibrateOnActionClicked())
{
{
VibrationService.create().ifPresent(VibrationService::vibrate);
VibrationService.create().ifPresent(VibrationService::vibrate);
}
}
}
}
@Override
@Override
public void setConnected(boolean isConnected) {
public void setConnected(boolean isConnected) {
this.isConnected = isConnected;
this.isConnected = isConnected;
}
}
@Override
@Override
public ActionBox getActionBox(int col, int row)
public ActionBox getActionBox(int col, int row)
{
{
return getDashboardPane().getActionGridPane().getActionBox(col, row);
return getDashboardPane().getActionGridPane().getActionBox(col, row);
}
}
@Override
@Override
public boolean isConnected()
public boolean isConnected()
{
{
return isConnected;
return isConnected;
}
}
@Override
@Override
public void renderProfile(ClientProfile clientProfile, boolean freshRender)
public void renderProfile(ClientProfile clientProfile, boolean freshRender)
{
{
getDashboardPane().renderProfile(clientProfile, freshRender);
getDashboardPane().renderProfile(clientProfile, freshRender);
}
}
@Override
@Override
public void clearActionBox(int col, int row)
public void clearActionBox(int col, int row)
{
{
Platform.runLater(()->getDashboardPane().getActionGridPane().clearActionBox(col, row));
Platform.runLater(()->getDashboardPane().getActionGridPane().clearActionBox(col, row));
}
}
@Override
@Override
public void addBlankActionBox(int col, int row)
public void addBlankActionBox(int col, int row)
{
{
Platform.runLater(()->getDashboardPane().getActionGridPane().addBlankActionBox(col, row));
Platform.runLater(()->getDashboardPane().getActionGridPane().addBlankActionBox(col, row));
}
}
@Override
@Override
public void renderAction(String currentProfileID, Action action)
public void renderAction(String currentProfileID, Action action)
{
{
Platform.runLater(()->{
Platform.runLater(()->{
try {
try {
if(getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) &&
if(getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) &&
getCurrentProfile().getID().equals(currentProfileID))
getCurrentProfile().getID().equals(currentProfileID))
{
{
getDashboardPane().getActionGridPane().renderAction(action);
getDashboardPane().getActionGridPane().renderAction(action);
}
}
}
}
catch (Exception e)
catch (Exception e)
{
{
e.printStackTrace();
e.printStackTrace();
}
}
});
});
}
}
@Override
@Override
public void refreshGridIfCurrentProfile(String profileID) {
public void refreshGridIfCurrentProfile(String profileID) {
if(getCurrentProfile().getID().equals(profileID))
if(getCurrentProfile().getID().equals(profileID))
{
{
Platform.runLater(()-> getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(profileID), true));
Platform.runLater(()-> getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(profileID), true));
}
}
}
}
@Override
@Override
public ClientProfile getCurrentProfile() {
public ClientProfile getCurrentProfile() {
return getDashboardPane().getActionGridPane().getClientProfile();
return getDashboardPane().getActionGridPane().getClientProfile();
}
}
@Override
@Override
public String getCurrentParent()
public String getCurrentParent()
{
{
return getDashboardPane().getActionGridPane().getCurrentParent();
return getDashboardPane().getActionGridPane().getCurrentParent();
}
}
@Override
@Override
public ActionBox getActionBoxByProfileAndID(String profileID, String actionID)
public ActionBox getActionBoxByProfileAndID(String profileID, String actionID)
{
{
Action action = getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID);
Action action = getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID);
if(!getCurrentProfile().getID().equals(profileID) && !getCurrentParent().equals(action.getParent()))
if(!getCurrentProfile().getID().equals(profileID) && !getCurrentParent().equals(action.getParent()))
return null;
return null;
return getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation());
return getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation());
}
}
@Override
@Override
public void openURL(String url)
public void openURL(String url)
{
{
if(ClientInfo.getInstance().isPhone())
if(ClientInfo.getInstance().isPhone())
{
{
BrowserService.create().ifPresentOrElse(s->
BrowserService.create().ifPresentOrElse(s->
{
{
try
try
{
{
s.launchExternalBrowser(url);
s.launchExternalBrowser(url);
}
}
catch (Exception e )
catch (Exception e )
{
{
handleMinorException(
handleMinorException(
new MinorException("Cant start browser! You can go to Server Settings > About > Contact " +
new MinorException("Cant start browser! You can go to Server Settings > About > Contact " +
"and open the links from there.")
"and open the links from there.")
);
);
}
}
},()-> handleMinorException(
},()-> handleMinorException(
new MinorException("Sorry!","No browser detected. You can go to Server Settings > About > Contact " +
new MinorException("Sorry!","No browser detected. You can go to Server Settings > About > Contact " +
"and open the links from there.")
"and open the links from there.")
));
));
}
}
else
else
{
{
if(getClientInfo().getPlatform() == com.stream_pi.util.platform.Platform.LINUX &&
if(getClientInfo().getPlatform() == com.stream_pi.util.platform.Platform.LINUX &&
!StartupFlags.IS_X_MODE)
!StartupFlags.IS_X_MODE)
{
{
handleMinorException(new MinorException("Sorry!","Your system is running directly on framebuffer and " +
handleMinorException(new MinorException("Sorry!","Your system is running directly on framebuffer and " +
"does not support opening a browser. You can go to Server Settings > About > Contact " +
"does not support opening a browser. You can go to Server Settings > About > Contact " +
"and open the links from there."));
"and open the links from there."));
}
}
else
else
{
{
getHostServices().showDocument(url);
getHostServices().showDocument(url);
}
}
}
}
}
}
@Override
@Override
public void factoryReset()
public void factoryReset()
{
{
getLogger().info("Reset to factory ...");
getLogger().info("Reset to factory ...");
onCloseRequest();
onCloseRequest();
boolean result = IOHelper.deleteFile(getClientInfo().getPrePath());
boolean result = IOHelper.deleteFile(getClientInfo().getPrePath());
if(result)
if(result)
{
{
setFirstRun(true);
setFirstRun(true);
init();
init();
}
}
else
else
{
{
handleSevereException(new SevereException("Unable to delete all files successfully. Installation corrupt. Re-install."));
handleSevereException(new SevereException("Unable to delete all files successfully. Installation corrupt. Re-install."));
}
}
}
}
public void setFirstRun(boolean firstRun)
public void setFirstRun(boolean firstRun)
{
{
this.firstRun = firstRun;
this.firstRun = firstRun;
}
}
}
}
/*
/*
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 java.util.Objects;
import java.util.Objects;
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.Main;
import com.stream_pi.client.Main;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.StartupFlags;
import com.stream_pi.client.info.StartupFlags;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.exception.SevereException;
import com.stream_pi.util.iohelper.IOHelper;
import com.stream_pi.util.iohelper.IOHelper;
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 static void nullify()
public static void nullify()
{
{
instance = null;
instance = null;
}
}
public static void unzipToDefaultPrePath() throws Exception
public static void unzipToDefaultPrePath() throws Exception
{
{
IOHelper.unzip(Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath());
IOHelper.unzip(Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath());
Config.getInstance().setThemesPath(ClientInfo.getInstance().getPrePath()+"Themes/");
Config.getInstance().setThemesPath(ClientInfo.getInstance().getPrePath()+"Themes/");
Config.getInstance().setIconsPath(ClientInfo.getInstance().getPrePath()+"Icons/");
Config.getInstance().setIconsPath(ClientInfo.getInstance().getPrePath()+"Icons/");
Config.getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath()+"Profiles/");
Config.getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath()+"Profiles/");
Config.getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE);
Config.getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE);
Config.getInstance().save();
Config.getInstance().save();
}
}
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/";
}
}
//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 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 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+"");
}
}
private Element getStartupWindowSizeElement()
private Element getStartupWindowSizeElement()
{
{
return (Element) getClientElement().getElementsByTagName("startup-window-size").item(0);
return (Element) getClientElement().getElementsByTagName("startup-window-size").item(0);
}
}
public double getStartupWindowWidth()
public double getStartupWindowWidth()
{
{
return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width",
return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width",
getDefaultStartupWindowWidth(), false, true, document, configFile);
getDefaultStartupWindowWidth(), false, true, document, configFile);
}
}
public double getStartupWindowHeight()
public double getStartupWindowHeight()
{
{
return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height",
return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height",
getDefaultStartupWindowHeight(), false, true, document, configFile);
getDefaultStartupWindowHeight(), false, true, document, configFile);
}
}
public int getDefaultStartupWindowWidth()
public int getDefaultStartupWindowWidth()
{
{
return 800;
return 800;
}
}
public int getDefaultStartupWindowHeight()
public int getDefaultStartupWindowHeight()
{
{
return 400;
return 400;
}
}
public void setStartupWindowSize(double width, double height)
public void setStartupWindowSize(double width, double height)
{
{
setStartupWindowWidth(width);
setStartupWindowWidth(width);
setStartupWindowHeight(height);
setStartupWindowHeight(height);
}
}
public void setStartupWindowWidth(double width)
public void setStartupWindowWidth(double width)
{
{
getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+"");
getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+"");
}
}
public void setStartupWindowHeight(double height)
public void setStartupWindowHeight(double height)
{
{
getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+"");
getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+"");
}
}
public void setStartupIsXMode(boolean value)
public void setStartupIsXMode(boolean value)
{
{
getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(value+"");
}
}
public boolean getDefaultIsStartupXMode()
public boolean getDefaultIsStartupXMode()
{
{
return false;
return false;
}
}
public boolean isStartupXMode()
public boolean isStartupXMode()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot-x-mode", getDefaultIsStartupXMode(), false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot-x-mode", getDefaultIsStartupXMode(), false, true, document, configFile);
}
}
public boolean getDefaultIsTryConnectingWhenActionClicked()
public boolean getDefaultIsTryConnectingWhenActionClicked()
{
{
return false;
return false;
}
}
public boolean isTryConnectingWhenActionClicked()
public boolean isTryConnectingWhenActionClicked()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "try-connecting-when-action-clicked", getDefaultIsTryConnectingWhenActionClicked(), false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "try-connecting-when-action-clicked", getDefaultIsTryConnectingWhenActionClicked(), false, true, document, configFile);
}
}
public void setTryConnectingWhenActionClicked(boolean value)
public void setTryConnectingWhenActionClicked(boolean value)
{
{
getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(value+"");
}
}
public boolean getDefaultScreenSaverEnabled()
public boolean getDefaultScreenSaverEnabled()
{
{
return false;
return false;
}
}
public boolean isScreenSaverEnabled()
public boolean isScreenSaverEnabled()
{
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "screen-saver", getDefaultScreenSaverEnabled(), false, true, document, configFile);
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "screen-saver", getDefaultScreenSaverEnabled(), false, true, document, configFile);
}
}
public void setScreenSaverEnabled(boolean value)
public void setScreenSaverEnabled(boolean value)
{
{
getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(value+"");
getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(value+"");
}
}
public int getDefaultScreenSaverTimeout()
public int getDefaultScreenSaverTimeout()
{
{
return 60;
return 60;
}
}
public int getScreenSaverTimeout()
public int getScreenSaverTimeout()
{
{
return XMLConfigHelper.getIntProperty(getOthersElement(), "screen-saver-timeout-seconds", getDefaultScreenSaverTimeout(), false, true, document, configFile);
return XMLConfigHelper.getIntProperty(getOthersElement(), "screen-saver-timeout-seconds", getDefaultScreenSaverTimeout(), false, true, document, configFile);
}
}
public void setScreenSaverTimeout(String value)
public void setScreenSaverTimeout(String value)
{
{
getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value);
getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value);
}
}
public boolean getDefaultInvertRowsColsOnDeviceRotate()
{
return true;
}
public boolean isInvertRowsColsOnDeviceRotate()
{
return XMLConfigHelper.getBooleanProperty(getOthersElement(), "invert-rows-cols-on-device-rotate", getDefaultInvertRowsColsOnDeviceRotate(), false, true, document, configFile);
}
public void setInvertRowsColsOnDeviceRotate(boolean value)
{
getOthersElement().getElementsByTagName("invert-rows-cols-on-device-rotate").item(0).setTextContent(value+"");
}
}
}
package com.stream_pi.client.window.dashboard.actiongridpane;
package com.stream_pi.client.window.dashboard.actiongridpane;
import java.util.logging.Logger;
import java.util.logging.Logger;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.Action;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.ActionType;
import com.stream_pi.action_api.action.Location;
import com.stream_pi.action_api.action.Location;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.StartupFlags;
import com.stream_pi.client.io.Config;
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.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 javafx.concurrent.Task;
import javafx.concurrent.Task;
import javafx.geometry.Insets;
import javafx.geometry.Insets;
import javafx.geometry.Orientation;
import javafx.geometry.Pos;
import javafx.geometry.Pos;
import javafx.scene.CacheHint;
import javafx.scene.CacheHint;
import javafx.scene.Node;
import javafx.scene.Node;
import javafx.scene.control.ScrollPane;
import javafx.scene.control.ScrollPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.GridPane;
import javafx.scene.layout.Priority;
import javafx.scene.layout.Priority;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.StackPane;
import javafx.scene.layout.VBox;
import javafx.scene.layout.VBox;
import org.kordamp.ikonli.javafx.FontIcon;
import org.kordamp.ikonli.javafx.FontIcon;
public class ActionGridPane extends ScrollPane implements ActionGridPaneListener
public class ActionGridPane extends ScrollPane implements ActionGridPaneListener
{
{
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ClientListener clientListener;
private ClientListener clientListener;
private ActionBox[][] actionBoxes;
private ActionBox[][] actionBoxes;
private GridPane actionsGridPane;
private GridPane actionsGridPane;
public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener)
public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener)
{
{
this.clientListener = clientListener;
this.clientListener = clientListener;
logger = Logger.getLogger(ActionGridPane.class.getName());
logger = Logger.getLogger(ActionGridPane.class.getName());
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
getStyleClass().add("action_grid_pane_parent");
getStyleClass().add("action_grid_pane_parent");
actionsGridPane = new GridPane();
actionsGridPane = new GridPane();
actionsGridPane.setPadding(new Insets(5.0));
actionsGridPane.setPadding(new Insets(5.0));
actionsGridPane.getStyleClass().add("action_grid_pane");
actionsGridPane.getStyleClass().add("action_grid_pane");
actionsGridPane.prefWidthProperty().bind(widthProperty().subtract(20));
actionsGridPane.prefWidthProperty().bind(widthProperty().subtract(20));
actionsGridPane.prefHeightProperty().bind(heightProperty().subtract(20));
actionsGridPane.prefHeightProperty().bind(heightProperty().subtract(20));
setContent(actionsGridPane);
setContent(actionsGridPane);
actionsGridPane.setAlignment(Pos.CENTER);
actionsGridPane.setAlignment(Pos.CENTER);
VBox.setVgrow(this, Priority.ALWAYS);
VBox.setVgrow(this, Priority.ALWAYS);
setCache(true);
setCache(true);
setCacheHint(CacheHint.SPEED);
setCacheHint(CacheHint.SPEED);
}
}
private String currentParent;
private String currentParent;
public void setCurrentParent(String currentParent) {
public void setCurrentParent(String currentParent) {
this.currentParent = currentParent;
this.currentParent = currentParent;
}
}
public ClientProfile getClientProfile() {
public ClientProfile getClientProfile() {
return clientProfile;
return clientProfile;
}
}
private int rows, cols;
private int rows, cols;
private ClientProfile clientProfile;
private ClientProfile clientProfile;
public void setClientProfile(ClientProfile clientProfile)
public void setClientProfile(ClientProfile clientProfile)
{
{
this.clientProfile = clientProfile;
this.clientProfile = clientProfile;
setCurrentParent("root");
setCurrentParent("root");
setRows(clientProfile.getRows());
setRows(clientProfile.getRows());
setCols(clientProfile.getCols());
setCols(clientProfile.getCols());
}
}
public void actionFailed(String profileID, String actionID)
public void actionFailed(String profileID, String actionID)
{
{
if(getClientProfile().getID().equals(profileID))
if(getClientProfile().getID().equals(profileID))
{
{
Action action = getClientProfile().getActionFromID(actionID);
Action action = getClientProfile().getActionFromID(actionID);
if(action != null)
if(action != null)
{
{
if(currentParent.equals(action.getParent()))
if(currentParent.equals(action.getParent()))
{
{
failShow(action);
failShow(action);
}
}
else
else
{
{
if(action.getLocation().getCol() == -1)
if(action.getLocation().getCol() == -1)
{
{
failShow(getClientProfile().getActionFromID(action.getParent()));
failShow(getClientProfile().getActionFromID(action.getParent()));
}
}
}
}
}
}
}
}
}
}
public void failShow(Action action)
public void failShow(Action action)
{
{
actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus();
actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus();
}
}
public String getCurrentParent() {
public String getCurrentParent() {
return currentParent;
return currentParent;
}
}
public StackPane getFolderBackButton()
public StackPane getFolderBackButton()
{
{
StackPane stackPane = new StackPane();
StackPane stackPane = new StackPane();
stackPane.getStyleClass().add("action_box");
stackPane.getStyleClass().add("action_box");
stackPane.getStyleClass().add("action_box_valid");
stackPane.getStyleClass().add("action_box_valid");
stackPane.setPrefSize(
stackPane.setPrefSize(
getClientProfile().getActionSize(),
getClientProfile().getActionSize(),
getClientProfile().getActionSize()
getClientProfile().getActionSize()
);
);
FontIcon fontIcon = new FontIcon("fas-chevron-left");
FontIcon fontIcon = new FontIcon("fas-chevron-left");
fontIcon.getStyleClass().add("folder_action_back_button_icon");
fontIcon.getStyleClass().add("folder_action_back_button_icon");
fontIcon.setIconSize(getClientProfile().getActionSize() - 30);
fontIcon.setIconSize(getClientProfile().getActionSize() - 30);
stackPane.setAlignment(Pos.CENTER);
stackPane.setAlignment(Pos.CENTER);
stackPane.getChildren().add(fontIcon);
stackPane.getChildren().add(fontIcon);
stackPane.setOnMouseClicked(e->returnToPreviousParent());
stackPane.setOnMouseClicked(e->returnToPreviousParent());
return stackPane;
return stackPane;
}
}
private boolean isFreshRender = true;
private boolean isFreshRender = true;
private Node folderBackButton = null;
private Node folderBackButton = null;
public void renderGrid()
public void renderGrid()
{
{
actionsGridPane.setHgap(getClientProfile().getActionGap());
actionsGridPane.setHgap(getClientProfile().getActionGap());
actionsGridPane.setVgap(getClientProfile().getActionGap());
actionsGridPane.setVgap(getClientProfile().getActionGap());
if(isFreshRender)
if(isFreshRender)
{
{
clear();
clear();
actionBoxes = new ActionBox[cols][rows];
actionBoxes = new ActionBox[cols][rows];
}
}
boolean isFolder = false;
boolean isFolder = false;
if(getCurrentParent().equals("root"))
if(getCurrentParent().equals("root"))
{
{
if(folderBackButton != null)
if(folderBackButton != null)
{
{
actionsGridPane.getChildren().remove(folderBackButton);
actionsGridPane.getChildren().remove(folderBackButton);
folderBackButton = null;
folderBackButton = null;
actionBoxes[0][0] = addBlankActionBox(0,0);
actionBoxes[0][0] = addBlankActionBox(0,0);
}
}
}
}
else
else
{
{
isFolder = true;
isFolder = true;
if(folderBackButton != null)
if(folderBackButton != null)
{
{
actionsGridPane.getChildren().remove(folderBackButton);
actionsGridPane.getChildren().remove(folderBackButton);
folderBackButton = null;
folderBackButton = null;
}
}
else
else
{
{
actionsGridPane.getChildren().remove(actionBoxes[0][0]);
actionsGridPane.getChildren().remove(actionBoxes[0][0]);
}
}
folderBackButton = getFolderBackButton();
folderBackButton = getFolderBackButton();
actionsGridPane.add(folderBackButton, 0,0);
actionsGridPane.add(folderBackButton, 0,0);
}
}
for(int row = 0; row<rows; row++)
for(int row = 0; row<rows; row++)
{
{
for(int col = 0; col<cols; col++)
for(int col = 0; col<cols; col++)
{
{
if(row == 0 && col == 0 && isFolder)
if(row == 0 && col == 0 && isFolder)
continue;
continue;
if(isFreshRender)
if(isFreshRender)
{
{
actionBoxes[col][row] = addBlankActionBox(col, row);
actionBoxes[col][row] = addBlankActionBox(col, row);
}
}
else
else
{
{
if(actionBoxes[col][row].getAction() != null)
if(actionBoxes[col][row].getAction() != null)
{
{
actionBoxes[col][row].clear();
actionBoxes[col][row].clear();
}
}
}
}
}
}
}
}
isFreshRender = false;
isFreshRender = false;
}
}
public void setFreshRender(boolean isFreshRender) {
public void setFreshRender(boolean isFreshRender) {
this.isFreshRender = isFreshRender;
this.isFreshRender = isFreshRender;
}
}
public void renderActions()
public void renderActions()
{
{
StringBuilder errors = new StringBuilder();
StringBuilder errors = new StringBuilder();
for(Action eachAction : getClientProfile().getActions())
for(Action eachAction : getClientProfile().getActions())
{
{
logger.info("Action ID : "+eachAction.getID()+"\nInvalid : "+eachAction.isInvalid());
logger.info("Action ID : "+eachAction.getID()+"\nInvalid : "+eachAction.isInvalid());
try {
try {
renderAction(eachAction);
renderAction(eachAction);
}
}
catch (SevereException e)
catch (SevereException e)
{
{
exceptionAndAlertHandler.handleSevereException(e);
exceptionAndAlertHandler.handleSevereException(e);
}
}
catch (MinorException e)
catch (MinorException e)
{
{
errors.append("*").append(e.getShortMessage()).append("\n");
errors.append("*").append(e.getShortMessage()).append("\n");
}
}
}
}
if(!errors.toString().isEmpty())
if(!errors.toString().isEmpty())
{
{
exceptionAndAlertHandler.handleMinorException(new MinorException("Error while rendering following actions", errors.toString()));
exceptionAndAlertHandler.handleMinorException(new MinorException("Error while rendering following actions", errors.toString()));
}
}
}
}
public void clear()
public void clear()
{
{
actionsGridPane.getChildren().clear();
actionsGridPane.getChildren().clear();
}
}
private Logger logger;
private Logger logger;
public void clearActionBox(int col, int row)
public void clearActionBox(int col, int row)
{
{
actionBoxes[col][row].clear();
actionBoxes[col][row].clear();
}
}
public ActionBox getActionBox(int col, int row)
public ActionBox getActionBox(int col, int row)
{
{
return actionBoxes[col][row];
return actionBoxes[col][row];
}
}
public ActionBox addBlankActionBox(int col, int row)
public ActionBox addBlankActionBox(int col, int row)
{
{
ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), exceptionAndAlertHandler, clientListener, this, row, col);
ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), exceptionAndAlertHandler, clientListener, this, row, col);
actionBox.setStreamPiParent(currentParent);
actionBox.setStreamPiParent(currentParent);
actionsGridPane.add(actionBox, col, row);
try
{
if(Config.getInstance().isInvertRowsColsOnDeviceRotate() && ClientInfo.getInstance().isPhone())
{
if(clientListener.getCurrentOrientation() == Orientation.HORIZONTAL)
{
actionsGridPane.add(actionBox, col, row);
}
else
{
actionsGridPane.add(actionBox, row, col);
}
}
else
{
actionsGridPane.add(actionBox, col, row);
}
}
catch (SevereException e)
{
exceptionAndAlertHandler.handleSevereException(e);
}
return actionBox;
return actionBox;
}
}
public void toggleOffAllToggleActions()
public void toggleOffAllToggleActions()
{
{
for(Node each : actionsGridPane.getChildren())
for(Node each : actionsGridPane.getChildren())
{
{
if(each instanceof ActionBox)
if(each instanceof ActionBox)
{
{
ActionBox eachActionBox = (ActionBox) each;
ActionBox eachActionBox = (ActionBox) each;
if(eachActionBox.getAction() != null)
if(eachActionBox.getAction() != null)
{
{
if(eachActionBox.getAction().getActionType() == ActionType.TOGGLE)
if(eachActionBox.getAction().getActionType() == ActionType.TOGGLE)
{
{
if(eachActionBox.getCurrentToggleStatus()) // ON
if(eachActionBox.getCurrentToggleStatus()) // ON
{
{
eachActionBox.toggle();
eachActionBox.toggle();
}
}
}
}
}
}
}
}
}
}
}
}
public void renderAction(Action action) throws SevereException, MinorException
public void renderAction(Action action) throws SevereException, MinorException
{
{
if(!action.getParent().equals(currentParent))
if(!action.getParent().equals(currentParent))
{
{
logger.info("Skipping action "+action.getID()+", not current parent!");
logger.info("Skipping action "+action.getID()+", not current parent!");
return;
return;
}
}
if(action.getLocation().getRow()==-1)
if(action.getLocation().getRow()==-1)
{
{
logger.info("Action has -1 rowIndex. Probably Combine Action. Skipping ...");
logger.info("Action has -1 rowIndex. Probably Combine Action. Skipping ...");
return;
return;
}
}
if(action.getLocation().getRow() > rows || action.getLocation().getCol() > cols)
if(action.getLocation().getRow() > rows || action.getLocation().getCol() > cols)
{
{
throw new MinorException("Action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" +
throw new MinorException("Action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" +
" Consider increasing rows/cols from client settings and relocating/deleting it.");
" Consider increasing rows/cols from client settings and relocating/deleting it.");
}
}
Location location = action.getLocation();
Location location = action.getLocation();
ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()];
ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()];
if(actionBox.getAction()!=null)
if(actionBox.getAction()!=null)
{
{
if(!actionBox.getAction().getID().equals(action.getID()))
if(!actionBox.getAction().getID().equals(action.getID()))
{
{
actionBox.clear();
actionBox.clear();
}
}
}
}
else
else
{
{
actionBox.clear();
actionBox.clear();
}
}
boolean oldToggleStatus = actionBox.getCurrentToggleStatus();
boolean oldToggleStatus = actionBox.getCurrentToggleStatus();
actionBox.setAction(action);
actionBox.setAction(action);
actionBox.setCurrentToggleStatus(oldToggleStatus);
actionBox.setCurrentToggleStatus(oldToggleStatus);
actionBox.setStreamPiParent(currentParent);
actionBox.setStreamPiParent(currentParent);
actionBox.init();
actionBox.init();
/*ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), action, exceptionAndAlertHandler, this, location.getRow(), location.getCol());
/*ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), action, exceptionAndAlertHandler, this, location.getRow(), location.getCol());
actionBox.setStreamPiParent(currentParent);
actionBox.setStreamPiParent(currentParent);
clearActionBox(location.getCol(), location.getRow());
clearActionBox(location.getCol(), location.getRow());
System.out.println(location.getCol()+","+location.getRow());
System.out.println(location.getCol()+","+location.getRow());
add(actionBox, location.getRow(), location.getCol());
add(actionBox, location.getRow(), location.getCol());
actionBoxes[location.getCol()][location.getRow()] = actionBox;*/
actionBoxes[location.getCol()][location.getRow()] = actionBox;*/
}
}
public void setRows(int rows)
public void setRows(int rows)
{
{
this.rows = rows;
this.rows = rows;
}
}
public void setCols(int cols)
public void setCols(int cols)
{
{
this.cols = cols;
this.cols = cols;
}
}
public int getRows()
public int getRows()
{
{
return rows;
return rows;
}
}
public int getCols()
public int getCols()
{
{
return cols;
return cols;
}
}
private String previousParent;
private String previousParent;
public void setPreviousParent(String previousParent) {
public void setPreviousParent(String previousParent) {
this.previousParent = previousParent;
this.previousParent = previousParent;
}
}
public String getPreviousParent() {
public String getPreviousParent() {
return previousParent;
return previousParent;
}
}
@Override
@Override
public void renderFolder(String actionID) {
public void renderFolder(String actionID) {
setCurrentParent(clientProfile.getActionFromID(actionID).getID());
setCurrentParent(clientProfile.getActionFromID(actionID).getID());
setPreviousParent(clientProfile.getActionFromID(actionID).getParent());
setPreviousParent(clientProfile.getActionFromID(actionID).getParent());
renderGrid();
renderGrid();
renderActions();
renderActions();
}
}
@Override
@Override
public void normalActionClicked(String ID)
public void normalActionClicked(String ID)
{
{
clientListener.onActionClicked(getClientProfile().getID(), ID, false);
clientListener.onActionClicked(getClientProfile().getID(), ID, false);
}
}
@Override
@Override
public void toggleActionClicked(String ID, boolean toggleState)
public void toggleActionClicked(String ID, boolean toggleState)
{
{
clientListener.onActionClicked(getClientProfile().getID(), ID, toggleState);
clientListener.onActionClicked(getClientProfile().getID(), ID, toggleState);
}
}
@Override
@Override
public ActionBox getActionBoxByLocation(Location location)
public ActionBox getActionBoxByLocation(Location location)
{
{
return getActionBox(location.getCol(), location.getRow());
return getActionBox(location.getCol(), location.getRow());
}
}
@Override
@Override
public boolean isConnected()
public boolean isConnected()
{
{
return clientListener.isConnected();
return clientListener.isConnected();
}
}
@Override
@Override
public void combineActionClicked(String ID) {
public void combineActionClicked(String ID) {
if(clientListener.isConnected())
if(clientListener.isConnected())
{
{
new Thread(new Task<Void>() {
new Thread(new Task<Void>() {
@Override
@Override
protected Void call()
protected Void call()
{
{
Action action = getClientProfile().getActionFromID(ID);
Action action = getClientProfile().getActionFromID(ID);
for(int i = 0;i<action.getClientProperties().get().size();i++)
for(int i = 0;i<action.getClientProperties().get().size();i++)
{
{
try {
try {
logger.info("Clicking "+i+", '"+action.getClientProperties().getSingleProperty(i+"").getRawValue()+"'");
logger.info("Clicking "+i+", '"+action.getClientProperties().getSingleProperty(i+"").getRawValue()+"'");
normalActionClicked(action.getClientProperties().getSingleProperty(i+"").getRawValue());
normalActionClicked(action.getClientProperties().getSingleProperty(i+"").getRawValue());
} catch (MinorException e) {
} catch (MinorException e) {
e.printStackTrace();
e.printStackTrace();
exceptionAndAlertHandler.handleMinorException(e);
exceptionAndAlertHandler.handleMinorException(e);
}
}
}
}
return null;
return null;
}
}
}).start();
}).start();
}
}
}
}
public void returnToPreviousParent()
public void returnToPreviousParent()
{
{
setCurrentParent(getPreviousParent());
setCurrentParent(getPreviousParent());
if(!getPreviousParent().equals("root"))
if(!getPreviousParent().equals("root"))
{
{
System.out.println("parent : "+getPreviousParent());
System.out.println("parent : "+getPreviousParent());
setPreviousParent(getClientProfile().getActionFromID(
setPreviousParent(getClientProfile().getActionFromID(
getPreviousParent()
getPreviousParent()
).getParent());
).getParent());
}
}
renderGrid();
renderGrid();
renderActions();
renderActions();
}
}
}
}
package com.stream_pi.client.window.settings;
package com.stream_pi.client.window.settings;
import com.gluonhq.attach.vibration.VibrationService;
import com.gluonhq.attach.vibration.VibrationService;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.controller.ClientListener;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.ClientInfo;
import com.stream_pi.client.info.StartupFlags;
import com.stream_pi.client.info.StartupFlags;
import com.stream_pi.client.io.Config;
import com.stream_pi.client.io.Config;
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.StreamPiAlertListener;
import com.stream_pi.util.alert.StreamPiAlertListener;
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.startatboot.StartAtBoot;
import com.stream_pi.util.startatboot.StartAtBoot;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.HBoxInputBox;
import com.stream_pi.util.uihelper.HBoxWithSpaceBetween;
import com.stream_pi.util.uihelper.HBoxWithSpaceBetween;
import com.stream_pi.util.uihelper.SpaceFiller;
import com.stream_pi.util.uihelper.SpaceFiller;
import javafx.application.HostServices;
import javafx.application.HostServices;
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;
import org.controlsfx.control.ToggleSwitch;
import org.controlsfx.control.ToggleSwitch;
import java.io.File;
import java.io.File;
import java.util.logging.Logger;
import java.util.logging.Logger;
public class GeneralTab extends VBox
public class GeneralTab extends VBox
{
{
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ExceptionAndAlertHandler exceptionAndAlertHandler;
private ClientListener clientListener;
private ClientListener clientListener;
private HostServices hostServices;
private HostServices hostServices;
private TextField serverPortTextField;
private TextField serverPortTextField;
private TextField serverHostNameOrIPTextField;
private TextField serverHostNameOrIPTextField;
private TextField screenTimeoutTextField;
private TextField screenTimeoutTextField;
private StreamPiComboBox<ClientProfile> clientProfileComboBox;
private StreamPiComboBox<ClientProfile> clientProfileComboBox;
private StreamPiComboBox<Theme> themeComboBox;
private StreamPiComboBox<Theme> themeComboBox;
private TextField nickNameTextField;
private TextField nickNameTextField;
private Button saveButton;
private Button saveButton;
private Button connectDisconnectButton;
private Button connectDisconnectButton;
private Button shutdownButton;
private Button shutdownButton;
private HBoxWithSpaceBetween startOnBootHBox;
private HBoxWithSpaceBetween startOnBootHBox;
private ToggleSwitch startOnBootToggleSwitch;
private ToggleSwitch startOnBootToggleSwitch;
private HBoxWithSpaceBetween screenSaverHBox;
private HBoxWithSpaceBetween screenSaverHBox;
private ToggleSwitch screenSaverToggleSwitch;
private ToggleSwitch screenSaverToggleSwitch;
private HBoxWithSpaceBetween tryConnectingToServerIfActionClickedHBox;
private HBoxWithSpaceBetween tryConnectingToServerIfActionClickedHBox;
private ToggleSwitch tryConnectingToServerIfActionClickedToggleSwitch;
private ToggleSwitch tryConnectingToServerIfActionClickedToggleSwitch;
private HBoxWithSpaceBetween connectOnStartupHBox;
private HBoxWithSpaceBetween connectOnStartupHBox;
private ToggleSwitch connectOnStartupToggleSwitch;
private ToggleSwitch connectOnStartupToggleSwitch;
private HBoxWithSpaceBetween vibrateOnActionPressHBox;
private HBoxWithSpaceBetween vibrateOnActionPressHBox;
private ToggleSwitch vibrateOnActionPressToggleSwitch;
private ToggleSwitch vibrateOnActionPressToggleSwitch;
private HBoxWithSpaceBetween fullScreenModeHBox;
private HBoxWithSpaceBetween fullScreenModeHBox;
private ToggleSwitch fullScreenModeToggleSwitch;
private ToggleSwitch fullScreenModeToggleSwitch;
private HBoxWithSpaceBetween showCursorHBox;
private HBoxWithSpaceBetween showCursorHBox;
private ToggleSwitch showCursorToggleSwitch;
private ToggleSwitch showCursorToggleSwitch;
private HBoxWithSpaceBetween invertRowsColsHBox;
private ToggleSwitch invertRowsColsToggleSwitch;
private TextField themesPathTextField;
private TextField themesPathTextField;
private TextField iconsPathTextField;
private TextField iconsPathTextField;
private TextField profilesPathTextField;
private TextField profilesPathTextField;
private final Button factoryResetButton;
private final Button factoryResetButton;
private Logger logger;
private Logger logger;
private final Button checkForUpdatesButton;
private final Button checkForUpdatesButton;
private HBoxInputBox screenTimeoutSecondsHBoxInputBox;
private HBoxInputBox screenTimeoutSecondsHBoxInputBox;
public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler,
public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler,
ClientListener clientListener, HostServices hostServices)
ClientListener clientListener, HostServices hostServices)
{
{
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.exceptionAndAlertHandler = exceptionAndAlertHandler;
this.clientListener = clientListener;
this.clientListener = clientListener;
this.hostServices = hostServices;
this.hostServices = hostServices;
logger = Logger.getLogger("");
logger = Logger.getLogger("");
serverPortTextField = new TextField();
serverPortTextField = new TextField();
screenTimeoutTextField = new TextField();
screenTimeoutTextField = 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();
startOnBootToggleSwitch = new ToggleSwitch();
startOnBootToggleSwitch = new ToggleSwitch();
startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", startOnBootToggleSwitch);
startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", startOnBootToggleSwitch);
startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty());
startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty());
screenSaverToggleSwitch = new ToggleSwitch();
screenSaverToggleSwitch = new ToggleSwitch();
screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", screenSaverToggleSwitch);
screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", screenSaverToggleSwitch);
screenSaverHBox.managedProperty().bind(screenSaverHBox.visibleProperty());
screenSaverHBox.managedProperty().bind(screenSaverHBox.visibleProperty());
tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch();
tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch();
tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", tryConnectingToServerIfActionClickedToggleSwitch);
tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", tryConnectingToServerIfActionClickedToggleSwitch);
tryConnectingToServerIfActionClickedHBox.managedProperty().bind(tryConnectingToServerIfActionClickedHBox.visibleProperty());
tryConnectingToServerIfActionClickedHBox.managedProperty().bind(tryConnectingToServerIfActionClickedHBox.visibleProperty());
fullScreenModeToggleSwitch = new ToggleSwitch();
fullScreenModeToggleSwitch = new ToggleSwitch();
fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", fullScreenModeToggleSwitch);
fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", fullScreenModeToggleSwitch);
fullScreenModeHBox.managedProperty().bind(fullScreenModeHBox.visibleProperty());
fullScreenModeHBox.managedProperty().bind(fullScreenModeHBox.visibleProperty());
vibrateOnActionPressToggleSwitch = new ToggleSwitch();
vibrateOnActionPressToggleSwitch = new ToggleSwitch();
vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", vibrateOnActionPressToggleSwitch);
vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", vibrateOnActionPressToggleSwitch);
vibrateOnActionPressHBox.managedProperty().bind(vibrateOnActionPressHBox.visibleProperty());
vibrateOnActionPressHBox.managedProperty().bind(vibrateOnActionPressHBox.visibleProperty());
connectOnStartupToggleSwitch = new ToggleSwitch();
connectOnStartupToggleSwitch = new ToggleSwitch();
connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", connectOnStartupToggleSwitch);
connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", connectOnStartupToggleSwitch);
connectOnStartupHBox.managedProperty().bind(connectOnStartupHBox.visibleProperty());
connectOnStartupHBox.managedProperty().bind(connectOnStartupHBox.visibleProperty());
showCursorToggleSwitch = new ToggleSwitch();
showCursorToggleSwitch = new ToggleSwitch();
showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", showCursorToggleSwitch);
showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", showCursorToggleSwitch);
showCursorHBox.managedProperty().bind(showCursorHBox.visibleProperty());
showCursorHBox.managedProperty().bind(showCursorHBox.visibleProperty());
invertRowsColsToggleSwitch = new ToggleSwitch();
invertRowsColsHBox = new HBoxWithSpaceBetween("Invert Grid on Rotate", invertRowsColsToggleSwitch);
invertRowsColsHBox.managedProperty().bind(invertRowsColsHBox.visibleProperty());
int prefWidth = 200;
int prefWidth = 200;
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());
factoryResetButton = new Button("Factory Reset");
factoryResetButton = new Button("Factory Reset");
factoryResetButton.setOnAction(actionEvent -> onFactoryResetButtonClicked());
factoryResetButton.setOnAction(actionEvent -> onFactoryResetButtonClicked());
screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", screenTimeoutTextField, prefWidth);
screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", screenTimeoutTextField, prefWidth);
screenTimeoutSecondsHBoxInputBox.managedProperty().bind(screenTimeoutSecondsHBoxInputBox.visibleProperty());
screenTimeoutSecondsHBoxInputBox.managedProperty().bind(screenTimeoutSecondsHBoxInputBox.visibleProperty());
screenTimeoutTextField.disableProperty().bind(screenSaverToggleSwitch.selectedProperty().not());
screenTimeoutTextField.disableProperty().bind(screenSaverToggleSwitch.selectedProperty().not());
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());
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 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,
screenTimeoutSecondsHBoxInputBox,
screenTimeoutSecondsHBoxInputBox,
invertRowsColsHBox,
screenSaverHBox,
screenSaverHBox,
tryConnectingToServerIfActionClickedHBox,
tryConnectingToServerIfActionClickedHBox,
fullScreenModeHBox,
fullScreenModeHBox,
connectOnStartupHBox,
connectOnStartupHBox,
vibrateOnActionPressHBox,
vibrateOnActionPressHBox,
startOnBootHBox,
startOnBootHBox,
showCursorHBox,
showCursorHBox,
checkForUpdatesButton,
checkForUpdatesButton,
shutdownButton,
shutdownButton,
factoryResetButton
factoryResetButton
);
);
vBox.getStyleClass().add("settings_base_vbox");
vBox.getStyleClass().add("settings_base_vbox");
vBox.setSpacing(10.0);
vBox.setSpacing(10.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));
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(10.0);
setSpacing(10.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);
startOnBootHBox.setVisible(false);
startOnBootHBox.setVisible(false);
showCursorHBox.setVisible(false);
showCursorHBox.setVisible(false);
fullScreenModeHBox.setVisible(false);
fullScreenModeHBox.setVisible(false);
shutdownButton.setVisible(false);
shutdownButton.setVisible(false);
}
}
else
else
{
{
if(!StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON)
shutdownButton.setVisible(StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON);
{
shutdownButton.setVisible(false);
}
vibrateOnActionPressHBox.setVisible(false);
vibrateOnActionPressHBox.setVisible(false);
invertRowsColsHBox.setVisible(false);
fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON);
fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON);
buttonBar.getChildren().add(exitButton);
buttonBar.getChildren().add(exitButton);
}
}
screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE);
screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE);
screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE);
screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE);
}
}
private Logger getLogger()
private Logger getLogger()
{
{
return logger;
return logger;
}
}
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) {
if(ClientInfo.getInstance().isPhone())
if(ClientInfo.getInstance().isPhone())
{
{
clientListener.openURL(getURL());
clientListener.openURL(getURL());
}
}
else
else
{
{
hostServices.showDocument(getURL());
hostServices.showDocument(getURL());
}
}
}
}
});
});
}
}
private void onFactoryResetButtonClicked()
private void onFactoryResetButtonClicked()
{
{
StreamPiAlert confirmation = new StreamPiAlert("Warning","Are you sure?\n" +
StreamPiAlert confirmation = new StreamPiAlert("Warning","Are you sure?\n" +
"This will erase everything.",StreamPiAlertType.WARNING);
"This will erase everything.",StreamPiAlertType.WARNING);
String yesButton = "Yes";
String yesButton = "Yes";
String noButton = "No";
String noButton = "No";
confirmation.setButtons(yesButton, noButton);
confirmation.setButtons(yesButton, noButton);
confirmation.setOnClicked(new StreamPiAlertListener() {
confirmation.setOnClicked(new StreamPiAlertListener() {
@Override
@Override
public void onClick(String s) {
public void onClick(String s) {
if(s.equals(yesButton))
if(s.equals(yesButton))
{
{
clientListener.factoryReset();
clientListener.factoryReset();
}
}
}
}
});
});
confirmation.show();
confirmation.show();
}
}
public void onExitButtonClicked()
public void onExitButtonClicked()
{
{
clientListener.onCloseRequest();
clientListener.onCloseRequest();
clientListener.exitApp();
clientListener.exitApp();
}
}
public void setDisableStatus(boolean status)
public void setDisableStatus(boolean status)
{
{
saveButton.setDisable(status);
saveButton.setDisable(status);
connectDisconnectButton.setDisable(status);
connectDisconnectButton.setDisable(status);
}
}
public Button getConnectDisconnectButton()
public Button getConnectDisconnectButton()
{
{
return connectDisconnectButton;
return connectDisconnectButton;
}
}
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 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()+"");
screenTimeoutTextField.setText(config.getScreenSaverTimeout()+"");
screenTimeoutTextField.setText(config.getScreenSaverTimeout()+"");
screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled());
screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled());
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());
startOnBootToggleSwitch.setSelected(config.isStartOnBoot());
startOnBootToggleSwitch.setSelected(config.isStartOnBoot());
fullScreenModeToggleSwitch.setSelected(config.getIsFullScreenMode());
fullScreenModeToggleSwitch.setSelected(config.getIsFullScreenMode());
showCursorToggleSwitch.setSelected(config.isShowCursor());
showCursorToggleSwitch.setSelected(config.isShowCursor());
connectOnStartupToggleSwitch.setSelected(config.isConnectOnStartup());
connectOnStartupToggleSwitch.setSelected(config.isConnectOnStartup());
vibrateOnActionPressToggleSwitch.setSelected(config.isVibrateOnActionClicked());
vibrateOnActionPressToggleSwitch.setSelected(config.isVibrateOnActionClicked());
tryConnectingToServerIfActionClickedToggleSwitch.setSelected(config.isTryConnectingWhenActionClicked());
tryConnectingToServerIfActionClickedToggleSwitch.setSelected(config.isTryConnectingWhenActionClicked());
invertRowsColsToggleSwitch.setSelected(config.isInvertRowsColsOnDeviceRotate());
}
}
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 Port should be above 1024.\n");
errors.append("* Server Port 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 Port should be a number.\n");
errors.append("* Server Port should be a number.\n");
}
}
int screenSaverTimeout = -1;
int screenSaverTimeout = -1;
try
try
{
{
screenSaverTimeout = Integer.parseInt(serverPortTextField.getText());
screenSaverTimeout = Integer.parseInt(serverPortTextField.getText());
if(screenSaverTimeout < 15)
if(screenSaverTimeout < 15)
errors.append("* Screen Timeout cannot be below 15 seconds.\n");
errors.append("* Screen Timeout cannot be below 15 seconds.\n");
}
}
catch (NumberFormatException exception)
catch (NumberFormatException exception)
{
{
errors.append("* Screen Timeout should be a number.\n");
errors.append("* Screen Timeout 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");
}
}
else
else
{
{
if(nickNameTextField.getText().equals("about maker"))
if(nickNameTextField.getText().equals("about maker"))
{
{
new StreamPiAlert("किसने बनाया ? / কে বানিয়েছে ?","ZGViYXlhbiAtIGluZGlh\n" +
new StreamPiAlert("किसने बनाया ? / কে বানিয়েছে ?","ZGViYXlhbiAtIGluZGlh\n" +
"boka XD").show();
"boka XD").show();
}
}
}
}
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 = fullScreenModeToggleSwitch.isSelected();
boolean isFullScreen = fullScreenModeToggleSwitch.isSelected();
if(config.getIsFullScreenMode() != isFullScreen)
if(config.getIsFullScreenMode() != isFullScreen)
{
{
toBeReloaded = true;
toBeReloaded = true;
}
}
config.setIsFullScreenMode(isFullScreen);
config.setIsFullScreenMode(isFullScreen);
config.setTryConnectingWhenActionClicked(tryConnectingToServerIfActionClickedToggleSwitch.isSelected());
config.setTryConnectingWhenActionClicked(tryConnectingToServerIfActionClickedToggleSwitch.isSelected());
boolean startOnBoot = startOnBootToggleSwitch.isSelected();
boolean startOnBoot = startOnBootToggleSwitch.isSelected();
if(config.isStartOnBoot() != startOnBoot)
if(config.isStartOnBoot() != startOnBoot)
{
{
if(StartupFlags.RUNNER_FILE_NAME == null)
if(StartupFlags.RUNNER_FILE_NAME == 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(StartupFlags.RUNNER_FILE_NAME),
startAtBoot.create(new File(StartupFlags.RUNNER_FILE_NAME),
StartupFlags.IS_X_MODE);
StartupFlags.IS_X_MODE);
config.setStartupIsXMode(StartupFlags.IS_X_MODE);
config.setStartupIsXMode(StartupFlags.IS_X_MODE);
}
}
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(showCursorToggleSwitch.isSelected());
config.setShowCursor(showCursorToggleSwitch.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());
if(config.isScreenSaverEnabled() != screenSaverToggleSwitch.isSelected())
if(config.isScreenSaverEnabled() != screenSaverToggleSwitch.isSelected())
toBeReloaded = true;
toBeReloaded = true;
config.setScreenSaverEnabled(screenSaverToggleSwitch.isSelected());
config.setScreenSaverEnabled(screenSaverToggleSwitch.isSelected());
if(!(screenSaverTimeout+"").equals(screenTimeoutTextField.getText()))
if(!(screenSaverTimeout+"").equals(screenTimeoutTextField.getText()))
toBeReloaded = true;
toBeReloaded = true;
config.setScreenSaverTimeout(screenTimeoutTextField.getText());
config.setScreenSaverTimeout(screenTimeoutTextField.getText());
config.setConnectOnStartup(connectOnStartupToggleSwitch.isSelected());
config.setConnectOnStartup(connectOnStartupToggleSwitch.isSelected());
boolean isVibrateOnActionClicked = vibrateOnActionPressToggleSwitch.isSelected();
boolean isVibrateOnActionClicked = vibrateOnActionPressToggleSwitch.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.setInvertRowsColsOnDeviceRotate(invertRowsColsToggleSwitch.isSelected());
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);
}
}
}
}
}
}
PKRIcons/PKR Profiles/PK'cJRLV&1Profiles/6fe15d84-8ac7-4b72-88f6-e497335fea7e.xmlU EJĞl,U $bG!}__BQN=>õlc`O'T9՜Z=:﷮:s 8o -]LChF#,Ii1fzEHgaBfyfjU@7u-;LIٌ5nb_Q/PKRThemes/PKR!Themes/com.stream_pi.defaultdark/PKR%Themes/com.stream_pi.defaultdark/res/PKʹRޱ D.Themes/com.stream_pi.defaultdark/res/style.cssTMo0GT+JOV[XudL߁Rrxf<c"D<$!?>~h-)䮷]f{guT+#¡p z8Xl70Hjڤږ:}P*-X֫q&^3 U.ρɥqe6cj OLas+tk
PKRIcons/PKR Profiles/PK'cJRLV&1Profiles/6fe15d84-8ac7-4b72-88f6-e497335fea7e.xmlU EJĞl,U $bG!}__BQN=>õlc`O'T9՜Z=:﷮:s 8o -]LChF#,Ii1fzEHgaBfyfjU@7u-;LIٌ5nb_Q/PKRThemes/PKR!Themes/com.stream_pi.defaultdark/PKR%Themes/com.stream_pi.defaultdark/res/PKʹRޱ D.Themes/com.stream_pi.defaultdark/res/style.cssTMo0GT+JOV[XudL߁Rrxf<c"D<$!?>~h-)䮷]f{guT+#¡p z8Xl70Hjڤږ:}P*-X֫q&^3 U.ρɥqe6cj OLas+tk
_!7lYИ 9%+Ȇ !ղJγ]\oNapfk4ވg}rOT
_!7lYИ 9%+Ȇ !ղJγ]\oNapfk4ވg}rOT
4%JLFYFԐeBC7c0HݦFG-]bݑ8ʍm5QFY7?d-<ء|(W-4]8^a<$/y GMq?dVI]hM (b SrnV߮&qc樵LqM129w~<ĦUUqiu$P|a\!X8#g PK,R}*Themes/com.stream_pi.defaultdark/theme.xmluP MNi ]89>/VZݽ˽cK FpnL; )ÑU|cr&+|a1
4%JLFYFԐeBC7c0HݦFG-]bݑ8ʍm5QFY7?d-<ء|(W-4]8^a<$/y GMq?dVI]hM (b SrnV߮&qc樵LqM129w~<ĦUUqiu$P|a\!X8#g PK,R}*Themes/com.stream_pi.defaultdark/theme.xmluP MNi ]89>/VZݽ˽cK FpnL; )ÑU|cr&+|a1
/U$aaDd]o'Z(5H1MD.&pn ZF#H6)MO2yxtY9F&^Ot]PKR"Themes/com.stream_pi.defaultlight/PKR&Themes/com.stream_pi.defaultlight/res/PKRNLr/Themes/com.stream_pi.defaultlight/res/style.cssTMo0#,ZtW{NVIUqp YrHy3Wd$'OGH^c{ 1T
/U$aaDd]o'Z(5H1MD.&pn ZF#H6)MO2yxtY9F&^Ot]PKR"Themes/com.stream_pi.defaultlight/PKR&Themes/com.stream_pi.defaultlight/res/PKRNLr/Themes/com.stream_pi.defaultlight/res/style.cssTMo0#,ZtW{NVIUqp YrHy3Wd$'OGH^c{ 1T
j +-$qR-14u4I]mIѶQfJaq&K m%
j +-$qR-14u4I]mIѶQfJaq&K m%
E_4ye\IQ?1ӦdjtLU!Qyamh8ԍ;TF:&]yCRbɚ7djhi|F!lh?p3ۡqhqvxr!3~[ #). jȪbS^eWrICbgԭ,}\}++}%;F} $cdNM>֥fR:ehRK=N3n\4-l87ڽ;QPwFB6|uw0ٗVmCz<2nTՙ2,PK,R|+Themes/com.stream_pi.defaultlight/theme.xmluPA0{)L0)ă/@hM{(3kSFIf ]FLη+-Ñ ~k[MV{1Hli0+8~oҭ ȲXZ Ni@rQ]ELz\X-gyDMu ΢WP8ztǖ5,b"+-PKR)Themes/com.stream_pi.defaulthighcontrast/PKR-Themes/com.stream_pi.defaulthighcontrast/res/PK)RG6Themes/com.stream_pi.defaulthighcontrast/res/style.cssUMo0#|^vz\eO-A: 2IU@@06<7oL~0 x 0`IBa=O!wtNu.J22*, ל,``Z@[I/ N-uhU*Z\A>=G1g\^kI]0xa\[ ϘqZ RU٧&I1zf wȍjF]LΒ344Z6QyVҺw<::u"-3-rOL`LlI6c22lZ|_pv7]2u EtXYYeuHֻ@<<Qմu{F(;άRK=Mt,c 8r8l#GftKon-<w%sjLD)lZ@Qw ׳Y4[{x}{V*%Ĉwu%B]R!VI7*DBsJi;Wi`7PK,RGzK2Themes/com.stream_pi.defaulthighcontrast/theme.xmluP10 ܑC 40 x)n&(qR|w>O]n輶,chJ{֦.Ŋ3V,t;  #x4S+IFm*Pm%u6֐OlwJs)x RD |" >9H}H>(ЋK0:ҟPKdR;f
E_4ye\IQ?1ӦdjtLU!Qyamh8ԍ;TF:&]yCRbɚ7djhi|F!lh?p3ۡqhqvxr!3~[ #). jȪbS^eWrICbgԭ,}\}++}%;F} $cdNM>֥fR:ehRK=N3n\4-l87ڽ;QPwFB6|uw0ٗVmCz<2nTՙ2,PK,R|+Themes/com.stream_pi.defaultlight/theme.xmluPA0{)L0)ă/@hM{(3kSFIf ]FLη+-Ñ ~k[MV{1Hli0+8~oҭ ȲXZ Ni@rQ]ELz\X-gyDMu ΢WP8ztǖ5,b"+-PKR)Themes/com.stream_pi.defaulthighcontrast/PKR-Themes/com.stream_pi.defaulthighcontrast/res/PK)RG6Themes/com.stream_pi.defaulthighcontrast/res/style.cssUMo0#|^vz\eO-A: 2IU@@06<7oL~0 x 0`IBa=O!wtNu.J22*, ל,``Z@[I/ N-uhU*Z\A>=G1g\^kI]0xa\[ ϘqZ RU٧&I1zf wȍjF]LΒ344Z6QyVҺw<::u"-3-rOL`LlI6c22lZ|_pv7]2u EtXYYeuHֻ@<<Qմu{F(;άRK=Mt,c 8r8l#GftKon-<w%sjLD)lZ@Qw ׳Y4[{x}{V*%Ĉwu%B]R!VI7*DBsJi;Wi`7PK,RGzK2Themes/com.stream_pi.defaulthighcontrast/theme.xmluP10 ܑC 40 x)n&(qR|w>O]n輶,chJ{֦.Ŋ3V,t;  #x4S+IFm*Pm%u6֐OlwJs)x RD |" >9H}H>(ЋK0:ҟPKdR;f
config.xmlTn0 ?+qG t,T In}([
config.xmlTn0 ?+qG t,T In}([
v)WON9O"Hl9o3iF`kUg[R+0~iwkG=py 5Mz&TtcСnS52VUm*ӫRPoPN֏CSY%dUU`-W5(9'(yQ ,z;LAS~džGiiBs`CèL \:tN(c ='i+а.isטjA%wߌ,c@zr7t`$&uf*ȸ$poG*ӳ;FI|k +i%k>
v)WON9O"Hl9o3iF`kUg[R+0~iwkG=py 5Mz&TtcСnS52VUm*ӫRPoPN֏CSY%dUU`-W5(9'(yQ ,z;LAS~džGiiBs`CèL \:tN(c ='i+а.isטjA%wߌ,c@zr7t`$&uf*ȸ$poG*ӳ;FI|k +i%k>
!>cB"|rNZ9'pdL/$<@4Cɘsu$APK?RAIcons/PK?R A$Profiles/PK?'cJRLV&1KProfiles/6fe15d84-8ac7-4b72-88f6-e497335fea7e.xmlPK?RA7Themes/PK?R!A\Themes/com.stream_pi.defaultdark/PK?R%AThemes/com.stream_pi.defaultdark/res/PK?ʹRޱ D.Themes/com.stream_pi.defaultdark/res/style.cssPK?,R}*5Themes/com.stream_pi.defaultdark/theme.xmlPK?R"A>Themes/com.stream_pi.defaultlight/PK?R&A~Themes/com.stream_pi.defaultlight/res/PK?RNLr/Themes/com.stream_pi.defaultlight/res/style.cssPK?,R|+Themes/com.stream_pi.defaultlight/theme.xmlPK?R)AThemes/com.stream_pi.defaulthighcontrast/PK?R-A8 Themes/com.stream_pi.defaulthighcontrast/res/PK?)RG6 Themes/com.stream_pi.defaulthighcontrast/res/style.cssPK?,RGzK2 Themes/com.stream_pi.defaulthighcontrast/theme.xmlPK?dR;f
!>cB"|rNZ9'pdL/$<@4Cɘsu$APK?RAIcons/PK?R A$Profiles/PK?'cJRLV&1KProfiles/6fe15d84-8ac7-4b72-88f6-e497335fea7e.xmlPK?RA7Themes/PK?R!A\Themes/com.stream_pi.defaultdark/PK?R%AThemes/com.stream_pi.defaultdark/res/PK?ʹRޱ D.Themes/com.stream_pi.defaultdark/res/style.cssPK?,R}*5Themes/com.stream_pi.defaultdark/theme.xmlPK?R"A>Themes/com.stream_pi.defaultlight/PK?R&A~Themes/com.stream_pi.defaultlight/res/PK?RNLr/Themes/com.stream_pi.defaultlight/res/style.cssPK?,R|+Themes/com.stream_pi.defaultlight/theme.xmlPK?R)AThemes/com.stream_pi.defaulthighcontrast/PK?R-A8 Themes/com.stream_pi.defaulthighcontrast/res/PK?)RG6 Themes/com.stream_pi.defaulthighcontrast/res/style.cssPK?,RGzK2 Themes/com.stream_pi.defaulthighcontrast/theme.xmlPK?dR;f
config.xmlPK]
config.xmlPK]