From c18559e2eaa287747f37b6212d37945bf52f5366 Mon Sep 17 00:00:00 2001 From: quimo Date: Sun, 29 Aug 2021 16:43:48 +0100 Subject: [PATCH 01/12] i found the only copy of my animations code. --- .../animations/AnimateFXInterpolator.java | 20 + .../client/animations/AnimationFX.java | 131 +++ .../stream_pi/client/animations/Bounce.java | 33 + .../com/stream_pi/client/animations/Flip.java | 46 + .../client/animations/JackInTheBox.java | 42 + .../stream_pi/client/animations/Jello.java | 43 + .../stream_pi/client/animations/Pulse.java | 35 + .../client/animations/RubberBand.java | 35 + .../stream_pi/client/animations/Shake.java | 33 + .../stream_pi/client/animations/Swing.java | 39 + .../com/stream_pi/client/animations/Tada.java | 38 + .../stream_pi/client/animations/Wobble.java | 34 + .../java/com/stream_pi/client/io/Config.java | 698 ++++++-------- .../com/stream_pi/client/window/Base.java | 700 ++++++-------- .../window/ExceptionAndAlertHandler.java | 23 +- .../window/dashboard/DashboardBase.java | 98 +- .../dashboard/actiongridpane/ActionBox.java | 687 ++++++------- .../actiongridpane/ActionGridPane.java | 561 ++++------- .../ActionGridPaneListener.java | 21 +- .../window/firsttimeuse/FinalConfigPane.java | 199 ++-- .../window/firsttimeuse/FirstTimeUse.java | 189 ++-- .../window/firsttimeuse/LicensePane.java | 31 +- .../window/firsttimeuse/WelcomePane.java | 34 +- .../window/firsttimeuse/WindowName.java | 11 +- .../window/settings/About/AboutTab.java | 244 ++--- .../window/settings/About/ContactTab.java | 62 +- .../window/settings/About/Contributor.java | 55 +- .../settings/About/ContributorsTab.java | 88 +- .../window/settings/About/LicenseTab.java | 16 +- .../client/window/settings/GeneralTab.java | 906 +++++++----------- .../client/window/settings/SettingsBase.java | 91 +- .../com/stream_pi/client/Default.zip | Bin 5434 -> 6759 bytes 32 files changed, 2460 insertions(+), 2783 deletions(-) create mode 100644 src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java create mode 100644 src/main/java/com/stream_pi/client/animations/AnimationFX.java create mode 100644 src/main/java/com/stream_pi/client/animations/Bounce.java create mode 100644 src/main/java/com/stream_pi/client/animations/Flip.java create mode 100644 src/main/java/com/stream_pi/client/animations/JackInTheBox.java create mode 100644 src/main/java/com/stream_pi/client/animations/Jello.java create mode 100644 src/main/java/com/stream_pi/client/animations/Pulse.java create mode 100644 src/main/java/com/stream_pi/client/animations/RubberBand.java create mode 100644 src/main/java/com/stream_pi/client/animations/Shake.java create mode 100644 src/main/java/com/stream_pi/client/animations/Swing.java create mode 100644 src/main/java/com/stream_pi/client/animations/Tada.java create mode 100644 src/main/java/com/stream_pi/client/animations/Wobble.java diff --git a/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java b/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java new file mode 100644 index 00000000..23b56e11 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java @@ -0,0 +1,20 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Interpolator; + +public final class AnimateFXInterpolator +{ + public static final Interpolator EASE; + + private AnimateFXInterpolator() { + throw new IllegalStateException("AnimateFX Interpolator"); + } + + static { + EASE = Interpolator.SPLINE(0.25, 0.1, 0.25, 1.0); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/AnimationFX.java b/src/main/java/com/stream_pi/client/animations/AnimationFX.java new file mode 100644 index 00000000..2122351f --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/AnimationFX.java @@ -0,0 +1,131 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Animation; +import javafx.beans.value.ObservableValue; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.util.Duration; +import javafx.scene.Node; +import javafx.animation.Timeline; + +public abstract class AnimationFX +{ + public static final int INDEFINITE = -1; + private Timeline timeline; + private boolean reset; + private Node node; + private AnimationFX nextAnimation; + private boolean hasNextAnimation; + + public AnimationFX(final Node node) { + this.setNode(node); + } + + public AnimationFX() { + this.hasNextAnimation = false; + this.reset = false; + } + + private AnimationFX onFinished() { + if (this.reset) { + this.resetNode(); + } + if (this.nextAnimation != null) { + this.nextAnimation.play(); + } + return this; + } + + public AnimationFX playOnFinished(final AnimationFX animation) { + this.setNextAnimation(animation); + return this; + } + + public AnimationFX setResetOnFinished(final boolean reset) { + this.reset = reset; + return this; + } + + public void play() { + this.timeline.play(); + } + + public AnimationFX stop() { + this.timeline.stop(); + return this; + } + + abstract AnimationFX resetNode(); + + abstract void initTimeline(); + + public Timeline getTimeline() { + return this.timeline; + } + + public void setTimeline(final Timeline timeline) { + this.timeline = timeline; + } + + public boolean isResetOnFinished() { + return this.reset; + } + + protected void setReset(final boolean reset) { + this.reset = reset; + } + + public Node getNode() { + return this.node; + } + + public void setNode(final Node node) { + this.node = node; + this.initTimeline(); + this.timeline.statusProperty().addListener((observable, oldValue, newValue) -> { + if (newValue.equals((Object)Animation.Status.STOPPED)) { + this.onFinished(); + } + }); + } + + public AnimationFX getNextAnimation() { + return this.nextAnimation; + } + + protected void setNextAnimation(final AnimationFX nextAnimation) { + this.hasNextAnimation = true; + this.nextAnimation = nextAnimation; + } + + public boolean hasNextAnimation() { + return this.hasNextAnimation; + } + + protected void setHasNextAnimation(final boolean hasNextAnimation) { + this.hasNextAnimation = hasNextAnimation; + } + + public AnimationFX setCycleCount(final int value) { + this.timeline.setCycleCount(value); + return this; + } + + public AnimationFX setSpeed(final double value) { + this.timeline.setRate(value); + return this; + } + + public AnimationFX setDelay(final Duration value) { + this.timeline.setDelay(value); + return this; + } + + public final void setOnFinished(final EventHandler value) { + this.timeline.setOnFinished((EventHandler)value); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Bounce.java b/src/main/java/com/stream_pi/client/animations/Bounce.java new file mode 100644 index 00000000..c87abfda --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Bounce.java @@ -0,0 +1,33 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.Interpolator; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.Node; + +public class Bounce extends AnimationFX +{ + public Bounce(final Node node) { + super(node); + } + + public Bounce() { + } + + public AnimationFX resetNode() { + this.getNode().setTranslateY(0.0); + return this; + } + + @Override + void initTimeline() { + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)0, Interpolator.SPLINE(0.215, 0.61, 0.355, 1.0)) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)(-30), Interpolator.SPLINE(0.755, 0.05, 0.855, 0.06)) }), new KeyFrame(Duration.millis(550.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)0, Interpolator.SPLINE(0.215, 0.61, 0.355, 1.0)) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)(-15), Interpolator.SPLINE(0.755, 0.05, 0.855, 0.06)) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)0, Interpolator.SPLINE(0.215, 0.61, 0.355, 1.0)) }), new KeyFrame(Duration.millis(900.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)(-5), Interpolator.SPLINE(0.755, 0.05, 0.855, 0.06)) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)0, Interpolator.SPLINE(0.215, 0.61, 0.355, 1.0)) }) })); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Flip.java b/src/main/java/com/stream_pi/client/animations/Flip.java new file mode 100644 index 00000000..e6e6ba17 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Flip.java @@ -0,0 +1,46 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.scene.ParallelCamera; +import javafx.event.ActionEvent; +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.Interpolator; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.transform.Rotate; +import javafx.scene.Camera; +import javafx.scene.PerspectiveCamera; +import javafx.scene.Node; + +public class Flip extends AnimationFX +{ + public Flip(final Node node) { + super(node); + } + + public Flip() { + } + + @Override + AnimationFX resetNode() { + this.getNode().setRotate(0.0); + this.getNode().setScaleX(1.0); + this.getNode().setScaleY(1.0); + this.getNode().setScaleZ(1.0); + this.getNode().setTranslateZ(0.0); + return this; + } + + @Override + void initTimeline() { + this.getNode().getScene().setCamera((Camera)new PerspectiveCamera()); + this.getNode().setRotationAxis(Rotate.Y_AXIS); + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)360, Interpolator.EASE_OUT) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)190, Interpolator.EASE_OUT), new KeyValue((WritableValue)this.getNode().translateZProperty(), (Object)(-150), Interpolator.EASE_OUT) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)170, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().translateZProperty(), (Object)(-150), Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.95, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.95, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)0.95, Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().translateZProperty(), (Object)0, Interpolator.EASE_IN) }) })); + this.getTimeline().setOnFinished(event -> this.getNode().getScene().setCamera((Camera)new ParallelCamera())); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/JackInTheBox.java b/src/main/java/com/stream_pi/client/animations/JackInTheBox.java new file mode 100644 index 00000000..c055af64 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/JackInTheBox.java @@ -0,0 +1,42 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; + +public class JackInTheBox extends AnimationFX +{ + private Rotate rotate; + + public JackInTheBox(final Node node) { + super(node); + } + + public JackInTheBox() { + } + + @Override + AnimationFX resetNode() { + this.getNode().setScaleX(1.0); + this.getNode().setScaleZ(1.0); + this.getNode().setScaleY(1.0); + this.getNode().setOpacity(1.0); + this.rotate.setAngle(0.0); + return this; + } + + @Override + void initTimeline() { + this.rotate = new Rotate(30.0, this.getNode().getBoundsInParent().getWidth() / 2.0, this.getNode().getBoundsInParent().getHeight()); + this.getNode().getTransforms().add((Object)this.rotate); + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.rotate.angleProperty(), (Object)30, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().opacityProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.rotate.angleProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.rotate.angleProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.rotate.angleProperty(), (Object)0, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().opacityProperty(), (Object)1, AnimateFXInterpolator.EASE) }) })); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Jello.java b/src/main/java/com/stream_pi/client/animations/Jello.java new file mode 100644 index 00000000..8ee61a56 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Jello.java @@ -0,0 +1,43 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.geometry.Bounds; +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.Node; +import javafx.scene.transform.Shear; + +public class Jello extends AnimationFX +{ + private Shear shear; + + public Jello(final Node node) { + super(node); + } + + public Jello() { + } + + @Override + AnimationFX resetNode() { + this.shear.setX(0.0); + this.shear.setY(0.0); + return this; + } + + @Override + void initTimeline() { + this.shear = new Shear(); + final Bounds bounds = this.getNode().getLayoutBounds(); + this.shear.setPivotX(bounds.getWidth() / 2.0); + this.shear.setPivotY(bounds.getHeight() / 2.0); + this.getNode().getTransforms().add((Object)this.shear); + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0) }), new KeyFrame(Duration.millis(111.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0.125), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0.125) }), new KeyFrame(Duration.millis(222.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)(-0.625)), new KeyValue((WritableValue)this.shear.yProperty(), (Object)(-0.625)) }), new KeyFrame(Duration.millis(333.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0.3125), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0.3125) }), new KeyFrame(Duration.millis(444.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)(-0.15625)), new KeyValue((WritableValue)this.shear.yProperty(), (Object)(-0.15625)) }), new KeyFrame(Duration.millis(555.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0.078125), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0.078125) }), new KeyFrame(Duration.millis(666.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)(-0.0390625)), new KeyValue((WritableValue)this.shear.yProperty(), (Object)(-0.0390625)) }), new KeyFrame(Duration.millis(777.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0.01953125), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0.01953125) }), new KeyFrame(Duration.millis(888.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0) }) })); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Pulse.java b/src/main/java/com/stream_pi/client/animations/Pulse.java new file mode 100644 index 00000000..4788ab3f --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Pulse.java @@ -0,0 +1,35 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.Node; + +public class Pulse extends AnimationFX +{ + public Pulse(final Node node) { + super(node); + } + + public Pulse() { + } + + @Override + AnimationFX resetNode() { + this.getNode().setScaleX(1.0); + this.getNode().setScaleY(1.0); + this.getNode().setScaleZ(1.0); + return this; + } + + @Override + void initTimeline() { + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.05, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.05, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.05, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }) })); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/RubberBand.java b/src/main/java/com/stream_pi/client/animations/RubberBand.java new file mode 100644 index 00000000..4c985de2 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RubberBand.java @@ -0,0 +1,35 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.Node; + +public class RubberBand extends AnimationFX +{ + public RubberBand(final Node node) { + super(node); + } + + public RubberBand() { + } + + @Override + AnimationFX resetNode() { + this.getNode().setScaleX(1.0); + this.getNode().setScaleY(1.0); + this.getNode().setScaleZ(1.0); + return this; + } + + @Override + void initTimeline() { + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(300.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.25, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.75, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.75, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.25, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.15, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.85, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(650.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.95, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.05, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(750.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.05, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.95, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }) })); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Shake.java b/src/main/java/com/stream_pi/client/animations/Shake.java new file mode 100644 index 00000000..dfd218ff --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Shake.java @@ -0,0 +1,33 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.Node; + +public class Shake extends AnimationFX +{ + public Shake(final Node node) { + super(node); + } + + public Shake() { + } + + @Override + AnimationFX resetNode() { + this.getNode().setTranslateX(0.0); + return this; + } + + @Override + void initTimeline() { + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(100.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(200.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)10, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(300.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)10, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)10, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)10, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(900.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)0, AnimateFXInterpolator.EASE) }) })); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Swing.java b/src/main/java/com/stream_pi/client/animations/Swing.java new file mode 100644 index 00000000..496f2b16 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Swing.java @@ -0,0 +1,39 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; + +public class Swing extends AnimationFX +{ + private Rotate rotation; + + public Swing(final Node node) { + super(node); + } + + public Swing() { + } + + @Override + AnimationFX resetNode() { + this.rotation.setAngle(0.0); + return this; + } + + @Override + void initTimeline() { + (this.rotation = new Rotate()).setPivotX(this.getNode().getLayoutBounds().getWidth() / 2.0); + this.rotation.setPivotY(-this.getNode().getLayoutBounds().getHeight()); + this.getNode().getTransforms().add((Object)this.rotation); + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(200.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)15, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)5, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)(-5), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)0, AnimateFXInterpolator.EASE) }) })); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Tada.java b/src/main/java/com/stream_pi/client/animations/Tada.java new file mode 100644 index 00000000..ceb144ef --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Tada.java @@ -0,0 +1,38 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.transform.Rotate; +import javafx.scene.Node; + +public class Tada extends AnimationFX +{ + public Tada(final Node node) { + super(node); + } + + public Tada() { + } + + @Override + AnimationFX resetNode() { + this.getNode().setScaleX(1.0); + this.getNode().setScaleY(1.0); + this.getNode().setScaleZ(1.0); + this.getNode().setRotate(0.0); + return this; + } + + @Override + void initTimeline() { + this.getNode().setRotationAxis(Rotate.Z_AXIS); + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(100.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(200.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(300.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(900.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, AnimateFXInterpolator.EASE) }) })); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Wobble.java b/src/main/java/com/stream_pi/client/animations/Wobble.java new file mode 100644 index 00000000..e3e17d50 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Wobble.java @@ -0,0 +1,34 @@ +// +// Decompiled by Procyon v0.5.36 +// + +package com.stream_pi.client.animations; + +import javafx.animation.Timeline; +import javafx.beans.value.WritableValue; +import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.Node; + +public class Wobble extends AnimationFX +{ + public Wobble(final Node node) { + super(node); + } + + public Wobble() { + } + + @Override + AnimationFX resetNode() { + this.getNode().setTranslateX(0.0); + this.getNode().setRotate(0.0); + return this; + } + + @Override + void initTimeline() { + this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)0, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(150.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-0.25 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-5), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(300.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(0.2 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(450.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-0.15 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(0.1 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)2, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(750.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-0.05 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-1), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)0, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, AnimateFXInterpolator.EASE) }) })); + } +} diff --git a/src/main/java/com/stream_pi/client/io/Config.java b/src/main/java/com/stream_pi/client/io/Config.java index df04a419..d4fe1e42 100644 --- a/src/main/java/com/stream_pi/client/io/Config.java +++ b/src/main/java/com/stream_pi/client/io/Config.java @@ -1,538 +1,420 @@ -/* -Config.java - -Contributor(s) : Debayan Sutradhar (@rnayabed) - -handler for config.xml - */ +// +// Decompiled by Procyon v0.5.36 +// package com.stream_pi.client.io; -import java.io.File; -import java.util.Objects; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Result; +import org.w3c.dom.Element; +import com.stream_pi.util.platform.Platform; +import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; import javax.xml.transform.Source; +import javax.xml.transform.Result; import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; +import org.w3c.dom.Node; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; - -import com.stream_pi.client.Main; -import com.stream_pi.client.info.ClientInfo; +import javax.xml.transform.TransformerFactory; import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.util.exception.SevereException; import com.stream_pi.util.iohelper.IOHelper; -import com.stream_pi.util.platform.Platform; -import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; - +import java.util.Objects; +import com.stream_pi.client.Main; +import java.io.InputStream; +import javax.xml.parsers.DocumentBuilder; +import com.stream_pi.util.exception.SevereException; +import javax.xml.parsers.DocumentBuilderFactory; +import com.stream_pi.client.info.ClientInfo; import org.w3c.dom.Document; -import org.w3c.dom.Element; +import java.io.File; public class Config { - private static Config instance = null; - + private static Config instance; private final File configFile; - private Document document; - - private Config() throws SevereException - { - try - { - configFile = new File(ClientInfo.getInstance().getPrePath()+"config.xml"); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - document = docBuilder.parse(configFile); + + private Config() throws SevereException { + try { + this.configFile = new File(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath())); + final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + this.document = docBuilder.parse(this.configFile); } - catch (Exception e) - { + catch (Exception e) { e.printStackTrace(); - throw new SevereException("Config", "unable to read config.xml\n"+e.getMessage()); + throw new SevereException("Config", invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, e.getMessage())); } } - - public static synchronized Config getInstance() throws SevereException - { - if(instance == null) - instance = new Config(); - - return instance; + + public static synchronized Config getInstance() throws SevereException { + if (Config.instance == null) { + Config.instance = new Config(); + } + return Config.instance; } - - public static void nullify() - { - instance = null; + + public static void nullify() { + Config.instance = null; } - - public static void unzipToDefaultPrePath() throws Exception - { - IOHelper.unzip(Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath()); - Config.getInstance().setThemesPath(ClientInfo.getInstance().getPrePath()+"Themes/"); - Config.getInstance().setIconsPath(ClientInfo.getInstance().getPrePath()+"Icons/"); - Config.getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath()+"Profiles/"); - - Config.getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE); - - Config.getInstance().save(); + + public static void unzipToDefaultPrePath() throws Exception { + IOHelper.unzip((InputStream)Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath()); + getInstance().setThemesPath(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath())); + getInstance().setIconsPath(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath())); + getInstance().setProfilesPath(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath())); + getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE); + getInstance().save(); } - - public void save() throws SevereException - { - try - { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - Result output = new StreamResult(configFile); - Source input = new DOMSource(document); - + + public void save() throws SevereException { + try { + final Transformer transformer = TransformerFactory.newInstance().newTransformer(); + final Result output = new StreamResult(this.configFile); + final Source input = new DOMSource(this.document); transformer.transform(input, output); } - catch (Exception e) - { + catch (Exception e) { throw new SevereException("Config", "unable to save config.xml"); } } - - - //Client Element - //Default Values - public String getDefaultClientNickName() - { + public String getDefaultClientNickName() { return "Stream-Pi Client"; } - - public String getDefaultStartupProfileID() - { + + public String getDefaultStartupProfileID() { return "default"; } - - public String getDefaultCurrentThemeFullName() - { + + public String getDefaultCurrentThemeFullName() { return "com.stream_pi.defaultlight"; } - - public String getDefaultThemesPath() - { - return ClientInfo.getInstance().getPrePath()+"Themes/"; + + public String getDefaultCurrentAnimationName() { + return "None"; } - - public String getDefaultProfilesPath() - { - return ClientInfo.getInstance().getPrePath()+"Profiles/"; + + public String getDefaultThemesPath() { + return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); } - - public String getDefaultIconsPath() - { - return ClientInfo.getInstance().getPrePath()+"Icons/"; + + public String getDefaultProfilesPath() { + return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); } - - //Getters - - public String getClientNickName() - { - return XMLConfigHelper.getStringProperty(document, "nickname", getDefaultClientNickName(), false, true, document, configFile); + + public String getDefaultIconsPath() { + return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); } - - public String getStartupProfileID() - { - return XMLConfigHelper.getStringProperty(document, "startup-profile", getDefaultStartupProfileID(), false, true, document, configFile); + + public String getClientNickName() { + return XMLConfigHelper.getStringProperty((Node)this.document, "nickname", this.getDefaultClientNickName(), false, true, this.document, this.configFile); } - - public String getCurrentThemeFullName() - { - return XMLConfigHelper.getStringProperty(document, "current-theme-full-name", getDefaultCurrentThemeFullName(), false, true, document, configFile); + + public String getStartupProfileID() { + return XMLConfigHelper.getStringProperty((Node)this.document, "startup-profile", this.getDefaultStartupProfileID(), false, true, this.document, this.configFile); } - - public String getThemesPath() - { - Platform platform = ClientInfo.getInstance().getPlatform(); - if(platform != Platform.ANDROID && - platform != Platform.IOS) - return ClientInfo.getInstance().getPrePath() + "Themes/"; - - return XMLConfigHelper.getStringProperty(document, "themes-path", getDefaultThemesPath(), false, true, document, configFile); + + public String getCurrentThemeFullName() { + return XMLConfigHelper.getStringProperty((Node)this.document, "current-theme-full-name", this.getDefaultCurrentThemeFullName(), false, true, this.document, this.configFile); } - - public String getProfilesPath() - { - Platform platform = ClientInfo.getInstance().getPlatform(); - if(platform != Platform.ANDROID && - platform != Platform.IOS) - return ClientInfo.getInstance().getPrePath() + "Profiles/"; - - return XMLConfigHelper.getStringProperty(document, "profiles-path", getDefaultProfilesPath(), false, true, document, configFile); + + public String getCurrentAnimationName() { + return XMLConfigHelper.getStringProperty((Node)this.document, "current-animation-name", this.getDefaultCurrentAnimationName(), false, true, this.document, this.configFile); } - - public String getIconsPath() - { - Platform platform = ClientInfo.getInstance().getPlatform(); - if(platform != Platform.ANDROID && - platform != Platform.IOS) - return ClientInfo.getInstance().getPrePath() + "Icons/"; - - return XMLConfigHelper.getStringProperty(document, "icons-path", getDefaultIconsPath(), false, true, document, configFile); + + public String getThemesPath() { + final Platform platform = ClientInfo.getInstance().getPlatform(); + if (platform != Platform.ANDROID && platform != Platform.IOS) { + return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + } + return XMLConfigHelper.getStringProperty((Node)this.document, "themes-path", this.getDefaultThemesPath(), false, true, this.document, this.configFile); } - - - //Setters - - public void setNickName(String nickName) - { - document.getElementsByTagName("nickname").item(0).setTextContent(nickName); + public String getProfilesPath() { + final Platform platform = ClientInfo.getInstance().getPlatform(); + if (platform != Platform.ANDROID && platform != Platform.IOS) { + return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + } + return XMLConfigHelper.getStringProperty((Node)this.document, "profiles-path", this.getDefaultProfilesPath(), false, true, this.document, this.configFile); } - - public void setStartupProfileID(String id) - { - document.getElementsByTagName("startup-profile").item(0).setTextContent(id); + + public String getIconsPath() { + final Platform platform = ClientInfo.getInstance().getPlatform(); + if (platform != Platform.ANDROID && platform != Platform.IOS) { + return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + } + return XMLConfigHelper.getStringProperty((Node)this.document, "icons-path", this.getDefaultIconsPath(), false, true, this.document, this.configFile); } - - public void setCurrentThemeFullName(String name) - { - document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); + + public void setNickName(final String nickName) { + this.document.getElementsByTagName("nickname").item(0).setTextContent(nickName); } - - public void setProfilesPath(String profilesPath) - { - document.getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath); + + public void setStartupProfileID(final String id) { + this.document.getElementsByTagName("startup-profile").item(0).setTextContent(id); } - - public void setIconsPath(String iconsPath) - { - document.getElementsByTagName("icons-path").item(0).setTextContent(iconsPath); + + public void setCurrentThemeFullName(final String name) { + this.document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); } - - public void setThemesPath(String themesPath) - { - document.getElementsByTagName("themes-path").item(0).setTextContent(themesPath); + + public void setCurrentAnimationFullName(final String name) { + this.document.getElementsByTagName("current-animation-name").item(0).setTextContent(name); } - - - //comms-server - public Element getCommsServerElement() - { - return (Element) document.getElementsByTagName("comms-server").item(0); + + public void setProfilesPath(final String profilesPath) { + this.document.getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath); } - - public String getDefaultSavedServerHostNameOrIP() - { + + public void setIconsPath(final String iconsPath) { + this.document.getElementsByTagName("icons-path").item(0).setTextContent(iconsPath); + } + + public void setThemesPath(final String themesPath) { + this.document.getElementsByTagName("themes-path").item(0).setTextContent(themesPath); + } + + public Element getCommsServerElement() { + return (Element)this.document.getElementsByTagName("comms-server").item(0); + } + + public String getDefaultSavedServerHostNameOrIP() { return "127.0.0.1"; } - - public int getDefaultSavedServerPort() - { + + public int getDefaultSavedServerPort() { return -1; } - - - public String getSavedServerHostNameOrIP() - { - return XMLConfigHelper.getStringProperty(getCommsServerElement(), "hostname-ip", getDefaultSavedServerHostNameOrIP(), false, true, document, configFile); + + public String getSavedServerHostNameOrIP() { + return XMLConfigHelper.getStringProperty((Node)this.getCommsServerElement(), "hostname-ip", this.getDefaultSavedServerHostNameOrIP(), false, true, this.document, this.configFile); } - - public int getSavedServerPort() - { - return XMLConfigHelper.getIntProperty(getCommsServerElement(), "port", getDefaultSavedServerPort(), false, true, document, configFile); + + public int getSavedServerPort() { + return XMLConfigHelper.getIntProperty((Node)this.getCommsServerElement(), "port", this.getDefaultSavedServerPort(), false, true, this.document, this.configFile); } - - public void setServerHostNameOrIP(String hostNameOrIP) - { - getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP); + + public void setServerHostNameOrIP(final String hostNameOrIP) { + this.getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP); } - - public void setServerPort(int port) - { - getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(port+""); + + public void setServerPort(final int port) { + this.getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(I)Ljava/lang/String;, port)); } - - - - - - //screen-mover - public Element getScreenMoverElement() - { - return (Element) document.getElementsByTagName("screen-mover").item(0); + + public Element getScreenMoverElement() { + return (Element)this.document.getElementsByTagName("screen-mover").item(0); } - - - //others - public Element getOthersElement() - { - return (Element) document.getElementsByTagName("others").item(0); + + public Element getOthersElement() { + return (Element)this.document.getElementsByTagName("others").item(0); } - - //others-default - - public boolean getDefaultStartOnBoot() - { + + public boolean getDefaultStartOnBoot() { return false; } - - public boolean getDefaultIsShowCursor() - { + + public boolean getDefaultIsShowCursor() { return true; } - - public boolean getDefaultFirstTimeUse() - { + + public boolean getDefaultFirstTimeUse() { return true; } - - - public boolean isShowCursor() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "show-cursor", getDefaultIsShowCursor(), false, true, document, configFile); + public boolean isShowCursor() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "show-cursor", this.getDefaultIsShowCursor(), false, true, this.document, this.configFile); } - - public boolean isStartOnBoot() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot", getDefaultStartOnBoot(), false, true, document, configFile); + public boolean isStartOnBoot() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "start-on-boot", this.getDefaultStartOnBoot(), false, true, this.document, this.configFile); } - - public boolean isFirstTimeUse() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile); + public boolean isFirstTimeUse() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "first-time-use", true, false, true, this.document, this.configFile); } - - public boolean isVibrateOnActionClicked() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "vibrate-on-action-clicked", false, false, true, document, configFile); + + public boolean isVibrateOnActionClicked() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "vibrate-on-action-clicked", false, false, true, this.document, this.configFile); } - - public boolean isConnectOnStartup() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "connect-on-startup", false, false, true, document, configFile); + + public boolean isConnectOnStartup() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "connect-on-startup", false, false, true, this.document, this.configFile); } - - public boolean getIsFullScreenMode() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "full-screen-mode", false, false, true, document, configFile); + + public boolean getIsFullScreenMode() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "full-screen-mode", false, false, true, this.document, this.configFile); } - - - public void setStartOnBoot(boolean value) - { - getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+""); + + public void setStartOnBoot(final boolean value) { + this.getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - public void setShowCursor(boolean value) - { - getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(value+""); + + public void setShowCursor(final boolean value) { + this.getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - public void setFullscreen(boolean value) - { - getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(value+""); + + public void setFullscreen(final boolean value) { + this.getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - public void setFirstTimeUse(boolean value) - { - getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+""); + + public void setFirstTimeUse(final boolean value) { + this.getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - public void setVibrateOnActionClicked(boolean value) - { - getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(value+""); + + public void setVibrateOnActionClicked(final boolean value) { + this.getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - public void setConnectOnStartup(boolean value) - { - getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(value+""); + + public void setConnectOnStartup(final boolean value) { + this.getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - public void setIsFullScreenMode(boolean value) - { - getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(value+""); + + public void setIsFullScreenMode(final boolean value) { + this.getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - - - private Element getStartupWindowSizeElement() - { - return (Element) document.getElementsByTagName("startup-window-size").item(0); + + private Element getStartupWindowSizeElement() { + return (Element)this.document.getElementsByTagName("startup-window-size").item(0); } - - public double getStartupWindowWidth() - { - return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width", - getDefaultStartupWindowWidth(), false, true, document, configFile); + + public double getStartupWindowWidth() { + return XMLConfigHelper.getDoubleProperty((Node)this.getStartupWindowSizeElement(), "width", (double)this.getDefaultStartupWindowWidth(), false, true, this.document, this.configFile); } - - public double getStartupWindowHeight() - { - return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height", - getDefaultStartupWindowHeight(), false, true, document, configFile); + + public double getStartupWindowHeight() { + return XMLConfigHelper.getDoubleProperty((Node)this.getStartupWindowSizeElement(), "height", (double)this.getDefaultStartupWindowHeight(), false, true, this.document, this.configFile); } - - - public int getDefaultStartupWindowWidth() - { + + public int getDefaultStartupWindowWidth() { return 800; } - - public int getDefaultStartupWindowHeight() - { + + public int getDefaultStartupWindowHeight() { return 400; } - - public void setStartupWindowSize(double width, double height) - { - setStartupWindowWidth(width); - setStartupWindowHeight(height); + + public void setStartupWindowSize(final double width, final double height) { + this.setStartupWindowWidth(width); + this.setStartupWindowHeight(height); } - - public void setStartupWindowWidth(double width) - { - getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+""); + + public void setStartupWindowWidth(final double width) { + this.getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(D)Ljava/lang/String;, width)); } - - public void setStartupWindowHeight(double height) - { - getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+""); + + public void setStartupWindowHeight(final double height) { + this.getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(D)Ljava/lang/String;, height)); } - - public void setStartupIsXMode(boolean value) - { - getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(value+""); + + public void setStartupIsXMode(final boolean value) { + this.getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - public boolean getDefaultIsStartupXMode() - { + + public boolean getDefaultIsStartupXMode() { return false; } - - public boolean isStartupXMode() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot-x-mode", getDefaultIsStartupXMode(), false, true, document, configFile); + + public boolean isStartupXMode() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "start-on-boot-x-mode", this.getDefaultIsStartupXMode(), false, true, this.document, this.configFile); } - - - public boolean getDefaultIsTryConnectingWhenActionClicked() - { + + public boolean getDefaultIsTryConnectingWhenActionClicked() { return false; } - - public boolean isTryConnectingWhenActionClicked() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "try-connecting-when-action-clicked", getDefaultIsTryConnectingWhenActionClicked(), false, true, document, configFile); + + public boolean isTryConnectingWhenActionClicked() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "try-connecting-when-action-clicked", this.getDefaultIsTryConnectingWhenActionClicked(), false, true, this.document, this.configFile); } - - public void setTryConnectingWhenActionClicked(boolean value) - { - getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(value+""); + + public void setTryConnectingWhenActionClicked(final boolean value) { + this.getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - - public boolean getDefaultScreenSaverEnabled() - { + + public boolean getDefaultScreenSaverEnabled() { return false; } - - public boolean isScreenSaverEnabled() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "screen-saver", getDefaultScreenSaverEnabled(), false, true, document, configFile); + + public boolean isScreenSaverEnabled() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "screen-saver", this.getDefaultScreenSaverEnabled(), false, true, this.document, this.configFile); } - - public void setScreenSaverEnabled(boolean value) - { - getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(value+""); + + public void setScreenSaverEnabled(final boolean value) { + this.getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - public int getDefaultScreenSaverTimeout() - { + + public int getDefaultScreenSaverTimeout() { return 60; } - - public int getScreenSaverTimeout() - { - return XMLConfigHelper.getIntProperty(getOthersElement(), "screen-saver-timeout-seconds", getDefaultScreenSaverTimeout(), false, true, document, configFile); + + public int getScreenSaverTimeout() { + return XMLConfigHelper.getIntProperty((Node)this.getOthersElement(), "screen-saver-timeout-seconds", this.getDefaultScreenSaverTimeout(), false, true, this.document, this.configFile); } - - public void setScreenSaverTimeout(String value) - { - getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value); + + public void setScreenSaverTimeout(final String value) { + this.getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value); } - - public int getDefaultScreenMoverInterval() - { + + public int getDefaultScreenMoverInterval() { return 120000; } - - public int getScreenMoverInterval() - { - return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "interval", getDefaultScreenMoverInterval(), false, true, document, configFile); + + public int getScreenMoverInterval() { + return XMLConfigHelper.getIntProperty((Node)this.getScreenMoverElement(), "interval", this.getDefaultScreenMoverInterval(), false, true, this.document, this.configFile); } - - public void setScreenMoverInterval(String value) - { - getScreenMoverElement().getElementsByTagName("interval").item(0).setTextContent(value); + + public void setScreenMoverInterval(final String value) { + this.getScreenMoverElement().getElementsByTagName("interval").item(0).setTextContent(value); } - - public int getDefaultScreenMoverXChange() - { + + public int getDefaultScreenMoverXChange() { return 5; } - - public int getScreenMoverXChange() - { - return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "x-change", getDefaultScreenMoverXChange(), false, true, document, configFile); + + public int getScreenMoverXChange() { + return XMLConfigHelper.getIntProperty((Node)this.getScreenMoverElement(), "x-change", this.getDefaultScreenMoverXChange(), false, true, this.document, this.configFile); } - - public void setScreenMoverXChange(String value) - { - getScreenMoverElement().getElementsByTagName("x-change").item(0).setTextContent(value); + + public void setScreenMoverXChange(final String value) { + this.getScreenMoverElement().getElementsByTagName("x-change").item(0).setTextContent(value); } - - public int getDefaultScreenMoverYChange() - { + + public int getDefaultScreenMoverYChange() { return 5; } - - public int getScreenMoverYChange() - { - return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "y-change", getDefaultScreenMoverYChange(), false, true, document, configFile); + + public int getScreenMoverYChange() { + return XMLConfigHelper.getIntProperty((Node)this.getScreenMoverElement(), "y-change", this.getDefaultScreenMoverYChange(), false, true, this.document, this.configFile); } - - public void setScreenMoverYChange(String value) - { - getScreenMoverElement().getElementsByTagName("y-change").item(0).setTextContent(value); + + public void setScreenMoverYChange(final String value) { + this.getScreenMoverElement().getElementsByTagName("y-change").item(0).setTextContent(value); } - - public boolean getDefaultScreenMoverEnabled() - { + + public boolean getDefaultScreenMoverEnabled() { return false; } - - public boolean isScreenMoverEnabled() - { - return XMLConfigHelper.getBooleanProperty(getScreenMoverElement(), "status", getDefaultScreenMoverEnabled(), false, true, document, configFile); + + public boolean isScreenMoverEnabled() { + return XMLConfigHelper.getBooleanProperty((Node)this.getScreenMoverElement(), "status", this.getDefaultScreenMoverEnabled(), false, true, this.document, this.configFile); } - - public void setScreenMoverEnabled(boolean value) - { - getScreenMoverElement().getElementsByTagName("status").item(0).setTextContent(value+""); + + public void setScreenMoverEnabled(final boolean value) { + this.getScreenMoverElement().getElementsByTagName("status").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); } - - public boolean getDefaultInvertRowsColsOnDeviceRotate() - { + + public boolean getDefaultInvertRowsColsOnDeviceRotate() { return true; } - - public boolean isInvertRowsColsOnDeviceRotate() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "invert-rows-cols-on-device-rotate", getDefaultInvertRowsColsOnDeviceRotate(), false, true, document, configFile); + + public boolean isInvertRowsColsOnDeviceRotate() { + return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "invert-rows-cols-on-device-rotate", this.getDefaultInvertRowsColsOnDeviceRotate(), false, true, this.document, this.configFile); } - - public void setInvertRowsColsOnDeviceRotate(boolean value) - { - getOthersElement().getElementsByTagName("invert-rows-cols-on-device-rotate").item(0).setTextContent(value+""); + + public void setInvertRowsColsOnDeviceRotate(final boolean value) { + this.getOthersElement().getElementsByTagName("invert-rows-cols-on-device-rotate").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + } + + static { + Config.instance = null; } } diff --git a/src/main/java/com/stream_pi/client/window/Base.java b/src/main/java/com/stream_pi/client/window/Base.java index db32b98e..fb34a432 100644 --- a/src/main/java/com/stream_pi/client/window/Base.java +++ b/src/main/java/com/stream_pi/client/window/Base.java @@ -1,530 +1,386 @@ -package com.stream_pi.client.window; +// +// Decompiled by Procyon v0.5.36 +// -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.controller.ScreenSaver; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; - -import java.io.File; -import java.nio.file.Paths; -import java.util.Objects; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Logger; +package com.stream_pi.client.window; -import com.stream_pi.client.Main; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.profile.ClientProfiles; -import com.stream_pi.client.window.dashboard.DashboardBase; -import com.stream_pi.client.window.firsttimeuse.FirstTimeUse; -import com.stream_pi.client.window.settings.SettingsBase; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.theme_api.Themes; -import com.stream_pi.util.alert.StreamPiAlert; -import com.stream_pi.util.combobox.StreamPiComboBox; import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler; -import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler; +import java.util.Iterator; +import java.util.Collection; +import javafx.scene.text.Font; import com.stream_pi.util.platform.Platform; - -import javafx.application.HostServices; -import javafx.geometry.Insets; -import javafx.scene.CacheHint; import javafx.scene.Cursor; -import javafx.scene.image.Image; import javafx.scene.input.KeyCombination; -import javafx.scene.layout.StackPane; -import javafx.scene.text.Font; import javafx.stage.Screen; +import com.stream_pi.util.exception.SevereException; +import javafx.scene.Node; +import com.stream_pi.util.combobox.StreamPiComboBox; +import com.stream_pi.util.alert.StreamPiAlert; +import javafx.geometry.Insets; +import javafx.scene.CacheHint; +import javafx.beans.value.ObservableValue; +import javafx.scene.image.Image; +import java.util.Objects; +import com.stream_pi.client.Main; +import java.io.InputStream; +import java.util.logging.Handler; +import java.io.File; +import java.util.concurrent.Executors; +import com.stream_pi.theme_api.Themes; +import com.stream_pi.theme_api.Theme; +import javafx.application.HostServices; +import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler; +import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler; +import java.util.logging.Logger; +import com.stream_pi.client.window.firsttimeuse.FirstTimeUse; +import com.stream_pi.client.window.settings.SettingsBase; +import com.stream_pi.client.window.dashboard.DashboardBase; import javafx.stage.Stage; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.profile.ClientProfiles; +import com.stream_pi.client.io.Config; +import java.util.concurrent.ExecutorService; +import com.stream_pi.client.controller.ClientListener; +import javafx.scene.layout.StackPane; public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ClientListener { - private final ExecutorService executor = Executors.newCachedThreadPool(); - + private final ExecutorService executor; private Config config; - private ClientProfiles clientProfiles; - private ClientInfo clientInfo; - private Stage stage; - - public Stage getStage() - { - return stage; - } - - public Logger getLogger() - { - return logger; - } - private DashboardBase dashboardBase; private SettingsBase settingsBase; - private FirstTimeUse firstTimeUse; - - private StackPane alertStackPane; - - @Override + private Logger logger; + private StreamPiLogFileHandler logFileHandler; + private StreamPiLogFallbackHandler logFallbackHandler; + private HostServices hostServices; + private Theme currentTheme; + Themes themes; + + public Base() { + this.executor = Executors.newCachedThreadPool(); + this.logger = null; + this.logFileHandler = null; + this.logFallbackHandler = null; + } + + public Stage getStage() { + return this.stage; + } + + public Logger getLogger() { + return this.logger; + } + public ClientProfiles getClientProfiles() { - return clientProfiles; + return this.clientProfiles; } - - public void setClientProfiles(ClientProfiles clientProfiles) { + + public void setClientProfiles(final ClientProfiles clientProfiles) { this.clientProfiles = clientProfiles; } - - private Logger logger = null; - private StreamPiLogFileHandler logFileHandler = null; - private StreamPiLogFallbackHandler logFallbackHandler = null; - - @Override - public void initLogger() - { - try - { - if(logFileHandler != null) + + public void initLogger() { + try { + if (this.logFileHandler != null) { return; - - closeLogger(); - logger = Logger.getLogger("com.stream_pi"); - - if(new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite()) - { - String path = ClientInfo.getInstance().getPrePath()+"../stream-pi-client.log"; - - if(getClientInfo().isPhone()) - path = ClientInfo.getInstance().getPrePath()+"stream-pi-client.log"; - - logFileHandler = new StreamPiLogFileHandler(path); - logger.addHandler(logFileHandler); } - else - { - logFallbackHandler = new StreamPiLogFallbackHandler(); - logger.addHandler(logFallbackHandler); + this.closeLogger(); + this.logger = Logger.getLogger("com.stream_pi"); + if (new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite()) { + String path = invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + if (this.getClientInfo().isPhone()) { + path = invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + } + this.logFileHandler = new StreamPiLogFileHandler(path); + this.logger.addHandler((Handler)this.logFileHandler); + } + else { + this.logFallbackHandler = new StreamPiLogFallbackHandler(); + this.logger.addHandler((Handler)this.logFallbackHandler); } - } - catch(Exception e) - { + catch (Exception e) { e.printStackTrace(); - - logFallbackHandler = new StreamPiLogFallbackHandler(); - logger.addHandler(logFallbackHandler); + this.logFallbackHandler = new StreamPiLogFallbackHandler(); + this.logger.addHandler((Handler)this.logFallbackHandler); } } - public void closeLogger() - { - if(logFileHandler != null) - logFileHandler.close(); - else if(logFallbackHandler != null) - logFallbackHandler.close(); + public void closeLogger() { + if (this.logFileHandler != null) { + this.logFileHandler.close(); + } + else if (this.logFallbackHandler != null) { + this.logFallbackHandler.close(); + } } - - private HostServices hostServices; - - public void setHostServices(HostServices hostServices) - { + + public void setHostServices(final HostServices hostServices) { this.hostServices = hostServices; } - - public HostServices getHostServices() - { - return hostServices; + + public HostServices getHostServices() { + return this.hostServices; } - - public void initBase() throws SevereException - { - stage = (Stage) getScene().getWindow(); - - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon256x256.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon48x48.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon32x32.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon24x24.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon16x16.png")))); - - clientInfo = ClientInfo.getInstance(); - dashboardBase = new DashboardBase(this, this); - dashboardBase.prefWidthProperty().bind(widthProperty()); - dashboardBase.prefHeightProperty().bind(heightProperty()); - - settingsBase = new SettingsBase(getHostServices(), this, this); - - alertStackPane = new StackPane(); - alertStackPane.setCache(true); - alertStackPane.setCacheHint(CacheHint.SPEED); - alertStackPane.setPadding(new Insets(10)); - alertStackPane.setOpacity(0); - - StreamPiAlert.setParent(alertStackPane); - StreamPiComboBox.setParent(alertStackPane); - - - getChildren().clear(); - - - getChildren().addAll(alertStackPane); - - if(getClientInfo().isPhone()) - { - dashboardBase.setPadding(new Insets(10)); - settingsBase.setPadding(new Insets(10)); + + public void initBase() throws SevereException { + this.stage = (Stage)this.getScene().getWindow(); + this.getStage().getIcons().add((Object)new Image((InputStream)Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png")))); + this.clientInfo = ClientInfo.getInstance(); + this.dashboardBase = new DashboardBase(this, this); + this.dashboardBase.prefWidthProperty().bind((ObservableValue)this.widthProperty()); + this.dashboardBase.prefHeightProperty().bind((ObservableValue)this.heightProperty()); + this.settingsBase = new SettingsBase(this.getHostServices(), this, this); + (this.alertStackPane = new StackPane()).setCache(true); + this.alertStackPane.setCacheHint(CacheHint.SPEED); + this.alertStackPane.setPadding(new Insets(10.0)); + this.alertStackPane.setOpacity(0.0); + StreamPiAlert.setParent(this.alertStackPane); + StreamPiComboBox.setParent(this.alertStackPane); + this.getChildren().clear(); + this.getChildren().addAll((Object[])new Node[] { (Node)this.alertStackPane }); + if (this.getClientInfo().isPhone()) { + this.dashboardBase.setPadding(new Insets(10.0)); + this.settingsBase.setPadding(new Insets(10.0)); } - - initLogger(); - - checkPrePathDirectory(); - - - getChildren().addAll(settingsBase, dashboardBase); - - setStyle(null); - - config = Config.getInstance(); - - initThemes(); - - if(config.isFirstTimeUse()) - { - - firstTimeUse = new FirstTimeUse(this, this); - - getChildren().add(firstTimeUse); - - if(getClientInfo().isPhone()) - { - firstTimeUse.setPadding(new Insets(10)); + this.initLogger(); + this.checkPrePathDirectory(); + this.getChildren().addAll((Object[])new Node[] { (Node)this.settingsBase, (Node)this.dashboardBase }); + this.setStyle((String)null); + this.config = Config.getInstance(); + this.initThemes(); + if (this.config.isFirstTimeUse()) { + this.firstTimeUse = new FirstTimeUse(this, this); + this.getChildren().add((Object)this.firstTimeUse); + if (this.getClientInfo().isPhone()) { + this.firstTimeUse.setPadding(new Insets(10.0)); } - - firstTimeUse.toFront(); - - //resolution check - resizeAccordingToResolution(); + this.firstTimeUse.toFront(); + this.resizeAccordingToResolution(); } - else - { - dashboardBase.toFront(); + else { + this.dashboardBase.toFront(); } } - - public void initThemes() throws SevereException - { - clearStylesheets(); - if(themes==null) - registerThemes(); - applyDefaultStylesheet(); - applyDefaultTheme(); - applyDefaultIconsStylesheet(); - applyGlobalDefaultStylesheet(); + + public void initThemes() throws SevereException { + this.clearStylesheets(); + if (this.themes == null) { + this.registerThemes(); + } + this.applyDefaultStylesheet(); + this.applyDefaultTheme(); + this.applyDefaultIconsStylesheet(); + this.applyGlobalDefaultStylesheet(); } - - private void resizeAccordingToResolution() - { - if(!getClientInfo().isPhone()) - { - double height = getScreenHeight(); - double width = getScreenWidth(); - - if(height < 500) - setPrefHeight(320); - - if(width < 500) - setPrefWidth(240); + + private void resizeAccordingToResolution() { + if (!this.getClientInfo().isPhone()) { + final double height = this.getScreenHeight(); + final double width = this.getScreenWidth(); + if (height < 500.0) { + this.setPrefHeight(320.0); + } + if (width < 500.0) { + this.setPrefWidth(240.0); + } } } - - @Override - public ExecutorService getExecutor() - { - return executor; + + public ExecutorService getExecutor() { + return this.executor; } - - @Override - public double getStageWidth() - { - if(getClientInfo().isPhone()) - { - return getScreenWidth(); - } - else - { - return getStage().getWidth(); + + public double getStageWidth() { + if (this.getClientInfo().isPhone()) { + return this.getScreenWidth(); } + return this.getStage().getWidth(); } - - public double getScreenWidth() - { + + public double getScreenWidth() { return Screen.getPrimary().getBounds().getWidth(); } - - @Override - public double getStageHeight() - { - if(ClientInfo.getInstance().isPhone()) - { - return getScreenHeight(); - } - else - { - return getStage().getHeight(); + + public double getStageHeight() { + if (ClientInfo.getInstance().isPhone()) { + return this.getScreenHeight(); } + return this.getStage().getHeight(); } - - public double getScreenHeight() - { + + public double getScreenHeight() { return Screen.getPrimary().getBounds().getHeight(); } - - private void checkPrePathDirectory() throws SevereException - { - try - { - String path = getClientInfo().getPrePath(); - - if(path == null) - { - throwStoragePermErrorAlert("Unable to access file system!"); + + private void checkPrePathDirectory() throws SevereException { + try { + final String path = this.getClientInfo().getPrePath(); + if (path == null) { + this.throwStoragePermErrorAlert("Unable to access file system!"); return; } - - File file = new File(path); - - - if(!file.exists()) - { - boolean result = file.mkdirs(); - if(result) - { + final File file = new File(path); + if (!file.exists()) { + final boolean result = file.mkdirs(); + if (result) { Config.unzipToDefaultPrePath(); - - initLogger(); + this.initLogger(); } - else - { - throwStoragePermErrorAlert("No storage permission. Give it!"); + else { + this.throwStoragePermErrorAlert("No storage permission. Give it!"); } } } - catch (Exception e) - { + catch (Exception e) { e.printStackTrace(); throw new SevereException(e.getMessage()); } } - - private void throwStoragePermErrorAlert(String msg) throws SevereException - { - resizeAccordingToResolution(); - - clearStylesheets(); - applyDefaultStylesheet(); - applyDefaultIconsStylesheet(); - applyGlobalDefaultStylesheet(); - getStage().show(); + + private void throwStoragePermErrorAlert(final String msg) throws SevereException { + this.resizeAccordingToResolution(); + this.clearStylesheets(); + this.applyDefaultStylesheet(); + this.applyDefaultIconsStylesheet(); + this.applyGlobalDefaultStylesheet(); + this.getStage().show(); throw new SevereException(msg); } - - public void setupFlags() throws SevereException - { - //Full Screen - if(Config.getInstance().getIsFullScreenMode()) - { - getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); - getStage().setFullScreen(true); + + public void setupFlags() throws SevereException { + if (Config.getInstance().getIsFullScreenMode()) { + this.getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); + this.getStage().setFullScreen(true); } - else - { - getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC")); - getStage().setFullScreen(false); + else { + this.getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC")); + this.getStage().setFullScreen(false); } - - //Cursor - if(Config.getInstance().isShowCursor()) - { - setCursor(Cursor.DEFAULT); + if (Config.getInstance().isShowCursor()) { + this.setCursor(Cursor.DEFAULT); } - else - { - setCursor(Cursor.NONE); + else { + this.setCursor(Cursor.NONE); } } - - + public SettingsBase getSettingsPane() { - return settingsBase; + return this.settingsBase; } - + public DashboardBase getDashboardPane() { - return dashboardBase; + return this.dashboardBase; } - - public void renderRootDefaultProfile() - { - getDashboardPane().renderProfile(getClientProfiles().getProfileFromID( - getConfig().getStartupProfileID() - ), true); + + public void renderRootDefaultProfile() { + this.getDashboardPane().renderProfile(this.getClientProfiles().getProfileFromID(this.getConfig().getStartupProfileID()), true); } - - - - public void clearStylesheets() - { - getStylesheets().clear(); + + public void clearStylesheets() { + this.getStylesheets().clear(); } - - - - public void applyDefaultStylesheet() - { - if(clientInfo.getPlatform() != Platform.IOS) - Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13); - - getStylesheets().add(Main.class.getResource("style.css").toExternalForm()); + + public void applyDefaultStylesheet() { + if (this.clientInfo.getPlatform() != Platform.IOS) { + Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13.0); + } + this.getStylesheets().add((Object)Main.class.getResource("style.css").toExternalForm()); } - - public void applyDefaultIconsStylesheet() - { - getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm()); + + public void applyDefaultIconsStylesheet() { + this.getStylesheets().add((Object)Main.class.getResource("default_icons.css").toExternalForm()); } - - - public Config getConfig() - { - return config; + + public Config getConfig() { + return this.config; } - - public ClientInfo getClientInfo() - { - return clientInfo; + + public ClientInfo getClientInfo() { + return this.clientInfo; } - - private Theme currentTheme; - - @Override - public Theme getCurrentTheme() - { - return currentTheme; + + public Theme getCurrentTheme() { + return this.currentTheme; } - - - public void applyTheme(Theme t) - { - logger.info("Applying theme '"+t.getFullName()+"' ..."); - - if(t.getFonts() != null) - { - for(String fontFile : t.getFonts()) - { - Font.loadFont(fontFile.replace("%20",""), 13); + + public void applyTheme(final Theme t) { + this.logger.info(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, t.getFullName())); + if (t.getFonts() != null) { + for (final String fontFile : t.getFonts()) { + Font.loadFont(fontFile.replace("%20", ""), 13.0); } } - currentTheme = t; - getStylesheets().addAll(t.getStylesheets()); - - logger.info("... Done!"); + this.currentTheme = t; + this.getStylesheets().addAll((Collection)t.getStylesheets()); + this.logger.info("... Done!"); } - - public void applyGlobalDefaultStylesheet() - { - File globalCSSFile = new File(getConfig().getDefaultThemesPath()+"/global.css"); - if(globalCSSFile.exists()) - { - getLogger().info("Found global default style sheet. Adding ..."); - getStylesheets().add(globalCSSFile.toURI().toString()); + + public void applyGlobalDefaultStylesheet() { + final File globalCSSFile = new File(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, this.getConfig().getDefaultThemesPath())); + if (globalCSSFile.exists()) { + this.getLogger().info("Found global default style sheet. Adding ..."); + this.getStylesheets().add((Object)globalCSSFile.toURI().toString()); } } - - Themes themes; - public void registerThemes() throws SevereException - { - logger.info("Loading themes ..."); - - themes = new Themes(getConfig().getDefaultThemesPath(), getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), clientInfo.getMinThemeSupportVersion()); - - if(!themes.getErrors().isEmpty()) - { - StringBuilder themeErrors = new StringBuilder(); - - for(MinorException eachException : themes.getErrors()) - { + + public void registerThemes() throws SevereException { + this.logger.info("Loading themes ..."); + this.themes = new Themes(this.getConfig().getDefaultThemesPath(), this.getConfig().getThemesPath(), this.getConfig().getCurrentThemeFullName(), this.clientInfo.getMinThemeSupportVersion()); + if (!this.themes.getErrors().isEmpty()) { + final StringBuilder themeErrors = new StringBuilder(); + for (final MinorException eachException : this.themes.getErrors()) { themeErrors.append("\n * ").append(eachException.getMessage()); } - - if(themes.getIsBadThemeTheCurrentOne()) - { - if(getConfig().getCurrentThemeFullName().equals(getConfig().getDefaultCurrentThemeFullName())) - { - throw new SevereException("Unable to get default theme ("+getConfig().getDefaultCurrentThemeFullName()+")\n" + - "Please restore the theme or reinstall."); + if (this.themes.getIsBadThemeTheCurrentOne()) { + if (this.getConfig().getCurrentThemeFullName().equals(this.getConfig().getDefaultCurrentThemeFullName())) { + throw new SevereException(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, this.getConfig().getDefaultCurrentThemeFullName())); } - - themeErrors.append("\n\nReverted to default theme! (").append(getConfig().getDefaultCurrentThemeFullName()).append(")"); - - getConfig().setCurrentThemeFullName(getConfig().getDefaultCurrentThemeFullName()); - getConfig().save(); + themeErrors.append("\n\nReverted to default theme! (").append(this.getConfig().getDefaultCurrentThemeFullName()).append(")"); + this.getConfig().setCurrentThemeFullName(this.getConfig().getDefaultCurrentThemeFullName()); + this.getConfig().save(); } - - handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString())); + this.handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString())); } - logger.info("...Themes loaded successfully !"); + this.logger.info("...Themes loaded successfully !"); } - - @Override - public Themes getThemes() - { - return themes; + + public Themes getThemes() { + return this.themes; } - - - public void applyDefaultTheme() - { - logger.info("Applying default theme ..."); - + + public void applyDefaultTheme() { + this.logger.info("Applying default theme ..."); boolean foundTheme = false; - for(Theme t: themes.getThemeList()) - { - if(t.getFullName().equals(config.getCurrentThemeFullName())) - { + for (final Theme t : this.themes.getThemeList()) { + if (t.getFullName().equals(this.config.getCurrentThemeFullName())) { foundTheme = true; - applyTheme(t); + this.applyTheme(t); break; } } - - if(foundTheme) - { - logger.info("... Done!"); + if (foundTheme) { + this.logger.info("... Done!"); } - else - { - logger.info("Theme not found. reverting to light theme ..."); + else { + this.logger.info("Theme not found. reverting to light theme ..."); try { Config.getInstance().setCurrentThemeFullName("com.stream_pi.defaultlight"); Config.getInstance().save(); - - applyDefaultTheme(); + this.applyDefaultTheme(); } - catch (SevereException e) - { - handleSevereException(e); + catch (SevereException e) { + this.handleSevereException(e); } } - - } - - @Override - public String getDefaultThemeFullName() - { - return config.getCurrentThemeFullName(); + + public String getDefaultThemeFullName() { + return this.config.getCurrentThemeFullName(); } - - } diff --git a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java index 42c276c1..e7f74a2a 100644 --- a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java +++ b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java @@ -1,15 +1,22 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.alert.StreamPiAlertType; public interface ExceptionAndAlertHandler { - void onAlert(String title, String body, StreamPiAlertType alertType); - - void handleMinorException(MinorException e); - void handleMinorException(String message, MinorException e); - void handleSevereException(SevereException e); - void handleSevereException(String message, SevereException e); + void onAlert(final String p0, final String p1, final StreamPiAlertType p2); + + void handleMinorException(final MinorException p0); + + void handleMinorException(final String p0, final MinorException p1); + + void handleSevereException(final SevereException p0); + + void handleSevereException(final String p0, final SevereException p1); } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java index c1951e23..ff9556bd 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java @@ -1,78 +1,68 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.dashboard; -import com.stream_pi.client.controller.ClientListener; import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPane; - -import javafx.geometry.Insets; import javafx.geometry.Pos; -import javafx.scene.control.Button; +import javafx.geometry.Insets; import javafx.scene.layout.HBox; -import javafx.scene.layout.VBox; +import javafx.scene.Node; import org.kordamp.ikonli.javafx.FontIcon; +import com.stream_pi.client.controller.ClientListener; +import javafx.scene.control.Button; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPane; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import javafx.scene.layout.VBox; public class DashboardBase extends VBox { private ExceptionAndAlertHandler exceptionAndAlertHandler; - private ActionGridPane actionGridPane; private Button settingsButton; - - public DashboardBase(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) - { + + public DashboardBase(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener) { this.exceptionAndAlertHandler = exceptionAndAlertHandler; - - actionGridPane = new ActionGridPane(exceptionAndAlertHandler, clientListener); - - FontIcon fontIcon = new FontIcon("fas-cog"); - fontIcon.getStyleClass().addAll("dashboard_settings_button_icon"); - - settingsButton = new Button(); - settingsButton.getStyleClass().addAll("dashboard_settings_button"); - settingsButton.setGraphic(fontIcon); - - HBox hBox = new HBox(settingsButton); - hBox.getStyleClass().add("dashboard_settings_button_parent"); - hBox.setPadding(new Insets(0,5,5,0)); + this.actionGridPane = new ActionGridPane(exceptionAndAlertHandler, clientListener); + final FontIcon fontIcon = new FontIcon("fas-cog"); + fontIcon.getStyleClass().addAll((Object[])new String[] { "dashboard_settings_button_icon" }); + this.settingsButton = new Button(); + this.settingsButton.getStyleClass().addAll((Object[])new String[] { "dashboard_settings_button" }); + this.settingsButton.setGraphic((Node)fontIcon); + final HBox hBox = new HBox(new Node[] { (Node)this.settingsButton }); + hBox.getStyleClass().add((Object)"dashboard_settings_button_parent"); + hBox.setPadding(new Insets(0.0, 5.0, 5.0, 0.0)); hBox.setAlignment(Pos.CENTER_RIGHT); - - - getChildren().addAll(actionGridPane,hBox); - - getStyleClass().add("dashboard"); + this.getChildren().addAll((Object[])new Node[] { (Node)this.actionGridPane, (Node)hBox }); + this.getStyleClass().add((Object)"dashboard"); } - - public void renderProfile(ClientProfile clientProfile, boolean freshRender) - { - renderProfile(clientProfile, "root", freshRender); + + public void renderProfile(final ClientProfile clientProfile, final boolean freshRender) { + this.renderProfile(clientProfile, "root", freshRender); } - - public void renderProfile(ClientProfile clientProfile, String currentParent, boolean freshRender) - { - actionGridPane.setClientProfile(clientProfile); - actionGridPane.setCurrentParent(currentParent); - actionGridPane.setFreshRender(freshRender); - - actionGridPane.renderGrid(); - actionGridPane.renderActions(); + + public void renderProfile(final ClientProfile clientProfile, final String currentParent, final boolean freshRender) { + this.actionGridPane.setClientProfile(clientProfile); + this.actionGridPane.setCurrentParent(currentParent); + this.actionGridPane.setFreshRender(freshRender); + this.actionGridPane.renderGrid(); + this.actionGridPane.renderActions(); } - - public void addBlankActionBox(int col, int row) - { - actionGridPane.addBlankActionBox(col, row); + + public void addBlankActionBox(final int col, final int row) { + this.actionGridPane.addBlankActionBox(col, row); } - - public void clearActionBox(int col, int row) - { - actionGridPane.clearActionBox(col, row); + + public void clearActionBox(final int col, final int row) { + this.actionGridPane.clearActionBox(col, row); } - + public ActionGridPane getActionGridPane() { - return actionGridPane; + return this.actionGridPane; } - + public Button getSettingsButton() { - return settingsButton; + return this.settingsButton; } } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java index ab71a778..89ecec77 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java @@ -1,198 +1,171 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.dashboard.actiongridpane; -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; +import javafx.scene.input.MouseEvent; +import javafx.event.ActionEvent; +import com.stream_pi.client.animations.Wobble; +import com.stream_pi.client.animations.Tada; +import com.stream_pi.client.animations.Shake; +import com.stream_pi.client.animations.RubberBand; +import com.stream_pi.client.animations.Pulse; +import com.stream_pi.client.animations.Jello; +import com.stream_pi.client.animations.Swing; +import com.stream_pi.client.animations.JackInTheBox; +import com.stream_pi.client.animations.Bounce; +import com.stream_pi.client.animations.Flip; +import javafx.geometry.Pos; import com.stream_pi.action_api.action.DisplayTextAlignment; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; +import javafx.scene.layout.BackgroundSize; +import javafx.scene.layout.BackgroundPosition; +import javafx.scene.layout.BackgroundRepeat; +import java.io.InputStream; +import javafx.scene.image.Image; +import java.io.ByteArrayInputStream; +import javafx.scene.layout.BackgroundImage; import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.client.io.Config; +import com.stream_pi.action_api.action.ActionType; +import javafx.beans.value.WritableValue; import javafx.animation.Interpolator; -import javafx.animation.KeyFrame; import javafx.animation.KeyValue; -import javafx.animation.Timeline; -import javafx.geometry.Pos; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import javafx.scene.Node; import javafx.scene.CacheHint; -import javafx.scene.control.Label; -import javafx.scene.image.Image; -import javafx.scene.layout.Background; -import javafx.scene.layout.BackgroundImage; -import javafx.scene.layout.BackgroundPosition; -import javafx.scene.layout.BackgroundRepeat; -import javafx.scene.layout.BackgroundSize; -import javafx.scene.layout.StackPane; -import javafx.scene.text.Font; +import javafx.beans.value.ObservableValue; import javafx.scene.text.TextAlignment; -import javafx.util.Duration; +import javafx.scene.layout.Background; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.action_api.action.Action; +import com.stream_pi.client.controller.ClientListener; +import javafx.animation.Timeline; import org.kordamp.ikonli.javafx.FontIcon; - -import java.io.ByteArrayInputStream; import java.util.logging.Logger; +import javafx.scene.control.Label; +import javafx.scene.layout.StackPane; public class ActionBox extends StackPane { - private Label displayTextLabel; - private int row; private int col; - + private Logger logger; + private FontIcon statusIcon; + private Timeline statusIconAnimation; + private int size; + private ActionGridPaneListener actionGridPaneListener; + private ClientListener clientListener; + private Action action; + private ExceptionAndAlertHandler exceptionAndAlertHandler; + private String parent; + FontIcon fontIcon; + public int getRow() { - return row; + return this.row; } - + public int getCol() { - return col; + return this.col; } - private Logger logger; - - - - public void clear() - { - setStyle(null); - setAction(null); - setCurrentToggleStatus(false); - getStyleClass().clear(); - setBackground(Background.EMPTY); - removeFontIcon(); - getChildren().clear(); - baseInit(); + public void clear() { + this.setStyle((String)null); + this.setAction(null); + this.setCurrentToggleStatus(false); + this.getStyleClass().clear(); + this.setBackground(Background.EMPTY); + this.removeFontIcon(); + this.getChildren().clear(); + this.baseInit(); } - - private FontIcon statusIcon; - - public void baseInit() - { - displayTextLabel = new Label(); - displayTextLabel.setWrapText(true); - displayTextLabel.setTextAlignment(TextAlignment.CENTER); - displayTextLabel.getStyleClass().add("action_box_display_text_label"); - - displayTextLabel.prefHeightProperty().bind(heightProperty()); - displayTextLabel.prefWidthProperty().bind(widthProperty()); - - - statusIcon = new FontIcon("fas-exclamation-triangle"); - statusIcon.getStyleClass().add("action_box_error_icon"); - statusIcon.setOpacity(0); - statusIcon.setCache(true); - statusIcon.setCacheHint(CacheHint.SPEED); - statusIcon.setIconSize(size - 30); - - getChildren().addAll(statusIcon, displayTextLabel); - - setMinSize(size, size); - setMaxSize(size, size); - - getStyleClass().clear(); - getStyleClass().add("action_box"); - getStyleClass().add("action_box_"+row+"_"+col); - - setIcon(null); - - setOnMouseClicked(touchEvent -> actionClicked()); - - setOnMousePressed(TouchEvent -> { - if(action != null) - { - getStyleClass().add("action_box_onclick"); + public void baseInit() { + (this.displayTextLabel = new Label()).setWrapText(true); + this.displayTextLabel.setTextAlignment(TextAlignment.CENTER); + this.displayTextLabel.getStyleClass().add((Object)"action_box_display_text_label"); + this.displayTextLabel.prefHeightProperty().bind((ObservableValue)this.heightProperty()); + this.displayTextLabel.prefWidthProperty().bind((ObservableValue)this.widthProperty()); + this.statusIcon = new FontIcon("fas-exclamation-triangle"); + this.statusIcon.getStyleClass().add((Object)"action_box_error_icon"); + this.statusIcon.setOpacity(0.0); + this.statusIcon.setCache(true); + this.statusIcon.setCacheHint(CacheHint.SPEED); + this.statusIcon.setIconSize(this.size - 30); + this.getChildren().addAll((Object[])new Node[] { (Node)this.statusIcon, (Node)this.displayTextLabel }); + this.setMinSize((double)this.size, (double)this.size); + this.setMaxSize((double)this.size, (double)this.size); + this.getStyleClass().clear(); + this.getStyleClass().add((Object)"action_box"); + this.getStyleClass().add(invokedynamic(makeConcatWithConstants:(II)Ljava/lang/String;, this.row, this.col)); + this.setIcon(null); + this.setOnMouseClicked(touchEvent -> this.actionClicked()); + this.setOnMousePressed(TouchEvent -> { + if (this.action != null) { + this.getStyleClass().add((Object)"action_box_onclick"); } }); - setOnMouseReleased(TouchEvent ->{ - if(action != null) - { - getStyleClass().remove("action_box_onclick"); + this.setOnMouseReleased(TouchEvent -> { + if (this.action != null) { + this.getStyleClass().remove((Object)"action_box_onclick"); } }); - - statusIconAnimation = new Timeline( - new KeyFrame( - Duration.millis(0.0D), - new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)), - new KeyFrame( - Duration.millis(100.0D), - new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)), - new KeyFrame( - Duration.millis(600.0D), - new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)), - new KeyFrame( - Duration.millis(700.0D), - new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT)) - ); - - statusIconAnimation.setOnFinished(event -> { - statusIcon.toBack(); - }); - - setCache(true); - setCacheHint(CacheHint.QUALITY); + (this.statusIconAnimation = new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.statusIcon.opacityProperty(), (Object)0.0, Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(100.0), new KeyValue[] { new KeyValue((WritableValue)this.statusIcon.opacityProperty(), (Object)1.0, Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.statusIcon.opacityProperty(), (Object)1.0, Interpolator.EASE_OUT) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.statusIcon.opacityProperty(), (Object)0.0, Interpolator.EASE_OUT) }) })).setOnFinished(event -> this.statusIcon.toBack()); + this.setCache(true); + this.setCacheHint(CacheHint.QUALITY); } - - public void actionClicked() - { - if(action!=null) - { - if(action.getActionType() == ActionType.FOLDER) - { - getActionGridPaneListener().renderFolder(action.getID()); + + public void actionClicked() { + if (this.action != null) { + if (this.action.getActionType() == ActionType.FOLDER) { + this.getActionGridPaneListener().renderFolder(this.action.getID()); } - else - { - if(!getActionGridPaneListener().isConnected()) - { - try - { - if(Config.getInstance().isTryConnectingWhenActionClicked()) - { - clientListener.setupClientConnection(this::actionClicked); + else { + if (!this.getActionGridPaneListener().isConnected()) { + try { + if (Config.getInstance().isTryConnectingWhenActionClicked()) { + this.clientListener.setupClientConnection(this::actionClicked); } - else - { - exceptionAndAlertHandler.handleMinorException(new MinorException("Not Connected", "Not Connected to any Server")); + else { + this.exceptionAndAlertHandler.handleMinorException(new MinorException("Not Connected", "Not Connected to any Server")); } return; } - catch (SevereException e) - { - exceptionAndAlertHandler.handleSevereException(e); + catch (SevereException e) { + this.exceptionAndAlertHandler.handleSevereException(e); } } - - if(action.getActionType() == ActionType.COMBINE || action.getActionType() == ActionType.NORMAL) - { - getActionGridPaneListener().normalOrCombineActionClicked(action.getID()); + if (this.action.getActionType() == ActionType.COMBINE || this.action.getActionType() == ActionType.NORMAL) { + this.getActionGridPaneListener().normalOrCombineActionClicked(this.action.getID()); } - else if(action.getActionType() == ActionType.TOGGLE) - { - toggle(); - getActionGridPaneListener().toggleActionClicked(action.getID(), getCurrentToggleStatus()); + else if (this.action.getActionType() == ActionType.TOGGLE) { + this.toggle(); + this.getActionGridPaneListener().toggleActionClicked(this.action.getID(), this.getCurrentToggleStatus()); } } } + try { + this.playActionAnimation(); + } + catch (SevereException e) { + Logger.getLogger("").warning(e.getMessage()); + } } - - private Timeline statusIconAnimation; - + public Timeline getStatusIconAnimation() { - return statusIconAnimation; + return this.statusIconAnimation; } - + public ActionGridPaneListener getActionGridPaneListener() { - return actionGridPaneListener; + return this.actionGridPaneListener; } - - private int size; - private ActionGridPaneListener actionGridPaneListener; - private ClientListener clientListener; - - public ActionBox(int size, ExceptionAndAlertHandler exceptionAndAlertHandler, - ClientListener clientListener, ActionGridPaneListener actionGridPaneListener, int row, int col) - { + + public ActionBox(final int size, final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener, final ActionGridPaneListener actionGridPaneListener, final int row, final int col) { + this.action = null; + this.fontIcon = null; this.actionGridPaneListener = actionGridPaneListener; this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.size = size; @@ -200,285 +173,249 @@ public ActionBox(int size, ExceptionAndAlertHandler exceptionAndAlertHandler, this.col = col; this.clientListener = clientListener; this.logger = Logger.getLogger(""); - - baseInit(); + this.baseInit(); } - - public Logger getLogger() - { - return logger; + + public Logger getLogger() { + return this.logger; } - - public void setIcon(byte[] iconByteArray) - { - removeFontIcon(); - - if(iconByteArray == null) - { - getStyleClass().remove("action_box_icon_present"); - getStyleClass().add("action_box_icon_not_present"); - setBackground(null); + + public void setIcon(final byte[] iconByteArray) { + this.removeFontIcon(); + if (iconByteArray == null) { + this.getStyleClass().remove((Object)"action_box_icon_present"); + this.getStyleClass().add((Object)"action_box_icon_not_present"); + this.setBackground((Background)null); } - else - { - getStyleClass().add("action_box_icon_present"); - getStyleClass().remove("action_box_icon_not_present"); - - - setBackground( - new Background( - new BackgroundImage(new Image( - new ByteArrayInputStream(iconByteArray), size, size, false, true - ), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, - - new BackgroundSize(100, 100, true, true, true, false)) - ) - ); + else { + this.getStyleClass().add((Object)"action_box_icon_present"); + this.getStyleClass().remove((Object)"action_box_icon_not_present"); + this.setBackground(new Background(new BackgroundImage[] { new BackgroundImage(new Image((InputStream)new ByteArrayInputStream(iconByteArray), (double)this.size, (double)this.size, false, true), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, new BackgroundSize(100.0, 100.0, true, true, true, false)) })); } } - - private Action action = null; public Action getAction() { - return action; + return this.action; } - - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - private String parent; - + public String getStreamPiParent() { - return parent; + return this.parent; } - - public void setStreamPiParent(String parent) { + + public void setStreamPiParent(final String parent) { this.parent = parent; } - - public void setAction(Action action) - { + + public void setAction(final Action action) { this.action = action; } - - public void init() - { - setBackground(null); - setStyle(null); - displayTextLabel.setStyle(null); - - - if(getAction().isShowDisplayText()) - { - setDisplayTextAlignment(action.getDisplayTextAlignment()); - setDisplayTextFontColourAndSize(action.getDisplayTextFontColourHex()); - setDisplayTextLabel(getAction().getDisplayText()); + + public void init() { + this.setBackground((Background)null); + this.setStyle((String)null); + this.displayTextLabel.setStyle((String)null); + if (this.getAction().isShowDisplayText()) { + this.setDisplayTextAlignment(this.action.getDisplayTextAlignment()); + this.setDisplayTextFontColourAndSize(this.action.getDisplayTextFontColourHex()); + this.setDisplayTextLabel(this.getAction().getDisplayText()); } - else - setDisplayTextLabel(""); - - setBackgroundColour(action.getBgColourHex()); - - try - { - if(action.getActionType() == ActionType.TOGGLE) - { - toggle(getCurrentToggleStatus()); + else { + this.setDisplayTextLabel(""); + } + this.setBackgroundColour(this.action.getBgColourHex()); + try { + if (this.action.getActionType() == ActionType.TOGGLE) { + this.toggle(this.getCurrentToggleStatus()); } - else - { - if(action.isHasIcon()) - { - if(!action.getCurrentIconState().isBlank()) - { - setIcon(action.getCurrentIcon()); - } - } - else - { - setIcon(null); + else if (this.action.isHasIcon()) { + if (!this.action.getCurrentIconState().isBlank()) { + this.setIcon(this.action.getCurrentIcon()); } } + else { + this.setIcon(null); + } } - catch (Exception e) - { + catch (Exception e) { e.printStackTrace(); } } - - - public void setCurrentToggleStatus(boolean currentToggleStatus) - { - if(getAction() != null) - getAction().setCurrentToggleStatus(currentToggleStatus); + + public void setCurrentToggleStatus(final boolean currentToggleStatus) { + if (this.getAction() != null) { + this.getAction().setCurrentToggleStatus(currentToggleStatus); + } } - - public boolean getCurrentToggleStatus() - { - if(getAction() == null) - return false; - - return getAction().getCurrentToggleStatus(); + + public boolean getCurrentToggleStatus() { + return this.getAction() != null && this.getAction().getCurrentToggleStatus(); } - - public void toggle() - { - setCurrentToggleStatus(!getCurrentToggleStatus()); - - toggle(getCurrentToggleStatus()); + + public void toggle() { + this.setCurrentToggleStatus(!this.getCurrentToggleStatus()); + this.toggle(this.getCurrentToggleStatus()); } - - public void toggle(boolean isON) - { - String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__"); - - boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true"); - boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true"); - - if(isON) // ON - { - if(action.isHasIcon()) - { - boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on"); - - if(isToggleOnPresent) - { - if(isToggleOnHidden) - { - setDefaultToggleIcon(true); + + public void toggle(final boolean isON) { + final String[] toggleStatesHiddenStatus = this.action.getCurrentIconState().split("__"); + final boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true"); + final boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true"); + if (isON) { + if (this.action.isHasIcon()) { + final boolean isToggleOnPresent = this.action.getIcons().containsKey("toggle_on"); + if (isToggleOnPresent) { + if (isToggleOnHidden) { + this.setDefaultToggleIcon(true); } - else - { - setIcon(action.getIcons().get("toggle_on")); + else { + this.setIcon(this.action.getIcons().get("toggle_on")); } } - else - { - setDefaultToggleIcon(true); + else { + this.setDefaultToggleIcon(true); } } - else - { - setDefaultToggleIcon(true); + else { + this.setDefaultToggleIcon(true); } } - else // OFF - { - if(action.isHasIcon()) - { - boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off"); - - if(isToggleOffPresent) - { - if(isToggleOffHidden) - { - setDefaultToggleIcon(false); - } - else - { - setIcon(action.getIcons().get("toggle_off")); - } + else if (this.action.isHasIcon()) { + final boolean isToggleOffPresent = this.action.getIcons().containsKey("toggle_off"); + if (isToggleOffPresent) { + if (isToggleOffHidden) { + this.setDefaultToggleIcon(false); } - else - { - setDefaultToggleIcon(false); + else { + this.setIcon(this.action.getIcons().get("toggle_off")); } } - else - { - setDefaultToggleIcon(false); + else { + this.setDefaultToggleIcon(false); } } + else { + this.setDefaultToggleIcon(false); + } } - - - public void setDefaultToggleIcon(boolean isToggleOn) - { + + public void setDefaultToggleIcon(final boolean isToggleOn) { String styleClass; - - if(isToggleOn) - { + if (isToggleOn) { styleClass = "action_box_toggle_on"; } - else - { + else { styleClass = "action_box_toggle_off"; } - - - setBackground(null); - - - if(fontIcon!=null) - { - fontIcon.getStyleClass().removeIf(s -> s.equals("action_box_toggle_off") || s.equals("action_box_toggle_on")); + this.setBackground((Background)null); + if (this.fontIcon != null) { + this.fontIcon.getStyleClass().removeIf(s -> s.equals("action_box_toggle_off") || s.equals("action_box_toggle_on")); } - else - { - fontIcon = new FontIcon(); - fontIcon.setIconSize((int) (size * 0.8)); - getChildren().add(fontIcon); + else { + (this.fontIcon = new FontIcon()).setIconSize((int)(this.size * 0.8)); + this.getChildren().add((Object)this.fontIcon); } - - fontIcon.getStyleClass().add(styleClass); - - fontIcon.toBack(); + this.fontIcon.getStyleClass().add((Object)styleClass); + this.fontIcon.toBack(); } - - public void removeFontIcon() - { - if(fontIcon!=null) - { - getChildren().remove(fontIcon); - fontIcon = null; + + public void removeFontIcon() { + if (this.fontIcon != null) { + this.getChildren().remove((Object)this.fontIcon); + this.fontIcon = null; } } - - FontIcon fontIcon = null; - - public void animateStatus() - { - statusIcon.toFront(); - statusIconAnimation.play(); + + public void animateStatus() { + this.statusIcon.toFront(); + this.statusIconAnimation.play(); } - - public void setDisplayTextLabel(String text) - { - displayTextLabel.setText(text); + + public void setDisplayTextLabel(final String text) { + this.displayTextLabel.setText(text); } - - public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment) - { - if(displayTextAlignment == DisplayTextAlignment.CENTER) - displayTextLabel.setAlignment(Pos.CENTER); - else if (displayTextAlignment == DisplayTextAlignment.BOTTOM) - displayTextLabel.setAlignment(Pos.BOTTOM_CENTER); - else if (displayTextAlignment == DisplayTextAlignment.TOP) - displayTextLabel.setAlignment(Pos.TOP_CENTER); + + public void setDisplayTextAlignment(final DisplayTextAlignment displayTextAlignment) { + if (displayTextAlignment == DisplayTextAlignment.CENTER) { + this.displayTextLabel.setAlignment(Pos.CENTER); + } + else if (displayTextAlignment == DisplayTextAlignment.BOTTOM) { + this.displayTextLabel.setAlignment(Pos.BOTTOM_CENTER); + } + else if (displayTextAlignment == DisplayTextAlignment.TOP) { + this.displayTextLabel.setAlignment(Pos.TOP_CENTER); + } } - - public void setDisplayTextFontColourAndSize(String colour) - { + + public void setDisplayTextFontColourAndSize(final String colour) { String totalStyle = ""; - if(!colour.isEmpty()) - { - totalStyle+="-fx-text-fill : "+colour+";"; + if (!colour.isEmpty()) { + totalStyle = invokedynamic(makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;, totalStyle, colour); } - - if(getAction().getNameFontSize() > -1) - { - totalStyle+="-fx-font-size: "+getAction().getNameFontSize()+";"; + if (this.getAction().getNameFontSize() > -1.0) { + totalStyle = invokedynamic(makeConcatWithConstants:(Ljava/lang/String;D)Ljava/lang/String;, totalStyle, this.getAction().getNameFontSize()); } - - if(!totalStyle.isBlank()) - { - displayTextLabel.setStyle(totalStyle); + if (!totalStyle.isBlank()) { + this.displayTextLabel.setStyle(totalStyle); } } - - - public void setBackgroundColour(String colour) - { - if(!colour.isEmpty()) - setStyle("-fx-background-color : "+colour); + + public void playActionAnimation() throws SevereException { + final Config config = Config.getInstance(); + final String currentAnimationName = config.getCurrentAnimationName(); + switch (currentAnimationName) { + case "None": { + break; + } + case "Flip": { + new Flip((Node)this.getChildren().get(1)).play(); + break; + } + case "Bounce": { + new Bounce((Node)this.getChildren().get(1)).play(); + break; + } + case "Jack In The Box": { + new JackInTheBox((Node)this.getChildren().get(1)).play(); + break; + } + case "Swing": { + new Swing((Node)this.getChildren().get(1)).play(); + break; + } + case "Jello": { + new Jello((Node)this.getChildren().get(1)).play(); + break; + } + case "Pulse": { + new Pulse((Node)this.getChildren().get(1)).play(); + break; + } + case "RubberBand": { + new RubberBand((Node)this.getChildren().get(1)).play(); + break; + } + case "Shake": { + new Shake((Node)this.getChildren().get(1)).play(); + break; + } + case "Tada": { + new Tada((Node)this.getChildren().get(1)).play(); + break; + } + case "Wobble": { + new Wobble((Node)this.getChildren().get(1)).play(); + break; + } + default: { + Logger.getLogger("").warning("Invalid Option/n Please contact quimodotcom to solve this error!"); + break; + } + } + } + + public void setBackgroundColour(final String colour) { + if (!colour.isEmpty()) { + this.setStyle(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, colour)); + } } } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java index 1eafe151..ebecfb33 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java @@ -1,459 +1,316 @@ -package com.stream_pi.client.window.dashboard.actiongridpane; +// +// Decompiled by Procyon v0.5.36 +// -import java.util.logging.Logger; +package com.stream_pi.client.window.dashboard.actiongridpane; -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; +import javafx.scene.input.MouseEvent; import com.stream_pi.action_api.action.Location; -import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.action_api.action.ActionType; +import javafx.geometry.Orientation; 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.window.ExceptionAndAlertHandler; +import java.util.Iterator; import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.exception.SevereException; -import javafx.concurrent.Task; -import javafx.geometry.Insets; -import javafx.geometry.Orientation; -import javafx.geometry.Pos; +import org.kordamp.ikonli.javafx.FontIcon; +import javafx.scene.layout.StackPane; +import com.stream_pi.action_api.action.Action; import javafx.scene.CacheHint; +import javafx.scene.layout.VBox; +import javafx.scene.layout.Priority; +import javafx.geometry.Pos; +import javafx.beans.value.ObservableValue; +import javafx.geometry.Insets; +import java.util.logging.Logger; import javafx.scene.Node; -import javafx.scene.control.ScrollPane; +import com.stream_pi.client.profile.ClientProfile; import javafx.scene.layout.GridPane; -import javafx.scene.layout.Priority; -import javafx.scene.layout.StackPane; -import javafx.scene.layout.VBox; -import org.kordamp.ikonli.javafx.FontIcon; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import javafx.scene.control.ScrollPane; public class ActionGridPane extends ScrollPane implements ActionGridPaneListener { - private ExceptionAndAlertHandler exceptionAndAlertHandler; - private ClientListener clientListener; - private ActionBox[][] actionBoxes; - private GridPane actionsGridPane; - - public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) - { + private String currentParent; + private int rows; + private int cols; + private ClientProfile clientProfile; + private boolean isFreshRender; + private Node folderBackButton; + private Logger logger; + private String previousParent; + + public ActionGridPane(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener) { + this.isFreshRender = true; + this.folderBackButton = null; this.clientListener = clientListener; - - logger = Logger.getLogger(ActionGridPane.class.getName()); + this.logger = Logger.getLogger(ActionGridPane.class.getName()); this.exceptionAndAlertHandler = exceptionAndAlertHandler; - - getStyleClass().add("action_grid_pane_parent"); - - actionsGridPane = new GridPane(); - actionsGridPane.setPadding(new Insets(5.0)); - actionsGridPane.getStyleClass().add("action_grid_pane"); - actionsGridPane.prefWidthProperty().bind(widthProperty().subtract(20)); - actionsGridPane.prefHeightProperty().bind(heightProperty().subtract(20)); - - setContent(actionsGridPane); - - actionsGridPane.setAlignment(Pos.CENTER); - - - VBox.setVgrow(this, Priority.ALWAYS); - - setCache(true); - setCacheHint(CacheHint.SPEED); + this.getStyleClass().add((Object)"action_grid_pane_parent"); + (this.actionsGridPane = new GridPane()).setPadding(new Insets(5.0)); + this.actionsGridPane.getStyleClass().add((Object)"action_grid_pane"); + this.actionsGridPane.prefWidthProperty().bind((ObservableValue)this.widthProperty().subtract(20)); + this.actionsGridPane.prefHeightProperty().bind((ObservableValue)this.heightProperty().subtract(20)); + this.setContent((Node)this.actionsGridPane); + this.actionsGridPane.setAlignment(Pos.CENTER); + VBox.setVgrow((Node)this, Priority.ALWAYS); + this.setCache(true); + this.setCacheHint(CacheHint.SPEED); } - - private String currentParent; - - public void setCurrentParent(String currentParent) { + + public void setCurrentParent(final String currentParent) { this.currentParent = currentParent; } - + public ClientProfile getClientProfile() { - return clientProfile; + return this.clientProfile; } - - private int rows, cols; - - private ClientProfile clientProfile; - - public void setClientProfile(ClientProfile clientProfile) - { + + public void setClientProfile(final ClientProfile clientProfile) { this.clientProfile = clientProfile; - - setCurrentParent("root"); - setRows(clientProfile.getRows()); - setCols(clientProfile.getCols()); + this.setCurrentParent("root"); + this.setRows(clientProfile.getRows()); + this.setCols(clientProfile.getCols()); } - - public void actionFailed(String profileID, String actionID) - { - if(getClientProfile().getID().equals(profileID)) - { - Action action = getClientProfile().getActionFromID(actionID); - if(action != null) - { - if(currentParent.equals(action.getParent())) - { - failShow(action); + + public void actionFailed(final String profileID, final String actionID) { + if (this.getClientProfile().getID().equals(profileID)) { + final Action action = this.getClientProfile().getActionFromID(actionID); + if (action != null) { + if (this.currentParent.equals(action.getParent())) { + this.failShow(action); } - else - { - if(action.getLocation().getCol() == -1) - { - failShow(getClientProfile().getActionFromID(action.getParent())); - } + else if (action.getLocation().getCol() == -1) { + this.failShow(this.getClientProfile().getActionFromID(action.getParent())); } } } } - - public void failShow(Action action) - { - actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus(); + + public void failShow(final Action action) { + this.actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus(); } - - + public String getCurrentParent() { - return currentParent; + return this.currentParent; } - - public StackPane getFolderBackButton() - { - StackPane stackPane = new StackPane(); - stackPane.getStyleClass().add("action_box"); - stackPane.getStyleClass().add("action_box_valid"); - - stackPane.setPrefSize( - getClientProfile().getActionSize(), - getClientProfile().getActionSize() - ); - - FontIcon fontIcon = new FontIcon("fas-chevron-left"); - fontIcon.getStyleClass().add("folder_action_back_button_icon"); - fontIcon.setIconSize(getClientProfile().getActionSize() - 30); - + + public StackPane getFolderBackButton() { + final StackPane stackPane = new StackPane(); + stackPane.getStyleClass().add((Object)"action_box"); + stackPane.getStyleClass().add((Object)"action_box_valid"); + stackPane.setPrefSize((double)this.getClientProfile().getActionSize(), (double)this.getClientProfile().getActionSize()); + final FontIcon fontIcon = new FontIcon("fas-chevron-left"); + fontIcon.getStyleClass().add((Object)"folder_action_back_button_icon"); + fontIcon.setIconSize(this.getClientProfile().getActionSize() - 30); stackPane.setAlignment(Pos.CENTER); - stackPane.getChildren().add(fontIcon); - - stackPane.setOnMouseClicked(e->returnToPreviousParent()); - + stackPane.getChildren().add((Object)fontIcon); + stackPane.setOnMouseClicked(e -> this.returnToPreviousParent()); return stackPane; } - - private boolean isFreshRender = true; - private Node folderBackButton = null; - public void renderGrid() - { - actionsGridPane.setHgap(getClientProfile().getActionGap()); - actionsGridPane.setVgap(getClientProfile().getActionGap()); - - if(isFreshRender) - { - clear(); - actionBoxes = new ActionBox[cols][rows]; + + public void renderGrid() { + this.actionsGridPane.setHgap((double)this.getClientProfile().getActionGap()); + this.actionsGridPane.setVgap((double)this.getClientProfile().getActionGap()); + if (this.isFreshRender) { + this.clear(); + this.actionBoxes = new ActionBox[this.cols][this.rows]; } - boolean isFolder = false; - - if(getCurrentParent().equals("root")) - { - if(folderBackButton != null) - { - actionsGridPane.getChildren().remove(folderBackButton); - folderBackButton = null; - - actionBoxes[0][0] = addBlankActionBox(0,0); + if (this.getCurrentParent().equals("root")) { + if (this.folderBackButton != null) { + this.actionsGridPane.getChildren().remove((Object)this.folderBackButton); + this.folderBackButton = null; + this.actionBoxes[0][0] = this.addBlankActionBox(0, 0); } } - else - { + else { isFolder = true; - - if(folderBackButton != null) - { - actionsGridPane.getChildren().remove(folderBackButton); - folderBackButton = null; + if (this.folderBackButton != null) { + this.actionsGridPane.getChildren().remove((Object)this.folderBackButton); + this.folderBackButton = null; } - else - { - actionsGridPane.getChildren().remove(actionBoxes[0][0]); + else { + this.actionsGridPane.getChildren().remove((Object)this.actionBoxes[0][0]); } - - folderBackButton = getFolderBackButton(); - actionsGridPane.add(folderBackButton, 0,0); + this.folderBackButton = (Node)this.getFolderBackButton(); + this.actionsGridPane.add(this.folderBackButton, 0, 0); } - - for(int row = 0; row= rows || action.getLocation().getCol() >= cols) - { - throw new MinorException("Action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" + - " Consider increasing rows/cols from client settings and relocating/deleting it."); + if (action.getLocation().getRow() >= this.rows || action.getLocation().getCol() >= this.cols) { + throw new MinorException(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;, action.getDisplayText(), action.getID())); } - - - Location location = action.getLocation(); - - if( getClientProfile().getCols() < location.getCol() || getClientProfile().getRows() < location.getRow()) + final Location location = action.getLocation(); + if (this.getClientProfile().getCols() < location.getCol() || this.getClientProfile().getRows() < location.getRow()) { return; - - ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()]; - - if(actionBox.getAction()!=null) - { - if(!actionBox.getAction().getID().equals(action.getID())) - { + } + final ActionBox actionBox = this.actionBoxes[location.getCol()][location.getRow()]; + if (actionBox.getAction() != null) { + if (!actionBox.getAction().getID().equals(action.getID())) { actionBox.clear(); } } - else - { + else { actionBox.clear(); } - - - boolean oldToggleStatus = action.getCurrentToggleStatus(); - - + final boolean oldToggleStatus = action.getCurrentToggleStatus(); actionBox.setAction(action); - - actionBox.setCurrentToggleStatus(oldToggleStatus); - - - actionBox.setStreamPiParent(currentParent); + actionBox.setStreamPiParent(this.currentParent); actionBox.init(); - - /*ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), action, exceptionAndAlertHandler, this, location.getRow(), location.getCol()); - - actionBox.setStreamPiParent(currentParent); - - clearActionBox(location.getCol(), location.getRow()); - - System.out.println(location.getCol()+","+location.getRow()); - add(actionBox, location.getRow(), location.getCol()); - - actionBoxes[location.getCol()][location.getRow()] = actionBox;*/ } - - public void setRows(int rows) - { + + public void setRows(final int rows) { this.rows = rows; } - - public void setCols(int cols) - { + + public void setCols(final int cols) { this.cols = cols; } - - public int getRows() - { - return rows; + + public int getRows() { + return this.rows; } - - public int getCols() - { - return cols; + + public int getCols() { + return this.cols; } - - private String previousParent; - - public void setPreviousParent(String previousParent) { + + public void setPreviousParent(final String previousParent) { this.previousParent = previousParent; } - + public String getPreviousParent() { - return previousParent; + return this.previousParent; } - - @Override - public void renderFolder(String actionID) { - setCurrentParent(clientProfile.getActionFromID(actionID).getID()); - setPreviousParent(clientProfile.getActionFromID(actionID).getParent()); - renderGrid(); - renderActions(); + + public void renderFolder(final String actionID) { + this.setCurrentParent(this.clientProfile.getActionFromID(actionID).getID()); + this.setPreviousParent(this.clientProfile.getActionFromID(actionID).getParent()); + this.renderGrid(); + this.renderActions(); } - - @Override - public void normalOrCombineActionClicked(String ID) - { - clientListener.onActionClicked(getClientProfile().getID(), ID, false); + + public void normalOrCombineActionClicked(final String ID) { + this.clientListener.onActionClicked(this.getClientProfile().getID(), ID, false); } - - @Override - public void toggleActionClicked(String ID, boolean toggleState) - { - clientListener.onActionClicked(getClientProfile().getID(), ID, toggleState); + + public void toggleActionClicked(final String ID, final boolean toggleState) { + this.clientListener.onActionClicked(this.getClientProfile().getID(), ID, toggleState); } - - @Override - public ActionBox getActionBoxByLocation(Location location) - { - return getActionBox(location.getCol(), location.getRow()); + + public ActionBox getActionBoxByLocation(final Location location) { + return this.getActionBox(location.getCol(), location.getRow()); } - - - @Override - public boolean isConnected() - { - return clientListener.isConnected(); + + public boolean isConnected() { + return this.clientListener.isConnected(); } - - - public void returnToPreviousParent() - { - setCurrentParent(getPreviousParent()); - - if(!getPreviousParent().equals("root")) - { - System.out.println("parent : "+getPreviousParent()); - setPreviousParent(getClientProfile().getActionFromID( - getPreviousParent() - ).getParent()); + + public void returnToPreviousParent() { + this.setCurrentParent(this.getPreviousParent()); + if (!this.getPreviousParent().equals("root")) { + System.out.println(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, this.getPreviousParent())); + this.setPreviousParent(this.getClientProfile().getActionFromID(this.getPreviousParent()).getParent()); } - - renderGrid(); - renderActions(); + this.renderGrid(); + this.renderActions(); } } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java index a8290f4c..b845657b 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java @@ -1,17 +1,20 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.dashboard.actiongridpane; -import com.stream_pi.action_api.action.Action; import com.stream_pi.action_api.action.Location; -import com.stream_pi.action_api.otheractions.FolderAction; public interface ActionGridPaneListener { - void renderFolder(String ID); - - void normalOrCombineActionClicked(String ID); - void toggleActionClicked(String ID, boolean toggleState); - - ActionBox getActionBoxByLocation(Location location); - + void renderFolder(final String p0); + + void normalOrCombineActionClicked(final String p0); + + void toggleActionClicked(final String p0, final boolean p1); + + ActionBox getActionBoxByLocation(final Location p0); + boolean isConnected(); } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java index 9060a0d7..30c1fdd3 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java @@ -1,174 +1,135 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.firsttimeuse; -import com.gluonhq.attach.orientation.OrientationService; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; +import javafx.concurrent.Task; +import javafx.event.ActionEvent; import com.stream_pi.util.alert.StreamPiAlert; import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.uihelper.HBoxInputBox; - -import javafx.application.Platform; -import javafx.concurrent.Task; import javafx.geometry.Orientation; -import javafx.scene.control.Button; +import com.gluonhq.attach.orientation.OrientationService; +import com.stream_pi.client.profile.ClientProfile; +import java.io.File; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.io.Config; +import javafx.application.Platform; +import com.stream_pi.util.uihelper.HBoxInputBox; +import javafx.scene.Node; +import javafx.scene.layout.Priority; import javafx.scene.control.Label; -import javafx.scene.control.ScrollPane; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import javafx.scene.control.Button; import javafx.scene.control.TextField; -import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; -import javax.xml.transform.TransformerException; -import java.io.File; - public class FinalConfigPane extends VBox { private TextField clientNicknameTextField; private TextField serverIPHostNameTextField; private TextField serverPortTextField; private Button nextButton; - private ExceptionAndAlertHandler exceptionAndAlertHandler; private ClientListener clientListener; - - public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener, - Button nextButton) - { + private int rowsToSet; + private int colsToSet; + + public FinalConfigPane(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener, final Button nextButton) { this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.clientListener = clientListener; this.nextButton = nextButton; - - getStyleClass().add("first_time_use_pane_final_config"); - - Label label = new Label("That's it. Now just a little bit and then you're set!"); + this.getStyleClass().add((Object)"first_time_use_pane_final_config"); + final Label label = new Label("That's it. Now just a little bit and then you're set!"); label.setWrapText(true); - VBox.setVgrow(label, Priority.ALWAYS); - label.getStyleClass().add("first_time_use_pane_final_config_label"); - - clientNicknameTextField = new TextField(); - serverIPHostNameTextField = new TextField(); - serverPortTextField = new TextField(); - - HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField, 150); - HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField, 150); - HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField, 150); - - getChildren().addAll(label, clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox); - - setSpacing(10.0); - - setVisible(false); + VBox.setVgrow((Node)label, Priority.ALWAYS); + label.getStyleClass().add((Object)"first_time_use_pane_final_config_label"); + this.clientNicknameTextField = new TextField(); + this.serverIPHostNameTextField = new TextField(); + this.serverPortTextField = new TextField(); + final HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", this.clientNicknameTextField, 150); + final HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", this.serverIPHostNameTextField, 150); + final HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", this.serverPortTextField, 150); + this.getChildren().addAll((Object[])new Node[] { (Node)label, (Node)clientNickNameInputBox, (Node)serverIPHostNameInputBox, (Node)serverIPPortInputBox }); + this.setSpacing(10.0); + this.setVisible(false); } - - public void makeChangesToNextButton() - { - nextButton.setText("Confirm"); - nextButton.setOnAction(actionEvent -> new Thread(new Task() { - @Override - protected Void call() - { - onConfirmButtonClicked(); + + public void makeChangesToNextButton() { + this.nextButton.setText("Confirm"); + this.nextButton.setOnAction(actionEvent -> new Thread((Runnable)new Task() { + protected Void call() { + FinalConfigPane.this.onConfirmButtonClicked(); return null; } }).start()); } - - private void onConfirmButtonClicked() - { - Platform.runLater(()->nextButton.setDisable(true)); - - StringBuilder errors = new StringBuilder(); - - if(clientNicknameTextField.getText().isBlank()) - { + + private void onConfirmButtonClicked() { + Platform.runLater(() -> this.nextButton.setDisable(true)); + final StringBuilder errors = new StringBuilder(); + if (this.clientNicknameTextField.getText().isBlank()) { errors.append("* Nick name cannot be blank.\n"); } - - if(serverIPHostNameTextField.getText().isBlank()) - { + if (this.serverIPHostNameTextField.getText().isBlank()) { errors.append("* Server IP cannot be empty.\n"); } - int port = -1; - try - { - port = Integer.parseInt(serverPortTextField.getText()); - - if(port < 1024) + try { + port = Integer.parseInt(this.serverPortTextField.getText()); + if (port < 1024) { 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"); + } } - catch (NumberFormatException exception) - { + catch (NumberFormatException exception) { errors.append("* Server Port should be a number.\n"); } - - if(errors.toString().isEmpty()) - { - try - { - Config.getInstance().setNickName(clientNicknameTextField.getText()); - Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText()); + if (errors.toString().isEmpty()) { + try { + Config.getInstance().setNickName(this.clientNicknameTextField.getText()); + Config.getInstance().setServerHostNameOrIP(this.serverIPHostNameTextField.getText()); Config.getInstance().setServerPort(port); Config.getInstance().setFirstTimeUse(false); - - if(ClientInfo.getInstance().isPhone()) - { + if (ClientInfo.getInstance().isPhone()) { Config.getInstance().setScreenMoverEnabled(true); } - Config.getInstance().save(); - - ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+ - Config.getInstance().getStartupProfileID()+".xml"), Config.getInstance().getIconsPath()); - - int pre = clientProfile.getActionSize()+(clientProfile.getActionGap()*4); - - - rowsToSet = (int) (clientListener.getStageHeight()/pre); - colsToSet = (int) (clientListener.getStageWidth()/pre); - - if(ClientInfo.getInstance().isPhone()) - { + final ClientProfile clientProfile = new ClientProfile(new File(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;, Config.getInstance().getProfilesPath(), Config.getInstance().getStartupProfileID())), Config.getInstance().getIconsPath()); + final int pre = clientProfile.getActionSize() + clientProfile.getActionGap() * 4; + this.rowsToSet = (int)(this.clientListener.getStageHeight() / pre); + this.colsToSet = (int)(this.clientListener.getStageWidth() / pre); + if (ClientInfo.getInstance().isPhone()) { + int tmp; OrientationService.create().ifPresent(orientationService -> { - if(orientationService.getOrientation().isPresent() && - orientationService.getOrientation().get().equals(Orientation.VERTICAL)) - { - int tmp = rowsToSet; - rowsToSet = colsToSet; - colsToSet = tmp; + if (orientationService.getOrientation().isPresent() && ((Orientation)orientationService.getOrientation().get()).equals((Object)Orientation.VERTICAL)) { + tmp = this.rowsToSet; + this.rowsToSet = this.colsToSet; + this.colsToSet = tmp; } + return; }); } - - clientProfile.setCols(colsToSet); - clientProfile.setRows(rowsToSet); - + clientProfile.setCols(this.colsToSet); + clientProfile.setRows(this.rowsToSet); clientProfile.saveProfileDetails(); - - Platform.runLater(()-> { - clientListener.init(); - clientListener.setupClientConnection(); + Platform.runLater(() -> { + this.clientListener.init(); + this.clientListener.setupClientConnection(); }); } - catch(Exception e) - { + catch (Exception e) { e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(new SevereException(e.getMessage())); + this.exceptionAndAlertHandler.handleSevereException(new SevereException(e.getMessage())); } } - else - { - Platform.runLater(()->nextButton.setDisable(false)); - new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors, StreamPiAlertType.ERROR).show(); + else { + Platform.runLater(() -> this.nextButton.setDisable(false)); + new StreamPiAlert("Uh Oh", invokedynamic(makeConcatWithConstants:(Ljava/lang/StringBuilder;)Ljava/lang/String;, errors), StreamPiAlertType.ERROR).show(); } } - - private int rowsToSet,colsToSet; } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java index 857be4fd..b4cf1cce 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java @@ -1,142 +1,105 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.firsttimeuse; -import com.stream_pi.client.Main; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.window.ExceptionAndAlertHandler; +import javafx.event.ActionEvent; +import javafx.scene.layout.HBox; import com.stream_pi.util.uihelper.SpaceFiller; - +import javafx.scene.Node; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; import javafx.geometry.Insets; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.window.ExceptionAndAlertHandler; import javafx.scene.control.Button; import javafx.scene.control.Label; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; -import javafx.scene.text.Font; - -public class FirstTimeUse extends VBox{ - - - public FirstTimeUse(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) - { - getStyleClass().add("first_time_use_pane"); - - setSpacing(10.0); - setPadding(new Insets(5)); - - headingLabel = new Label(); - headingLabel.getStyleClass().add("first_time_use_pane_heading_label"); - - StackPane stackPane = new StackPane(); - stackPane.getStyleClass().add("first_time_use_pane_stackpane"); - - VBox.setVgrow(stackPane, Priority.ALWAYS); - - nextButton = new Button("Next"); - nextButton.setOnAction(event-> onNextButtonClicked()); - - previousButton = new Button("Previous"); - previousButton.setOnAction(event-> onPreviousButtonClicked()); - - HBox buttonBar = new HBox(previousButton, SpaceFiller.horizontal(), nextButton); - buttonBar.getStyleClass().add("first_time_use_pane_button_bar"); - buttonBar.setSpacing(10.0); - - welcomePane = new WelcomePane(); - licensePane = new LicensePane(); - finalConfigPane = new FinalConfigPane(exceptionAndAlertHandler, clientListener, nextButton); - - stackPane.getChildren().addAll( - welcomePane, - licensePane, - finalConfigPane - ); - - getChildren().addAll(headingLabel, stackPane, buttonBar); - - setWindow(WindowName.WELCOME); - } +public class FirstTimeUse extends VBox +{ private Label headingLabel; private Button nextButton; private Button previousButton; private WelcomePane welcomePane; private LicensePane licensePane; private FinalConfigPane finalConfigPane; - private WindowName windowName; - - private void onNextButtonClicked() - { - if(windowName == WindowName.WELCOME) - { - setWindow(WindowName.LICENSE); + + public FirstTimeUse(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener) { + this.getStyleClass().add((Object)"first_time_use_pane"); + this.setSpacing(10.0); + this.setPadding(new Insets(5.0)); + this.headingLabel = new Label(); + this.headingLabel.getStyleClass().add((Object)"first_time_use_pane_heading_label"); + final StackPane stackPane = new StackPane(); + stackPane.getStyleClass().add((Object)"first_time_use_pane_stackpane"); + VBox.setVgrow((Node)stackPane, Priority.ALWAYS); + (this.nextButton = new Button("Next")).setOnAction(event -> this.onNextButtonClicked()); + (this.previousButton = new Button("Previous")).setOnAction(event -> this.onPreviousButtonClicked()); + final HBox buttonBar = new HBox(new Node[] { (Node)this.previousButton, (Node)SpaceFiller.horizontal(), (Node)this.nextButton }); + buttonBar.getStyleClass().add((Object)"first_time_use_pane_button_bar"); + buttonBar.setSpacing(10.0); + this.welcomePane = new WelcomePane(); + this.licensePane = new LicensePane(); + this.finalConfigPane = new FinalConfigPane(exceptionAndAlertHandler, clientListener, this.nextButton); + stackPane.getChildren().addAll((Object[])new Node[] { (Node)this.welcomePane, (Node)this.licensePane, (Node)this.finalConfigPane }); + this.getChildren().addAll((Object[])new Node[] { (Node)this.headingLabel, (Node)stackPane, (Node)buttonBar }); + this.setWindow(WindowName.WELCOME); + } + + private void onNextButtonClicked() { + if (this.windowName == WindowName.WELCOME) { + this.setWindow(WindowName.LICENSE); } - else if(windowName == WindowName.LICENSE) - { - setWindow(WindowName.FINAL); + else if (this.windowName == WindowName.LICENSE) { + this.setWindow(WindowName.FINAL); } } - - private void onPreviousButtonClicked() - { - nextButton.setText("Next"); - - if(windowName == WindowName.FINAL) - { - setWindow(WindowName.LICENSE); + + private void onPreviousButtonClicked() { + this.nextButton.setText("Next"); + if (this.windowName == WindowName.FINAL) { + this.setWindow(WindowName.LICENSE); } - else if(windowName == WindowName.LICENSE) - { - setWindow(WindowName.WELCOME); + else if (this.windowName == WindowName.LICENSE) { + this.setWindow(WindowName.WELCOME); } } - - private void setWindow(WindowName windowName) - { - if (windowName == WindowName.WELCOME) - { + + private void setWindow(final WindowName windowName) { + if (windowName == WindowName.WELCOME) { this.windowName = WindowName.WELCOME; - welcomePane.toFront(); - welcomePane.setVisible(true); - licensePane.setVisible(false); - finalConfigPane.setVisible(false); - - headingLabel.setText(""); - - nextButton.setText("Next"); - nextButton.setOnAction(event-> onNextButtonClicked()); - previousButton.setVisible(false); + this.welcomePane.toFront(); + this.welcomePane.setVisible(true); + this.licensePane.setVisible(false); + this.finalConfigPane.setVisible(false); + this.headingLabel.setText(""); + this.nextButton.setText("Next"); + this.nextButton.setOnAction(event -> this.onNextButtonClicked()); + this.previousButton.setVisible(false); } - else if (windowName == WindowName.LICENSE) - { + else if (windowName == WindowName.LICENSE) { this.windowName = WindowName.LICENSE; - licensePane.toFront(); - welcomePane.setVisible(false); - licensePane.setVisible(true); - finalConfigPane.setVisible(false); - - headingLabel.setText("License Agreement"); - - nextButton.setText("Agree and Continue"); - nextButton.setOnAction(event-> onNextButtonClicked()); - previousButton.setVisible(true); + this.licensePane.toFront(); + this.welcomePane.setVisible(false); + this.licensePane.setVisible(true); + this.finalConfigPane.setVisible(false); + this.headingLabel.setText("License Agreement"); + this.nextButton.setText("Agree and Continue"); + this.nextButton.setOnAction(event -> this.onNextButtonClicked()); + this.previousButton.setVisible(true); } - else if (windowName == WindowName.FINAL) - { + else if (windowName == WindowName.FINAL) { this.windowName = WindowName.FINAL; - finalConfigPane.toFront(); - welcomePane.setVisible(false); - licensePane.setVisible(false); - finalConfigPane.setVisible(true); - - headingLabel.setText("Finishing up ..."); - - finalConfigPane.makeChangesToNextButton(); - previousButton.setVisible(true); + this.finalConfigPane.toFront(); + this.welcomePane.setVisible(false); + this.licensePane.setVisible(false); + this.finalConfigPane.setVisible(true); + this.headingLabel.setText("Finishing up ..."); + this.finalConfigPane.makeChangesToNextButton(); + this.previousButton.setVisible(true); } } - - - } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java index aa35e97c..f994b115 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java @@ -1,24 +1,25 @@ -package com.stream_pi.client.window.firsttimeuse; +// +// Decompiled by Procyon v0.5.36 +// -import com.stream_pi.client.info.License; +package com.stream_pi.client.window.firsttimeuse; -import javafx.scene.control.Label; -import javafx.scene.control.TextArea; +import javafx.scene.Node; import javafx.scene.layout.Priority; +import javafx.beans.value.ObservableValue; +import javafx.scene.control.TextArea; +import com.stream_pi.client.info.License; import javafx.scene.layout.VBox; -public class LicensePane extends VBox { - public LicensePane() - { - getStyleClass().add("first_time_use_pane_license"); - - TextArea licenseTextArea = new TextArea(License.getLicense()); +public class LicensePane extends VBox +{ + public LicensePane() { + this.getStyleClass().add((Object)"first_time_use_pane_license"); + final TextArea licenseTextArea = new TextArea(License.getLicense()); licenseTextArea.setWrapText(false); licenseTextArea.setEditable(false); - - licenseTextArea.prefWidthProperty().bind(widthProperty()); - VBox.setVgrow(licenseTextArea, Priority.ALWAYS); - - getChildren().addAll(licenseTextArea); + licenseTextArea.prefWidthProperty().bind((ObservableValue)this.widthProperty()); + VBox.setVgrow((Node)licenseTextArea, Priority.ALWAYS); + this.getChildren().addAll((Object[])new Node[] { (Node)licenseTextArea }); } } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java index cb0c59b0..02149c0f 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java @@ -1,29 +1,29 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.firsttimeuse; +import javafx.scene.Node; import javafx.geometry.Pos; import javafx.scene.control.Label; import javafx.scene.layout.VBox; -public class WelcomePane extends VBox{ - public WelcomePane() - { - getStyleClass().add("first_time_use_pane_welcome"); - - Label welcomeLabel = new Label("Welcome!"); +public class WelcomePane extends VBox +{ + public WelcomePane() { + this.getStyleClass().add((Object)"first_time_use_pane_welcome"); + final Label welcomeLabel = new Label("Welcome!"); welcomeLabel.setWrapText(true); welcomeLabel.setAlignment(Pos.CENTER); - welcomeLabel.getStyleClass().add("first_time_use_welcome_pane_welcome_label"); - - Label nextToContinue = new Label("Please click \"Next\" to start the Setup process"); + welcomeLabel.getStyleClass().add((Object)"first_time_use_welcome_pane_welcome_label"); + final Label nextToContinue = new Label("Please click \"Next\" to start the Setup process"); nextToContinue.setWrapText(true); nextToContinue.setAlignment(Pos.CENTER); - nextToContinue.getStyleClass().add("first_time_use_welcome_pane_next_to_continue_label"); - - - setAlignment(Pos.CENTER); - setSpacing(5.0); - getChildren().addAll(welcomeLabel, nextToContinue); - - setVisible(false); + nextToContinue.getStyleClass().add((Object)"first_time_use_welcome_pane_next_to_continue_label"); + this.setAlignment(Pos.CENTER); + this.setSpacing(5.0); + this.getChildren().addAll((Object[])new Node[] { (Node)welcomeLabel, (Node)nextToContinue }); + this.setVisible(false); } } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java index 84a8214f..785195a4 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java @@ -1,5 +1,12 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.firsttimeuse; -public enum WindowName { - WELCOME, LICENSE, FINAL +public enum WindowName +{ + WELCOME, + LICENSE, + FINAL; } diff --git a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java index eaeaccbf..52f2c432 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java @@ -1,173 +1,125 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.settings.About; +import javafx.event.ActionEvent; +import javafx.scene.CacheHint; +import java.io.IOException; +import java.util.logging.Logger; +import javafx.beans.value.ObservableValue; +import java.lang.management.ManagementFactory; +import java.lang.management.GarbageCollectorMXBean; +import javafx.scene.layout.HBox; import com.stream_pi.action_api.ActionAPI; -import com.stream_pi.client.Main; -import com.stream_pi.client.controller.ClientListener; +import javafx.scene.control.Label; import com.stream_pi.client.info.ClientInfo; -import javafx.application.HostServices; +import javafx.scene.control.Hyperlink; +import javafx.scene.layout.Priority; import javafx.event.Event; -import javafx.event.EventHandler; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.*; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; import javafx.scene.input.SwipeEvent; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.management.ManagementFactory; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; +import javafx.scene.control.TabPane; +import javafx.scene.Node; +import javafx.scene.control.Tab; +import javafx.scene.image.ImageView; +import javafx.scene.image.Image; import java.util.Objects; -import java.util.logging.Logger; +import com.stream_pi.client.Main; +import java.io.InputStream; +import javafx.geometry.Pos; +import javafx.geometry.Insets; +import javafx.scene.layout.VBox; +import com.stream_pi.client.controller.ClientListener; +import javafx.scene.control.ScrollPane; public class AboutTab extends ScrollPane { private ClientListener clientListener; - private ContributorsTab contributorsTab; private VBox mainVBox; - - public AboutTab(ClientListener clientListener) - { + + public AboutTab(final ClientListener clientListener) { this.clientListener = clientListener; - - getStyleClass().add("about_parent"); - - setPadding(new Insets(5)); - - mainVBox = new VBox(); - mainVBox.getStyleClass().add("about"); - mainVBox.setSpacing(5.0); - - - mainVBox.setAlignment(Pos.TOP_CENTER); - - Image appIcon = new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))); - ImageView appIconImageView = new ImageView(appIcon); - appIconImageView.setFitHeight(146); - appIconImageView.setFitWidth(132); - - - Tab contributorsT = new Tab("Contributors"); - contributorsTab = new ContributorsTab(); - contributorsT.setContent(contributorsTab); - - - TabPane tabPane = new TabPane(); + this.getStyleClass().add((Object)"about_parent"); + this.setPadding(new Insets(5.0)); + this.mainVBox = new VBox(); + this.mainVBox.getStyleClass().add((Object)"about"); + this.mainVBox.setSpacing(5.0); + this.mainVBox.setAlignment(Pos.TOP_CENTER); + final Image appIcon = new Image((InputStream)Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))); + final ImageView appIconImageView = new ImageView(appIcon); + appIconImageView.setFitHeight(146.0); + appIconImageView.setFitWidth(132.0); + final Tab contributorsT = new Tab("Contributors"); + contributorsT.setContent((Node)(this.contributorsTab = new ContributorsTab())); + final TabPane tabPane = new TabPane(); tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); - - tabPane.getStyleClass().add("settings_about_tab_internal"); + tabPane.getStyleClass().add((Object)"settings_about_tab_internal"); tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); - tabPane.setMaxWidth(600); - VBox.setVgrow(tabPane, Priority.ALWAYS); - - Tab licenseTab = new Tab("License"); - licenseTab.setContent(new LicenseTab()); - - - - Tab contactTab = new Tab("Contact"); - contactTab.setContent(new ContactTab(clientListener)); - - tabPane.getTabs().addAll(licenseTab, contributorsT, contactTab); - - - Hyperlink donateButton = new Hyperlink("DONATE"); - donateButton.setOnAction(event -> openWebpage("https://www.patreon.com/streampi")); - donateButton.getStyleClass().add("about_donate_hyperlink"); - - - ClientInfo clientInfo = ClientInfo.getInstance(); - - Label versionText = new Label(clientInfo.getVersion().getText() + " - "+ clientInfo.getPlatform().getUIName() + " - "+ clientInfo.getReleaseStatus().getUIName()); - versionText.getStyleClass().add("about_version_label"); - - Label commStandardLabel = new Label("Comm Standard "+clientInfo.getCommStandardVersion().getText()); - commStandardLabel.getStyleClass().add("about_comm_standard_label"); - - Label minThemeAPILabel = new Label("Min ThemeAPI "+clientInfo.getMinThemeSupportVersion().getText()); - minThemeAPILabel.getStyleClass().add("about_min_theme_api_label"); - - Label minActionAPILabel = new Label("Min ActionAPI "+clientInfo.getMinPluginSupportVersion().getText()); - minActionAPILabel.getStyleClass().add("about_min_action_api_label"); - - Label currentActionAPILabel = new Label("ActionAPI "+ ActionAPI.API_VERSION.getText()); - currentActionAPILabel.getStyleClass().add("about_current_action_api_label"); - - HBox hBox1 = new HBox(versionText); - + tabPane.setMaxWidth(600.0); + VBox.setVgrow((Node)tabPane, Priority.ALWAYS); + final Tab licenseTab = new Tab("License"); + licenseTab.setContent((Node)new LicenseTab()); + final Tab contactTab = new Tab("Contact"); + contactTab.setContent((Node)new ContactTab(clientListener)); + tabPane.getTabs().addAll((Object[])new Tab[] { licenseTab, contributorsT, contactTab }); + final Hyperlink donateButton = new Hyperlink("DONATE"); + donateButton.setOnAction(event -> this.openWebpage("https://www.patreon.com/streampi")); + donateButton.getStyleClass().add((Object)"about_donate_hyperlink"); + final ClientInfo clientInfo = ClientInfo.getInstance(); + final Label versionText = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;, clientInfo.getVersion().getText(), clientInfo.getPlatform().getUIName(), clientInfo.getReleaseStatus().getUIName())); + versionText.getStyleClass().add((Object)"about_version_label"); + final Label commStandardLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, clientInfo.getCommStandardVersion().getText())); + commStandardLabel.getStyleClass().add((Object)"about_comm_standard_label"); + final Label minThemeAPILabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, clientInfo.getMinThemeSupportVersion().getText())); + minThemeAPILabel.getStyleClass().add((Object)"about_min_theme_api_label"); + final Label minActionAPILabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, clientInfo.getMinPluginSupportVersion().getText())); + minActionAPILabel.getStyleClass().add((Object)"about_min_action_api_label"); + final Label currentActionAPILabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ActionAPI.API_VERSION.getText())); + currentActionAPILabel.getStyleClass().add((Object)"about_current_action_api_label"); + final HBox hBox1 = new HBox(new Node[] { (Node)versionText }); hBox1.setAlignment(Pos.CENTER); - hBox1.setSpacing(10); - - Label javaVersionLabel = new Label("Java "+System.getProperty("java.version")); - javaVersionLabel.getStyleClass().add("about_java_version"); - - Label javafxVersionLabel = new Label("JavaFX "+System.getProperty("javafx.version")); - javafxVersionLabel.getStyleClass().add("about_javafx_version"); - - Label javaGCLabel = new Label("GC: "+ ManagementFactory.getGarbageCollectorMXBeans().get(0).getName()); - javaGCLabel.getStyleClass().add("about_java_gc"); - - HBox hBox2 = new HBox(javaVersionLabel, getSep(), - javafxVersionLabel); - + hBox1.setSpacing(10.0); + final Label javaVersionLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, System.getProperty("java.version"))); + javaVersionLabel.getStyleClass().add((Object)"about_java_version"); + final Label javafxVersionLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, System.getProperty("javafx.version"))); + javafxVersionLabel.getStyleClass().add((Object)"about_javafx_version"); + final Label javaGCLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ManagementFactory.getGarbageCollectorMXBeans().get(0).getName())); + javaGCLabel.getStyleClass().add((Object)"about_java_gc"); + final HBox hBox2 = new HBox(new Node[] { (Node)javaVersionLabel, (Node)this.getSep(), (Node)javafxVersionLabel }); hBox2.setAlignment(Pos.CENTER); - hBox2.setSpacing(10); - - - Label disclaimerLabel = new Label("This contributor list shows only those who have contributed " + - "to the Client Source code.\nTo know about the contributors of Action API, Theme API, Util, " + - "visit the respective repositories. If you want to know about the Core Team instead, please visit the website."); - - disclaimerLabel.getStyleClass().add("about_license_contributors_disclaimer_label"); - - disclaimerLabel.prefWidthProperty().bind(tabPane.widthProperty()); - + hBox2.setSpacing(10.0); + final Label disclaimerLabel = new Label("This contributor list shows only those who have contributed to the Client Source code.\nTo know about the contributors of Action API, Theme API, Util, visit the respective repositories. If you want to know about the Core Team instead, please visit the website."); + disclaimerLabel.getStyleClass().add((Object)"about_license_contributors_disclaimer_label"); + disclaimerLabel.prefWidthProperty().bind((ObservableValue)tabPane.widthProperty()); disclaimerLabel.setWrapText(true); - - - mainVBox.getChildren().addAll(appIconImageView, tabPane, disclaimerLabel, - donateButton, hBox1, hBox2,javaGCLabel); - mainVBox.prefWidthProperty().bind(widthProperty().subtract(30)); - - setContent(mainVBox); - - InputStream inputStream = Main.class.getResourceAsStream("build-date"); - if(inputStream != null) - { - try - { - Logger.getLogger(getClass().getName()).info("build-date present"); - Label buildDateLabel = new Label("Build date/time: " + new String(inputStream.readAllBytes())); - buildDateLabel.getStyleClass().add("build-date-label"); - mainVBox.getChildren().add(buildDateLabel); + this.mainVBox.getChildren().addAll((Object[])new Node[] { (Node)appIconImageView, (Node)tabPane, (Node)disclaimerLabel, (Node)donateButton, (Node)hBox1, (Node)hBox2, (Node)javaGCLabel }); + this.mainVBox.prefWidthProperty().bind((ObservableValue)this.widthProperty().subtract(30)); + this.setContent((Node)this.mainVBox); + final InputStream inputStream = Main.class.getResourceAsStream("build-date"); + if (inputStream != null) { + try { + Logger.getLogger(this.getClass().getName()).info("build-date present"); + final Label buildDateLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, new String(inputStream.readAllBytes()))); + buildDateLabel.getStyleClass().add((Object)"build-date-label"); + this.mainVBox.getChildren().add((Object)buildDateLabel); } - catch (IOException e) - { - Logger.getLogger(getClass().getName()).info("build-date not present"); + catch (IOException e) { + Logger.getLogger(this.getClass().getName()).info("build-date not present"); } } - - setCache(true); - setCacheHint(CacheHint.SPEED); + this.setCache(true); + this.setCacheHint(CacheHint.SPEED); } - - private Label getSep() - { - Label label = new Label("|"); - label.getStyleClass().add("separator_ui_label"); + + private Label getSep() { + final Label label = new Label("|"); + label.getStyleClass().add((Object)"separator_ui_label"); return label; } - - public void openWebpage(String url) - { - clientListener.openURL(url); + + public void openWebpage(final String url) { + this.clientListener.openURL(url); } } diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java index 04005b2b..d862bd5a 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java @@ -1,50 +1,40 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.settings.About; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.info.ClientInfo; import com.stream_pi.util.contactlinks.ContactLinks; -import javafx.application.HostServices; +import javafx.event.ActionEvent; +import javafx.scene.layout.VBox; +import javafx.scene.Node; import javafx.scene.control.Hyperlink; +import com.stream_pi.client.controller.ClientListener; import javafx.scene.control.ScrollPane; -import javafx.scene.layout.VBox; - public class ContactTab extends ScrollPane { private ClientListener clientListener; - - public ContactTab(ClientListener clientListener) - { + + public ContactTab(final ClientListener clientListener) { this.clientListener = clientListener; - - getStyleClass().add("about_contact_tab_scroll_pane"); - - Hyperlink github = new Hyperlink("GitHub"); - github.setOnAction(event -> openWebpage(ContactLinks.getGitHub())); - - Hyperlink discord = new Hyperlink("Discord"); - discord.setOnAction(event -> openWebpage(ContactLinks.getDiscord())); - - Hyperlink website = new Hyperlink("Website"); - website.setOnAction(event -> openWebpage(ContactLinks.getWebsite())); - - Hyperlink twitter = new Hyperlink("Twitter"); - twitter.setOnAction(event -> openWebpage(ContactLinks.getTwitter())); - - Hyperlink matrix = new Hyperlink("Matrix"); - matrix.setOnAction(event -> openWebpage(ContactLinks.getMatrix())); - - - VBox vBox = new VBox(github, discord, website, twitter, matrix); + this.getStyleClass().add((Object)"about_contact_tab_scroll_pane"); + final Hyperlink github = new Hyperlink("GitHub"); + github.setOnAction(event -> this.openWebpage(ContactLinks.getGitHub())); + final Hyperlink discord = new Hyperlink("Discord"); + discord.setOnAction(event -> this.openWebpage(ContactLinks.getDiscord())); + final Hyperlink website = new Hyperlink("Website"); + website.setOnAction(event -> this.openWebpage(ContactLinks.getWebsite())); + final Hyperlink twitter = new Hyperlink("Twitter"); + twitter.setOnAction(event -> this.openWebpage(ContactLinks.getTwitter())); + final Hyperlink matrix = new Hyperlink("Matrix"); + matrix.setOnAction(event -> this.openWebpage(ContactLinks.getMatrix())); + final VBox vBox = new VBox(new Node[] { (Node)github, (Node)discord, (Node)website, (Node)twitter, (Node)matrix }); vBox.setSpacing(10.0); - - setContent(vBox); + this.setContent((Node)vBox); } - - - public void openWebpage(String url) - { - clientListener.openURL(url); + + public void openWebpage(final String url) { + this.clientListener.openURL(url); } - } diff --git a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java index 03258429..c2ef3b9d 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java @@ -1,49 +1,56 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.settings.About; public class Contributor { - public String name = null; - public String email = null; - public String description = null; - public String location = null; - - public Contributor(String name, String email, String description, String location) - { + public String name; + public String email; + public String description; + public String location; + + public Contributor(final String name, final String email, final String description, final String location) { + this.name = null; + this.email = null; + this.description = null; + this.location = null; this.name = name; this.email = email; this.description = description; this.location = location; } - - public void setName(String name) { + + public void setName(final String name) { this.name = name; } - - public void setEmail(String email) { + + public void setEmail(final String email) { this.email = email; } - - public void setDescription(String description) { + + public void setDescription(final String description) { this.description = description; } - + public String getName() { - return name; + return this.name; } - + public String getEmail() { - return email; + return this.email; } - + public String getDescription() { - return description; + return this.description; } - + public String getLocation() { - return location; + return this.location; } - - public void setLocation(String location) { + + public void setLocation(final String location) { this.location = location; } -} \ No newline at end of file +} diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java index 4a69636e..ae562363 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java @@ -1,76 +1,54 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.settings.About; import javafx.scene.CacheHint; -import javafx.scene.control.Label; +import javafx.scene.Node; +import javafx.util.Callback; +import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; -import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.VBox; public class ContributorsTab extends VBox { TableView tableView; - - public ContributorsTab() - { - getStyleClass().add("about_license_contributors_vbox"); - - tableView = new TableView<>(); - tableView.getStyleClass().add("about_license_contributors_table_view"); - - TableColumn descriptionColumn = new TableColumn<>("Description"); + + public ContributorsTab() { + this.getStyleClass().add((Object)"about_license_contributors_vbox"); + this.tableView = (TableView)new TableView(); + this.tableView.getStyleClass().add((Object)"about_license_contributors_table_view"); + final TableColumn descriptionColumn = (TableColumn)new TableColumn("Description"); descriptionColumn.setReorderable(false); - descriptionColumn.setPrefWidth(250); + descriptionColumn.setPrefWidth(250.0); descriptionColumn.setResizable(false); - descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description")); - - TableColumn nameColumn = new TableColumn<>("Name (GitHub)"); + descriptionColumn.setCellValueFactory((Callback)new PropertyValueFactory("description")); + final TableColumn nameColumn = (TableColumn)new TableColumn("Name (GitHub)"); nameColumn.setReorderable(false); - nameColumn.setPrefWidth(220); + nameColumn.setPrefWidth(220.0); nameColumn.setResizable(false); - nameColumn.setCellValueFactory(new PropertyValueFactory<>("name")); - - TableColumn emailColumn = new TableColumn<>("Email"); + nameColumn.setCellValueFactory((Callback)new PropertyValueFactory("name")); + final TableColumn emailColumn = (TableColumn)new TableColumn("Email"); emailColumn.setReorderable(false); - emailColumn.setPrefWidth(200); + emailColumn.setPrefWidth(200.0); emailColumn.setResizable(false); - emailColumn.setCellValueFactory(new PropertyValueFactory<>("email")); - - TableColumn locationColumn = new TableColumn<>("Location"); + emailColumn.setCellValueFactory((Callback)new PropertyValueFactory("email")); + final TableColumn locationColumn = (TableColumn)new TableColumn("Location"); locationColumn.setReorderable(false); - locationColumn.setPrefWidth(100); + locationColumn.setPrefWidth(100.0); locationColumn.setResizable(false); - locationColumn.setCellValueFactory(new PropertyValueFactory<>("location")); - - - tableView.getColumns().addAll(descriptionColumn, nameColumn, emailColumn, locationColumn); - - tableView.setPrefWidth(descriptionColumn.getPrefWidth() + nameColumn.getPrefWidth() + emailColumn.getPrefWidth()); - - tableView.getItems().addAll( - new Contributor("Debayan Sutradhar (rnayabed)", - "debayansutradhar3@gmail.com", - "Founder, Author, Maintainer", - "India"), - new Contributor("Samuel Quiñones (SamuelQuinones)", - "sdquinones1@gmail.com", - "Founder", - "United States"), - new Contributor("Abhinay Agarwal (abhinayagarwal)", - "abhinay_agarwal@live.com", - "Refactoring, Fixes", - "India") - ); - - getChildren().addAll(tableView); - - - setCache(true); - setCacheHint(CacheHint.SPEED); + locationColumn.setCellValueFactory((Callback)new PropertyValueFactory("location")); + this.tableView.getColumns().addAll((Object[])new TableColumn[] { descriptionColumn, nameColumn, emailColumn, locationColumn }); + this.tableView.setPrefWidth(descriptionColumn.getPrefWidth() + nameColumn.getPrefWidth() + emailColumn.getPrefWidth()); + this.tableView.getItems().addAll((Object[])new Contributor[] { new Contributor("Debayan Sutradhar (rnayabed)", "debayansutradhar3@gmail.com", "Founder, Author, Maintainer", "India"), new Contributor("Samuel Qui\u00f1ones (SamuelQuinones)", "sdquinones1@gmail.com", "Founder", "United States"), new Contributor("Abhinay Agarwal (abhinayagarwal)", "abhinay_agarwal@live.com", "Refactoring, Fixes", "India") }); + this.getChildren().addAll((Object[])new Node[] { (Node)this.tableView }); + this.setCache(true); + this.setCacheHint(CacheHint.SPEED); } - - public TableView getTableView() - { - return tableView; + + public TableView getTableView() { + return this.tableView; } } diff --git a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java index 88ab9746..16d24fc4 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java @@ -1,16 +1,18 @@ -package com.stream_pi.client.window.settings.About; +// +// Decompiled by Procyon v0.5.36 +// +package com.stream_pi.client.window.settings.About; import com.stream_pi.client.info.License; import javafx.scene.control.TextArea; public class LicenseTab extends TextArea { - public LicenseTab() - { - setText(License.getLicense()); - getStyleClass().add("about_license_text_area"); - setWrapText(false); - setEditable(false); + public LicenseTab() { + this.setText(License.getLicense()); + this.getStyleClass().add((Object)"about_license_text_area"); + this.setWrapText(false); + this.setEditable(false); } } diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java index 5100fd89..81c430e3 100644 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -1,743 +1,511 @@ +// +// Decompiled by Procyon v0.5.36 +// + package com.stream_pi.client.window.settings; import com.gluonhq.attach.vibration.VibrationService; +import com.stream_pi.util.startatboot.StartAtBoot; import com.stream_pi.client.Main; -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.util.exception.MinorException; import com.stream_pi.client.io.Config; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.util.alert.StreamPiAlert; +import javafx.application.Platform; +import com.stream_pi.util.exception.SevereException; import com.stream_pi.util.alert.StreamPiAlertListener; +import com.stream_pi.util.alert.StreamPiAlert; import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.checkforupdates.CheckForUpdates; +import javafx.event.Event; +import javafx.event.ActionEvent; import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick; -import com.stream_pi.util.combobox.StreamPiComboBox; -import com.stream_pi.util.combobox.StreamPiComboBoxFactory; -import com.stream_pi.util.combobox.StreamPiComboBoxListener; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.platform.Platform; import com.stream_pi.util.platform.PlatformType; -import com.stream_pi.util.startatboot.StartAtBoot; +import com.stream_pi.util.checkforupdates.CheckForUpdates; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.info.ClientInfo; +import javafx.scene.CacheHint; +import javafx.geometry.Pos; +import javafx.scene.layout.Priority; +import javafx.scene.control.ScrollPane; +import javafx.geometry.Insets; +import com.stream_pi.util.uihelper.SpaceFiller; +import javafx.scene.control.Label; +import javafx.scene.layout.HBox; +import javafx.beans.value.ObservableValue; +import javafx.scene.Node; +import com.stream_pi.util.combobox.StreamPiComboBoxListener; +import com.stream_pi.util.combobox.StreamPiComboBoxFactory; +import java.util.Arrays; +import java.util.List; import com.stream_pi.util.uihelper.HBoxInputBox; +import java.util.logging.Logger; +import org.controlsfx.control.ToggleSwitch; import com.stream_pi.util.uihelper.HBoxWithSpaceBetween; -import com.stream_pi.util.uihelper.SpaceFiller; +import javafx.scene.control.Button; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.util.combobox.StreamPiComboBox; +import javafx.scene.control.TextField; import javafx.application.HostServices; -import javafx.event.ActionEvent; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.*; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.window.ExceptionAndAlertHandler; import javafx.scene.layout.VBox; -import org.controlsfx.control.ToggleSwitch; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.logging.Logger; public class GeneralTab extends VBox { private ExceptionAndAlertHandler exceptionAndAlertHandler; private ClientListener clientListener; private HostServices hostServices; - private TextField serverPortTextField; private TextField serverHostNameOrIPTextField; - private TextField screenTimeoutTextField; - private StreamPiComboBox clientProfileComboBox; private StreamPiComboBox themeComboBox; - + private StreamPiComboBox animationComboBox; private TextField nickNameTextField; - private Button saveButton; private Button connectDisconnectButton; private Button shutdownButton; - private HBoxWithSpaceBetween startOnBootHBox; private ToggleSwitch startOnBootToggleSwitch; - private HBoxWithSpaceBetween screenSaverHBox; private ToggleSwitch screenSaverToggleSwitch; - private HBoxWithSpaceBetween screenMoverHBox; private ToggleSwitch screenMoverToggleSwitch; - private HBoxWithSpaceBetween tryConnectingToServerIfActionClickedHBox; private ToggleSwitch tryConnectingToServerIfActionClickedToggleSwitch; - private HBoxWithSpaceBetween connectOnStartupHBox; private ToggleSwitch connectOnStartupToggleSwitch; - private HBoxWithSpaceBetween vibrateOnActionPressHBox; private ToggleSwitch vibrateOnActionPressToggleSwitch; - private HBoxWithSpaceBetween fullScreenModeHBox; private ToggleSwitch fullScreenModeToggleSwitch; - private HBoxWithSpaceBetween showCursorHBox; private ToggleSwitch showCursorToggleSwitch; - private HBoxWithSpaceBetween invertRowsColsHBox; private ToggleSwitch invertRowsColsToggleSwitch; - private TextField themesPathTextField; private TextField iconsPathTextField; private TextField profilesPathTextField; - private final Button factoryResetButton; - private Logger logger; - - private final Button checkForUpdatesButton; - private HBoxInputBox screenTimeoutSecondsHBoxInputBox; - - public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler, - ClientListener clientListener, HostServices hostServices) - { + private List animationList; + + public GeneralTab(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener, final HostServices hostServices) { + this.animationList = Arrays.asList("None", "Bounce", "Flip", "Jack In The Box", "Jello", "Pulse", "RubberBand", "Shake", "Swing", "Tada", "Wobble"); this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.clientListener = clientListener; this.hostServices = hostServices; - - logger = Logger.getLogger(""); - - serverPortTextField = new TextField(); - screenTimeoutTextField = new TextField(); - - - serverHostNameOrIPTextField = new TextField(); - nickNameTextField = new TextField(); - - clientProfileComboBox = new StreamPiComboBox<>(); - - clientProfileComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() - { - @Override - public String getOptionDisplayText(ClientProfile object) - { + this.logger = Logger.getLogger(""); + this.serverPortTextField = new TextField(); + this.screenTimeoutTextField = new TextField(); + this.serverHostNameOrIPTextField = new TextField(); + this.nickNameTextField = new TextField(); + (this.clientProfileComboBox = (StreamPiComboBox)new StreamPiComboBox()).setStreamPiComboBoxFactory((StreamPiComboBoxFactory)new StreamPiComboBoxFactory() { + public String getOptionDisplayText(final ClientProfile object) { return object.getName(); } }); - - clientProfileComboBox.setStreamPiComboBoxListener(new StreamPiComboBoxListener(){ - @Override - public void onNewItemSelected(ClientProfile selectedItem) - { + (this.animationComboBox = (StreamPiComboBox)new StreamPiComboBox()).setStreamPiComboBoxFactory((StreamPiComboBoxFactory)new StreamPiComboBoxFactory() { + public String getOptionDisplayText(final String object) { + return object; + } + }); + this.clientProfileComboBox.setStreamPiComboBoxListener((StreamPiComboBoxListener)new StreamPiComboBoxListener() { + public void onNewItemSelected(final ClientProfile selectedItem) { clientListener.renderProfile(selectedItem, true); } }); - - - themeComboBox = new StreamPiComboBox<>(); - themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() - { - @Override - public String getOptionDisplayText(Theme object) - { + (this.themeComboBox = (StreamPiComboBox)new StreamPiComboBox()).setStreamPiComboBoxFactory((StreamPiComboBoxFactory)new StreamPiComboBoxFactory() { + public String getOptionDisplayText(final Theme object) { return object.getShortName(); } }); - - themesPathTextField = new TextField(); - iconsPathTextField = new TextField(); - profilesPathTextField = new TextField(); - - startOnBootToggleSwitch = new ToggleSwitch(); - startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", startOnBootToggleSwitch); - startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty()); - - screenSaverToggleSwitch = new ToggleSwitch(); - screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", screenSaverToggleSwitch); - screenSaverHBox.managedProperty().bind(screenSaverHBox.visibleProperty()); - - screenMoverToggleSwitch = new ToggleSwitch(); - screenMoverHBox = new HBoxWithSpaceBetween("OLED Burn-In Protector", screenMoverToggleSwitch); - screenMoverHBox.managedProperty().bind(screenMoverHBox.visibleProperty()); - - tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch(); - tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", tryConnectingToServerIfActionClickedToggleSwitch); - tryConnectingToServerIfActionClickedHBox.managedProperty().bind(tryConnectingToServerIfActionClickedHBox.visibleProperty()); - - fullScreenModeToggleSwitch = new ToggleSwitch(); - fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", fullScreenModeToggleSwitch); - fullScreenModeHBox.managedProperty().bind(fullScreenModeHBox.visibleProperty()); - - vibrateOnActionPressToggleSwitch = new ToggleSwitch(); - vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", vibrateOnActionPressToggleSwitch); - vibrateOnActionPressHBox.managedProperty().bind(vibrateOnActionPressHBox.visibleProperty()); - - connectOnStartupToggleSwitch = new ToggleSwitch(); - connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", connectOnStartupToggleSwitch); - connectOnStartupHBox.managedProperty().bind(connectOnStartupHBox.visibleProperty()); - - showCursorToggleSwitch = new ToggleSwitch(); - showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", showCursorToggleSwitch); - showCursorHBox.managedProperty().bind(showCursorHBox.visibleProperty()); - - invertRowsColsToggleSwitch = new ToggleSwitch(); - invertRowsColsHBox = new HBoxWithSpaceBetween("Invert Grid on Rotate", invertRowsColsToggleSwitch); - invertRowsColsHBox.managedProperty().bind(invertRowsColsHBox.visibleProperty()); - - int prefWidth = 200; - - HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", themesPathTextField, prefWidth); - themesPathInputBox.managedProperty().bind(themesPathInputBox.visibleProperty()); - - - HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", iconsPathTextField, prefWidth); - iconsPathInputBox.managedProperty().bind(iconsPathInputBox.visibleProperty()); - - - HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", profilesPathTextField, prefWidth); - profilesPathInputBox.managedProperty().bind(profilesPathInputBox.visibleProperty()); - - checkForUpdatesButton = new Button("Check for updates"); - checkForUpdatesButton.setOnAction(event->checkForUpdates()); - - factoryResetButton = new Button("Factory Reset"); - factoryResetButton.setOnAction(actionEvent -> onFactoryResetButtonClicked()); - - - screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", screenTimeoutTextField, prefWidth); - screenTimeoutSecondsHBoxInputBox.managedProperty().bind(screenTimeoutSecondsHBoxInputBox.visibleProperty()); - screenTimeoutTextField.disableProperty().bind(screenSaverToggleSwitch.selectedProperty().not()); - - saveButton = new Button("Save"); - saveButton.setOnAction(event->onSaveButtonClicked()); - - connectDisconnectButton = new Button("Connect"); - connectDisconnectButton.setOnAction(event -> onConnectDisconnectButtonClicked()); - - - Button exitButton = new Button("Exit"); - exitButton.setOnAction(event -> onExitButtonClicked()); - - HBox buttonBar = new HBox(connectDisconnectButton, saveButton); - - shutdownButton = new Button("Shutdown"); - shutdownButton.managedProperty().bind(shutdownButton.visibleProperty()); - shutdownButton.setOnAction(event -> onShutdownButtonClicked()); - - - VBox vBox = new VBox( - generateSubHeading("Connection"), - new HBoxInputBox("Device Name", nickNameTextField, prefWidth), - new HBoxInputBox("Host Name/IP", serverHostNameOrIPTextField, prefWidth), - new HBoxInputBox("Port", serverPortTextField, prefWidth), - generateSubHeading("Client"), - new HBox( - new Label("Current profile"), - SpaceFiller.horizontal(), - clientProfileComboBox - ), - new HBox( - new Label("Theme"), - SpaceFiller.horizontal(), - themeComboBox - ), - generateSubHeading("Others"), - themesPathInputBox, - iconsPathInputBox, - profilesPathInputBox, - screenTimeoutSecondsHBoxInputBox, - invertRowsColsHBox, - screenSaverHBox, - screenMoverHBox, - tryConnectingToServerIfActionClickedHBox, - fullScreenModeHBox, - connectOnStartupHBox, - vibrateOnActionPressHBox, - startOnBootHBox, - showCursorHBox, - checkForUpdatesButton, - shutdownButton, - factoryResetButton - ); - - - vBox.getStyleClass().add("settings_base_vbox"); - + this.themesPathTextField = new TextField(); + this.iconsPathTextField = new TextField(); + this.profilesPathTextField = new TextField(); + this.startOnBootToggleSwitch = new ToggleSwitch(); + this.startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", (Node)this.startOnBootToggleSwitch); + this.startOnBootHBox.managedProperty().bind((ObservableValue)this.startOnBootHBox.visibleProperty()); + this.screenSaverToggleSwitch = new ToggleSwitch(); + this.screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", (Node)this.screenSaverToggleSwitch); + this.screenSaverHBox.managedProperty().bind((ObservableValue)this.screenSaverHBox.visibleProperty()); + this.screenMoverToggleSwitch = new ToggleSwitch(); + this.screenMoverHBox = new HBoxWithSpaceBetween("OLED Burn-In Protector", (Node)this.screenMoverToggleSwitch); + this.screenMoverHBox.managedProperty().bind((ObservableValue)this.screenMoverHBox.visibleProperty()); + this.tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch(); + this.tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", (Node)this.tryConnectingToServerIfActionClickedToggleSwitch); + this.tryConnectingToServerIfActionClickedHBox.managedProperty().bind((ObservableValue)this.tryConnectingToServerIfActionClickedHBox.visibleProperty()); + this.fullScreenModeToggleSwitch = new ToggleSwitch(); + this.fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", (Node)this.fullScreenModeToggleSwitch); + this.fullScreenModeHBox.managedProperty().bind((ObservableValue)this.fullScreenModeHBox.visibleProperty()); + this.vibrateOnActionPressToggleSwitch = new ToggleSwitch(); + this.vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", (Node)this.vibrateOnActionPressToggleSwitch); + this.vibrateOnActionPressHBox.managedProperty().bind((ObservableValue)this.vibrateOnActionPressHBox.visibleProperty()); + this.connectOnStartupToggleSwitch = new ToggleSwitch(); + this.connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", (Node)this.connectOnStartupToggleSwitch); + this.connectOnStartupHBox.managedProperty().bind((ObservableValue)this.connectOnStartupHBox.visibleProperty()); + this.showCursorToggleSwitch = new ToggleSwitch(); + this.showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", (Node)this.showCursorToggleSwitch); + this.showCursorHBox.managedProperty().bind((ObservableValue)this.showCursorHBox.visibleProperty()); + this.invertRowsColsToggleSwitch = new ToggleSwitch(); + this.invertRowsColsHBox = new HBoxWithSpaceBetween("Invert Grid on Rotate", (Node)this.invertRowsColsToggleSwitch); + this.invertRowsColsHBox.managedProperty().bind((ObservableValue)this.invertRowsColsHBox.visibleProperty()); + final int prefWidth = 200; + final HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", this.themesPathTextField, prefWidth); + themesPathInputBox.managedProperty().bind((ObservableValue)themesPathInputBox.visibleProperty()); + final HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", this.iconsPathTextField, prefWidth); + iconsPathInputBox.managedProperty().bind((ObservableValue)iconsPathInputBox.visibleProperty()); + final HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", this.profilesPathTextField, prefWidth); + profilesPathInputBox.managedProperty().bind((ObservableValue)profilesPathInputBox.visibleProperty()); + (this.checkForUpdatesButton = new Button("Check for updates")).setOnAction(event -> this.checkForUpdates()); + (this.factoryResetButton = new Button("Factory Reset")).setOnAction(actionEvent -> this.onFactoryResetButtonClicked()); + this.screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", this.screenTimeoutTextField, prefWidth); + this.screenTimeoutSecondsHBoxInputBox.managedProperty().bind((ObservableValue)this.screenTimeoutSecondsHBoxInputBox.visibleProperty()); + this.screenTimeoutTextField.disableProperty().bind((ObservableValue)this.screenSaverToggleSwitch.selectedProperty().not()); + (this.saveButton = new Button("Save")).setOnAction(event -> this.onSaveButtonClicked()); + (this.connectDisconnectButton = new Button("Connect")).setOnAction(event -> this.onConnectDisconnectButtonClicked()); + final Button exitButton = new Button("Exit"); + exitButton.setOnAction(event -> this.onExitButtonClicked()); + final HBox buttonBar = new HBox(new Node[] { (Node)this.connectDisconnectButton, (Node)this.saveButton }); + this.shutdownButton = new Button("Shutdown"); + this.shutdownButton.managedProperty().bind((ObservableValue)this.shutdownButton.visibleProperty()); + this.shutdownButton.setOnAction(event -> this.onShutdownButtonClicked()); + final VBox vBox = new VBox(new Node[] { (Node)this.generateSubHeading("Connection"), (Node)new HBoxInputBox("Device Name", this.nickNameTextField, prefWidth), (Node)new HBoxInputBox("Host Name/IP", this.serverHostNameOrIPTextField, prefWidth), (Node)new HBoxInputBox("Port", this.serverPortTextField, prefWidth), (Node)this.generateSubHeading("Client"), (Node)new HBox(new Node[] { (Node)new Label("Current profile"), (Node)SpaceFiller.horizontal(), (Node)this.clientProfileComboBox }), (Node)new HBox(new Node[] { (Node)new Label("Theme"), (Node)SpaceFiller.horizontal(), (Node)this.themeComboBox }), (Node)new HBox(new Node[] { (Node)new Label("Action Animation"), (Node)SpaceFiller.horizontal(), (Node)this.animationComboBox }), (Node)this.generateSubHeading("Others"), (Node)themesPathInputBox, (Node)iconsPathInputBox, (Node)profilesPathInputBox, (Node)this.screenTimeoutSecondsHBoxInputBox, (Node)this.invertRowsColsHBox, (Node)this.screenSaverHBox, (Node)this.screenMoverHBox, (Node)this.tryConnectingToServerIfActionClickedHBox, (Node)this.fullScreenModeHBox, (Node)this.connectOnStartupHBox, (Node)this.vibrateOnActionPressHBox, (Node)this.startOnBootHBox, (Node)this.showCursorHBox, (Node)this.checkForUpdatesButton, (Node)this.shutdownButton, (Node)this.factoryResetButton }); + vBox.getStyleClass().add((Object)"settings_base_vbox"); vBox.setSpacing(10.0); - vBox.setPadding(new Insets(5)); - - ScrollPane scrollPane = new ScrollPane(); + vBox.setPadding(new Insets(5.0)); + final ScrollPane scrollPane = new ScrollPane(); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); - VBox.setVgrow(scrollPane, Priority.ALWAYS); - scrollPane.getStyleClass().add("settings_base_scroll_pane"); - scrollPane.setContent(vBox); - - vBox.setMinWidth(300); - - vBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(30)); - - - buttonBar.getStyleClass().add("settings_button_bar"); - - - buttonBar.setPadding(new Insets(0,5,5,0)); + VBox.setVgrow((Node)scrollPane, Priority.ALWAYS); + scrollPane.getStyleClass().add((Object)"settings_base_scroll_pane"); + scrollPane.setContent((Node)vBox); + vBox.setMinWidth(300.0); + vBox.prefWidthProperty().bind((ObservableValue)scrollPane.widthProperty().subtract(30)); + buttonBar.getStyleClass().add((Object)"settings_button_bar"); + buttonBar.setPadding(new Insets(0.0, 5.0, 5.0, 0.0)); buttonBar.setSpacing(5.0); buttonBar.setAlignment(Pos.CENTER_RIGHT); - - setSpacing(10.0); - - getChildren().addAll( - scrollPane, - buttonBar - ); - - setCache(true); - setCacheHint(CacheHint.SPEED); - - - //Perform platform checks - - if(ClientInfo.getInstance().isPhone()) - { + this.setSpacing(10.0); + this.getChildren().addAll((Object[])new Node[] { (Node)scrollPane, (Node)buttonBar }); + this.setCache(true); + this.setCacheHint(CacheHint.SPEED); + if (ClientInfo.getInstance().isPhone()) { themesPathInputBox.setVisible(false); iconsPathInputBox.setVisible(false); profilesPathInputBox.setVisible(false); - - startOnBootHBox.setVisible(false); - showCursorHBox.setVisible(false); - fullScreenModeHBox.setVisible(false); - shutdownButton.setVisible(false); + this.startOnBootHBox.setVisible(false); + this.showCursorHBox.setVisible(false); + this.fullScreenModeHBox.setVisible(false); + this.shutdownButton.setVisible(false); } - else - { - invertRowsColsHBox.setVisible(false); - vibrateOnActionPressHBox.setVisible(false); - buttonBar.getChildren().add(exitButton); - - - fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON); - - shutdownButton.setVisible(StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON); + else { + this.invertRowsColsHBox.setVisible(false); + this.vibrateOnActionPressHBox.setVisible(false); + buttonBar.getChildren().add((Object)exitButton); + this.fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON); + this.shutdownButton.setVisible(StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON); } - - - screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); - screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); + this.screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); + this.screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); } - - private Label generateSubHeading(String text) - { - Label label = new Label(text); - label.getStyleClass().add("general_settings_sub_heading"); + + private Label generateSubHeading(final String text) { + final Label label = new Label(text); + label.getStyleClass().add((Object)"general_settings_sub_heading"); return label; } - - private Logger getLogger() - { - return logger; + + private Logger getLogger() { + return this.logger; } - - private void checkForUpdates() - { - new CheckForUpdates(checkForUpdatesButton, - PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() { - @Override - public void handle(ActionEvent actionEvent) { - if(ClientInfo.getInstance().isPhone()) - { - clientListener.openURL(getURL()); + + private void checkForUpdates() { + new CheckForUpdates(this.checkForUpdatesButton, PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), (UpdateHyperlinkOnClick)new UpdateHyperlinkOnClick() { + public void handle(final ActionEvent actionEvent) { + if (ClientInfo.getInstance().isPhone()) { + GeneralTab.this.clientListener.openURL(this.getURL()); } - else - { - hostServices.showDocument(getURL()); + else { + GeneralTab.this.hostServices.showDocument(this.getURL()); } } }); } - - private void onFactoryResetButtonClicked() - { - StreamPiAlert confirmation = new StreamPiAlert("Warning","Are you sure?\n" + - "This will erase everything.",StreamPiAlertType.WARNING); - - String yesButton = "Yes"; - String noButton = "No"; - - confirmation.setButtons(yesButton, noButton); - - confirmation.setOnClicked(new StreamPiAlertListener() { - @Override - public void onClick(String s) { - if(s.equals(yesButton)) - { - clientListener.factoryReset(); + + private void onFactoryResetButtonClicked() { + final StreamPiAlert confirmation = new StreamPiAlert("Warning", "Are you sure?\nThis will erase everything.", StreamPiAlertType.WARNING); + final String yesButton = "Yes"; + final String noButton = "No"; + confirmation.setButtons(new String[] { yesButton, noButton }); + confirmation.setOnClicked((StreamPiAlertListener)new StreamPiAlertListener() { + public void onClick(final String s) { + if (s.equals(yesButton)) { + GeneralTab.this.clientListener.factoryReset(); } } }); - confirmation.show(); } - - - public void onExitButtonClicked() - { - clientListener.onCloseRequest(); - clientListener.exitApp(); + + public void onExitButtonClicked() { + this.clientListener.onCloseRequest(); + this.clientListener.exitApp(); } - - public void setDisableStatus(boolean status) - { - saveButton.setDisable(status); - connectDisconnectButton.setDisable(status); + + public void setDisableStatus(final boolean status) { + this.saveButton.setDisable(status); + this.connectDisconnectButton.setDisable(status); } - - public Button getConnectDisconnectButton() - { - return connectDisconnectButton; + + public Button getConnectDisconnectButton() { + return this.connectDisconnectButton; } - - public void onShutdownButtonClicked() - { - clientListener.onCloseRequest(); - - try - { + + public void onShutdownButtonClicked() { + this.clientListener.onCloseRequest(); + try { Runtime.getRuntime().exec("sudo halt"); } - catch (Exception e) - { + catch (Exception e) { e.printStackTrace(); } } - - public void onConnectDisconnectButtonClicked() - { - try - { - if(clientListener.isConnected()) - clientListener.disconnect("Client disconnected from settings"); - else - clientListener.setupClientConnection(); + + public void onConnectDisconnectButtonClicked() { + try { + if (this.clientListener.isConnected()) { + this.clientListener.disconnect("Client disconnected from settings"); + } + else { + this.clientListener.setupClientConnection(); + } } - catch (SevereException e) - { + catch (SevereException e) { e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(e); + this.exceptionAndAlertHandler.handleSevereException(e); } } - - public void setConnectDisconnectButtonStatus() - { - javafx.application.Platform.runLater(()->{ - setDisableStatus(false); - - if(clientListener.isConnected()) - connectDisconnectButton.setText("Disconnect"); - else - connectDisconnectButton.setText("Connect"); + + public void setConnectDisconnectButtonStatus() { + Platform.runLater(() -> { + this.setDisableStatus(false); + if (this.clientListener.isConnected()) { + this.connectDisconnectButton.setText("Disconnect"); + } + else { + this.connectDisconnectButton.setText("Connect"); + } }); - } - - public void loadData() throws SevereException - { - Config config = Config.getInstance(); - - nickNameTextField.setText(config.getClientNickName()); - - serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP()); - serverPortTextField.setText(config.getSavedServerPort()+""); - - screenTimeoutTextField.setText(config.getScreenSaverTimeout()+""); - screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); - screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); - - clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles()); - + + public void loadData() throws SevereException { + final Config config = Config.getInstance(); + this.nickNameTextField.setText(config.getClientNickName()); + this.serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP()); + this.serverPortTextField.setText(invokedynamic(makeConcatWithConstants:(I)Ljava/lang/String;, config.getSavedServerPort())); + this.screenTimeoutTextField.setText(invokedynamic(makeConcatWithConstants:(I)Ljava/lang/String;, config.getScreenSaverTimeout())); + this.screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); + this.screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); + this.clientProfileComboBox.setOptions((List)this.clientListener.getClientProfiles().getClientProfiles()); + this.animationComboBox.setOptions((List)this.animationList); int ind = 0; - for(int i = 0;i 65535) + } + else if (port > 65535) { 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"); } - - int screenSaverTimeout = -1; - try - { - screenSaverTimeout = Integer.parseInt(serverPortTextField.getText()); - - if(screenSaverTimeout < 15) + try { + screenSaverTimeout = Integer.parseInt(this.serverPortTextField.getText()); + if (screenSaverTimeout < 15) { errors.append("* Screen Timeout cannot be below 15 seconds.\n"); + } } - catch (NumberFormatException exception) - { + catch (NumberFormatException exception2) { errors.append("* Screen Timeout should be a number.\n"); } - - - if(serverHostNameOrIPTextField.getText().isBlank()) - { + if (this.serverHostNameOrIPTextField.getText().isBlank()) { errors.append("* Server IP cannot be empty.\n"); } - - if(nickNameTextField.getText().isBlank()) - { + if (this.nickNameTextField.getText().isBlank()) { errors.append("* Nick name cannot be blank.\n"); } - else - { - if(nickNameTextField.getText().equals("about maker")) - { - new StreamPiAlert("किसने बनाया ? / কে বানিয়েছে ?","ZGViYXlhbiAtIGluZGlh\n" + - "boka XD").show(); - } + else if (this.nickNameTextField.getText().equals("about maker")) { + new StreamPiAlert("\u0915\u093f\u0938\u0928\u0947 \u092c\u0928\u093e\u092f\u093e ? / \u0995\u09c7 \u09ac\u09be\u09a8\u09bf\u09df\u09c7\u099b\u09c7 ?", "ZGViYXlhbiAtIGluZGlh\nboka XD").show(); } - - - if(!errors.toString().isEmpty()) - { - exceptionAndAlertHandler.handleMinorException(new MinorException( - "You made mistakes", - "Please fix the errors and try again :\n"+errors.toString() - )); + else if (this.nickNameTextField.getText().equals("imachonk")) { + new StreamPiAlert("bigquimo is mega chonk", "i cant stop sweating lol").show(); + } + if (!errors.toString().isEmpty()) { + this.exceptionAndAlertHandler.handleMinorException(new MinorException("You made mistakes", invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, errors.toString()))); return; } - - - - try - { + try { boolean toBeReloaded = false; - boolean syncWithServer = false; - - Config config = Config.getInstance(); - - if(!config.getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName())) - { + final Config config = Config.getInstance(); + if (!config.getCurrentThemeFullName().equals(((Theme)this.themeComboBox.getCurrentSelectedItem()).getFullName())) { syncWithServer = true; - - try - { - config.setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName()); + try { + config.setCurrentThemeFullName(((Theme)this.themeComboBox.getCurrentSelectedItem()).getFullName()); config.save(); - clientListener.initThemes(); + this.clientListener.initThemes(); } - catch(SevereException e) - { - exceptionAndAlertHandler.handleSevereException(e); + catch (SevereException e) { + this.exceptionAndAlertHandler.handleSevereException(e); } } - - if(!config.getClientNickName().equals(nickNameTextField.getText())) - { + if (!config.getCurrentAnimationName().equals(this.animationComboBox.getCurrentSelectedItem())) { syncWithServer = true; + try { + config.setCurrentAnimationFullName((String)this.animationComboBox.getCurrentSelectedItem()); + config.save(); + } + catch (SevereException e) { + this.exceptionAndAlertHandler.handleSevereException(e); + } } - - config.setNickName(nickNameTextField.getText()); - - if(port != config.getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP())) - { + if (!config.getClientNickName().equals(this.nickNameTextField.getText())) { + syncWithServer = true; + } + config.setNickName(this.nickNameTextField.getText()); + if (port != config.getSavedServerPort() || !this.serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP())) { syncWithServer = true; } - config.setServerPort(port); - config.setServerHostNameOrIP(serverHostNameOrIPTextField.getText()); - - boolean isFullScreen = fullScreenModeToggleSwitch.isSelected(); - - if(config.getIsFullScreenMode() != isFullScreen) - { + config.setServerHostNameOrIP(this.serverHostNameOrIPTextField.getText()); + final boolean isFullScreen = this.fullScreenModeToggleSwitch.isSelected(); + if (config.getIsFullScreenMode() != isFullScreen) { toBeReloaded = true; } - config.setIsFullScreenMode(isFullScreen); - - - - config.setTryConnectingWhenActionClicked(tryConnectingToServerIfActionClickedToggleSwitch.isSelected()); - - - - boolean startOnBoot = startOnBootToggleSwitch.isSelected(); - - if(config.isStartOnBoot() != startOnBoot) - { - StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), - Main.class.getProtectionDomain().getCodeSource().getLocation(), - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); - - if(startOnBoot) - { - try - { + config.setTryConnectingWhenActionClicked(this.tryConnectingToServerIfActionClickedToggleSwitch.isSelected()); + boolean startOnBoot = this.startOnBootToggleSwitch.isSelected(); + if (config.isStartOnBoot() != startOnBoot) { + final StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), Main.class.getProtectionDomain().getCodeSource().getLocation(), StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); + if (startOnBoot) { + try { startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); config.setStartupIsXMode(StartupFlags.IS_X_MODE); } - catch (MinorException e) - { - exceptionAndAlertHandler.handleMinorException(e); + catch (MinorException e2) { + this.exceptionAndAlertHandler.handleMinorException(e2); startOnBoot = false; } } - else - { - boolean result = startAtBoot.delete(); - if(!result) + else { + final boolean result = startAtBoot.delete(); + if (!result) { new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show(); + } } } - config.setStartOnBoot(startOnBoot); - - if(!config.isShowCursor() ==showCursorToggleSwitch.isSelected()) + if (!config.isShowCursor() == this.showCursorToggleSwitch.isSelected()) { toBeReloaded = true; - - config.setShowCursor(showCursorToggleSwitch.isSelected()); - - - if(!config.getThemesPath().equals(themesPathTextField.getText())) + } + config.setShowCursor(this.showCursorToggleSwitch.isSelected()); + if (!config.getThemesPath().equals(this.themesPathTextField.getText())) { toBeReloaded = true; - - config.setThemesPath(themesPathTextField.getText()); - - - if(!config.getIconsPath().equals(iconsPathTextField.getText())) + } + config.setThemesPath(this.themesPathTextField.getText()); + if (!config.getIconsPath().equals(this.iconsPathTextField.getText())) { toBeReloaded = true; - - config.setIconsPath(iconsPathTextField.getText()); - - if(!config.getProfilesPath().equals(profilesPathTextField.getText())) + } + config.setIconsPath(this.iconsPathTextField.getText()); + if (!config.getProfilesPath().equals(this.profilesPathTextField.getText())) { toBeReloaded = true; - - config.setProfilesPath(profilesPathTextField.getText()); - - if(config.isScreenSaverEnabled() != screenSaverToggleSwitch.isSelected()) + } + config.setProfilesPath(this.profilesPathTextField.getText()); + if (config.isScreenSaverEnabled() != this.screenSaverToggleSwitch.isSelected()) { toBeReloaded = true; - - config.setScreenSaverEnabled(screenSaverToggleSwitch.isSelected()); - - if(config.isScreenMoverEnabled() != screenMoverToggleSwitch.isSelected()) + } + config.setScreenSaverEnabled(this.screenSaverToggleSwitch.isSelected()); + if (config.isScreenMoverEnabled() != this.screenMoverToggleSwitch.isSelected()) { toBeReloaded = true; - - config.setScreenMoverEnabled(screenMoverToggleSwitch.isSelected()); - - if(!(screenSaverTimeout+"").equals(screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) - { - config.setScreenSaverTimeout(screenTimeoutTextField.getText()); - - clientListener.getScreenSaver().setTimeout(config.getScreenSaverTimeout()); - clientListener.getScreenSaver().restartTimer(); } - - - config.setConnectOnStartup(connectOnStartupToggleSwitch.isSelected()); - - boolean isVibrateOnActionClicked = vibrateOnActionPressToggleSwitch.isSelected(); - - if(config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked) - { - if(VibrationService.create().isEmpty()) - { - isVibrateOnActionClicked = false; - new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show(); - } + config.setScreenMoverEnabled(this.screenMoverToggleSwitch.isSelected()); + if (!invokedynamic(makeConcatWithConstants:(I)Ljava/lang/String;, screenSaverTimeout).equals(this.screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) { + config.setScreenSaverTimeout(this.screenTimeoutTextField.getText()); + this.clientListener.getScreenSaver().setTimeout(config.getScreenSaverTimeout()); + this.clientListener.getScreenSaver().restartTimer(); + } + config.setConnectOnStartup(this.connectOnStartupToggleSwitch.isSelected()); + boolean isVibrateOnActionClicked = this.vibrateOnActionPressToggleSwitch.isSelected(); + if (config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked && VibrationService.create().isEmpty()) { + isVibrateOnActionClicked = false; + new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show(); } - config.setVibrateOnActionClicked(isVibrateOnActionClicked); - config.setInvertRowsColsOnDeviceRotate(invertRowsColsToggleSwitch.isSelected()); - + config.setInvertRowsColsOnDeviceRotate(this.invertRowsColsToggleSwitch.isSelected()); config.save(); - - loadData(); - - - if(syncWithServer) - { - if(clientListener.isConnected()) - { - clientListener.getClient().updateClientDetails(); - } + this.loadData(); + if (syncWithServer && this.clientListener.isConnected()) { + this.clientListener.getClient().updateClientDetails(); } - - if(toBeReloaded) - { - if(!ClientInfo.getInstance().isPhone() && !config.getIsFullScreenMode()) - { - config.setStartupWindowSize(clientListener.getStageWidth(), clientListener.getStageHeight()); + if (toBeReloaded) { + if (!ClientInfo.getInstance().isPhone() && !config.getIsFullScreenMode()) { + config.setStartupWindowSize(this.clientListener.getStageWidth(), this.clientListener.getStageHeight()); config.save(); } - - clientListener.init(); - clientListener.renderRootDefaultProfile(); + this.clientListener.init(); + this.clientListener.renderRootDefaultProfile(); } } - catch (SevereException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(e); + catch (SevereException e3) { + e3.printStackTrace(); + this.exceptionAndAlertHandler.handleSevereException(e3); } - catch (MinorException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleMinorException(e); + catch (MinorException e4) { + e4.printStackTrace(); + this.exceptionAndAlertHandler.handleMinorException(e4); } } - } diff --git a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java index 818461aa..274d447f 100644 --- a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java +++ b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java @@ -1,73 +1,60 @@ -package com.stream_pi.client.window.settings; +// +// Decompiled by Procyon v0.5.36 +// -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.window.settings.About.AboutTab; +package com.stream_pi.client.window.settings; -import javafx.application.HostServices; -import javafx.event.Event; +import javafx.scene.CacheHint; import javafx.geometry.Insets; import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.*; -import javafx.scene.input.SwipeEvent; +import com.stream_pi.client.window.settings.About.AboutTab; +import javafx.scene.control.Tab; +import javafx.scene.Node; import javafx.scene.layout.Priority; +import javafx.event.Event; +import javafx.scene.input.SwipeEvent; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import javafx.application.HostServices; +import javafx.scene.control.Button; +import javafx.scene.control.TabPane; import javafx.scene.layout.VBox; public class SettingsBase extends VBox { private TabPane tabPane; - private GeneralTab generalTab; - private Button closeButton; - private HostServices hostServices; private ExceptionAndAlertHandler exceptionAndAlertHandler; - - public SettingsBase(HostServices hostServices, ExceptionAndAlertHandler exceptionAndAlertHandler, - ClientListener clientListener) - { + + public SettingsBase(final HostServices hostServices, final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener) { this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.hostServices = hostServices; - - tabPane = new TabPane(); - tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); - tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); - VBox.setVgrow(tabPane, Priority.ALWAYS); - - Tab generalSettingsTab = new Tab("Settings"); - generalTab = new GeneralTab(exceptionAndAlertHandler, clientListener, hostServices); - generalSettingsTab.setContent(generalTab); - - Tab aboutTab = new Tab("About"); - aboutTab.setContent(new AboutTab(clientListener)); - - tabPane.getTabs().addAll(generalSettingsTab, aboutTab); - - setAlignment(Pos.TOP_RIGHT); - - closeButton = new Button("Close"); - VBox.setMargin(closeButton, new Insets(5.0)); - - getChildren().addAll(tabPane, closeButton); - - setCache(true); - setCacheHint(CacheHint.SPEED); + (this.tabPane = new TabPane()).addEventFilter(SwipeEvent.ANY, Event::consume); + this.tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); + VBox.setVgrow((Node)this.tabPane, Priority.ALWAYS); + final Tab generalSettingsTab = new Tab("Settings"); + generalSettingsTab.setContent((Node)(this.generalTab = new GeneralTab(exceptionAndAlertHandler, clientListener, hostServices))); + final Tab aboutTab = new Tab("About"); + aboutTab.setContent((Node)new AboutTab(clientListener)); + this.tabPane.getTabs().addAll((Object[])new Tab[] { generalSettingsTab, aboutTab }); + this.setAlignment(Pos.TOP_RIGHT); + VBox.setMargin((Node)(this.closeButton = new Button("Close")), new Insets(5.0)); + this.getChildren().addAll((Object[])new Node[] { (Node)this.tabPane, (Node)this.closeButton }); + this.setCache(true); + this.setCacheHint(CacheHint.SPEED); } - - public void setDefaultTabToGeneral() - { - tabPane.getSelectionModel().selectFirst(); + + public void setDefaultTabToGeneral() { + this.tabPane.getSelectionModel().selectFirst(); } - - public Button getCloseButton() - { - return closeButton; + + public Button getCloseButton() { + return this.closeButton; } - - public GeneralTab getGeneralTab() - { - return generalTab; + + public GeneralTab getGeneralTab() { + return this.generalTab; } } diff --git a/src/main/resources/com/stream_pi/client/Default.zip b/src/main/resources/com/stream_pi/client/Default.zip index 748677d111625eebb3a0ead726105bb22b8a41b7..add98b34078e2ebf54e6438e6f9a119a17074453 100644 GIT binary patch literal 6759 zcmb_gcOcaLA3tPe?_EkKBP;8WmD1UVL`L>m$H~enoe?Q?Mr1xwN=7A8_RdQ7CM1c6 zQfB0S_w{thQ|R~mz3-3D-5>XUe?G6*>oZ<&m>R)8dJqZrLyacV1^tL2LJ(*_h!bRq zbb{O22zojq^v+U%h;Jb%%$*&{&4JO~lMIBnZypZ>!u}rw3OlP2(a%X;qCe>u;(Jt6 zqMkd3ec|~l+58Woht|hjl!JnE?>0E6p9GmQ2eliA&Cglq_l>ewiIjdect*xL5b93leZ6(e>gEHm zuHb7pNwY|OSch^s;$$Uvmz7~xQ`%df*vo%C#&|m8b6fVxC>GcaACM<^$yT7Nm0@iT z_w$ERtP+cM9lP&7;dQ;;fdhs#Qcu|zHM)N>h(p?v3(2nX<(q!M(u^o6Yu8WZ;_9iEk;qg|%ewEvt^`92_iNDf^0qsS%T?BXZaT@IfFzYOr+?0@|C7o7MTD z!S#U%D?$~l3SEWP1$cq|s~I3bVB99a-{&C3=76~%;dTh?y`};7!%<7sjj0e~WiGNc zjRf3UMBEA@CIB(FloSxNkUTB`fxsmMti_}xMMcHo*5;Dd8{6hl3)lLrfpOcc^&*NW zt2oI|FRFegu1=0ba9lm6H%>WC%sI+=#Ny1M%MVRWPijYNF38GN?j$S~00O^7%ASzBwzJp&AoyPfMpn@KE@j)JakF4pFbrp|VPR@QKHcZ8dj zxr@X9AcMoZq(|7<*t+d8KcJ5&`|%BZ7-5$~vzgxpfwVA32wJ+juB-O8>exE}z_^Wn zh6c6$SB1$>x4z8ueCO{bOUWO`3QcH>02dX63$o{2g1B)KDuvLbr=7G>p5jhKCLWP) zJ?PYGs;O_W@0ArO*a{DV-=d7S7BMKu zyp))5Ok}@MnBI~2+2NS?H`mO|3R=xu+D=*Znjo`|8uAQ_Lq)<4bXE?rXoQ>+d# zUm&y!Jx-cYedU!yno+05xzt#nt4kw2RU~sFP(&DqoiN=H|7*xf)fHqwKwCCxU2f5k z!9BxpPR*7EI|UbQlZeFA>i1&lyp0V6Y`lW6Jp-MJ)Oh4h-kiE`RzDL4p&IrExzQBg z4J3SZTRc1I-7$;9{0mbIq2HpLx&+Gb0Dh+Ed?Tu``~V33o*#i-u={C?{`WNHVkdF@ zPfGm(TOyQ|!sG+!C8ZA1YhuEjsOW2WL~+cXC|)PFR&Jh)G^@!V79Hv#-%D~yS~;Ig z8l5JJpQqQ2FCVkCRrTpg7tH-WTOQk36Z%H<`MG!KW7!#QgED_{Qh~_0GAbyS^9dhi zO?isxR`92&%m#lSP$qWdV?!^_uuX-qO~4$V`j>*Ax4TzKbloD*LgW%&x}%CFiE^Fb z9d2OpEGK=VbBYt~8^oR-d6+a>PO1(X!FV|UDu*iLdEatlF+O%k4J~{rxGx3JC&03 zDxA`UsY}i@$Qw*%^M#}vW>`dI&Yhh$?<}&mRLYV*V5J`QXtM0_p*XX0t6pd5=p8T7 zudDDEXH5Gka#KPWwTWoOR9gpUyw0RVrX+!ht-TZIYbxmDeWf!;Z0O$mt1-r~hTpf- z%CafH?hiL!^i&c;qb4Z=^19Ya2F0`z$xK)f)#!JHqc4txA|-QzR@t>9OPE;gYXt9p z%ohp%qRJC{0j8f6eZ_F>umy#gvK`-yQZQMZ`;;!x@z6^!9bo{rkfMkii(#xZxV zm9+*aufFhEaCmf_Lg)E>ns_~tj@r@l+#O9y#O_u!Il0N*?PD%Uugr83->tF>=oYlh zsR+A15xjo+fHtj#^&w=pl~VLr-#~Kyd;f9cQsU3&YHJ_aO+y!N($;2~>C9OM%Cu<0 zGBEd(8NW+&G>U7z6NTuMd-N15SS)5r8y;vgU3rUKkzaDhd>JPV{t#QFaY==CQvR=? zSD&-#>n*kWN_?+Zs3W0=y%{0DPV^ZQGTG<2+tdtbNOvh<6eZu#4{ zd1i=>#L>-lcwWu=HBzZMsX;#{zK5F6Ywpkzse75IAc4@+UVR&;`y*mu#plaS0qONo zX%u6yvI7LRDZR-p(sLjNfrNIE-sYM9v-TiAvXWS!|yi0c#nR$;C%;Fc&9h zf46@FOBU(n%{Z-N0AZZCWNhrzdxLVrgiMotruW7Y^fVfWIsonM{ zI?qhGR=a;~CeisehYMK@O>DLIt%B(lkM_gWtw-PKP({WMHD-2BleEA$w;Qd4s8)>Pn(}y?=}kWm70qt_2I9uvmerXW_s(UYeMCHNyyz zHLWs8B5?vkD#375mn}OVqKqRs2HvDDbH$rU)~Z^|RV6LCp~=6i)b9)QX>wbeN(`yE z`9%1HLae@CFroO%0f|(bXbE9Nn%5-!njA06hbh-1ML)N+ra^rWUKh_JARw6FSb7&$ zhol;+XHJTrnRR=pS`p~%uTl>W>~C+@xWA?*d*J(I_;T`tWfpcRn2m&?f;L0MOIyz% zwVt7ND(61(3E3Py?yzTO0{bUdo1w6Yir^l6|2H|3L|a9ccxMGQAi%!<&tCvQf zK#yPIo)7C*Tw-vm&vlN63rc(@24rNGc9Wn1D&~zG@x$%5yp(9IVcYF1>>67R~E05Fgj{_!zk zCbUWT1?1_vc_r5L9sO??i~8AY`eLe8Qc(Kf&nFFfJ{98UIvlw?^s=hqQG)C7Xz}3_ zWTf!Xu5{ZbF|jFMi(u$81+aQWx30lJSFrK*ho-Hpmqj}})KjU9!Iq=mHsFS+QzIQV zj5ngi43lNDSxZ-SNKf^RgCA$cVLl*fA4k=M))7EQ?8UA#xR)JxgG!=nkHLs|_uNcb zxCxhv$xyP4U+v|pQ1({y=fM+iY++LkC3X~=;)M)2y?SU`7}hwLr!lD9%9K4ZR=~cx zQcdZQg{bD}(`0sbE9-wwXV~{e&VTVZ_v7?4357OidEOI7Jwb{NpgqpTd^4T2YYCp| zX_lJPnmvYIfhR!rr@8tpoH!yMUUnh8Z29Z#hsINoTZ7FK%Px?t&a%{?2lKl19IK?+ znmi^kL#yKI2}}lOYl7qbTA#6qMQDEV_{^N-Kks_?9N(f6^hwQ(QDW95YSvHQ<~m_w z3RWs^&}qO021QMi@nRVD@o=QEb_z++MB!CS`#6-|Djg^N$M*N*LSI`q2*Adn;fk zN&vHt3yk91&Gf%S@2A6g_rBRCirWn$VBT?oQB)?{Sk*7fZoF#OOYUgpH-QAq{8qOL zn0Z`aP#JqExo11F72)km1-vjWFp8tt%kc++zg+6(E9y_zy4Cps-WV4clrr{U+`Z=i zWwC&<#05stpLFNKKgnrtHuGnGx0)uvXyO8cn*Nj0f4p>{Sp-d5_sOJ*^I_A`LpM((u0um1pgygtIH(ITuY3Q$Ym~d zZMme3n{X$RsH{;#*2wI7)aPb@MD}zE{XV!TuY;?*wZ3qelb2iO`d@@jon_4Qr^m4h_y+0m z!k=dxxuw*sx;y4KGE875s2(=KHNEO3#p&yD;jY&th(gu@BH|D`EL4#zI#Wp^h`NlhHnRL7nPLjt z&2N-$KM0k!R4+J}=U_HC`$*x%Iiow}-BTCk60BxrW@g?PM?~fus}d|`vhIG!geths zPX>~2rw$B^FWt_ZLd)wIHoUj%dPApPq{N)e6SmV*`K0%ktRK9BzKyg`xJ=I2IBY+m zqaRuv^sM>#^cud(z(8)GXd`E6D|o$mdv%V_Laru~Jf8)nYu|zrdyR_4fT9{#}I40fc##5;?j6I~KrFlO+-bFzX3Q z&=PJ|Tm)agRK;(NUOlm3u)1GO`WXGzggM3v>9X}fiia1>la*z*cVYhBd{nZ-UQ*)3>`EWy+5Es!}S}vIev96qt^7#-EFk<%#v1RkaS%p&B?y^l)p?%cF_<>s}sn zj*iF3gA+F?3ju5)12?mV<7+>Z@m=wcd!nlTR6?@4_eOHI&4d@H#l@#|b5IK|NVpFT-Kh8~iQ8kDD z@JO*l-+M7TEVge*+dw%Q%2@CSh)alp^FlI~X;0ZcgLdi(6PUN6u~$0)U`l~MuF4_= zOuEDSK>bU(0=OatOe680f-na_h6WB1;P_Uq&f|j5dgC;F!oo;+F60-?R6wM7N!2fi zseirHlH}Zl*gSxkY$9oVkx3{}#Pt3X;lskCalXvO3S5k?j%W#va!i`|8PiYJm`g;e z4b1kv4r!7Y`#Rp*JDzfv`V$y7~6m%_6*I zvyhO$0kC|MYCjZ0kBu?pxehsse=li->$D#&b+n6q*Oz+`-vD#B5AKK35~Uhkth~z^ z(MGoUBQM@OMudf4&YyRREPs>k8ouNv^f?-n0&|`3WOUg{hERS(s^0n~eYK};#Yr<$H58%GHq~~@rzgiY1M~HsXsOnvB;yC`QM%~H$d)K# zM*Dh;!@=wg81&h@mB&GY;)%2-LrG^vTei2t-qo*vNryre_Hgc((zyLuHsKKX_O(BK zmeUGa&9EUUIsWla4YxTQ5K=7Qm|TilTtf5$pw$7GXfqMfC7tH)!?PrFxr<0e$T2Bg8Ai2dU!j2cO&@RH?q4Sj z*H_DM-68Dd4BPyDNSUmQi=kNh_?1Dc(yPOl?$IC>Nh)Q=`|FELT00cb`cERdv-_j| zrgr0v-4%#6lX-Dlb?#y(tmv&KDd_X+r`v~~$vYPyi=z{4axt^b=3|=yQ+1tbku=rl znz+oiv{V&X%XINnE2es!9b0NmH8*ZAt+UsH7wmN$K{;6+uDVPqIfGancFPtrH$LHb zBCf6#tI$>dfq$rJsWyp2BIa4)T5yQI^8!A8BzWU7#!ca+)AgB(@^fyLh%hcV9-j87 zO0BYPE5K#4BlKK=ppkFW@dsfxxotE{4ogKD?tuI*f*Asvc?CNWTgzYPOXIC!Kdx!> zitgrP6oamApg#;DY8p*pJIffgk;VAz zer3bJBOX}#{aKrUfcTG{+PQQ-fpHi2{WcP)uguKRO)UO_i_Pu=Rll2SkD~p0~ILBm^Bqm@}jNHG<&?+dG zm4}!4kZW(?T_{gHMQ7Xdt4ePuOW+XKqB7a}mM2wRH-blN(wgOHIyb;#Fx zt`q*L_s(LUFM4@%mb~IFnO-O2oF*p>E_~pNEV|$WN6KzBr+B{G?|@)qH{l?)i$Ua= zfsHj7rp&9a@oh%}WrjG`V3~A!NtlGI|_)f(vAdpgP^Y(AY^>^*dJrYj*CL5W0^$1GyT}DcAFmX zeA^A!eD??Wzuv{NQ3(A&|M{Vl?fed~3QG!{8Kw>-yyUL00RgLjH=V Date: Sun, 29 Aug 2021 17:32:12 +0100 Subject: [PATCH 02/12] changes --- src/main/java/com/stream_pi/client/Main.java | 100 +- .../animations/AnimateFXInterpolator.java | 2 +- .../client/animations/AnimationFX.java | 2 +- .../stream_pi/client/animations/Bounce.java | 2 +- .../com/stream_pi/client/animations/Flip.java | 2 +- .../client/animations/JackInTheBox.java | 2 +- .../stream_pi/client/animations/Jello.java | 2 +- .../stream_pi/client/animations/Pulse.java | 2 +- .../client/animations/RubberBand.java | 2 +- .../stream_pi/client/animations/Shake.java | 2 +- .../stream_pi/client/animations/Swing.java | 2 +- .../com/stream_pi/client/animations/Tada.java | 2 +- .../stream_pi/client/animations/Wobble.java | 2 +- .../stream_pi/client/connection/Client.java | 1176 +++++++---------- .../client/controller/ClientListener.java | 115 +- .../client/controller/Controller.java | 893 +++++-------- .../client/controller/ScreenMover.java | 114 +- .../client/controller/ScreenSaver.java | 162 +-- .../com/stream_pi/client/info/ClientInfo.java | 147 +-- .../com/stream_pi/client/info/License.java | 45 +- .../stream_pi/client/info/StartupFlags.java | 28 +- .../java/com/stream_pi/client/io/Config.java | 54 +- .../client/profile/ClientProfile.java | 967 +++++--------- .../client/profile/ClientProfiles.java | 144 +- .../com/stream_pi/client/window/Base.java | 12 +- .../window/ExceptionAndAlertHandler.java | 2 +- .../window/dashboard/DashboardBase.java | 2 +- .../dashboard/actiongridpane/ActionBox.java | 10 +- .../actiongridpane/ActionGridPane.java | 12 +- .../ActionGridPaneListener.java | 2 +- .../window/firsttimeuse/FinalConfigPane.java | 11 +- .../window/firsttimeuse/FirstTimeUse.java | 2 +- .../window/firsttimeuse/LicensePane.java | 2 +- .../window/firsttimeuse/WelcomePane.java | 2 +- .../window/firsttimeuse/WindowName.java | 2 +- .../window/settings/About/AboutTab.java | 20 +- .../window/settings/About/ContactTab.java | 2 +- .../window/settings/About/Contributor.java | 2 +- .../settings/About/ContributorsTab.java | 2 +- .../window/settings/About/LicenseTab.java | 2 +- .../client/window/settings/GeneralTab.java | 10 +- .../client/window/settings/SettingsBase.java | 2 +- 42 files changed, 1592 insertions(+), 2476 deletions(-) diff --git a/src/main/java/com/stream_pi/client/Main.java b/src/main/java/com/stream_pi/client/Main.java index 65f79390..d7559ed4 100644 --- a/src/main/java/com/stream_pi/client/Main.java +++ b/src/main/java/com/stream_pi/client/Main.java @@ -1,63 +1,65 @@ -package com.stream_pi.client; +// +// Decompiled by Procyon v0.6-prerelease +// -import com.stream_pi.client.controller.Controller; -import com.stream_pi.client.info.ClientInfo; +package com.stream_pi.client; import com.stream_pi.client.info.StartupFlags; -import javafx.application.Application; +import javafx.scene.Parent; import javafx.scene.Scene; +import com.stream_pi.client.controller.Controller; import javafx.stage.Stage; +import javafx.application.Application; -public class Main extends Application { - - - @Override - public void start(Stage stage) - { - Controller d = new Controller(); - Scene s = new Scene(d); +public class Main extends Application +{ + public void start(final Stage stage) { + final Controller d = new Controller(); + final Scene s = new Scene((Parent)d); stage.setScene(s); - d.setHostServices(getHostServices()); + d.setHostServices(this.getHostServices()); d.init(); } - - - public static void main(String[] args) - { - for(String eachArg : args) - { - if(!eachArg.startsWith("Stream-Pi")) - continue; - - String[] r = eachArg.split("="); - String arg = r[0]; - String val = r[1]; - - switch (arg) { - case "Stream-Pi.startupRunnerFileName": - StartupFlags.RUNNER_FILE_NAME = val; - break; - case "Stream-Pi.showShutDownButton": - StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = val.equals("true"); - break; - case "Stream-Pi.isXMode": - StartupFlags.IS_X_MODE = val.equals("true"); - break; - case "Stream-Pi.isShowFullScreenToggleButton": - StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = val.equals("true"); - break; - case "Stream-Pi.defaultFullScreenMode": - StartupFlags.DEFAULT_FULLSCREEN_MODE = val.equals("true"); - break; - case "Stream-Pi.enableScreenSaverFeature": - StartupFlags.SCREEN_SAVER_FEATURE = val.equals("true"); - break; - case "Stream-Pi.appendPathBeforeRunnerFileToOvercomeJPackageLimitation": - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = val.equals("true"); - break; + + public static void main(final String[] args) { + for (final String eachArg : args) { + if (eachArg.startsWith("Stream-Pi")) { + final String[] r = eachArg.split("="); + final String arg = r[0]; + final String val = r[1]; + final String s = arg; + switch (s) { + case "Stream-Pi.startupRunnerFileName": { + StartupFlags.RUNNER_FILE_NAME = val; + break; + } + case "Stream-Pi.showShutDownButton": { + StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = val.equals("true"); + break; + } + case "Stream-Pi.isXMode": { + StartupFlags.IS_X_MODE = val.equals("true"); + break; + } + case "Stream-Pi.isShowFullScreenToggleButton": { + StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = val.equals("true"); + break; + } + case "Stream-Pi.defaultFullScreenMode": { + StartupFlags.DEFAULT_FULLSCREEN_MODE = val.equals("true"); + break; + } + case "Stream-Pi.enableScreenSaverFeature": { + StartupFlags.SCREEN_SAVER_FEATURE = val.equals("true"); + break; + } + case "Stream-Pi.appendPathBeforeRunnerFileToOvercomeJPackageLimitation": { + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = val.equals("true"); + break; + } + } } } - launch(args); } } diff --git a/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java b/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java index 23b56e11..49fecb95 100644 --- a/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java +++ b/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/AnimationFX.java b/src/main/java/com/stream_pi/client/animations/AnimationFX.java index 2122351f..00bfe3f0 100644 --- a/src/main/java/com/stream_pi/client/animations/AnimationFX.java +++ b/src/main/java/com/stream_pi/client/animations/AnimationFX.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/Bounce.java b/src/main/java/com/stream_pi/client/animations/Bounce.java index c87abfda..7b9f8de8 100644 --- a/src/main/java/com/stream_pi/client/animations/Bounce.java +++ b/src/main/java/com/stream_pi/client/animations/Bounce.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/Flip.java b/src/main/java/com/stream_pi/client/animations/Flip.java index e6e6ba17..aa34814f 100644 --- a/src/main/java/com/stream_pi/client/animations/Flip.java +++ b/src/main/java/com/stream_pi/client/animations/Flip.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/JackInTheBox.java b/src/main/java/com/stream_pi/client/animations/JackInTheBox.java index c055af64..3e564f49 100644 --- a/src/main/java/com/stream_pi/client/animations/JackInTheBox.java +++ b/src/main/java/com/stream_pi/client/animations/JackInTheBox.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/Jello.java b/src/main/java/com/stream_pi/client/animations/Jello.java index 8ee61a56..044e7c85 100644 --- a/src/main/java/com/stream_pi/client/animations/Jello.java +++ b/src/main/java/com/stream_pi/client/animations/Jello.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/Pulse.java b/src/main/java/com/stream_pi/client/animations/Pulse.java index 4788ab3f..818d4a40 100644 --- a/src/main/java/com/stream_pi/client/animations/Pulse.java +++ b/src/main/java/com/stream_pi/client/animations/Pulse.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/RubberBand.java b/src/main/java/com/stream_pi/client/animations/RubberBand.java index 4c985de2..71da6c94 100644 --- a/src/main/java/com/stream_pi/client/animations/RubberBand.java +++ b/src/main/java/com/stream_pi/client/animations/RubberBand.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/Shake.java b/src/main/java/com/stream_pi/client/animations/Shake.java index dfd218ff..b168de7d 100644 --- a/src/main/java/com/stream_pi/client/animations/Shake.java +++ b/src/main/java/com/stream_pi/client/animations/Shake.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/Swing.java b/src/main/java/com/stream_pi/client/animations/Swing.java index 496f2b16..cead81e8 100644 --- a/src/main/java/com/stream_pi/client/animations/Swing.java +++ b/src/main/java/com/stream_pi/client/animations/Swing.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/Tada.java b/src/main/java/com/stream_pi/client/animations/Tada.java index ceb144ef..5ad65776 100644 --- a/src/main/java/com/stream_pi/client/animations/Tada.java +++ b/src/main/java/com/stream_pi/client/animations/Tada.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/animations/Wobble.java b/src/main/java/com/stream_pi/client/animations/Wobble.java index e3e17d50..a63be276 100644 --- a/src/main/java/com/stream_pi/client/animations/Wobble.java +++ b/src/main/java/com/stream_pi/client/animations/Wobble.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.animations; diff --git a/src/main/java/com/stream_pi/client/connection/Client.java b/src/main/java/com/stream_pi/client/connection/Client.java index 50c98dba..ac99c850 100644 --- a/src/main/java/com/stream_pi/client/connection/Client.java +++ b/src/main/java/com/stream_pi/client/connection/Client.java @@ -1,963 +1,693 @@ +// +// Decompiled by Procyon v0.6-prerelease +// + package com.stream_pi.client.connection; -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; -import com.stream_pi.action_api.action.DisplayTextAlignment; +import java.util.Objects; +import java.io.File; +import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.util.version.Version; import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.action.DisplayTextAlignment; import com.stream_pi.action_api.actionproperty.ClientProperties; import com.stream_pi.action_api.actionproperty.property.Property; -import com.stream_pi.action_api.actionproperty.property.Type; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.action_api.action.ActionType; +import java.util.ArrayList; +import java.util.Iterator; import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import javafx.geometry.Orientation; +import com.stream_pi.client.io.Config; import com.stream_pi.theme_api.Theme; -import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.action_api.action.Action; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import javafx.application.Platform; import com.stream_pi.util.comms.Message; -import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.version.Version; -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.geometry.Orientation; - -import java.io.*; +import java.io.IOException; +import com.stream_pi.util.exception.MinorException; +import java.net.SocketAddress; import java.net.InetSocketAddress; -import java.net.Socket; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; +import javafx.concurrent.Task; import java.util.logging.Logger; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.client.controller.ClientListener; +import java.util.concurrent.atomic.AtomicBoolean; +import java.io.ObjectInputStream; +import java.io.ObjectOutputStream; +import java.net.Socket; public class Client extends Thread { - private Socket socket; - private ObjectOutputStream oos; private ObjectInputStream ois; - - private AtomicBoolean stop = new AtomicBoolean(false); - + private AtomicBoolean stop; private ClientListener clientListener; private ExceptionAndAlertHandler exceptionAndAlertHandler; - private ClientInfo clientInfo; - private String serverIP; private int serverPort; private Logger logger; - private Runnable onConnectAndSetupToBeRun; - - public Client(String serverIP, int serverPort, ClientListener clientListener, - ExceptionAndAlertHandler exceptionAndAlertHandler, Runnable onConnectAndSetupToBeRun) - { + + public Client(final String serverIP, final int serverPort, final ClientListener clientListener, final ExceptionAndAlertHandler exceptionAndAlertHandler, final Runnable onConnectAndSetupToBeRun) { + this.stop = new AtomicBoolean(false); this.serverIP = serverIP; this.serverPort = serverPort; - this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.clientInfo = ClientInfo.getInstance(); this.clientListener = clientListener; - this.onConnectAndSetupToBeRun = onConnectAndSetupToBeRun; - - logger = Logger.getLogger(Client.class.getName()); - - clientListener.getExecutor().submit(new Task() { - @Override - protected Void call() - { - try - { - try - { - logger.info("Trying to connect to server at "+serverIP+":"+serverPort); - socket = new Socket(); - socket.connect(new InetSocketAddress(serverIP, serverPort), 5000); + this.logger = Logger.getLogger(Client.class.getName()); + clientListener.getExecutor().submit((Runnable)new Task() { + protected Void call() { + try { + try { + Client.this.logger.info("Trying to connect to server at " + serverIP + ":" + serverPort); + (Client.this.socket = new Socket()).connect(new InetSocketAddress(serverIP, serverPort), 5000); clientListener.setConnected(true); - logger.info("Connected to "+socket.getRemoteSocketAddress()+" !"); + Client.this.logger.info("Connected to " + Client.this.socket.getRemoteSocketAddress() + " !"); } - catch (IOException e) - { + catch (IOException e) { e.printStackTrace(); clientListener.setConnected(false); throw new MinorException("Connection Error", "Unable to connect to server. Please check settings and connection and try again."); } - finally - { + finally { clientListener.updateSettingsConnectDisconnectButton(); } - - try - { - oos = new ObjectOutputStream(socket.getOutputStream()); - ois = new ObjectInputStream(socket.getInputStream()); + try { + Client.this.oos = new ObjectOutputStream(Client.this.socket.getOutputStream()); + Client.this.ois = new ObjectInputStream(Client.this.socket.getInputStream()); } - catch (IOException e) - { - logger.severe(e.getMessage()); + catch (IOException e) { + Client.this.logger.severe(e.getMessage()); e.printStackTrace(); throw new MinorException("Unable to set up io Streams to server. Check connection and try again."); } - - start(); - } catch (MinorException e) - { - exceptionAndAlertHandler.handleMinorException(e); + Client.this.start(); + } + catch (MinorException e2) { + exceptionAndAlertHandler.handleMinorException(e2); } return null; } }); } - - public synchronized void exit() - { - if(stop.get()) + + public synchronized void exit() { + if (this.stop.get()) { return; - - logger.info("Stopping ..."); - - try - { - if(socket!=null) - { - disconnect(); + } + this.logger.info("Stopping ..."); + try { + if (this.socket != null) { + this.disconnect(); } } - catch (SevereException e) - { - logger.severe(e.getMessage()); - exceptionAndAlertHandler.handleSevereException(e); + catch (SevereException e) { + this.logger.severe(e.getMessage()); + this.exceptionAndAlertHandler.handleSevereException(e); e.printStackTrace(); } } - - - public synchronized void sendMessage(Message message) throws SevereException - { - try - { - oos.writeObject(message); - oos.flush(); - } - catch (IOException e) - { + + public synchronized void sendMessage(final Message message) throws SevereException { + try { + this.oos.writeObject(message); + this.oos.flush(); + } + catch (IOException e) { e.printStackTrace(); throw new SevereException("Unable to write to io Stream!"); } } - + @Override public void run() { - try - { - while(!stop.get()) - { - try - { - Message message = (Message) ois.readObject(); - - String header = message.getHeader(); - - logger.info("Message Received. Heading : "+header); - - switch (header) - { - case "ready" : onServerReady(); - break; - - case "action_icon" : onActionIconReceived(message); - break; - - case "disconnect" : serverDisconnected(message); - break; - - case "get_client_details" : sendClientDetails(); - break; - - case "get_client_screen_details" : sendClientScreenDetails(); - break; - - case "get_profiles" : sendProfileNamesToServer(); - break; - - case "get_profile_details": sendProfileDetailsToServer(message); - break; - - case "save_action_details": saveActionDetails(message); - break; - - case "delete_action": deleteAction(message); - break; - - case "get_themes": sendThemesToServer(); - break; - - case "save_client_details": saveClientDetails(message); - break; - - case "save_client_profile": saveProfileDetails(message); - break; - - case "delete_profile": deleteProfile(message); - break; - - case "action_failed": actionFailed(message); - break; - - case "set_toggle_status": onSetToggleStatus(message); - break; - - default: logger.warning("Command '"+header+"' does not match records. Make sure client and server versions are equal."); - + try { + while (!this.stop.get()) { + try { + final Message message = (Message)this.ois.readObject(); + final String header = message.getHeader(); + this.logger.info("Message Received. Heading : " + header); + final String s = header; + switch (s) { + case "ready": { + this.onServerReady(); + continue; + } + case "action_icon": { + this.onActionIconReceived(message); + continue; + } + case "disconnect": { + this.serverDisconnected(message); + continue; + } + case "get_client_details": { + this.sendClientDetails(); + continue; + } + case "get_client_screen_details": { + this.sendClientScreenDetails(); + continue; + } + case "get_profiles": { + this.sendProfileNamesToServer(); + continue; + } + case "get_profile_details": { + this.sendProfileDetailsToServer(message); + continue; + } + case "save_action_details": { + this.saveActionDetails(message); + continue; + } + case "delete_action": { + this.deleteAction(message); + continue; + } + case "get_themes": { + this.sendThemesToServer(); + continue; + } + case "save_client_details": { + this.saveClientDetails(message); + continue; + } + case "save_client_profile": { + this.saveProfileDetails(message); + continue; + } + case "delete_profile": { + this.deleteProfile(message); + continue; + } + case "action_failed": { + this.actionFailed(message); + continue; + } + case "set_toggle_status": { + this.onSetToggleStatus(message); + continue; + } + default: { + this.logger.warning("Command '" + header + "' does not match records. Make sure client and server versions are equal."); + continue; + } } + continue; } - catch (IOException | ClassNotFoundException e) - { - logger.severe(e.getMessage()); + catch (IOException | ClassNotFoundException ex) { + final Exception ex2; + final Exception e = ex2; + this.logger.severe(e.getMessage()); e.printStackTrace(); - - clientListener.setConnected(false); - clientListener.updateSettingsConnectDisconnectButton(); - clientListener.onDisconnect(); - - if(!stop.get()) - { - //isDisconnect.set(true); //Prevent running disconnect + this.clientListener.setConnected(false); + this.clientListener.updateSettingsConnectDisconnectButton(); + this.clientListener.onDisconnect(); + if (!this.stop.get()) { throw new MinorException("Accidentally disconnected from Server! (Failed at readUTF)"); } - - exit(); - + this.exit(); return; } + break; } } - catch (SevereException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - - exceptionAndAlertHandler.handleSevereException(e); + catch (SevereException e2) { + this.logger.severe(e2.getMessage()); + e2.printStackTrace(); + this.exceptionAndAlertHandler.handleSevereException(e2); } - catch (MinorException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - - exceptionAndAlertHandler.handleMinorException(e); + catch (MinorException e3) { + this.logger.severe(e3.getMessage()); + e3.printStackTrace(); + this.exceptionAndAlertHandler.handleMinorException(e3); } } - - private void onSetToggleStatus(Message message) - { - String[] arr = message.getStringArrValue(); - - String profileID = arr[0]; - String actionID = arr[1]; - boolean newStatus = arr[2].equals("true"); - - boolean currentStatus = clientListener.getToggleStatus(profileID,actionID); - - if(currentStatus == newStatus) - { + + private void onSetToggleStatus(final Message message) { + final String[] arr = message.getStringArrValue(); + final String profileID = arr[0]; + final String actionID = arr[1]; + final boolean newStatus = arr[2].equals("true"); + final boolean currentStatus = this.clientListener.getToggleStatus(profileID, actionID); + if (currentStatus == newStatus) { return; } - - ActionBox actionBox = clientListener.getActionBoxByProfileAndID(profileID, actionID); - - if(actionBox!=null) - { + final ActionBox actionBox = this.clientListener.getActionBoxByProfileAndID(profileID, actionID); + if (actionBox != null) { actionBox.setCurrentToggleStatus(newStatus); - Platform.runLater(()-> actionBox.toggle(newStatus)); + Platform.runLater(() -> actionBox.toggle(newStatus)); } } - - private void onActionIconReceived(Message message) throws MinorException - { - String profileID = message.getStringArrValue()[0]; - String actionID = message.getStringArrValue()[1]; - String state = message.getStringArrValue()[2]; - - clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon( - actionID, - message.getByteArrValue(), - state - ); - - Action a = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - clientListener.renderAction(profileID, a); + + private void onActionIconReceived(final Message message) throws MinorException { + final String profileID = message.getStringArrValue()[0]; + final String actionID = message.getStringArrValue()[1]; + final String state = message.getStringArrValue()[2]; + this.clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon(actionID, message.getByteArrValue(), state); + final Action a = this.clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + this.clientListener.renderAction(profileID, a); } - - - - //commands - - public synchronized void sendIcon(String profileID, String actionID, String state, byte[] icon) throws SevereException - { - try - { - Thread.sleep(50); - } - catch (InterruptedException e) - { + + public synchronized void sendIcon(final String profileID, final String actionID, final String state, final byte[] icon) throws SevereException { + try { + Thread.sleep(50L); + } + catch (InterruptedException e) { e.printStackTrace(); } - - Message message = new Message("action_icon"); - message.setStringArrValue(profileID, actionID, state); + final Message message = new Message("action_icon"); + message.setStringArrValue(new String[] { profileID, actionID, state }); message.setByteArrValue(icon); - sendMessage(message); + this.sendMessage(message); } - - public void disconnect() throws SevereException - { - disconnect(""); + + public void disconnect() throws SevereException { + this.disconnect(""); } - - public void disconnect(String message) throws SevereException - { - if(stop.get()) + + public void disconnect(final String message) throws SevereException { + if (this.stop.get()) { return; - - stop.set(true); - - logger.info("Sending server disconnect message ..."); - - Message m = new Message("disconnect"); + } + this.stop.set(true); + this.logger.info("Sending server disconnect message ..."); + final Message m = new Message("disconnect"); m.setStringValue(message); - sendMessage(m); - - try - { - if(!socket.isClosed()) - socket.close(); - - clientListener.setConnected(false); - clientListener.updateSettingsConnectDisconnectButton(); + this.sendMessage(m); + try { + if (!this.socket.isClosed()) { + this.socket.close(); + } + this.clientListener.setConnected(false); + this.clientListener.updateSettingsConnectDisconnectButton(); } - catch (IOException e) - { + catch (IOException e) { e.printStackTrace(); throw new SevereException("Unable to close socket"); } } - - public void onServerReady() - { - if(onConnectAndSetupToBeRun!=null) - { - onConnectAndSetupToBeRun.run(); - onConnectAndSetupToBeRun = null; + + public void onServerReady() { + if (this.onConnectAndSetupToBeRun != null) { + this.onConnectAndSetupToBeRun.run(); + this.onConnectAndSetupToBeRun = null; } } - - public void sendThemesToServer() throws SevereException - { - Message message = new Message("themes"); - - String[] arr = new String[clientListener.getThemes().getThemeList().size()*4]; - + + public void sendThemesToServer() throws SevereException { + final Message message = new Message("themes"); + final String[] arr = new String[this.clientListener.getThemes().getThemeList().size() * 4]; int x = 0; - for(int i = 0;i a = new ArrayList<>(); - + final ArrayList a = new ArrayList(); a.add(profileID); a.add(action.getID()); - a.add(action.getActionType()+""); - - if(action.getActionType() == ActionType.NORMAL || - action.getActionType() == ActionType.TOGGLE) { + a.add("" + action.getActionType()); + if (action.getActionType() == ActionType.NORMAL || action.getActionType() == ActionType.TOGGLE) { a.add(action.getVersion().getText()); } - else - { + else { a.add("no"); } - - if(action.getActionType() ==ActionType.NORMAL || - action.getActionType() == ActionType.TOGGLE) - { + if (action.getActionType() == ActionType.NORMAL || action.getActionType() == ActionType.TOGGLE) { a.add(action.getModuleName()); } - else - { + else { a.add("nut"); } - - //display - a.add(action.getBgColourHex()); - - //icon - - - StringBuilder allIconStatesNames = new StringBuilder(); - for(String eachState : action.getIcons().keySet()) - { + final StringBuilder allIconStatesNames = new StringBuilder(); + for (final String eachState : action.getIcons().keySet()) { allIconStatesNames.append(eachState).append("::"); } a.add(allIconStatesNames.toString()); - - - a.add(action.getCurrentIconState()+""); - - //text - a.add(action.isShowDisplayText()+""); + a.add(action.getCurrentIconState()); + a.add("" + action.isShowDisplayText()); a.add(action.getDisplayTextFontColourHex()); a.add(action.getDisplayText()); - a.add(action.getNameFontSize()+""); - a.add(action.getDisplayTextAlignment()+""); - - //location - - if(action.getLocation() == null) - { + a.add("" + action.getNameFontSize()); + a.add("" + action.getDisplayTextAlignment()); + if (action.getLocation() == null) { a.add("-1"); a.add("-1"); } - else - { - a.add(action.getLocation().getRow()+""); - a.add(action.getLocation().getCol()+""); + else { + a.add("" + action.getLocation().getRow()); + a.add("" + action.getLocation().getCol()); } - a.add(action.getParent()); - - a.add(action.getDelayBeforeExecuting()+""); - - //client properties - - ClientProperties clientProperties = action.getClientProperties(); - - a.add(clientProperties.getSize()+""); - - for(Property property : clientProperties.get()) - { + a.add("" + action.getDelayBeforeExecuting()); + final ClientProperties clientProperties = action.getClientProperties(); + a.add("" + clientProperties.getSize()); + for (final Property property : clientProperties.get()) { a.add(property.getName()); a.add(property.getRawValue()); } - - - - Message message = new Message("action_details"); - + final Message message = new Message("action_details"); String[] x = new String[a.size()]; x = a.toArray(x); - message.setStringArrValue(x); - sendMessage(message); - + this.sendMessage(message); } - - public void saveActionDetails(Message message) - { - String[] r = message.getStringArrValue(); - - String profileID = r[0]; - - String actionID = r[1]; - ActionType actionType = ActionType.valueOf(r[2]); - - //3 - Version - //4 - ModuleName - - //display - String bgColorHex = r[5]; - - String[] iconStates = r[6].split("::"); - String currentIconState = r[7]; - - //text - boolean isShowDisplayText = r[8].equals("true"); - String displayFontColor = r[9]; - String displayText = r[10]; - double displayLabelFontSize = Double.parseDouble(r[11]); - DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[12]); - - //location - String row = r[13]; - String col = r[14]; - - Location location = new Location(Integer.parseInt(row), Integer.parseInt(col)); - - Action action = new Action(actionID, actionType); - - if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE) - { - try - { + + public void saveActionDetails(final Message message) { + final String[] r = message.getStringArrValue(); + final String profileID = r[0]; + final String actionID = r[1]; + final ActionType actionType = ActionType.valueOf(r[2]); + final String bgColorHex = r[5]; + final String[] iconStates = r[6].split("::"); + final String currentIconState = r[7]; + final boolean isShowDisplayText = r[8].equals("true"); + final String displayFontColor = r[9]; + final String displayText = r[10]; + final double displayLabelFontSize = Double.parseDouble(r[11]); + final DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[12]); + final String row = r[13]; + final String col = r[14]; + final Location location = new Location(Integer.parseInt(row), Integer.parseInt(col)); + final Action action = new Action(actionID, actionType); + Label_0190: { + if (actionType != ActionType.NORMAL) { + if (actionType != ActionType.TOGGLE) { + break Label_0190; + } + } + try { action.setVersion(new Version(r[3])); action.setModuleName(r[4]); } - catch (Exception e) - { - logger.severe(e.getMessage()); + catch (Exception e) { + this.logger.severe(e.getMessage()); e.printStackTrace(); } } - - action.setBgColourHex(bgColorHex); - action.setShowDisplayText(isShowDisplayText); action.setDisplayTextFontColourHex(displayFontColor); action.setDisplayText(displayText); action.setDisplayTextAlignment(displayTextAlignment); action.setNameFontSize(displayLabelFontSize); action.setCurrentIconState(currentIconState); - action.setLocation(location); - - - String parent = r[15]; + final String parent = r[15]; action.setParent(parent); - - //client properties - action.setDelayBeforeExecuting(Integer.parseInt(r[16])); - - int clientPropertiesSize = Integer.parseInt(r[17]); - - ClientProperties clientProperties = new ClientProperties(); - - if(actionType == ActionType.FOLDER) + final int clientPropertiesSize = Integer.parseInt(r[17]); + final ClientProperties clientProperties = new ClientProperties(); + if (actionType == ActionType.FOLDER) { clientProperties.setDuplicatePropertyAllowed(true); - - for(int i = 18;i<((clientPropertiesSize*2) + 18); i+=2) - { - Property property = new Property(r[i], Type.STRING); - property.setRawValue(r[i+1]); - + } + for (int i = 18; i < clientPropertiesSize * 2 + 18; i += 2) { + final Property property = new Property(r[i], Type.STRING); + property.setRawValue(r[i + 1]); clientProperties.addProperty(property); } - action.setClientProperties(clientProperties); - - try - { - Action old = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID()); - - if(old != null) - { - for(String oldState : old.getIcons().keySet()) - { + try { + final Action old = this.clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID()); + if (old != null) { + for (String oldState : old.getIcons().keySet()) { boolean isPresent = false; - for(String state : iconStates) - { - if(state.equals(oldState)) - { + for (final String state : iconStates) { + if (state.equals(oldState)) { isPresent = true; action.addIcon(state, old.getIcon(state)); break; } } - - if(!isPresent) - { - // State no longer exists. Delete. - - new File(Config.getInstance().getIconsPath()+"/"+actionID+"___"+oldState).delete(); + if (!isPresent) { + new File(Config.getInstance().getIconsPath() + "/" + actionID + "___" + oldState).delete(); } } } - - clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action); - - clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action); - - clientListener.renderAction(profileID, action); - - if(clientListener.getScreenSaver()!=null) - { - Platform.runLater(()->clientListener.getScreenSaver().restart()); + this.clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action); + this.clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action); + this.clientListener.renderAction(profileID, action); + if (this.clientListener.getScreenSaver() != null) { + Platform.runLater(() -> this.clientListener.getScreenSaver().restart()); } } - catch (Exception e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); + catch (Exception e2) { + e2.printStackTrace(); + this.exceptionAndAlertHandler.handleMinorException(new MinorException(e2.getMessage())); } } - - public void deleteAction(Message message) - { - try - { - String[] arr = message.getStringArrValue(); - String profileID = arr[0]; - String actionID = arr[1]; - - Action acc = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - - if(acc == null) - { - exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action "+actionID+" since it does not exist.")); + + public void deleteAction(final Message message) { + try { + final String[] arr = message.getStringArrValue(); + final String profileID = arr[0]; + final String actionID = arr[1]; + final Action acc = this.clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + if (acc == null) { + this.exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action " + actionID + " since it does not exist.")); return; } - - if(acc.getActionType() == ActionType.FOLDER) - { - ArrayList idsToBeRemoved = new ArrayList<>(); - - ArrayList folders = new ArrayList<>(); - String folderToBeDeletedID = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID(); - + if (acc.getActionType() == ActionType.FOLDER) { + final ArrayList idsToBeRemoved = new ArrayList(); + final ArrayList folders = new ArrayList(); + final String folderToBeDeletedID = this.clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID(); folders.add(folderToBeDeletedID); - boolean startOver = true; - while(startOver) - { + while (startOver) { startOver = false; - for(Action action : clientListener.getClientProfiles().getProfileFromID(profileID).getActions()) - { - if(folders.contains(action.getParent())) - { - if(!idsToBeRemoved.contains(action.getID())) - { - idsToBeRemoved.add(action.getID()); - if(action.getActionType() == ActionType.FOLDER) - { - folders.add(action.getID()); - startOver = true; - } + for (final Action action : this.clientListener.getClientProfiles().getProfileFromID(profileID).getActions()) { + if (folders.contains(action.getParent()) && !idsToBeRemoved.contains(action.getID())) { + idsToBeRemoved.add(action.getID()); + if (action.getActionType() != ActionType.FOLDER) { + continue; } + folders.add(action.getID()); + startOver = true; } } } - - - for(String ids : idsToBeRemoved) - { - clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids); + for (final String ids : idsToBeRemoved) { + this.clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids); } - + final ClientListener clientListener = this.clientListener; + Objects.requireNonNull(clientListener); Platform.runLater(clientListener::renderRootDefaultProfile); - } - else if (acc.getActionType() == ActionType.COMBINE) - { - for(Property property : acc.getClientProperties().get()) - { - clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue()); + else if (acc.getActionType() == ActionType.COMBINE) { + for (final Property property : acc.getClientProperties().get()) { + this.clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue()); } } - - - clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID()); - - clientListener.getClientProfiles().getProfileFromID(profileID).saveActions(); - - if(acc.getLocation().getCol()!=-1) - { - Platform.runLater(()-> { - if (clientListener.getCurrentProfile().getID().equals(profileID) - && clientListener.getCurrentParent().equals(acc.getParent())) - { - clientListener.clearActionBox( - acc.getLocation().getCol(), - acc.getLocation().getRow() - ); + this.clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID()); + this.clientListener.getClientProfiles().getProfileFromID(profileID).saveActions(); + if (acc.getLocation().getCol() != -1) { + Platform.runLater(() -> { + if (this.clientListener.getCurrentProfile().getID().equals(profileID) && this.clientListener.getCurrentParent().equals(acc.getParent())) { + this.clientListener.clearActionBox(acc.getLocation().getCol(), acc.getLocation().getRow()); } }); } - - } - catch (Exception e) - { + catch (Exception e) { e.printStackTrace(); - exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); + this.exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); } } - - public void saveClientDetails(Message message) - { - try - { - boolean reInit = false; - - String[] sep = message.getStringArrValue(); - + + public void saveClientDetails(final Message message) { + try { + final boolean reInit = false; + final String[] sep = message.getStringArrValue(); Config.getInstance().setNickName(sep[0]); - - Config.getInstance().setStartupProfileID(sep[1]); - - String oldThemeFullName = Config.getInstance().getCurrentThemeFullName(); - String newThemeFullName = sep[2]; - + final String oldThemeFullName = Config.getInstance().getCurrentThemeFullName(); + final String newThemeFullName = sep[2]; Config.getInstance().setCurrentThemeFullName(sep[2]); Config.getInstance().save(); - - if(!oldThemeFullName.equals(newThemeFullName)) - { - Platform.runLater(()-> { + if (!oldThemeFullName.equals(newThemeFullName)) { + Platform.runLater(() -> { try { - clientListener.initThemes(); - } catch (SevereException e) { - exceptionAndAlertHandler.handleSevereException(e); + this.clientListener.initThemes(); + } + catch (SevereException e2) { + this.exceptionAndAlertHandler.handleSevereException(e2); } + return; }); } - + final ClientListener clientListener = this.clientListener; + Objects.requireNonNull(clientListener); Platform.runLater(clientListener::loadSettings); } - catch (SevereException e) - { + catch (SevereException e) { e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(e); + this.exceptionAndAlertHandler.handleSevereException(e); } } - - public void saveProfileDetails(Message message) throws SevereException, MinorException - { - String[] sep = message.getStringArrValue(); - - ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(sep[0]); - - if(clientProfile == null) - { - clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+sep[0]+".xml"), - Config.getInstance().getIconsPath()); + + public void saveProfileDetails(final Message message) throws SevereException, MinorException { + final String[] sep = message.getStringArrValue(); + ClientProfile clientProfile = this.clientListener.getClientProfiles().getProfileFromID(sep[0]); + if (clientProfile == null) { + clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath() + "/" + sep[0] + ".xml"), Config.getInstance().getIconsPath()); } - clientProfile.setName(sep[1]); clientProfile.setRows(Integer.parseInt(sep[2])); clientProfile.setCols(Integer.parseInt(sep[3])); clientProfile.setActionSize(Integer.parseInt(sep[4])); clientProfile.setActionGap(Integer.parseInt(sep[5])); - - try - { - clientListener.getClientProfiles().addProfile(clientProfile); + try { + this.clientListener.getClientProfiles().addProfile(clientProfile); clientProfile.saveProfileDetails(); - clientListener.refreshGridIfCurrentProfile(sep[0]); + this.clientListener.refreshGridIfCurrentProfile(sep[0]); + final ClientListener clientListener = this.clientListener; + Objects.requireNonNull(clientListener); Platform.runLater(clientListener::loadSettings); } - catch (Exception e) - { + catch (Exception e) { e.printStackTrace(); throw new SevereException(e.getMessage()); } } - - public void deleteProfile(Message message) - { - clientListener.getClientProfiles().deleteProfile(clientListener.getClientProfiles().getProfileFromID( - message.getStringValue() - )); - - if(clientListener.getCurrentProfile().getID().equals(message.getStringValue())) - { + + public void deleteProfile(final Message message) { + this.clientListener.getClientProfiles().deleteProfile(this.clientListener.getClientProfiles().getProfileFromID(message.getStringValue())); + if (this.clientListener.getCurrentProfile().getID().equals(message.getStringValue())) { + final ClientListener clientListener = this.clientListener; + Objects.requireNonNull(clientListener); Platform.runLater(clientListener::renderRootDefaultProfile); } } - - public void onActionClicked(String profileID, String actionID, boolean toggleState) throws SevereException - { - Message m = new Message("action_clicked"); - m.setStringArrValue(profileID, actionID, toggleState+""); - sendMessage(m); + + public void onActionClicked(final String profileID, final String actionID, final boolean toggleState) throws SevereException { + final Message m = new Message("action_clicked"); + m.setStringArrValue(new String[] { profileID, actionID, "" + toggleState }); + this.sendMessage(m); } - - public void updateOrientationOnClient(Orientation orientation) throws SevereException - { - Message m = new Message("client_orientation"); + + public void updateOrientationOnClient(final Orientation orientation) throws SevereException { + final Message m = new Message("client_orientation"); m.setStringValue(orientation.toString()); - sendMessage(m); + this.sendMessage(m); } - - public void actionFailed(Message message) - { - String[] r = message.getStringArrValue(); - String profileID = r[0]; - String actionID = r[1]; - clientListener.onActionFailed(profileID, actionID); + + public void actionFailed(final Message message) { + final String[] r = message.getStringArrValue(); + final String profileID = r[0]; + final String actionID = r[1]; + this.clientListener.onActionFailed(profileID, actionID); } } diff --git a/src/main/java/com/stream_pi/client/controller/ClientListener.java b/src/main/java/com/stream_pi/client/controller/ClientListener.java index aedf3ed3..da1ac435 100644 --- a/src/main/java/com/stream_pi/client/controller/ClientListener.java +++ b/src/main/java/com/stream_pi/client/controller/ClientListener.java @@ -1,86 +1,97 @@ +// +// Decompiled by Procyon v0.6-prerelease +// + package com.stream_pi.client.controller; +import javafx.geometry.Orientation; +import java.util.concurrent.ExecutorService; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; import com.stream_pi.action_api.action.Action; -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.ClientProfiles; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; -import com.stream_pi.theme_api.Theme; +import com.stream_pi.client.connection.Client; import com.stream_pi.theme_api.Themes; -import com.stream_pi.util.exception.SevereException; -import javafx.geometry.Orientation; - -import java.util.concurrent.ExecutorService; +import com.stream_pi.client.profile.ClientProfiles; public interface ClientListener { - void onActionFailed(String profileID, String actionID); - void onActionClicked(String profileID, String actionID, boolean toggleState); + void onActionFailed(final String p0, final String p1); + + void onActionClicked(final String p0, final String p1, final boolean p2); + ClientProfiles getClientProfiles(); - + Themes getThemes(); + String getDefaultThemeFullName(); - + Client getClient(); - + void renderRootDefaultProfile(); - - void setConnected(boolean isConnected); + + void setConnected(final boolean p0); + boolean isConnected(); - - void renderProfile(ClientProfile clientProfile, boolean freshRender); - - void clearActionBox(int col, int row); - void addBlankActionBox(int col, int row); - void renderAction(String currentProfileID, Action action); - void refreshGridIfCurrentProfile(String currentProfileID); - ActionBox getActionBox(int col, int row); - + void renderProfile(final ClientProfile p0, final boolean p1); + + void clearActionBox(final int p0, final int p1); + + void addBlankActionBox(final int p0, final int p1); + + void renderAction(final String p0, final Action p1); + + void refreshGridIfCurrentProfile(final String p0); + + ActionBox getActionBox(final int p0, final int p1); + ClientProfile getCurrentProfile(); - + String getCurrentParent(); - + Theme getCurrentTheme(); - + void initLogger() throws SevereException; + void init(); - - void disconnect(String message) throws SevereException; - + + void disconnect(final String p0) throws SevereException; + void setupClientConnection(); - - void setupClientConnection(Runnable onConnect); - + + void setupClientConnection(final Runnable p0); + void updateSettingsConnectDisconnectButton(); - + void onCloseRequest(); - + void loadSettings(); - + double getStageWidth(); + double getStageHeight(); - + void onDisconnect(); - - boolean getToggleStatus(String profileID, String actionID); - - ActionBox getActionBoxByProfileAndID(String profileID, String actionID); - - void openURL(String URL); - + + boolean getToggleStatus(final String p0, final String p1); + + ActionBox getActionBoxByProfileAndID(final String p0, final String p1); + + void openURL(final String p0); + void factoryReset(); + void exitApp(); - + ExecutorService getExecutor(); - + Orientation getCurrentOrientation(); - - void setFirstRun(boolean firstRun); - + + void setFirstRun(final boolean p0); + ScreenSaver getScreenSaver(); - + void initThemes() throws SevereException; } diff --git a/src/main/java/com/stream_pi/client/controller/Controller.java b/src/main/java/com/stream_pi/client/controller/Controller.java index 993c6fcd..18b32443 100644 --- a/src/main/java/com/stream_pi/client/controller/Controller.java +++ b/src/main/java/com/stream_pi/client/controller/Controller.java @@ -1,723 +1,476 @@ +// +// Decompiled by Procyon v0.6-prerelease +// + package com.stream_pi.client.controller; +import javafx.beans.value.ObservableValue; +import javafx.stage.WindowEvent; +import javafx.event.ActionEvent; +import com.stream_pi.util.iohelper.IOHelper; import com.gluonhq.attach.browser.BrowserService; -import com.gluonhq.attach.orientation.OrientationService; -import com.gluonhq.attach.vibration.VibrationService; import com.stream_pi.action_api.action.Action; -import com.stream_pi.client.Main; -import com.stream_pi.client.connection.Client; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.profile.ClientProfiles; -import com.stream_pi.client.window.Base; import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; -import com.stream_pi.util.alert.StreamPiAlert; +import com.gluonhq.attach.vibration.VibrationService; import com.stream_pi.util.alert.StreamPiAlertListener; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.gluonhq.attach.lifecycle.LifecycleService; -import com.gluonhq.attach.util.Services; - -import com.stream_pi.util.iohelper.IOHelper; -import com.stream_pi.util.platform.PlatformType; -import com.stream_pi.util.startatboot.StartAtBoot; +import java.util.logging.Level; +import javafx.scene.Node; +import javafx.beans.value.WritableValue; import javafx.animation.Interpolator; -import javafx.animation.KeyFrame; import javafx.animation.KeyValue; +import javafx.util.Duration; +import javafx.animation.KeyFrame; +import java.util.function.Consumer; +import com.gluonhq.attach.util.Services; +import com.gluonhq.attach.lifecycle.LifecycleService; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import java.util.Iterator; +import com.stream_pi.util.exception.SevereException; +import com.gluonhq.attach.orientation.OrientationService; +import com.stream_pi.client.profile.ClientProfiles; +import java.io.File; +import com.stream_pi.client.io.Config; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.startatboot.StartAtBoot; +import com.stream_pi.client.Main; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.util.platform.PlatformType; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.util.platform.Platform; import javafx.animation.Timeline; -import javafx.application.Platform; -import javafx.beans.InvalidationListener; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; import javafx.geometry.Orientation; -import javafx.scene.Node; -import javafx.scene.input.KeyCombination; -import javafx.scene.layout.StackPane; -import javafx.stage.Screen; -import javafx.util.Duration; - -import java.io.*; -import java.net.URISyntaxException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Level; - +import com.stream_pi.client.connection.Client; +import com.stream_pi.client.window.Base; public class Controller extends Base { private Client client; - - public Controller() - { - client = null; + private boolean firstRun; + private ScreenSaver screenSaver; + private ScreenMover screenMover; + private Orientation currentOrientation; + private Timeline openSettingsTimeLine; + private Timeline closeSettingsTimeLine; + private boolean isConnected; + + public Controller() { + this.firstRun = true; + this.screenSaver = null; + this.screenMover = null; + this.currentOrientation = null; + this.isConnected = false; + this.client = null; } - - - private boolean firstRun = true; - private ScreenSaver screenSaver = null; - private ScreenMover screenMover = null; - - @Override - public ScreenSaver getScreenSaver() - { - return screenSaver; + + public ScreenSaver getScreenSaver() { + return this.screenSaver; } - - @Override - public void init() - { - try - { - if(firstRun) - initBase(); - - - if(getConfig().isScreenSaverEnabled()) - { - if(screenSaver == null) - { - screenSaver = new ScreenSaver(this, getConfig().getScreenSaverTimeout()); - getChildren().add(screenSaver); - screenSaver.toBack(); + + public void init() { + try { + if (this.firstRun) { + this.initBase(); + } + if (this.getConfig().isScreenSaverEnabled()) { + if (this.screenSaver == null) { + this.screenSaver = new ScreenSaver(this, this.getConfig().getScreenSaverTimeout()); + this.getChildren().add((Object)this.screenSaver); + this.screenSaver.toBack(); } - else - { - screenSaver.setTimeout(getConfig().getScreenSaverTimeout()); - screenSaver.restart(); + else { + this.screenSaver.setTimeout(this.getConfig().getScreenSaverTimeout()); + this.screenSaver.restart(); } } - else - { - if(screenSaver != null) - { - screenSaver.stop(); - getChildren().remove(screenSaver); - screenSaver = null; - } + else if (this.screenSaver != null) { + this.screenSaver.stop(); + this.getChildren().remove((Object)this.screenSaver); + this.screenSaver = null; } - - - if(getClientInfo().getPlatform() != com.stream_pi.util.platform.Platform.ANDROID) - { - if(getConfig().isStartOnBoot()) - { - if(StartupFlags.IS_X_MODE != getConfig().isStartupXMode()) - { - StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), - Main.class.getProtectionDomain().getCodeSource().getLocation(), - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); - - boolean result = startAtBoot.delete(); - if(!result) - { - 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, " + - "delete the old starter file, then exit and restart Stream-Pi as normal user.", StreamPiAlertType.ERROR).show(); + if (this.getClientInfo().getPlatform() != Platform.ANDROID) { + if (this.getConfig().isStartOnBoot() && StartupFlags.IS_X_MODE != this.getConfig().isStartupXMode()) { + final StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), Main.class.getProtectionDomain().getCodeSource().getLocation(), StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); + final boolean result = startAtBoot.delete(); + if (!result) { + new StreamPiAlert("Uh Oh!", "Unable to delete the previous starter file.\nThis 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(); + } + else { + try { + startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); + this.getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE); } - else - { - try - { - startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); - getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE); - } - catch (MinorException e) - { - getConfig().setStartOnBoot(false); - handleMinorException(e); - } + catch (MinorException e) { + this.getConfig().setStartOnBoot(false); + this.handleMinorException(e); } } } - - setupFlags(); - - if(!getConfig().getIsFullScreenMode()) - { - getStage().setWidth(getConfig().getStartupWindowWidth()); - getStage().setHeight(getConfig().getStartupWindowHeight()); + this.setupFlags(); + if (!this.getConfig().getIsFullScreenMode()) { + this.getStage().setWidth(this.getConfig().getStartupWindowWidth()); + this.getStage().setHeight(this.getConfig().getStartupWindowHeight()); } } - - - setupDashWindow(); - - getStage().show(); - - - if(getConfig().isScreenMoverEnabled()) - { - if(screenMover == null) - { - screenMover = new ScreenMover(getStage(), getConfig().getScreenMoverInterval(), - getConfig().getScreenMoverXChange(), - getConfig().getScreenMoverYChange()); + this.setupDashWindow(); + this.getStage().show(); + if (this.getConfig().isScreenMoverEnabled()) { + if (this.screenMover == null) { + this.screenMover = new ScreenMover(this.getStage(), this.getConfig().getScreenMoverInterval(), this.getConfig().getScreenMoverXChange(), this.getConfig().getScreenMoverYChange()); } - else - { - screenMover.setInterval(getConfig().getScreenMoverInterval()); - screenMover.restart(); + else { + this.screenMover.setInterval(this.getConfig().getScreenMoverInterval()); + this.screenMover.restart(); } } - else - { - if(screenMover != null) - { - screenMover.stop(); - screenMover = null; - } + else if (this.screenMover != null) { + this.screenMover.stop(); + this.screenMover = null; } - - - if(Config.getInstance().isFirstTimeUse()) + if (Config.getInstance().isFirstTimeUse()) { return; - - setupSettingsWindowsAnimations(); - - - - getDashboardPane().getSettingsButton().setOnAction(event -> { - openSettingsTimeLine.play(); - }); - - getSettingsPane().getCloseButton().setOnAction(event -> { - closeSettingsTimeLine.play(); - }); - - setClientProfiles(new ClientProfiles(new File(getConfig().getProfilesPath()), getConfig().getStartupProfileID())); - - if(getClientProfiles().getLoadingErrors().size() > 0) - { - StringBuilder errors = new StringBuilder("Please rectify the following errors and try again"); - - for(MinorException exception : getClientProfiles().getLoadingErrors()) - { - errors.append("\n * ") - .append(exception.getMessage()); + } + this.setupSettingsWindowsAnimations(); + this.getDashboardPane().getSettingsButton().setOnAction(event -> this.openSettingsTimeLine.play()); + this.getSettingsPane().getCloseButton().setOnAction(event -> this.closeSettingsTimeLine.play()); + this.setClientProfiles(new ClientProfiles(new File(this.getConfig().getProfilesPath()), this.getConfig().getStartupProfileID())); + if (this.getClientProfiles().getLoadingErrors().size() > 0) { + final StringBuilder errors = new StringBuilder("Please rectify the following errors and try again"); + for (final MinorException exception : this.getClientProfiles().getLoadingErrors()) { + errors.append("\n * ").append(exception.getMessage()); } - throw new MinorException("Profiles", errors.toString()); } - - - if(getClientInfo().isPhone() && getConfig().isInvertRowsColsOnDeviceRotate()) - { + if (this.getClientInfo().isPhone() && this.getConfig().isInvertRowsColsOnDeviceRotate()) { OrientationService.create().ifPresent(orientationService -> { - if(orientationService.getOrientation().isPresent()) - { - setCurrentOrientation(orientationService.getOrientation().get()); + if (orientationService.getOrientation().isPresent()) { + this.setCurrentOrientation(orientationService.getOrientation().get()); orientationService.orientationProperty().addListener((observableValue, oldOrientation, newOrientation) -> { - setCurrentOrientation(newOrientation); - - getDashboardPane().renderProfile( - getCurrentProfile(), - getCurrentParent(), - true - ); - - getExecutor().submit(()->{ - try - { - if(isConnected()) - { - getClient().updateOrientationOnClient(getCurrentOrientation()); + this.setCurrentOrientation(newOrientation); + this.getDashboardPane().renderProfile(this.getCurrentProfile(), this.getCurrentParent(), true); + this.getExecutor().submit(() -> { + try { + if (this.isConnected()) { + this.getClient().updateOrientationOnClient(this.getCurrentOrientation()); } } - catch (SevereException e) - { - handleSevereException(e); + catch (SevereException e) { + this.handleSevereException(e); } }); }); } + return; }); } - - renderRootDefaultProfile(); - loadSettings(); - - if(firstRun) - { - if(getConfig().isConnectOnStartup()) - { - setupClientConnection(); + this.renderRootDefaultProfile(); + this.loadSettings(); + if (this.firstRun) { + if (this.getConfig().isConnectOnStartup()) { + this.setupClientConnection(); } - firstRun = false; + this.firstRun = false; } - - if(!getClientInfo().isPhone()) - { - getStage().widthProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); - getStage().heightProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); + if (!this.getClientInfo().isPhone()) { + this.getStage().widthProperty().addListener((observableValue, orientation, t1) -> this.syncClientSizeDetailsWithServer()); + this.getStage().heightProperty().addListener((observableValue, orientation, t1) -> this.syncClientSizeDetailsWithServer()); } } - catch (SevereException e) - { - handleSevereException(e); + catch (SevereException e2) { + this.handleSevereException(e2); } - catch (MinorException e) - { - handleMinorException(e); + catch (MinorException e3) { + this.handleMinorException(e3); } } - - private Orientation currentOrientation = null; - - @Override - public Orientation getCurrentOrientation() - { - return currentOrientation; + + public Orientation getCurrentOrientation() { + return this.currentOrientation; } - - private void setCurrentOrientation(Orientation currentOrientation) - { + + private void setCurrentOrientation(final Orientation currentOrientation) { this.currentOrientation = currentOrientation; } - - public void syncClientSizeDetailsWithServer() - { - if(isConnected()) - { + + public void syncClientSizeDetailsWithServer() { + if (this.isConnected()) { try { - client.sendClientScreenDetails(); - } catch (SevereException e) { + this.client.sendClientScreenDetails(); + } + catch (SevereException e) { e.printStackTrace(); } } } - - @Override - public void setupClientConnection() - { - setupClientConnection(null); + + public void setupClientConnection() { + this.setupClientConnection(null); } - - @Override - public void setupClientConnection(Runnable onConnect) - { - if(getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) //probably already connecting + + public void setupClientConnection(final Runnable onConnect) { + if (this.getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) { return; - - Platform.runLater(()->getSettingsPane().getGeneralTab().setDisableStatus(true)); - client = new Client(getConfig().getSavedServerHostNameOrIP(), getConfig().getSavedServerPort(), this, this, onConnect); + } + javafx.application.Platform.runLater(() -> this.getSettingsPane().getGeneralTab().setDisableStatus(true)); + this.client = new Client(this.getConfig().getSavedServerHostNameOrIP(), this.getConfig().getSavedServerPort(), this, this, onConnect); } - - @Override + public void updateSettingsConnectDisconnectButton() { - getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus(); + this.getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus(); } - - @Override - public void disconnect(String message) throws SevereException { - client.disconnect(message); + + public void disconnect(final String message) throws SevereException { + this.client.disconnect(message); } - - - public void setupDashWindow() - { - getStage().setTitle("Stream-Pi Client"); - getStage().setOnCloseRequest(e->{ - onCloseRequest(); - exitApp(); + + public void setupDashWindow() { + this.getStage().setTitle("Stream-Pi Client"); + this.getStage().setOnCloseRequest(e -> { + this.onCloseRequest(); + this.exitApp(); }); } - - - @Override - public void onCloseRequest() - { - try - { - if(isConnected()) - client.exit(); - - if(screenSaver != null) - { - screenSaver.stop(); + + public void onCloseRequest() { + try { + if (this.isConnected()) { + this.client.exit(); } - - if(screenMover != null) - { - screenMover.stop(); + if (this.screenSaver != null) { + this.screenSaver.stop(); } - - if(getConfig() != null) - { - if(!getClientInfo().isPhone() && !getConfig().getIsFullScreenMode()) - { - getConfig().setStartupWindowSize(getStageWidth(), getStageHeight()); - getConfig().save(); - } + if (this.screenMover != null) { + this.screenMover.stop(); + } + if (this.getConfig() != null && !this.getClientInfo().isPhone() && !this.getConfig().getIsFullScreenMode()) { + this.getConfig().setStartupWindowSize(this.getStageWidth(), this.getStageHeight()); + this.getConfig().save(); } } - catch (SevereException e) - { - handleSevereException(e); + catch (SevereException e) { + this.handleSevereException(e); } - finally - { - getLogger().info("Shut down"); - closeLogger(); + finally { + this.getLogger().info("Shut down"); + this.closeLogger(); Config.nullify(); } } - - @Override - public void exitApp() - { - getExecutor().shutdown(); - if (ClientInfo.getInstance().getPlatform() == com.stream_pi.util.platform.Platform.ANDROID) - { - Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown); + + public void exitApp() { + this.getExecutor().shutdown(); + if (ClientInfo.getInstance().getPlatform() == Platform.ANDROID) { + Services.get((Class)LifecycleService.class).ifPresent(LifecycleService::shutdown); } - else - { - Platform.exit(); + else { + javafx.application.Platform.exit(); } } - - @Override + public void loadSettings() { try { - getSettingsPane().getGeneralTab().loadData(); - } catch (SevereException e) { + this.getSettingsPane().getGeneralTab().loadData(); + } + catch (SevereException e) { e.printStackTrace(); - handleSevereException(e); + this.handleSevereException(e); } } - - @Override + public Client getClient() { - return client; + return this.client; } - - @Override + public void onDisconnect() { - Platform.runLater(()->getDashboardPane().getActionGridPane().toggleOffAllToggleActions()); + javafx.application.Platform.runLater(() -> this.getDashboardPane().getActionGridPane().toggleOffAllToggleActions()); } - - @Override - public boolean getToggleStatus(String profileID, String actionID) - { - return getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus(); + + public boolean getToggleStatus(final String profileID, final String actionID) { + return this.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus(); } - - - private Timeline openSettingsTimeLine; - private Timeline closeSettingsTimeLine; - - - private void setupSettingsWindowsAnimations() - { - Node settingsNode = getSettingsPane(); - Node dashboardNode = getDashboardPane(); - - openSettingsTimeLine = new Timeline(); - openSettingsTimeLine.setCycleCount(1); - - - openSettingsTimeLine.getKeyFrames().addAll( - new KeyFrame(Duration.millis(0.0D), - new KeyValue(settingsNode.opacityProperty(), - 0.0D, Interpolator.EASE_IN)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(settingsNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)), - - new KeyFrame(Duration.millis(0.0D), - new KeyValue(dashboardNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(dashboardNode.opacityProperty(), - 0.0D, Interpolator.LINEAR)) - ); - - openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront()); - - - closeSettingsTimeLine = new Timeline(); - closeSettingsTimeLine.setCycleCount(1); - - closeSettingsTimeLine.getKeyFrames().addAll( - new KeyFrame(Duration.millis(0.0D), - new KeyValue(settingsNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(settingsNode.opacityProperty(), - 0.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(0.0D), - new KeyValue(dashboardNode.opacityProperty(), - 0.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(dashboardNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)) - ); - - closeSettingsTimeLine.setOnFinished(event1 -> { + + private void setupSettingsWindowsAnimations() { + final Node settingsNode = (Node)this.getSettingsPane(); + final Node dashboardNode = (Node)this.getDashboardPane(); + (this.openSettingsTimeLine = new Timeline()).setCycleCount(1); + this.openSettingsTimeLine.getKeyFrames().addAll((Object[])new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)settingsNode.opacityProperty(), (Object)0.0, Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(90.0), new KeyValue[] { new KeyValue((WritableValue)settingsNode.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)dashboardNode.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(90.0), new KeyValue[] { new KeyValue((WritableValue)dashboardNode.opacityProperty(), (Object)0.0, Interpolator.LINEAR) }) }); + this.openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront()); + (this.closeSettingsTimeLine = new Timeline()).setCycleCount(1); + this.closeSettingsTimeLine.getKeyFrames().addAll((Object[])new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)settingsNode.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(90.0), new KeyValue[] { new KeyValue((WritableValue)settingsNode.opacityProperty(), (Object)0.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)dashboardNode.opacityProperty(), (Object)0.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(90.0), new KeyValue[] { new KeyValue((WritableValue)dashboardNode.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }) }); + this.closeSettingsTimeLine.setOnFinished(event1 -> { dashboardNode.toFront(); - Platform.runLater(()-> { + javafx.application.Platform.runLater(() -> { try { - getSettingsPane().getGeneralTab().loadData(); - } catch (SevereException e) { + this.getSettingsPane().getGeneralTab().loadData(); + } + catch (SevereException e) { e.printStackTrace(); - - handleSevereException(e); + this.handleSevereException(e); } }); }); } - - - @Override - public void handleMinorException(MinorException e) - { - handleMinorException(e.getMessage(), e); + + public void handleMinorException(final MinorException e) { + this.handleMinorException(e.getMessage(), e); } - - @Override - public void handleMinorException(String message, MinorException e) - { - getLogger().log(Level.SEVERE, message, e); + + public void handleMinorException(final String message, final MinorException e) { + this.getLogger().log(Level.SEVERE, message, (Throwable)e); e.printStackTrace(); - - Platform.runLater(()-> { - if(getScreenSaver() != null) - { - getScreenSaver().restart(); + javafx.application.Platform.runLater(() -> { + if (this.getScreenSaver() != null) { + this.getScreenSaver().restart(); } - - genNewAlert(e.getTitle(), message, StreamPiAlertType.WARNING).show(); + this.genNewAlert(e.getTitle(), message, StreamPiAlertType.WARNING).show(); }); } - - @Override - public void handleSevereException(SevereException e) - { - handleSevereException(e.getMessage(), e); + + public void handleSevereException(final SevereException e) { + this.handleSevereException(e.getMessage(), e); } - - @Override - public void handleSevereException(String message, SevereException e) - { - getLogger().log(Level.SEVERE, message, e); + + public void handleSevereException(final String message, final SevereException e) { + this.getLogger().log(Level.SEVERE, message, (Throwable)e); e.printStackTrace(); - - - Platform.runLater(()-> - { - if(getScreenSaver() != null) - { - getScreenSaver().restart(); + javafx.application.Platform.runLater(() -> { + if (this.getScreenSaver() != null) { + this.getScreenSaver().restart(); } - - StreamPiAlert alert = genNewAlert(e.getTitle(), message, StreamPiAlertType.ERROR); - - alert.setOnClicked(new StreamPiAlertListener() - { - @Override - public void onClick(String txt) - { - onCloseRequest(); - exitApp(); + final StreamPiAlert alert = this.genNewAlert(e.getTitle(), message, StreamPiAlertType.ERROR); + alert.setOnClicked((StreamPiAlertListener)new StreamPiAlertListener() { + public void onClick(final String txt) { + Controller.this.onCloseRequest(); + Controller.this.exitApp(); } }); alert.show(); }); } - - @Override - public void onAlert(String title, String body, StreamPiAlertType alertType) { - Platform.runLater(()-> genNewAlert(title, body, alertType).show()); + + public void onAlert(final String title, final String body, final StreamPiAlertType alertType) { + javafx.application.Platform.runLater(() -> this.genNewAlert(title, body, alertType).show()); } - - public StreamPiAlert genNewAlert(String title, String message, StreamPiAlertType alertType) - { + + public StreamPiAlert genNewAlert(final String title, final String message, final StreamPiAlertType alertType) { return new StreamPiAlert(title, message, alertType); } - - - private boolean isConnected = false; - - @Override - public void onActionFailed(String profileID, String actionID) { - Platform.runLater(()-> getDashboardPane().getActionGridPane().actionFailed(profileID, actionID)); + + public void onActionFailed(final String profileID, final String actionID) { + javafx.application.Platform.runLater(() -> this.getDashboardPane().getActionGridPane().actionFailed(profileID, actionID)); } - - @Override - public void onActionClicked(String profileID, String actionID, boolean toggleState) - { + + public void onActionClicked(final String profileID, final String actionID, final boolean toggleState) { try { - - vibratePhone(); - - client.onActionClicked(profileID, actionID, toggleState); - } catch (SevereException e) { + this.vibratePhone(); + this.client.onActionClicked(profileID, actionID, toggleState); + } + catch (SevereException e) { e.printStackTrace(); - handleSevereException(e); + this.handleSevereException(e); } } - - public void vibratePhone() - { - if(getConfig().isVibrateOnActionClicked()) - { + + public void vibratePhone() { + if (this.getConfig().isVibrateOnActionClicked()) { VibrationService.create().ifPresent(VibrationService::vibrate); } } - - @Override - public void setConnected(boolean isConnected) { + + public void setConnected(final boolean isConnected) { this.isConnected = isConnected; } - - @Override - public ActionBox getActionBox(int col, int row) - { - return getDashboardPane().getActionGridPane().getActionBox(col, row); + + public ActionBox getActionBox(final int col, final int row) { + return this.getDashboardPane().getActionGridPane().getActionBox(col, row); } - - @Override - public boolean isConnected() - { - return isConnected; + + public boolean isConnected() { + return this.isConnected; } - - @Override - public void renderProfile(ClientProfile clientProfile, boolean freshRender) - { - getDashboardPane().renderProfile(clientProfile, freshRender); + + public void renderProfile(final ClientProfile clientProfile, final boolean freshRender) { + this.getDashboardPane().renderProfile(clientProfile, freshRender); } - - @Override - public void clearActionBox(int col, int row) - { - Platform.runLater(()->getDashboardPane().getActionGridPane().clearActionBox(col, row)); + + public void clearActionBox(final int col, final int row) { + javafx.application.Platform.runLater(() -> this.getDashboardPane().getActionGridPane().clearActionBox(col, row)); } - - @Override - public void addBlankActionBox(int col, int row) - { - Platform.runLater(()->getDashboardPane().getActionGridPane().addBlankActionBox(col, row)); + + public void addBlankActionBox(final int col, final int row) { + javafx.application.Platform.runLater(() -> this.getDashboardPane().getActionGridPane().addBlankActionBox(col, row)); } - - @Override - public void renderAction(String currentProfileID, Action action) - { - Platform.runLater(()->{ + + public void renderAction(final String currentProfileID, final Action action) { + javafx.application.Platform.runLater(() -> { try { - if(getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) && - getCurrentProfile().getID().equals(currentProfileID)) - { - getDashboardPane().getActionGridPane().renderAction(action); + if (this.getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) && this.getCurrentProfile().getID().equals(currentProfileID)) { + this.getDashboardPane().getActionGridPane().renderAction(action); } - } - catch (Exception e) - { + catch (Exception e) { e.printStackTrace(); } }); } - - - - @Override - public void refreshGridIfCurrentProfile(String profileID) { - if(getCurrentProfile().getID().equals(profileID)) - { - Platform.runLater(()-> getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(profileID), true)); + + public void refreshGridIfCurrentProfile(final String profileID) { + if (this.getCurrentProfile().getID().equals(profileID)) { + javafx.application.Platform.runLater(() -> this.getDashboardPane().renderProfile(this.getClientProfiles().getProfileFromID(profileID), true)); } } - - @Override + public ClientProfile getCurrentProfile() { - return getDashboardPane().getActionGridPane().getClientProfile(); + return this.getDashboardPane().getActionGridPane().getClientProfile(); } - - @Override - public String getCurrentParent() - { - return getDashboardPane().getActionGridPane().getCurrentParent(); + + public String getCurrentParent() { + return this.getDashboardPane().getActionGridPane().getCurrentParent(); } - - - @Override - public ActionBox getActionBoxByProfileAndID(String profileID, String actionID) - { - Action action = getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - - if(!getCurrentProfile().getID().equals(profileID) && !getCurrentParent().equals(action.getParent())) + + public ActionBox getActionBoxByProfileAndID(final String profileID, final String actionID) { + final Action action = this.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + if (!this.getCurrentProfile().getID().equals(profileID) && !this.getCurrentParent().equals(action.getParent())) { return null; - - return getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation()); + } + return this.getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation()); } - - @Override - public void openURL(String url) - { - if(ClientInfo.getInstance().isPhone()) - { - BrowserService.create().ifPresentOrElse(s-> - { - try - { + + public void openURL(final String url) { + if (ClientInfo.getInstance().isPhone()) { + BrowserService.create().ifPresentOrElse(s -> { + try { s.launchExternalBrowser(url); } - catch (Exception e ) - { - handleMinorException( - new MinorException("Cant start browser! You can go to Server Settings > About > Contact " + - "and open the links from there.") - ); + catch (Exception e) { + this.handleMinorException(new MinorException("Cant start browser! You can go to Server Settings > About > Contact and open the links from there.")); } - },()-> handleMinorException( - new MinorException("Sorry!","No browser detected. You can go to Server Settings > About > Contact " + - "and open the links from there.") - )); + }, () -> this.handleMinorException(new MinorException("Sorry!", "No browser detected. You can go to Server Settings > About > Contact and open the links from there."))); } - else - { - if(getClientInfo().getPlatform() == com.stream_pi.util.platform.Platform.LINUX && - !StartupFlags.IS_X_MODE) - { - 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 " + - "and open the links from there.")); - } - else - { - getHostServices().showDocument(url); - } + else if (this.getClientInfo().getPlatform() == Platform.LINUX && !StartupFlags.IS_X_MODE) { + this.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 and open the links from there.")); + } + else { + this.getHostServices().showDocument(url); } } - - @Override - public void factoryReset() - { - getLogger().info("Reset to factory ..."); - - onCloseRequest(); - - try - { - IOHelper.deleteFile(getClientInfo().getPrePath()); - - setFirstRun(true); - init(); + + public void factoryReset() { + this.getLogger().info("Reset to factory ..."); + this.onCloseRequest(); + try { + IOHelper.deleteFile(this.getClientInfo().getPrePath()); + this.setFirstRun(true); + this.init(); } - catch (SevereException e) - { - handleSevereException("Unable to successfully factory reset. Delete directory \n'"+getClientInfo().getPrePath()+"/home/rnayabed/HDD_1/projects/stream-pi/server'\nMessage:\n"+e.getMessage(),e); + catch (SevereException e) { + this.handleSevereException("Unable to successfully factory reset. Delete directory \n'" + this.getClientInfo().getPrePath() + "/home/rnayabed/HDD_1/projects/stream-pi/server'\nMessage:\n" + e.getMessage(), e); } } - - @Override - public void setFirstRun(boolean firstRun) - { + + public void setFirstRun(final boolean firstRun) { this.firstRun = firstRun; } } diff --git a/src/main/java/com/stream_pi/client/controller/ScreenMover.java b/src/main/java/com/stream_pi/client/controller/ScreenMover.java index bdb799d0..a0fc60b5 100644 --- a/src/main/java/com/stream_pi/client/controller/ScreenMover.java +++ b/src/main/java/com/stream_pi/client/controller/ScreenMover.java @@ -1,33 +1,26 @@ +// +// Decompiled by Procyon v0.6-prerelease +// + package com.stream_pi.client.controller; -import com.stream_pi.client.window.Base; -import com.stream_pi.util.exception.SevereException; -import javafx.animation.*; +import java.util.TimerTask; import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.scene.Node; -import javafx.scene.Scene; -import javafx.scene.layout.StackPane; import javafx.stage.Stage; -import javafx.util.Duration; - import java.util.Timer; -import java.util.TimerTask; public class ScreenMover { private Timer timer; - private long interval; - private boolean isOldLocation; - private double originalX, originalY; - private double changeX, changeY; - + private double originalX; + private double originalY; + private double changeX; + private double changeY; private Stage stage; - - public ScreenMover(Stage stage, long interval, int changeX, int changeY) - { + + public ScreenMover(final Stage stage, final long interval, final int changeX, final int changeY) { this.stage = stage; this.changeX = changeX; this.changeY = changeY; @@ -35,69 +28,52 @@ public ScreenMover(Stage stage, long interval, int changeX, int changeY) this.originalY = stage.getY(); this.isOldLocation = true; this.interval = interval; - - startTimer(); + this.startTimer(); } - - - public void stop() - { - isOldLocation = true; - shiftScreen(); - - stopTimer(); + + public void stop() { + this.isOldLocation = true; + this.shiftScreen(); + this.stopTimer(); } - - public void restart() - { - stop(); - startTimer(); + + public void restart() { + this.stop(); + this.startTimer(); } - - private void shiftScreen() - { - Platform.runLater(()->{ - if(isOldLocation) - { - isOldLocation = false; - - stage.setX(originalX+changeX); - stage.setY(originalY+changeY); + + private void shiftScreen() { + Platform.runLater(() -> { + if (this.isOldLocation) { + this.isOldLocation = false; + this.stage.setX(this.originalX + this.changeX); + this.stage.setY(this.originalY + this.changeY); } - else - { - isOldLocation = true; - - stage.setX(originalX); - stage.setY(originalY); + else { + this.isOldLocation = true; + this.stage.setX(this.originalX); + this.stage.setY(this.originalY); } }); } - - public void setInterval(int seconds) - { + + public void setInterval(final int seconds) { this.interval = seconds; } - - private void stopTimer() - { - if(timer != null) - { - timer.cancel(); - timer.purge(); + + private void stopTimer() { + if (this.timer != null) { + this.timer.cancel(); + this.timer.purge(); } } - - private void startTimer() - { - timer = new Timer(); - timer.scheduleAtFixedRate(new TimerTask() - { + + private void startTimer() { + (this.timer = new Timer()).scheduleAtFixedRate(new TimerTask() { @Override - public void run() - { - shiftScreen(); + public void run() { + ScreenMover.this.shiftScreen(); } - },interval, interval); + }, this.interval, this.interval); } } diff --git a/src/main/java/com/stream_pi/client/controller/ScreenSaver.java b/src/main/java/com/stream_pi/client/controller/ScreenSaver.java index 28bac210..6576f34b 100644 --- a/src/main/java/com/stream_pi/client/controller/ScreenSaver.java +++ b/src/main/java/com/stream_pi/client/controller/ScreenSaver.java @@ -1,124 +1,92 @@ +// +// Decompiled by Procyon v0.6-prerelease +// + package com.stream_pi.client.controller; -import com.stream_pi.client.window.Base; -import com.stream_pi.util.exception.SevereException; -import javafx.animation.*; +import javafx.scene.input.MouseEvent; +import java.util.TimerTask; +import javafx.animation.Animation; import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.scene.Node; -import javafx.scene.layout.StackPane; +import javafx.beans.value.WritableValue; +import javafx.animation.Interpolator; +import javafx.animation.KeyValue; import javafx.util.Duration; - +import javafx.animation.KeyFrame; +import com.stream_pi.client.window.Base; +import javafx.animation.Timeline; import java.util.Timer; -import java.util.TimerTask; +import javafx.scene.layout.StackPane; public class ScreenSaver extends StackPane { private Timer timer; - private Timeline showScreenSaverTimeline; private long timeout; - - public ScreenSaver(Base base, int timeout) - { - this.timeout = timeout* 1000L; - - setOpacity(0); - getStyleClass().add("screensaver"); - - - showScreenSaverTimeline = new Timeline(); - showScreenSaverTimeline.setCycleCount(1); - - - showScreenSaverTimeline.getKeyFrames().addAll( - new KeyFrame(Duration.millis(0.0D), - new KeyValue(opacityProperty(), - 0.0D, Interpolator.EASE_IN)), - new KeyFrame(Duration.seconds(15D), - new KeyValue(opacityProperty(), - 1.0D, Interpolator.LINEAR)) - ); - - startTimer(); - - base.setOnMouseClicked(mouseEvent -> { - restart(); - }); - + + public ScreenSaver(final Base base, final int timeout) { + this.timeout = timeout * 1000L; + this.setOpacity(0.0); + this.getStyleClass().add((Object)"screensaver"); + (this.showScreenSaverTimeline = new Timeline()).setCycleCount(1); + this.showScreenSaverTimeline.getKeyFrames().addAll((Object[])new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.opacityProperty(), (Object)0.0, Interpolator.EASE_IN) }), new KeyFrame(Duration.seconds(15.0), new KeyValue[] { new KeyValue((WritableValue)this.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }) }); + this.startTimer(); + base.setOnMouseClicked(mouseEvent -> this.restart()); } - - public void restart() - { - close(); - restartTimer(); + + public void restart() { + this.close(); + this.restartTimer(); } - - - - public void stop() - { - stopTimer(); - setOpacity(0); - toBack(); + + public void stop() { + this.stopTimer(); + this.setOpacity(0.0); + this.toBack(); } - - - private void show() - { - Platform.runLater(()->{ - setOpacity(0); - toFront(); - showScreenSaverTimeline.play(); + + private void show() { + Platform.runLater(() -> { + this.setOpacity(0.0); + this.toFront(); + this.showScreenSaverTimeline.play(); }); } - - private void close() - { - Platform.runLater(()->{ - if(showScreenSaverTimeline.getStatus() == Animation.Status.RUNNING) - { - showScreenSaverTimeline.stop(); + + private void close() { + Platform.runLater(() -> { + if (this.showScreenSaverTimeline.getStatus() == Animation.Status.RUNNING) { + this.showScreenSaverTimeline.stop(); } - - - setOpacity(0.0); - toBack(); + this.setOpacity(0.0); + this.toBack(); + return; }); - - restartTimer(); + this.restartTimer(); } - - public void setTimeout(int seconds) - { - this.timeout = seconds* 1000L; + + public void setTimeout(final int seconds) { + this.timeout = seconds * 1000L; } - - public void restartTimer() - { - stopTimer(); - startTimer(); + + public void restartTimer() { + this.stopTimer(); + this.startTimer(); } - - private void stopTimer() - { - if(timer != null) - { - timer.cancel(); - timer.purge(); + + private void stopTimer() { + if (this.timer != null) { + this.timer.cancel(); + this.timer.purge(); } } - - private void startTimer() - { - timer = new Timer(); - timer.schedule(new TimerTask() - { + + private void startTimer() { + (this.timer = new Timer()).schedule(new TimerTask() { @Override - public void run() - { - show(); + public void run() { + ScreenSaver.this.show(); } - },timeout); + }, this.timeout); } } diff --git a/src/main/java/com/stream_pi/client/info/ClientInfo.java b/src/main/java/com/stream_pi/client/info/ClientInfo.java index 19b7d8e0..199ace07 100644 --- a/src/main/java/com/stream_pi/client/info/ClientInfo.java +++ b/src/main/java/com/stream_pi/client/info/ClientInfo.java @@ -1,121 +1,92 @@ -/* -ServerInfo.java - -Stores basic information about the server - name, platform type - -Contributors: Debayan Sutradhar (@dubbadhar) - */ +// +// Decompiled by Procyon v0.6-prerelease +// package com.stream_pi.client.info; +import java.io.File; import com.gluonhq.attach.storage.StorageService; -import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.platform.Platform; import com.stream_pi.util.platform.ReleaseStatus; import com.stream_pi.util.version.Version; -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Optional; -import java.util.function.Function; - -public class ClientInfo { +public class ClientInfo +{ private Version version; private final ReleaseStatus releaseStatus; private Platform platform; - private String prePath; - private Version minThemeSupportVersion; private Version minPluginSupportVersion; private Version commStandardVersion; - - private static ClientInfo instance = null; - - private ClientInfo() - { - version = new Version(1,0,0); - minThemeSupportVersion = new Version(1,0,0); - minPluginSupportVersion = new Version(1,0,0); - commStandardVersion = new Version(1,0,0); - - releaseStatus = ReleaseStatus.EA; - - String osName = System.getProperty("os.name").toLowerCase(); - - prePath = System.getProperty("user.home")+"/Stream-Pi/Client/"; - - if(osName.contains("windows")) - { - platform = Platform.WINDOWS; + private static ClientInfo instance; + + private ClientInfo() { + this.version = new Version(1, 0, 0); + this.minThemeSupportVersion = new Version(1, 0, 0); + this.minPluginSupportVersion = new Version(1, 0, 0); + this.commStandardVersion = new Version(1, 0, 0); + this.releaseStatus = ReleaseStatus.EA; + final String osName = System.getProperty("os.name").toLowerCase(); + this.prePath = System.getProperty("user.home") + "/Stream-Pi/Client/"; + if (osName.contains("windows")) { + this.platform = Platform.WINDOWS; } - else if (osName.contains("linux")) - { - platform = Platform.LINUX; + else if (osName.contains("linux")) { + this.platform = Platform.LINUX; } - else if(osName.contains("android") || osName.contains("ios")) - { - StorageService.create().ifPresent(s-> s.getPrivateStorage().ifPresentOrElse(sp-> prePath = sp.getAbsolutePath()+"/Stream-Pi/Client/", - ()-> prePath = null)); - - platform = Platform.valueOf(osName.toUpperCase()); + else if (osName.contains("android") || osName.contains("ios")) { + StorageService.create().ifPresent(s -> s.getPrivateStorage().ifPresentOrElse(sp -> this.prePath = sp.getAbsolutePath() + "/Stream-Pi/Client/", () -> this.prePath = null)); + this.platform = Platform.valueOf(osName.toUpperCase()); } - else if (osName.contains("mac")) - { - platform = Platform.MAC; + else if (osName.contains("mac")) { + this.platform = Platform.MAC; } - else - { - platform = Platform.UNKNOWN; + else { + this.platform = Platform.UNKNOWN; } } - - public static synchronized ClientInfo getInstance(){ - if(instance == null) - { - instance = new ClientInfo(); + + public static synchronized ClientInfo getInstance() { + if (ClientInfo.instance == null) { + ClientInfo.instance = new ClientInfo(); } - - return instance; + return ClientInfo.instance; } - - public String getPrePath() - { - return prePath; + + public String getPrePath() { + return this.prePath; } - - public Platform getPlatform() - { - return platform; + + public Platform getPlatform() { + return this.platform; } - + public Version getVersion() { - return version; + return this.version; } - - public ReleaseStatus getReleaseStatus() - { - return releaseStatus; + + public ReleaseStatus getReleaseStatus() { + return this.releaseStatus; } - - public Version getMinThemeSupportVersion() - { - return minThemeSupportVersion; + + public Version getMinThemeSupportVersion() { + return this.minThemeSupportVersion; } - - public Version getMinPluginSupportVersion() - { - return minPluginSupportVersion; + + public Version getMinPluginSupportVersion() { + return this.minPluginSupportVersion; } - - public Version getCommStandardVersion() - { - return commStandardVersion; + + public Version getCommStandardVersion() { + return this.commStandardVersion; } - - - public boolean isPhone() - { - return getPlatform() == Platform.ANDROID || getPlatform() == Platform.IOS; + + public boolean isPhone() { + return this.getPlatform() == Platform.ANDROID || this.getPlatform() == Platform.IOS; + } + + static { + ClientInfo.instance = null; } } diff --git a/src/main/java/com/stream_pi/client/info/License.java b/src/main/java/com/stream_pi/client/info/License.java index 71a8d9de..ac83197c 100644 --- a/src/main/java/com/stream_pi/client/info/License.java +++ b/src/main/java/com/stream_pi/client/info/License.java @@ -1,43 +1,12 @@ -/* -Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macropad -Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones) - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -Written by : Debayan Sutradhar (rnayabed) -*/ +// +// Decompiled by Procyon v0.6-prerelease +// package com.stream_pi.client.info; -public class License { - public static String getLicense() - { - return "Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad\n" + - "Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)\n" + - "\n" + - "This program is free software: you can redistribute it and/or modify\n" + - "it under the terms of the GNU General Public License as published by\n" + - "the Free Software Foundation, either version 3 of the License, or\n" + - "(at your option) any later version.\n" + - "\n" + - "This program is distributed in the hope that it will be useful,\n" + - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + - "GNU General Public License for more details.\n" + - "\n\n"+ - "Opensource Libraries/Tech used :\n"+ - "1. JavaFX - GNU General Public License with Classpath Exception\nhttp://openjdk.java.net/legal/gplv2+ce.html\n\n"+ - "2. Gluon Attach - GPL License\nhttps://github.com/gluonhq/attach/blob/master/LICENSE\n\n"+ - "3. Gluon Client Maven Plugin - BSD-3 License\nhttps://github.com/gluonhq/client-maven-plugin/blob/master/LICENSE\n\n" + - "4. Ikonli - Apache License\nhttps://github.com/kordamp/ikonli/blob/master/LICENSE\n\n"+ - "5. Roboto Font - Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0\n\n"+ - "6. ControlsFX - BSD 3-Clause License\nhttps://github.com/controlsfx/controlsfx/blob/jfx-13/license.txt\n\n"; +public class License +{ + public static String getLicense() { + return "Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad\nCopyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Qui\u00f1ones (SamuelQuinones)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\n\nOpensource Libraries/Tech used :\n1. JavaFX - GNU General Public License with Classpath Exception\nhttp://openjdk.java.net/legal/gplv2+ce.html\n\n2. Gluon Attach - GPL License\nhttps://github.com/gluonhq/attach/blob/master/LICENSE\n\n3. Gluon Client Maven Plugin - BSD-3 License\nhttps://github.com/gluonhq/client-maven-plugin/blob/master/LICENSE\n\n4. Ikonli - Apache License\nhttps://github.com/kordamp/ikonli/blob/master/LICENSE\n\n5. Roboto Font - Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0\n\n6. ControlsFX - BSD 3-Clause License\nhttps://github.com/controlsfx/controlsfx/blob/jfx-13/license.txt\n\n"; } } diff --git a/src/main/java/com/stream_pi/client/info/StartupFlags.java b/src/main/java/com/stream_pi/client/info/StartupFlags.java index ff515f13..f585a1aa 100644 --- a/src/main/java/com/stream_pi/client/info/StartupFlags.java +++ b/src/main/java/com/stream_pi/client/info/StartupFlags.java @@ -1,12 +1,26 @@ +// +// Decompiled by Procyon v0.6-prerelease +// + package com.stream_pi.client.info; public class StartupFlags { - public static String RUNNER_FILE_NAME = null; - public static boolean IS_SHOW_SHUT_DOWN_BUTTON = false; - public static boolean IS_X_MODE = true; - public static boolean SCREEN_SAVER_FEATURE= false; - public static boolean DEFAULT_FULLSCREEN_MODE=false; - public static boolean SHOW_FULLSCREEN_TOGGLE_BUTTON=true; - public static boolean APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = false; + public static String RUNNER_FILE_NAME; + public static boolean IS_SHOW_SHUT_DOWN_BUTTON; + public static boolean IS_X_MODE; + public static boolean SCREEN_SAVER_FEATURE; + public static boolean DEFAULT_FULLSCREEN_MODE; + public static boolean SHOW_FULLSCREEN_TOGGLE_BUTTON; + public static boolean APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION; + + static { + StartupFlags.RUNNER_FILE_NAME = null; + StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = false; + StartupFlags.IS_X_MODE = true; + StartupFlags.SCREEN_SAVER_FEATURE = false; + StartupFlags.DEFAULT_FULLSCREEN_MODE = false; + StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = true; + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = false; + } } diff --git a/src/main/java/com/stream_pi/client/io/Config.java b/src/main/java/com/stream_pi/client/io/Config.java index d4fe1e42..f5da207e 100644 --- a/src/main/java/com/stream_pi/client/io/Config.java +++ b/src/main/java/com/stream_pi/client/io/Config.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.io; @@ -34,14 +34,14 @@ public class Config private Config() throws SevereException { try { - this.configFile = new File(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath())); + this.configFile = new File(ClientInfo.getInstance().getPrePath() + "config.xml"); final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); this.document = docBuilder.parse(this.configFile); } catch (Exception e) { e.printStackTrace(); - throw new SevereException("Config", invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, e.getMessage())); + throw new SevereException("Config", "unable to read config.xml\n" + e.getMessage()); } } @@ -58,9 +58,9 @@ public static void nullify() { public static void unzipToDefaultPrePath() throws Exception { IOHelper.unzip((InputStream)Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath()); - getInstance().setThemesPath(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath())); - getInstance().setIconsPath(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath())); - getInstance().setProfilesPath(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath())); + getInstance().setThemesPath(ClientInfo.getInstance().getPrePath() + "Themes/"); + getInstance().setIconsPath(ClientInfo.getInstance().getPrePath() + "Icons/"); + getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath() + "Profiles/"); getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE); getInstance().save(); } @@ -94,15 +94,15 @@ public String getDefaultCurrentAnimationName() { } public String getDefaultThemesPath() { - return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + return ClientInfo.getInstance().getPrePath() + "Themes/"; } public String getDefaultProfilesPath() { - return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + return ClientInfo.getInstance().getPrePath() + "Profiles/"; } public String getDefaultIconsPath() { - return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + return ClientInfo.getInstance().getPrePath() + "Icons/"; } public String getClientNickName() { @@ -124,7 +124,7 @@ public String getCurrentAnimationName() { public String getThemesPath() { final Platform platform = ClientInfo.getInstance().getPlatform(); if (platform != Platform.ANDROID && platform != Platform.IOS) { - return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + return ClientInfo.getInstance().getPrePath() + "Themes/"; } return XMLConfigHelper.getStringProperty((Node)this.document, "themes-path", this.getDefaultThemesPath(), false, true, this.document, this.configFile); } @@ -132,7 +132,7 @@ public String getThemesPath() { public String getProfilesPath() { final Platform platform = ClientInfo.getInstance().getPlatform(); if (platform != Platform.ANDROID && platform != Platform.IOS) { - return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + return ClientInfo.getInstance().getPrePath() + "Profiles/"; } return XMLConfigHelper.getStringProperty((Node)this.document, "profiles-path", this.getDefaultProfilesPath(), false, true, this.document, this.configFile); } @@ -140,7 +140,7 @@ public String getProfilesPath() { public String getIconsPath() { final Platform platform = ClientInfo.getInstance().getPlatform(); if (platform != Platform.ANDROID && platform != Platform.IOS) { - return invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + return ClientInfo.getInstance().getPrePath() + "Icons/"; } return XMLConfigHelper.getStringProperty((Node)this.document, "icons-path", this.getDefaultIconsPath(), false, true, this.document, this.configFile); } @@ -198,7 +198,7 @@ public void setServerHostNameOrIP(final String hostNameOrIP) { } public void setServerPort(final int port) { - this.getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(I)Ljava/lang/String;, port)); + this.getCommsServerElement().getElementsByTagName("port").item(0).setTextContent("" + port); } public Element getScreenMoverElement() { @@ -246,31 +246,31 @@ public boolean getIsFullScreenMode() { } public void setStartOnBoot(final boolean value) { - this.getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent("" + value); } public void setShowCursor(final boolean value) { - this.getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent("" + value); } public void setFullscreen(final boolean value) { - this.getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent("" + value); } public void setFirstTimeUse(final boolean value) { - this.getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent("" + value); } public void setVibrateOnActionClicked(final boolean value) { - this.getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent("" + value); } public void setConnectOnStartup(final boolean value) { - this.getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent("" + value); } public void setIsFullScreenMode(final boolean value) { - this.getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent("" + value); } private Element getStartupWindowSizeElement() { @@ -299,15 +299,15 @@ public void setStartupWindowSize(final double width, final double height) { } public void setStartupWindowWidth(final double width) { - this.getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(D)Ljava/lang/String;, width)); + this.getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent("" + width); } public void setStartupWindowHeight(final double height) { - this.getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(D)Ljava/lang/String;, height)); + this.getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent("" + height); } public void setStartupIsXMode(final boolean value) { - this.getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent("" + value); } public boolean getDefaultIsStartupXMode() { @@ -327,7 +327,7 @@ public boolean isTryConnectingWhenActionClicked() { } public void setTryConnectingWhenActionClicked(final boolean value) { - this.getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent("" + value); } public boolean getDefaultScreenSaverEnabled() { @@ -339,7 +339,7 @@ public boolean isScreenSaverEnabled() { } public void setScreenSaverEnabled(final boolean value) { - this.getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent("" + value); } public int getDefaultScreenSaverTimeout() { @@ -399,7 +399,7 @@ public boolean isScreenMoverEnabled() { } public void setScreenMoverEnabled(final boolean value) { - this.getScreenMoverElement().getElementsByTagName("status").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getScreenMoverElement().getElementsByTagName("status").item(0).setTextContent("" + value); } public boolean getDefaultInvertRowsColsOnDeviceRotate() { @@ -411,7 +411,7 @@ public boolean isInvertRowsColsOnDeviceRotate() { } public void setInvertRowsColsOnDeviceRotate(final boolean value) { - this.getOthersElement().getElementsByTagName("invert-rows-cols-on-device-rotate").item(0).setTextContent(invokedynamic(makeConcatWithConstants:(Z)Ljava/lang/String;, value)); + this.getOthersElement().getElementsByTagName("invert-rows-cols-on-device-rotate").item(0).setTextContent("" + value); } static { diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfile.java b/src/main/java/com/stream_pi/client/profile/ClientProfile.java index 5764146b..6a93c815 100644 --- a/src/main/java/com/stream_pi/client/profile/ClientProfile.java +++ b/src/main/java/com/stream_pi/client/profile/ClientProfile.java @@ -1,758 +1,507 @@ +// +// Decompiled by Procyon v0.6-prerelease +// + package com.stream_pi.client.profile; -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; import java.util.ArrayList; -import java.util.HashMap; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.*; -import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.TransformerException; +import java.io.OutputStream; +import java.io.FileOutputStream; +import java.util.Iterator; +import javax.xml.transform.Transformer; +import javax.xml.transform.Result; +import javax.xml.transform.Source; import javax.xml.transform.stream.StreamResult; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.TransformerFactory; +import org.w3c.dom.NodeList; import com.stream_pi.action_api.action.DisplayTextAlignment; +import java.nio.file.Files; import com.stream_pi.action_api.action.Location; -import com.stream_pi.action_api.actionproperty.ClientProperties; import com.stream_pi.action_api.actionproperty.property.Property; import com.stream_pi.action_api.actionproperty.property.Type; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.version.Version; +import com.stream_pi.action_api.actionproperty.ClientProperties; +import com.stream_pi.action_api.action.ActionType; +import org.w3c.dom.Node; import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; - -import org.w3c.dom.Document; import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class ClientProfile implements Cloneable{ - private String name, ID; - - private int rows, cols, actionSize, actionGap; +import javax.xml.parsers.DocumentBuilder; +import com.stream_pi.util.exception.MinorException; +import javax.xml.parsers.DocumentBuilderFactory; +import org.w3c.dom.Document; +import java.util.logging.Logger; +import java.io.File; +import com.stream_pi.action_api.action.Action; +import java.util.HashMap; - +public class ClientProfile implements Cloneable +{ + private String name; + private String ID; + private int rows; + private int cols; + private int actionSize; + private int actionGap; private HashMap actions; private String iconsPath; - private File file; - private Logger logger; private Document document; - - public ClientProfile(File file, String iconsPath) throws MinorException - { + + public ClientProfile(final File file, final String iconsPath) throws MinorException { this.file = file; this.iconsPath = iconsPath; - - actions = new HashMap<>(); - - logger = Logger.getLogger(ClientProfile.class.getName()); - - if(!file.exists() && !file.isFile()) - createConfigFile(file); - - try - { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - document = docBuilder.parse(file); + this.actions = new HashMap(); + this.logger = Logger.getLogger(ClientProfile.class.getName()); + if (!file.exists() && !file.isFile()) { + this.createConfigFile(file); } - catch (Exception e) - { + try { + final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + this.document = docBuilder.parse(file); + } + catch (Exception e) { e.printStackTrace(); throw new MinorException("profile", "Unable to read profile config file."); } - - - setID(file.getName().replace(".xml", "")); - load(); + this.setID(file.getName().replace(".xml", "")); + this.load(); } - - - private Element getProfileElement() - { - return (Element) document.getElementsByTagName("profile").item(0); - } - - private Element getActionsElement() - { - return (Element) document.getElementsByTagName("actions").item(0); - } - - public void load() throws MinorException - { - try - { - actions.clear(); - - logger.info("Loading profile "+getID()+" ..."); - - String name = XMLConfigHelper.getStringProperty(getProfileElement(), "name"); - int rows = XMLConfigHelper.getIntProperty(getProfileElement(), "rows"); - int cols = XMLConfigHelper.getIntProperty(getProfileElement(), "cols"); - int actionSize = XMLConfigHelper.getIntProperty(getProfileElement(), "action-size"); - int actionGap = XMLConfigHelper.getIntProperty(getProfileElement(), "action-gap"); - - setName(name); - setRows(rows); - setCols(cols); - setActionSize(actionSize); - setActionGap(actionGap); - - - //Load Actions - - NodeList actionsNodesList = getActionsElement().getChildNodes(); - - int actionsSize = actionsNodesList.getLength(); - - logger.info("Actions Size : "+actionsSize); - - for(int item = 0; item-1) - { - - Element actionElement = (Element) getActionsElement().getElementsByTagName("action").item(index); - - Element displayElement = (Element) actionElement.getElementsByTagName("display").item(0); - Element backgroundElement = (Element) displayElement.getElementsByTagName("background").item(0); - Element iconElement = (Element) backgroundElement.getElementsByTagName("icon").item(0); - - Element statesElements = (Element) iconElement.getElementsByTagName("states").item(0); - - NodeList statesNodeList = statesElements.getChildNodes(); - - for (int i = 0;i -1) { + final Element actionElement = (Element)this.getActionsElement().getElementsByTagName("action").item(index); + final Element displayElement = (Element)actionElement.getElementsByTagName("display").item(0); + final Element backgroundElement = (Element)displayElement.getElementsByTagName("background").item(0); + final Element iconElement = (Element)backgroundElement.getElementsByTagName("icon").item(0); + final Element statesElements = (Element)iconElement.getElementsByTagName("states").item(0); + final NodeList statesNodeList = statesElements.getChildNodes(); + for (int i = 0; i < statesNodeList.getLength(); ++i) { + final Node eachStateNode = statesNodeList.item(i); + if (eachStateNode.getNodeType() == 1) { + final Element eachIconStateElement = (Element)eachStateNode; + if (eachIconStateElement.getNodeName().equals("state")) { + final String state = eachIconStateElement.getTextContent(); + new File(this.iconsPath + "/" + ID + "___" + state).delete(); + } + } } - - - - actions.remove(ID); + this.actions.remove(ID); } - } - - public ArrayList getActions() - { - ArrayList p = new ArrayList<>(); - for(String profile : actions.keySet()) - p.add(actions.get(profile)); + + public ArrayList getActions() { + final ArrayList p = new ArrayList(); + for (final String profile : this.actions.keySet()) { + p.add(this.actions.get(profile)); + } return p; } - - public String getID() - { - return ID; + + public String getID() { + return this.ID; } - - public String getName() - { - return name; + + public String getName() { + return this.name; } - - public int getRows() - { - return rows; + + public int getRows() { + return this.rows; } - - public int getCols() - { - return cols; + + public int getCols() { + return this.cols; } - - public int getActionSize() - { - return actionSize; + + public int getActionSize() { + return this.actionSize; } - - public Action getActionFromID(String ID) - { - return actions.getOrDefault(ID, null); + + public Action getActionFromID(final String ID) { + return this.actions.getOrDefault(ID, null); } - - public int getActionGap() - { - return actionGap; + + public int getActionGap() { + return this.actionGap; } - - public void setRows(int rows) - { + + public void setRows(final int rows) { this.rows = rows; } - - public void setCols(int cols) - { + + public void setCols(final int cols) { this.cols = cols; } - - public void setID(String ID) - { + + public void setID(final String ID) { this.ID = ID; } - - public void setActionSize(int actionSize) - { + + public void setActionSize(final int actionSize) { this.actionSize = actionSize; } - - public void setActionGap(int actionGap) - { + + public void setActionGap(final int actionGap) { this.actionGap = actionGap; } - - public void setName(String name) - { + + public void setName(final String name) { this.name = name; } - - public Object clone() throws CloneNotSupportedException - { + public Object clone() throws CloneNotSupportedException { return super.clone(); } } diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfiles.java b/src/main/java/com/stream_pi/client/profile/ClientProfiles.java index 8e4572b8..28229c08 100644 --- a/src/main/java/com/stream_pi/client/profile/ClientProfiles.java +++ b/src/main/java/com/stream_pi/client/profile/ClientProfiles.java @@ -1,119 +1,93 @@ +// +// Decompiled by Procyon v0.6-prerelease +// + package com.stream_pi.client.profile; +import java.util.Iterator; import com.stream_pi.client.io.Config; -import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.exception.SevereException; - -import java.io.File; -import java.util.ArrayList; import java.util.HashMap; +import com.stream_pi.util.exception.MinorException; +import java.util.ArrayList; import java.util.logging.Logger; +import java.io.File; -public class ClientProfiles { - - +public class ClientProfiles +{ private File profilesFolder; private String defaultProfileID; - private Logger logger; - - public ClientProfiles(File profilesFolder, String defaultProfileID) throws SevereException - { - logger = Logger.getLogger(ClientProfiles.class.getName()); - + private ArrayList loadingErrors; + private HashMap clientProfiles; + + public ClientProfiles(final File profilesFolder, final String defaultProfileID) throws SevereException { + this.logger = Logger.getLogger(ClientProfiles.class.getName()); this.defaultProfileID = defaultProfileID; this.profilesFolder = profilesFolder; - clientProfiles = new HashMap<>(); - loadingErrors = new ArrayList<>(); - - loadProfiles(); + this.clientProfiles = new HashMap(); + this.loadingErrors = new ArrayList(); + this.loadProfiles(); } - - public void addProfile(ClientProfile clientProfile) throws CloneNotSupportedException { - clientProfiles.put(clientProfile.getID(), (ClientProfile) clientProfile.clone()); + + public void addProfile(final ClientProfile clientProfile) throws CloneNotSupportedException { + this.clientProfiles.put(clientProfile.getID(), (ClientProfile)clientProfile.clone()); } - - public void deleteProfile(ClientProfile clientProfile) - { - clientProfiles.remove(clientProfile.getID()); - + + public void deleteProfile(final ClientProfile clientProfile) { + this.clientProfiles.remove(clientProfile.getID()); clientProfile.deleteProfile(); } - - private ArrayList loadingErrors; - private HashMap clientProfiles; - - public void loadProfiles() throws SevereException - { - logger.info("Loading profiles ..."); - - - String iconsPath = Config.getInstance().getIconsPath(); - - clientProfiles.clear(); - loadingErrors.clear(); - - if(!profilesFolder.isDirectory()) - { - throw new SevereException("Profiles","Profile folder doesn't exist! Cant continue."); + + public void loadProfiles() throws SevereException { + this.logger.info("Loading profiles ..."); + final String iconsPath = Config.getInstance().getIconsPath(); + this.clientProfiles.clear(); + this.loadingErrors.clear(); + if (!this.profilesFolder.isDirectory()) { + throw new SevereException("Profiles", "Profile folder doesn't exist! Cant continue."); } - - - File[] profilesFiles = profilesFolder.listFiles(); - if(profilesFiles == null) - { - throw new SevereException("Profiles","profilesFiles returned null. Cant continue!"); + final File[] profilesFiles = this.profilesFolder.listFiles(); + if (profilesFiles == null) { + throw new SevereException("Profiles", "profilesFiles returned null. Cant continue!"); } - - for(File eachProfileFile : profilesFiles) - { - try - { - ClientProfile profile = new ClientProfile(eachProfileFile, iconsPath); - try - { - addProfile(profile); + final File[] array = profilesFiles; + for (int length = array.length, i = 0; i < length; ++i) { + final File eachProfileFile = array[i]; + try { + final ClientProfile profile = new ClientProfile(eachProfileFile, iconsPath); + try { + this.addProfile(profile); } - catch (CloneNotSupportedException e) - { + catch (CloneNotSupportedException e) { e.printStackTrace(); throw new SevereException(e.getMessage()); } } - catch (MinorException e) - { - if(eachProfileFile.getName().replace(".xml","").equals(defaultProfileID)) - { + catch (MinorException e2) { + if (eachProfileFile.getName().replace(".xml", "").equals(this.defaultProfileID)) { throw new SevereException("Profiles", "Default profile bad. Can't continue"); } - - loadingErrors.add(new MinorException(e.getMessage()+" ("+eachProfileFile.getName().replace(".xml", ""))); - - e.printStackTrace(); + this.loadingErrors.add(new MinorException(e2.getMessage() + " (" + eachProfileFile.getName().replace(".xml", ""))); + e2.printStackTrace(); } } - - logger.info("Loaded all profiles!"); + this.logger.info("Loaded all profiles!"); } - - public ArrayList getLoadingErrors() - { - return loadingErrors; + + public ArrayList getLoadingErrors() { + return this.loadingErrors; } - - public ArrayList getClientProfiles() - { - ArrayList p = new ArrayList<>(); - for(String profile : clientProfiles.keySet()) - p.add(clientProfiles.get(profile)); + + public ArrayList getClientProfiles() { + final ArrayList p = new ArrayList(); + for (final String profile : this.clientProfiles.keySet()) { + p.add(this.clientProfiles.get(profile)); + } return p; } - public ClientProfile getProfileFromID(String profileID) - { - return clientProfiles.getOrDefault(profileID, null); + public ClientProfile getProfileFromID(final String profileID) { + return this.clientProfiles.getOrDefault(profileID, null); } - - - } diff --git a/src/main/java/com/stream_pi/client/window/Base.java b/src/main/java/com/stream_pi/client/window/Base.java index fb34a432..9961e4ad 100644 --- a/src/main/java/com/stream_pi/client/window/Base.java +++ b/src/main/java/com/stream_pi/client/window/Base.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window; @@ -92,9 +92,9 @@ public void initLogger() { this.closeLogger(); this.logger = Logger.getLogger("com.stream_pi"); if (new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite()) { - String path = invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + String path = ClientInfo.getInstance().getPrePath() + "../stream-pi-client.log"; if (this.getClientInfo().isPhone()) { - path = invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ClientInfo.getInstance().getPrePath()); + path = ClientInfo.getInstance().getPrePath() + "stream-pi-client.log"; } this.logFileHandler = new StreamPiLogFileHandler(path); this.logger.addHandler((Handler)this.logFileHandler); @@ -310,7 +310,7 @@ public Theme getCurrentTheme() { } public void applyTheme(final Theme t) { - this.logger.info(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, t.getFullName())); + this.logger.info("Applying theme '" + t.getFullName() + "' ..."); if (t.getFonts() != null) { for (final String fontFile : t.getFonts()) { Font.loadFont(fontFile.replace("%20", ""), 13.0); @@ -322,7 +322,7 @@ public void applyTheme(final Theme t) { } public void applyGlobalDefaultStylesheet() { - final File globalCSSFile = new File(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, this.getConfig().getDefaultThemesPath())); + final File globalCSSFile = new File(this.getConfig().getDefaultThemesPath() + "/global.css"); if (globalCSSFile.exists()) { this.getLogger().info("Found global default style sheet. Adding ..."); this.getStylesheets().add((Object)globalCSSFile.toURI().toString()); @@ -339,7 +339,7 @@ public void registerThemes() throws SevereException { } if (this.themes.getIsBadThemeTheCurrentOne()) { if (this.getConfig().getCurrentThemeFullName().equals(this.getConfig().getDefaultCurrentThemeFullName())) { - throw new SevereException(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, this.getConfig().getDefaultCurrentThemeFullName())); + throw new SevereException("Unable to get default theme (" + this.getConfig().getDefaultCurrentThemeFullName() + ")\nPlease restore the theme or reinstall."); } themeErrors.append("\n\nReverted to default theme! (").append(this.getConfig().getDefaultCurrentThemeFullName()).append(")"); this.getConfig().setCurrentThemeFullName(this.getConfig().getDefaultCurrentThemeFullName()); diff --git a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java index e7f74a2a..603d58c2 100644 --- a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java +++ b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window; diff --git a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java index ff9556bd..5a15a47a 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.dashboard; diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java index 89ecec77..d63084ef 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.dashboard.actiongridpane; @@ -100,7 +100,7 @@ public void baseInit() { this.setMaxSize((double)this.size, (double)this.size); this.getStyleClass().clear(); this.getStyleClass().add((Object)"action_box"); - this.getStyleClass().add(invokedynamic(makeConcatWithConstants:(II)Ljava/lang/String;, this.row, this.col)); + this.getStyleClass().add("action_box_" + this.row + "_" + this.col); this.setIcon(null); this.setOnMouseClicked(touchEvent -> this.actionClicked()); this.setOnMousePressed(TouchEvent -> { @@ -349,10 +349,10 @@ else if (displayTextAlignment == DisplayTextAlignment.TOP) { public void setDisplayTextFontColourAndSize(final String colour) { String totalStyle = ""; if (!colour.isEmpty()) { - totalStyle = invokedynamic(makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;, totalStyle, colour); + totalStyle = totalStyle + "-fx-text-fill : " + colour; } if (this.getAction().getNameFontSize() > -1.0) { - totalStyle = invokedynamic(makeConcatWithConstants:(Ljava/lang/String;D)Ljava/lang/String;, totalStyle, this.getAction().getNameFontSize()); + totalStyle = totalStyle + "-fx-font-size: " + this.getAction().getNameFontSize(); } if (!totalStyle.isBlank()) { this.displayTextLabel.setStyle(totalStyle); @@ -415,7 +415,7 @@ public void playActionAnimation() throws SevereException { public void setBackgroundColour(final String colour) { if (!colour.isEmpty()) { - this.setStyle(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, colour)); + this.setStyle("-fx-background-color : " + colour); } } } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java index ebecfb33..5980b77d 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.dashboard.actiongridpane; @@ -162,8 +162,8 @@ public void setFreshRender(final boolean isFreshRender) { public void renderActions() { final StringBuilder errors = new StringBuilder(); - for (final Action eachAction : this.getClientProfile().getActions()) { - this.logger.info(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;Z)Ljava/lang/String;, eachAction.getID(), eachAction.isInvalid())); + for (Action eachAction : this.getClientProfile().getActions()) { + this.logger.info("Action ID : " + eachAction.getID() + "\nInvalid : " + eachAction.isInvalid()); try { this.renderAction(eachAction); } @@ -227,7 +227,7 @@ public void toggleOffAllToggleActions() { public void renderAction(final Action action) throws SevereException, MinorException { if (!action.getParent().equals(this.currentParent)) { - this.logger.info(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, action.getID())); + this.logger.info("Skipping action " + action.getID() + ", not current parent!"); return; } if (action.getLocation().getRow() == -1) { @@ -235,7 +235,7 @@ public void renderAction(final Action action) throws SevereException, MinorExcep return; } if (action.getLocation().getRow() >= this.rows || action.getLocation().getCol() >= this.cols) { - throw new MinorException(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;, action.getDisplayText(), action.getID())); + throw new MinorException("Action " + action.getDisplayText() + " (" + action.getID() + ") falls outside bounds.\n Consider increasing rows/cols from client settings and relocating/deleting it."); } final Location location = action.getLocation(); if (this.getClientProfile().getCols() < location.getCol() || this.getClientProfile().getRows() < location.getRow()) { @@ -307,7 +307,7 @@ public boolean isConnected() { public void returnToPreviousParent() { this.setCurrentParent(this.getPreviousParent()); if (!this.getPreviousParent().equals("root")) { - System.out.println(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, this.getPreviousParent())); + System.out.println("parent : " + this.getPreviousParent()); this.setPreviousParent(this.getClientProfile().getActionFromID(this.getPreviousParent()).getParent()); } this.renderGrid(); diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java index b845657b..dfdf87f1 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.dashboard.actiongridpane; diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java index 30c1fdd3..3b1eabed 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.firsttimeuse; @@ -99,15 +99,14 @@ else if (port > 65535) { Config.getInstance().setScreenMoverEnabled(true); } Config.getInstance().save(); - final ClientProfile clientProfile = new ClientProfile(new File(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;, Config.getInstance().getProfilesPath(), Config.getInstance().getStartupProfileID())), Config.getInstance().getIconsPath()); + final ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath() + "/" + Config.getInstance().getStartupProfileID() + ".xml"), Config.getInstance().getIconsPath()); final int pre = clientProfile.getActionSize() + clientProfile.getActionGap() * 4; this.rowsToSet = (int)(this.clientListener.getStageHeight() / pre); this.colsToSet = (int)(this.clientListener.getStageWidth() / pre); if (ClientInfo.getInstance().isPhone()) { - int tmp; OrientationService.create().ifPresent(orientationService -> { - if (orientationService.getOrientation().isPresent() && ((Orientation)orientationService.getOrientation().get()).equals((Object)Orientation.VERTICAL)) { - tmp = this.rowsToSet; + if (orientationService.getOrientation().isPresent() && orientationService.getOrientation().get().equals((Object)Orientation.VERTICAL)) { + final int tmp = this.rowsToSet; this.rowsToSet = this.colsToSet; this.colsToSet = tmp; } @@ -129,7 +128,7 @@ else if (port > 65535) { } else { Platform.runLater(() -> this.nextButton.setDisable(false)); - new StreamPiAlert("Uh Oh", invokedynamic(makeConcatWithConstants:(Ljava/lang/StringBuilder;)Ljava/lang/String;, errors), StreamPiAlertType.ERROR).show(); + new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n" + errors, StreamPiAlertType.ERROR).show(); } } } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java index b4cf1cce..e5099631 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.firsttimeuse; diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java index f994b115..43582863 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.firsttimeuse; diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java index 02149c0f..c14e19fa 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.firsttimeuse; diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java index 785195a4..264b6353 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.firsttimeuse; diff --git a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java index 52f2c432..f0a2d493 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.settings.About; @@ -68,24 +68,24 @@ public AboutTab(final ClientListener clientListener) { donateButton.setOnAction(event -> this.openWebpage("https://www.patreon.com/streampi")); donateButton.getStyleClass().add((Object)"about_donate_hyperlink"); final ClientInfo clientInfo = ClientInfo.getInstance(); - final Label versionText = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;, clientInfo.getVersion().getText(), clientInfo.getPlatform().getUIName(), clientInfo.getReleaseStatus().getUIName())); + final Label versionText = new Label(clientInfo.getVersion().getText() + " - " + clientInfo.getPlatform().getUIName() + " - " + clientInfo.getReleaseStatus().getUIName()); versionText.getStyleClass().add((Object)"about_version_label"); - final Label commStandardLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, clientInfo.getCommStandardVersion().getText())); + final Label commStandardLabel = new Label("Comm Standard " + clientInfo.getCommStandardVersion().getText()); commStandardLabel.getStyleClass().add((Object)"about_comm_standard_label"); - final Label minThemeAPILabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, clientInfo.getMinThemeSupportVersion().getText())); + final Label minThemeAPILabel = new Label("Min ThemeAPI " + clientInfo.getMinThemeSupportVersion().getText()); minThemeAPILabel.getStyleClass().add((Object)"about_min_theme_api_label"); - final Label minActionAPILabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, clientInfo.getMinPluginSupportVersion().getText())); + final Label minActionAPILabel = new Label("Min ActionAPI " + clientInfo.getMinPluginSupportVersion().getText()); minActionAPILabel.getStyleClass().add((Object)"about_min_action_api_label"); - final Label currentActionAPILabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ActionAPI.API_VERSION.getText())); + final Label currentActionAPILabel = new Label("ActionAPI " + ActionAPI.API_VERSION.getText()); currentActionAPILabel.getStyleClass().add((Object)"about_current_action_api_label"); final HBox hBox1 = new HBox(new Node[] { (Node)versionText }); hBox1.setAlignment(Pos.CENTER); hBox1.setSpacing(10.0); - final Label javaVersionLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, System.getProperty("java.version"))); + final Label javaVersionLabel = new Label("Java " + System.getProperty("java.version")); javaVersionLabel.getStyleClass().add((Object)"about_java_version"); - final Label javafxVersionLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, System.getProperty("javafx.version"))); + final Label javafxVersionLabel = new Label("JavaFX " + System.getProperty("javafx.version")); javafxVersionLabel.getStyleClass().add((Object)"about_javafx_version"); - final Label javaGCLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, ManagementFactory.getGarbageCollectorMXBeans().get(0).getName())); + final Label javaGCLabel = new Label("GC: " + ManagementFactory.getGarbageCollectorMXBeans().get(0).getName()); javaGCLabel.getStyleClass().add((Object)"about_java_gc"); final HBox hBox2 = new HBox(new Node[] { (Node)javaVersionLabel, (Node)this.getSep(), (Node)javafxVersionLabel }); hBox2.setAlignment(Pos.CENTER); @@ -101,7 +101,7 @@ public AboutTab(final ClientListener clientListener) { if (inputStream != null) { try { Logger.getLogger(this.getClass().getName()).info("build-date present"); - final Label buildDateLabel = new Label(invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, new String(inputStream.readAllBytes()))); + final Label buildDateLabel = new Label("Build date/time: " + new String(inputStream.readAllBytes())); buildDateLabel.getStyleClass().add((Object)"build-date-label"); this.mainVBox.getChildren().add((Object)buildDateLabel); } diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java index d862bd5a..7f2425bd 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.settings.About; diff --git a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java index c2ef3b9d..06f68a19 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.settings.About; diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java index ae562363..b463413b 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.settings.About; diff --git a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java index 16d24fc4..61928bbe 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.settings.About; diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java index 81c430e3..6efc4346 100644 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.settings; @@ -303,8 +303,8 @@ public void loadData() throws SevereException { final Config config = Config.getInstance(); this.nickNameTextField.setText(config.getClientNickName()); this.serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP()); - this.serverPortTextField.setText(invokedynamic(makeConcatWithConstants:(I)Ljava/lang/String;, config.getSavedServerPort())); - this.screenTimeoutTextField.setText(invokedynamic(makeConcatWithConstants:(I)Ljava/lang/String;, config.getScreenSaverTimeout())); + this.serverPortTextField.setText("" + config.getSavedServerPort()); + this.screenTimeoutTextField.setText("" + config.getScreenSaverTimeout()); this.screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); this.screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); this.clientProfileComboBox.setOptions((List)this.clientListener.getClientProfiles().getClientProfiles()); @@ -384,7 +384,7 @@ else if (this.nickNameTextField.getText().equals("imachonk")) { new StreamPiAlert("bigquimo is mega chonk", "i cant stop sweating lol").show(); } if (!errors.toString().isEmpty()) { - this.exceptionAndAlertHandler.handleMinorException(new MinorException("You made mistakes", invokedynamic(makeConcatWithConstants:(Ljava/lang/String;)Ljava/lang/String;, errors.toString()))); + this.exceptionAndAlertHandler.handleMinorException(new MinorException("You made mistakes", "Please fix the errors and try again :\n" + errors.toString())); return; } try { @@ -472,7 +472,7 @@ else if (this.nickNameTextField.getText().equals("imachonk")) { toBeReloaded = true; } config.setScreenMoverEnabled(this.screenMoverToggleSwitch.isSelected()); - if (!invokedynamic(makeConcatWithConstants:(I)Ljava/lang/String;, screenSaverTimeout).equals(this.screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) { + if (!("" + screenSaverTimeout).equals(this.screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) { config.setScreenSaverTimeout(this.screenTimeoutTextField.getText()); this.clientListener.getScreenSaver().setTimeout(config.getScreenSaverTimeout()); this.clientListener.getScreenSaver().restartTimer(); diff --git a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java index 274d447f..53480e28 100644 --- a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java +++ b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java @@ -1,5 +1,5 @@ // -// Decompiled by Procyon v0.5.36 +// Decompiled by Procyon v0.6-prerelease // package com.stream_pi.client.window.settings; From 72cc1e74d7c1bfcf1cca7260fb5b91d8a4e7daea Mon Sep 17 00:00:00 2001 From: quimo Date: Sun, 29 Aug 2021 18:06:26 +0100 Subject: [PATCH 03/12] changes --- src/main/java/com/stream_pi/client/Main.java | 100 +- .../animations/AnimateFXInterpolator.java | 20 - .../client/animations/AnimationFX.java | 131 -- .../stream_pi/client/animations/Bounce.java | 33 - .../com/stream_pi/client/animations/Flip.java | 46 - .../client/animations/JackInTheBox.java | 42 - .../stream_pi/client/animations/Jello.java | 43 - .../stream_pi/client/animations/Pulse.java | 35 - .../client/animations/RubberBand.java | 35 - .../stream_pi/client/animations/Shake.java | 33 - .../stream_pi/client/animations/Swing.java | 39 - .../com/stream_pi/client/animations/Tada.java | 38 - .../stream_pi/client/animations/Wobble.java | 34 - .../stream_pi/client/connection/Client.java | 1176 ++++++++++------- .../client/controller/ClientListener.java | 115 +- .../client/controller/Controller.java | 893 ++++++++----- .../client/controller/ScreenMover.java | 114 +- .../client/controller/ScreenSaver.java | 162 ++- .../com/stream_pi/client/info/ClientInfo.java | 147 ++- .../com/stream_pi/client/info/License.java | 45 +- .../stream_pi/client/info/StartupFlags.java | 28 +- .../java/com/stream_pi/client/io/Config.java | 692 ++++++---- .../client/profile/ClientProfile.java | 967 +++++++++----- .../client/profile/ClientProfiles.java | 144 +- .../com/stream_pi/client/window/Base.java | 700 ++++++---- .../window/ExceptionAndAlertHandler.java | 23 +- .../window/dashboard/DashboardBase.java | 98 +- .../dashboard/actiongridpane/ActionBox.java | 687 +++++----- .../actiongridpane/ActionGridPane.java | 561 +++++--- .../ActionGridPaneListener.java | 21 +- .../window/firsttimeuse/FinalConfigPane.java | 198 +-- .../window/firsttimeuse/FirstTimeUse.java | 189 +-- .../window/firsttimeuse/LicensePane.java | 31 +- .../window/firsttimeuse/WelcomePane.java | 34 +- .../window/firsttimeuse/WindowName.java | 11 +- .../window/settings/About/AboutTab.java | 244 ++-- .../window/settings/About/ContactTab.java | 62 +- .../window/settings/About/Contributor.java | 55 +- .../settings/About/ContributorsTab.java | 88 +- .../window/settings/About/LicenseTab.java | 16 +- .../client/window/settings/GeneralTab.java | 906 ++++++++----- .../client/window/settings/SettingsBase.java | 91 +- .../com/stream_pi/client/Default.zip | Bin 6759 -> 5434 bytes 43 files changed, 5167 insertions(+), 3960 deletions(-) delete mode 100644 src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java delete mode 100644 src/main/java/com/stream_pi/client/animations/AnimationFX.java delete mode 100644 src/main/java/com/stream_pi/client/animations/Bounce.java delete mode 100644 src/main/java/com/stream_pi/client/animations/Flip.java delete mode 100644 src/main/java/com/stream_pi/client/animations/JackInTheBox.java delete mode 100644 src/main/java/com/stream_pi/client/animations/Jello.java delete mode 100644 src/main/java/com/stream_pi/client/animations/Pulse.java delete mode 100644 src/main/java/com/stream_pi/client/animations/RubberBand.java delete mode 100644 src/main/java/com/stream_pi/client/animations/Shake.java delete mode 100644 src/main/java/com/stream_pi/client/animations/Swing.java delete mode 100644 src/main/java/com/stream_pi/client/animations/Tada.java delete mode 100644 src/main/java/com/stream_pi/client/animations/Wobble.java diff --git a/src/main/java/com/stream_pi/client/Main.java b/src/main/java/com/stream_pi/client/Main.java index d7559ed4..65f79390 100644 --- a/src/main/java/com/stream_pi/client/Main.java +++ b/src/main/java/com/stream_pi/client/Main.java @@ -1,65 +1,63 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client; +import com.stream_pi.client.controller.Controller; +import com.stream_pi.client.info.ClientInfo; + import com.stream_pi.client.info.StartupFlags; -import javafx.scene.Parent; +import javafx.application.Application; import javafx.scene.Scene; -import com.stream_pi.client.controller.Controller; import javafx.stage.Stage; -import javafx.application.Application; -public class Main extends Application -{ - public void start(final Stage stage) { - final Controller d = new Controller(); - final Scene s = new Scene((Parent)d); +public class Main extends Application { + + + @Override + public void start(Stage stage) + { + Controller d = new Controller(); + Scene s = new Scene(d); stage.setScene(s); - d.setHostServices(this.getHostServices()); + d.setHostServices(getHostServices()); d.init(); } - - public static void main(final String[] args) { - for (final String eachArg : args) { - if (eachArg.startsWith("Stream-Pi")) { - final String[] r = eachArg.split("="); - final String arg = r[0]; - final String val = r[1]; - final String s = arg; - switch (s) { - case "Stream-Pi.startupRunnerFileName": { - StartupFlags.RUNNER_FILE_NAME = val; - break; - } - case "Stream-Pi.showShutDownButton": { - StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = val.equals("true"); - break; - } - case "Stream-Pi.isXMode": { - StartupFlags.IS_X_MODE = val.equals("true"); - break; - } - case "Stream-Pi.isShowFullScreenToggleButton": { - StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = val.equals("true"); - break; - } - case "Stream-Pi.defaultFullScreenMode": { - StartupFlags.DEFAULT_FULLSCREEN_MODE = val.equals("true"); - break; - } - case "Stream-Pi.enableScreenSaverFeature": { - StartupFlags.SCREEN_SAVER_FEATURE = val.equals("true"); - break; - } - case "Stream-Pi.appendPathBeforeRunnerFileToOvercomeJPackageLimitation": { - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = val.equals("true"); - break; - } - } + + + public static void main(String[] args) + { + for(String eachArg : args) + { + if(!eachArg.startsWith("Stream-Pi")) + continue; + + String[] r = eachArg.split("="); + String arg = r[0]; + String val = r[1]; + + switch (arg) { + case "Stream-Pi.startupRunnerFileName": + StartupFlags.RUNNER_FILE_NAME = val; + break; + case "Stream-Pi.showShutDownButton": + StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = val.equals("true"); + break; + case "Stream-Pi.isXMode": + StartupFlags.IS_X_MODE = val.equals("true"); + break; + case "Stream-Pi.isShowFullScreenToggleButton": + StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = val.equals("true"); + break; + case "Stream-Pi.defaultFullScreenMode": + StartupFlags.DEFAULT_FULLSCREEN_MODE = val.equals("true"); + break; + case "Stream-Pi.enableScreenSaverFeature": + StartupFlags.SCREEN_SAVER_FEATURE = val.equals("true"); + break; + case "Stream-Pi.appendPathBeforeRunnerFileToOvercomeJPackageLimitation": + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = val.equals("true"); + break; } } + launch(args); } } diff --git a/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java b/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java deleted file mode 100644 index 49fecb95..00000000 --- a/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java +++ /dev/null @@ -1,20 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Interpolator; - -public final class AnimateFXInterpolator -{ - public static final Interpolator EASE; - - private AnimateFXInterpolator() { - throw new IllegalStateException("AnimateFX Interpolator"); - } - - static { - EASE = Interpolator.SPLINE(0.25, 0.1, 0.25, 1.0); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/AnimationFX.java b/src/main/java/com/stream_pi/client/animations/AnimationFX.java deleted file mode 100644 index 00bfe3f0..00000000 --- a/src/main/java/com/stream_pi/client/animations/AnimationFX.java +++ /dev/null @@ -1,131 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Animation; -import javafx.beans.value.ObservableValue; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; -import javafx.util.Duration; -import javafx.scene.Node; -import javafx.animation.Timeline; - -public abstract class AnimationFX -{ - public static final int INDEFINITE = -1; - private Timeline timeline; - private boolean reset; - private Node node; - private AnimationFX nextAnimation; - private boolean hasNextAnimation; - - public AnimationFX(final Node node) { - this.setNode(node); - } - - public AnimationFX() { - this.hasNextAnimation = false; - this.reset = false; - } - - private AnimationFX onFinished() { - if (this.reset) { - this.resetNode(); - } - if (this.nextAnimation != null) { - this.nextAnimation.play(); - } - return this; - } - - public AnimationFX playOnFinished(final AnimationFX animation) { - this.setNextAnimation(animation); - return this; - } - - public AnimationFX setResetOnFinished(final boolean reset) { - this.reset = reset; - return this; - } - - public void play() { - this.timeline.play(); - } - - public AnimationFX stop() { - this.timeline.stop(); - return this; - } - - abstract AnimationFX resetNode(); - - abstract void initTimeline(); - - public Timeline getTimeline() { - return this.timeline; - } - - public void setTimeline(final Timeline timeline) { - this.timeline = timeline; - } - - public boolean isResetOnFinished() { - return this.reset; - } - - protected void setReset(final boolean reset) { - this.reset = reset; - } - - public Node getNode() { - return this.node; - } - - public void setNode(final Node node) { - this.node = node; - this.initTimeline(); - this.timeline.statusProperty().addListener((observable, oldValue, newValue) -> { - if (newValue.equals((Object)Animation.Status.STOPPED)) { - this.onFinished(); - } - }); - } - - public AnimationFX getNextAnimation() { - return this.nextAnimation; - } - - protected void setNextAnimation(final AnimationFX nextAnimation) { - this.hasNextAnimation = true; - this.nextAnimation = nextAnimation; - } - - public boolean hasNextAnimation() { - return this.hasNextAnimation; - } - - protected void setHasNextAnimation(final boolean hasNextAnimation) { - this.hasNextAnimation = hasNextAnimation; - } - - public AnimationFX setCycleCount(final int value) { - this.timeline.setCycleCount(value); - return this; - } - - public AnimationFX setSpeed(final double value) { - this.timeline.setRate(value); - return this; - } - - public AnimationFX setDelay(final Duration value) { - this.timeline.setDelay(value); - return this; - } - - public final void setOnFinished(final EventHandler value) { - this.timeline.setOnFinished((EventHandler)value); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/Bounce.java b/src/main/java/com/stream_pi/client/animations/Bounce.java deleted file mode 100644 index 7b9f8de8..00000000 --- a/src/main/java/com/stream_pi/client/animations/Bounce.java +++ /dev/null @@ -1,33 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.Interpolator; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.Node; - -public class Bounce extends AnimationFX -{ - public Bounce(final Node node) { - super(node); - } - - public Bounce() { - } - - public AnimationFX resetNode() { - this.getNode().setTranslateY(0.0); - return this; - } - - @Override - void initTimeline() { - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)0, Interpolator.SPLINE(0.215, 0.61, 0.355, 1.0)) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)(-30), Interpolator.SPLINE(0.755, 0.05, 0.855, 0.06)) }), new KeyFrame(Duration.millis(550.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)0, Interpolator.SPLINE(0.215, 0.61, 0.355, 1.0)) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)(-15), Interpolator.SPLINE(0.755, 0.05, 0.855, 0.06)) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)0, Interpolator.SPLINE(0.215, 0.61, 0.355, 1.0)) }), new KeyFrame(Duration.millis(900.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)(-5), Interpolator.SPLINE(0.755, 0.05, 0.855, 0.06)) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateYProperty(), (Object)0, Interpolator.SPLINE(0.215, 0.61, 0.355, 1.0)) }) })); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/Flip.java b/src/main/java/com/stream_pi/client/animations/Flip.java deleted file mode 100644 index aa34814f..00000000 --- a/src/main/java/com/stream_pi/client/animations/Flip.java +++ /dev/null @@ -1,46 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.scene.ParallelCamera; -import javafx.event.ActionEvent; -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.Interpolator; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.transform.Rotate; -import javafx.scene.Camera; -import javafx.scene.PerspectiveCamera; -import javafx.scene.Node; - -public class Flip extends AnimationFX -{ - public Flip(final Node node) { - super(node); - } - - public Flip() { - } - - @Override - AnimationFX resetNode() { - this.getNode().setRotate(0.0); - this.getNode().setScaleX(1.0); - this.getNode().setScaleY(1.0); - this.getNode().setScaleZ(1.0); - this.getNode().setTranslateZ(0.0); - return this; - } - - @Override - void initTimeline() { - this.getNode().getScene().setCamera((Camera)new PerspectiveCamera()); - this.getNode().setRotationAxis(Rotate.Y_AXIS); - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)360, Interpolator.EASE_OUT) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)190, Interpolator.EASE_OUT), new KeyValue((WritableValue)this.getNode().translateZProperty(), (Object)(-150), Interpolator.EASE_OUT) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)170, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().translateZProperty(), (Object)(-150), Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.95, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.95, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)0.95, Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, Interpolator.EASE_IN), new KeyValue((WritableValue)this.getNode().translateZProperty(), (Object)0, Interpolator.EASE_IN) }) })); - this.getTimeline().setOnFinished(event -> this.getNode().getScene().setCamera((Camera)new ParallelCamera())); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/JackInTheBox.java b/src/main/java/com/stream_pi/client/animations/JackInTheBox.java deleted file mode 100644 index 3e564f49..00000000 --- a/src/main/java/com/stream_pi/client/animations/JackInTheBox.java +++ /dev/null @@ -1,42 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.Node; -import javafx.scene.transform.Rotate; - -public class JackInTheBox extends AnimationFX -{ - private Rotate rotate; - - public JackInTheBox(final Node node) { - super(node); - } - - public JackInTheBox() { - } - - @Override - AnimationFX resetNode() { - this.getNode().setScaleX(1.0); - this.getNode().setScaleZ(1.0); - this.getNode().setScaleY(1.0); - this.getNode().setOpacity(1.0); - this.rotate.setAngle(0.0); - return this; - } - - @Override - void initTimeline() { - this.rotate = new Rotate(30.0, this.getNode().getBoundsInParent().getWidth() / 2.0, this.getNode().getBoundsInParent().getHeight()); - this.getNode().getTransforms().add((Object)this.rotate); - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.rotate.angleProperty(), (Object)30, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().opacityProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.rotate.angleProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.rotate.angleProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.rotate.angleProperty(), (Object)0, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().opacityProperty(), (Object)1, AnimateFXInterpolator.EASE) }) })); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/Jello.java b/src/main/java/com/stream_pi/client/animations/Jello.java deleted file mode 100644 index 044e7c85..00000000 --- a/src/main/java/com/stream_pi/client/animations/Jello.java +++ /dev/null @@ -1,43 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.geometry.Bounds; -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.Node; -import javafx.scene.transform.Shear; - -public class Jello extends AnimationFX -{ - private Shear shear; - - public Jello(final Node node) { - super(node); - } - - public Jello() { - } - - @Override - AnimationFX resetNode() { - this.shear.setX(0.0); - this.shear.setY(0.0); - return this; - } - - @Override - void initTimeline() { - this.shear = new Shear(); - final Bounds bounds = this.getNode().getLayoutBounds(); - this.shear.setPivotX(bounds.getWidth() / 2.0); - this.shear.setPivotY(bounds.getHeight() / 2.0); - this.getNode().getTransforms().add((Object)this.shear); - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0) }), new KeyFrame(Duration.millis(111.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0.125), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0.125) }), new KeyFrame(Duration.millis(222.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)(-0.625)), new KeyValue((WritableValue)this.shear.yProperty(), (Object)(-0.625)) }), new KeyFrame(Duration.millis(333.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0.3125), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0.3125) }), new KeyFrame(Duration.millis(444.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)(-0.15625)), new KeyValue((WritableValue)this.shear.yProperty(), (Object)(-0.15625)) }), new KeyFrame(Duration.millis(555.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0.078125), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0.078125) }), new KeyFrame(Duration.millis(666.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)(-0.0390625)), new KeyValue((WritableValue)this.shear.yProperty(), (Object)(-0.0390625)) }), new KeyFrame(Duration.millis(777.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0.01953125), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0.01953125) }), new KeyFrame(Duration.millis(888.0), new KeyValue[] { new KeyValue((WritableValue)this.shear.xProperty(), (Object)0), new KeyValue((WritableValue)this.shear.yProperty(), (Object)0) }) })); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/Pulse.java b/src/main/java/com/stream_pi/client/animations/Pulse.java deleted file mode 100644 index 818d4a40..00000000 --- a/src/main/java/com/stream_pi/client/animations/Pulse.java +++ /dev/null @@ -1,35 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.Node; - -public class Pulse extends AnimationFX -{ - public Pulse(final Node node) { - super(node); - } - - public Pulse() { - } - - @Override - AnimationFX resetNode() { - this.getNode().setScaleX(1.0); - this.getNode().setScaleY(1.0); - this.getNode().setScaleZ(1.0); - return this; - } - - @Override - void initTimeline() { - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.05, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.05, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.05, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }) })); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/RubberBand.java b/src/main/java/com/stream_pi/client/animations/RubberBand.java deleted file mode 100644 index 71da6c94..00000000 --- a/src/main/java/com/stream_pi/client/animations/RubberBand.java +++ /dev/null @@ -1,35 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.Node; - -public class RubberBand extends AnimationFX -{ - public RubberBand(final Node node) { - super(node); - } - - public RubberBand() { - } - - @Override - AnimationFX resetNode() { - this.getNode().setScaleX(1.0); - this.getNode().setScaleY(1.0); - this.getNode().setScaleZ(1.0); - return this; - } - - @Override - void initTimeline() { - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(300.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.25, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.75, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.75, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.25, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.15, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.85, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(650.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.95, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.05, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(750.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.05, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.95, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE) }) })); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/Shake.java b/src/main/java/com/stream_pi/client/animations/Shake.java deleted file mode 100644 index b168de7d..00000000 --- a/src/main/java/com/stream_pi/client/animations/Shake.java +++ /dev/null @@ -1,33 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.Node; - -public class Shake extends AnimationFX -{ - public Shake(final Node node) { - super(node); - } - - public Shake() { - } - - @Override - AnimationFX resetNode() { - this.getNode().setTranslateX(0.0); - return this; - } - - @Override - void initTimeline() { - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(100.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(200.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)10, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(300.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)10, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)10, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)10, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(900.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)0, AnimateFXInterpolator.EASE) }) })); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/Swing.java b/src/main/java/com/stream_pi/client/animations/Swing.java deleted file mode 100644 index cead81e8..00000000 --- a/src/main/java/com/stream_pi/client/animations/Swing.java +++ /dev/null @@ -1,39 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.Node; -import javafx.scene.transform.Rotate; - -public class Swing extends AnimationFX -{ - private Rotate rotation; - - public Swing(final Node node) { - super(node); - } - - public Swing() { - } - - @Override - AnimationFX resetNode() { - this.rotation.setAngle(0.0); - return this; - } - - @Override - void initTimeline() { - (this.rotation = new Rotate()).setPivotX(this.getNode().getLayoutBounds().getWidth() / 2.0); - this.rotation.setPivotY(-this.getNode().getLayoutBounds().getHeight()); - this.getNode().getTransforms().add((Object)this.rotation); - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(200.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)15, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)(-10), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)5, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)(-5), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.rotation.angleProperty(), (Object)0, AnimateFXInterpolator.EASE) }) })); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/Tada.java b/src/main/java/com/stream_pi/client/animations/Tada.java deleted file mode 100644 index 5ad65776..00000000 --- a/src/main/java/com/stream_pi/client/animations/Tada.java +++ /dev/null @@ -1,38 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.transform.Rotate; -import javafx.scene.Node; - -public class Tada extends AnimationFX -{ - public Tada(final Node node) { - super(node); - } - - public Tada() { - } - - @Override - AnimationFX resetNode() { - this.getNode().setScaleX(1.0); - this.getNode().setScaleY(1.0); - this.getNode().setScaleZ(1.0); - this.getNode().setRotate(0.0); - return this; - } - - @Override - void initTimeline() { - this.getNode().setRotationAxis(Rotate.Z_AXIS); - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(100.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(200.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)0.9, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(300.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(400.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(500.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(800.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(900.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1.1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().scaleXProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleYProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().scaleZProperty(), (Object)1, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, AnimateFXInterpolator.EASE) }) })); - } -} diff --git a/src/main/java/com/stream_pi/client/animations/Wobble.java b/src/main/java/com/stream_pi/client/animations/Wobble.java deleted file mode 100644 index a63be276..00000000 --- a/src/main/java/com/stream_pi/client/animations/Wobble.java +++ /dev/null @@ -1,34 +0,0 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - -package com.stream_pi.client.animations; - -import javafx.animation.Timeline; -import javafx.beans.value.WritableValue; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import javafx.scene.Node; - -public class Wobble extends AnimationFX -{ - public Wobble(final Node node) { - super(node); - } - - public Wobble() { - } - - @Override - AnimationFX resetNode() { - this.getNode().setTranslateX(0.0); - this.getNode().setRotate(0.0); - return this; - } - - @Override - void initTimeline() { - this.setTimeline(new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)0, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(150.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-0.25 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-5), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(300.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(0.2 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)3, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(450.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-0.15 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-3), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(0.1 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)2, AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(750.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)(-0.05 * this.getNode().getBoundsInParent().getWidth()), AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)(-1), AnimateFXInterpolator.EASE) }), new KeyFrame(Duration.millis(1000.0), new KeyValue[] { new KeyValue((WritableValue)this.getNode().translateXProperty(), (Object)0, AnimateFXInterpolator.EASE), new KeyValue((WritableValue)this.getNode().rotateProperty(), (Object)0, AnimateFXInterpolator.EASE) }) })); - } -} diff --git a/src/main/java/com/stream_pi/client/connection/Client.java b/src/main/java/com/stream_pi/client/connection/Client.java index ac99c850..50c98dba 100644 --- a/src/main/java/com/stream_pi/client/connection/Client.java +++ b/src/main/java/com/stream_pi/client/connection/Client.java @@ -1,693 +1,963 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.connection; -import java.util.Objects; -import java.io.File; -import com.stream_pi.action_api.actionproperty.property.Type; -import com.stream_pi.util.version.Version; -import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; import com.stream_pi.action_api.action.DisplayTextAlignment; +import com.stream_pi.action_api.action.Location; import com.stream_pi.action_api.actionproperty.ClientProperties; import com.stream_pi.action_api.actionproperty.property.Property; -import com.stream_pi.action_api.action.ActionType; -import java.util.ArrayList; -import java.util.Iterator; -import com.stream_pi.client.profile.ClientProfile; -import javafx.geometry.Orientation; +import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.client.controller.ClientListener; import com.stream_pi.client.io.Config; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.action_api.action.Action; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import javafx.application.Platform; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.util.alert.StreamPiAlertType; import com.stream_pi.util.comms.Message; -import com.stream_pi.util.exception.SevereException; -import java.io.IOException; import com.stream_pi.util.exception.MinorException; -import java.net.SocketAddress; -import java.net.InetSocketAddress; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.version.Version; +import javafx.application.Platform; import javafx.concurrent.Task; -import java.util.logging.Logger; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.controller.ClientListener; -import java.util.concurrent.atomic.AtomicBoolean; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; +import javafx.geometry.Orientation; + +import java.io.*; +import java.net.InetSocketAddress; import java.net.Socket; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Logger; public class Client extends Thread { + private Socket socket; + private ObjectOutputStream oos; private ObjectInputStream ois; - private AtomicBoolean stop; + + private AtomicBoolean stop = new AtomicBoolean(false); + private ClientListener clientListener; private ExceptionAndAlertHandler exceptionAndAlertHandler; + private ClientInfo clientInfo; + private String serverIP; private int serverPort; private Logger logger; + private Runnable onConnectAndSetupToBeRun; - - public Client(final String serverIP, final int serverPort, final ClientListener clientListener, final ExceptionAndAlertHandler exceptionAndAlertHandler, final Runnable onConnectAndSetupToBeRun) { - this.stop = new AtomicBoolean(false); + + public Client(String serverIP, int serverPort, ClientListener clientListener, + ExceptionAndAlertHandler exceptionAndAlertHandler, Runnable onConnectAndSetupToBeRun) + { this.serverIP = serverIP; this.serverPort = serverPort; + this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.clientInfo = ClientInfo.getInstance(); this.clientListener = clientListener; + this.onConnectAndSetupToBeRun = onConnectAndSetupToBeRun; - this.logger = Logger.getLogger(Client.class.getName()); - clientListener.getExecutor().submit((Runnable)new Task() { - protected Void call() { - try { - try { - Client.this.logger.info("Trying to connect to server at " + serverIP + ":" + serverPort); - (Client.this.socket = new Socket()).connect(new InetSocketAddress(serverIP, serverPort), 5000); + + logger = Logger.getLogger(Client.class.getName()); + + clientListener.getExecutor().submit(new Task() { + @Override + protected Void call() + { + try + { + try + { + logger.info("Trying to connect to server at "+serverIP+":"+serverPort); + socket = new Socket(); + socket.connect(new InetSocketAddress(serverIP, serverPort), 5000); clientListener.setConnected(true); - Client.this.logger.info("Connected to " + Client.this.socket.getRemoteSocketAddress() + " !"); + logger.info("Connected to "+socket.getRemoteSocketAddress()+" !"); } - catch (IOException e) { + catch (IOException e) + { e.printStackTrace(); clientListener.setConnected(false); throw new MinorException("Connection Error", "Unable to connect to server. Please check settings and connection and try again."); } - finally { + finally + { clientListener.updateSettingsConnectDisconnectButton(); } - try { - Client.this.oos = new ObjectOutputStream(Client.this.socket.getOutputStream()); - Client.this.ois = new ObjectInputStream(Client.this.socket.getInputStream()); + + try + { + oos = new ObjectOutputStream(socket.getOutputStream()); + ois = new ObjectInputStream(socket.getInputStream()); } - catch (IOException e) { - Client.this.logger.severe(e.getMessage()); + catch (IOException e) + { + logger.severe(e.getMessage()); e.printStackTrace(); throw new MinorException("Unable to set up io Streams to server. Check connection and try again."); } - Client.this.start(); - } - catch (MinorException e2) { - exceptionAndAlertHandler.handleMinorException(e2); + + start(); + } catch (MinorException e) + { + exceptionAndAlertHandler.handleMinorException(e); } return null; } }); } - - public synchronized void exit() { - if (this.stop.get()) { + + public synchronized void exit() + { + if(stop.get()) return; - } - this.logger.info("Stopping ..."); - try { - if (this.socket != null) { - this.disconnect(); + + logger.info("Stopping ..."); + + try + { + if(socket!=null) + { + disconnect(); } } - catch (SevereException e) { - this.logger.severe(e.getMessage()); - this.exceptionAndAlertHandler.handleSevereException(e); + catch (SevereException e) + { + logger.severe(e.getMessage()); + exceptionAndAlertHandler.handleSevereException(e); e.printStackTrace(); } } - - public synchronized void sendMessage(final Message message) throws SevereException { - try { - this.oos.writeObject(message); - this.oos.flush(); - } - catch (IOException e) { + + + public synchronized void sendMessage(Message message) throws SevereException + { + try + { + oos.writeObject(message); + oos.flush(); + } + catch (IOException e) + { e.printStackTrace(); throw new SevereException("Unable to write to io Stream!"); } } - + @Override public void run() { - try { - while (!this.stop.get()) { - try { - final Message message = (Message)this.ois.readObject(); - final String header = message.getHeader(); - this.logger.info("Message Received. Heading : " + header); - final String s = header; - switch (s) { - case "ready": { - this.onServerReady(); - continue; - } - case "action_icon": { - this.onActionIconReceived(message); - continue; - } - case "disconnect": { - this.serverDisconnected(message); - continue; - } - case "get_client_details": { - this.sendClientDetails(); - continue; - } - case "get_client_screen_details": { - this.sendClientScreenDetails(); - continue; - } - case "get_profiles": { - this.sendProfileNamesToServer(); - continue; - } - case "get_profile_details": { - this.sendProfileDetailsToServer(message); - continue; - } - case "save_action_details": { - this.saveActionDetails(message); - continue; - } - case "delete_action": { - this.deleteAction(message); - continue; - } - case "get_themes": { - this.sendThemesToServer(); - continue; - } - case "save_client_details": { - this.saveClientDetails(message); - continue; - } - case "save_client_profile": { - this.saveProfileDetails(message); - continue; - } - case "delete_profile": { - this.deleteProfile(message); - continue; - } - case "action_failed": { - this.actionFailed(message); - continue; - } - case "set_toggle_status": { - this.onSetToggleStatus(message); - continue; - } - default: { - this.logger.warning("Command '" + header + "' does not match records. Make sure client and server versions are equal."); - continue; - } + try + { + while(!stop.get()) + { + try + { + Message message = (Message) ois.readObject(); + + String header = message.getHeader(); + + logger.info("Message Received. Heading : "+header); + + switch (header) + { + case "ready" : onServerReady(); + break; + + case "action_icon" : onActionIconReceived(message); + break; + + case "disconnect" : serverDisconnected(message); + break; + + case "get_client_details" : sendClientDetails(); + break; + + case "get_client_screen_details" : sendClientScreenDetails(); + break; + + case "get_profiles" : sendProfileNamesToServer(); + break; + + case "get_profile_details": sendProfileDetailsToServer(message); + break; + + case "save_action_details": saveActionDetails(message); + break; + + case "delete_action": deleteAction(message); + break; + + case "get_themes": sendThemesToServer(); + break; + + case "save_client_details": saveClientDetails(message); + break; + + case "save_client_profile": saveProfileDetails(message); + break; + + case "delete_profile": deleteProfile(message); + break; + + case "action_failed": actionFailed(message); + break; + + case "set_toggle_status": onSetToggleStatus(message); + break; + + default: logger.warning("Command '"+header+"' does not match records. Make sure client and server versions are equal."); + } - continue; } - catch (IOException | ClassNotFoundException ex) { - final Exception ex2; - final Exception e = ex2; - this.logger.severe(e.getMessage()); + catch (IOException | ClassNotFoundException e) + { + logger.severe(e.getMessage()); e.printStackTrace(); - this.clientListener.setConnected(false); - this.clientListener.updateSettingsConnectDisconnectButton(); - this.clientListener.onDisconnect(); - if (!this.stop.get()) { + + clientListener.setConnected(false); + clientListener.updateSettingsConnectDisconnectButton(); + clientListener.onDisconnect(); + + if(!stop.get()) + { + //isDisconnect.set(true); //Prevent running disconnect throw new MinorException("Accidentally disconnected from Server! (Failed at readUTF)"); } - this.exit(); + + exit(); + return; } - break; } } - catch (SevereException e2) { - this.logger.severe(e2.getMessage()); - e2.printStackTrace(); - this.exceptionAndAlertHandler.handleSevereException(e2); + catch (SevereException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + + exceptionAndAlertHandler.handleSevereException(e); } - catch (MinorException e3) { - this.logger.severe(e3.getMessage()); - e3.printStackTrace(); - this.exceptionAndAlertHandler.handleMinorException(e3); + catch (MinorException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + + exceptionAndAlertHandler.handleMinorException(e); } } - - private void onSetToggleStatus(final Message message) { - final String[] arr = message.getStringArrValue(); - final String profileID = arr[0]; - final String actionID = arr[1]; - final boolean newStatus = arr[2].equals("true"); - final boolean currentStatus = this.clientListener.getToggleStatus(profileID, actionID); - if (currentStatus == newStatus) { + + private void onSetToggleStatus(Message message) + { + String[] arr = message.getStringArrValue(); + + String profileID = arr[0]; + String actionID = arr[1]; + boolean newStatus = arr[2].equals("true"); + + boolean currentStatus = clientListener.getToggleStatus(profileID,actionID); + + if(currentStatus == newStatus) + { return; } - final ActionBox actionBox = this.clientListener.getActionBoxByProfileAndID(profileID, actionID); - if (actionBox != null) { + + ActionBox actionBox = clientListener.getActionBoxByProfileAndID(profileID, actionID); + + if(actionBox!=null) + { actionBox.setCurrentToggleStatus(newStatus); - Platform.runLater(() -> actionBox.toggle(newStatus)); + Platform.runLater(()-> actionBox.toggle(newStatus)); } } - - private void onActionIconReceived(final Message message) throws MinorException { - final String profileID = message.getStringArrValue()[0]; - final String actionID = message.getStringArrValue()[1]; - final String state = message.getStringArrValue()[2]; - this.clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon(actionID, message.getByteArrValue(), state); - final Action a = this.clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - this.clientListener.renderAction(profileID, a); + + private void onActionIconReceived(Message message) throws MinorException + { + String profileID = message.getStringArrValue()[0]; + String actionID = message.getStringArrValue()[1]; + String state = message.getStringArrValue()[2]; + + clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon( + actionID, + message.getByteArrValue(), + state + ); + + Action a = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + clientListener.renderAction(profileID, a); } - - public synchronized void sendIcon(final String profileID, final String actionID, final String state, final byte[] icon) throws SevereException { - try { - Thread.sleep(50L); - } - catch (InterruptedException e) { + + + + //commands + + public synchronized void sendIcon(String profileID, String actionID, String state, byte[] icon) throws SevereException + { + try + { + Thread.sleep(50); + } + catch (InterruptedException e) + { e.printStackTrace(); } - final Message message = new Message("action_icon"); - message.setStringArrValue(new String[] { profileID, actionID, state }); + + Message message = new Message("action_icon"); + message.setStringArrValue(profileID, actionID, state); message.setByteArrValue(icon); - this.sendMessage(message); + sendMessage(message); } - - public void disconnect() throws SevereException { - this.disconnect(""); + + public void disconnect() throws SevereException + { + disconnect(""); } - - public void disconnect(final String message) throws SevereException { - if (this.stop.get()) { + + public void disconnect(String message) throws SevereException + { + if(stop.get()) return; - } - this.stop.set(true); - this.logger.info("Sending server disconnect message ..."); - final Message m = new Message("disconnect"); + + stop.set(true); + + logger.info("Sending server disconnect message ..."); + + Message m = new Message("disconnect"); m.setStringValue(message); - this.sendMessage(m); - try { - if (!this.socket.isClosed()) { - this.socket.close(); - } - this.clientListener.setConnected(false); - this.clientListener.updateSettingsConnectDisconnectButton(); + sendMessage(m); + + try + { + if(!socket.isClosed()) + socket.close(); + + clientListener.setConnected(false); + clientListener.updateSettingsConnectDisconnectButton(); } - catch (IOException e) { + catch (IOException e) + { e.printStackTrace(); throw new SevereException("Unable to close socket"); } } - - public void onServerReady() { - if (this.onConnectAndSetupToBeRun != null) { - this.onConnectAndSetupToBeRun.run(); - this.onConnectAndSetupToBeRun = null; + + public void onServerReady() + { + if(onConnectAndSetupToBeRun!=null) + { + onConnectAndSetupToBeRun.run(); + onConnectAndSetupToBeRun = null; } } - - public void sendThemesToServer() throws SevereException { - final Message message = new Message("themes"); - final String[] arr = new String[this.clientListener.getThemes().getThemeList().size() * 4]; + + public void sendThemesToServer() throws SevereException + { + Message message = new Message("themes"); + + String[] arr = new String[clientListener.getThemes().getThemeList().size()*4]; + int x = 0; - for (int i = 0; i < this.clientListener.getThemes().getThemeList().size(); ++i) { - final Theme theme = this.clientListener.getThemes().getThemeList().get(i); + for(int i = 0;i a = new ArrayList(); + + ArrayList a = new ArrayList<>(); + a.add(profileID); a.add(action.getID()); - a.add("" + action.getActionType()); - if (action.getActionType() == ActionType.NORMAL || action.getActionType() == ActionType.TOGGLE) { + a.add(action.getActionType()+""); + + if(action.getActionType() == ActionType.NORMAL || + action.getActionType() == ActionType.TOGGLE) { a.add(action.getVersion().getText()); } - else { + else + { a.add("no"); } - if (action.getActionType() == ActionType.NORMAL || action.getActionType() == ActionType.TOGGLE) { + + if(action.getActionType() ==ActionType.NORMAL || + action.getActionType() == ActionType.TOGGLE) + { a.add(action.getModuleName()); } - else { + else + { a.add("nut"); } + + //display + a.add(action.getBgColourHex()); - final StringBuilder allIconStatesNames = new StringBuilder(); - for (final String eachState : action.getIcons().keySet()) { + + //icon + + + StringBuilder allIconStatesNames = new StringBuilder(); + for(String eachState : action.getIcons().keySet()) + { allIconStatesNames.append(eachState).append("::"); } a.add(allIconStatesNames.toString()); - a.add(action.getCurrentIconState()); - a.add("" + action.isShowDisplayText()); + + + a.add(action.getCurrentIconState()+""); + + //text + a.add(action.isShowDisplayText()+""); a.add(action.getDisplayTextFontColourHex()); a.add(action.getDisplayText()); - a.add("" + action.getNameFontSize()); - a.add("" + action.getDisplayTextAlignment()); - if (action.getLocation() == null) { + a.add(action.getNameFontSize()+""); + a.add(action.getDisplayTextAlignment()+""); + + //location + + if(action.getLocation() == null) + { a.add("-1"); a.add("-1"); } - else { - a.add("" + action.getLocation().getRow()); - a.add("" + action.getLocation().getCol()); + else + { + a.add(action.getLocation().getRow()+""); + a.add(action.getLocation().getCol()+""); } + a.add(action.getParent()); - a.add("" + action.getDelayBeforeExecuting()); - final ClientProperties clientProperties = action.getClientProperties(); - a.add("" + clientProperties.getSize()); - for (final Property property : clientProperties.get()) { + + a.add(action.getDelayBeforeExecuting()+""); + + //client properties + + ClientProperties clientProperties = action.getClientProperties(); + + a.add(clientProperties.getSize()+""); + + for(Property property : clientProperties.get()) + { a.add(property.getName()); a.add(property.getRawValue()); } - final Message message = new Message("action_details"); + + + + Message message = new Message("action_details"); + String[] x = new String[a.size()]; x = a.toArray(x); + message.setStringArrValue(x); - this.sendMessage(message); + sendMessage(message); + } - - public void saveActionDetails(final Message message) { - final String[] r = message.getStringArrValue(); - final String profileID = r[0]; - final String actionID = r[1]; - final ActionType actionType = ActionType.valueOf(r[2]); - final String bgColorHex = r[5]; - final String[] iconStates = r[6].split("::"); - final String currentIconState = r[7]; - final boolean isShowDisplayText = r[8].equals("true"); - final String displayFontColor = r[9]; - final String displayText = r[10]; - final double displayLabelFontSize = Double.parseDouble(r[11]); - final DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[12]); - final String row = r[13]; - final String col = r[14]; - final Location location = new Location(Integer.parseInt(row), Integer.parseInt(col)); - final Action action = new Action(actionID, actionType); - Label_0190: { - if (actionType != ActionType.NORMAL) { - if (actionType != ActionType.TOGGLE) { - break Label_0190; - } - } - try { + + public void saveActionDetails(Message message) + { + String[] r = message.getStringArrValue(); + + String profileID = r[0]; + + String actionID = r[1]; + ActionType actionType = ActionType.valueOf(r[2]); + + //3 - Version + //4 - ModuleName + + //display + String bgColorHex = r[5]; + + String[] iconStates = r[6].split("::"); + String currentIconState = r[7]; + + //text + boolean isShowDisplayText = r[8].equals("true"); + String displayFontColor = r[9]; + String displayText = r[10]; + double displayLabelFontSize = Double.parseDouble(r[11]); + DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[12]); + + //location + String row = r[13]; + String col = r[14]; + + Location location = new Location(Integer.parseInt(row), Integer.parseInt(col)); + + Action action = new Action(actionID, actionType); + + if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE) + { + try + { action.setVersion(new Version(r[3])); action.setModuleName(r[4]); } - catch (Exception e) { - this.logger.severe(e.getMessage()); + catch (Exception e) + { + logger.severe(e.getMessage()); e.printStackTrace(); } } + + action.setBgColourHex(bgColorHex); + action.setShowDisplayText(isShowDisplayText); action.setDisplayTextFontColourHex(displayFontColor); action.setDisplayText(displayText); action.setDisplayTextAlignment(displayTextAlignment); action.setNameFontSize(displayLabelFontSize); action.setCurrentIconState(currentIconState); + action.setLocation(location); - final String parent = r[15]; + + + String parent = r[15]; action.setParent(parent); + + //client properties + action.setDelayBeforeExecuting(Integer.parseInt(r[16])); - final int clientPropertiesSize = Integer.parseInt(r[17]); - final ClientProperties clientProperties = new ClientProperties(); - if (actionType == ActionType.FOLDER) { + + int clientPropertiesSize = Integer.parseInt(r[17]); + + ClientProperties clientProperties = new ClientProperties(); + + if(actionType == ActionType.FOLDER) clientProperties.setDuplicatePropertyAllowed(true); - } - for (int i = 18; i < clientPropertiesSize * 2 + 18; i += 2) { - final Property property = new Property(r[i], Type.STRING); - property.setRawValue(r[i + 1]); + + for(int i = 18;i<((clientPropertiesSize*2) + 18); i+=2) + { + Property property = new Property(r[i], Type.STRING); + property.setRawValue(r[i+1]); + clientProperties.addProperty(property); } + action.setClientProperties(clientProperties); - try { - final Action old = this.clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID()); - if (old != null) { - for (String oldState : old.getIcons().keySet()) { + + try + { + Action old = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID()); + + if(old != null) + { + for(String oldState : old.getIcons().keySet()) + { boolean isPresent = false; - for (final String state : iconStates) { - if (state.equals(oldState)) { + for(String state : iconStates) + { + if(state.equals(oldState)) + { isPresent = true; action.addIcon(state, old.getIcon(state)); break; } } - if (!isPresent) { - new File(Config.getInstance().getIconsPath() + "/" + actionID + "___" + oldState).delete(); + + if(!isPresent) + { + // State no longer exists. Delete. + + new File(Config.getInstance().getIconsPath()+"/"+actionID+"___"+oldState).delete(); } } } - this.clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action); - this.clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action); - this.clientListener.renderAction(profileID, action); - if (this.clientListener.getScreenSaver() != null) { - Platform.runLater(() -> this.clientListener.getScreenSaver().restart()); + + clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action); + + clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action); + + clientListener.renderAction(profileID, action); + + if(clientListener.getScreenSaver()!=null) + { + Platform.runLater(()->clientListener.getScreenSaver().restart()); } } - catch (Exception e2) { - e2.printStackTrace(); - this.exceptionAndAlertHandler.handleMinorException(new MinorException(e2.getMessage())); + catch (Exception e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); } } - - public void deleteAction(final Message message) { - try { - final String[] arr = message.getStringArrValue(); - final String profileID = arr[0]; - final String actionID = arr[1]; - final Action acc = this.clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - if (acc == null) { - this.exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action " + actionID + " since it does not exist.")); + + public void deleteAction(Message message) + { + try + { + String[] arr = message.getStringArrValue(); + String profileID = arr[0]; + String actionID = arr[1]; + + Action acc = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + + if(acc == null) + { + exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action "+actionID+" since it does not exist.")); return; } - if (acc.getActionType() == ActionType.FOLDER) { - final ArrayList idsToBeRemoved = new ArrayList(); - final ArrayList folders = new ArrayList(); - final String folderToBeDeletedID = this.clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID(); + + if(acc.getActionType() == ActionType.FOLDER) + { + ArrayList idsToBeRemoved = new ArrayList<>(); + + ArrayList folders = new ArrayList<>(); + String folderToBeDeletedID = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID(); + folders.add(folderToBeDeletedID); + boolean startOver = true; - while (startOver) { + while(startOver) + { startOver = false; - for (final Action action : this.clientListener.getClientProfiles().getProfileFromID(profileID).getActions()) { - if (folders.contains(action.getParent()) && !idsToBeRemoved.contains(action.getID())) { - idsToBeRemoved.add(action.getID()); - if (action.getActionType() != ActionType.FOLDER) { - continue; + for(Action action : clientListener.getClientProfiles().getProfileFromID(profileID).getActions()) + { + if(folders.contains(action.getParent())) + { + if(!idsToBeRemoved.contains(action.getID())) + { + idsToBeRemoved.add(action.getID()); + if(action.getActionType() == ActionType.FOLDER) + { + folders.add(action.getID()); + startOver = true; + } } - folders.add(action.getID()); - startOver = true; } } } - for (final String ids : idsToBeRemoved) { - this.clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids); + + + for(String ids : idsToBeRemoved) + { + clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids); } - final ClientListener clientListener = this.clientListener; - Objects.requireNonNull(clientListener); + Platform.runLater(clientListener::renderRootDefaultProfile); + } - else if (acc.getActionType() == ActionType.COMBINE) { - for (final Property property : acc.getClientProperties().get()) { - this.clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue()); + else if (acc.getActionType() == ActionType.COMBINE) + { + for(Property property : acc.getClientProperties().get()) + { + clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue()); } } - this.clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID()); - this.clientListener.getClientProfiles().getProfileFromID(profileID).saveActions(); - if (acc.getLocation().getCol() != -1) { - Platform.runLater(() -> { - if (this.clientListener.getCurrentProfile().getID().equals(profileID) && this.clientListener.getCurrentParent().equals(acc.getParent())) { - this.clientListener.clearActionBox(acc.getLocation().getCol(), acc.getLocation().getRow()); + + + clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID()); + + clientListener.getClientProfiles().getProfileFromID(profileID).saveActions(); + + if(acc.getLocation().getCol()!=-1) + { + Platform.runLater(()-> { + if (clientListener.getCurrentProfile().getID().equals(profileID) + && clientListener.getCurrentParent().equals(acc.getParent())) + { + clientListener.clearActionBox( + acc.getLocation().getCol(), + acc.getLocation().getRow() + ); } }); } + + } - catch (Exception e) { + catch (Exception e) + { e.printStackTrace(); - this.exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); + exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); } } - - public void saveClientDetails(final Message message) { - try { - final boolean reInit = false; - final String[] sep = message.getStringArrValue(); + + public void saveClientDetails(Message message) + { + try + { + boolean reInit = false; + + String[] sep = message.getStringArrValue(); + Config.getInstance().setNickName(sep[0]); + + Config.getInstance().setStartupProfileID(sep[1]); - final String oldThemeFullName = Config.getInstance().getCurrentThemeFullName(); - final String newThemeFullName = sep[2]; + + String oldThemeFullName = Config.getInstance().getCurrentThemeFullName(); + String newThemeFullName = sep[2]; + Config.getInstance().setCurrentThemeFullName(sep[2]); Config.getInstance().save(); - if (!oldThemeFullName.equals(newThemeFullName)) { - Platform.runLater(() -> { + + if(!oldThemeFullName.equals(newThemeFullName)) + { + Platform.runLater(()-> { try { - this.clientListener.initThemes(); - } - catch (SevereException e2) { - this.exceptionAndAlertHandler.handleSevereException(e2); + clientListener.initThemes(); + } catch (SevereException e) { + exceptionAndAlertHandler.handleSevereException(e); } - return; }); } - final ClientListener clientListener = this.clientListener; - Objects.requireNonNull(clientListener); + Platform.runLater(clientListener::loadSettings); } - catch (SevereException e) { + catch (SevereException e) + { e.printStackTrace(); - this.exceptionAndAlertHandler.handleSevereException(e); + exceptionAndAlertHandler.handleSevereException(e); } } - - public void saveProfileDetails(final Message message) throws SevereException, MinorException { - final String[] sep = message.getStringArrValue(); - ClientProfile clientProfile = this.clientListener.getClientProfiles().getProfileFromID(sep[0]); - if (clientProfile == null) { - clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath() + "/" + sep[0] + ".xml"), Config.getInstance().getIconsPath()); + + public void saveProfileDetails(Message message) throws SevereException, MinorException + { + String[] sep = message.getStringArrValue(); + + ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(sep[0]); + + if(clientProfile == null) + { + clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+sep[0]+".xml"), + Config.getInstance().getIconsPath()); } + clientProfile.setName(sep[1]); clientProfile.setRows(Integer.parseInt(sep[2])); clientProfile.setCols(Integer.parseInt(sep[3])); clientProfile.setActionSize(Integer.parseInt(sep[4])); clientProfile.setActionGap(Integer.parseInt(sep[5])); - try { - this.clientListener.getClientProfiles().addProfile(clientProfile); + + try + { + clientListener.getClientProfiles().addProfile(clientProfile); clientProfile.saveProfileDetails(); - this.clientListener.refreshGridIfCurrentProfile(sep[0]); - final ClientListener clientListener = this.clientListener; - Objects.requireNonNull(clientListener); + clientListener.refreshGridIfCurrentProfile(sep[0]); Platform.runLater(clientListener::loadSettings); } - catch (Exception e) { + catch (Exception e) + { e.printStackTrace(); throw new SevereException(e.getMessage()); } } - - public void deleteProfile(final Message message) { - this.clientListener.getClientProfiles().deleteProfile(this.clientListener.getClientProfiles().getProfileFromID(message.getStringValue())); - if (this.clientListener.getCurrentProfile().getID().equals(message.getStringValue())) { - final ClientListener clientListener = this.clientListener; - Objects.requireNonNull(clientListener); + + public void deleteProfile(Message message) + { + clientListener.getClientProfiles().deleteProfile(clientListener.getClientProfiles().getProfileFromID( + message.getStringValue() + )); + + if(clientListener.getCurrentProfile().getID().equals(message.getStringValue())) + { Platform.runLater(clientListener::renderRootDefaultProfile); } } - - public void onActionClicked(final String profileID, final String actionID, final boolean toggleState) throws SevereException { - final Message m = new Message("action_clicked"); - m.setStringArrValue(new String[] { profileID, actionID, "" + toggleState }); - this.sendMessage(m); + + public void onActionClicked(String profileID, String actionID, boolean toggleState) throws SevereException + { + Message m = new Message("action_clicked"); + m.setStringArrValue(profileID, actionID, toggleState+""); + sendMessage(m); } - - public void updateOrientationOnClient(final Orientation orientation) throws SevereException { - final Message m = new Message("client_orientation"); + + public void updateOrientationOnClient(Orientation orientation) throws SevereException + { + Message m = new Message("client_orientation"); m.setStringValue(orientation.toString()); - this.sendMessage(m); + sendMessage(m); } - - public void actionFailed(final Message message) { - final String[] r = message.getStringArrValue(); - final String profileID = r[0]; - final String actionID = r[1]; - this.clientListener.onActionFailed(profileID, actionID); + + public void actionFailed(Message message) + { + String[] r = message.getStringArrValue(); + String profileID = r[0]; + String actionID = r[1]; + clientListener.onActionFailed(profileID, actionID); } } diff --git a/src/main/java/com/stream_pi/client/controller/ClientListener.java b/src/main/java/com/stream_pi/client/controller/ClientListener.java index da1ac435..aedf3ed3 100644 --- a/src/main/java/com/stream_pi/client/controller/ClientListener.java +++ b/src/main/java/com/stream_pi/client/controller/ClientListener.java @@ -1,97 +1,86 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.controller; -import javafx.geometry.Orientation; -import java.util.concurrent.ExecutorService; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; import com.stream_pi.action_api.action.Action; -import com.stream_pi.client.profile.ClientProfile; import com.stream_pi.client.connection.Client; -import com.stream_pi.theme_api.Themes; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.profile.ClientProfile; import com.stream_pi.client.profile.ClientProfiles; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.theme_api.Themes; +import com.stream_pi.util.exception.SevereException; +import javafx.geometry.Orientation; + +import java.util.concurrent.ExecutorService; public interface ClientListener { - void onActionFailed(final String p0, final String p1); - - void onActionClicked(final String p0, final String p1, final boolean p2); - + void onActionFailed(String profileID, String actionID); + void onActionClicked(String profileID, String actionID, boolean toggleState); ClientProfiles getClientProfiles(); - + Themes getThemes(); - String getDefaultThemeFullName(); - + Client getClient(); - + void renderRootDefaultProfile(); - - void setConnected(final boolean p0); - + + void setConnected(boolean isConnected); boolean isConnected(); + + void renderProfile(ClientProfile clientProfile, boolean freshRender); + + void clearActionBox(int col, int row); + void addBlankActionBox(int col, int row); + void renderAction(String currentProfileID, Action action); + void refreshGridIfCurrentProfile(String currentProfileID); - void renderProfile(final ClientProfile p0, final boolean p1); - - void clearActionBox(final int p0, final int p1); - - void addBlankActionBox(final int p0, final int p1); - - void renderAction(final String p0, final Action p1); - - void refreshGridIfCurrentProfile(final String p0); - - ActionBox getActionBox(final int p0, final int p1); - + ActionBox getActionBox(int col, int row); + ClientProfile getCurrentProfile(); - + String getCurrentParent(); - + Theme getCurrentTheme(); - + void initLogger() throws SevereException; - void init(); - - void disconnect(final String p0) throws SevereException; - + + void disconnect(String message) throws SevereException; + void setupClientConnection(); - - void setupClientConnection(final Runnable p0); - + + void setupClientConnection(Runnable onConnect); + void updateSettingsConnectDisconnectButton(); - + void onCloseRequest(); - + void loadSettings(); - + double getStageWidth(); - double getStageHeight(); - + void onDisconnect(); - - boolean getToggleStatus(final String p0, final String p1); - - ActionBox getActionBoxByProfileAndID(final String p0, final String p1); - - void openURL(final String p0); - + + boolean getToggleStatus(String profileID, String actionID); + + ActionBox getActionBoxByProfileAndID(String profileID, String actionID); + + void openURL(String URL); + void factoryReset(); - void exitApp(); - + ExecutorService getExecutor(); - + Orientation getCurrentOrientation(); - - void setFirstRun(final boolean p0); - + + void setFirstRun(boolean firstRun); + ScreenSaver getScreenSaver(); - + void initThemes() throws SevereException; } diff --git a/src/main/java/com/stream_pi/client/controller/Controller.java b/src/main/java/com/stream_pi/client/controller/Controller.java index 18b32443..993c6fcd 100644 --- a/src/main/java/com/stream_pi/client/controller/Controller.java +++ b/src/main/java/com/stream_pi/client/controller/Controller.java @@ -1,476 +1,723 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.controller; -import javafx.beans.value.ObservableValue; -import javafx.stage.WindowEvent; -import javafx.event.ActionEvent; -import com.stream_pi.util.iohelper.IOHelper; import com.gluonhq.attach.browser.BrowserService; +import com.gluonhq.attach.orientation.OrientationService; +import com.gluonhq.attach.vibration.VibrationService; import com.stream_pi.action_api.action.Action; +import com.stream_pi.client.Main; +import com.stream_pi.client.connection.Client; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import com.gluonhq.attach.vibration.VibrationService; -import com.stream_pi.util.alert.StreamPiAlertListener; -import java.util.logging.Level; -import javafx.scene.Node; -import javafx.beans.value.WritableValue; -import javafx.animation.Interpolator; -import javafx.animation.KeyValue; -import javafx.util.Duration; -import javafx.animation.KeyFrame; -import java.util.function.Consumer; -import com.gluonhq.attach.util.Services; -import com.gluonhq.attach.lifecycle.LifecycleService; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import java.util.Iterator; -import com.stream_pi.util.exception.SevereException; -import com.gluonhq.attach.orientation.OrientationService; import com.stream_pi.client.profile.ClientProfiles; -import java.io.File; -import com.stream_pi.client.io.Config; -import com.stream_pi.util.exception.MinorException; +import com.stream_pi.client.window.Base; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertListener; import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.startatboot.StartAtBoot; -import com.stream_pi.client.Main; -import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.gluonhq.attach.lifecycle.LifecycleService; +import com.gluonhq.attach.util.Services; + +import com.stream_pi.util.iohelper.IOHelper; import com.stream_pi.util.platform.PlatformType; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.util.platform.Platform; +import com.stream_pi.util.startatboot.StartAtBoot; +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; import javafx.animation.Timeline; +import javafx.application.Platform; +import javafx.beans.InvalidationListener; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; import javafx.geometry.Orientation; -import com.stream_pi.client.connection.Client; -import com.stream_pi.client.window.Base; +import javafx.scene.Node; +import javafx.scene.input.KeyCombination; +import javafx.scene.layout.StackPane; +import javafx.stage.Screen; +import javafx.util.Duration; + +import java.io.*; +import java.net.URISyntaxException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.logging.Level; + public class Controller extends Base { private Client client; - private boolean firstRun; - private ScreenSaver screenSaver; - private ScreenMover screenMover; - private Orientation currentOrientation; - private Timeline openSettingsTimeLine; - private Timeline closeSettingsTimeLine; - private boolean isConnected; - - public Controller() { - this.firstRun = true; - this.screenSaver = null; - this.screenMover = null; - this.currentOrientation = null; - this.isConnected = false; - this.client = null; + + public Controller() + { + client = null; } - - public ScreenSaver getScreenSaver() { - return this.screenSaver; + + + private boolean firstRun = true; + private ScreenSaver screenSaver = null; + private ScreenMover screenMover = null; + + @Override + public ScreenSaver getScreenSaver() + { + return screenSaver; } - - public void init() { - try { - if (this.firstRun) { - this.initBase(); - } - if (this.getConfig().isScreenSaverEnabled()) { - if (this.screenSaver == null) { - this.screenSaver = new ScreenSaver(this, this.getConfig().getScreenSaverTimeout()); - this.getChildren().add((Object)this.screenSaver); - this.screenSaver.toBack(); + + @Override + public void init() + { + try + { + if(firstRun) + initBase(); + + + if(getConfig().isScreenSaverEnabled()) + { + if(screenSaver == null) + { + screenSaver = new ScreenSaver(this, getConfig().getScreenSaverTimeout()); + getChildren().add(screenSaver); + screenSaver.toBack(); } - else { - this.screenSaver.setTimeout(this.getConfig().getScreenSaverTimeout()); - this.screenSaver.restart(); + else + { + screenSaver.setTimeout(getConfig().getScreenSaverTimeout()); + screenSaver.restart(); } } - else if (this.screenSaver != null) { - this.screenSaver.stop(); - this.getChildren().remove((Object)this.screenSaver); - this.screenSaver = null; + else + { + if(screenSaver != null) + { + screenSaver.stop(); + getChildren().remove(screenSaver); + screenSaver = null; + } } - if (this.getClientInfo().getPlatform() != Platform.ANDROID) { - if (this.getConfig().isStartOnBoot() && StartupFlags.IS_X_MODE != this.getConfig().isStartupXMode()) { - final StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), Main.class.getProtectionDomain().getCodeSource().getLocation(), StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); - final boolean result = startAtBoot.delete(); - if (!result) { - new StreamPiAlert("Uh Oh!", "Unable to delete the previous starter file.\nThis 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(); - } - else { - try { - startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); - this.getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE); + + + if(getClientInfo().getPlatform() != com.stream_pi.util.platform.Platform.ANDROID) + { + if(getConfig().isStartOnBoot()) + { + if(StartupFlags.IS_X_MODE != getConfig().isStartupXMode()) + { + StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), + Main.class.getProtectionDomain().getCodeSource().getLocation(), + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); + + boolean result = startAtBoot.delete(); + if(!result) + { + 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, " + + "delete the old starter file, then exit and restart Stream-Pi as normal user.", StreamPiAlertType.ERROR).show(); } - catch (MinorException e) { - this.getConfig().setStartOnBoot(false); - this.handleMinorException(e); + else + { + try + { + startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); + getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE); + } + catch (MinorException e) + { + getConfig().setStartOnBoot(false); + handleMinorException(e); + } } } } - this.setupFlags(); - if (!this.getConfig().getIsFullScreenMode()) { - this.getStage().setWidth(this.getConfig().getStartupWindowWidth()); - this.getStage().setHeight(this.getConfig().getStartupWindowHeight()); + + setupFlags(); + + if(!getConfig().getIsFullScreenMode()) + { + getStage().setWidth(getConfig().getStartupWindowWidth()); + getStage().setHeight(getConfig().getStartupWindowHeight()); } } - this.setupDashWindow(); - this.getStage().show(); - if (this.getConfig().isScreenMoverEnabled()) { - if (this.screenMover == null) { - this.screenMover = new ScreenMover(this.getStage(), this.getConfig().getScreenMoverInterval(), this.getConfig().getScreenMoverXChange(), this.getConfig().getScreenMoverYChange()); + + + setupDashWindow(); + + getStage().show(); + + + if(getConfig().isScreenMoverEnabled()) + { + if(screenMover == null) + { + screenMover = new ScreenMover(getStage(), getConfig().getScreenMoverInterval(), + getConfig().getScreenMoverXChange(), + getConfig().getScreenMoverYChange()); } - else { - this.screenMover.setInterval(this.getConfig().getScreenMoverInterval()); - this.screenMover.restart(); + else + { + screenMover.setInterval(getConfig().getScreenMoverInterval()); + screenMover.restart(); } } - else if (this.screenMover != null) { - this.screenMover.stop(); - this.screenMover = null; + else + { + if(screenMover != null) + { + screenMover.stop(); + screenMover = null; + } } - if (Config.getInstance().isFirstTimeUse()) { + + + if(Config.getInstance().isFirstTimeUse()) return; - } - this.setupSettingsWindowsAnimations(); - this.getDashboardPane().getSettingsButton().setOnAction(event -> this.openSettingsTimeLine.play()); - this.getSettingsPane().getCloseButton().setOnAction(event -> this.closeSettingsTimeLine.play()); - this.setClientProfiles(new ClientProfiles(new File(this.getConfig().getProfilesPath()), this.getConfig().getStartupProfileID())); - if (this.getClientProfiles().getLoadingErrors().size() > 0) { - final StringBuilder errors = new StringBuilder("Please rectify the following errors and try again"); - for (final MinorException exception : this.getClientProfiles().getLoadingErrors()) { - errors.append("\n * ").append(exception.getMessage()); + + setupSettingsWindowsAnimations(); + + + + getDashboardPane().getSettingsButton().setOnAction(event -> { + openSettingsTimeLine.play(); + }); + + getSettingsPane().getCloseButton().setOnAction(event -> { + closeSettingsTimeLine.play(); + }); + + setClientProfiles(new ClientProfiles(new File(getConfig().getProfilesPath()), getConfig().getStartupProfileID())); + + if(getClientProfiles().getLoadingErrors().size() > 0) + { + StringBuilder errors = new StringBuilder("Please rectify the following errors and try again"); + + for(MinorException exception : getClientProfiles().getLoadingErrors()) + { + errors.append("\n * ") + .append(exception.getMessage()); } + throw new MinorException("Profiles", errors.toString()); } - if (this.getClientInfo().isPhone() && this.getConfig().isInvertRowsColsOnDeviceRotate()) { + + + if(getClientInfo().isPhone() && getConfig().isInvertRowsColsOnDeviceRotate()) + { OrientationService.create().ifPresent(orientationService -> { - if (orientationService.getOrientation().isPresent()) { - this.setCurrentOrientation(orientationService.getOrientation().get()); + if(orientationService.getOrientation().isPresent()) + { + setCurrentOrientation(orientationService.getOrientation().get()); orientationService.orientationProperty().addListener((observableValue, oldOrientation, newOrientation) -> { - this.setCurrentOrientation(newOrientation); - this.getDashboardPane().renderProfile(this.getCurrentProfile(), this.getCurrentParent(), true); - this.getExecutor().submit(() -> { - try { - if (this.isConnected()) { - this.getClient().updateOrientationOnClient(this.getCurrentOrientation()); + setCurrentOrientation(newOrientation); + + getDashboardPane().renderProfile( + getCurrentProfile(), + getCurrentParent(), + true + ); + + getExecutor().submit(()->{ + try + { + if(isConnected()) + { + getClient().updateOrientationOnClient(getCurrentOrientation()); } } - catch (SevereException e) { - this.handleSevereException(e); + catch (SevereException e) + { + handleSevereException(e); } }); }); } - return; }); } - this.renderRootDefaultProfile(); - this.loadSettings(); - if (this.firstRun) { - if (this.getConfig().isConnectOnStartup()) { - this.setupClientConnection(); + + renderRootDefaultProfile(); + loadSettings(); + + if(firstRun) + { + if(getConfig().isConnectOnStartup()) + { + setupClientConnection(); } - this.firstRun = false; + firstRun = false; } - if (!this.getClientInfo().isPhone()) { - this.getStage().widthProperty().addListener((observableValue, orientation, t1) -> this.syncClientSizeDetailsWithServer()); - this.getStage().heightProperty().addListener((observableValue, orientation, t1) -> this.syncClientSizeDetailsWithServer()); + + if(!getClientInfo().isPhone()) + { + getStage().widthProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); + getStage().heightProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); } } - catch (SevereException e2) { - this.handleSevereException(e2); + catch (SevereException e) + { + handleSevereException(e); } - catch (MinorException e3) { - this.handleMinorException(e3); + catch (MinorException e) + { + handleMinorException(e); } } - - public Orientation getCurrentOrientation() { - return this.currentOrientation; + + private Orientation currentOrientation = null; + + @Override + public Orientation getCurrentOrientation() + { + return currentOrientation; } - - private void setCurrentOrientation(final Orientation currentOrientation) { + + private void setCurrentOrientation(Orientation currentOrientation) + { this.currentOrientation = currentOrientation; } - - public void syncClientSizeDetailsWithServer() { - if (this.isConnected()) { + + public void syncClientSizeDetailsWithServer() + { + if(isConnected()) + { try { - this.client.sendClientScreenDetails(); - } - catch (SevereException e) { + client.sendClientScreenDetails(); + } catch (SevereException e) { e.printStackTrace(); } } } - - public void setupClientConnection() { - this.setupClientConnection(null); + + @Override + public void setupClientConnection() + { + setupClientConnection(null); } - - public void setupClientConnection(final Runnable onConnect) { - if (this.getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) { + + @Override + public void setupClientConnection(Runnable onConnect) + { + if(getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) //probably already connecting return; - } - javafx.application.Platform.runLater(() -> this.getSettingsPane().getGeneralTab().setDisableStatus(true)); - this.client = new Client(this.getConfig().getSavedServerHostNameOrIP(), this.getConfig().getSavedServerPort(), this, this, onConnect); + + Platform.runLater(()->getSettingsPane().getGeneralTab().setDisableStatus(true)); + client = new Client(getConfig().getSavedServerHostNameOrIP(), getConfig().getSavedServerPort(), this, this, onConnect); } - + + @Override public void updateSettingsConnectDisconnectButton() { - this.getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus(); + getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus(); } - - public void disconnect(final String message) throws SevereException { - this.client.disconnect(message); + + @Override + public void disconnect(String message) throws SevereException { + client.disconnect(message); } - - public void setupDashWindow() { - this.getStage().setTitle("Stream-Pi Client"); - this.getStage().setOnCloseRequest(e -> { - this.onCloseRequest(); - this.exitApp(); + + + public void setupDashWindow() + { + getStage().setTitle("Stream-Pi Client"); + getStage().setOnCloseRequest(e->{ + onCloseRequest(); + exitApp(); }); } - - public void onCloseRequest() { - try { - if (this.isConnected()) { - this.client.exit(); - } - if (this.screenSaver != null) { - this.screenSaver.stop(); + + + @Override + public void onCloseRequest() + { + try + { + if(isConnected()) + client.exit(); + + if(screenSaver != null) + { + screenSaver.stop(); } - if (this.screenMover != null) { - this.screenMover.stop(); + + if(screenMover != null) + { + screenMover.stop(); } - if (this.getConfig() != null && !this.getClientInfo().isPhone() && !this.getConfig().getIsFullScreenMode()) { - this.getConfig().setStartupWindowSize(this.getStageWidth(), this.getStageHeight()); - this.getConfig().save(); + + if(getConfig() != null) + { + if(!getClientInfo().isPhone() && !getConfig().getIsFullScreenMode()) + { + getConfig().setStartupWindowSize(getStageWidth(), getStageHeight()); + getConfig().save(); + } } } - catch (SevereException e) { - this.handleSevereException(e); + catch (SevereException e) + { + handleSevereException(e); } - finally { - this.getLogger().info("Shut down"); - this.closeLogger(); + finally + { + getLogger().info("Shut down"); + closeLogger(); Config.nullify(); } } - - public void exitApp() { - this.getExecutor().shutdown(); - if (ClientInfo.getInstance().getPlatform() == Platform.ANDROID) { - Services.get((Class)LifecycleService.class).ifPresent(LifecycleService::shutdown); + + @Override + public void exitApp() + { + getExecutor().shutdown(); + if (ClientInfo.getInstance().getPlatform() == com.stream_pi.util.platform.Platform.ANDROID) + { + Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown); } - else { - javafx.application.Platform.exit(); + else + { + Platform.exit(); } } - + + @Override public void loadSettings() { try { - this.getSettingsPane().getGeneralTab().loadData(); - } - catch (SevereException e) { + getSettingsPane().getGeneralTab().loadData(); + } catch (SevereException e) { e.printStackTrace(); - this.handleSevereException(e); + handleSevereException(e); } } - + + @Override public Client getClient() { - return this.client; + return client; } - + + @Override public void onDisconnect() { - javafx.application.Platform.runLater(() -> this.getDashboardPane().getActionGridPane().toggleOffAllToggleActions()); + Platform.runLater(()->getDashboardPane().getActionGridPane().toggleOffAllToggleActions()); } - - public boolean getToggleStatus(final String profileID, final String actionID) { - return this.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus(); + + @Override + public boolean getToggleStatus(String profileID, String actionID) + { + return getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus(); } - - private void setupSettingsWindowsAnimations() { - final Node settingsNode = (Node)this.getSettingsPane(); - final Node dashboardNode = (Node)this.getDashboardPane(); - (this.openSettingsTimeLine = new Timeline()).setCycleCount(1); - this.openSettingsTimeLine.getKeyFrames().addAll((Object[])new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)settingsNode.opacityProperty(), (Object)0.0, Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(90.0), new KeyValue[] { new KeyValue((WritableValue)settingsNode.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)dashboardNode.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(90.0), new KeyValue[] { new KeyValue((WritableValue)dashboardNode.opacityProperty(), (Object)0.0, Interpolator.LINEAR) }) }); - this.openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront()); - (this.closeSettingsTimeLine = new Timeline()).setCycleCount(1); - this.closeSettingsTimeLine.getKeyFrames().addAll((Object[])new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)settingsNode.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(90.0), new KeyValue[] { new KeyValue((WritableValue)settingsNode.opacityProperty(), (Object)0.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)dashboardNode.opacityProperty(), (Object)0.0, Interpolator.LINEAR) }), new KeyFrame(Duration.millis(90.0), new KeyValue[] { new KeyValue((WritableValue)dashboardNode.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }) }); - this.closeSettingsTimeLine.setOnFinished(event1 -> { + + + private Timeline openSettingsTimeLine; + private Timeline closeSettingsTimeLine; + + + private void setupSettingsWindowsAnimations() + { + Node settingsNode = getSettingsPane(); + Node dashboardNode = getDashboardPane(); + + openSettingsTimeLine = new Timeline(); + openSettingsTimeLine.setCycleCount(1); + + + openSettingsTimeLine.getKeyFrames().addAll( + new KeyFrame(Duration.millis(0.0D), + new KeyValue(settingsNode.opacityProperty(), + 0.0D, Interpolator.EASE_IN)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(settingsNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)), + + new KeyFrame(Duration.millis(0.0D), + new KeyValue(dashboardNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(dashboardNode.opacityProperty(), + 0.0D, Interpolator.LINEAR)) + ); + + openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront()); + + + closeSettingsTimeLine = new Timeline(); + closeSettingsTimeLine.setCycleCount(1); + + closeSettingsTimeLine.getKeyFrames().addAll( + new KeyFrame(Duration.millis(0.0D), + new KeyValue(settingsNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(settingsNode.opacityProperty(), + 0.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(0.0D), + new KeyValue(dashboardNode.opacityProperty(), + 0.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(dashboardNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)) + ); + + closeSettingsTimeLine.setOnFinished(event1 -> { dashboardNode.toFront(); - javafx.application.Platform.runLater(() -> { + Platform.runLater(()-> { try { - this.getSettingsPane().getGeneralTab().loadData(); - } - catch (SevereException e) { + getSettingsPane().getGeneralTab().loadData(); + } catch (SevereException e) { e.printStackTrace(); - this.handleSevereException(e); + + handleSevereException(e); } }); }); } - - public void handleMinorException(final MinorException e) { - this.handleMinorException(e.getMessage(), e); + + + @Override + public void handleMinorException(MinorException e) + { + handleMinorException(e.getMessage(), e); } - - public void handleMinorException(final String message, final MinorException e) { - this.getLogger().log(Level.SEVERE, message, (Throwable)e); + + @Override + public void handleMinorException(String message, MinorException e) + { + getLogger().log(Level.SEVERE, message, e); e.printStackTrace(); - javafx.application.Platform.runLater(() -> { - if (this.getScreenSaver() != null) { - this.getScreenSaver().restart(); + + Platform.runLater(()-> { + if(getScreenSaver() != null) + { + getScreenSaver().restart(); } - this.genNewAlert(e.getTitle(), message, StreamPiAlertType.WARNING).show(); + + genNewAlert(e.getTitle(), message, StreamPiAlertType.WARNING).show(); }); } - - public void handleSevereException(final SevereException e) { - this.handleSevereException(e.getMessage(), e); + + @Override + public void handleSevereException(SevereException e) + { + handleSevereException(e.getMessage(), e); } - - public void handleSevereException(final String message, final SevereException e) { - this.getLogger().log(Level.SEVERE, message, (Throwable)e); + + @Override + public void handleSevereException(String message, SevereException e) + { + getLogger().log(Level.SEVERE, message, e); e.printStackTrace(); - javafx.application.Platform.runLater(() -> { - if (this.getScreenSaver() != null) { - this.getScreenSaver().restart(); + + + Platform.runLater(()-> + { + if(getScreenSaver() != null) + { + getScreenSaver().restart(); } - final StreamPiAlert alert = this.genNewAlert(e.getTitle(), message, StreamPiAlertType.ERROR); - alert.setOnClicked((StreamPiAlertListener)new StreamPiAlertListener() { - public void onClick(final String txt) { - Controller.this.onCloseRequest(); - Controller.this.exitApp(); + + StreamPiAlert alert = genNewAlert(e.getTitle(), message, StreamPiAlertType.ERROR); + + alert.setOnClicked(new StreamPiAlertListener() + { + @Override + public void onClick(String txt) + { + onCloseRequest(); + exitApp(); } }); alert.show(); }); } - - public void onAlert(final String title, final String body, final StreamPiAlertType alertType) { - javafx.application.Platform.runLater(() -> this.genNewAlert(title, body, alertType).show()); + + @Override + public void onAlert(String title, String body, StreamPiAlertType alertType) { + Platform.runLater(()-> genNewAlert(title, body, alertType).show()); } - - public StreamPiAlert genNewAlert(final String title, final String message, final StreamPiAlertType alertType) { + + public StreamPiAlert genNewAlert(String title, String message, StreamPiAlertType alertType) + { return new StreamPiAlert(title, message, alertType); } - - public void onActionFailed(final String profileID, final String actionID) { - javafx.application.Platform.runLater(() -> this.getDashboardPane().getActionGridPane().actionFailed(profileID, actionID)); + + + private boolean isConnected = false; + + @Override + public void onActionFailed(String profileID, String actionID) { + Platform.runLater(()-> getDashboardPane().getActionGridPane().actionFailed(profileID, actionID)); } - - public void onActionClicked(final String profileID, final String actionID, final boolean toggleState) { + + @Override + public void onActionClicked(String profileID, String actionID, boolean toggleState) + { try { - this.vibratePhone(); - this.client.onActionClicked(profileID, actionID, toggleState); - } - catch (SevereException e) { + + vibratePhone(); + + client.onActionClicked(profileID, actionID, toggleState); + } catch (SevereException e) { e.printStackTrace(); - this.handleSevereException(e); + handleSevereException(e); } } - - public void vibratePhone() { - if (this.getConfig().isVibrateOnActionClicked()) { + + public void vibratePhone() + { + if(getConfig().isVibrateOnActionClicked()) + { VibrationService.create().ifPresent(VibrationService::vibrate); } } - - public void setConnected(final boolean isConnected) { + + @Override + public void setConnected(boolean isConnected) { this.isConnected = isConnected; } - - public ActionBox getActionBox(final int col, final int row) { - return this.getDashboardPane().getActionGridPane().getActionBox(col, row); + + @Override + public ActionBox getActionBox(int col, int row) + { + return getDashboardPane().getActionGridPane().getActionBox(col, row); } - - public boolean isConnected() { - return this.isConnected; + + @Override + public boolean isConnected() + { + return isConnected; } - - public void renderProfile(final ClientProfile clientProfile, final boolean freshRender) { - this.getDashboardPane().renderProfile(clientProfile, freshRender); + + @Override + public void renderProfile(ClientProfile clientProfile, boolean freshRender) + { + getDashboardPane().renderProfile(clientProfile, freshRender); } - - public void clearActionBox(final int col, final int row) { - javafx.application.Platform.runLater(() -> this.getDashboardPane().getActionGridPane().clearActionBox(col, row)); + + @Override + public void clearActionBox(int col, int row) + { + Platform.runLater(()->getDashboardPane().getActionGridPane().clearActionBox(col, row)); } - - public void addBlankActionBox(final int col, final int row) { - javafx.application.Platform.runLater(() -> this.getDashboardPane().getActionGridPane().addBlankActionBox(col, row)); + + @Override + public void addBlankActionBox(int col, int row) + { + Platform.runLater(()->getDashboardPane().getActionGridPane().addBlankActionBox(col, row)); } - - public void renderAction(final String currentProfileID, final Action action) { - javafx.application.Platform.runLater(() -> { + + @Override + public void renderAction(String currentProfileID, Action action) + { + Platform.runLater(()->{ try { - if (this.getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) && this.getCurrentProfile().getID().equals(currentProfileID)) { - this.getDashboardPane().getActionGridPane().renderAction(action); + if(getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) && + getCurrentProfile().getID().equals(currentProfileID)) + { + getDashboardPane().getActionGridPane().renderAction(action); } + } - catch (Exception e) { + catch (Exception e) + { e.printStackTrace(); } }); } - - public void refreshGridIfCurrentProfile(final String profileID) { - if (this.getCurrentProfile().getID().equals(profileID)) { - javafx.application.Platform.runLater(() -> this.getDashboardPane().renderProfile(this.getClientProfiles().getProfileFromID(profileID), true)); + + + + @Override + public void refreshGridIfCurrentProfile(String profileID) { + if(getCurrentProfile().getID().equals(profileID)) + { + Platform.runLater(()-> getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(profileID), true)); } } - + + @Override public ClientProfile getCurrentProfile() { - return this.getDashboardPane().getActionGridPane().getClientProfile(); + return getDashboardPane().getActionGridPane().getClientProfile(); } - - public String getCurrentParent() { - return this.getDashboardPane().getActionGridPane().getCurrentParent(); + + @Override + public String getCurrentParent() + { + return getDashboardPane().getActionGridPane().getCurrentParent(); } - - public ActionBox getActionBoxByProfileAndID(final String profileID, final String actionID) { - final Action action = this.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - if (!this.getCurrentProfile().getID().equals(profileID) && !this.getCurrentParent().equals(action.getParent())) { + + + @Override + public ActionBox getActionBoxByProfileAndID(String profileID, String actionID) + { + Action action = getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + + if(!getCurrentProfile().getID().equals(profileID) && !getCurrentParent().equals(action.getParent())) return null; - } - return this.getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation()); + + return getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation()); } - - public void openURL(final String url) { - if (ClientInfo.getInstance().isPhone()) { - BrowserService.create().ifPresentOrElse(s -> { - try { + + @Override + public void openURL(String url) + { + if(ClientInfo.getInstance().isPhone()) + { + BrowserService.create().ifPresentOrElse(s-> + { + try + { s.launchExternalBrowser(url); } - catch (Exception e) { - this.handleMinorException(new MinorException("Cant start browser! You can go to Server Settings > About > Contact and open the links from there.")); + catch (Exception e ) + { + handleMinorException( + new MinorException("Cant start browser! You can go to Server Settings > About > Contact " + + "and open the links from there.") + ); } - }, () -> this.handleMinorException(new MinorException("Sorry!", "No browser detected. You can go to Server Settings > About > Contact and open the links from there."))); - } - else if (this.getClientInfo().getPlatform() == Platform.LINUX && !StartupFlags.IS_X_MODE) { - this.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 and open the links from there.")); + },()-> handleMinorException( + new MinorException("Sorry!","No browser detected. You can go to Server Settings > About > Contact " + + "and open the links from there.") + )); } - else { - this.getHostServices().showDocument(url); + else + { + if(getClientInfo().getPlatform() == com.stream_pi.util.platform.Platform.LINUX && + !StartupFlags.IS_X_MODE) + { + 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 " + + "and open the links from there.")); + } + else + { + getHostServices().showDocument(url); + } } } - - public void factoryReset() { - this.getLogger().info("Reset to factory ..."); - this.onCloseRequest(); - try { - IOHelper.deleteFile(this.getClientInfo().getPrePath()); - this.setFirstRun(true); - this.init(); + + @Override + public void factoryReset() + { + getLogger().info("Reset to factory ..."); + + onCloseRequest(); + + try + { + IOHelper.deleteFile(getClientInfo().getPrePath()); + + setFirstRun(true); + init(); } - catch (SevereException e) { - this.handleSevereException("Unable to successfully factory reset. Delete directory \n'" + this.getClientInfo().getPrePath() + "/home/rnayabed/HDD_1/projects/stream-pi/server'\nMessage:\n" + e.getMessage(), e); + catch (SevereException e) + { + handleSevereException("Unable to successfully factory reset. Delete directory \n'"+getClientInfo().getPrePath()+"/home/rnayabed/HDD_1/projects/stream-pi/server'\nMessage:\n"+e.getMessage(),e); } } - - public void setFirstRun(final boolean firstRun) { + + @Override + public void setFirstRun(boolean firstRun) + { this.firstRun = firstRun; } } diff --git a/src/main/java/com/stream_pi/client/controller/ScreenMover.java b/src/main/java/com/stream_pi/client/controller/ScreenMover.java index a0fc60b5..bdb799d0 100644 --- a/src/main/java/com/stream_pi/client/controller/ScreenMover.java +++ b/src/main/java/com/stream_pi/client/controller/ScreenMover.java @@ -1,26 +1,33 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.controller; -import java.util.TimerTask; +import com.stream_pi.client.window.Base; +import com.stream_pi.util.exception.SevereException; +import javafx.animation.*; import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.layout.StackPane; import javafx.stage.Stage; +import javafx.util.Duration; + import java.util.Timer; +import java.util.TimerTask; public class ScreenMover { private Timer timer; + private long interval; + private boolean isOldLocation; - private double originalX; - private double originalY; - private double changeX; - private double changeY; + private double originalX, originalY; + private double changeX, changeY; + private Stage stage; - - public ScreenMover(final Stage stage, final long interval, final int changeX, final int changeY) { + + public ScreenMover(Stage stage, long interval, int changeX, int changeY) + { this.stage = stage; this.changeX = changeX; this.changeY = changeY; @@ -28,52 +35,69 @@ public ScreenMover(final Stage stage, final long interval, final int changeX, fi this.originalY = stage.getY(); this.isOldLocation = true; this.interval = interval; - this.startTimer(); + + startTimer(); } - - public void stop() { - this.isOldLocation = true; - this.shiftScreen(); - this.stopTimer(); + + + public void stop() + { + isOldLocation = true; + shiftScreen(); + + stopTimer(); } - - public void restart() { - this.stop(); - this.startTimer(); + + public void restart() + { + stop(); + startTimer(); } - - private void shiftScreen() { - Platform.runLater(() -> { - if (this.isOldLocation) { - this.isOldLocation = false; - this.stage.setX(this.originalX + this.changeX); - this.stage.setY(this.originalY + this.changeY); + + private void shiftScreen() + { + Platform.runLater(()->{ + if(isOldLocation) + { + isOldLocation = false; + + stage.setX(originalX+changeX); + stage.setY(originalY+changeY); } - else { - this.isOldLocation = true; - this.stage.setX(this.originalX); - this.stage.setY(this.originalY); + else + { + isOldLocation = true; + + stage.setX(originalX); + stage.setY(originalY); } }); } - - public void setInterval(final int seconds) { + + public void setInterval(int seconds) + { this.interval = seconds; } - - private void stopTimer() { - if (this.timer != null) { - this.timer.cancel(); - this.timer.purge(); + + private void stopTimer() + { + if(timer != null) + { + timer.cancel(); + timer.purge(); } } - - private void startTimer() { - (this.timer = new Timer()).scheduleAtFixedRate(new TimerTask() { + + private void startTimer() + { + timer = new Timer(); + timer.scheduleAtFixedRate(new TimerTask() + { @Override - public void run() { - ScreenMover.this.shiftScreen(); + public void run() + { + shiftScreen(); } - }, this.interval, this.interval); + },interval, interval); } } diff --git a/src/main/java/com/stream_pi/client/controller/ScreenSaver.java b/src/main/java/com/stream_pi/client/controller/ScreenSaver.java index 6576f34b..28bac210 100644 --- a/src/main/java/com/stream_pi/client/controller/ScreenSaver.java +++ b/src/main/java/com/stream_pi/client/controller/ScreenSaver.java @@ -1,92 +1,124 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.controller; -import javafx.scene.input.MouseEvent; -import java.util.TimerTask; -import javafx.animation.Animation; +import com.stream_pi.client.window.Base; +import com.stream_pi.util.exception.SevereException; +import javafx.animation.*; import javafx.application.Platform; -import javafx.beans.value.WritableValue; -import javafx.animation.Interpolator; -import javafx.animation.KeyValue; +import javafx.concurrent.Task; +import javafx.scene.Node; +import javafx.scene.layout.StackPane; import javafx.util.Duration; -import javafx.animation.KeyFrame; -import com.stream_pi.client.window.Base; -import javafx.animation.Timeline; + import java.util.Timer; -import javafx.scene.layout.StackPane; +import java.util.TimerTask; public class ScreenSaver extends StackPane { private Timer timer; + private Timeline showScreenSaverTimeline; private long timeout; - - public ScreenSaver(final Base base, final int timeout) { - this.timeout = timeout * 1000L; - this.setOpacity(0.0); - this.getStyleClass().add((Object)"screensaver"); - (this.showScreenSaverTimeline = new Timeline()).setCycleCount(1); - this.showScreenSaverTimeline.getKeyFrames().addAll((Object[])new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.opacityProperty(), (Object)0.0, Interpolator.EASE_IN) }), new KeyFrame(Duration.seconds(15.0), new KeyValue[] { new KeyValue((WritableValue)this.opacityProperty(), (Object)1.0, Interpolator.LINEAR) }) }); - this.startTimer(); - base.setOnMouseClicked(mouseEvent -> this.restart()); + + public ScreenSaver(Base base, int timeout) + { + this.timeout = timeout* 1000L; + + setOpacity(0); + getStyleClass().add("screensaver"); + + + showScreenSaverTimeline = new Timeline(); + showScreenSaverTimeline.setCycleCount(1); + + + showScreenSaverTimeline.getKeyFrames().addAll( + new KeyFrame(Duration.millis(0.0D), + new KeyValue(opacityProperty(), + 0.0D, Interpolator.EASE_IN)), + new KeyFrame(Duration.seconds(15D), + new KeyValue(opacityProperty(), + 1.0D, Interpolator.LINEAR)) + ); + + startTimer(); + + base.setOnMouseClicked(mouseEvent -> { + restart(); + }); + } - - public void restart() { - this.close(); - this.restartTimer(); + + public void restart() + { + close(); + restartTimer(); } - - public void stop() { - this.stopTimer(); - this.setOpacity(0.0); - this.toBack(); + + + + public void stop() + { + stopTimer(); + setOpacity(0); + toBack(); } - - private void show() { - Platform.runLater(() -> { - this.setOpacity(0.0); - this.toFront(); - this.showScreenSaverTimeline.play(); + + + private void show() + { + Platform.runLater(()->{ + setOpacity(0); + toFront(); + showScreenSaverTimeline.play(); }); } - - private void close() { - Platform.runLater(() -> { - if (this.showScreenSaverTimeline.getStatus() == Animation.Status.RUNNING) { - this.showScreenSaverTimeline.stop(); + + private void close() + { + Platform.runLater(()->{ + if(showScreenSaverTimeline.getStatus() == Animation.Status.RUNNING) + { + showScreenSaverTimeline.stop(); } - this.setOpacity(0.0); - this.toBack(); - return; + + + setOpacity(0.0); + toBack(); }); - this.restartTimer(); + + restartTimer(); } - - public void setTimeout(final int seconds) { - this.timeout = seconds * 1000L; + + public void setTimeout(int seconds) + { + this.timeout = seconds* 1000L; } - - public void restartTimer() { - this.stopTimer(); - this.startTimer(); + + public void restartTimer() + { + stopTimer(); + startTimer(); } - - private void stopTimer() { - if (this.timer != null) { - this.timer.cancel(); - this.timer.purge(); + + private void stopTimer() + { + if(timer != null) + { + timer.cancel(); + timer.purge(); } } - - private void startTimer() { - (this.timer = new Timer()).schedule(new TimerTask() { + + private void startTimer() + { + timer = new Timer(); + timer.schedule(new TimerTask() + { @Override - public void run() { - ScreenSaver.this.show(); + public void run() + { + show(); } - }, this.timeout); + },timeout); } } diff --git a/src/main/java/com/stream_pi/client/info/ClientInfo.java b/src/main/java/com/stream_pi/client/info/ClientInfo.java index 199ace07..19b7d8e0 100644 --- a/src/main/java/com/stream_pi/client/info/ClientInfo.java +++ b/src/main/java/com/stream_pi/client/info/ClientInfo.java @@ -1,92 +1,121 @@ -// -// Decompiled by Procyon v0.6-prerelease -// +/* +ServerInfo.java + +Stores basic information about the server - name, platform type + +Contributors: Debayan Sutradhar (@dubbadhar) + */ package com.stream_pi.client.info; -import java.io.File; import com.gluonhq.attach.storage.StorageService; +import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.platform.Platform; import com.stream_pi.util.platform.ReleaseStatus; import com.stream_pi.util.version.Version; -public class ClientInfo -{ +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Optional; +import java.util.function.Function; + +public class ClientInfo { private Version version; private final ReleaseStatus releaseStatus; private Platform platform; + private String prePath; + private Version minThemeSupportVersion; private Version minPluginSupportVersion; private Version commStandardVersion; - private static ClientInfo instance; - - private ClientInfo() { - this.version = new Version(1, 0, 0); - this.minThemeSupportVersion = new Version(1, 0, 0); - this.minPluginSupportVersion = new Version(1, 0, 0); - this.commStandardVersion = new Version(1, 0, 0); - this.releaseStatus = ReleaseStatus.EA; - final String osName = System.getProperty("os.name").toLowerCase(); - this.prePath = System.getProperty("user.home") + "/Stream-Pi/Client/"; - if (osName.contains("windows")) { - this.platform = Platform.WINDOWS; + + private static ClientInfo instance = null; + + private ClientInfo() + { + version = new Version(1,0,0); + minThemeSupportVersion = new Version(1,0,0); + minPluginSupportVersion = new Version(1,0,0); + commStandardVersion = new Version(1,0,0); + + releaseStatus = ReleaseStatus.EA; + + String osName = System.getProperty("os.name").toLowerCase(); + + prePath = System.getProperty("user.home")+"/Stream-Pi/Client/"; + + if(osName.contains("windows")) + { + platform = Platform.WINDOWS; } - else if (osName.contains("linux")) { - this.platform = Platform.LINUX; + else if (osName.contains("linux")) + { + platform = Platform.LINUX; } - else if (osName.contains("android") || osName.contains("ios")) { - StorageService.create().ifPresent(s -> s.getPrivateStorage().ifPresentOrElse(sp -> this.prePath = sp.getAbsolutePath() + "/Stream-Pi/Client/", () -> this.prePath = null)); - this.platform = Platform.valueOf(osName.toUpperCase()); + else if(osName.contains("android") || osName.contains("ios")) + { + StorageService.create().ifPresent(s-> s.getPrivateStorage().ifPresentOrElse(sp-> prePath = sp.getAbsolutePath()+"/Stream-Pi/Client/", + ()-> prePath = null)); + + platform = Platform.valueOf(osName.toUpperCase()); } - else if (osName.contains("mac")) { - this.platform = Platform.MAC; + else if (osName.contains("mac")) + { + platform = Platform.MAC; } - else { - this.platform = Platform.UNKNOWN; + else + { + platform = Platform.UNKNOWN; } } - - public static synchronized ClientInfo getInstance() { - if (ClientInfo.instance == null) { - ClientInfo.instance = new ClientInfo(); + + public static synchronized ClientInfo getInstance(){ + if(instance == null) + { + instance = new ClientInfo(); } - return ClientInfo.instance; + + return instance; } - - public String getPrePath() { - return this.prePath; + + public String getPrePath() + { + return prePath; } - - public Platform getPlatform() { - return this.platform; + + public Platform getPlatform() + { + return platform; } - + public Version getVersion() { - return this.version; - } - - public ReleaseStatus getReleaseStatus() { - return this.releaseStatus; + return version; } - - public Version getMinThemeSupportVersion() { - return this.minThemeSupportVersion; + + public ReleaseStatus getReleaseStatus() + { + return releaseStatus; } - - public Version getMinPluginSupportVersion() { - return this.minPluginSupportVersion; + + public Version getMinThemeSupportVersion() + { + return minThemeSupportVersion; } - - public Version getCommStandardVersion() { - return this.commStandardVersion; + + public Version getMinPluginSupportVersion() + { + return minPluginSupportVersion; } - - public boolean isPhone() { - return this.getPlatform() == Platform.ANDROID || this.getPlatform() == Platform.IOS; + + public Version getCommStandardVersion() + { + return commStandardVersion; } - - static { - ClientInfo.instance = null; + + + public boolean isPhone() + { + return getPlatform() == Platform.ANDROID || getPlatform() == Platform.IOS; } } diff --git a/src/main/java/com/stream_pi/client/info/License.java b/src/main/java/com/stream_pi/client/info/License.java index ac83197c..71a8d9de 100644 --- a/src/main/java/com/stream_pi/client/info/License.java +++ b/src/main/java/com/stream_pi/client/info/License.java @@ -1,12 +1,43 @@ -// -// Decompiled by Procyon v0.6-prerelease -// +/* +Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macropad +Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones) + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Written by : Debayan Sutradhar (rnayabed) +*/ package com.stream_pi.client.info; -public class License -{ - public static String getLicense() { - return "Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad\nCopyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Qui\u00f1ones (SamuelQuinones)\n\nThis program is free software: you can redistribute it and/or modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\nGNU General Public License for more details.\n\n\nOpensource Libraries/Tech used :\n1. JavaFX - GNU General Public License with Classpath Exception\nhttp://openjdk.java.net/legal/gplv2+ce.html\n\n2. Gluon Attach - GPL License\nhttps://github.com/gluonhq/attach/blob/master/LICENSE\n\n3. Gluon Client Maven Plugin - BSD-3 License\nhttps://github.com/gluonhq/client-maven-plugin/blob/master/LICENSE\n\n4. Ikonli - Apache License\nhttps://github.com/kordamp/ikonli/blob/master/LICENSE\n\n5. Roboto Font - Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0\n\n6. ControlsFX - BSD 3-Clause License\nhttps://github.com/controlsfx/controlsfx/blob/jfx-13/license.txt\n\n"; +public class License { + public static String getLicense() + { + return "Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad\n" + + "Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)\n" + + "\n" + + "This program is free software: you can redistribute it and/or modify\n" + + "it under the terms of the GNU General Public License as published by\n" + + "the Free Software Foundation, either version 3 of the License, or\n" + + "(at your option) any later version.\n" + + "\n" + + "This program is distributed in the hope that it will be useful,\n" + + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + + "GNU General Public License for more details.\n" + + "\n\n"+ + "Opensource Libraries/Tech used :\n"+ + "1. JavaFX - GNU General Public License with Classpath Exception\nhttp://openjdk.java.net/legal/gplv2+ce.html\n\n"+ + "2. Gluon Attach - GPL License\nhttps://github.com/gluonhq/attach/blob/master/LICENSE\n\n"+ + "3. Gluon Client Maven Plugin - BSD-3 License\nhttps://github.com/gluonhq/client-maven-plugin/blob/master/LICENSE\n\n" + + "4. Ikonli - Apache License\nhttps://github.com/kordamp/ikonli/blob/master/LICENSE\n\n"+ + "5. Roboto Font - Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0\n\n"+ + "6. ControlsFX - BSD 3-Clause License\nhttps://github.com/controlsfx/controlsfx/blob/jfx-13/license.txt\n\n"; } } diff --git a/src/main/java/com/stream_pi/client/info/StartupFlags.java b/src/main/java/com/stream_pi/client/info/StartupFlags.java index f585a1aa..ff515f13 100644 --- a/src/main/java/com/stream_pi/client/info/StartupFlags.java +++ b/src/main/java/com/stream_pi/client/info/StartupFlags.java @@ -1,26 +1,12 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.info; public class StartupFlags { - public static String RUNNER_FILE_NAME; - public static boolean IS_SHOW_SHUT_DOWN_BUTTON; - public static boolean IS_X_MODE; - public static boolean SCREEN_SAVER_FEATURE; - public static boolean DEFAULT_FULLSCREEN_MODE; - public static boolean SHOW_FULLSCREEN_TOGGLE_BUTTON; - public static boolean APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION; - - static { - StartupFlags.RUNNER_FILE_NAME = null; - StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = false; - StartupFlags.IS_X_MODE = true; - StartupFlags.SCREEN_SAVER_FEATURE = false; - StartupFlags.DEFAULT_FULLSCREEN_MODE = false; - StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = true; - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = false; - } + public static String RUNNER_FILE_NAME = null; + public static boolean IS_SHOW_SHUT_DOWN_BUTTON = false; + public static boolean IS_X_MODE = true; + public static boolean SCREEN_SAVER_FEATURE= false; + public static boolean DEFAULT_FULLSCREEN_MODE=false; + public static boolean SHOW_FULLSCREEN_TOGGLE_BUTTON=true; + public static boolean APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = false; } diff --git a/src/main/java/com/stream_pi/client/io/Config.java b/src/main/java/com/stream_pi/client/io/Config.java index f5da207e..df04a419 100644 --- a/src/main/java/com/stream_pi/client/io/Config.java +++ b/src/main/java/com/stream_pi/client/io/Config.java @@ -1,420 +1,538 @@ -// -// Decompiled by Procyon v0.6-prerelease -// +/* +Config.java + +Contributor(s) : Debayan Sutradhar (@rnayabed) + +handler for config.xml + */ package com.stream_pi.client.io; -import org.w3c.dom.Element; -import com.stream_pi.util.platform.Platform; -import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; -import javax.xml.transform.Source; +import java.io.File; +import java.util.Objects; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.transform.Result; +import javax.xml.transform.Source; import javax.xml.transform.Transformer; -import org.w3c.dom.Node; +import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; -import javax.xml.transform.TransformerFactory; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.util.iohelper.IOHelper; -import java.util.Objects; + import com.stream_pi.client.Main; -import java.io.InputStream; -import javax.xml.parsers.DocumentBuilder; -import com.stream_pi.util.exception.SevereException; -import javax.xml.parsers.DocumentBuilderFactory; import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.iohelper.IOHelper; +import com.stream_pi.util.platform.Platform; +import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; + import org.w3c.dom.Document; -import java.io.File; +import org.w3c.dom.Element; public class Config { - private static Config instance; + private static Config instance = null; + private final File configFile; + private Document document; - - private Config() throws SevereException { - try { - this.configFile = new File(ClientInfo.getInstance().getPrePath() + "config.xml"); - final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - this.document = docBuilder.parse(this.configFile); + + private Config() throws SevereException + { + try + { + configFile = new File(ClientInfo.getInstance().getPrePath()+"config.xml"); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + document = docBuilder.parse(configFile); } - catch (Exception e) { + catch (Exception e) + { e.printStackTrace(); - throw new SevereException("Config", "unable to read config.xml\n" + e.getMessage()); + throw new SevereException("Config", "unable to read config.xml\n"+e.getMessage()); } } - - public static synchronized Config getInstance() throws SevereException { - if (Config.instance == null) { - Config.instance = new Config(); - } - return Config.instance; + + public static synchronized Config getInstance() throws SevereException + { + if(instance == null) + instance = new Config(); + + return instance; } - - public static void nullify() { - Config.instance = null; + + public static void nullify() + { + instance = null; } - - public static void unzipToDefaultPrePath() throws Exception { - IOHelper.unzip((InputStream)Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath()); - getInstance().setThemesPath(ClientInfo.getInstance().getPrePath() + "Themes/"); - getInstance().setIconsPath(ClientInfo.getInstance().getPrePath() + "Icons/"); - getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath() + "Profiles/"); - getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE); - getInstance().save(); + + public static void unzipToDefaultPrePath() throws Exception + { + IOHelper.unzip(Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath()); + Config.getInstance().setThemesPath(ClientInfo.getInstance().getPrePath()+"Themes/"); + Config.getInstance().setIconsPath(ClientInfo.getInstance().getPrePath()+"Icons/"); + Config.getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath()+"Profiles/"); + + Config.getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE); + + Config.getInstance().save(); } - - public void save() throws SevereException { - try { - final Transformer transformer = TransformerFactory.newInstance().newTransformer(); - final Result output = new StreamResult(this.configFile); - final Source input = new DOMSource(this.document); + + public void save() throws SevereException + { + try + { + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Result output = new StreamResult(configFile); + Source input = new DOMSource(document); + transformer.transform(input, output); } - catch (Exception e) { + catch (Exception e) + { throw new SevereException("Config", "unable to save config.xml"); } } + + + //Client Element - public String getDefaultClientNickName() { + //Default Values + public String getDefaultClientNickName() + { return "Stream-Pi Client"; } - - public String getDefaultStartupProfileID() { + + public String getDefaultStartupProfileID() + { return "default"; } - - public String getDefaultCurrentThemeFullName() { + + public String getDefaultCurrentThemeFullName() + { return "com.stream_pi.defaultlight"; } - - public String getDefaultCurrentAnimationName() { - return "None"; - } - - public String getDefaultThemesPath() { - return ClientInfo.getInstance().getPrePath() + "Themes/"; - } - - public String getDefaultProfilesPath() { - return ClientInfo.getInstance().getPrePath() + "Profiles/"; + + public String getDefaultThemesPath() + { + return ClientInfo.getInstance().getPrePath()+"Themes/"; } - - public String getDefaultIconsPath() { - return ClientInfo.getInstance().getPrePath() + "Icons/"; + + public String getDefaultProfilesPath() + { + return ClientInfo.getInstance().getPrePath()+"Profiles/"; } - - public String getClientNickName() { - return XMLConfigHelper.getStringProperty((Node)this.document, "nickname", this.getDefaultClientNickName(), false, true, this.document, this.configFile); + + public String getDefaultIconsPath() + { + return ClientInfo.getInstance().getPrePath()+"Icons/"; } - - public String getStartupProfileID() { - return XMLConfigHelper.getStringProperty((Node)this.document, "startup-profile", this.getDefaultStartupProfileID(), false, true, this.document, this.configFile); + + //Getters + + public String getClientNickName() + { + return XMLConfigHelper.getStringProperty(document, "nickname", getDefaultClientNickName(), false, true, document, configFile); } - - public String getCurrentThemeFullName() { - return XMLConfigHelper.getStringProperty((Node)this.document, "current-theme-full-name", this.getDefaultCurrentThemeFullName(), false, true, this.document, this.configFile); + + public String getStartupProfileID() + { + return XMLConfigHelper.getStringProperty(document, "startup-profile", getDefaultStartupProfileID(), false, true, document, configFile); } - - public String getCurrentAnimationName() { - return XMLConfigHelper.getStringProperty((Node)this.document, "current-animation-name", this.getDefaultCurrentAnimationName(), false, true, this.document, this.configFile); + + public String getCurrentThemeFullName() + { + return XMLConfigHelper.getStringProperty(document, "current-theme-full-name", getDefaultCurrentThemeFullName(), false, true, document, configFile); } - - public String getThemesPath() { - final Platform platform = ClientInfo.getInstance().getPlatform(); - if (platform != Platform.ANDROID && platform != Platform.IOS) { + + public String getThemesPath() + { + Platform platform = ClientInfo.getInstance().getPlatform(); + if(platform != Platform.ANDROID && + platform != Platform.IOS) return ClientInfo.getInstance().getPrePath() + "Themes/"; - } - return XMLConfigHelper.getStringProperty((Node)this.document, "themes-path", this.getDefaultThemesPath(), false, true, this.document, this.configFile); + + return XMLConfigHelper.getStringProperty(document, "themes-path", getDefaultThemesPath(), false, true, document, configFile); } - - public String getProfilesPath() { - final Platform platform = ClientInfo.getInstance().getPlatform(); - if (platform != Platform.ANDROID && platform != Platform.IOS) { + + public String getProfilesPath() + { + Platform platform = ClientInfo.getInstance().getPlatform(); + if(platform != Platform.ANDROID && + platform != Platform.IOS) return ClientInfo.getInstance().getPrePath() + "Profiles/"; - } - return XMLConfigHelper.getStringProperty((Node)this.document, "profiles-path", this.getDefaultProfilesPath(), false, true, this.document, this.configFile); + + return XMLConfigHelper.getStringProperty(document, "profiles-path", getDefaultProfilesPath(), false, true, document, configFile); } - - public String getIconsPath() { - final Platform platform = ClientInfo.getInstance().getPlatform(); - if (platform != Platform.ANDROID && platform != Platform.IOS) { + + public String getIconsPath() + { + Platform platform = ClientInfo.getInstance().getPlatform(); + if(platform != Platform.ANDROID && + platform != Platform.IOS) return ClientInfo.getInstance().getPrePath() + "Icons/"; - } - return XMLConfigHelper.getStringProperty((Node)this.document, "icons-path", this.getDefaultIconsPath(), false, true, this.document, this.configFile); - } - - public void setNickName(final String nickName) { - this.document.getElementsByTagName("nickname").item(0).setTextContent(nickName); + + return XMLConfigHelper.getStringProperty(document, "icons-path", getDefaultIconsPath(), false, true, document, configFile); } + - public void setStartupProfileID(final String id) { - this.document.getElementsByTagName("startup-profile").item(0).setTextContent(id); + + //Setters + + public void setNickName(String nickName) + { + document.getElementsByTagName("nickname").item(0).setTextContent(nickName); } - - public void setCurrentThemeFullName(final String name) { - this.document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); + + public void setStartupProfileID(String id) + { + document.getElementsByTagName("startup-profile").item(0).setTextContent(id); } - - public void setCurrentAnimationFullName(final String name) { - this.document.getElementsByTagName("current-animation-name").item(0).setTextContent(name); + + public void setCurrentThemeFullName(String name) + { + document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); } - - public void setProfilesPath(final String profilesPath) { - this.document.getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath); + + public void setProfilesPath(String profilesPath) + { + document.getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath); } - - public void setIconsPath(final String iconsPath) { - this.document.getElementsByTagName("icons-path").item(0).setTextContent(iconsPath); + + public void setIconsPath(String iconsPath) + { + document.getElementsByTagName("icons-path").item(0).setTextContent(iconsPath); } - - public void setThemesPath(final String themesPath) { - this.document.getElementsByTagName("themes-path").item(0).setTextContent(themesPath); + + public void setThemesPath(String themesPath) + { + document.getElementsByTagName("themes-path").item(0).setTextContent(themesPath); } - - public Element getCommsServerElement() { - return (Element)this.document.getElementsByTagName("comms-server").item(0); + + + //comms-server + public Element getCommsServerElement() + { + return (Element) document.getElementsByTagName("comms-server").item(0); } - - public String getDefaultSavedServerHostNameOrIP() { + + public String getDefaultSavedServerHostNameOrIP() + { return "127.0.0.1"; } - - public int getDefaultSavedServerPort() { + + public int getDefaultSavedServerPort() + { return -1; } - - public String getSavedServerHostNameOrIP() { - return XMLConfigHelper.getStringProperty((Node)this.getCommsServerElement(), "hostname-ip", this.getDefaultSavedServerHostNameOrIP(), false, true, this.document, this.configFile); + + + public String getSavedServerHostNameOrIP() + { + return XMLConfigHelper.getStringProperty(getCommsServerElement(), "hostname-ip", getDefaultSavedServerHostNameOrIP(), false, true, document, configFile); } - - public int getSavedServerPort() { - return XMLConfigHelper.getIntProperty((Node)this.getCommsServerElement(), "port", this.getDefaultSavedServerPort(), false, true, this.document, this.configFile); + + public int getSavedServerPort() + { + return XMLConfigHelper.getIntProperty(getCommsServerElement(), "port", getDefaultSavedServerPort(), false, true, document, configFile); } - - public void setServerHostNameOrIP(final String hostNameOrIP) { - this.getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP); + + public void setServerHostNameOrIP(String hostNameOrIP) + { + getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP); } - - public void setServerPort(final int port) { - this.getCommsServerElement().getElementsByTagName("port").item(0).setTextContent("" + port); + + public void setServerPort(int port) + { + getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(port+""); } - - public Element getScreenMoverElement() { - return (Element)this.document.getElementsByTagName("screen-mover").item(0); + + + + + + //screen-mover + public Element getScreenMoverElement() + { + return (Element) document.getElementsByTagName("screen-mover").item(0); } - - public Element getOthersElement() { - return (Element)this.document.getElementsByTagName("others").item(0); + + + //others + public Element getOthersElement() + { + return (Element) document.getElementsByTagName("others").item(0); } - - public boolean getDefaultStartOnBoot() { + + //others-default + + public boolean getDefaultStartOnBoot() + { return false; } - - public boolean getDefaultIsShowCursor() { + + public boolean getDefaultIsShowCursor() + { return true; } - - public boolean getDefaultFirstTimeUse() { + + public boolean getDefaultFirstTimeUse() + { return true; } + + - public boolean isShowCursor() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "show-cursor", this.getDefaultIsShowCursor(), false, true, this.document, this.configFile); + public boolean isShowCursor() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "show-cursor", getDefaultIsShowCursor(), false, true, document, configFile); } + - public boolean isStartOnBoot() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "start-on-boot", this.getDefaultStartOnBoot(), false, true, this.document, this.configFile); + public boolean isStartOnBoot() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot", getDefaultStartOnBoot(), false, true, document, configFile); } + - public boolean isFirstTimeUse() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "first-time-use", true, false, true, this.document, this.configFile); + public boolean isFirstTimeUse() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile); } - - public boolean isVibrateOnActionClicked() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "vibrate-on-action-clicked", false, false, true, this.document, this.configFile); + + public boolean isVibrateOnActionClicked() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "vibrate-on-action-clicked", false, false, true, document, configFile); } - - public boolean isConnectOnStartup() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "connect-on-startup", false, false, true, this.document, this.configFile); + + public boolean isConnectOnStartup() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "connect-on-startup", false, false, true, document, configFile); } - - public boolean getIsFullScreenMode() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "full-screen-mode", false, false, true, this.document, this.configFile); + + public boolean getIsFullScreenMode() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "full-screen-mode", false, false, true, document, configFile); } - - public void setStartOnBoot(final boolean value) { - this.getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent("" + value); + + + public void setStartOnBoot(boolean value) + { + getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+""); } - - public void setShowCursor(final boolean value) { - this.getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent("" + value); + + public void setShowCursor(boolean value) + { + getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(value+""); } - - public void setFullscreen(final boolean value) { - this.getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent("" + value); + + public void setFullscreen(boolean value) + { + getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(value+""); } - - public void setFirstTimeUse(final boolean value) { - this.getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent("" + value); + + public void setFirstTimeUse(boolean value) + { + getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+""); } - - public void setVibrateOnActionClicked(final boolean value) { - this.getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent("" + value); + + public void setVibrateOnActionClicked(boolean value) + { + getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(value+""); } - - public void setConnectOnStartup(final boolean value) { - this.getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent("" + value); + + public void setConnectOnStartup(boolean value) + { + getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(value+""); } - - public void setIsFullScreenMode(final boolean value) { - this.getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent("" + value); + + public void setIsFullScreenMode(boolean value) + { + getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(value+""); } - - private Element getStartupWindowSizeElement() { - return (Element)this.document.getElementsByTagName("startup-window-size").item(0); + + + + private Element getStartupWindowSizeElement() + { + return (Element) document.getElementsByTagName("startup-window-size").item(0); } - - public double getStartupWindowWidth() { - return XMLConfigHelper.getDoubleProperty((Node)this.getStartupWindowSizeElement(), "width", (double)this.getDefaultStartupWindowWidth(), false, true, this.document, this.configFile); + + public double getStartupWindowWidth() + { + return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width", + getDefaultStartupWindowWidth(), false, true, document, configFile); } - - public double getStartupWindowHeight() { - return XMLConfigHelper.getDoubleProperty((Node)this.getStartupWindowSizeElement(), "height", (double)this.getDefaultStartupWindowHeight(), false, true, this.document, this.configFile); + + public double getStartupWindowHeight() + { + return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height", + getDefaultStartupWindowHeight(), false, true, document, configFile); } - - public int getDefaultStartupWindowWidth() { + + + public int getDefaultStartupWindowWidth() + { return 800; } - - public int getDefaultStartupWindowHeight() { + + public int getDefaultStartupWindowHeight() + { return 400; } - - public void setStartupWindowSize(final double width, final double height) { - this.setStartupWindowWidth(width); - this.setStartupWindowHeight(height); + + public void setStartupWindowSize(double width, double height) + { + setStartupWindowWidth(width); + setStartupWindowHeight(height); } - - public void setStartupWindowWidth(final double width) { - this.getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent("" + width); + + public void setStartupWindowWidth(double width) + { + getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+""); } - - public void setStartupWindowHeight(final double height) { - this.getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent("" + height); + + public void setStartupWindowHeight(double height) + { + getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+""); } - - public void setStartupIsXMode(final boolean value) { - this.getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent("" + value); + + public void setStartupIsXMode(boolean value) + { + getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(value+""); } - - public boolean getDefaultIsStartupXMode() { + + public boolean getDefaultIsStartupXMode() + { return false; } - - public boolean isStartupXMode() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "start-on-boot-x-mode", this.getDefaultIsStartupXMode(), false, true, this.document, this.configFile); + + public boolean isStartupXMode() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot-x-mode", getDefaultIsStartupXMode(), false, true, document, configFile); } - - public boolean getDefaultIsTryConnectingWhenActionClicked() { + + + public boolean getDefaultIsTryConnectingWhenActionClicked() + { return false; } - - public boolean isTryConnectingWhenActionClicked() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "try-connecting-when-action-clicked", this.getDefaultIsTryConnectingWhenActionClicked(), false, true, this.document, this.configFile); + + public boolean isTryConnectingWhenActionClicked() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "try-connecting-when-action-clicked", getDefaultIsTryConnectingWhenActionClicked(), false, true, document, configFile); } - - public void setTryConnectingWhenActionClicked(final boolean value) { - this.getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent("" + value); + + public void setTryConnectingWhenActionClicked(boolean value) + { + getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(value+""); } - - public boolean getDefaultScreenSaverEnabled() { + + + public boolean getDefaultScreenSaverEnabled() + { return false; } - - public boolean isScreenSaverEnabled() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "screen-saver", this.getDefaultScreenSaverEnabled(), false, true, this.document, this.configFile); + + public boolean isScreenSaverEnabled() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "screen-saver", getDefaultScreenSaverEnabled(), false, true, document, configFile); } - - public void setScreenSaverEnabled(final boolean value) { - this.getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent("" + value); + + public void setScreenSaverEnabled(boolean value) + { + getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(value+""); } - - public int getDefaultScreenSaverTimeout() { + + public int getDefaultScreenSaverTimeout() + { return 60; } - - public int getScreenSaverTimeout() { - return XMLConfigHelper.getIntProperty((Node)this.getOthersElement(), "screen-saver-timeout-seconds", this.getDefaultScreenSaverTimeout(), false, true, this.document, this.configFile); + + public int getScreenSaverTimeout() + { + return XMLConfigHelper.getIntProperty(getOthersElement(), "screen-saver-timeout-seconds", getDefaultScreenSaverTimeout(), false, true, document, configFile); } - - public void setScreenSaverTimeout(final String value) { - this.getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value); + + public void setScreenSaverTimeout(String value) + { + getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value); } - - public int getDefaultScreenMoverInterval() { + + public int getDefaultScreenMoverInterval() + { return 120000; } - - public int getScreenMoverInterval() { - return XMLConfigHelper.getIntProperty((Node)this.getScreenMoverElement(), "interval", this.getDefaultScreenMoverInterval(), false, true, this.document, this.configFile); + + public int getScreenMoverInterval() + { + return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "interval", getDefaultScreenMoverInterval(), false, true, document, configFile); } - - public void setScreenMoverInterval(final String value) { - this.getScreenMoverElement().getElementsByTagName("interval").item(0).setTextContent(value); + + public void setScreenMoverInterval(String value) + { + getScreenMoverElement().getElementsByTagName("interval").item(0).setTextContent(value); } - - public int getDefaultScreenMoverXChange() { + + public int getDefaultScreenMoverXChange() + { return 5; } - - public int getScreenMoverXChange() { - return XMLConfigHelper.getIntProperty((Node)this.getScreenMoverElement(), "x-change", this.getDefaultScreenMoverXChange(), false, true, this.document, this.configFile); + + public int getScreenMoverXChange() + { + return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "x-change", getDefaultScreenMoverXChange(), false, true, document, configFile); } - - public void setScreenMoverXChange(final String value) { - this.getScreenMoverElement().getElementsByTagName("x-change").item(0).setTextContent(value); + + public void setScreenMoverXChange(String value) + { + getScreenMoverElement().getElementsByTagName("x-change").item(0).setTextContent(value); } - - public int getDefaultScreenMoverYChange() { + + public int getDefaultScreenMoverYChange() + { return 5; } - - public int getScreenMoverYChange() { - return XMLConfigHelper.getIntProperty((Node)this.getScreenMoverElement(), "y-change", this.getDefaultScreenMoverYChange(), false, true, this.document, this.configFile); + + public int getScreenMoverYChange() + { + return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "y-change", getDefaultScreenMoverYChange(), false, true, document, configFile); } - - public void setScreenMoverYChange(final String value) { - this.getScreenMoverElement().getElementsByTagName("y-change").item(0).setTextContent(value); + + public void setScreenMoverYChange(String value) + { + getScreenMoverElement().getElementsByTagName("y-change").item(0).setTextContent(value); } - - public boolean getDefaultScreenMoverEnabled() { + + public boolean getDefaultScreenMoverEnabled() + { return false; } - - public boolean isScreenMoverEnabled() { - return XMLConfigHelper.getBooleanProperty((Node)this.getScreenMoverElement(), "status", this.getDefaultScreenMoverEnabled(), false, true, this.document, this.configFile); + + public boolean isScreenMoverEnabled() + { + return XMLConfigHelper.getBooleanProperty(getScreenMoverElement(), "status", getDefaultScreenMoverEnabled(), false, true, document, configFile); } - - public void setScreenMoverEnabled(final boolean value) { - this.getScreenMoverElement().getElementsByTagName("status").item(0).setTextContent("" + value); + + public void setScreenMoverEnabled(boolean value) + { + getScreenMoverElement().getElementsByTagName("status").item(0).setTextContent(value+""); } - - public boolean getDefaultInvertRowsColsOnDeviceRotate() { + + public boolean getDefaultInvertRowsColsOnDeviceRotate() + { return true; } - - public boolean isInvertRowsColsOnDeviceRotate() { - return XMLConfigHelper.getBooleanProperty((Node)this.getOthersElement(), "invert-rows-cols-on-device-rotate", this.getDefaultInvertRowsColsOnDeviceRotate(), false, true, this.document, this.configFile); - } - - public void setInvertRowsColsOnDeviceRotate(final boolean value) { - this.getOthersElement().getElementsByTagName("invert-rows-cols-on-device-rotate").item(0).setTextContent("" + value); + + public boolean isInvertRowsColsOnDeviceRotate() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "invert-rows-cols-on-device-rotate", getDefaultInvertRowsColsOnDeviceRotate(), false, true, document, configFile); } - - static { - Config.instance = null; + + public void setInvertRowsColsOnDeviceRotate(boolean value) + { + getOthersElement().getElementsByTagName("invert-rows-cols-on-device-rotate").item(0).setTextContent(value+""); } } diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfile.java b/src/main/java/com/stream_pi/client/profile/ClientProfile.java index 6a93c815..5764146b 100644 --- a/src/main/java/com/stream_pi/client/profile/ClientProfile.java +++ b/src/main/java/com/stream_pi/client/profile/ClientProfile.java @@ -1,507 +1,758 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.profile; -import java.util.ArrayList; -import javax.xml.transform.TransformerException; -import java.io.OutputStream; +import java.io.File; import java.io.FileOutputStream; -import java.util.Iterator; -import javax.xml.transform.Transformer; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.stream.StreamResult; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.logging.Logger; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.*; import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.TransformerFactory; -import org.w3c.dom.NodeList; +import javax.xml.transform.stream.StreamResult; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; import com.stream_pi.action_api.action.DisplayTextAlignment; -import java.nio.file.Files; import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.actionproperty.ClientProperties; import com.stream_pi.action_api.actionproperty.property.Property; import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.version.Version; -import com.stream_pi.action_api.actionproperty.ClientProperties; -import com.stream_pi.action_api.action.ActionType; -import org.w3c.dom.Node; import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; -import org.w3c.dom.Element; -import javax.xml.parsers.DocumentBuilder; -import com.stream_pi.util.exception.MinorException; -import javax.xml.parsers.DocumentBuilderFactory; + import org.w3c.dom.Document; -import java.util.logging.Logger; -import java.io.File; -import com.stream_pi.action_api.action.Action; -import java.util.HashMap; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class ClientProfile implements Cloneable{ + private String name, ID; -public class ClientProfile implements Cloneable -{ - private String name; - private String ID; - private int rows; - private int cols; - private int actionSize; - private int actionGap; + private int rows, cols, actionSize, actionGap; + + private HashMap actions; private String iconsPath; + private File file; + private Logger logger; private Document document; - - public ClientProfile(final File file, final String iconsPath) throws MinorException { + + public ClientProfile(File file, String iconsPath) throws MinorException + { this.file = file; this.iconsPath = iconsPath; - this.actions = new HashMap(); - this.logger = Logger.getLogger(ClientProfile.class.getName()); - if (!file.exists() && !file.isFile()) { - this.createConfigFile(file); - } - try { - final DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - final DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - this.document = docBuilder.parse(file); + + actions = new HashMap<>(); + + logger = Logger.getLogger(ClientProfile.class.getName()); + + if(!file.exists() && !file.isFile()) + createConfigFile(file); + + try + { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + document = docBuilder.parse(file); } - catch (Exception e) { + catch (Exception e) + { e.printStackTrace(); throw new MinorException("profile", "Unable to read profile config file."); } - this.setID(file.getName().replace(".xml", "")); - this.load(); + + + setID(file.getName().replace(".xml", "")); + load(); } - - private Element getProfileElement() { - return (Element)this.document.getElementsByTagName("profile").item(0); + + + private Element getProfileElement() + { + return (Element) document.getElementsByTagName("profile").item(0); } - - private Element getActionsElement() { - return (Element)this.document.getElementsByTagName("actions").item(0); + + private Element getActionsElement() + { + return (Element) document.getElementsByTagName("actions").item(0); } + + public void load() throws MinorException + { + try + { + actions.clear(); + + logger.info("Loading profile "+getID()+" ..."); + + String name = XMLConfigHelper.getStringProperty(getProfileElement(), "name"); + int rows = XMLConfigHelper.getIntProperty(getProfileElement(), "rows"); + int cols = XMLConfigHelper.getIntProperty(getProfileElement(), "cols"); + int actionSize = XMLConfigHelper.getIntProperty(getProfileElement(), "action-size"); + int actionGap = XMLConfigHelper.getIntProperty(getProfileElement(), "action-gap"); + + setName(name); + setRows(rows); + setCols(cols); + setActionSize(actionSize); + setActionGap(actionGap); + + + //Load Actions + + NodeList actionsNodesList = getActionsElement().getChildNodes(); + + int actionsSize = actionsNodesList.getLength(); + + logger.info("Actions Size : "+actionsSize); + + for(int item = 0; item -1) { - final Element actionElement = (Element)this.getActionsElement().getElementsByTagName("action").item(index); - final Element displayElement = (Element)actionElement.getElementsByTagName("display").item(0); - final Element backgroundElement = (Element)displayElement.getElementsByTagName("background").item(0); - final Element iconElement = (Element)backgroundElement.getElementsByTagName("icon").item(0); - final Element statesElements = (Element)iconElement.getElementsByTagName("states").item(0); - final NodeList statesNodeList = statesElements.getChildNodes(); - for (int i = 0; i < statesNodeList.getLength(); ++i) { - final Node eachStateNode = statesNodeList.item(i); - if (eachStateNode.getNodeType() == 1) { - final Element eachIconStateElement = (Element)eachStateNode; - if (eachIconStateElement.getNodeName().equals("state")) { - final String state = eachIconStateElement.getTextContent(); - new File(this.iconsPath + "/" + ID + "___" + state).delete(); - } - } + + + + public void removeAction(String ID) throws Exception { + int index = getActionIndexInConfig(ID); + + if(index>-1) + { + + Element actionElement = (Element) getActionsElement().getElementsByTagName("action").item(index); + + Element displayElement = (Element) actionElement.getElementsByTagName("display").item(0); + Element backgroundElement = (Element) displayElement.getElementsByTagName("background").item(0); + Element iconElement = (Element) backgroundElement.getElementsByTagName("icon").item(0); + + Element statesElements = (Element) iconElement.getElementsByTagName("states").item(0); + + NodeList statesNodeList = statesElements.getChildNodes(); + + for (int i = 0;i getActions() { - final ArrayList p = new ArrayList(); - for (final String profile : this.actions.keySet()) { - p.add(this.actions.get(profile)); - } + + public ArrayList getActions() + { + ArrayList p = new ArrayList<>(); + for(String profile : actions.keySet()) + p.add(actions.get(profile)); return p; } - - public String getID() { - return this.ID; + + public String getID() + { + return ID; } - - public String getName() { - return this.name; + + public String getName() + { + return name; } - - public int getRows() { - return this.rows; + + public int getRows() + { + return rows; } - - public int getCols() { - return this.cols; + + public int getCols() + { + return cols; } - - public int getActionSize() { - return this.actionSize; + + public int getActionSize() + { + return actionSize; } - - public Action getActionFromID(final String ID) { - return this.actions.getOrDefault(ID, null); + + public Action getActionFromID(String ID) + { + return actions.getOrDefault(ID, null); } - - public int getActionGap() { - return this.actionGap; + + public int getActionGap() + { + return actionGap; } - - public void setRows(final int rows) { + + public void setRows(int rows) + { this.rows = rows; } - - public void setCols(final int cols) { + + public void setCols(int cols) + { this.cols = cols; } - - public void setID(final String ID) { + + public void setID(String ID) + { this.ID = ID; } - - public void setActionSize(final int actionSize) { + + public void setActionSize(int actionSize) + { this.actionSize = actionSize; } - - public void setActionGap(final int actionGap) { + + public void setActionGap(int actionGap) + { this.actionGap = actionGap; } - - public void setName(final String name) { + + public void setName(String name) + { this.name = name; } - public Object clone() throws CloneNotSupportedException { + + public Object clone() throws CloneNotSupportedException + { return super.clone(); } } diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfiles.java b/src/main/java/com/stream_pi/client/profile/ClientProfiles.java index 28229c08..8e4572b8 100644 --- a/src/main/java/com/stream_pi/client/profile/ClientProfiles.java +++ b/src/main/java/com/stream_pi/client/profile/ClientProfiles.java @@ -1,93 +1,119 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.profile; -import java.util.Iterator; import com.stream_pi.client.io.Config; -import com.stream_pi.util.exception.SevereException; -import java.util.HashMap; import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; + +import java.io.File; import java.util.ArrayList; +import java.util.HashMap; import java.util.logging.Logger; -import java.io.File; -public class ClientProfiles -{ +public class ClientProfiles { + + private File profilesFolder; private String defaultProfileID; + private Logger logger; - private ArrayList loadingErrors; - private HashMap clientProfiles; - - public ClientProfiles(final File profilesFolder, final String defaultProfileID) throws SevereException { - this.logger = Logger.getLogger(ClientProfiles.class.getName()); + + public ClientProfiles(File profilesFolder, String defaultProfileID) throws SevereException + { + logger = Logger.getLogger(ClientProfiles.class.getName()); + this.defaultProfileID = defaultProfileID; this.profilesFolder = profilesFolder; - this.clientProfiles = new HashMap(); - this.loadingErrors = new ArrayList(); - this.loadProfiles(); + clientProfiles = new HashMap<>(); + loadingErrors = new ArrayList<>(); + + loadProfiles(); } - - public void addProfile(final ClientProfile clientProfile) throws CloneNotSupportedException { - this.clientProfiles.put(clientProfile.getID(), (ClientProfile)clientProfile.clone()); + + public void addProfile(ClientProfile clientProfile) throws CloneNotSupportedException { + clientProfiles.put(clientProfile.getID(), (ClientProfile) clientProfile.clone()); } - - public void deleteProfile(final ClientProfile clientProfile) { - this.clientProfiles.remove(clientProfile.getID()); + + public void deleteProfile(ClientProfile clientProfile) + { + clientProfiles.remove(clientProfile.getID()); + clientProfile.deleteProfile(); } - - public void loadProfiles() throws SevereException { - this.logger.info("Loading profiles ..."); - final String iconsPath = Config.getInstance().getIconsPath(); - this.clientProfiles.clear(); - this.loadingErrors.clear(); - if (!this.profilesFolder.isDirectory()) { - throw new SevereException("Profiles", "Profile folder doesn't exist! Cant continue."); + + private ArrayList loadingErrors; + private HashMap clientProfiles; + + public void loadProfiles() throws SevereException + { + logger.info("Loading profiles ..."); + + + String iconsPath = Config.getInstance().getIconsPath(); + + clientProfiles.clear(); + loadingErrors.clear(); + + if(!profilesFolder.isDirectory()) + { + throw new SevereException("Profiles","Profile folder doesn't exist! Cant continue."); } - final File[] profilesFiles = this.profilesFolder.listFiles(); - if (profilesFiles == null) { - throw new SevereException("Profiles", "profilesFiles returned null. Cant continue!"); + + + File[] profilesFiles = profilesFolder.listFiles(); + if(profilesFiles == null) + { + throw new SevereException("Profiles","profilesFiles returned null. Cant continue!"); } - final File[] array = profilesFiles; - for (int length = array.length, i = 0; i < length; ++i) { - final File eachProfileFile = array[i]; - try { - final ClientProfile profile = new ClientProfile(eachProfileFile, iconsPath); - try { - this.addProfile(profile); + + for(File eachProfileFile : profilesFiles) + { + try + { + ClientProfile profile = new ClientProfile(eachProfileFile, iconsPath); + try + { + addProfile(profile); } - catch (CloneNotSupportedException e) { + catch (CloneNotSupportedException e) + { e.printStackTrace(); throw new SevereException(e.getMessage()); } } - catch (MinorException e2) { - if (eachProfileFile.getName().replace(".xml", "").equals(this.defaultProfileID)) { + catch (MinorException e) + { + if(eachProfileFile.getName().replace(".xml","").equals(defaultProfileID)) + { throw new SevereException("Profiles", "Default profile bad. Can't continue"); } - this.loadingErrors.add(new MinorException(e2.getMessage() + " (" + eachProfileFile.getName().replace(".xml", ""))); - e2.printStackTrace(); + + loadingErrors.add(new MinorException(e.getMessage()+" ("+eachProfileFile.getName().replace(".xml", ""))); + + e.printStackTrace(); } } - this.logger.info("Loaded all profiles!"); + + logger.info("Loaded all profiles!"); } - - public ArrayList getLoadingErrors() { - return this.loadingErrors; + + public ArrayList getLoadingErrors() + { + return loadingErrors; } - - public ArrayList getClientProfiles() { - final ArrayList p = new ArrayList(); - for (final String profile : this.clientProfiles.keySet()) { - p.add(this.clientProfiles.get(profile)); - } + + public ArrayList getClientProfiles() + { + ArrayList p = new ArrayList<>(); + for(String profile : clientProfiles.keySet()) + p.add(clientProfiles.get(profile)); return p; } - public ClientProfile getProfileFromID(final String profileID) { - return this.clientProfiles.getOrDefault(profileID, null); + public ClientProfile getProfileFromID(String profileID) + { + return clientProfiles.getOrDefault(profileID, null); } + + + } diff --git a/src/main/java/com/stream_pi/client/window/Base.java b/src/main/java/com/stream_pi/client/window/Base.java index 9961e4ad..db32b98e 100644 --- a/src/main/java/com/stream_pi/client/window/Base.java +++ b/src/main/java/com/stream_pi/client/window/Base.java @@ -1,386 +1,530 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window; -import com.stream_pi.util.exception.MinorException; -import java.util.Iterator; -import java.util.Collection; -import javafx.scene.text.Font; -import com.stream_pi.util.platform.Platform; -import javafx.scene.Cursor; -import javafx.scene.input.KeyCombination; -import javafx.stage.Screen; -import com.stream_pi.util.exception.SevereException; -import javafx.scene.Node; -import com.stream_pi.util.combobox.StreamPiComboBox; -import com.stream_pi.util.alert.StreamPiAlert; -import javafx.geometry.Insets; -import javafx.scene.CacheHint; -import javafx.beans.value.ObservableValue; -import javafx.scene.image.Image; -import java.util.Objects; -import com.stream_pi.client.Main; -import java.io.InputStream; -import java.util.logging.Handler; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.controller.ScreenSaver; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; + import java.io.File; +import java.nio.file.Paths; +import java.util.Objects; +import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; -import com.stream_pi.theme_api.Themes; -import com.stream_pi.theme_api.Theme; -import javafx.application.HostServices; -import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler; -import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler; import java.util.logging.Logger; + +import com.stream_pi.client.Main; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.profile.ClientProfiles; +import com.stream_pi.client.window.dashboard.DashboardBase; import com.stream_pi.client.window.firsttimeuse.FirstTimeUse; import com.stream_pi.client.window.settings.SettingsBase; -import com.stream_pi.client.window.dashboard.DashboardBase; -import javafx.stage.Stage; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.profile.ClientProfiles; -import com.stream_pi.client.io.Config; -import java.util.concurrent.ExecutorService; -import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.theme_api.Themes; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.combobox.StreamPiComboBox; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler; +import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler; +import com.stream_pi.util.platform.Platform; + +import javafx.application.HostServices; +import javafx.geometry.Insets; +import javafx.scene.CacheHint; +import javafx.scene.Cursor; +import javafx.scene.image.Image; +import javafx.scene.input.KeyCombination; import javafx.scene.layout.StackPane; +import javafx.scene.text.Font; +import javafx.stage.Screen; +import javafx.stage.Stage; public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ClientListener { - private final ExecutorService executor; + private final ExecutorService executor = Executors.newCachedThreadPool(); + private Config config; + private ClientProfiles clientProfiles; + private ClientInfo clientInfo; + private Stage stage; + + public Stage getStage() + { + return stage; + } + + public Logger getLogger() + { + return logger; + } + private DashboardBase dashboardBase; private SettingsBase settingsBase; + private FirstTimeUse firstTimeUse; + + private StackPane alertStackPane; - private Logger logger; - private StreamPiLogFileHandler logFileHandler; - private StreamPiLogFallbackHandler logFallbackHandler; - private HostServices hostServices; - private Theme currentTheme; - Themes themes; - - public Base() { - this.executor = Executors.newCachedThreadPool(); - this.logger = null; - this.logFileHandler = null; - this.logFallbackHandler = null; - } - - public Stage getStage() { - return this.stage; - } - - public Logger getLogger() { - return this.logger; - } - + + @Override public ClientProfiles getClientProfiles() { - return this.clientProfiles; + return clientProfiles; } - - public void setClientProfiles(final ClientProfiles clientProfiles) { + + public void setClientProfiles(ClientProfiles clientProfiles) { this.clientProfiles = clientProfiles; } - - public void initLogger() { - try { - if (this.logFileHandler != null) { + + private Logger logger = null; + private StreamPiLogFileHandler logFileHandler = null; + private StreamPiLogFallbackHandler logFallbackHandler = null; + + @Override + public void initLogger() + { + try + { + if(logFileHandler != null) return; + + closeLogger(); + logger = Logger.getLogger("com.stream_pi"); + + if(new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite()) + { + String path = ClientInfo.getInstance().getPrePath()+"../stream-pi-client.log"; + + if(getClientInfo().isPhone()) + path = ClientInfo.getInstance().getPrePath()+"stream-pi-client.log"; + + logFileHandler = new StreamPiLogFileHandler(path); + logger.addHandler(logFileHandler); } - this.closeLogger(); - this.logger = Logger.getLogger("com.stream_pi"); - if (new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite()) { - String path = ClientInfo.getInstance().getPrePath() + "../stream-pi-client.log"; - if (this.getClientInfo().isPhone()) { - path = ClientInfo.getInstance().getPrePath() + "stream-pi-client.log"; - } - this.logFileHandler = new StreamPiLogFileHandler(path); - this.logger.addHandler((Handler)this.logFileHandler); - } - else { - this.logFallbackHandler = new StreamPiLogFallbackHandler(); - this.logger.addHandler((Handler)this.logFallbackHandler); + else + { + logFallbackHandler = new StreamPiLogFallbackHandler(); + logger.addHandler(logFallbackHandler); } + } - catch (Exception e) { + catch(Exception e) + { e.printStackTrace(); - this.logFallbackHandler = new StreamPiLogFallbackHandler(); - this.logger.addHandler((Handler)this.logFallbackHandler); + + logFallbackHandler = new StreamPiLogFallbackHandler(); + logger.addHandler(logFallbackHandler); } } - public void closeLogger() { - if (this.logFileHandler != null) { - this.logFileHandler.close(); - } - else if (this.logFallbackHandler != null) { - this.logFallbackHandler.close(); - } + public void closeLogger() + { + if(logFileHandler != null) + logFileHandler.close(); + else if(logFallbackHandler != null) + logFallbackHandler.close(); } - - public void setHostServices(final HostServices hostServices) { + + private HostServices hostServices; + + public void setHostServices(HostServices hostServices) + { this.hostServices = hostServices; } - - public HostServices getHostServices() { - return this.hostServices; + + public HostServices getHostServices() + { + return hostServices; } - - public void initBase() throws SevereException { - this.stage = (Stage)this.getScene().getWindow(); - this.getStage().getIcons().add((Object)new Image((InputStream)Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png")))); - this.clientInfo = ClientInfo.getInstance(); - this.dashboardBase = new DashboardBase(this, this); - this.dashboardBase.prefWidthProperty().bind((ObservableValue)this.widthProperty()); - this.dashboardBase.prefHeightProperty().bind((ObservableValue)this.heightProperty()); - this.settingsBase = new SettingsBase(this.getHostServices(), this, this); - (this.alertStackPane = new StackPane()).setCache(true); - this.alertStackPane.setCacheHint(CacheHint.SPEED); - this.alertStackPane.setPadding(new Insets(10.0)); - this.alertStackPane.setOpacity(0.0); - StreamPiAlert.setParent(this.alertStackPane); - StreamPiComboBox.setParent(this.alertStackPane); - this.getChildren().clear(); - this.getChildren().addAll((Object[])new Node[] { (Node)this.alertStackPane }); - if (this.getClientInfo().isPhone()) { - this.dashboardBase.setPadding(new Insets(10.0)); - this.settingsBase.setPadding(new Insets(10.0)); + + public void initBase() throws SevereException + { + stage = (Stage) getScene().getWindow(); + + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon256x256.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon48x48.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon32x32.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon24x24.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon16x16.png")))); + + clientInfo = ClientInfo.getInstance(); + dashboardBase = new DashboardBase(this, this); + dashboardBase.prefWidthProperty().bind(widthProperty()); + dashboardBase.prefHeightProperty().bind(heightProperty()); + + settingsBase = new SettingsBase(getHostServices(), this, this); + + alertStackPane = new StackPane(); + alertStackPane.setCache(true); + alertStackPane.setCacheHint(CacheHint.SPEED); + alertStackPane.setPadding(new Insets(10)); + alertStackPane.setOpacity(0); + + StreamPiAlert.setParent(alertStackPane); + StreamPiComboBox.setParent(alertStackPane); + + + getChildren().clear(); + + + getChildren().addAll(alertStackPane); + + if(getClientInfo().isPhone()) + { + dashboardBase.setPadding(new Insets(10)); + settingsBase.setPadding(new Insets(10)); } - this.initLogger(); - this.checkPrePathDirectory(); - this.getChildren().addAll((Object[])new Node[] { (Node)this.settingsBase, (Node)this.dashboardBase }); - this.setStyle((String)null); - this.config = Config.getInstance(); - this.initThemes(); - if (this.config.isFirstTimeUse()) { - this.firstTimeUse = new FirstTimeUse(this, this); - this.getChildren().add((Object)this.firstTimeUse); - if (this.getClientInfo().isPhone()) { - this.firstTimeUse.setPadding(new Insets(10.0)); + + initLogger(); + + checkPrePathDirectory(); + + + getChildren().addAll(settingsBase, dashboardBase); + + setStyle(null); + + config = Config.getInstance(); + + initThemes(); + + if(config.isFirstTimeUse()) + { + + firstTimeUse = new FirstTimeUse(this, this); + + getChildren().add(firstTimeUse); + + if(getClientInfo().isPhone()) + { + firstTimeUse.setPadding(new Insets(10)); } - this.firstTimeUse.toFront(); - this.resizeAccordingToResolution(); + + firstTimeUse.toFront(); + + //resolution check + resizeAccordingToResolution(); } - else { - this.dashboardBase.toFront(); + else + { + dashboardBase.toFront(); } } - - public void initThemes() throws SevereException { - this.clearStylesheets(); - if (this.themes == null) { - this.registerThemes(); - } - this.applyDefaultStylesheet(); - this.applyDefaultTheme(); - this.applyDefaultIconsStylesheet(); - this.applyGlobalDefaultStylesheet(); + + public void initThemes() throws SevereException + { + clearStylesheets(); + if(themes==null) + registerThemes(); + applyDefaultStylesheet(); + applyDefaultTheme(); + applyDefaultIconsStylesheet(); + applyGlobalDefaultStylesheet(); } - - private void resizeAccordingToResolution() { - if (!this.getClientInfo().isPhone()) { - final double height = this.getScreenHeight(); - final double width = this.getScreenWidth(); - if (height < 500.0) { - this.setPrefHeight(320.0); - } - if (width < 500.0) { - this.setPrefWidth(240.0); - } + + private void resizeAccordingToResolution() + { + if(!getClientInfo().isPhone()) + { + double height = getScreenHeight(); + double width = getScreenWidth(); + + if(height < 500) + setPrefHeight(320); + + if(width < 500) + setPrefWidth(240); } } - - public ExecutorService getExecutor() { - return this.executor; + + @Override + public ExecutorService getExecutor() + { + return executor; } - - public double getStageWidth() { - if (this.getClientInfo().isPhone()) { - return this.getScreenWidth(); + + @Override + public double getStageWidth() + { + if(getClientInfo().isPhone()) + { + return getScreenWidth(); + } + else + { + return getStage().getWidth(); } - return this.getStage().getWidth(); } - - public double getScreenWidth() { + + public double getScreenWidth() + { return Screen.getPrimary().getBounds().getWidth(); } - - public double getStageHeight() { - if (ClientInfo.getInstance().isPhone()) { - return this.getScreenHeight(); + + @Override + public double getStageHeight() + { + if(ClientInfo.getInstance().isPhone()) + { + return getScreenHeight(); + } + else + { + return getStage().getHeight(); } - return this.getStage().getHeight(); } - - public double getScreenHeight() { + + public double getScreenHeight() + { return Screen.getPrimary().getBounds().getHeight(); } - - private void checkPrePathDirectory() throws SevereException { - try { - final String path = this.getClientInfo().getPrePath(); - if (path == null) { - this.throwStoragePermErrorAlert("Unable to access file system!"); + + private void checkPrePathDirectory() throws SevereException + { + try + { + String path = getClientInfo().getPrePath(); + + if(path == null) + { + throwStoragePermErrorAlert("Unable to access file system!"); return; } - final File file = new File(path); - if (!file.exists()) { - final boolean result = file.mkdirs(); - if (result) { + + File file = new File(path); + + + if(!file.exists()) + { + boolean result = file.mkdirs(); + if(result) + { Config.unzipToDefaultPrePath(); - this.initLogger(); + + initLogger(); } - else { - this.throwStoragePermErrorAlert("No storage permission. Give it!"); + else + { + throwStoragePermErrorAlert("No storage permission. Give it!"); } } } - catch (Exception e) { + catch (Exception e) + { e.printStackTrace(); throw new SevereException(e.getMessage()); } } - - private void throwStoragePermErrorAlert(final String msg) throws SevereException { - this.resizeAccordingToResolution(); - this.clearStylesheets(); - this.applyDefaultStylesheet(); - this.applyDefaultIconsStylesheet(); - this.applyGlobalDefaultStylesheet(); - this.getStage().show(); + + private void throwStoragePermErrorAlert(String msg) throws SevereException + { + resizeAccordingToResolution(); + + clearStylesheets(); + applyDefaultStylesheet(); + applyDefaultIconsStylesheet(); + applyGlobalDefaultStylesheet(); + getStage().show(); throw new SevereException(msg); } - - public void setupFlags() throws SevereException { - if (Config.getInstance().getIsFullScreenMode()) { - this.getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); - this.getStage().setFullScreen(true); + + public void setupFlags() throws SevereException + { + //Full Screen + if(Config.getInstance().getIsFullScreenMode()) + { + getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); + getStage().setFullScreen(true); } - else { - this.getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC")); - this.getStage().setFullScreen(false); + else + { + getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC")); + getStage().setFullScreen(false); } - if (Config.getInstance().isShowCursor()) { - this.setCursor(Cursor.DEFAULT); + + //Cursor + if(Config.getInstance().isShowCursor()) + { + setCursor(Cursor.DEFAULT); } - else { - this.setCursor(Cursor.NONE); + else + { + setCursor(Cursor.NONE); } } - + + public SettingsBase getSettingsPane() { - return this.settingsBase; + return settingsBase; } - + public DashboardBase getDashboardPane() { - return this.dashboardBase; + return dashboardBase; } - - public void renderRootDefaultProfile() { - this.getDashboardPane().renderProfile(this.getClientProfiles().getProfileFromID(this.getConfig().getStartupProfileID()), true); + + public void renderRootDefaultProfile() + { + getDashboardPane().renderProfile(getClientProfiles().getProfileFromID( + getConfig().getStartupProfileID() + ), true); } - - public void clearStylesheets() { - this.getStylesheets().clear(); + + + + public void clearStylesheets() + { + getStylesheets().clear(); } - - public void applyDefaultStylesheet() { - if (this.clientInfo.getPlatform() != Platform.IOS) { - Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13.0); - } - this.getStylesheets().add((Object)Main.class.getResource("style.css").toExternalForm()); + + + + public void applyDefaultStylesheet() + { + if(clientInfo.getPlatform() != Platform.IOS) + Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13); + + getStylesheets().add(Main.class.getResource("style.css").toExternalForm()); } - - public void applyDefaultIconsStylesheet() { - this.getStylesheets().add((Object)Main.class.getResource("default_icons.css").toExternalForm()); + + public void applyDefaultIconsStylesheet() + { + getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm()); } - - public Config getConfig() { - return this.config; + + + public Config getConfig() + { + return config; } - - public ClientInfo getClientInfo() { - return this.clientInfo; + + public ClientInfo getClientInfo() + { + return clientInfo; } - - public Theme getCurrentTheme() { - return this.currentTheme; + + private Theme currentTheme; + + @Override + public Theme getCurrentTheme() + { + return currentTheme; } - - public void applyTheme(final Theme t) { - this.logger.info("Applying theme '" + t.getFullName() + "' ..."); - if (t.getFonts() != null) { - for (final String fontFile : t.getFonts()) { - Font.loadFont(fontFile.replace("%20", ""), 13.0); + + + public void applyTheme(Theme t) + { + logger.info("Applying theme '"+t.getFullName()+"' ..."); + + if(t.getFonts() != null) + { + for(String fontFile : t.getFonts()) + { + Font.loadFont(fontFile.replace("%20",""), 13); } } - this.currentTheme = t; - this.getStylesheets().addAll((Collection)t.getStylesheets()); - this.logger.info("... Done!"); + currentTheme = t; + getStylesheets().addAll(t.getStylesheets()); + + logger.info("... Done!"); } - - public void applyGlobalDefaultStylesheet() { - final File globalCSSFile = new File(this.getConfig().getDefaultThemesPath() + "/global.css"); - if (globalCSSFile.exists()) { - this.getLogger().info("Found global default style sheet. Adding ..."); - this.getStylesheets().add((Object)globalCSSFile.toURI().toString()); + + public void applyGlobalDefaultStylesheet() + { + File globalCSSFile = new File(getConfig().getDefaultThemesPath()+"/global.css"); + if(globalCSSFile.exists()) + { + getLogger().info("Found global default style sheet. Adding ..."); + getStylesheets().add(globalCSSFile.toURI().toString()); } } - - public void registerThemes() throws SevereException { - this.logger.info("Loading themes ..."); - this.themes = new Themes(this.getConfig().getDefaultThemesPath(), this.getConfig().getThemesPath(), this.getConfig().getCurrentThemeFullName(), this.clientInfo.getMinThemeSupportVersion()); - if (!this.themes.getErrors().isEmpty()) { - final StringBuilder themeErrors = new StringBuilder(); - for (final MinorException eachException : this.themes.getErrors()) { + + Themes themes; + public void registerThemes() throws SevereException + { + logger.info("Loading themes ..."); + + themes = new Themes(getConfig().getDefaultThemesPath(), getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), clientInfo.getMinThemeSupportVersion()); + + if(!themes.getErrors().isEmpty()) + { + StringBuilder themeErrors = new StringBuilder(); + + for(MinorException eachException : themes.getErrors()) + { themeErrors.append("\n * ").append(eachException.getMessage()); } - if (this.themes.getIsBadThemeTheCurrentOne()) { - if (this.getConfig().getCurrentThemeFullName().equals(this.getConfig().getDefaultCurrentThemeFullName())) { - throw new SevereException("Unable to get default theme (" + this.getConfig().getDefaultCurrentThemeFullName() + ")\nPlease restore the theme or reinstall."); + + if(themes.getIsBadThemeTheCurrentOne()) + { + if(getConfig().getCurrentThemeFullName().equals(getConfig().getDefaultCurrentThemeFullName())) + { + throw new SevereException("Unable to get default theme ("+getConfig().getDefaultCurrentThemeFullName()+")\n" + + "Please restore the theme or reinstall."); } - themeErrors.append("\n\nReverted to default theme! (").append(this.getConfig().getDefaultCurrentThemeFullName()).append(")"); - this.getConfig().setCurrentThemeFullName(this.getConfig().getDefaultCurrentThemeFullName()); - this.getConfig().save(); + + themeErrors.append("\n\nReverted to default theme! (").append(getConfig().getDefaultCurrentThemeFullName()).append(")"); + + getConfig().setCurrentThemeFullName(getConfig().getDefaultCurrentThemeFullName()); + getConfig().save(); } - this.handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString())); + + handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString())); } - this.logger.info("...Themes loaded successfully !"); + logger.info("...Themes loaded successfully !"); } - - public Themes getThemes() { - return this.themes; + + @Override + public Themes getThemes() + { + return themes; } - - public void applyDefaultTheme() { - this.logger.info("Applying default theme ..."); + + + public void applyDefaultTheme() + { + logger.info("Applying default theme ..."); + boolean foundTheme = false; - for (final Theme t : this.themes.getThemeList()) { - if (t.getFullName().equals(this.config.getCurrentThemeFullName())) { + for(Theme t: themes.getThemeList()) + { + if(t.getFullName().equals(config.getCurrentThemeFullName())) + { foundTheme = true; - this.applyTheme(t); + applyTheme(t); break; } } - if (foundTheme) { - this.logger.info("... Done!"); + + if(foundTheme) + { + logger.info("... Done!"); } - else { - this.logger.info("Theme not found. reverting to light theme ..."); + else + { + logger.info("Theme not found. reverting to light theme ..."); try { Config.getInstance().setCurrentThemeFullName("com.stream_pi.defaultlight"); Config.getInstance().save(); - this.applyDefaultTheme(); + + applyDefaultTheme(); } - catch (SevereException e) { - this.handleSevereException(e); + catch (SevereException e) + { + handleSevereException(e); } } + + } - - public String getDefaultThemeFullName() { - return this.config.getCurrentThemeFullName(); + + @Override + public String getDefaultThemeFullName() + { + return config.getCurrentThemeFullName(); } + + } diff --git a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java index 603d58c2..42c276c1 100644 --- a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java +++ b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java @@ -1,22 +1,15 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; public interface ExceptionAndAlertHandler { - void onAlert(final String p0, final String p1, final StreamPiAlertType p2); - - void handleMinorException(final MinorException p0); - - void handleMinorException(final String p0, final MinorException p1); - - void handleSevereException(final SevereException p0); - - void handleSevereException(final String p0, final SevereException p1); + void onAlert(String title, String body, StreamPiAlertType alertType); + + void handleMinorException(MinorException e); + void handleMinorException(String message, MinorException e); + void handleSevereException(SevereException e); + void handleSevereException(String message, SevereException e); } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java index 5a15a47a..c1951e23 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java @@ -1,68 +1,78 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.dashboard; +import com.stream_pi.client.controller.ClientListener; import com.stream_pi.client.profile.ClientProfile; -import javafx.geometry.Pos; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPane; + import javafx.geometry.Insets; -import javafx.scene.layout.HBox; -import javafx.scene.Node; -import org.kordamp.ikonli.javafx.FontIcon; -import com.stream_pi.client.controller.ClientListener; +import javafx.geometry.Pos; import javafx.scene.control.Button; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPane; -import com.stream_pi.client.window.ExceptionAndAlertHandler; +import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; +import org.kordamp.ikonli.javafx.FontIcon; public class DashboardBase extends VBox { private ExceptionAndAlertHandler exceptionAndAlertHandler; + private ActionGridPane actionGridPane; private Button settingsButton; - - public DashboardBase(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener) { + + public DashboardBase(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) + { this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.actionGridPane = new ActionGridPane(exceptionAndAlertHandler, clientListener); - final FontIcon fontIcon = new FontIcon("fas-cog"); - fontIcon.getStyleClass().addAll((Object[])new String[] { "dashboard_settings_button_icon" }); - this.settingsButton = new Button(); - this.settingsButton.getStyleClass().addAll((Object[])new String[] { "dashboard_settings_button" }); - this.settingsButton.setGraphic((Node)fontIcon); - final HBox hBox = new HBox(new Node[] { (Node)this.settingsButton }); - hBox.getStyleClass().add((Object)"dashboard_settings_button_parent"); - hBox.setPadding(new Insets(0.0, 5.0, 5.0, 0.0)); + + actionGridPane = new ActionGridPane(exceptionAndAlertHandler, clientListener); + + FontIcon fontIcon = new FontIcon("fas-cog"); + fontIcon.getStyleClass().addAll("dashboard_settings_button_icon"); + + settingsButton = new Button(); + settingsButton.getStyleClass().addAll("dashboard_settings_button"); + settingsButton.setGraphic(fontIcon); + + HBox hBox = new HBox(settingsButton); + hBox.getStyleClass().add("dashboard_settings_button_parent"); + hBox.setPadding(new Insets(0,5,5,0)); hBox.setAlignment(Pos.CENTER_RIGHT); - this.getChildren().addAll((Object[])new Node[] { (Node)this.actionGridPane, (Node)hBox }); - this.getStyleClass().add((Object)"dashboard"); + + + getChildren().addAll(actionGridPane,hBox); + + getStyleClass().add("dashboard"); } - - public void renderProfile(final ClientProfile clientProfile, final boolean freshRender) { - this.renderProfile(clientProfile, "root", freshRender); + + public void renderProfile(ClientProfile clientProfile, boolean freshRender) + { + renderProfile(clientProfile, "root", freshRender); } - - public void renderProfile(final ClientProfile clientProfile, final String currentParent, final boolean freshRender) { - this.actionGridPane.setClientProfile(clientProfile); - this.actionGridPane.setCurrentParent(currentParent); - this.actionGridPane.setFreshRender(freshRender); - this.actionGridPane.renderGrid(); - this.actionGridPane.renderActions(); + + public void renderProfile(ClientProfile clientProfile, String currentParent, boolean freshRender) + { + actionGridPane.setClientProfile(clientProfile); + actionGridPane.setCurrentParent(currentParent); + actionGridPane.setFreshRender(freshRender); + + actionGridPane.renderGrid(); + actionGridPane.renderActions(); } - - public void addBlankActionBox(final int col, final int row) { - this.actionGridPane.addBlankActionBox(col, row); + + public void addBlankActionBox(int col, int row) + { + actionGridPane.addBlankActionBox(col, row); } - - public void clearActionBox(final int col, final int row) { - this.actionGridPane.clearActionBox(col, row); + + public void clearActionBox(int col, int row) + { + actionGridPane.clearActionBox(col, row); } - + public ActionGridPane getActionGridPane() { - return this.actionGridPane; + return actionGridPane; } - + public Button getSettingsButton() { - return this.settingsButton; + return settingsButton; } } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java index d63084ef..ab71a778 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java @@ -1,171 +1,198 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.dashboard.actiongridpane; -import javafx.scene.input.MouseEvent; -import javafx.event.ActionEvent; -import com.stream_pi.client.animations.Wobble; -import com.stream_pi.client.animations.Tada; -import com.stream_pi.client.animations.Shake; -import com.stream_pi.client.animations.RubberBand; -import com.stream_pi.client.animations.Pulse; -import com.stream_pi.client.animations.Jello; -import com.stream_pi.client.animations.Swing; -import com.stream_pi.client.animations.JackInTheBox; -import com.stream_pi.client.animations.Bounce; -import com.stream_pi.client.animations.Flip; -import javafx.geometry.Pos; +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; import com.stream_pi.action_api.action.DisplayTextAlignment; -import javafx.scene.layout.BackgroundSize; -import javafx.scene.layout.BackgroundPosition; -import javafx.scene.layout.BackgroundRepeat; -import java.io.InputStream; -import javafx.scene.image.Image; -import java.io.ByteArrayInputStream; -import javafx.scene.layout.BackgroundImage; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.exception.MinorException; +import com.stream_pi.client.controller.ClientListener; import com.stream_pi.client.io.Config; -import com.stream_pi.action_api.action.ActionType; -import javafx.beans.value.WritableValue; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; import javafx.animation.Interpolator; -import javafx.animation.KeyValue; -import javafx.util.Duration; import javafx.animation.KeyFrame; -import javafx.scene.Node; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.geometry.Pos; import javafx.scene.CacheHint; -import javafx.beans.value.ObservableValue; -import javafx.scene.text.TextAlignment; +import javafx.scene.control.Label; +import javafx.scene.image.Image; import javafx.scene.layout.Background; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.action_api.action.Action; -import com.stream_pi.client.controller.ClientListener; -import javafx.animation.Timeline; +import javafx.scene.layout.BackgroundImage; +import javafx.scene.layout.BackgroundPosition; +import javafx.scene.layout.BackgroundRepeat; +import javafx.scene.layout.BackgroundSize; +import javafx.scene.layout.StackPane; +import javafx.scene.text.Font; +import javafx.scene.text.TextAlignment; +import javafx.util.Duration; import org.kordamp.ikonli.javafx.FontIcon; + +import java.io.ByteArrayInputStream; import java.util.logging.Logger; -import javafx.scene.control.Label; -import javafx.scene.layout.StackPane; public class ActionBox extends StackPane { + private Label displayTextLabel; + private int row; private int col; - private Logger logger; - private FontIcon statusIcon; - private Timeline statusIconAnimation; - private int size; - private ActionGridPaneListener actionGridPaneListener; - private ClientListener clientListener; - private Action action; - private ExceptionAndAlertHandler exceptionAndAlertHandler; - private String parent; - FontIcon fontIcon; - + public int getRow() { - return this.row; + return row; } - + public int getCol() { - return this.col; + return col; } - public void clear() { - this.setStyle((String)null); - this.setAction(null); - this.setCurrentToggleStatus(false); - this.getStyleClass().clear(); - this.setBackground(Background.EMPTY); - this.removeFontIcon(); - this.getChildren().clear(); - this.baseInit(); + private Logger logger; + + + + public void clear() + { + setStyle(null); + setAction(null); + setCurrentToggleStatus(false); + getStyleClass().clear(); + setBackground(Background.EMPTY); + removeFontIcon(); + getChildren().clear(); + baseInit(); } + + private FontIcon statusIcon; + + public void baseInit() + { + displayTextLabel = new Label(); + displayTextLabel.setWrapText(true); + displayTextLabel.setTextAlignment(TextAlignment.CENTER); + displayTextLabel.getStyleClass().add("action_box_display_text_label"); + + displayTextLabel.prefHeightProperty().bind(heightProperty()); + displayTextLabel.prefWidthProperty().bind(widthProperty()); + + + statusIcon = new FontIcon("fas-exclamation-triangle"); + statusIcon.getStyleClass().add("action_box_error_icon"); + statusIcon.setOpacity(0); + statusIcon.setCache(true); + statusIcon.setCacheHint(CacheHint.SPEED); + statusIcon.setIconSize(size - 30); + - public void baseInit() { - (this.displayTextLabel = new Label()).setWrapText(true); - this.displayTextLabel.setTextAlignment(TextAlignment.CENTER); - this.displayTextLabel.getStyleClass().add((Object)"action_box_display_text_label"); - this.displayTextLabel.prefHeightProperty().bind((ObservableValue)this.heightProperty()); - this.displayTextLabel.prefWidthProperty().bind((ObservableValue)this.widthProperty()); - this.statusIcon = new FontIcon("fas-exclamation-triangle"); - this.statusIcon.getStyleClass().add((Object)"action_box_error_icon"); - this.statusIcon.setOpacity(0.0); - this.statusIcon.setCache(true); - this.statusIcon.setCacheHint(CacheHint.SPEED); - this.statusIcon.setIconSize(this.size - 30); - this.getChildren().addAll((Object[])new Node[] { (Node)this.statusIcon, (Node)this.displayTextLabel }); - this.setMinSize((double)this.size, (double)this.size); - this.setMaxSize((double)this.size, (double)this.size); - this.getStyleClass().clear(); - this.getStyleClass().add((Object)"action_box"); - this.getStyleClass().add("action_box_" + this.row + "_" + this.col); - this.setIcon(null); - this.setOnMouseClicked(touchEvent -> this.actionClicked()); - this.setOnMousePressed(TouchEvent -> { - if (this.action != null) { - this.getStyleClass().add((Object)"action_box_onclick"); + getChildren().addAll(statusIcon, displayTextLabel); + + setMinSize(size, size); + setMaxSize(size, size); + + getStyleClass().clear(); + getStyleClass().add("action_box"); + getStyleClass().add("action_box_"+row+"_"+col); + + setIcon(null); + + setOnMouseClicked(touchEvent -> actionClicked()); + + setOnMousePressed(TouchEvent -> { + if(action != null) + { + getStyleClass().add("action_box_onclick"); } }); - this.setOnMouseReleased(TouchEvent -> { - if (this.action != null) { - this.getStyleClass().remove((Object)"action_box_onclick"); + setOnMouseReleased(TouchEvent ->{ + if(action != null) + { + getStyleClass().remove("action_box_onclick"); } }); - (this.statusIconAnimation = new Timeline(new KeyFrame[] { new KeyFrame(Duration.millis(0.0), new KeyValue[] { new KeyValue((WritableValue)this.statusIcon.opacityProperty(), (Object)0.0, Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(100.0), new KeyValue[] { new KeyValue((WritableValue)this.statusIcon.opacityProperty(), (Object)1.0, Interpolator.EASE_IN) }), new KeyFrame(Duration.millis(600.0), new KeyValue[] { new KeyValue((WritableValue)this.statusIcon.opacityProperty(), (Object)1.0, Interpolator.EASE_OUT) }), new KeyFrame(Duration.millis(700.0), new KeyValue[] { new KeyValue((WritableValue)this.statusIcon.opacityProperty(), (Object)0.0, Interpolator.EASE_OUT) }) })).setOnFinished(event -> this.statusIcon.toBack()); - this.setCache(true); - this.setCacheHint(CacheHint.QUALITY); + + statusIconAnimation = new Timeline( + new KeyFrame( + Duration.millis(0.0D), + new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)), + new KeyFrame( + Duration.millis(100.0D), + new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)), + new KeyFrame( + Duration.millis(600.0D), + new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)), + new KeyFrame( + Duration.millis(700.0D), + new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT)) + ); + + statusIconAnimation.setOnFinished(event -> { + statusIcon.toBack(); + }); + + setCache(true); + setCacheHint(CacheHint.QUALITY); } - - public void actionClicked() { - if (this.action != null) { - if (this.action.getActionType() == ActionType.FOLDER) { - this.getActionGridPaneListener().renderFolder(this.action.getID()); + + public void actionClicked() + { + if(action!=null) + { + if(action.getActionType() == ActionType.FOLDER) + { + getActionGridPaneListener().renderFolder(action.getID()); } - else { - if (!this.getActionGridPaneListener().isConnected()) { - try { - if (Config.getInstance().isTryConnectingWhenActionClicked()) { - this.clientListener.setupClientConnection(this::actionClicked); + else + { + if(!getActionGridPaneListener().isConnected()) + { + try + { + if(Config.getInstance().isTryConnectingWhenActionClicked()) + { + clientListener.setupClientConnection(this::actionClicked); } - else { - this.exceptionAndAlertHandler.handleMinorException(new MinorException("Not Connected", "Not Connected to any Server")); + else + { + exceptionAndAlertHandler.handleMinorException(new MinorException("Not Connected", "Not Connected to any Server")); } return; } - catch (SevereException e) { - this.exceptionAndAlertHandler.handleSevereException(e); + catch (SevereException e) + { + exceptionAndAlertHandler.handleSevereException(e); } } - if (this.action.getActionType() == ActionType.COMBINE || this.action.getActionType() == ActionType.NORMAL) { - this.getActionGridPaneListener().normalOrCombineActionClicked(this.action.getID()); + + if(action.getActionType() == ActionType.COMBINE || action.getActionType() == ActionType.NORMAL) + { + getActionGridPaneListener().normalOrCombineActionClicked(action.getID()); } - else if (this.action.getActionType() == ActionType.TOGGLE) { - this.toggle(); - this.getActionGridPaneListener().toggleActionClicked(this.action.getID(), this.getCurrentToggleStatus()); + else if(action.getActionType() == ActionType.TOGGLE) + { + toggle(); + getActionGridPaneListener().toggleActionClicked(action.getID(), getCurrentToggleStatus()); } } } - try { - this.playActionAnimation(); - } - catch (SevereException e) { - Logger.getLogger("").warning(e.getMessage()); - } } - + + private Timeline statusIconAnimation; + public Timeline getStatusIconAnimation() { - return this.statusIconAnimation; + return statusIconAnimation; } - + public ActionGridPaneListener getActionGridPaneListener() { - return this.actionGridPaneListener; + return actionGridPaneListener; } - - public ActionBox(final int size, final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener, final ActionGridPaneListener actionGridPaneListener, final int row, final int col) { - this.action = null; - this.fontIcon = null; + + private int size; + private ActionGridPaneListener actionGridPaneListener; + private ClientListener clientListener; + + public ActionBox(int size, ExceptionAndAlertHandler exceptionAndAlertHandler, + ClientListener clientListener, ActionGridPaneListener actionGridPaneListener, int row, int col) + { this.actionGridPaneListener = actionGridPaneListener; this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.size = size; @@ -173,249 +200,285 @@ public ActionBox(final int size, final ExceptionAndAlertHandler exceptionAndAler this.col = col; this.clientListener = clientListener; this.logger = Logger.getLogger(""); - this.baseInit(); + + baseInit(); } - - public Logger getLogger() { - return this.logger; + + public Logger getLogger() + { + return logger; } - - public void setIcon(final byte[] iconByteArray) { - this.removeFontIcon(); - if (iconByteArray == null) { - this.getStyleClass().remove((Object)"action_box_icon_present"); - this.getStyleClass().add((Object)"action_box_icon_not_present"); - this.setBackground((Background)null); + + public void setIcon(byte[] iconByteArray) + { + removeFontIcon(); + + if(iconByteArray == null) + { + getStyleClass().remove("action_box_icon_present"); + getStyleClass().add("action_box_icon_not_present"); + setBackground(null); } - else { - this.getStyleClass().add((Object)"action_box_icon_present"); - this.getStyleClass().remove((Object)"action_box_icon_not_present"); - this.setBackground(new Background(new BackgroundImage[] { new BackgroundImage(new Image((InputStream)new ByteArrayInputStream(iconByteArray), (double)this.size, (double)this.size, false, true), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, new BackgroundSize(100.0, 100.0, true, true, true, false)) })); + else + { + getStyleClass().add("action_box_icon_present"); + getStyleClass().remove("action_box_icon_not_present"); + + + setBackground( + new Background( + new BackgroundImage(new Image( + new ByteArrayInputStream(iconByteArray), size, size, false, true + ), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, + + new BackgroundSize(100, 100, true, true, true, false)) + ) + ); } } + + private Action action = null; public Action getAction() { - return this.action; + return action; } - + + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + private String parent; + public String getStreamPiParent() { - return this.parent; + return parent; } - - public void setStreamPiParent(final String parent) { + + public void setStreamPiParent(String parent) { this.parent = parent; } - - public void setAction(final Action action) { + + public void setAction(Action action) + { this.action = action; } - - public void init() { - this.setBackground((Background)null); - this.setStyle((String)null); - this.displayTextLabel.setStyle((String)null); - if (this.getAction().isShowDisplayText()) { - this.setDisplayTextAlignment(this.action.getDisplayTextAlignment()); - this.setDisplayTextFontColourAndSize(this.action.getDisplayTextFontColourHex()); - this.setDisplayTextLabel(this.getAction().getDisplayText()); - } - else { - this.setDisplayTextLabel(""); + + public void init() + { + setBackground(null); + setStyle(null); + displayTextLabel.setStyle(null); + + + if(getAction().isShowDisplayText()) + { + setDisplayTextAlignment(action.getDisplayTextAlignment()); + setDisplayTextFontColourAndSize(action.getDisplayTextFontColourHex()); + setDisplayTextLabel(getAction().getDisplayText()); } - this.setBackgroundColour(this.action.getBgColourHex()); - try { - if (this.action.getActionType() == ActionType.TOGGLE) { - this.toggle(this.getCurrentToggleStatus()); + else + setDisplayTextLabel(""); + + setBackgroundColour(action.getBgColourHex()); + + try + { + if(action.getActionType() == ActionType.TOGGLE) + { + toggle(getCurrentToggleStatus()); } - else if (this.action.isHasIcon()) { - if (!this.action.getCurrentIconState().isBlank()) { - this.setIcon(this.action.getCurrentIcon()); + else + { + if(action.isHasIcon()) + { + if(!action.getCurrentIconState().isBlank()) + { + setIcon(action.getCurrentIcon()); + } + } + else + { + setIcon(null); } - } - else { - this.setIcon(null); } } - catch (Exception e) { + catch (Exception e) + { e.printStackTrace(); } } - - public void setCurrentToggleStatus(final boolean currentToggleStatus) { - if (this.getAction() != null) { - this.getAction().setCurrentToggleStatus(currentToggleStatus); - } + + + public void setCurrentToggleStatus(boolean currentToggleStatus) + { + if(getAction() != null) + getAction().setCurrentToggleStatus(currentToggleStatus); } - - public boolean getCurrentToggleStatus() { - return this.getAction() != null && this.getAction().getCurrentToggleStatus(); + + public boolean getCurrentToggleStatus() + { + if(getAction() == null) + return false; + + return getAction().getCurrentToggleStatus(); } - - public void toggle() { - this.setCurrentToggleStatus(!this.getCurrentToggleStatus()); - this.toggle(this.getCurrentToggleStatus()); + + public void toggle() + { + setCurrentToggleStatus(!getCurrentToggleStatus()); + + toggle(getCurrentToggleStatus()); } - - public void toggle(final boolean isON) { - final String[] toggleStatesHiddenStatus = this.action.getCurrentIconState().split("__"); - final boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true"); - final boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true"); - if (isON) { - if (this.action.isHasIcon()) { - final boolean isToggleOnPresent = this.action.getIcons().containsKey("toggle_on"); - if (isToggleOnPresent) { - if (isToggleOnHidden) { - this.setDefaultToggleIcon(true); + + public void toggle(boolean isON) + { + String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__"); + + boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true"); + boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true"); + + if(isON) // ON + { + if(action.isHasIcon()) + { + boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on"); + + if(isToggleOnPresent) + { + if(isToggleOnHidden) + { + setDefaultToggleIcon(true); } - else { - this.setIcon(this.action.getIcons().get("toggle_on")); + else + { + setIcon(action.getIcons().get("toggle_on")); } } - else { - this.setDefaultToggleIcon(true); + else + { + setDefaultToggleIcon(true); } } - else { - this.setDefaultToggleIcon(true); + else + { + setDefaultToggleIcon(true); } } - else if (this.action.isHasIcon()) { - final boolean isToggleOffPresent = this.action.getIcons().containsKey("toggle_off"); - if (isToggleOffPresent) { - if (isToggleOffHidden) { - this.setDefaultToggleIcon(false); + else // OFF + { + if(action.isHasIcon()) + { + boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off"); + + if(isToggleOffPresent) + { + if(isToggleOffHidden) + { + setDefaultToggleIcon(false); + } + else + { + setIcon(action.getIcons().get("toggle_off")); + } } - else { - this.setIcon(this.action.getIcons().get("toggle_off")); + else + { + setDefaultToggleIcon(false); } } - else { - this.setDefaultToggleIcon(false); + else + { + setDefaultToggleIcon(false); } } - else { - this.setDefaultToggleIcon(false); - } } - - public void setDefaultToggleIcon(final boolean isToggleOn) { + + + public void setDefaultToggleIcon(boolean isToggleOn) + { String styleClass; - if (isToggleOn) { + + if(isToggleOn) + { styleClass = "action_box_toggle_on"; } - else { + else + { styleClass = "action_box_toggle_off"; } - this.setBackground((Background)null); - if (this.fontIcon != null) { - this.fontIcon.getStyleClass().removeIf(s -> s.equals("action_box_toggle_off") || s.equals("action_box_toggle_on")); + + + setBackground(null); + + + if(fontIcon!=null) + { + fontIcon.getStyleClass().removeIf(s -> s.equals("action_box_toggle_off") || s.equals("action_box_toggle_on")); } - else { - (this.fontIcon = new FontIcon()).setIconSize((int)(this.size * 0.8)); - this.getChildren().add((Object)this.fontIcon); + else + { + fontIcon = new FontIcon(); + fontIcon.setIconSize((int) (size * 0.8)); + getChildren().add(fontIcon); } - this.fontIcon.getStyleClass().add((Object)styleClass); - this.fontIcon.toBack(); + + fontIcon.getStyleClass().add(styleClass); + + fontIcon.toBack(); } - - public void removeFontIcon() { - if (this.fontIcon != null) { - this.getChildren().remove((Object)this.fontIcon); - this.fontIcon = null; + + public void removeFontIcon() + { + if(fontIcon!=null) + { + getChildren().remove(fontIcon); + fontIcon = null; } } - - public void animateStatus() { - this.statusIcon.toFront(); - this.statusIconAnimation.play(); + + FontIcon fontIcon = null; + + public void animateStatus() + { + statusIcon.toFront(); + statusIconAnimation.play(); } - - public void setDisplayTextLabel(final String text) { - this.displayTextLabel.setText(text); + + public void setDisplayTextLabel(String text) + { + displayTextLabel.setText(text); } - - public void setDisplayTextAlignment(final DisplayTextAlignment displayTextAlignment) { - if (displayTextAlignment == DisplayTextAlignment.CENTER) { - this.displayTextLabel.setAlignment(Pos.CENTER); - } - else if (displayTextAlignment == DisplayTextAlignment.BOTTOM) { - this.displayTextLabel.setAlignment(Pos.BOTTOM_CENTER); - } - else if (displayTextAlignment == DisplayTextAlignment.TOP) { - this.displayTextLabel.setAlignment(Pos.TOP_CENTER); - } + + public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment) + { + if(displayTextAlignment == DisplayTextAlignment.CENTER) + displayTextLabel.setAlignment(Pos.CENTER); + else if (displayTextAlignment == DisplayTextAlignment.BOTTOM) + displayTextLabel.setAlignment(Pos.BOTTOM_CENTER); + else if (displayTextAlignment == DisplayTextAlignment.TOP) + displayTextLabel.setAlignment(Pos.TOP_CENTER); } - - public void setDisplayTextFontColourAndSize(final String colour) { + + public void setDisplayTextFontColourAndSize(String colour) + { String totalStyle = ""; - if (!colour.isEmpty()) { - totalStyle = totalStyle + "-fx-text-fill : " + colour; - } - if (this.getAction().getNameFontSize() > -1.0) { - totalStyle = totalStyle + "-fx-font-size: " + this.getAction().getNameFontSize(); + if(!colour.isEmpty()) + { + totalStyle+="-fx-text-fill : "+colour+";"; } - if (!totalStyle.isBlank()) { - this.displayTextLabel.setStyle(totalStyle); + + if(getAction().getNameFontSize() > -1) + { + totalStyle+="-fx-font-size: "+getAction().getNameFontSize()+";"; } - } - - public void playActionAnimation() throws SevereException { - final Config config = Config.getInstance(); - final String currentAnimationName = config.getCurrentAnimationName(); - switch (currentAnimationName) { - case "None": { - break; - } - case "Flip": { - new Flip((Node)this.getChildren().get(1)).play(); - break; - } - case "Bounce": { - new Bounce((Node)this.getChildren().get(1)).play(); - break; - } - case "Jack In The Box": { - new JackInTheBox((Node)this.getChildren().get(1)).play(); - break; - } - case "Swing": { - new Swing((Node)this.getChildren().get(1)).play(); - break; - } - case "Jello": { - new Jello((Node)this.getChildren().get(1)).play(); - break; - } - case "Pulse": { - new Pulse((Node)this.getChildren().get(1)).play(); - break; - } - case "RubberBand": { - new RubberBand((Node)this.getChildren().get(1)).play(); - break; - } - case "Shake": { - new Shake((Node)this.getChildren().get(1)).play(); - break; - } - case "Tada": { - new Tada((Node)this.getChildren().get(1)).play(); - break; - } - case "Wobble": { - new Wobble((Node)this.getChildren().get(1)).play(); - break; - } - default: { - Logger.getLogger("").warning("Invalid Option/n Please contact quimodotcom to solve this error!"); - break; - } + + if(!totalStyle.isBlank()) + { + displayTextLabel.setStyle(totalStyle); } } - - public void setBackgroundColour(final String colour) { - if (!colour.isEmpty()) { - this.setStyle("-fx-background-color : " + colour); - } + + + public void setBackgroundColour(String colour) + { + if(!colour.isEmpty()) + setStyle("-fx-background-color : "+colour); } } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java index 5980b77d..1eafe151 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java @@ -1,316 +1,459 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.dashboard.actiongridpane; -import javafx.scene.input.MouseEvent; -import com.stream_pi.action_api.action.Location; +import java.util.logging.Logger; + +import com.stream_pi.action_api.action.Action; import com.stream_pi.action_api.action.ActionType; -import javafx.geometry.Orientation; +import com.stream_pi.action_api.action.Location; +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 java.util.Iterator; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.exception.SevereException; -import org.kordamp.ikonli.javafx.FontIcon; -import javafx.scene.layout.StackPane; -import com.stream_pi.action_api.action.Action; -import javafx.scene.CacheHint; -import javafx.scene.layout.VBox; -import javafx.scene.layout.Priority; -import javafx.geometry.Pos; -import javafx.beans.value.ObservableValue; +import javafx.concurrent.Task; import javafx.geometry.Insets; -import java.util.logging.Logger; +import javafx.geometry.Orientation; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; import javafx.scene.Node; -import com.stream_pi.client.profile.ClientProfile; -import javafx.scene.layout.GridPane; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.window.ExceptionAndAlertHandler; import javafx.scene.control.ScrollPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import org.kordamp.ikonli.javafx.FontIcon; public class ActionGridPane extends ScrollPane implements ActionGridPaneListener { + private ExceptionAndAlertHandler exceptionAndAlertHandler; + private ClientListener clientListener; + private ActionBox[][] actionBoxes; + private GridPane actionsGridPane; - private String currentParent; - private int rows; - private int cols; - private ClientProfile clientProfile; - private boolean isFreshRender; - private Node folderBackButton; - private Logger logger; - private String previousParent; - - public ActionGridPane(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener) { - this.isFreshRender = true; - this.folderBackButton = null; + + public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) + { this.clientListener = clientListener; - this.logger = Logger.getLogger(ActionGridPane.class.getName()); + + logger = Logger.getLogger(ActionGridPane.class.getName()); this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.getStyleClass().add((Object)"action_grid_pane_parent"); - (this.actionsGridPane = new GridPane()).setPadding(new Insets(5.0)); - this.actionsGridPane.getStyleClass().add((Object)"action_grid_pane"); - this.actionsGridPane.prefWidthProperty().bind((ObservableValue)this.widthProperty().subtract(20)); - this.actionsGridPane.prefHeightProperty().bind((ObservableValue)this.heightProperty().subtract(20)); - this.setContent((Node)this.actionsGridPane); - this.actionsGridPane.setAlignment(Pos.CENTER); - VBox.setVgrow((Node)this, Priority.ALWAYS); - this.setCache(true); - this.setCacheHint(CacheHint.SPEED); + + getStyleClass().add("action_grid_pane_parent"); + + actionsGridPane = new GridPane(); + actionsGridPane.setPadding(new Insets(5.0)); + actionsGridPane.getStyleClass().add("action_grid_pane"); + actionsGridPane.prefWidthProperty().bind(widthProperty().subtract(20)); + actionsGridPane.prefHeightProperty().bind(heightProperty().subtract(20)); + + setContent(actionsGridPane); + + actionsGridPane.setAlignment(Pos.CENTER); + + + VBox.setVgrow(this, Priority.ALWAYS); + + setCache(true); + setCacheHint(CacheHint.SPEED); } - - public void setCurrentParent(final String currentParent) { + + private String currentParent; + + public void setCurrentParent(String currentParent) { this.currentParent = currentParent; } - + public ClientProfile getClientProfile() { - return this.clientProfile; + return clientProfile; } - - public void setClientProfile(final ClientProfile clientProfile) { + + private int rows, cols; + + private ClientProfile clientProfile; + + public void setClientProfile(ClientProfile clientProfile) + { this.clientProfile = clientProfile; - this.setCurrentParent("root"); - this.setRows(clientProfile.getRows()); - this.setCols(clientProfile.getCols()); + + setCurrentParent("root"); + setRows(clientProfile.getRows()); + setCols(clientProfile.getCols()); } - - public void actionFailed(final String profileID, final String actionID) { - if (this.getClientProfile().getID().equals(profileID)) { - final Action action = this.getClientProfile().getActionFromID(actionID); - if (action != null) { - if (this.currentParent.equals(action.getParent())) { - this.failShow(action); + + public void actionFailed(String profileID, String actionID) + { + if(getClientProfile().getID().equals(profileID)) + { + Action action = getClientProfile().getActionFromID(actionID); + if(action != null) + { + if(currentParent.equals(action.getParent())) + { + failShow(action); } - else if (action.getLocation().getCol() == -1) { - this.failShow(this.getClientProfile().getActionFromID(action.getParent())); + else + { + if(action.getLocation().getCol() == -1) + { + failShow(getClientProfile().getActionFromID(action.getParent())); + } } } } } - - public void failShow(final Action action) { - this.actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus(); + + public void failShow(Action action) + { + actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus(); } - + + public String getCurrentParent() { - return this.currentParent; + return currentParent; } - - public StackPane getFolderBackButton() { - final StackPane stackPane = new StackPane(); - stackPane.getStyleClass().add((Object)"action_box"); - stackPane.getStyleClass().add((Object)"action_box_valid"); - stackPane.setPrefSize((double)this.getClientProfile().getActionSize(), (double)this.getClientProfile().getActionSize()); - final FontIcon fontIcon = new FontIcon("fas-chevron-left"); - fontIcon.getStyleClass().add((Object)"folder_action_back_button_icon"); - fontIcon.setIconSize(this.getClientProfile().getActionSize() - 30); + + public StackPane getFolderBackButton() + { + StackPane stackPane = new StackPane(); + stackPane.getStyleClass().add("action_box"); + stackPane.getStyleClass().add("action_box_valid"); + + stackPane.setPrefSize( + getClientProfile().getActionSize(), + getClientProfile().getActionSize() + ); + + FontIcon fontIcon = new FontIcon("fas-chevron-left"); + fontIcon.getStyleClass().add("folder_action_back_button_icon"); + fontIcon.setIconSize(getClientProfile().getActionSize() - 30); + stackPane.setAlignment(Pos.CENTER); - stackPane.getChildren().add((Object)fontIcon); - stackPane.setOnMouseClicked(e -> this.returnToPreviousParent()); + stackPane.getChildren().add(fontIcon); + + stackPane.setOnMouseClicked(e->returnToPreviousParent()); + return stackPane; } - - public void renderGrid() { - this.actionsGridPane.setHgap((double)this.getClientProfile().getActionGap()); - this.actionsGridPane.setVgap((double)this.getClientProfile().getActionGap()); - if (this.isFreshRender) { - this.clear(); - this.actionBoxes = new ActionBox[this.cols][this.rows]; + + private boolean isFreshRender = true; + private Node folderBackButton = null; + public void renderGrid() + { + actionsGridPane.setHgap(getClientProfile().getActionGap()); + actionsGridPane.setVgap(getClientProfile().getActionGap()); + + if(isFreshRender) + { + clear(); + actionBoxes = new ActionBox[cols][rows]; } + boolean isFolder = false; - if (this.getCurrentParent().equals("root")) { - if (this.folderBackButton != null) { - this.actionsGridPane.getChildren().remove((Object)this.folderBackButton); - this.folderBackButton = null; - this.actionBoxes[0][0] = this.addBlankActionBox(0, 0); + + if(getCurrentParent().equals("root")) + { + if(folderBackButton != null) + { + actionsGridPane.getChildren().remove(folderBackButton); + folderBackButton = null; + + actionBoxes[0][0] = addBlankActionBox(0,0); } } - else { + else + { isFolder = true; - if (this.folderBackButton != null) { - this.actionsGridPane.getChildren().remove((Object)this.folderBackButton); - this.folderBackButton = null; + + if(folderBackButton != null) + { + actionsGridPane.getChildren().remove(folderBackButton); + folderBackButton = null; } - else { - this.actionsGridPane.getChildren().remove((Object)this.actionBoxes[0][0]); + else + { + actionsGridPane.getChildren().remove(actionBoxes[0][0]); } - this.folderBackButton = (Node)this.getFolderBackButton(); - this.actionsGridPane.add(this.folderBackButton, 0, 0); + + folderBackButton = getFolderBackButton(); + actionsGridPane.add(folderBackButton, 0,0); } - for (int row = 0; row < this.rows; ++row) { - for (int col = 0; col < this.cols; ++col) { - if (row != 0 || col != 0 || !isFolder) { - if (this.isFreshRender) { - this.actionBoxes[col][row] = this.addBlankActionBox(col, row); - } - else if (this.actionBoxes[col][row].getAction() != null) { - this.actionBoxes[col][row].clear(); + + for(int row = 0; row= this.rows || action.getLocation().getCol() >= this.cols) { - throw new MinorException("Action " + action.getDisplayText() + " (" + action.getID() + ") falls outside bounds.\n Consider increasing rows/cols from client settings and relocating/deleting it."); + + if(action.getLocation().getRow() >= rows || action.getLocation().getCol() >= cols) + { + throw new MinorException("Action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" + + " Consider increasing rows/cols from client settings and relocating/deleting it."); } - final Location location = action.getLocation(); - if (this.getClientProfile().getCols() < location.getCol() || this.getClientProfile().getRows() < location.getRow()) { + + + Location location = action.getLocation(); + + if( getClientProfile().getCols() < location.getCol() || getClientProfile().getRows() < location.getRow()) return; - } - final ActionBox actionBox = this.actionBoxes[location.getCol()][location.getRow()]; - if (actionBox.getAction() != null) { - if (!actionBox.getAction().getID().equals(action.getID())) { + + ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()]; + + if(actionBox.getAction()!=null) + { + if(!actionBox.getAction().getID().equals(action.getID())) + { actionBox.clear(); } } - else { + else + { actionBox.clear(); } - final boolean oldToggleStatus = action.getCurrentToggleStatus(); + + + boolean oldToggleStatus = action.getCurrentToggleStatus(); + + actionBox.setAction(action); + + actionBox.setCurrentToggleStatus(oldToggleStatus); - actionBox.setStreamPiParent(this.currentParent); + + + actionBox.setStreamPiParent(currentParent); actionBox.init(); + + /*ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), action, exceptionAndAlertHandler, this, location.getRow(), location.getCol()); + + actionBox.setStreamPiParent(currentParent); + + clearActionBox(location.getCol(), location.getRow()); + + System.out.println(location.getCol()+","+location.getRow()); + add(actionBox, location.getRow(), location.getCol()); + + actionBoxes[location.getCol()][location.getRow()] = actionBox;*/ } - - public void setRows(final int rows) { + + public void setRows(int rows) + { this.rows = rows; } - - public void setCols(final int cols) { + + public void setCols(int cols) + { this.cols = cols; } - - public int getRows() { - return this.rows; + + public int getRows() + { + return rows; } - - public int getCols() { - return this.cols; + + public int getCols() + { + return cols; } - - public void setPreviousParent(final String previousParent) { + + private String previousParent; + + public void setPreviousParent(String previousParent) { this.previousParent = previousParent; } - + public String getPreviousParent() { - return this.previousParent; + return previousParent; } - - public void renderFolder(final String actionID) { - this.setCurrentParent(this.clientProfile.getActionFromID(actionID).getID()); - this.setPreviousParent(this.clientProfile.getActionFromID(actionID).getParent()); - this.renderGrid(); - this.renderActions(); + + @Override + public void renderFolder(String actionID) { + setCurrentParent(clientProfile.getActionFromID(actionID).getID()); + setPreviousParent(clientProfile.getActionFromID(actionID).getParent()); + renderGrid(); + renderActions(); } - - public void normalOrCombineActionClicked(final String ID) { - this.clientListener.onActionClicked(this.getClientProfile().getID(), ID, false); + + @Override + public void normalOrCombineActionClicked(String ID) + { + clientListener.onActionClicked(getClientProfile().getID(), ID, false); } - - public void toggleActionClicked(final String ID, final boolean toggleState) { - this.clientListener.onActionClicked(this.getClientProfile().getID(), ID, toggleState); + + @Override + public void toggleActionClicked(String ID, boolean toggleState) + { + clientListener.onActionClicked(getClientProfile().getID(), ID, toggleState); } - - public ActionBox getActionBoxByLocation(final Location location) { - return this.getActionBox(location.getCol(), location.getRow()); + + @Override + public ActionBox getActionBoxByLocation(Location location) + { + return getActionBox(location.getCol(), location.getRow()); } - - public boolean isConnected() { - return this.clientListener.isConnected(); + + + @Override + public boolean isConnected() + { + return clientListener.isConnected(); } - - public void returnToPreviousParent() { - this.setCurrentParent(this.getPreviousParent()); - if (!this.getPreviousParent().equals("root")) { - System.out.println("parent : " + this.getPreviousParent()); - this.setPreviousParent(this.getClientProfile().getActionFromID(this.getPreviousParent()).getParent()); + + + public void returnToPreviousParent() + { + setCurrentParent(getPreviousParent()); + + if(!getPreviousParent().equals("root")) + { + System.out.println("parent : "+getPreviousParent()); + setPreviousParent(getClientProfile().getActionFromID( + getPreviousParent() + ).getParent()); } - this.renderGrid(); - this.renderActions(); + + renderGrid(); + renderActions(); } } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java index dfdf87f1..a8290f4c 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java @@ -1,20 +1,17 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.dashboard.actiongridpane; +import com.stream_pi.action_api.action.Action; import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.otheractions.FolderAction; public interface ActionGridPaneListener { - void renderFolder(final String p0); - - void normalOrCombineActionClicked(final String p0); - - void toggleActionClicked(final String p0, final boolean p1); - - ActionBox getActionBoxByLocation(final Location p0); - + void renderFolder(String ID); + + void normalOrCombineActionClicked(String ID); + void toggleActionClicked(String ID, boolean toggleState); + + ActionBox getActionBoxByLocation(Location location); + boolean isConnected(); } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java index 3b1eabed..9060a0d7 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java @@ -1,134 +1,174 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.firsttimeuse; -import javafx.concurrent.Task; -import javafx.event.ActionEvent; +import com.gluonhq.attach.orientation.OrientationService; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; import com.stream_pi.util.alert.StreamPiAlert; import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.exception.SevereException; -import javafx.geometry.Orientation; -import com.gluonhq.attach.orientation.OrientationService; -import com.stream_pi.client.profile.ClientProfile; -import java.io.File; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.io.Config; -import javafx.application.Platform; import com.stream_pi.util.uihelper.HBoxInputBox; -import javafx.scene.Node; -import javafx.scene.layout.Priority; -import javafx.scene.control.Label; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.window.ExceptionAndAlertHandler; + +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.geometry.Orientation; import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; import javafx.scene.control.TextField; +import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; +import javax.xml.transform.TransformerException; +import java.io.File; + public class FinalConfigPane extends VBox { private TextField clientNicknameTextField; private TextField serverIPHostNameTextField; private TextField serverPortTextField; private Button nextButton; + private ExceptionAndAlertHandler exceptionAndAlertHandler; private ClientListener clientListener; - private int rowsToSet; - private int colsToSet; - - public FinalConfigPane(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener, final Button nextButton) { + + public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener, + Button nextButton) + { this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.clientListener = clientListener; this.nextButton = nextButton; - this.getStyleClass().add((Object)"first_time_use_pane_final_config"); - final Label label = new Label("That's it. Now just a little bit and then you're set!"); + + getStyleClass().add("first_time_use_pane_final_config"); + + Label label = new Label("That's it. Now just a little bit and then you're set!"); label.setWrapText(true); - VBox.setVgrow((Node)label, Priority.ALWAYS); - label.getStyleClass().add((Object)"first_time_use_pane_final_config_label"); - this.clientNicknameTextField = new TextField(); - this.serverIPHostNameTextField = new TextField(); - this.serverPortTextField = new TextField(); - final HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", this.clientNicknameTextField, 150); - final HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", this.serverIPHostNameTextField, 150); - final HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", this.serverPortTextField, 150); - this.getChildren().addAll((Object[])new Node[] { (Node)label, (Node)clientNickNameInputBox, (Node)serverIPHostNameInputBox, (Node)serverIPPortInputBox }); - this.setSpacing(10.0); - this.setVisible(false); + VBox.setVgrow(label, Priority.ALWAYS); + label.getStyleClass().add("first_time_use_pane_final_config_label"); + + clientNicknameTextField = new TextField(); + serverIPHostNameTextField = new TextField(); + serverPortTextField = new TextField(); + + HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField, 150); + HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField, 150); + HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField, 150); + + getChildren().addAll(label, clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox); + + setSpacing(10.0); + + setVisible(false); } - - public void makeChangesToNextButton() { - this.nextButton.setText("Confirm"); - this.nextButton.setOnAction(actionEvent -> new Thread((Runnable)new Task() { - protected Void call() { - FinalConfigPane.this.onConfirmButtonClicked(); + + public void makeChangesToNextButton() + { + nextButton.setText("Confirm"); + nextButton.setOnAction(actionEvent -> new Thread(new Task() { + @Override + protected Void call() + { + onConfirmButtonClicked(); return null; } }).start()); } - - private void onConfirmButtonClicked() { - Platform.runLater(() -> this.nextButton.setDisable(true)); - final StringBuilder errors = new StringBuilder(); - if (this.clientNicknameTextField.getText().isBlank()) { + + private void onConfirmButtonClicked() + { + Platform.runLater(()->nextButton.setDisable(true)); + + StringBuilder errors = new StringBuilder(); + + if(clientNicknameTextField.getText().isBlank()) + { errors.append("* Nick name cannot be blank.\n"); } - if (this.serverIPHostNameTextField.getText().isBlank()) { + + if(serverIPHostNameTextField.getText().isBlank()) + { errors.append("* Server IP cannot be empty.\n"); } + int port = -1; - try { - port = Integer.parseInt(this.serverPortTextField.getText()); - if (port < 1024) { + try + { + port = Integer.parseInt(serverPortTextField.getText()); + + if(port < 1024) 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"); - } } - catch (NumberFormatException exception) { + catch (NumberFormatException exception) + { errors.append("* Server Port should be a number.\n"); } - if (errors.toString().isEmpty()) { - try { - Config.getInstance().setNickName(this.clientNicknameTextField.getText()); - Config.getInstance().setServerHostNameOrIP(this.serverIPHostNameTextField.getText()); + + if(errors.toString().isEmpty()) + { + try + { + Config.getInstance().setNickName(clientNicknameTextField.getText()); + Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText()); Config.getInstance().setServerPort(port); Config.getInstance().setFirstTimeUse(false); - if (ClientInfo.getInstance().isPhone()) { + + if(ClientInfo.getInstance().isPhone()) + { Config.getInstance().setScreenMoverEnabled(true); } + Config.getInstance().save(); - final ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath() + "/" + Config.getInstance().getStartupProfileID() + ".xml"), Config.getInstance().getIconsPath()); - final int pre = clientProfile.getActionSize() + clientProfile.getActionGap() * 4; - this.rowsToSet = (int)(this.clientListener.getStageHeight() / pre); - this.colsToSet = (int)(this.clientListener.getStageWidth() / pre); - if (ClientInfo.getInstance().isPhone()) { + + ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+ + Config.getInstance().getStartupProfileID()+".xml"), Config.getInstance().getIconsPath()); + + int pre = clientProfile.getActionSize()+(clientProfile.getActionGap()*4); + + + rowsToSet = (int) (clientListener.getStageHeight()/pre); + colsToSet = (int) (clientListener.getStageWidth()/pre); + + if(ClientInfo.getInstance().isPhone()) + { OrientationService.create().ifPresent(orientationService -> { - if (orientationService.getOrientation().isPresent() && orientationService.getOrientation().get().equals((Object)Orientation.VERTICAL)) { - final int tmp = this.rowsToSet; - this.rowsToSet = this.colsToSet; - this.colsToSet = tmp; + if(orientationService.getOrientation().isPresent() && + orientationService.getOrientation().get().equals(Orientation.VERTICAL)) + { + int tmp = rowsToSet; + rowsToSet = colsToSet; + colsToSet = tmp; } - return; }); } - clientProfile.setCols(this.colsToSet); - clientProfile.setRows(this.rowsToSet); + + clientProfile.setCols(colsToSet); + clientProfile.setRows(rowsToSet); + clientProfile.saveProfileDetails(); - Platform.runLater(() -> { - this.clientListener.init(); - this.clientListener.setupClientConnection(); + + Platform.runLater(()-> { + clientListener.init(); + clientListener.setupClientConnection(); }); } - catch (Exception e) { + catch(Exception e) + { e.printStackTrace(); - this.exceptionAndAlertHandler.handleSevereException(new SevereException(e.getMessage())); + exceptionAndAlertHandler.handleSevereException(new SevereException(e.getMessage())); } } - else { - Platform.runLater(() -> this.nextButton.setDisable(false)); - new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n" + errors, StreamPiAlertType.ERROR).show(); + else + { + Platform.runLater(()->nextButton.setDisable(false)); + new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors, StreamPiAlertType.ERROR).show(); } } + + private int rowsToSet,colsToSet; } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java index e5099631..857be4fd 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java @@ -1,105 +1,142 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.firsttimeuse; -import javafx.event.ActionEvent; -import javafx.scene.layout.HBox; -import com.stream_pi.util.uihelper.SpaceFiller; -import javafx.scene.Node; -import javafx.scene.layout.Priority; -import javafx.scene.layout.StackPane; -import javafx.geometry.Insets; +import com.stream_pi.client.Main; import com.stream_pi.client.controller.ClientListener; import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.util.uihelper.SpaceFiller; + +import javafx.geometry.Insets; import javafx.scene.control.Button; import javafx.scene.control.Label; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; import javafx.scene.layout.VBox; +import javafx.scene.text.Font; + +public class FirstTimeUse extends VBox{ + + + public FirstTimeUse(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) + { + getStyleClass().add("first_time_use_pane"); + + setSpacing(10.0); + setPadding(new Insets(5)); + + headingLabel = new Label(); + headingLabel.getStyleClass().add("first_time_use_pane_heading_label"); + + StackPane stackPane = new StackPane(); + stackPane.getStyleClass().add("first_time_use_pane_stackpane"); + + VBox.setVgrow(stackPane, Priority.ALWAYS); + + nextButton = new Button("Next"); + nextButton.setOnAction(event-> onNextButtonClicked()); + + previousButton = new Button("Previous"); + previousButton.setOnAction(event-> onPreviousButtonClicked()); + + HBox buttonBar = new HBox(previousButton, SpaceFiller.horizontal(), nextButton); + buttonBar.getStyleClass().add("first_time_use_pane_button_bar"); + buttonBar.setSpacing(10.0); + + welcomePane = new WelcomePane(); + licensePane = new LicensePane(); + finalConfigPane = new FinalConfigPane(exceptionAndAlertHandler, clientListener, nextButton); + + stackPane.getChildren().addAll( + welcomePane, + licensePane, + finalConfigPane + ); + + getChildren().addAll(headingLabel, stackPane, buttonBar); + + setWindow(WindowName.WELCOME); + } -public class FirstTimeUse extends VBox -{ private Label headingLabel; private Button nextButton; private Button previousButton; private WelcomePane welcomePane; private LicensePane licensePane; private FinalConfigPane finalConfigPane; + private WindowName windowName; - - public FirstTimeUse(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener) { - this.getStyleClass().add((Object)"first_time_use_pane"); - this.setSpacing(10.0); - this.setPadding(new Insets(5.0)); - this.headingLabel = new Label(); - this.headingLabel.getStyleClass().add((Object)"first_time_use_pane_heading_label"); - final StackPane stackPane = new StackPane(); - stackPane.getStyleClass().add((Object)"first_time_use_pane_stackpane"); - VBox.setVgrow((Node)stackPane, Priority.ALWAYS); - (this.nextButton = new Button("Next")).setOnAction(event -> this.onNextButtonClicked()); - (this.previousButton = new Button("Previous")).setOnAction(event -> this.onPreviousButtonClicked()); - final HBox buttonBar = new HBox(new Node[] { (Node)this.previousButton, (Node)SpaceFiller.horizontal(), (Node)this.nextButton }); - buttonBar.getStyleClass().add((Object)"first_time_use_pane_button_bar"); - buttonBar.setSpacing(10.0); - this.welcomePane = new WelcomePane(); - this.licensePane = new LicensePane(); - this.finalConfigPane = new FinalConfigPane(exceptionAndAlertHandler, clientListener, this.nextButton); - stackPane.getChildren().addAll((Object[])new Node[] { (Node)this.welcomePane, (Node)this.licensePane, (Node)this.finalConfigPane }); - this.getChildren().addAll((Object[])new Node[] { (Node)this.headingLabel, (Node)stackPane, (Node)buttonBar }); - this.setWindow(WindowName.WELCOME); - } - - private void onNextButtonClicked() { - if (this.windowName == WindowName.WELCOME) { - this.setWindow(WindowName.LICENSE); + + private void onNextButtonClicked() + { + if(windowName == WindowName.WELCOME) + { + setWindow(WindowName.LICENSE); } - else if (this.windowName == WindowName.LICENSE) { - this.setWindow(WindowName.FINAL); + else if(windowName == WindowName.LICENSE) + { + setWindow(WindowName.FINAL); } } - - private void onPreviousButtonClicked() { - this.nextButton.setText("Next"); - if (this.windowName == WindowName.FINAL) { - this.setWindow(WindowName.LICENSE); + + private void onPreviousButtonClicked() + { + nextButton.setText("Next"); + + if(windowName == WindowName.FINAL) + { + setWindow(WindowName.LICENSE); } - else if (this.windowName == WindowName.LICENSE) { - this.setWindow(WindowName.WELCOME); + else if(windowName == WindowName.LICENSE) + { + setWindow(WindowName.WELCOME); } } - - private void setWindow(final WindowName windowName) { - if (windowName == WindowName.WELCOME) { + + private void setWindow(WindowName windowName) + { + if (windowName == WindowName.WELCOME) + { this.windowName = WindowName.WELCOME; - this.welcomePane.toFront(); - this.welcomePane.setVisible(true); - this.licensePane.setVisible(false); - this.finalConfigPane.setVisible(false); - this.headingLabel.setText(""); - this.nextButton.setText("Next"); - this.nextButton.setOnAction(event -> this.onNextButtonClicked()); - this.previousButton.setVisible(false); + welcomePane.toFront(); + welcomePane.setVisible(true); + licensePane.setVisible(false); + finalConfigPane.setVisible(false); + + headingLabel.setText(""); + + nextButton.setText("Next"); + nextButton.setOnAction(event-> onNextButtonClicked()); + previousButton.setVisible(false); } - else if (windowName == WindowName.LICENSE) { + else if (windowName == WindowName.LICENSE) + { this.windowName = WindowName.LICENSE; - this.licensePane.toFront(); - this.welcomePane.setVisible(false); - this.licensePane.setVisible(true); - this.finalConfigPane.setVisible(false); - this.headingLabel.setText("License Agreement"); - this.nextButton.setText("Agree and Continue"); - this.nextButton.setOnAction(event -> this.onNextButtonClicked()); - this.previousButton.setVisible(true); + licensePane.toFront(); + welcomePane.setVisible(false); + licensePane.setVisible(true); + finalConfigPane.setVisible(false); + + headingLabel.setText("License Agreement"); + + nextButton.setText("Agree and Continue"); + nextButton.setOnAction(event-> onNextButtonClicked()); + previousButton.setVisible(true); } - else if (windowName == WindowName.FINAL) { + else if (windowName == WindowName.FINAL) + { this.windowName = WindowName.FINAL; - this.finalConfigPane.toFront(); - this.welcomePane.setVisible(false); - this.licensePane.setVisible(false); - this.finalConfigPane.setVisible(true); - this.headingLabel.setText("Finishing up ..."); - this.finalConfigPane.makeChangesToNextButton(); - this.previousButton.setVisible(true); + finalConfigPane.toFront(); + welcomePane.setVisible(false); + licensePane.setVisible(false); + finalConfigPane.setVisible(true); + + headingLabel.setText("Finishing up ..."); + + finalConfigPane.makeChangesToNextButton(); + previousButton.setVisible(true); } } + + + } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java index 43582863..aa35e97c 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java @@ -1,25 +1,24 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.firsttimeuse; -import javafx.scene.Node; -import javafx.scene.layout.Priority; -import javafx.beans.value.ObservableValue; -import javafx.scene.control.TextArea; import com.stream_pi.client.info.License; + +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; -public class LicensePane extends VBox -{ - public LicensePane() { - this.getStyleClass().add((Object)"first_time_use_pane_license"); - final TextArea licenseTextArea = new TextArea(License.getLicense()); +public class LicensePane extends VBox { + public LicensePane() + { + getStyleClass().add("first_time_use_pane_license"); + + TextArea licenseTextArea = new TextArea(License.getLicense()); licenseTextArea.setWrapText(false); licenseTextArea.setEditable(false); - licenseTextArea.prefWidthProperty().bind((ObservableValue)this.widthProperty()); - VBox.setVgrow((Node)licenseTextArea, Priority.ALWAYS); - this.getChildren().addAll((Object[])new Node[] { (Node)licenseTextArea }); + + licenseTextArea.prefWidthProperty().bind(widthProperty()); + VBox.setVgrow(licenseTextArea, Priority.ALWAYS); + + getChildren().addAll(licenseTextArea); } } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java index c14e19fa..cb0c59b0 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java @@ -1,29 +1,29 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.firsttimeuse; -import javafx.scene.Node; import javafx.geometry.Pos; import javafx.scene.control.Label; import javafx.scene.layout.VBox; -public class WelcomePane extends VBox -{ - public WelcomePane() { - this.getStyleClass().add((Object)"first_time_use_pane_welcome"); - final Label welcomeLabel = new Label("Welcome!"); +public class WelcomePane extends VBox{ + public WelcomePane() + { + getStyleClass().add("first_time_use_pane_welcome"); + + Label welcomeLabel = new Label("Welcome!"); welcomeLabel.setWrapText(true); welcomeLabel.setAlignment(Pos.CENTER); - welcomeLabel.getStyleClass().add((Object)"first_time_use_welcome_pane_welcome_label"); - final Label nextToContinue = new Label("Please click \"Next\" to start the Setup process"); + welcomeLabel.getStyleClass().add("first_time_use_welcome_pane_welcome_label"); + + Label nextToContinue = new Label("Please click \"Next\" to start the Setup process"); nextToContinue.setWrapText(true); nextToContinue.setAlignment(Pos.CENTER); - nextToContinue.getStyleClass().add((Object)"first_time_use_welcome_pane_next_to_continue_label"); - this.setAlignment(Pos.CENTER); - this.setSpacing(5.0); - this.getChildren().addAll((Object[])new Node[] { (Node)welcomeLabel, (Node)nextToContinue }); - this.setVisible(false); + nextToContinue.getStyleClass().add("first_time_use_welcome_pane_next_to_continue_label"); + + + setAlignment(Pos.CENTER); + setSpacing(5.0); + getChildren().addAll(welcomeLabel, nextToContinue); + + setVisible(false); } } diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java index 264b6353..84a8214f 100644 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java @@ -1,12 +1,5 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.firsttimeuse; -public enum WindowName -{ - WELCOME, - LICENSE, - FINAL; +public enum WindowName { + WELCOME, LICENSE, FINAL } diff --git a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java index f0a2d493..eaeaccbf 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java @@ -1,125 +1,173 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.settings.About; -import javafx.event.ActionEvent; -import javafx.scene.CacheHint; -import java.io.IOException; -import java.util.logging.Logger; -import javafx.beans.value.ObservableValue; -import java.lang.management.ManagementFactory; -import java.lang.management.GarbageCollectorMXBean; -import javafx.scene.layout.HBox; import com.stream_pi.action_api.ActionAPI; -import javafx.scene.control.Label; +import com.stream_pi.client.Main; +import com.stream_pi.client.controller.ClientListener; import com.stream_pi.client.info.ClientInfo; -import javafx.scene.control.Hyperlink; -import javafx.scene.layout.Priority; +import javafx.application.HostServices; import javafx.event.Event; -import javafx.scene.input.SwipeEvent; -import javafx.scene.control.TabPane; -import javafx.scene.Node; -import javafx.scene.control.Tab; -import javafx.scene.image.ImageView; -import javafx.scene.image.Image; -import java.util.Objects; -import com.stream_pi.client.Main; -import java.io.InputStream; -import javafx.geometry.Pos; +import javafx.event.EventHandler; import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.*; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.SwipeEvent; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; -import com.stream_pi.client.controller.ClientListener; -import javafx.scene.control.ScrollPane; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.management.ManagementFactory; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Objects; +import java.util.logging.Logger; public class AboutTab extends ScrollPane { private ClientListener clientListener; + private ContributorsTab contributorsTab; private VBox mainVBox; - - public AboutTab(final ClientListener clientListener) { + + public AboutTab(ClientListener clientListener) + { this.clientListener = clientListener; - this.getStyleClass().add((Object)"about_parent"); - this.setPadding(new Insets(5.0)); - this.mainVBox = new VBox(); - this.mainVBox.getStyleClass().add((Object)"about"); - this.mainVBox.setSpacing(5.0); - this.mainVBox.setAlignment(Pos.TOP_CENTER); - final Image appIcon = new Image((InputStream)Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))); - final ImageView appIconImageView = new ImageView(appIcon); - appIconImageView.setFitHeight(146.0); - appIconImageView.setFitWidth(132.0); - final Tab contributorsT = new Tab("Contributors"); - contributorsT.setContent((Node)(this.contributorsTab = new ContributorsTab())); - final TabPane tabPane = new TabPane(); + + getStyleClass().add("about_parent"); + + setPadding(new Insets(5)); + + mainVBox = new VBox(); + mainVBox.getStyleClass().add("about"); + mainVBox.setSpacing(5.0); + + + mainVBox.setAlignment(Pos.TOP_CENTER); + + Image appIcon = new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))); + ImageView appIconImageView = new ImageView(appIcon); + appIconImageView.setFitHeight(146); + appIconImageView.setFitWidth(132); + + + Tab contributorsT = new Tab("Contributors"); + contributorsTab = new ContributorsTab(); + contributorsT.setContent(contributorsTab); + + + TabPane tabPane = new TabPane(); tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); - tabPane.getStyleClass().add((Object)"settings_about_tab_internal"); + + tabPane.getStyleClass().add("settings_about_tab_internal"); tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); - tabPane.setMaxWidth(600.0); - VBox.setVgrow((Node)tabPane, Priority.ALWAYS); - final Tab licenseTab = new Tab("License"); - licenseTab.setContent((Node)new LicenseTab()); - final Tab contactTab = new Tab("Contact"); - contactTab.setContent((Node)new ContactTab(clientListener)); - tabPane.getTabs().addAll((Object[])new Tab[] { licenseTab, contributorsT, contactTab }); - final Hyperlink donateButton = new Hyperlink("DONATE"); - donateButton.setOnAction(event -> this.openWebpage("https://www.patreon.com/streampi")); - donateButton.getStyleClass().add((Object)"about_donate_hyperlink"); - final ClientInfo clientInfo = ClientInfo.getInstance(); - final Label versionText = new Label(clientInfo.getVersion().getText() + " - " + clientInfo.getPlatform().getUIName() + " - " + clientInfo.getReleaseStatus().getUIName()); - versionText.getStyleClass().add((Object)"about_version_label"); - final Label commStandardLabel = new Label("Comm Standard " + clientInfo.getCommStandardVersion().getText()); - commStandardLabel.getStyleClass().add((Object)"about_comm_standard_label"); - final Label minThemeAPILabel = new Label("Min ThemeAPI " + clientInfo.getMinThemeSupportVersion().getText()); - minThemeAPILabel.getStyleClass().add((Object)"about_min_theme_api_label"); - final Label minActionAPILabel = new Label("Min ActionAPI " + clientInfo.getMinPluginSupportVersion().getText()); - minActionAPILabel.getStyleClass().add((Object)"about_min_action_api_label"); - final Label currentActionAPILabel = new Label("ActionAPI " + ActionAPI.API_VERSION.getText()); - currentActionAPILabel.getStyleClass().add((Object)"about_current_action_api_label"); - final HBox hBox1 = new HBox(new Node[] { (Node)versionText }); + tabPane.setMaxWidth(600); + VBox.setVgrow(tabPane, Priority.ALWAYS); + + Tab licenseTab = new Tab("License"); + licenseTab.setContent(new LicenseTab()); + + + + Tab contactTab = new Tab("Contact"); + contactTab.setContent(new ContactTab(clientListener)); + + tabPane.getTabs().addAll(licenseTab, contributorsT, contactTab); + + + Hyperlink donateButton = new Hyperlink("DONATE"); + donateButton.setOnAction(event -> openWebpage("https://www.patreon.com/streampi")); + donateButton.getStyleClass().add("about_donate_hyperlink"); + + + ClientInfo clientInfo = ClientInfo.getInstance(); + + Label versionText = new Label(clientInfo.getVersion().getText() + " - "+ clientInfo.getPlatform().getUIName() + " - "+ clientInfo.getReleaseStatus().getUIName()); + versionText.getStyleClass().add("about_version_label"); + + Label commStandardLabel = new Label("Comm Standard "+clientInfo.getCommStandardVersion().getText()); + commStandardLabel.getStyleClass().add("about_comm_standard_label"); + + Label minThemeAPILabel = new Label("Min ThemeAPI "+clientInfo.getMinThemeSupportVersion().getText()); + minThemeAPILabel.getStyleClass().add("about_min_theme_api_label"); + + Label minActionAPILabel = new Label("Min ActionAPI "+clientInfo.getMinPluginSupportVersion().getText()); + minActionAPILabel.getStyleClass().add("about_min_action_api_label"); + + Label currentActionAPILabel = new Label("ActionAPI "+ ActionAPI.API_VERSION.getText()); + currentActionAPILabel.getStyleClass().add("about_current_action_api_label"); + + HBox hBox1 = new HBox(versionText); + hBox1.setAlignment(Pos.CENTER); - hBox1.setSpacing(10.0); - final Label javaVersionLabel = new Label("Java " + System.getProperty("java.version")); - javaVersionLabel.getStyleClass().add((Object)"about_java_version"); - final Label javafxVersionLabel = new Label("JavaFX " + System.getProperty("javafx.version")); - javafxVersionLabel.getStyleClass().add((Object)"about_javafx_version"); - final Label javaGCLabel = new Label("GC: " + ManagementFactory.getGarbageCollectorMXBeans().get(0).getName()); - javaGCLabel.getStyleClass().add((Object)"about_java_gc"); - final HBox hBox2 = new HBox(new Node[] { (Node)javaVersionLabel, (Node)this.getSep(), (Node)javafxVersionLabel }); + hBox1.setSpacing(10); + + Label javaVersionLabel = new Label("Java "+System.getProperty("java.version")); + javaVersionLabel.getStyleClass().add("about_java_version"); + + Label javafxVersionLabel = new Label("JavaFX "+System.getProperty("javafx.version")); + javafxVersionLabel.getStyleClass().add("about_javafx_version"); + + Label javaGCLabel = new Label("GC: "+ ManagementFactory.getGarbageCollectorMXBeans().get(0).getName()); + javaGCLabel.getStyleClass().add("about_java_gc"); + + HBox hBox2 = new HBox(javaVersionLabel, getSep(), + javafxVersionLabel); + hBox2.setAlignment(Pos.CENTER); - hBox2.setSpacing(10.0); - final Label disclaimerLabel = new Label("This contributor list shows only those who have contributed to the Client Source code.\nTo know about the contributors of Action API, Theme API, Util, visit the respective repositories. If you want to know about the Core Team instead, please visit the website."); - disclaimerLabel.getStyleClass().add((Object)"about_license_contributors_disclaimer_label"); - disclaimerLabel.prefWidthProperty().bind((ObservableValue)tabPane.widthProperty()); + hBox2.setSpacing(10); + + + Label disclaimerLabel = new Label("This contributor list shows only those who have contributed " + + "to the Client Source code.\nTo know about the contributors of Action API, Theme API, Util, " + + "visit the respective repositories. If you want to know about the Core Team instead, please visit the website."); + + disclaimerLabel.getStyleClass().add("about_license_contributors_disclaimer_label"); + + disclaimerLabel.prefWidthProperty().bind(tabPane.widthProperty()); + disclaimerLabel.setWrapText(true); - this.mainVBox.getChildren().addAll((Object[])new Node[] { (Node)appIconImageView, (Node)tabPane, (Node)disclaimerLabel, (Node)donateButton, (Node)hBox1, (Node)hBox2, (Node)javaGCLabel }); - this.mainVBox.prefWidthProperty().bind((ObservableValue)this.widthProperty().subtract(30)); - this.setContent((Node)this.mainVBox); - final InputStream inputStream = Main.class.getResourceAsStream("build-date"); - if (inputStream != null) { - try { - Logger.getLogger(this.getClass().getName()).info("build-date present"); - final Label buildDateLabel = new Label("Build date/time: " + new String(inputStream.readAllBytes())); - buildDateLabel.getStyleClass().add((Object)"build-date-label"); - this.mainVBox.getChildren().add((Object)buildDateLabel); + + + mainVBox.getChildren().addAll(appIconImageView, tabPane, disclaimerLabel, + donateButton, hBox1, hBox2,javaGCLabel); + mainVBox.prefWidthProperty().bind(widthProperty().subtract(30)); + + setContent(mainVBox); + + InputStream inputStream = Main.class.getResourceAsStream("build-date"); + if(inputStream != null) + { + try + { + Logger.getLogger(getClass().getName()).info("build-date present"); + Label buildDateLabel = new Label("Build date/time: " + new String(inputStream.readAllBytes())); + buildDateLabel.getStyleClass().add("build-date-label"); + mainVBox.getChildren().add(buildDateLabel); } - catch (IOException e) { - Logger.getLogger(this.getClass().getName()).info("build-date not present"); + catch (IOException e) + { + Logger.getLogger(getClass().getName()).info("build-date not present"); } } - this.setCache(true); - this.setCacheHint(CacheHint.SPEED); + + setCache(true); + setCacheHint(CacheHint.SPEED); } - - private Label getSep() { - final Label label = new Label("|"); - label.getStyleClass().add((Object)"separator_ui_label"); + + private Label getSep() + { + Label label = new Label("|"); + label.getStyleClass().add("separator_ui_label"); return label; } - - public void openWebpage(final String url) { - this.clientListener.openURL(url); + + public void openWebpage(String url) + { + clientListener.openURL(url); } } diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java index 7f2425bd..04005b2b 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java @@ -1,40 +1,50 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.settings.About; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.info.ClientInfo; import com.stream_pi.util.contactlinks.ContactLinks; -import javafx.event.ActionEvent; -import javafx.scene.layout.VBox; -import javafx.scene.Node; +import javafx.application.HostServices; import javafx.scene.control.Hyperlink; -import com.stream_pi.client.controller.ClientListener; import javafx.scene.control.ScrollPane; +import javafx.scene.layout.VBox; + public class ContactTab extends ScrollPane { private ClientListener clientListener; - - public ContactTab(final ClientListener clientListener) { + + public ContactTab(ClientListener clientListener) + { this.clientListener = clientListener; - this.getStyleClass().add((Object)"about_contact_tab_scroll_pane"); - final Hyperlink github = new Hyperlink("GitHub"); - github.setOnAction(event -> this.openWebpage(ContactLinks.getGitHub())); - final Hyperlink discord = new Hyperlink("Discord"); - discord.setOnAction(event -> this.openWebpage(ContactLinks.getDiscord())); - final Hyperlink website = new Hyperlink("Website"); - website.setOnAction(event -> this.openWebpage(ContactLinks.getWebsite())); - final Hyperlink twitter = new Hyperlink("Twitter"); - twitter.setOnAction(event -> this.openWebpage(ContactLinks.getTwitter())); - final Hyperlink matrix = new Hyperlink("Matrix"); - matrix.setOnAction(event -> this.openWebpage(ContactLinks.getMatrix())); - final VBox vBox = new VBox(new Node[] { (Node)github, (Node)discord, (Node)website, (Node)twitter, (Node)matrix }); + + getStyleClass().add("about_contact_tab_scroll_pane"); + + Hyperlink github = new Hyperlink("GitHub"); + github.setOnAction(event -> openWebpage(ContactLinks.getGitHub())); + + Hyperlink discord = new Hyperlink("Discord"); + discord.setOnAction(event -> openWebpage(ContactLinks.getDiscord())); + + Hyperlink website = new Hyperlink("Website"); + website.setOnAction(event -> openWebpage(ContactLinks.getWebsite())); + + Hyperlink twitter = new Hyperlink("Twitter"); + twitter.setOnAction(event -> openWebpage(ContactLinks.getTwitter())); + + Hyperlink matrix = new Hyperlink("Matrix"); + matrix.setOnAction(event -> openWebpage(ContactLinks.getMatrix())); + + + VBox vBox = new VBox(github, discord, website, twitter, matrix); vBox.setSpacing(10.0); - this.setContent((Node)vBox); + + setContent(vBox); } - - public void openWebpage(final String url) { - this.clientListener.openURL(url); + + + public void openWebpage(String url) + { + clientListener.openURL(url); } + } diff --git a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java index 06f68a19..03258429 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java @@ -1,56 +1,49 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.settings.About; public class Contributor { - public String name; - public String email; - public String description; - public String location; - - public Contributor(final String name, final String email, final String description, final String location) { - this.name = null; - this.email = null; - this.description = null; - this.location = null; + public String name = null; + public String email = null; + public String description = null; + public String location = null; + + public Contributor(String name, String email, String description, String location) + { this.name = name; this.email = email; this.description = description; this.location = location; } - - public void setName(final String name) { + + public void setName(String name) { this.name = name; } - - public void setEmail(final String email) { + + public void setEmail(String email) { this.email = email; } - - public void setDescription(final String description) { + + public void setDescription(String description) { this.description = description; } - + public String getName() { - return this.name; + return name; } - + public String getEmail() { - return this.email; + return email; } - + public String getDescription() { - return this.description; + return description; } - + public String getLocation() { - return this.location; + return location; } - - public void setLocation(final String location) { + + public void setLocation(String location) { this.location = location; } -} +} \ No newline at end of file diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java index b463413b..4a69636e 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java @@ -1,54 +1,76 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.settings.About; import javafx.scene.CacheHint; -import javafx.scene.Node; -import javafx.util.Callback; -import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.control.Label; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; +import javafx.scene.control.cell.PropertyValueFactory; import javafx.scene.layout.VBox; public class ContributorsTab extends VBox { TableView tableView; - - public ContributorsTab() { - this.getStyleClass().add((Object)"about_license_contributors_vbox"); - this.tableView = (TableView)new TableView(); - this.tableView.getStyleClass().add((Object)"about_license_contributors_table_view"); - final TableColumn descriptionColumn = (TableColumn)new TableColumn("Description"); + + public ContributorsTab() + { + getStyleClass().add("about_license_contributors_vbox"); + + tableView = new TableView<>(); + tableView.getStyleClass().add("about_license_contributors_table_view"); + + TableColumn descriptionColumn = new TableColumn<>("Description"); descriptionColumn.setReorderable(false); - descriptionColumn.setPrefWidth(250.0); + descriptionColumn.setPrefWidth(250); descriptionColumn.setResizable(false); - descriptionColumn.setCellValueFactory((Callback)new PropertyValueFactory("description")); - final TableColumn nameColumn = (TableColumn)new TableColumn("Name (GitHub)"); + descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description")); + + TableColumn nameColumn = new TableColumn<>("Name (GitHub)"); nameColumn.setReorderable(false); - nameColumn.setPrefWidth(220.0); + nameColumn.setPrefWidth(220); nameColumn.setResizable(false); - nameColumn.setCellValueFactory((Callback)new PropertyValueFactory("name")); - final TableColumn emailColumn = (TableColumn)new TableColumn("Email"); + nameColumn.setCellValueFactory(new PropertyValueFactory<>("name")); + + TableColumn emailColumn = new TableColumn<>("Email"); emailColumn.setReorderable(false); - emailColumn.setPrefWidth(200.0); + emailColumn.setPrefWidth(200); emailColumn.setResizable(false); - emailColumn.setCellValueFactory((Callback)new PropertyValueFactory("email")); - final TableColumn locationColumn = (TableColumn)new TableColumn("Location"); + emailColumn.setCellValueFactory(new PropertyValueFactory<>("email")); + + TableColumn locationColumn = new TableColumn<>("Location"); locationColumn.setReorderable(false); - locationColumn.setPrefWidth(100.0); + locationColumn.setPrefWidth(100); locationColumn.setResizable(false); - locationColumn.setCellValueFactory((Callback)new PropertyValueFactory("location")); - this.tableView.getColumns().addAll((Object[])new TableColumn[] { descriptionColumn, nameColumn, emailColumn, locationColumn }); - this.tableView.setPrefWidth(descriptionColumn.getPrefWidth() + nameColumn.getPrefWidth() + emailColumn.getPrefWidth()); - this.tableView.getItems().addAll((Object[])new Contributor[] { new Contributor("Debayan Sutradhar (rnayabed)", "debayansutradhar3@gmail.com", "Founder, Author, Maintainer", "India"), new Contributor("Samuel Qui\u00f1ones (SamuelQuinones)", "sdquinones1@gmail.com", "Founder", "United States"), new Contributor("Abhinay Agarwal (abhinayagarwal)", "abhinay_agarwal@live.com", "Refactoring, Fixes", "India") }); - this.getChildren().addAll((Object[])new Node[] { (Node)this.tableView }); - this.setCache(true); - this.setCacheHint(CacheHint.SPEED); + locationColumn.setCellValueFactory(new PropertyValueFactory<>("location")); + + + tableView.getColumns().addAll(descriptionColumn, nameColumn, emailColumn, locationColumn); + + tableView.setPrefWidth(descriptionColumn.getPrefWidth() + nameColumn.getPrefWidth() + emailColumn.getPrefWidth()); + + tableView.getItems().addAll( + new Contributor("Debayan Sutradhar (rnayabed)", + "debayansutradhar3@gmail.com", + "Founder, Author, Maintainer", + "India"), + new Contributor("Samuel Quiñones (SamuelQuinones)", + "sdquinones1@gmail.com", + "Founder", + "United States"), + new Contributor("Abhinay Agarwal (abhinayagarwal)", + "abhinay_agarwal@live.com", + "Refactoring, Fixes", + "India") + ); + + getChildren().addAll(tableView); + + + setCache(true); + setCacheHint(CacheHint.SPEED); } - - public TableView getTableView() { - return this.tableView; + + public TableView getTableView() + { + return tableView; } } diff --git a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java index 61928bbe..88ab9746 100644 --- a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java @@ -1,18 +1,16 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.settings.About; + import com.stream_pi.client.info.License; import javafx.scene.control.TextArea; public class LicenseTab extends TextArea { - public LicenseTab() { - this.setText(License.getLicense()); - this.getStyleClass().add((Object)"about_license_text_area"); - this.setWrapText(false); - this.setEditable(false); + public LicenseTab() + { + setText(License.getLicense()); + getStyleClass().add("about_license_text_area"); + setWrapText(false); + setEditable(false); } } diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java index 6efc4346..5100fd89 100644 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -1,511 +1,743 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.settings; import com.gluonhq.attach.vibration.VibrationService; -import com.stream_pi.util.startatboot.StartAtBoot; import com.stream_pi.client.Main; -import com.stream_pi.util.exception.MinorException; +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 javafx.application.Platform; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.alert.StreamPiAlertListener; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.theme_api.Theme; import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertListener; import com.stream_pi.util.alert.StreamPiAlertType; -import javafx.event.Event; -import javafx.event.ActionEvent; -import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick; -import com.stream_pi.util.platform.PlatformType; import com.stream_pi.util.checkforupdates.CheckForUpdates; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.info.ClientInfo; -import javafx.scene.CacheHint; -import javafx.geometry.Pos; -import javafx.scene.layout.Priority; -import javafx.scene.control.ScrollPane; -import javafx.geometry.Insets; -import com.stream_pi.util.uihelper.SpaceFiller; -import javafx.scene.control.Label; -import javafx.scene.layout.HBox; -import javafx.beans.value.ObservableValue; -import javafx.scene.Node; -import com.stream_pi.util.combobox.StreamPiComboBoxListener; +import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick; +import com.stream_pi.util.combobox.StreamPiComboBox; import com.stream_pi.util.combobox.StreamPiComboBoxFactory; -import java.util.Arrays; -import java.util.List; +import com.stream_pi.util.combobox.StreamPiComboBoxListener; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.platform.Platform; +import com.stream_pi.util.platform.PlatformType; +import com.stream_pi.util.startatboot.StartAtBoot; import com.stream_pi.util.uihelper.HBoxInputBox; -import java.util.logging.Logger; -import org.controlsfx.control.ToggleSwitch; import com.stream_pi.util.uihelper.HBoxWithSpaceBetween; -import javafx.scene.control.Button; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.util.combobox.StreamPiComboBox; -import javafx.scene.control.TextField; +import com.stream_pi.util.uihelper.SpaceFiller; import javafx.application.HostServices; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.window.ExceptionAndAlertHandler; +import javafx.event.ActionEvent; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.*; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; +import org.controlsfx.control.ToggleSwitch; + +import java.io.File; +import java.net.URISyntaxException; +import java.util.logging.Logger; public class GeneralTab extends VBox { private ExceptionAndAlertHandler exceptionAndAlertHandler; private ClientListener clientListener; private HostServices hostServices; + private TextField serverPortTextField; private TextField serverHostNameOrIPTextField; + private TextField screenTimeoutTextField; + private StreamPiComboBox clientProfileComboBox; private StreamPiComboBox themeComboBox; - private StreamPiComboBox animationComboBox; + private TextField nickNameTextField; + private Button saveButton; private Button connectDisconnectButton; private Button shutdownButton; + private HBoxWithSpaceBetween startOnBootHBox; private ToggleSwitch startOnBootToggleSwitch; + private HBoxWithSpaceBetween screenSaverHBox; private ToggleSwitch screenSaverToggleSwitch; + private HBoxWithSpaceBetween screenMoverHBox; private ToggleSwitch screenMoverToggleSwitch; + private HBoxWithSpaceBetween tryConnectingToServerIfActionClickedHBox; private ToggleSwitch tryConnectingToServerIfActionClickedToggleSwitch; + private HBoxWithSpaceBetween connectOnStartupHBox; private ToggleSwitch connectOnStartupToggleSwitch; + private HBoxWithSpaceBetween vibrateOnActionPressHBox; private ToggleSwitch vibrateOnActionPressToggleSwitch; + private HBoxWithSpaceBetween fullScreenModeHBox; private ToggleSwitch fullScreenModeToggleSwitch; + private HBoxWithSpaceBetween showCursorHBox; private ToggleSwitch showCursorToggleSwitch; + private HBoxWithSpaceBetween invertRowsColsHBox; private ToggleSwitch invertRowsColsToggleSwitch; + private TextField themesPathTextField; private TextField iconsPathTextField; private TextField profilesPathTextField; + private final Button factoryResetButton; + private Logger logger; + + private final Button checkForUpdatesButton; + private HBoxInputBox screenTimeoutSecondsHBoxInputBox; - private List animationList; - - public GeneralTab(final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener, final HostServices hostServices) { - this.animationList = Arrays.asList("None", "Bounce", "Flip", "Jack In The Box", "Jello", "Pulse", "RubberBand", "Shake", "Swing", "Tada", "Wobble"); + + public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler, + ClientListener clientListener, HostServices hostServices) + { this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.clientListener = clientListener; this.hostServices = hostServices; - this.logger = Logger.getLogger(""); - this.serverPortTextField = new TextField(); - this.screenTimeoutTextField = new TextField(); - this.serverHostNameOrIPTextField = new TextField(); - this.nickNameTextField = new TextField(); - (this.clientProfileComboBox = (StreamPiComboBox)new StreamPiComboBox()).setStreamPiComboBoxFactory((StreamPiComboBoxFactory)new StreamPiComboBoxFactory() { - public String getOptionDisplayText(final ClientProfile object) { + + logger = Logger.getLogger(""); + + serverPortTextField = new TextField(); + screenTimeoutTextField = new TextField(); + + + serverHostNameOrIPTextField = new TextField(); + nickNameTextField = new TextField(); + + clientProfileComboBox = new StreamPiComboBox<>(); + + clientProfileComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(ClientProfile object) + { return object.getName(); } }); - (this.animationComboBox = (StreamPiComboBox)new StreamPiComboBox()).setStreamPiComboBoxFactory((StreamPiComboBoxFactory)new StreamPiComboBoxFactory() { - public String getOptionDisplayText(final String object) { - return object; - } - }); - this.clientProfileComboBox.setStreamPiComboBoxListener((StreamPiComboBoxListener)new StreamPiComboBoxListener() { - public void onNewItemSelected(final ClientProfile selectedItem) { + + clientProfileComboBox.setStreamPiComboBoxListener(new StreamPiComboBoxListener(){ + @Override + public void onNewItemSelected(ClientProfile selectedItem) + { clientListener.renderProfile(selectedItem, true); } }); - (this.themeComboBox = (StreamPiComboBox)new StreamPiComboBox()).setStreamPiComboBoxFactory((StreamPiComboBoxFactory)new StreamPiComboBoxFactory() { - public String getOptionDisplayText(final Theme object) { + + + themeComboBox = new StreamPiComboBox<>(); + themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(Theme object) + { return object.getShortName(); } }); - this.themesPathTextField = new TextField(); - this.iconsPathTextField = new TextField(); - this.profilesPathTextField = new TextField(); - this.startOnBootToggleSwitch = new ToggleSwitch(); - this.startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", (Node)this.startOnBootToggleSwitch); - this.startOnBootHBox.managedProperty().bind((ObservableValue)this.startOnBootHBox.visibleProperty()); - this.screenSaverToggleSwitch = new ToggleSwitch(); - this.screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", (Node)this.screenSaverToggleSwitch); - this.screenSaverHBox.managedProperty().bind((ObservableValue)this.screenSaverHBox.visibleProperty()); - this.screenMoverToggleSwitch = new ToggleSwitch(); - this.screenMoverHBox = new HBoxWithSpaceBetween("OLED Burn-In Protector", (Node)this.screenMoverToggleSwitch); - this.screenMoverHBox.managedProperty().bind((ObservableValue)this.screenMoverHBox.visibleProperty()); - this.tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch(); - this.tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", (Node)this.tryConnectingToServerIfActionClickedToggleSwitch); - this.tryConnectingToServerIfActionClickedHBox.managedProperty().bind((ObservableValue)this.tryConnectingToServerIfActionClickedHBox.visibleProperty()); - this.fullScreenModeToggleSwitch = new ToggleSwitch(); - this.fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", (Node)this.fullScreenModeToggleSwitch); - this.fullScreenModeHBox.managedProperty().bind((ObservableValue)this.fullScreenModeHBox.visibleProperty()); - this.vibrateOnActionPressToggleSwitch = new ToggleSwitch(); - this.vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", (Node)this.vibrateOnActionPressToggleSwitch); - this.vibrateOnActionPressHBox.managedProperty().bind((ObservableValue)this.vibrateOnActionPressHBox.visibleProperty()); - this.connectOnStartupToggleSwitch = new ToggleSwitch(); - this.connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", (Node)this.connectOnStartupToggleSwitch); - this.connectOnStartupHBox.managedProperty().bind((ObservableValue)this.connectOnStartupHBox.visibleProperty()); - this.showCursorToggleSwitch = new ToggleSwitch(); - this.showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", (Node)this.showCursorToggleSwitch); - this.showCursorHBox.managedProperty().bind((ObservableValue)this.showCursorHBox.visibleProperty()); - this.invertRowsColsToggleSwitch = new ToggleSwitch(); - this.invertRowsColsHBox = new HBoxWithSpaceBetween("Invert Grid on Rotate", (Node)this.invertRowsColsToggleSwitch); - this.invertRowsColsHBox.managedProperty().bind((ObservableValue)this.invertRowsColsHBox.visibleProperty()); - final int prefWidth = 200; - final HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", this.themesPathTextField, prefWidth); - themesPathInputBox.managedProperty().bind((ObservableValue)themesPathInputBox.visibleProperty()); - final HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", this.iconsPathTextField, prefWidth); - iconsPathInputBox.managedProperty().bind((ObservableValue)iconsPathInputBox.visibleProperty()); - final HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", this.profilesPathTextField, prefWidth); - profilesPathInputBox.managedProperty().bind((ObservableValue)profilesPathInputBox.visibleProperty()); - (this.checkForUpdatesButton = new Button("Check for updates")).setOnAction(event -> this.checkForUpdates()); - (this.factoryResetButton = new Button("Factory Reset")).setOnAction(actionEvent -> this.onFactoryResetButtonClicked()); - this.screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", this.screenTimeoutTextField, prefWidth); - this.screenTimeoutSecondsHBoxInputBox.managedProperty().bind((ObservableValue)this.screenTimeoutSecondsHBoxInputBox.visibleProperty()); - this.screenTimeoutTextField.disableProperty().bind((ObservableValue)this.screenSaverToggleSwitch.selectedProperty().not()); - (this.saveButton = new Button("Save")).setOnAction(event -> this.onSaveButtonClicked()); - (this.connectDisconnectButton = new Button("Connect")).setOnAction(event -> this.onConnectDisconnectButtonClicked()); - final Button exitButton = new Button("Exit"); - exitButton.setOnAction(event -> this.onExitButtonClicked()); - final HBox buttonBar = new HBox(new Node[] { (Node)this.connectDisconnectButton, (Node)this.saveButton }); - this.shutdownButton = new Button("Shutdown"); - this.shutdownButton.managedProperty().bind((ObservableValue)this.shutdownButton.visibleProperty()); - this.shutdownButton.setOnAction(event -> this.onShutdownButtonClicked()); - final VBox vBox = new VBox(new Node[] { (Node)this.generateSubHeading("Connection"), (Node)new HBoxInputBox("Device Name", this.nickNameTextField, prefWidth), (Node)new HBoxInputBox("Host Name/IP", this.serverHostNameOrIPTextField, prefWidth), (Node)new HBoxInputBox("Port", this.serverPortTextField, prefWidth), (Node)this.generateSubHeading("Client"), (Node)new HBox(new Node[] { (Node)new Label("Current profile"), (Node)SpaceFiller.horizontal(), (Node)this.clientProfileComboBox }), (Node)new HBox(new Node[] { (Node)new Label("Theme"), (Node)SpaceFiller.horizontal(), (Node)this.themeComboBox }), (Node)new HBox(new Node[] { (Node)new Label("Action Animation"), (Node)SpaceFiller.horizontal(), (Node)this.animationComboBox }), (Node)this.generateSubHeading("Others"), (Node)themesPathInputBox, (Node)iconsPathInputBox, (Node)profilesPathInputBox, (Node)this.screenTimeoutSecondsHBoxInputBox, (Node)this.invertRowsColsHBox, (Node)this.screenSaverHBox, (Node)this.screenMoverHBox, (Node)this.tryConnectingToServerIfActionClickedHBox, (Node)this.fullScreenModeHBox, (Node)this.connectOnStartupHBox, (Node)this.vibrateOnActionPressHBox, (Node)this.startOnBootHBox, (Node)this.showCursorHBox, (Node)this.checkForUpdatesButton, (Node)this.shutdownButton, (Node)this.factoryResetButton }); - vBox.getStyleClass().add((Object)"settings_base_vbox"); + + themesPathTextField = new TextField(); + iconsPathTextField = new TextField(); + profilesPathTextField = new TextField(); + + startOnBootToggleSwitch = new ToggleSwitch(); + startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", startOnBootToggleSwitch); + startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty()); + + screenSaverToggleSwitch = new ToggleSwitch(); + screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", screenSaverToggleSwitch); + screenSaverHBox.managedProperty().bind(screenSaverHBox.visibleProperty()); + + screenMoverToggleSwitch = new ToggleSwitch(); + screenMoverHBox = new HBoxWithSpaceBetween("OLED Burn-In Protector", screenMoverToggleSwitch); + screenMoverHBox.managedProperty().bind(screenMoverHBox.visibleProperty()); + + tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch(); + tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", tryConnectingToServerIfActionClickedToggleSwitch); + tryConnectingToServerIfActionClickedHBox.managedProperty().bind(tryConnectingToServerIfActionClickedHBox.visibleProperty()); + + fullScreenModeToggleSwitch = new ToggleSwitch(); + fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", fullScreenModeToggleSwitch); + fullScreenModeHBox.managedProperty().bind(fullScreenModeHBox.visibleProperty()); + + vibrateOnActionPressToggleSwitch = new ToggleSwitch(); + vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", vibrateOnActionPressToggleSwitch); + vibrateOnActionPressHBox.managedProperty().bind(vibrateOnActionPressHBox.visibleProperty()); + + connectOnStartupToggleSwitch = new ToggleSwitch(); + connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", connectOnStartupToggleSwitch); + connectOnStartupHBox.managedProperty().bind(connectOnStartupHBox.visibleProperty()); + + showCursorToggleSwitch = new ToggleSwitch(); + showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", showCursorToggleSwitch); + showCursorHBox.managedProperty().bind(showCursorHBox.visibleProperty()); + + invertRowsColsToggleSwitch = new ToggleSwitch(); + invertRowsColsHBox = new HBoxWithSpaceBetween("Invert Grid on Rotate", invertRowsColsToggleSwitch); + invertRowsColsHBox.managedProperty().bind(invertRowsColsHBox.visibleProperty()); + + int prefWidth = 200; + + HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", themesPathTextField, prefWidth); + themesPathInputBox.managedProperty().bind(themesPathInputBox.visibleProperty()); + + + HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", iconsPathTextField, prefWidth); + iconsPathInputBox.managedProperty().bind(iconsPathInputBox.visibleProperty()); + + + HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", profilesPathTextField, prefWidth); + profilesPathInputBox.managedProperty().bind(profilesPathInputBox.visibleProperty()); + + checkForUpdatesButton = new Button("Check for updates"); + checkForUpdatesButton.setOnAction(event->checkForUpdates()); + + factoryResetButton = new Button("Factory Reset"); + factoryResetButton.setOnAction(actionEvent -> onFactoryResetButtonClicked()); + + + screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", screenTimeoutTextField, prefWidth); + screenTimeoutSecondsHBoxInputBox.managedProperty().bind(screenTimeoutSecondsHBoxInputBox.visibleProperty()); + screenTimeoutTextField.disableProperty().bind(screenSaverToggleSwitch.selectedProperty().not()); + + saveButton = new Button("Save"); + saveButton.setOnAction(event->onSaveButtonClicked()); + + connectDisconnectButton = new Button("Connect"); + connectDisconnectButton.setOnAction(event -> onConnectDisconnectButtonClicked()); + + + Button exitButton = new Button("Exit"); + exitButton.setOnAction(event -> onExitButtonClicked()); + + HBox buttonBar = new HBox(connectDisconnectButton, saveButton); + + shutdownButton = new Button("Shutdown"); + shutdownButton.managedProperty().bind(shutdownButton.visibleProperty()); + shutdownButton.setOnAction(event -> onShutdownButtonClicked()); + + + VBox vBox = new VBox( + generateSubHeading("Connection"), + new HBoxInputBox("Device Name", nickNameTextField, prefWidth), + new HBoxInputBox("Host Name/IP", serverHostNameOrIPTextField, prefWidth), + new HBoxInputBox("Port", serverPortTextField, prefWidth), + generateSubHeading("Client"), + new HBox( + new Label("Current profile"), + SpaceFiller.horizontal(), + clientProfileComboBox + ), + new HBox( + new Label("Theme"), + SpaceFiller.horizontal(), + themeComboBox + ), + generateSubHeading("Others"), + themesPathInputBox, + iconsPathInputBox, + profilesPathInputBox, + screenTimeoutSecondsHBoxInputBox, + invertRowsColsHBox, + screenSaverHBox, + screenMoverHBox, + tryConnectingToServerIfActionClickedHBox, + fullScreenModeHBox, + connectOnStartupHBox, + vibrateOnActionPressHBox, + startOnBootHBox, + showCursorHBox, + checkForUpdatesButton, + shutdownButton, + factoryResetButton + ); + + + vBox.getStyleClass().add("settings_base_vbox"); + vBox.setSpacing(10.0); - vBox.setPadding(new Insets(5.0)); - final ScrollPane scrollPane = new ScrollPane(); + vBox.setPadding(new Insets(5)); + + ScrollPane scrollPane = new ScrollPane(); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); - VBox.setVgrow((Node)scrollPane, Priority.ALWAYS); - scrollPane.getStyleClass().add((Object)"settings_base_scroll_pane"); - scrollPane.setContent((Node)vBox); - vBox.setMinWidth(300.0); - vBox.prefWidthProperty().bind((ObservableValue)scrollPane.widthProperty().subtract(30)); - buttonBar.getStyleClass().add((Object)"settings_button_bar"); - buttonBar.setPadding(new Insets(0.0, 5.0, 5.0, 0.0)); + VBox.setVgrow(scrollPane, Priority.ALWAYS); + scrollPane.getStyleClass().add("settings_base_scroll_pane"); + scrollPane.setContent(vBox); + + vBox.setMinWidth(300); + + vBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(30)); + + + buttonBar.getStyleClass().add("settings_button_bar"); + + + buttonBar.setPadding(new Insets(0,5,5,0)); buttonBar.setSpacing(5.0); buttonBar.setAlignment(Pos.CENTER_RIGHT); - this.setSpacing(10.0); - this.getChildren().addAll((Object[])new Node[] { (Node)scrollPane, (Node)buttonBar }); - this.setCache(true); - this.setCacheHint(CacheHint.SPEED); - if (ClientInfo.getInstance().isPhone()) { + + setSpacing(10.0); + + getChildren().addAll( + scrollPane, + buttonBar + ); + + setCache(true); + setCacheHint(CacheHint.SPEED); + + + //Perform platform checks + + if(ClientInfo.getInstance().isPhone()) + { themesPathInputBox.setVisible(false); iconsPathInputBox.setVisible(false); profilesPathInputBox.setVisible(false); - this.startOnBootHBox.setVisible(false); - this.showCursorHBox.setVisible(false); - this.fullScreenModeHBox.setVisible(false); - this.shutdownButton.setVisible(false); + + startOnBootHBox.setVisible(false); + showCursorHBox.setVisible(false); + fullScreenModeHBox.setVisible(false); + shutdownButton.setVisible(false); } - else { - this.invertRowsColsHBox.setVisible(false); - this.vibrateOnActionPressHBox.setVisible(false); - buttonBar.getChildren().add((Object)exitButton); - this.fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON); - this.shutdownButton.setVisible(StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON); + else + { + invertRowsColsHBox.setVisible(false); + vibrateOnActionPressHBox.setVisible(false); + buttonBar.getChildren().add(exitButton); + + + fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON); + + shutdownButton.setVisible(StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON); } - this.screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); - this.screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); + + + screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); + screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); } - - private Label generateSubHeading(final String text) { - final Label label = new Label(text); - label.getStyleClass().add((Object)"general_settings_sub_heading"); + + private Label generateSubHeading(String text) + { + Label label = new Label(text); + label.getStyleClass().add("general_settings_sub_heading"); return label; } - - private Logger getLogger() { - return this.logger; + + private Logger getLogger() + { + return logger; } - - private void checkForUpdates() { - new CheckForUpdates(this.checkForUpdatesButton, PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), (UpdateHyperlinkOnClick)new UpdateHyperlinkOnClick() { - public void handle(final ActionEvent actionEvent) { - if (ClientInfo.getInstance().isPhone()) { - GeneralTab.this.clientListener.openURL(this.getURL()); + + private void checkForUpdates() + { + new CheckForUpdates(checkForUpdatesButton, + PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() { + @Override + public void handle(ActionEvent actionEvent) { + if(ClientInfo.getInstance().isPhone()) + { + clientListener.openURL(getURL()); } - else { - GeneralTab.this.hostServices.showDocument(this.getURL()); + else + { + hostServices.showDocument(getURL()); } } }); } - - private void onFactoryResetButtonClicked() { - final StreamPiAlert confirmation = new StreamPiAlert("Warning", "Are you sure?\nThis will erase everything.", StreamPiAlertType.WARNING); - final String yesButton = "Yes"; - final String noButton = "No"; - confirmation.setButtons(new String[] { yesButton, noButton }); - confirmation.setOnClicked((StreamPiAlertListener)new StreamPiAlertListener() { - public void onClick(final String s) { - if (s.equals(yesButton)) { - GeneralTab.this.clientListener.factoryReset(); + + private void onFactoryResetButtonClicked() + { + StreamPiAlert confirmation = new StreamPiAlert("Warning","Are you sure?\n" + + "This will erase everything.",StreamPiAlertType.WARNING); + + String yesButton = "Yes"; + String noButton = "No"; + + confirmation.setButtons(yesButton, noButton); + + confirmation.setOnClicked(new StreamPiAlertListener() { + @Override + public void onClick(String s) { + if(s.equals(yesButton)) + { + clientListener.factoryReset(); } } }); + confirmation.show(); } - - public void onExitButtonClicked() { - this.clientListener.onCloseRequest(); - this.clientListener.exitApp(); + + + public void onExitButtonClicked() + { + clientListener.onCloseRequest(); + clientListener.exitApp(); } - - public void setDisableStatus(final boolean status) { - this.saveButton.setDisable(status); - this.connectDisconnectButton.setDisable(status); + + public void setDisableStatus(boolean status) + { + saveButton.setDisable(status); + connectDisconnectButton.setDisable(status); } - - public Button getConnectDisconnectButton() { - return this.connectDisconnectButton; + + public Button getConnectDisconnectButton() + { + return connectDisconnectButton; } - - public void onShutdownButtonClicked() { - this.clientListener.onCloseRequest(); - try { + + public void onShutdownButtonClicked() + { + clientListener.onCloseRequest(); + + try + { Runtime.getRuntime().exec("sudo halt"); } - catch (Exception e) { + catch (Exception e) + { e.printStackTrace(); } } - - public void onConnectDisconnectButtonClicked() { - try { - if (this.clientListener.isConnected()) { - this.clientListener.disconnect("Client disconnected from settings"); - } - else { - this.clientListener.setupClientConnection(); - } + + public void onConnectDisconnectButtonClicked() + { + try + { + if(clientListener.isConnected()) + clientListener.disconnect("Client disconnected from settings"); + else + clientListener.setupClientConnection(); } - catch (SevereException e) { + catch (SevereException e) + { e.printStackTrace(); - this.exceptionAndAlertHandler.handleSevereException(e); + exceptionAndAlertHandler.handleSevereException(e); } } - - public void setConnectDisconnectButtonStatus() { - Platform.runLater(() -> { - this.setDisableStatus(false); - if (this.clientListener.isConnected()) { - this.connectDisconnectButton.setText("Disconnect"); - } - else { - this.connectDisconnectButton.setText("Connect"); - } + + public void setConnectDisconnectButtonStatus() + { + javafx.application.Platform.runLater(()->{ + setDisableStatus(false); + + if(clientListener.isConnected()) + connectDisconnectButton.setText("Disconnect"); + else + connectDisconnectButton.setText("Connect"); }); + } - - public void loadData() throws SevereException { - final Config config = Config.getInstance(); - this.nickNameTextField.setText(config.getClientNickName()); - this.serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP()); - this.serverPortTextField.setText("" + config.getSavedServerPort()); - this.screenTimeoutTextField.setText("" + config.getScreenSaverTimeout()); - this.screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); - this.screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); - this.clientProfileComboBox.setOptions((List)this.clientListener.getClientProfiles().getClientProfiles()); - this.animationComboBox.setOptions((List)this.animationList); + + public void loadData() throws SevereException + { + Config config = Config.getInstance(); + + nickNameTextField.setText(config.getClientNickName()); + + serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP()); + serverPortTextField.setText(config.getSavedServerPort()+""); + + screenTimeoutTextField.setText(config.getScreenSaverTimeout()+""); + screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); + screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); + + clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles()); + int ind = 0; - for (int i = 0; i < this.clientProfileComboBox.getOptions().size(); ++i) { - if (this.clientProfileComboBox.getOptions().get(i).getID().equals(this.clientListener.getCurrentProfile().getID())) { + for(int i = 0;i 65535) { + else if(port > 65535) 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"); } + + int screenSaverTimeout = -1; - try { - screenSaverTimeout = Integer.parseInt(this.serverPortTextField.getText()); - if (screenSaverTimeout < 15) { + try + { + screenSaverTimeout = Integer.parseInt(serverPortTextField.getText()); + + if(screenSaverTimeout < 15) errors.append("* Screen Timeout cannot be below 15 seconds.\n"); - } } - catch (NumberFormatException exception2) { + catch (NumberFormatException exception) + { errors.append("* Screen Timeout should be a number.\n"); } - if (this.serverHostNameOrIPTextField.getText().isBlank()) { + + + if(serverHostNameOrIPTextField.getText().isBlank()) + { errors.append("* Server IP cannot be empty.\n"); } - if (this.nickNameTextField.getText().isBlank()) { + + if(nickNameTextField.getText().isBlank()) + { errors.append("* Nick name cannot be blank.\n"); } - else if (this.nickNameTextField.getText().equals("about maker")) { - new StreamPiAlert("\u0915\u093f\u0938\u0928\u0947 \u092c\u0928\u093e\u092f\u093e ? / \u0995\u09c7 \u09ac\u09be\u09a8\u09bf\u09df\u09c7\u099b\u09c7 ?", "ZGViYXlhbiAtIGluZGlh\nboka XD").show(); - } - else if (this.nickNameTextField.getText().equals("imachonk")) { - new StreamPiAlert("bigquimo is mega chonk", "i cant stop sweating lol").show(); + else + { + if(nickNameTextField.getText().equals("about maker")) + { + new StreamPiAlert("किसने बनाया ? / কে বানিয়েছে ?","ZGViYXlhbiAtIGluZGlh\n" + + "boka XD").show(); + } } - if (!errors.toString().isEmpty()) { - this.exceptionAndAlertHandler.handleMinorException(new MinorException("You made mistakes", "Please fix the errors and try again :\n" + errors.toString())); + + + if(!errors.toString().isEmpty()) + { + exceptionAndAlertHandler.handleMinorException(new MinorException( + "You made mistakes", + "Please fix the errors and try again :\n"+errors.toString() + )); return; } - try { + + + + try + { boolean toBeReloaded = false; + boolean syncWithServer = false; - final Config config = Config.getInstance(); - if (!config.getCurrentThemeFullName().equals(((Theme)this.themeComboBox.getCurrentSelectedItem()).getFullName())) { - syncWithServer = true; - try { - config.setCurrentThemeFullName(((Theme)this.themeComboBox.getCurrentSelectedItem()).getFullName()); - config.save(); - this.clientListener.initThemes(); - } - catch (SevereException e) { - this.exceptionAndAlertHandler.handleSevereException(e); - } - } - if (!config.getCurrentAnimationName().equals(this.animationComboBox.getCurrentSelectedItem())) { + + Config config = Config.getInstance(); + + if(!config.getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName())) + { syncWithServer = true; - try { - config.setCurrentAnimationFullName((String)this.animationComboBox.getCurrentSelectedItem()); + + try + { + config.setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName()); config.save(); + clientListener.initThemes(); } - catch (SevereException e) { - this.exceptionAndAlertHandler.handleSevereException(e); + catch(SevereException e) + { + exceptionAndAlertHandler.handleSevereException(e); } } - if (!config.getClientNickName().equals(this.nickNameTextField.getText())) { + + if(!config.getClientNickName().equals(nickNameTextField.getText())) + { syncWithServer = true; } - config.setNickName(this.nickNameTextField.getText()); - if (port != config.getSavedServerPort() || !this.serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP())) { + + config.setNickName(nickNameTextField.getText()); + + if(port != config.getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP())) + { syncWithServer = true; } + config.setServerPort(port); - config.setServerHostNameOrIP(this.serverHostNameOrIPTextField.getText()); - final boolean isFullScreen = this.fullScreenModeToggleSwitch.isSelected(); - if (config.getIsFullScreenMode() != isFullScreen) { + config.setServerHostNameOrIP(serverHostNameOrIPTextField.getText()); + + boolean isFullScreen = fullScreenModeToggleSwitch.isSelected(); + + if(config.getIsFullScreenMode() != isFullScreen) + { toBeReloaded = true; } + config.setIsFullScreenMode(isFullScreen); - config.setTryConnectingWhenActionClicked(this.tryConnectingToServerIfActionClickedToggleSwitch.isSelected()); - boolean startOnBoot = this.startOnBootToggleSwitch.isSelected(); - if (config.isStartOnBoot() != startOnBoot) { - final StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), Main.class.getProtectionDomain().getCodeSource().getLocation(), StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); - if (startOnBoot) { - try { + + + + config.setTryConnectingWhenActionClicked(tryConnectingToServerIfActionClickedToggleSwitch.isSelected()); + + + + boolean startOnBoot = startOnBootToggleSwitch.isSelected(); + + if(config.isStartOnBoot() != startOnBoot) + { + StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), + Main.class.getProtectionDomain().getCodeSource().getLocation(), + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); + + if(startOnBoot) + { + try + { startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); config.setStartupIsXMode(StartupFlags.IS_X_MODE); } - catch (MinorException e2) { - this.exceptionAndAlertHandler.handleMinorException(e2); + catch (MinorException e) + { + exceptionAndAlertHandler.handleMinorException(e); startOnBoot = false; } } - else { - final boolean result = startAtBoot.delete(); - if (!result) { + else + { + boolean result = startAtBoot.delete(); + if(!result) new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show(); - } } } + config.setStartOnBoot(startOnBoot); - if (!config.isShowCursor() == this.showCursorToggleSwitch.isSelected()) { + + if(!config.isShowCursor() ==showCursorToggleSwitch.isSelected()) toBeReloaded = true; - } - config.setShowCursor(this.showCursorToggleSwitch.isSelected()); - if (!config.getThemesPath().equals(this.themesPathTextField.getText())) { + + config.setShowCursor(showCursorToggleSwitch.isSelected()); + + + if(!config.getThemesPath().equals(themesPathTextField.getText())) toBeReloaded = true; - } - config.setThemesPath(this.themesPathTextField.getText()); - if (!config.getIconsPath().equals(this.iconsPathTextField.getText())) { + + config.setThemesPath(themesPathTextField.getText()); + + + if(!config.getIconsPath().equals(iconsPathTextField.getText())) toBeReloaded = true; - } - config.setIconsPath(this.iconsPathTextField.getText()); - if (!config.getProfilesPath().equals(this.profilesPathTextField.getText())) { + + config.setIconsPath(iconsPathTextField.getText()); + + if(!config.getProfilesPath().equals(profilesPathTextField.getText())) toBeReloaded = true; - } - config.setProfilesPath(this.profilesPathTextField.getText()); - if (config.isScreenSaverEnabled() != this.screenSaverToggleSwitch.isSelected()) { + + config.setProfilesPath(profilesPathTextField.getText()); + + if(config.isScreenSaverEnabled() != screenSaverToggleSwitch.isSelected()) toBeReloaded = true; - } - config.setScreenSaverEnabled(this.screenSaverToggleSwitch.isSelected()); - if (config.isScreenMoverEnabled() != this.screenMoverToggleSwitch.isSelected()) { + + config.setScreenSaverEnabled(screenSaverToggleSwitch.isSelected()); + + if(config.isScreenMoverEnabled() != screenMoverToggleSwitch.isSelected()) toBeReloaded = true; + + config.setScreenMoverEnabled(screenMoverToggleSwitch.isSelected()); + + if(!(screenSaverTimeout+"").equals(screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) + { + config.setScreenSaverTimeout(screenTimeoutTextField.getText()); + + clientListener.getScreenSaver().setTimeout(config.getScreenSaverTimeout()); + clientListener.getScreenSaver().restartTimer(); } - config.setScreenMoverEnabled(this.screenMoverToggleSwitch.isSelected()); - if (!("" + screenSaverTimeout).equals(this.screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) { - config.setScreenSaverTimeout(this.screenTimeoutTextField.getText()); - this.clientListener.getScreenSaver().setTimeout(config.getScreenSaverTimeout()); - this.clientListener.getScreenSaver().restartTimer(); - } - config.setConnectOnStartup(this.connectOnStartupToggleSwitch.isSelected()); - boolean isVibrateOnActionClicked = this.vibrateOnActionPressToggleSwitch.isSelected(); - if (config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked && VibrationService.create().isEmpty()) { - isVibrateOnActionClicked = false; - new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show(); + + + config.setConnectOnStartup(connectOnStartupToggleSwitch.isSelected()); + + boolean isVibrateOnActionClicked = vibrateOnActionPressToggleSwitch.isSelected(); + + if(config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked) + { + if(VibrationService.create().isEmpty()) + { + isVibrateOnActionClicked = false; + new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show(); + } } + config.setVibrateOnActionClicked(isVibrateOnActionClicked); - config.setInvertRowsColsOnDeviceRotate(this.invertRowsColsToggleSwitch.isSelected()); + config.setInvertRowsColsOnDeviceRotate(invertRowsColsToggleSwitch.isSelected()); + config.save(); - this.loadData(); - if (syncWithServer && this.clientListener.isConnected()) { - this.clientListener.getClient().updateClientDetails(); + + loadData(); + + + if(syncWithServer) + { + if(clientListener.isConnected()) + { + clientListener.getClient().updateClientDetails(); + } } - if (toBeReloaded) { - if (!ClientInfo.getInstance().isPhone() && !config.getIsFullScreenMode()) { - config.setStartupWindowSize(this.clientListener.getStageWidth(), this.clientListener.getStageHeight()); + + if(toBeReloaded) + { + if(!ClientInfo.getInstance().isPhone() && !config.getIsFullScreenMode()) + { + config.setStartupWindowSize(clientListener.getStageWidth(), clientListener.getStageHeight()); config.save(); } - this.clientListener.init(); - this.clientListener.renderRootDefaultProfile(); + + clientListener.init(); + clientListener.renderRootDefaultProfile(); } } - catch (SevereException e3) { - e3.printStackTrace(); - this.exceptionAndAlertHandler.handleSevereException(e3); + catch (SevereException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleSevereException(e); } - catch (MinorException e4) { - e4.printStackTrace(); - this.exceptionAndAlertHandler.handleMinorException(e4); + catch (MinorException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleMinorException(e); } } + } diff --git a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java index 53480e28..818461aa 100644 --- a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java +++ b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java @@ -1,60 +1,73 @@ -// -// Decompiled by Procyon v0.6-prerelease -// - package com.stream_pi.client.window.settings; -import javafx.scene.CacheHint; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import com.stream_pi.client.window.settings.About.AboutTab; -import javafx.scene.control.Tab; -import javafx.scene.Node; -import javafx.scene.layout.Priority; -import javafx.event.Event; -import javafx.scene.input.SwipeEvent; import com.stream_pi.client.controller.ClientListener; import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.client.window.settings.About.AboutTab; + import javafx.application.HostServices; -import javafx.scene.control.Button; -import javafx.scene.control.TabPane; +import javafx.event.Event; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.*; +import javafx.scene.input.SwipeEvent; +import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; public class SettingsBase extends VBox { private TabPane tabPane; + private GeneralTab generalTab; + private Button closeButton; + private HostServices hostServices; private ExceptionAndAlertHandler exceptionAndAlertHandler; - - public SettingsBase(final HostServices hostServices, final ExceptionAndAlertHandler exceptionAndAlertHandler, final ClientListener clientListener) { + + public SettingsBase(HostServices hostServices, ExceptionAndAlertHandler exceptionAndAlertHandler, + ClientListener clientListener) + { this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.hostServices = hostServices; - (this.tabPane = new TabPane()).addEventFilter(SwipeEvent.ANY, Event::consume); - this.tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); - VBox.setVgrow((Node)this.tabPane, Priority.ALWAYS); - final Tab generalSettingsTab = new Tab("Settings"); - generalSettingsTab.setContent((Node)(this.generalTab = new GeneralTab(exceptionAndAlertHandler, clientListener, hostServices))); - final Tab aboutTab = new Tab("About"); - aboutTab.setContent((Node)new AboutTab(clientListener)); - this.tabPane.getTabs().addAll((Object[])new Tab[] { generalSettingsTab, aboutTab }); - this.setAlignment(Pos.TOP_RIGHT); - VBox.setMargin((Node)(this.closeButton = new Button("Close")), new Insets(5.0)); - this.getChildren().addAll((Object[])new Node[] { (Node)this.tabPane, (Node)this.closeButton }); - this.setCache(true); - this.setCacheHint(CacheHint.SPEED); + + tabPane = new TabPane(); + tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); + tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); + VBox.setVgrow(tabPane, Priority.ALWAYS); + + Tab generalSettingsTab = new Tab("Settings"); + generalTab = new GeneralTab(exceptionAndAlertHandler, clientListener, hostServices); + generalSettingsTab.setContent(generalTab); + + Tab aboutTab = new Tab("About"); + aboutTab.setContent(new AboutTab(clientListener)); + + tabPane.getTabs().addAll(generalSettingsTab, aboutTab); + + setAlignment(Pos.TOP_RIGHT); + + closeButton = new Button("Close"); + VBox.setMargin(closeButton, new Insets(5.0)); + + getChildren().addAll(tabPane, closeButton); + + setCache(true); + setCacheHint(CacheHint.SPEED); } - - public void setDefaultTabToGeneral() { - this.tabPane.getSelectionModel().selectFirst(); + + public void setDefaultTabToGeneral() + { + tabPane.getSelectionModel().selectFirst(); } - - public Button getCloseButton() { - return this.closeButton; + + public Button getCloseButton() + { + return closeButton; } - - public GeneralTab getGeneralTab() { - return this.generalTab; + + public GeneralTab getGeneralTab() + { + return generalTab; } } diff --git a/src/main/resources/com/stream_pi/client/Default.zip b/src/main/resources/com/stream_pi/client/Default.zip index add98b34078e2ebf54e6438e6f9a119a17074453..748677d111625eebb3a0ead726105bb22b8a41b7 100644 GIT binary patch delta 3275 zcmZve2{=@19LC4KW(Y&J$c!OtNR%bHvW#`C%_t-jW^5sZ#$>ygtIH(ITuY3Q$Ym~d zZMme3n{X$RsH{;#*2wI7)aPb@MD}zE{XV!TuY;?*wZ3qelb2iO`d@@jon_4Qr^m4h_y+0m z!k=dxxuw*sx;y4KGE875s2(=KHNEO3#p&yD;jY&th(gu@BH|D`EL4#zI#Wp^h`NlhHnRL7nPLjt z&2N-$KM0k!R4+J}=U_HC`$*x%Iiow}-BTCk60BxrW@g?PM?~fus}d|`vhIG!geths zPX>~2rw$B^FWt_ZLd)wIHoUj%dPApPq{N)e6SmV*`K0%ktRK9BzKyg`xJ=I2IBY+m zqaRuv^sM>#^cud(z(8)GXd`E6D|o$mdv%V_Laru~Jf8)nYu|zrdyR_4fT9{#}I40fc##5;?j6I~KrFlO+-bFzX3Q z&=PJ|Tm)agRK;(NUOlm3u)1GO`WXGzggM3v>9X}fiia1>la*z*cVYhBd{nZ-UQ*)3>`EWy+5Es!}S}vIev96qt^7#-EFk<%#v1RkaS%p&B?y^l)p?%cF_<>s}sn zj*iF3gA+F?3ju5)12?mV<7+>Z@m=wcd!nlTR6?@4_eOHI&4d@H#l@#|b5IK|NVpFT-Kh8~iQ8kDD z@JO*l-+M7TEVge*+dw%Q%2@CSh)alp^FlI~X;0ZcgLdi(6PUN6u~$0)U`l~MuF4_= zOuEDSK>bU(0=OatOe680f-na_h6WB1;P_Uq&f|j5dgC;F!oo;+F60-?R6wM7N!2fi zseirHlH}Zl*gSxkY$9oVkx3{}#Pt3X;lskCalXvO3S5k?j%W#va!i`|8PiYJm`g;e z4b1kv4r!7Y`#Rp*JDzfv`V$y7~6m%_6*I zvyhO$0kC|MYCjZ0kBu?pxehsse=li->$D#&b+n6q*Oz+`-vD#B5AKK35~Uhkth~z^ z(MGoUBQM@OMudf4&YyRREPs>k8ouNv^f?-n0&|`3WOUg{hERS(s^0n~eYK};#Yr<$H58%GHq~~@rzgiY1M~HsXsOnvB;yC`QM%~H$d)K# zM*Dh;!@=wg81&h@mB&GY;)%2-LrG^vTei2t-qo*vNryre_Hgc((zyLuHsKKX_O(BK zmeUGa&9EUUIsWla4YxTQ5K=7Qm|TilTtf5$pw$7GXfqMfC7tH)!?PrFxr<0e$T2Bg8Ai2dU!j2cO&@RH?q4Sj z*H_DM-68Dd4BPyDNSUmQi=kNh_?1Dc(yPOl?$IC>Nh)Q=`|FELT00cb`cERdv-_j| zrgr0v-4%#6lX-Dlb?#y(tmv&KDd_X+r`v~~$vYPyi=z{4axt^b=3|=yQ+1tbku=rl znz+oiv{V&X%XINnE2es!9b0NmH8*ZAt+UsH7wmN$K{;6+uDVPqIfGancFPtrH$LHb zBCf6#tI$>dfq$rJsWyp2BIa4)T5yQI^8!A8BzWU7#!ca+)AgB(@^fyLh%hcV9-j87 zO0BYPE5K#4BlKK=ppkFW@dsfxxotE{4ogKD?tuI*f*Asvc?CNWTgzYPOXIC!Kdx!> zitgrP6oamApg#;DY8p*pJIffgk;VAz zer3bJBOX}#{aKrUfcTG{+PQQ-fpHi2{WcP)uguKRO)UO_i_Pu=Rll2SkD~p0~ILBm^Bqm@}jNHG<&?+dG zm4}!4kZW(?T_{gHMQ7Xdt4ePuOW+XKqB7a}mM2wRH-blN(wgOHIyb;#Fx zt`q*L_s(LUFM4@%mb~IFnO-O2oF*p>E_~pNEV|$WN6KzBr+B{G?|@)qH{l?)i$Ua= zfsHj7rp&9a@oh%}WrjG`V3~A!NtlGI|_)f(vAdpgP^Y(AY^>^*dJrYj*CL5W0^$1GyT}DcAFmX zeA^A!eD??Wzuv{NQ3(A&|M{Vl?fed~3QG!{8Kw>-yyUL00RgLjH=Vm$H~enoe?Q?Mr1xwN=7A8_RdQ7CM1c6 zQfB0S_w{thQ|R~mz3-3D-5>XUe?G6*>oZ<&m>R)8dJqZrLyacV1^tL2LJ(*_h!bRq zbb{O22zojq^v+U%h;Jb%%$*&{&4JO~lMIBnZypZ>!u}rw3OlP2(a%X;qCe>u;(Jt6 zqMkd3ec|~l+58Woht|hjl!JnE?>0E6p9GmQ2eliA&Cglq_l>ewiIjdect*xL5b93leZ6(e>gEHm zuHb7pNwY|OSch^s;$$Uvmz7~xQ`%df*vo%C#&|m8b6fVxC>GcaACM<^$yT7Nm0@iT z_w$ERtP+cM9lP&7;dQ;;fdhs#Qcu|zHM)N>h(p?v3(2nX<(q!M(u^o6Yu8WZ;_9iEk;qg|%ewEvt^`92_iNDf^0qsS%T?BXZaT@IfFzYOr+?0@|C7o7MTD z!S#U%D?$~l3SEWP1$cq|s~I3bVB99a-{&C3=76~%;dTh?y`};7!%<7sjj0e~WiGNc zjRf3UMBEA@CIB(FloSxNkUTB`fxsmMti_}xMMcHo*5;Dd8{6hl3)lLrfpOcc^&*NW zt2oI|FRFegu1=0ba9lm6H%>WC%sI+=#Ny1M%MVRWPijYNF38GN?j$S~00O^7%ASzBwzJp&AoyPfMpn@KE@j)JakF4pFbrp|VPR@QKHcZ8dj zxr@X9AcMoZq(|7<*t+d8KcJ5&`|%BZ7-5$~vzgxpfwVA32wJ+juB-O8>exE}z_^Wn zh6c6$SB1$>x4z8ueCO{bOUWO`3QcH>02dX63$o{2g1B)KDuvLbr=7G>p5jhKCLWP) zJ?PYGs;O_W@0ArO*a{DV-=d7S7BMKu zyp))5Ok}@MnBI~2+2NS?H`mO|3R=xu+D=*Znjo`|8uAQ_Lq)<4bXE?rXoQ>+d# zUm&y!Jx-cYedU!yno+05xzt#nt4kw2RU~sFP(&DqoiN=H|7*xf)fHqwKwCCxU2f5k z!9BxpPR*7EI|UbQlZeFA>i1&lyp0V6Y`lW6Jp-MJ)Oh4h-kiE`RzDL4p&IrExzQBg z4J3SZTRc1I-7$;9{0mbIq2HpLx&+Gb0Dh+Ed?Tu``~V33o*#i-u={C?{`WNHVkdF@ zPfGm(TOyQ|!sG+!C8ZA1YhuEjsOW2WL~+cXC|)PFR&Jh)G^@!V79Hv#-%D~yS~;Ig z8l5JJpQqQ2FCVkCRrTpg7tH-WTOQk36Z%H<`MG!KW7!#QgED_{Qh~_0GAbyS^9dhi zO?isxR`92&%m#lSP$qWdV?!^_uuX-qO~4$V`j>*Ax4TzKbloD*LgW%&x}%CFiE^Fb z9d2OpEGK=VbBYt~8^oR-d6+a>PO1(X!FV|UDu*iLdEatlF+O%k4J~{rxGx3JC&03 zDxA`UsY}i@$Qw*%^M#}vW>`dI&Yhh$?<}&mRLYV*V5J`QXtM0_p*XX0t6pd5=p8T7 zudDDEXH5Gka#KPWwTWoOR9gpUyw0RVrX+!ht-TZIYbxmDeWf!;Z0O$mt1-r~hTpf- z%CafH?hiL!^i&c;qb4Z=^19Ya2F0`z$xK)f)#!JHqc4txA|-QzR@t>9OPE;gYXt9p z%ohp%qRJC{0j8f6eZ_F>umy#gvK`-yQZQMZ`;;!x@z6^!9bo{rkfMkii(#xZxV zm9+*aufFhEaCmf_Lg)E>ns_~tj@r@l+#O9y#O_u!Il0N*?PD%Uugr83->tF>=oYlh zsR+A15xjo+fHtj#^&w=pl~VLr-#~Kyd;f9cQsU3&YHJ_aO+y!N($;2~>C9OM%Cu<0 zGBEd(8NW+&G>U7z6NTuMd-N15SS)5r8y;vgU3rUKkzaDhd>JPV{t#QFaY==CQvR=? zSD&-#>n*kWN_?+Zs3W0=y%{0DPV^ZQGTG<2+tdtbNOvh<6eZu#4{ zd1i=>#L>-lcwWu=HBzZMsX;#{zK5F6Ywpkzse75IAc4@+UVR&;`y*mu#plaS0qONo zX%u6yvI7LRDZR-p(sLjNfrNIE-sYM9v-TiAvXWS!|yi0c#nR$;C%;Fc&9h zf46@FOBU(n%{Z-N0AZZCWNhrzdxLVrgiMotruW7Y^fVfWIsonM{ zI?qhGR=a;~CeisehYMK@O>DLIt%B(lkM_gWtw-PKP({WMHD-2BleEA$w;Qd4s8)>Pn(}y?=}kWm70qt_2I9uvmerXW_s(UYeMCHNyyz zHLWs8B5?vkD#375mn}OVqKqRs2HvDDbH$rU)~Z^|RV6LCp~=6i)b9)QX>wbeN(`yE z`9%1HLae@CFroO%0f|(bXbE9Nn%5-!njA06hbh-1ML)N+ra^rWUKh_JARw6FSb7&$ zhol;+XHJTrnRR=pS`p~%uTl>W>~C+@xWA?*d*J(I_;T`tWfpcRn2m&?f;L0MOIyz% zwVt7ND(61(3E3Py?yzTO0{bUdo1w6Yir^l6|2H|3L|a9ccxMGQAi%!<&tCvQf zK#yPIo)7C*Tw-vm&vlN63rc(@24rNGc9Wn1D&~zG@x$%5yp(9IVcYF1>>67R~E05Fgj{_!zk zCbUWT1?1_vc_r5L9sO??i~8AY`eLe8Qc(Kf&nFFfJ{98UIvlw?^s=hqQG)C7Xz}3_ zWTf!Xu5{ZbF|jFMi(u$81+aQWx30lJSFrK*ho-Hpmqj}})KjU9!Iq=mHsFS+QzIQV zj5ngi43lNDSxZ-SNKf^RgCA$cVLl*fA4k=M))7EQ?8UA#xR)JxgG!=nkHLs|_uNcb zxCxhv$xyP4U+v|pQ1({y=fM+iY++LkC3X~=;)M)2y?SU`7}hwLr!lD9%9K4ZR=~cx zQcdZQg{bD}(`0sbE9-wwXV~{e&VTVZ_v7?4357OidEOI7Jwb{NpgqpTd^4T2YYCp| zX_lJPnmvYIfhR!rr@8tpoH!yMUUnh8Z29Z#hsINoTZ7FK%Px?t&a%{?2lKl19IK?+ znmi^kL#yKI2}}lOYl7qbTA#6qMQDEV_{^N-Kks_?9N(f6^hwQ(QDW95YSvHQ<~m_w z3RWs^&}qO021QMi@nRVD@o=QEb_z++MB!CS`#6-|Djg^N$M*N*LSI`q2*Adn;fk zN&vHt3yk91&Gf%S@2A6g_rBRCirWn$VBT?oQB)?{Sk*7fZoF#OOYUgpH-QAq{8qOL zn0Z`aP#JqExo11F72)km1-vjWFp8tt%kc++zg+6(E9y_zy4Cps-WV4clrr{U+`Z=i zWwC&<#05stpLFNKKgnrtHuGnGx0)uvXyO8cn*Nj0f4p>{Sp-d5_sOJ*^I_A`LpM((u0um1pg Date: Sun, 29 Aug 2021 19:22:47 +0100 Subject: [PATCH 04/12] animations remade --- .../java/com/stream_pi/client/io/Config.java | 13 +++++ .../dashboard/actiongridpane/ActionBox.java | 36 +++++++++++++ .../client/window/settings/GeneralTab.java | 53 ++++++++++++++++++- 3 files changed, 100 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/stream_pi/client/io/Config.java b/src/main/java/com/stream_pi/client/io/Config.java index df04a419..60b042b0 100644 --- a/src/main/java/com/stream_pi/client/io/Config.java +++ b/src/main/java/com/stream_pi/client/io/Config.java @@ -109,6 +109,11 @@ public String getDefaultStartupProfileID() { return "default"; } + + public String getDefaultCurrentAnimationName() + { + return "None"; + } public String getDefaultCurrentThemeFullName() { @@ -146,6 +151,10 @@ public String getCurrentThemeFullName() { return XMLConfigHelper.getStringProperty(document, "current-theme-full-name", getDefaultCurrentThemeFullName(), false, true, document, configFile); } + + public String getCurrentAnimationName() { + return XMLConfigHelper.getStringProperty(this.document, "current-animation-name", getDefaultCurrentAnimationName(), false, true, this.document, this.configFile); + } public String getThemesPath() { @@ -195,6 +204,10 @@ public void setCurrentThemeFullName(String name) { document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); } + + public void setCurrentAnimationFullName(String name) { + this.document.getElementsByTagName("current-animation-name").item(0).setTextContent(name); + } public void setProfilesPath(String profilesPath) { diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java index ab71a778..e7337e46 100644 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java @@ -28,6 +28,8 @@ import javafx.util.Duration; import org.kordamp.ikonli.javafx.FontIcon; +import animatefx.animation.*; + import java.io.ByteArrayInputStream; import java.util.logging.Logger; @@ -173,6 +175,11 @@ else if(action.getActionType() == ActionType.TOGGLE) getActionGridPaneListener().toggleActionClicked(action.getID(), getCurrentToggleStatus()); } } + try { + playActionAnimation(); + } catch (SevereException e) { + Logger.getLogger("").warning(e.getMessage()); + } } } @@ -259,6 +266,35 @@ public void setAction(Action action) { this.action = action; } + + public void playActionAnimation() throws SevereException { + Config config = Config.getInstance(); + switch (config.getCurrentAnimationName()) { + case "None": + return; + case "Flip": + (new Flip(getChildren().get(1))).play(); + case "Bounce": + (new Bounce(getChildren().get(1))).play(); + case "Jack In The Box": + (new JackInTheBox(getChildren().get(1))).play(); + case "Swing": + (new Swing(getChildren().get(1))).play(); + case "Jello": + (new Jello(getChildren().get(1))).play(); + case "Pulse": + (new Pulse(getChildren().get(1))).play(); + case "RubberBand": + (new RubberBand(getChildren().get(1))).play(); + case "Shake": + (new Shake(getChildren().get(1))).play(); + case "Tada": + (new Tada(getChildren().get(1))).play(); + case "Wobble": + (new Wobble(getChildren().get(1))).play(); + } + Logger.getLogger("").warning("Invalid Option/n Please contact quimodotcom to solve this error!"); + } public void init() { diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java index 5100fd89..d98e649a 100644 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -19,7 +19,6 @@ import com.stream_pi.util.combobox.StreamPiComboBoxListener; import com.stream_pi.util.exception.MinorException; import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.platform.Platform; import com.stream_pi.util.platform.PlatformType; import com.stream_pi.util.startatboot.StartAtBoot; import com.stream_pi.util.uihelper.HBoxInputBox; @@ -34,6 +33,8 @@ import javafx.scene.layout.HBox; import javafx.scene.layout.Priority; import javafx.scene.layout.VBox; +import java.util.Arrays; +import java.util.List; import org.controlsfx.control.ToggleSwitch; import java.io.File; @@ -53,6 +54,7 @@ public class GeneralTab extends VBox private StreamPiComboBox clientProfileComboBox; private StreamPiComboBox themeComboBox; + private StreamPiComboBox animationComboBox; private TextField nickNameTextField; @@ -99,10 +101,16 @@ public class GeneralTab extends VBox private final Button checkForUpdatesButton; private HBoxInputBox screenTimeoutSecondsHBoxInputBox; + + private List animationList; public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener, HostServices hostServices) { + this.animationList = Arrays.asList(new String[] { + "None", "Bounce", "Flip", "Jack In The Box", "Jello", "Pulse", "RubberBand", "Shake", "Swing", "Tada", + "Wobble" + }); this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.clientListener = clientListener; this.hostServices = hostServices; @@ -126,6 +134,17 @@ public String getOptionDisplayText(ClientProfile object) return object.getName(); } }); + animationComboBox = new StreamPiComboBox(); + + animationComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(String object) + { + return object; + } + }); + clientProfileComboBox.setStreamPiComboBoxListener(new StreamPiComboBoxListener(){ @Override @@ -243,6 +262,11 @@ public String getOptionDisplayText(Theme object) SpaceFiller.horizontal(), themeComboBox ), + new HBox( + new Label("Action Animation"), + SpaceFiller.horizontal(), + animationComboBox + ), generateSubHeading("Others"), themesPathInputBox, iconsPathInputBox, @@ -453,7 +477,7 @@ public void loadData() throws SevereException screenTimeoutTextField.setText(config.getScreenSaverTimeout()+""); screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); - + animationComboBox.setOptions(animationList); clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles()); int ind = 0; @@ -479,8 +503,19 @@ public void loadData() throws SevereException break; } } + + int ind3 = 0; + for(int i = 0;i 65535) exceptionAndAlertHandler.handleSevereException(e); } } + + if (!config.getCurrentAnimationName().equals(animationComboBox.getCurrentSelectedItem())) + { + syncWithServer = true; + + try + { + config.setCurrentAnimationFullName(animationComboBox.getCurrentSelectedItem()); + config.save(); + } catch (SevereException e) + { + exceptionAndAlertHandler.handleSevereException(e); + } + } if(!config.getClientNickName().equals(nickNameTextField.getText())) { From 26fe0ff4e303eb8ff9410fc085e60af07b910241 Mon Sep 17 00:00:00 2001 From: quimo Date: Sun, 29 Aug 2021 20:42:06 +0100 Subject: [PATCH 05/12] Update pom.xml --- pom.xml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/pom.xml b/pom.xml index 090f1d03..4bd704f3 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,12 @@ javafx-controls ${javafx.version} + + + io.github.typhon0 + AnimateFX + 1.2.1 + org.openjfx From 43bc92aff4ff1b62cc3f32f0fbd45e3be36220d8 Mon Sep 17 00:00:00 2001 From: quimo Date: Sun, 29 Aug 2021 20:46:24 +0100 Subject: [PATCH 06/12] Update to items --- src/main/java/module-info.java | 2 ++ .../com/stream_pi/client/Default.zip | Bin 5434 -> 5452 bytes 2 files changed, 2 insertions(+) diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 8d7223ec..dbb09f65 100644 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -15,6 +15,8 @@ requires java.management; requires java.xml; + + requires AnimateFX; opens com.stream_pi.client.window.settings.About to javafx.base; diff --git a/src/main/resources/com/stream_pi/client/Default.zip b/src/main/resources/com/stream_pi/client/Default.zip index 748677d111625eebb3a0ead726105bb22b8a41b7..971db6b77862606c0791ee9cd5d7f914cffc3751 100644 GIT binary patch delta 818 zcmdm`bw+E0H*Y-y0|&#MnX9bR;2!hCduFDK=WmbF z)k~Ob@@vN0>8o=XXGtr5{W;_BkAHrAHxE@VV-0pYY8$klr$JwGM>bMu^tphww#CTGI8 z1ok+mPGN|CvbZ9pjP==yWQ8K>Y_FARH~RygWS_L(z3$S&6YT*@9?V&jFD>->Wj5#Q zxfVGm8$a6KocB%tNr6T@XU_imx8}2BIdl3$mqkua3SZf}Q%JpDmE+)QksCMbwrYL) zXQ3e4GV@Yw!y`+vGxI}_ur3k(#%)^qwu8BQo5#tig?1jQn--obSmwkKFVT8AruXZY z)UCH3$s9J^_aS04x73}kQvRyWi%(K|ma7KqolWC7XLz#rirax4r$cJjQlhS%SzLd= zdV1}G_5UjhnADPQT03sfd?07fQ?%AW_?WfSxxV@)58glQ#@BR~mcFR$yqql?kRR{iwGM=A)g*X4$@$$-L9-(5rPbo9o8_t}r^z+a@+xNyG=oTQ@Dt4!=H@7}fvHQT5P8UxV-Qk&-XZFBJT8WY+4#OEtt(ICgmONqksYnM4>SCoqalUcxT}W8UDG2Qnx6OHCFQaE1xy3CKd2Qj?bp z7{f$A30Q-e`hrm)s#`D&Ch=3y0><yMg`z>!6QOVrWh-n8lbAbM#M!;gh2$D%&{kapacUWg94D8EG8<)Hj5u50008aR6+m% delta 796 zcmX@3wM%P*H*Y-?0|&#a86Sg`#ZttjnHU%rvobJnF)%PB=jWwmrt4MY=JbY~?z?Tk zvq$`eJ!muB)B6zpGPIb?>tUPxqy* zeZ-W#*lUZc-ND71{0-FS3I*Pd3idQzUAJUWocG6@;Zyls?VJLgYB%l6Ry?-(JJMXVbzJ?*~tNzG8Vw_)70$R`q)It`n*|s`* z?Y1k&3wrczp1pB&4&M0gpuPmJda}*x9Yrh6l`WRHNSiD>abt-;*o zvI^=;lV@*OSRcCNe7x|>gR@pIUZ^3SGo@l8lRM|CUQQw5ZL6pC+Elhriusw|VTNrGggGdrcM4Lxy@;(t4HG5_e23*M; Tn9{*uN#kS Date: Mon, 30 Aug 2021 11:00:49 +0100 Subject: [PATCH 07/12] changes --- LICENSE.txt | 1346 ++++++------ README.md | 56 +- assets/launchers/aarch64-jvm/run_console | 36 +- assets/launchers/aarch64-jvm/run_desktop | 8 +- assets/launchers/aarch64-native/run_console | 36 +- assets/launchers/aarch64-native/run_desktop | 8 +- assets/launchers/arm32-jvm/run_console | 36 +- assets/launchers/arm32-jvm/run_desktop | 8 +- assets/linux-icon.png | Bin assets/macos-icon.icns | Bin assets/windows-icon.ico | Bin pom.xml | 6 - src/android/AndroidManifest.xml | 46 +- src/android/mods/MainActivity.java | 1150 +++++----- src/android/res/mipmap-hdpi/ic_launcher.png | Bin src/android/res/mipmap-mdpi/ic_launcher.png | Bin src/android/res/mipmap-xhdpi/ic_launcher.png | Bin src/android/res/mipmap-xxhdpi/ic_launcher.png | Bin .../res/mipmap-xxxhdpi/ic_launcher.png | Bin .../AppIcon.appiconset/100.png | Bin .../AppIcon.appiconset/1024.png | Bin .../AppIcon.appiconset/114.png | Bin .../AppIcon.appiconset/120.png | Bin .../AppIcon.appiconset/144.png | Bin .../AppIcon.appiconset/152.png | Bin .../AppIcon.appiconset/167.png | Bin .../AppIcon.appiconset/180.png | Bin .../Assets.xcassets/AppIcon.appiconset/20.png | Bin .../Assets.xcassets/AppIcon.appiconset/29.png | Bin .../Assets.xcassets/AppIcon.appiconset/40.png | Bin .../Assets.xcassets/AppIcon.appiconset/50.png | Bin .../Assets.xcassets/AppIcon.appiconset/57.png | Bin .../Assets.xcassets/AppIcon.appiconset/58.png | Bin .../Assets.xcassets/AppIcon.appiconset/60.png | Bin .../Assets.xcassets/AppIcon.appiconset/72.png | Bin .../Assets.xcassets/AppIcon.appiconset/76.png | Bin .../Assets.xcassets/AppIcon.appiconset/80.png | Bin .../Assets.xcassets/AppIcon.appiconset/87.png | Bin .../AppIcon.appiconset/Contents.json | 0 src/ios/assets/Assets.xcassets/Contents.json | 10 +- .../assets/Base.lproj/LaunchScreen.storyboard | 64 +- .../assets/Base.lproj/MainScreen.storyboard | 64 +- .../assets/Default-375w-667h@2x~iphone.png | Bin .../Default-375w-812h-landscape@3x~iphone.png | Bin .../assets/Default-375w-812h@3x~iphone.png | Bin .../Default-414w-736h-landscape@3x~iphone.png | Bin .../assets/Default-414w-736h@3x~iphone.png | Bin .../Default-414w-896h-landscape@3x~iphone.png | Bin .../assets/Default-414w-896h@3x~iphone.png | Bin src/ios/assets/Default-568h@2x~iphone.png | Bin src/ios/assets/Default-landscape@2x~ipad.png | Bin src/ios/assets/Default-landscape~ipad.png | Bin src/ios/assets/Default-portrait@2x~ipad.png | Bin src/ios/assets/Default-portrait~ipad.png | Bin src/ios/assets/Default@2x~iphone.png | Bin src/ios/assets/iTunesArtwork.png | Bin src/ios/assets/iTunesArtwork@2x.png | Bin src/main/java/com/stream_pi/client/Main.java | 126 +- .../animations/AnimateFXInterpolator.java | 13 + .../client/animations/AnimationFX.java | 206 ++ .../stream_pi/client/animations/Bounce.java | 66 + .../stream_pi/client/animations/Flash.java | 57 + .../com/stream_pi/client/animations/Flip.java | 77 + .../client/animations/JackInTheBox.java | 65 + .../stream_pi/client/animations/Jello.java | 74 + .../stream_pi/client/animations/Pulse.java | 57 + .../client/animations/RubberBand.java | 80 + .../stream_pi/client/animations/Shake.java | 75 + .../stream_pi/client/animations/Swing.java | 63 + .../com/stream_pi/client/animations/Tada.java | 110 + .../stream_pi/client/animations/Wobble.java | 66 + .../stream_pi/client/connection/Client.java | 1926 ++++++++--------- .../client/controller/ClientListener.java | 172 +- .../client/controller/Controller.java | 1446 ++++++------- .../client/controller/ScreenMover.java | 206 +- .../client/controller/ScreenSaver.java | 248 +-- .../com/stream_pi/client/info/ClientInfo.java | 242 +-- .../com/stream_pi/client/info/License.java | 86 +- .../stream_pi/client/info/StartupFlags.java | 24 +- .../java/com/stream_pi/client/io/Config.java | 1102 +++++----- .../client/profile/ClientProfile.java | 1516 ++++++------- .../client/profile/ClientProfiles.java | 238 +- .../com/stream_pi/client/window/Base.java | 1060 ++++----- .../window/ExceptionAndAlertHandler.java | 30 +- .../window/dashboard/DashboardBase.java | 156 +- .../dashboard/actiongridpane/ActionBox.java | 1041 ++++----- .../actiongridpane/ActionGridPane.java | 918 ++++---- .../ActionGridPaneListener.java | 34 +- .../window/firsttimeuse/FinalConfigPane.java | 348 +-- .../window/firsttimeuse/FirstTimeUse.java | 284 +-- .../window/firsttimeuse/LicensePane.java | 48 +- .../window/firsttimeuse/WelcomePane.java | 58 +- .../window/firsttimeuse/WindowName.java | 10 +- .../window/settings/About/AboutTab.java | 346 +-- .../window/settings/About/ContactTab.java | 100 +- .../window/settings/About/Contributor.java | 96 +- .../settings/About/ContributorsTab.java | 152 +- .../window/settings/About/LicenseTab.java | 32 +- .../client/window/settings/GeneralTab.java | 1584 +++++++------- .../client/window/settings/SettingsBase.java | 146 +- src/main/java/module-info.java | 60 +- .../native-image/resource-config.json | 14 +- .../native-image/serialization-config.json | 20 +- .../com/stream_pi/client/Default.zip | Bin .../resources/com/stream_pi/client/Roboto.ttf | Bin .../com/stream_pi/client/app_icon.png | Bin .../com/stream_pi/client/default_icons.css | 54 +- .../com/stream_pi/client/icon16x16.png | Bin .../com/stream_pi/client/icon24x24.png | Bin .../com/stream_pi/client/icon256x256.png | Bin .../com/stream_pi/client/icon32x32.png | Bin .../com/stream_pi/client/icon48x48.png | Bin .../resources/com/stream_pi/client/style.css | 438 ++-- style_classes.txt | 86 +- 114 files changed, 9666 insertions(+), 8664 deletions(-) mode change 100644 => 100755 LICENSE.txt mode change 100644 => 100755 README.md mode change 100644 => 100755 assets/linux-icon.png mode change 100644 => 100755 assets/macos-icon.icns mode change 100644 => 100755 assets/windows-icon.ico mode change 100644 => 100755 pom.xml mode change 100644 => 100755 src/android/AndroidManifest.xml mode change 100644 => 100755 src/android/mods/MainActivity.java mode change 100644 => 100755 src/android/res/mipmap-hdpi/ic_launcher.png mode change 100644 => 100755 src/android/res/mipmap-mdpi/ic_launcher.png mode change 100644 => 100755 src/android/res/mipmap-xhdpi/ic_launcher.png mode change 100644 => 100755 src/android/res/mipmap-xxhdpi/ic_launcher.png mode change 100644 => 100755 src/android/res/mipmap-xxxhdpi/ic_launcher.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/100.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/1024.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/114.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/120.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/144.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/152.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/167.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/180.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/20.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/29.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/40.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/50.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/57.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/58.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/60.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/72.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/76.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/80.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/87.png mode change 100644 => 100755 src/ios/assets/Assets.xcassets/AppIcon.appiconset/Contents.json mode change 100644 => 100755 src/ios/assets/Assets.xcassets/Contents.json mode change 100644 => 100755 src/ios/assets/Base.lproj/LaunchScreen.storyboard mode change 100644 => 100755 src/ios/assets/Base.lproj/MainScreen.storyboard mode change 100644 => 100755 src/ios/assets/Default-375w-667h@2x~iphone.png mode change 100644 => 100755 src/ios/assets/Default-375w-812h-landscape@3x~iphone.png mode change 100644 => 100755 src/ios/assets/Default-375w-812h@3x~iphone.png mode change 100644 => 100755 src/ios/assets/Default-414w-736h-landscape@3x~iphone.png mode change 100644 => 100755 src/ios/assets/Default-414w-736h@3x~iphone.png mode change 100644 => 100755 src/ios/assets/Default-414w-896h-landscape@3x~iphone.png mode change 100644 => 100755 src/ios/assets/Default-414w-896h@3x~iphone.png mode change 100644 => 100755 src/ios/assets/Default-568h@2x~iphone.png mode change 100644 => 100755 src/ios/assets/Default-landscape@2x~ipad.png mode change 100644 => 100755 src/ios/assets/Default-landscape~ipad.png mode change 100644 => 100755 src/ios/assets/Default-portrait@2x~ipad.png mode change 100644 => 100755 src/ios/assets/Default-portrait~ipad.png mode change 100644 => 100755 src/ios/assets/Default@2x~iphone.png mode change 100644 => 100755 src/ios/assets/iTunesArtwork.png mode change 100644 => 100755 src/ios/assets/iTunesArtwork@2x.png mode change 100644 => 100755 src/main/java/com/stream_pi/client/Main.java create mode 100755 src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java create mode 100755 src/main/java/com/stream_pi/client/animations/AnimationFX.java create mode 100755 src/main/java/com/stream_pi/client/animations/Bounce.java create mode 100755 src/main/java/com/stream_pi/client/animations/Flash.java create mode 100755 src/main/java/com/stream_pi/client/animations/Flip.java create mode 100755 src/main/java/com/stream_pi/client/animations/JackInTheBox.java create mode 100755 src/main/java/com/stream_pi/client/animations/Jello.java create mode 100755 src/main/java/com/stream_pi/client/animations/Pulse.java create mode 100755 src/main/java/com/stream_pi/client/animations/RubberBand.java create mode 100755 src/main/java/com/stream_pi/client/animations/Shake.java create mode 100755 src/main/java/com/stream_pi/client/animations/Swing.java create mode 100755 src/main/java/com/stream_pi/client/animations/Tada.java create mode 100755 src/main/java/com/stream_pi/client/animations/Wobble.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/connection/Client.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/controller/ClientListener.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/controller/Controller.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/controller/ScreenMover.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/controller/ScreenSaver.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/info/ClientInfo.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/info/License.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/info/StartupFlags.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/io/Config.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/profile/ClientProfile.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/profile/ClientProfiles.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/Base.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/settings/About/Contributor.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/settings/GeneralTab.java mode change 100644 => 100755 src/main/java/com/stream_pi/client/window/settings/SettingsBase.java mode change 100644 => 100755 src/main/java/module-info.java mode change 100644 => 100755 src/main/resources/META-INF/native-image/resource-config.json mode change 100644 => 100755 src/main/resources/META-INF/native-image/serialization-config.json mode change 100644 => 100755 src/main/resources/com/stream_pi/client/Default.zip mode change 100644 => 100755 src/main/resources/com/stream_pi/client/Roboto.ttf mode change 100644 => 100755 src/main/resources/com/stream_pi/client/app_icon.png mode change 100644 => 100755 src/main/resources/com/stream_pi/client/default_icons.css mode change 100644 => 100755 src/main/resources/com/stream_pi/client/icon16x16.png mode change 100644 => 100755 src/main/resources/com/stream_pi/client/icon24x24.png mode change 100644 => 100755 src/main/resources/com/stream_pi/client/icon256x256.png mode change 100644 => 100755 src/main/resources/com/stream_pi/client/icon32x32.png mode change 100644 => 100755 src/main/resources/com/stream_pi/client/icon48x48.png mode change 100644 => 100755 src/main/resources/com/stream_pi/client/style.css mode change 100644 => 100755 style_classes.txt diff --git a/LICENSE.txt b/LICENSE.txt old mode 100644 new mode 100755 index e72bfdda..871ce8e6 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,674 +1,674 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read . \ No newline at end of file diff --git a/README.md b/README.md old mode 100644 new mode 100755 index aac43c76..dc74e123 --- a/README.md +++ b/README.md @@ -1,28 +1,28 @@ -# Stream-Pi Client - -![version](https://img.shields.io/badge/Version-1.0.0-green) - -## Prerequisites - -- Java >= 11 -- Maven >= 3.6.3 - -Note: If compiling the Android binary (apk) then GraalVM 21.1.0 (Java 11) should be used as JDK, or the path to it should be -set as value of environment variable `GRAALVM_HOME`. - -## Quick Start - -This project depends on the following Stream-Pi modules: - -- [Stream-Pi Action API](https://github.com/stream-pi/action-api) -- [Stream-Pi Theme API](https://github.com/stream-pi/theme-api) -- [Stream-Pi Utilities](https://github.com/stream-pi/util) - - -## Download binaries - -Downloadable Binaries for available platforms are available [here](https://github.com/stream-pi/client/releases). - -## Compile and Run from source - -Run `mvn clean javafx:run` +# Stream-Pi Client + +![version](https://img.shields.io/badge/Version-1.0.0-green) + +## Prerequisites + +- Java >= 11 +- Maven >= 3.6.3 + +Note: If compiling the Android binary (apk) then GraalVM 21.1.0 (Java 11) should be used as JDK, or the path to it should be +set as value of environment variable `GRAALVM_HOME`. + +## Quick Start + +This project depends on the following Stream-Pi modules: + +- [Stream-Pi Action API](https://github.com/stream-pi/action-api) +- [Stream-Pi Theme API](https://github.com/stream-pi/theme-api) +- [Stream-Pi Utilities](https://github.com/stream-pi/util) + + +## Download binaries + +Downloadable Binaries for available platforms are available [here](https://github.com/stream-pi/client/releases). + +## Compile and Run from source + +Run `mvn clean javafx:run` diff --git a/assets/launchers/aarch64-jvm/run_console b/assets/launchers/aarch64-jvm/run_console index 72de8843..7ec8a3eb 100755 --- a/assets/launchers/aarch64-jvm/run_console +++ b/assets/launchers/aarch64-jvm/run_console @@ -1,18 +1,18 @@ -#!/bin/bash -cd "${0%/*}" -export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true -export DISPLAY_CARD0=/dev/dri/card0 -export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 - -if ! jre/bin/java -Xmx700m -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD0 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card0, trying to launch using card1 - - if ! jre/bin/java -Xmx700m -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD1 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card1. Is your KMS driver turned on? - else - echo success using card1 - fi -else - echo success using card0 -fi - +#!/bin/bash +cd "${0%/*}" +export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true +export DISPLAY_CARD0=/dev/dri/card0 +export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 + +if ! jre/bin/java -Xmx700m -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD0 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card0, trying to launch using card1 + + if ! jre/bin/java -Xmx700m -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD1 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card1. Is your KMS driver turned on? + else + echo success using card1 + fi +else + echo success using card0 +fi + diff --git a/assets/launchers/aarch64-jvm/run_desktop b/assets/launchers/aarch64-jvm/run_desktop index a2d88f3e..be856ab1 100755 --- a/assets/launchers/aarch64-jvm/run_desktop +++ b/assets/launchers/aarch64-jvm/run_desktop @@ -1,4 +1,4 @@ -#!/bin/bash -cd "${0%/*}" - -DISPLAY=:0 jre/bin/java -Xmx700m --module-path . --add-modules ALL-MODULE-PATH -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx com.stream_pi.client.Main Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true +#!/bin/bash +cd "${0%/*}" + +DISPLAY=:0 jre/bin/java -Xmx700m --module-path . --add-modules ALL-MODULE-PATH -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx com.stream_pi.client.Main Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true diff --git a/assets/launchers/aarch64-native/run_console b/assets/launchers/aarch64-native/run_console index e4f94e8d..102a632e 100755 --- a/assets/launchers/aarch64-native/run_console +++ b/assets/launchers/aarch64-native/run_console @@ -1,18 +1,18 @@ -#!/bin/bash -cd "${0%/*}" -export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true -export DISPLAY_CARD0=/dev/dri/card0 -export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 - -if ! ./client -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dmonocle.platform=EGL -Degl.displayid=$DISPLAY_CARD0 Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card0, trying to launch using card1 - - if ! ./client -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dmonocle.platform=EGL -Degl.displayid=$DISPLAY_CARD1 Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card1. Is your KMS driver turned on? - else - echo success using card1 - fi -else - echo success using card0 -fi - +#!/bin/bash +cd "${0%/*}" +export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true +export DISPLAY_CARD0=/dev/dri/card0 +export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 + +if ! ./client -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dmonocle.platform=EGL -Degl.displayid=$DISPLAY_CARD0 Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card0, trying to launch using card1 + + if ! ./client -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dmonocle.platform=EGL -Degl.displayid=$DISPLAY_CARD1 Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card1. Is your KMS driver turned on? + else + echo success using card1 + fi +else + echo success using card0 +fi + diff --git a/assets/launchers/aarch64-native/run_desktop b/assets/launchers/aarch64-native/run_desktop index 691d8f09..d5b6ab59 100755 --- a/assets/launchers/aarch64-native/run_desktop +++ b/assets/launchers/aarch64-native/run_desktop @@ -1,4 +1,4 @@ -#!/bin/bash -cd "${0%/*}" - -DISPLAY=:0 ./client -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true +#!/bin/bash +cd "${0%/*}" + +DISPLAY=:0 ./client -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true diff --git a/assets/launchers/arm32-jvm/run_console b/assets/launchers/arm32-jvm/run_console index 22b36fa3..2d9968c2 100755 --- a/assets/launchers/arm32-jvm/run_console +++ b/assets/launchers/arm32-jvm/run_console @@ -1,18 +1,18 @@ -#!/bin/bash -cd "${0%/*}" -export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true -export DISPLAY_CARD0=/dev/dri/card0 -export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 - -if ! jre/bin/java -Xmx700m -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD0 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card0, trying to launch using card1 - - if ! jre/bin/java -Xmx700m -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD1 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card1. Is your KMS driver turned on? - else - echo success using card1 - fi -else - echo success using card0 -fi - +#!/bin/bash +cd "${0%/*}" +export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true +export DISPLAY_CARD0=/dev/dri/card0 +export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 + +if ! jre/bin/java -Xmx700m -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD0 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card0, trying to launch using card1 + + if ! jre/bin/java -Xmx700m -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD1 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card1. Is your KMS driver turned on? + else + echo success using card1 + fi +else + echo success using card0 +fi + diff --git a/assets/launchers/arm32-jvm/run_desktop b/assets/launchers/arm32-jvm/run_desktop index a2d88f3e..be856ab1 100755 --- a/assets/launchers/arm32-jvm/run_desktop +++ b/assets/launchers/arm32-jvm/run_desktop @@ -1,4 +1,4 @@ -#!/bin/bash -cd "${0%/*}" - -DISPLAY=:0 jre/bin/java -Xmx700m --module-path . --add-modules ALL-MODULE-PATH -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx com.stream_pi.client.Main Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true +#!/bin/bash +cd "${0%/*}" + +DISPLAY=:0 jre/bin/java -Xmx700m --module-path . --add-modules ALL-MODULE-PATH -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx com.stream_pi.client.Main Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true diff --git a/assets/linux-icon.png b/assets/linux-icon.png old mode 100644 new mode 100755 diff --git a/assets/macos-icon.icns b/assets/macos-icon.icns old mode 100644 new mode 100755 diff --git a/assets/windows-icon.ico b/assets/windows-icon.ico old mode 100644 new mode 100755 diff --git a/pom.xml b/pom.xml old mode 100644 new mode 100755 index 4bd704f3..1da0b657 --- a/pom.xml +++ b/pom.xml @@ -45,12 +45,6 @@ ${javafx.version} - - io.github.typhon0 - AnimateFX - 1.2.1 - - org.openjfx javafx-base diff --git a/src/android/AndroidManifest.xml b/src/android/AndroidManifest.xml old mode 100644 new mode 100755 index a65dbe05..d6bc2d6e --- a/src/android/AndroidManifest.xml +++ b/src/android/AndroidManifest.xml @@ -1,23 +1,23 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/src/android/mods/MainActivity.java b/src/android/mods/MainActivity.java old mode 100644 new mode 100755 index 1614aebd..ae9c33fb --- a/src/android/mods/MainActivity.java +++ b/src/android/mods/MainActivity.java @@ -1,575 +1,575 @@ -/* - * Copyright (c) 2019, 2020, Gluon - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL GLUON BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.gluonhq.helloandroid; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.graphics.PixelFormat; -import android.graphics.Rect; -import android.os.Bundle; -import android.util.DisplayMetrics; -import android.util.Log; - -import android.view.inputmethod.InputConnection; - -import android.view.KeyEvent; -import android.view.KeyCharacterMap; -import android.view.MotionEvent; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.view.WindowManager.LayoutParams; -import android.view.inputmethod.InputMethodManager; -import android.widget.FrameLayout; - -import java.util.TimeZone; -import javafx.scene.input.KeyCode; - -public class MainActivity extends Activity implements SurfaceHolder.Callback, - SurfaceHolder.Callback2 { - - private static MainActivity instance; - private static FrameLayout mViewGroup; - private static SurfaceView mView; - private long nativeWindowPtr; - private float density; - - private static final String TAG = "GraalActivity"; - - boolean graalStarted = false; - - private static InputMethodManager imm; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Log.v(TAG, "onCreate start, using Android Logging v1"); - Log.v(TAG, "Using modded MainActivity to prevent device lock"); - System.err.println("onCreate called, writing this to System.err"); - super.onCreate(savedInstanceState); - - getWindow().requestFeature(Window.FEATURE_NO_TITLE); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - getWindow().setSoftInputMode( - WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED - | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); - getWindow().setFormat(PixelFormat.RGBA_8888); - - - mView = new InternalSurfaceView(this); - mView.getHolder().addCallback(this); - mViewGroup = new FrameLayout(this); - mViewGroup.addView(mView); - setContentView(mViewGroup); - instance = this; - - imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - Log.v(TAG, "onCreate done"); - } - - @Override - public void surfaceCreated(SurfaceHolder holder) { - Log.v(TAG, "surfaceCreated for "+this); - Log.v(TAG, "loading substrate library"); - System.loadLibrary("substrate"); - Log.v(TAG, "loaded substrate library"); - nativeSetSurface(holder.getSurface()); - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - density = metrics.density; - Log.v(TAG, "metrics = "+metrics+", density = "+density); - nativeWindowPtr = surfaceReady(holder.getSurface(), density); - Rect currentBounds = new Rect(); - mView.getRootView().getWindowVisibleDisplayFrame(currentBounds); - - Log.v(TAG, "Surface created, native code informed about it, nativeWindow at "+nativeWindowPtr); - if (graalStarted) { - Log.v(TAG, "GraalApp is already started."); - } else { - Log.v(TAG, "We will now launch Graal in a separate thread"); - final String[] launchArgs = { - "-Duser.home=" + getApplicationInfo().dataDir, - "-Djava.io.tmpdir=" + getApplicationInfo().dataDir, - "-Duser.timezone=" + TimeZone.getDefault().getID(), - "-DLaunch.URL=" + System.getProperty("Launch.URL", ""), - "-DLaunch.LocalNotification=" + System.getProperty("Launch.LocalNotification", ""), - "-DLaunch.PushNotification=" + System.getProperty("Launch.PushNotification", "") - }; - Thread t = new Thread() { - @Override public void run() { - startGraalApp(launchArgs); - } - }; - t.start(); - graalStarted = true; - Log.v(TAG, "graalStarted true"); - } - Log.v(TAG, "surfaceCreated done"); - } - - - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, - int height) { - Log.v(TAG, "surfaceChanged start"); - Log.v(TAG, "[MainActivity] surfaceChanged, format = "+format+", width = "+width+", height = "+height); - nativeSetSurface(holder.getSurface()); - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - density = metrics.density; - Log.v(TAG, "surfaceChanged done, metrics = "+metrics+", density = "+density); - } - - @Override - public void surfaceDestroyed(SurfaceHolder holder) { - System.err.println("[MainGraalActivity] surfaceDestroyed, ignore for now"); - // _surfaceChanged(null); - } - - @Override - public void surfaceRedrawNeeded(SurfaceHolder holder) { - Log.v(TAG, "SurfaceRedraw needed start"); - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - Log.v(TAG, "ask native graallayer to redraw surface"); - nativeSurfaceRedrawNeeded(); - try { - Thread.sleep(500); - Log.v(TAG, "surfaceredraw needed part 1 done"); - nativeSurfaceRedrawNeeded(); - } catch (Exception e) { - e.printStackTrace(); - } - Log.v(TAG, "surfaceredraw needed (and wait) done"); - } - - @Override - public void onActivityResult(int requestCode, int resultCode, Intent intent) { - Log.v(TAG, "onActivityResult with requestCode " + requestCode + " and resultCode = " + resultCode + " and intent = " + intent); - nativeDispatchActivityResult(requestCode, resultCode, intent); - } - - static MainActivity getInstance() { - return instance; - } - - static ViewGroup getViewGroup() { - return mViewGroup; - } - - private static void showIME() { - Log.v(TAG, "Called notify_showIME for imm = "+imm+", mv = "+mView); - instance.runOnUiThread(new Runnable() { - @Override - public void run() { - mView.requestFocus(); - boolean answer = imm.showSoftInput(mView, 0); - Log.v(TAG, "Done calling notify_showIME, answer = " + answer); - } - }); - } - - private static void hideIME() { - Log.v(TAG, "Called notify_hideIME"); - instance.runOnUiThread(new Runnable() { - @Override - public void run() { - mView.requestFocus(); - boolean answer = imm.hideSoftInputFromWindow(mView.getWindowToken(), 0); - Log.v(TAG, "Done Calling notify_hideIME, answer = " + answer); - } - }); - } - - - private native void startGraalApp(String[] launchArgs); - private native long surfaceReady(Surface surface, float density); - private native void nativeSetSurface(Surface surface); - private native void nativeSurfaceRedrawNeeded(); - private native void nativeGotTouchEvent(int pcount, int[] actions, int[] ids, int[] touchXs, int[] touchYs); - private native void nativeGotKeyEvent(int action, int keycode); - private native void nativedispatchKeyEvent(int type, int key, char[] chars, int charCount, int modifiers); - private native void nativeDispatchLifecycleEvent(String event); - private native void nativeDispatchActivityResult(int requestCode, int resultCode, Intent intent); - - class InternalSurfaceView extends SurfaceView { - private static final int ACTION_POINTER_STILL = -1; - - public InternalSurfaceView(Context context) { - super(context); - setFocusableInTouchMode(true); - setFocusable(true); - } - - @Override - public boolean dispatchTouchEvent(MotionEvent event) { - int action = event.getAction(); - int actionCode = action & MotionEvent.ACTION_MASK; - final int pcount = event.getPointerCount(); - final int[] actions = new int[pcount]; - final int[] ids = new int[pcount]; - final int[] touchXs = new int[pcount]; - final int[] touchYs = new int[pcount]; - Log.v(TAG, "Activity, get touch event, pcount = "+pcount); - if (pcount > 1) { - //multitouch - if (actionCode == MotionEvent.ACTION_POINTER_DOWN - || actionCode == MotionEvent.ACTION_POINTER_UP) { - - int pointerIndex = event.getActionIndex(); - for (int i = 0; i < pcount; i++) { - actions[i] = pointerIndex == i ? actionCode : ACTION_POINTER_STILL; - ids[i] = event.getPointerId(i); - touchXs[i] = (int) (event.getX(i)/density); - touchYs[i] = (int) (event.getY(i)/density); - } - } else if (actionCode == MotionEvent.ACTION_MOVE) { - for (int i = 0; i < pcount; i++) { - touchXs[i] = (int) (event.getX(i)/density); - touchYs[i] = (int) (event.getY(i)/density); - actions[i] = MotionEvent.ACTION_MOVE; - ids[i] = event.getPointerId(i); - } - } - } else { - //single touch - actions[0] = actionCode; - ids[0] = event.getPointerId(0); - touchXs[0] = (int) (event.getX()/density); - touchYs[0] = (int) (event.getY()/density); - } - if (!isFocused()) { - Log.v(TAG, "View wasn't focused, requesting focus"); - requestFocus(); - } - nativeGotTouchEvent(pcount, actions, ids, touchXs, touchYs); - return true; - } - - @Override - public boolean dispatchKeyEvent(final KeyEvent event) { - Log.v(TAG, "Activity, process get key event, action = "+event.getAction()); - processAndroidKeyEvent (event); - // nativeGotKeyEvent(event.getAction(), event.getKeyCode()); - return true; - } - } - - @Override - protected void onDestroy() { - Log.v(TAG, "onDestroy"); - super.onDestroy(); - notifyLifecycleEvent("destroy"); - android.os.Process.killProcess(android.os.Process.myPid()); - } - - @Override - protected void onPause() { - Log.v(TAG, "onPause"); - super.onPause(); - notifyLifecycleEvent("pause"); - } - - @Override - protected void onResume() { - Log.v(TAG, "onResume"); - super.onResume(); - notifyLifecycleEvent("resume"); - Log.v(TAG, "onResume done"); - } - - @Override - protected void onStart() { - Log.v(TAG, "onStart"); - super.onStart(); - notifyLifecycleEvent("start"); - Log.v(TAG, "onStart done"); - } - - @Override - protected void onRestart() { - Log.v(TAG, "onRestart"); - super.onRestart(); - notifyLifecycleEvent("restart"); - } - - @Override - protected void onStop() { - Log.v(TAG, "onStop"); - super.onStop(); - notifyLifecycleEvent("stop"); - } - - private void notifyLifecycleEvent(String event) { - if (graalStarted) { - nativeDispatchLifecycleEvent(event); - } - } - - public final static int PRESS = 111; - public final static int RELEASE = 112; - public final static int TYPED = 113; - - private int deadKey = 0; - - void processAndroidKeyEvent (KeyEvent event) { - System.out.println("KeyEvent: " + event+" with action = "+event.getAction()); - int jfxModifiers = mapAndroidModifierToJfx(event.getMetaState()); - switch (event.getAction()) { - case KeyEvent.ACTION_DOWN: - KeyCode jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); -System.out.println ("[JVDBG] eventkeycode = "+event.getKeyCode()+" and jfxkc = "+jfxKeyCode+" with code "+ jfxKeyCode.impl_getCode()); - nativedispatchKeyEvent(PRESS, jfxKeyCode.impl_getCode(), jfxKeyCode.impl_getChar().toCharArray(), jfxKeyCode.impl_getChar().toCharArray().length, jfxModifiers); - break; - - case KeyEvent.ACTION_UP: - jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); - nativedispatchKeyEvent(RELEASE, jfxKeyCode.impl_getCode(), jfxKeyCode.impl_getChar().toCharArray(), jfxKeyCode.impl_getChar().toCharArray().length, jfxModifiers); - int unicodeChar = event.getUnicodeChar(); - if ((unicodeChar & KeyCharacterMap.COMBINING_ACCENT) != 0) { - deadKey = unicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK; - return; - } - - if (deadKey != 0 && unicodeChar != 0) { - unicodeChar = KeyCharacterMap.getDeadChar(deadKey, unicodeChar); - deadKey = 0; - } - - if (unicodeChar != 0) { - nativedispatchKeyEvent(TYPED, KeyCode.UNDEFINED.impl_getCode(), Character.toChars(unicodeChar), 1, jfxModifiers); - } - - break; - - case KeyEvent.ACTION_MULTIPLE: - if (event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN) { - nativedispatchKeyEvent(TYPED, KeyCode.UNDEFINED.impl_getCode(), event.getCharacters().toCharArray(), event.getCharacters().toCharArray().length, jfxModifiers); - } else { - jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); - for (int i = 0; i < event.getRepeatCount(); i++) { - nativedispatchKeyEvent(PRESS, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); - nativedispatchKeyEvent(RELEASE, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); - nativedispatchKeyEvent(TYPED, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); - } - } - - break; - default: - System.err.println("DalvikInput.onKeyEvent Unknown Action " + event.getAction()); - break; - } - } - - private final static int MODIFIER_SHIFT = 1; - private final static int MODIFIER_CONTROL = 2; - private final static int MODIFIER_ALT = 4; - private final static int MODIFIER_WINDOWS = 8; - - - private static int mapAndroidModifierToJfx(int androidMetaStates) { - int jfxModifiers = 0; - - if ((androidMetaStates & KeyEvent.META_SHIFT_MASK) != 0) { - jfxModifiers += MODIFIER_SHIFT; - } - - if ((androidMetaStates & KeyEvent.META_CTRL_MASK) != 0) { - jfxModifiers += MODIFIER_CONTROL; - } - - if ((androidMetaStates & KeyEvent.META_ALT_MASK) != 0) { - jfxModifiers += MODIFIER_ALT; - } - - if ((androidMetaStates & KeyEvent.META_META_ON) != 0) { - jfxModifiers += MODIFIER_WINDOWS; - } - return jfxModifiers; - } - - - private static KeyCode mapAndroidKeyCodeToJfx(int keycode) { - switch (keycode) { - case KeyEvent.KEYCODE_UNKNOWN: return KeyCode.UNDEFINED; - case KeyEvent.KEYCODE_HOME: return KeyCode.HOME; - case KeyEvent.KEYCODE_BACK: return KeyCode.ESCAPE; // special back key mapped to ESC - case KeyEvent.KEYCODE_0: return KeyCode.DIGIT0; - case KeyEvent.KEYCODE_1: return KeyCode.DIGIT1; - case KeyEvent.KEYCODE_2: return KeyCode.DIGIT2; - case KeyEvent.KEYCODE_3: return KeyCode.DIGIT3; - case KeyEvent.KEYCODE_4: return KeyCode.DIGIT4; - case KeyEvent.KEYCODE_5: return KeyCode.DIGIT5; - case KeyEvent.KEYCODE_6: return KeyCode.DIGIT6; - case KeyEvent.KEYCODE_7: return KeyCode.DIGIT7; - case KeyEvent.KEYCODE_8: return KeyCode.DIGIT8; - case KeyEvent.KEYCODE_9: return KeyCode.DIGIT9; - case KeyEvent.KEYCODE_STAR: return KeyCode.STAR; - case KeyEvent.KEYCODE_POUND: return KeyCode.POUND; - case KeyEvent.KEYCODE_DPAD_UP: return KeyCode.UP; - case KeyEvent.KEYCODE_DPAD_DOWN: return KeyCode.DOWN; - case KeyEvent.KEYCODE_DPAD_LEFT: return KeyCode.LEFT; - case KeyEvent.KEYCODE_DPAD_RIGHT: return KeyCode.RIGHT; - case KeyEvent.KEYCODE_VOLUME_UP: return KeyCode.VOLUME_UP; - case KeyEvent.KEYCODE_VOLUME_DOWN: return KeyCode.VOLUME_DOWN; - case KeyEvent.KEYCODE_POWER: return KeyCode.POWER; - case KeyEvent.KEYCODE_CLEAR: return KeyCode.CLEAR; - case KeyEvent.KEYCODE_A: return KeyCode.A; - case KeyEvent.KEYCODE_B: return KeyCode.B; - case KeyEvent.KEYCODE_C: return KeyCode.C; - case KeyEvent.KEYCODE_D: return KeyCode.D; - case KeyEvent.KEYCODE_E: return KeyCode.E; - case KeyEvent.KEYCODE_F: return KeyCode.F; - case KeyEvent.KEYCODE_G: return KeyCode.G; - case KeyEvent.KEYCODE_H: return KeyCode.H; - case KeyEvent.KEYCODE_I: return KeyCode.I; - case KeyEvent.KEYCODE_J: return KeyCode.J; - case KeyEvent.KEYCODE_K: return KeyCode.K; - case KeyEvent.KEYCODE_L: return KeyCode.L; - case KeyEvent.KEYCODE_M: return KeyCode.M; - case KeyEvent.KEYCODE_N: return KeyCode.N; - case KeyEvent.KEYCODE_O: return KeyCode.O; - case KeyEvent.KEYCODE_P: return KeyCode.P; - case KeyEvent.KEYCODE_Q: return KeyCode.Q; - case KeyEvent.KEYCODE_R: return KeyCode.R; - case KeyEvent.KEYCODE_S: return KeyCode.S; - case KeyEvent.KEYCODE_T: return KeyCode.T; - case KeyEvent.KEYCODE_U: return KeyCode.U; - case KeyEvent.KEYCODE_V: return KeyCode.V; - case KeyEvent.KEYCODE_W: return KeyCode.W; - case KeyEvent.KEYCODE_X: return KeyCode.X; - case KeyEvent.KEYCODE_Y: return KeyCode.Y; - case KeyEvent.KEYCODE_Z: return KeyCode.Z; - case KeyEvent.KEYCODE_COMMA: return KeyCode.COMMA; - case KeyEvent.KEYCODE_PERIOD: return KeyCode.PERIOD; - case KeyEvent.KEYCODE_ALT_LEFT: return KeyCode.ALT; - case KeyEvent.KEYCODE_ALT_RIGHT: return KeyCode.ALT; - case KeyEvent.KEYCODE_SHIFT_LEFT: return KeyCode.SHIFT; - case KeyEvent.KEYCODE_SHIFT_RIGHT: return KeyCode.SHIFT; - case KeyEvent.KEYCODE_TAB: return KeyCode.TAB; - case KeyEvent.KEYCODE_SPACE: return KeyCode.SPACE; - case KeyEvent.KEYCODE_ENTER: return KeyCode.ENTER; - case KeyEvent.KEYCODE_DEL: return KeyCode.BACK_SPACE; - case KeyEvent.KEYCODE_GRAVE: return KeyCode.DEAD_GRAVE; - case KeyEvent.KEYCODE_MINUS: return KeyCode.MINUS; - case KeyEvent.KEYCODE_EQUALS: return KeyCode.EQUALS; - case KeyEvent.KEYCODE_LEFT_BRACKET: return KeyCode.BRACELEFT; - case KeyEvent.KEYCODE_RIGHT_BRACKET: return KeyCode.BRACERIGHT; - case KeyEvent.KEYCODE_BACKSLASH: return KeyCode.BACK_SLASH; - case KeyEvent.KEYCODE_SEMICOLON: return KeyCode.SEMICOLON; - case KeyEvent.KEYCODE_SLASH: return KeyCode.SLASH; - case KeyEvent.KEYCODE_AT: return KeyCode.AT; - case KeyEvent.KEYCODE_PLUS: return KeyCode.PLUS; - case KeyEvent.KEYCODE_MENU: return KeyCode.CONTEXT_MENU; - case KeyEvent.KEYCODE_SEARCH: return KeyCode.FIND; - case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: return KeyCode.PLAY; - case KeyEvent.KEYCODE_MEDIA_STOP: return KeyCode.STOP; - case KeyEvent.KEYCODE_MEDIA_NEXT: return KeyCode.TRACK_NEXT; - case KeyEvent.KEYCODE_MEDIA_PREVIOUS: return KeyCode.TRACK_PREV; - case KeyEvent.KEYCODE_MEDIA_REWIND: return KeyCode.REWIND; - case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: return KeyCode.FAST_FWD; - case KeyEvent.KEYCODE_MUTE: return KeyCode.MUTE; - case KeyEvent.KEYCODE_PAGE_UP: return KeyCode.PAGE_UP; - case KeyEvent.KEYCODE_PAGE_DOWN: return KeyCode.PAGE_DOWN; - case KeyEvent.KEYCODE_BUTTON_A: return KeyCode.GAME_A; - case KeyEvent.KEYCODE_BUTTON_B: return KeyCode.GAME_B; - case KeyEvent.KEYCODE_BUTTON_C: return KeyCode.GAME_C; - case KeyEvent.KEYCODE_BUTTON_X: return KeyCode.GAME_D; - case KeyEvent.KEYCODE_BUTTON_MODE: return KeyCode.MODECHANGE; - case KeyEvent.KEYCODE_ESCAPE: return KeyCode.ESCAPE; - case KeyEvent.KEYCODE_CTRL_LEFT: return KeyCode.CONTROL; - case KeyEvent.KEYCODE_CTRL_RIGHT: return KeyCode.CONTROL; - case KeyEvent.KEYCODE_CAPS_LOCK: return KeyCode.CAPS; - case KeyEvent.KEYCODE_SCROLL_LOCK: return KeyCode.SCROLL_LOCK; - case KeyEvent.KEYCODE_META_LEFT: return KeyCode.META; - case KeyEvent.KEYCODE_META_RIGHT: return KeyCode.META; - case KeyEvent.KEYCODE_SYSRQ: return KeyCode.PRINTSCREEN; - case KeyEvent.KEYCODE_BREAK: return KeyCode.PAUSE; - case KeyEvent.KEYCODE_MOVE_HOME: return KeyCode.BEGIN; - case KeyEvent.KEYCODE_MOVE_END: return KeyCode.END; - case KeyEvent.KEYCODE_INSERT: return KeyCode.INSERT; - case KeyEvent.KEYCODE_MEDIA_PLAY: return KeyCode.PLAY; - case KeyEvent.KEYCODE_MEDIA_EJECT: return KeyCode.EJECT_TOGGLE; - case KeyEvent.KEYCODE_MEDIA_RECORD: return KeyCode.RECORD; - case KeyEvent.KEYCODE_F1: return KeyCode.F1; - case KeyEvent.KEYCODE_F2: return KeyCode.F2; - case KeyEvent.KEYCODE_F3: return KeyCode.F3; - case KeyEvent.KEYCODE_F4: return KeyCode.F4; - case KeyEvent.KEYCODE_F5: return KeyCode.F5; - case KeyEvent.KEYCODE_F6: return KeyCode.F6; - case KeyEvent.KEYCODE_F7: return KeyCode.F7; - case KeyEvent.KEYCODE_F8: return KeyCode.F8; - case KeyEvent.KEYCODE_F9: return KeyCode.F9; - case KeyEvent.KEYCODE_F10: return KeyCode.F10; - case KeyEvent.KEYCODE_F11: return KeyCode.F11; - case KeyEvent.KEYCODE_F12: return KeyCode.F12; - case KeyEvent.KEYCODE_NUM_LOCK: return KeyCode.NUM_LOCK; - case KeyEvent.KEYCODE_NUMPAD_0: return KeyCode.NUMPAD0; - case KeyEvent.KEYCODE_NUMPAD_1: return KeyCode.NUMPAD1; - case KeyEvent.KEYCODE_NUMPAD_2: return KeyCode.NUMPAD2; - case KeyEvent.KEYCODE_NUMPAD_3: return KeyCode.NUMPAD3; - case KeyEvent.KEYCODE_NUMPAD_4: return KeyCode.NUMPAD4; - case KeyEvent.KEYCODE_NUMPAD_5: return KeyCode.NUMPAD5; - case KeyEvent.KEYCODE_NUMPAD_6: return KeyCode.NUMPAD6; - case KeyEvent.KEYCODE_NUMPAD_7: return KeyCode.NUMPAD7; - case KeyEvent.KEYCODE_NUMPAD_8: return KeyCode.NUMPAD8; - case KeyEvent.KEYCODE_NUMPAD_9: return KeyCode.NUMPAD9; - case KeyEvent.KEYCODE_NUMPAD_DIVIDE: return KeyCode.DIVIDE; - case KeyEvent.KEYCODE_NUMPAD_MULTIPLY: return KeyCode.MULTIPLY; - case KeyEvent.KEYCODE_NUMPAD_SUBTRACT: return KeyCode.SUBTRACT; - case KeyEvent.KEYCODE_NUMPAD_ADD: return KeyCode.ADD; - case KeyEvent.KEYCODE_NUMPAD_DOT: return KeyCode.PERIOD; - case KeyEvent.KEYCODE_NUMPAD_COMMA: return KeyCode.COMMA; - case KeyEvent.KEYCODE_NUMPAD_ENTER: return KeyCode.ENTER; - case KeyEvent.KEYCODE_NUMPAD_EQUALS: return KeyCode.EQUALS; - case KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN: return KeyCode.LEFT_PARENTHESIS; - case KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN: return KeyCode.RIGHT_PARENTHESIS; - case KeyEvent.KEYCODE_VOLUME_MUTE: return KeyCode.MUTE; - case KeyEvent.KEYCODE_INFO: return KeyCode.INFO; - case KeyEvent.KEYCODE_CHANNEL_UP: return KeyCode.CHANNEL_UP; - case KeyEvent.KEYCODE_CHANNEL_DOWN: return KeyCode.CHANNEL_DOWN; - case KeyEvent.KEYCODE_PROG_RED: return KeyCode.COLORED_KEY_0; - case KeyEvent.KEYCODE_PROG_GREEN: return KeyCode.COLORED_KEY_1; - case KeyEvent.KEYCODE_PROG_YELLOW: return KeyCode.COLORED_KEY_2; - case KeyEvent.KEYCODE_PROG_BLUE: return KeyCode.COLORED_KEY_3; - case KeyEvent.KEYCODE_KATAKANA_HIRAGANA: return KeyCode.JAPANESE_HIRAGANA; - case KeyEvent.KEYCODE_KANA: return KeyCode.KANA; - default: - return KeyCode.UNDEFINED; - } - } - -} +/* + * Copyright (c) 2019, 2020, Gluon + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL GLUON BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.gluonhq.helloandroid; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.graphics.PixelFormat; +import android.graphics.Rect; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; + +import android.view.inputmethod.InputConnection; + +import android.view.KeyEvent; +import android.view.KeyCharacterMap; +import android.view.MotionEvent; +import android.view.Surface; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.view.WindowManager.LayoutParams; +import android.view.inputmethod.InputMethodManager; +import android.widget.FrameLayout; + +import java.util.TimeZone; +import javafx.scene.input.KeyCode; + +public class MainActivity extends Activity implements SurfaceHolder.Callback, + SurfaceHolder.Callback2 { + + private static MainActivity instance; + private static FrameLayout mViewGroup; + private static SurfaceView mView; + private long nativeWindowPtr; + private float density; + + private static final String TAG = "GraalActivity"; + + boolean graalStarted = false; + + private static InputMethodManager imm; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.v(TAG, "onCreate start, using Android Logging v1"); + Log.v(TAG, "Using modded MainActivity to prevent device lock"); + System.err.println("onCreate called, writing this to System.err"); + super.onCreate(savedInstanceState); + + getWindow().requestFeature(Window.FEATURE_NO_TITLE); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + getWindow().setSoftInputMode( + WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED + | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); + getWindow().setFormat(PixelFormat.RGBA_8888); + + + mView = new InternalSurfaceView(this); + mView.getHolder().addCallback(this); + mViewGroup = new FrameLayout(this); + mViewGroup.addView(mView); + setContentView(mViewGroup); + instance = this; + + imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + Log.v(TAG, "onCreate done"); + } + + @Override + public void surfaceCreated(SurfaceHolder holder) { + Log.v(TAG, "surfaceCreated for "+this); + Log.v(TAG, "loading substrate library"); + System.loadLibrary("substrate"); + Log.v(TAG, "loaded substrate library"); + nativeSetSurface(holder.getSurface()); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + density = metrics.density; + Log.v(TAG, "metrics = "+metrics+", density = "+density); + nativeWindowPtr = surfaceReady(holder.getSurface(), density); + Rect currentBounds = new Rect(); + mView.getRootView().getWindowVisibleDisplayFrame(currentBounds); + + Log.v(TAG, "Surface created, native code informed about it, nativeWindow at "+nativeWindowPtr); + if (graalStarted) { + Log.v(TAG, "GraalApp is already started."); + } else { + Log.v(TAG, "We will now launch Graal in a separate thread"); + final String[] launchArgs = { + "-Duser.home=" + getApplicationInfo().dataDir, + "-Djava.io.tmpdir=" + getApplicationInfo().dataDir, + "-Duser.timezone=" + TimeZone.getDefault().getID(), + "-DLaunch.URL=" + System.getProperty("Launch.URL", ""), + "-DLaunch.LocalNotification=" + System.getProperty("Launch.LocalNotification", ""), + "-DLaunch.PushNotification=" + System.getProperty("Launch.PushNotification", "") + }; + Thread t = new Thread() { + @Override public void run() { + startGraalApp(launchArgs); + } + }; + t.start(); + graalStarted = true; + Log.v(TAG, "graalStarted true"); + } + Log.v(TAG, "surfaceCreated done"); + } + + + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, + int height) { + Log.v(TAG, "surfaceChanged start"); + Log.v(TAG, "[MainActivity] surfaceChanged, format = "+format+", width = "+width+", height = "+height); + nativeSetSurface(holder.getSurface()); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + density = metrics.density; + Log.v(TAG, "surfaceChanged done, metrics = "+metrics+", density = "+density); + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + System.err.println("[MainGraalActivity] surfaceDestroyed, ignore for now"); + // _surfaceChanged(null); + } + + @Override + public void surfaceRedrawNeeded(SurfaceHolder holder) { + Log.v(TAG, "SurfaceRedraw needed start"); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + Log.v(TAG, "ask native graallayer to redraw surface"); + nativeSurfaceRedrawNeeded(); + try { + Thread.sleep(500); + Log.v(TAG, "surfaceredraw needed part 1 done"); + nativeSurfaceRedrawNeeded(); + } catch (Exception e) { + e.printStackTrace(); + } + Log.v(TAG, "surfaceredraw needed (and wait) done"); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent intent) { + Log.v(TAG, "onActivityResult with requestCode " + requestCode + " and resultCode = " + resultCode + " and intent = " + intent); + nativeDispatchActivityResult(requestCode, resultCode, intent); + } + + static MainActivity getInstance() { + return instance; + } + + static ViewGroup getViewGroup() { + return mViewGroup; + } + + private static void showIME() { + Log.v(TAG, "Called notify_showIME for imm = "+imm+", mv = "+mView); + instance.runOnUiThread(new Runnable() { + @Override + public void run() { + mView.requestFocus(); + boolean answer = imm.showSoftInput(mView, 0); + Log.v(TAG, "Done calling notify_showIME, answer = " + answer); + } + }); + } + + private static void hideIME() { + Log.v(TAG, "Called notify_hideIME"); + instance.runOnUiThread(new Runnable() { + @Override + public void run() { + mView.requestFocus(); + boolean answer = imm.hideSoftInputFromWindow(mView.getWindowToken(), 0); + Log.v(TAG, "Done Calling notify_hideIME, answer = " + answer); + } + }); + } + + + private native void startGraalApp(String[] launchArgs); + private native long surfaceReady(Surface surface, float density); + private native void nativeSetSurface(Surface surface); + private native void nativeSurfaceRedrawNeeded(); + private native void nativeGotTouchEvent(int pcount, int[] actions, int[] ids, int[] touchXs, int[] touchYs); + private native void nativeGotKeyEvent(int action, int keycode); + private native void nativedispatchKeyEvent(int type, int key, char[] chars, int charCount, int modifiers); + private native void nativeDispatchLifecycleEvent(String event); + private native void nativeDispatchActivityResult(int requestCode, int resultCode, Intent intent); + + class InternalSurfaceView extends SurfaceView { + private static final int ACTION_POINTER_STILL = -1; + + public InternalSurfaceView(Context context) { + super(context); + setFocusableInTouchMode(true); + setFocusable(true); + } + + @Override + public boolean dispatchTouchEvent(MotionEvent event) { + int action = event.getAction(); + int actionCode = action & MotionEvent.ACTION_MASK; + final int pcount = event.getPointerCount(); + final int[] actions = new int[pcount]; + final int[] ids = new int[pcount]; + final int[] touchXs = new int[pcount]; + final int[] touchYs = new int[pcount]; + Log.v(TAG, "Activity, get touch event, pcount = "+pcount); + if (pcount > 1) { + //multitouch + if (actionCode == MotionEvent.ACTION_POINTER_DOWN + || actionCode == MotionEvent.ACTION_POINTER_UP) { + + int pointerIndex = event.getActionIndex(); + for (int i = 0; i < pcount; i++) { + actions[i] = pointerIndex == i ? actionCode : ACTION_POINTER_STILL; + ids[i] = event.getPointerId(i); + touchXs[i] = (int) (event.getX(i)/density); + touchYs[i] = (int) (event.getY(i)/density); + } + } else if (actionCode == MotionEvent.ACTION_MOVE) { + for (int i = 0; i < pcount; i++) { + touchXs[i] = (int) (event.getX(i)/density); + touchYs[i] = (int) (event.getY(i)/density); + actions[i] = MotionEvent.ACTION_MOVE; + ids[i] = event.getPointerId(i); + } + } + } else { + //single touch + actions[0] = actionCode; + ids[0] = event.getPointerId(0); + touchXs[0] = (int) (event.getX()/density); + touchYs[0] = (int) (event.getY()/density); + } + if (!isFocused()) { + Log.v(TAG, "View wasn't focused, requesting focus"); + requestFocus(); + } + nativeGotTouchEvent(pcount, actions, ids, touchXs, touchYs); + return true; + } + + @Override + public boolean dispatchKeyEvent(final KeyEvent event) { + Log.v(TAG, "Activity, process get key event, action = "+event.getAction()); + processAndroidKeyEvent (event); + // nativeGotKeyEvent(event.getAction(), event.getKeyCode()); + return true; + } + } + + @Override + protected void onDestroy() { + Log.v(TAG, "onDestroy"); + super.onDestroy(); + notifyLifecycleEvent("destroy"); + android.os.Process.killProcess(android.os.Process.myPid()); + } + + @Override + protected void onPause() { + Log.v(TAG, "onPause"); + super.onPause(); + notifyLifecycleEvent("pause"); + } + + @Override + protected void onResume() { + Log.v(TAG, "onResume"); + super.onResume(); + notifyLifecycleEvent("resume"); + Log.v(TAG, "onResume done"); + } + + @Override + protected void onStart() { + Log.v(TAG, "onStart"); + super.onStart(); + notifyLifecycleEvent("start"); + Log.v(TAG, "onStart done"); + } + + @Override + protected void onRestart() { + Log.v(TAG, "onRestart"); + super.onRestart(); + notifyLifecycleEvent("restart"); + } + + @Override + protected void onStop() { + Log.v(TAG, "onStop"); + super.onStop(); + notifyLifecycleEvent("stop"); + } + + private void notifyLifecycleEvent(String event) { + if (graalStarted) { + nativeDispatchLifecycleEvent(event); + } + } + + public final static int PRESS = 111; + public final static int RELEASE = 112; + public final static int TYPED = 113; + + private int deadKey = 0; + + void processAndroidKeyEvent (KeyEvent event) { + System.out.println("KeyEvent: " + event+" with action = "+event.getAction()); + int jfxModifiers = mapAndroidModifierToJfx(event.getMetaState()); + switch (event.getAction()) { + case KeyEvent.ACTION_DOWN: + KeyCode jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); +System.out.println ("[JVDBG] eventkeycode = "+event.getKeyCode()+" and jfxkc = "+jfxKeyCode+" with code "+ jfxKeyCode.impl_getCode()); + nativedispatchKeyEvent(PRESS, jfxKeyCode.impl_getCode(), jfxKeyCode.impl_getChar().toCharArray(), jfxKeyCode.impl_getChar().toCharArray().length, jfxModifiers); + break; + + case KeyEvent.ACTION_UP: + jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); + nativedispatchKeyEvent(RELEASE, jfxKeyCode.impl_getCode(), jfxKeyCode.impl_getChar().toCharArray(), jfxKeyCode.impl_getChar().toCharArray().length, jfxModifiers); + int unicodeChar = event.getUnicodeChar(); + if ((unicodeChar & KeyCharacterMap.COMBINING_ACCENT) != 0) { + deadKey = unicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK; + return; + } + + if (deadKey != 0 && unicodeChar != 0) { + unicodeChar = KeyCharacterMap.getDeadChar(deadKey, unicodeChar); + deadKey = 0; + } + + if (unicodeChar != 0) { + nativedispatchKeyEvent(TYPED, KeyCode.UNDEFINED.impl_getCode(), Character.toChars(unicodeChar), 1, jfxModifiers); + } + + break; + + case KeyEvent.ACTION_MULTIPLE: + if (event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN) { + nativedispatchKeyEvent(TYPED, KeyCode.UNDEFINED.impl_getCode(), event.getCharacters().toCharArray(), event.getCharacters().toCharArray().length, jfxModifiers); + } else { + jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); + for (int i = 0; i < event.getRepeatCount(); i++) { + nativedispatchKeyEvent(PRESS, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); + nativedispatchKeyEvent(RELEASE, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); + nativedispatchKeyEvent(TYPED, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); + } + } + + break; + default: + System.err.println("DalvikInput.onKeyEvent Unknown Action " + event.getAction()); + break; + } + } + + private final static int MODIFIER_SHIFT = 1; + private final static int MODIFIER_CONTROL = 2; + private final static int MODIFIER_ALT = 4; + private final static int MODIFIER_WINDOWS = 8; + + + private static int mapAndroidModifierToJfx(int androidMetaStates) { + int jfxModifiers = 0; + + if ((androidMetaStates & KeyEvent.META_SHIFT_MASK) != 0) { + jfxModifiers += MODIFIER_SHIFT; + } + + if ((androidMetaStates & KeyEvent.META_CTRL_MASK) != 0) { + jfxModifiers += MODIFIER_CONTROL; + } + + if ((androidMetaStates & KeyEvent.META_ALT_MASK) != 0) { + jfxModifiers += MODIFIER_ALT; + } + + if ((androidMetaStates & KeyEvent.META_META_ON) != 0) { + jfxModifiers += MODIFIER_WINDOWS; + } + return jfxModifiers; + } + + + private static KeyCode mapAndroidKeyCodeToJfx(int keycode) { + switch (keycode) { + case KeyEvent.KEYCODE_UNKNOWN: return KeyCode.UNDEFINED; + case KeyEvent.KEYCODE_HOME: return KeyCode.HOME; + case KeyEvent.KEYCODE_BACK: return KeyCode.ESCAPE; // special back key mapped to ESC + case KeyEvent.KEYCODE_0: return KeyCode.DIGIT0; + case KeyEvent.KEYCODE_1: return KeyCode.DIGIT1; + case KeyEvent.KEYCODE_2: return KeyCode.DIGIT2; + case KeyEvent.KEYCODE_3: return KeyCode.DIGIT3; + case KeyEvent.KEYCODE_4: return KeyCode.DIGIT4; + case KeyEvent.KEYCODE_5: return KeyCode.DIGIT5; + case KeyEvent.KEYCODE_6: return KeyCode.DIGIT6; + case KeyEvent.KEYCODE_7: return KeyCode.DIGIT7; + case KeyEvent.KEYCODE_8: return KeyCode.DIGIT8; + case KeyEvent.KEYCODE_9: return KeyCode.DIGIT9; + case KeyEvent.KEYCODE_STAR: return KeyCode.STAR; + case KeyEvent.KEYCODE_POUND: return KeyCode.POUND; + case KeyEvent.KEYCODE_DPAD_UP: return KeyCode.UP; + case KeyEvent.KEYCODE_DPAD_DOWN: return KeyCode.DOWN; + case KeyEvent.KEYCODE_DPAD_LEFT: return KeyCode.LEFT; + case KeyEvent.KEYCODE_DPAD_RIGHT: return KeyCode.RIGHT; + case KeyEvent.KEYCODE_VOLUME_UP: return KeyCode.VOLUME_UP; + case KeyEvent.KEYCODE_VOLUME_DOWN: return KeyCode.VOLUME_DOWN; + case KeyEvent.KEYCODE_POWER: return KeyCode.POWER; + case KeyEvent.KEYCODE_CLEAR: return KeyCode.CLEAR; + case KeyEvent.KEYCODE_A: return KeyCode.A; + case KeyEvent.KEYCODE_B: return KeyCode.B; + case KeyEvent.KEYCODE_C: return KeyCode.C; + case KeyEvent.KEYCODE_D: return KeyCode.D; + case KeyEvent.KEYCODE_E: return KeyCode.E; + case KeyEvent.KEYCODE_F: return KeyCode.F; + case KeyEvent.KEYCODE_G: return KeyCode.G; + case KeyEvent.KEYCODE_H: return KeyCode.H; + case KeyEvent.KEYCODE_I: return KeyCode.I; + case KeyEvent.KEYCODE_J: return KeyCode.J; + case KeyEvent.KEYCODE_K: return KeyCode.K; + case KeyEvent.KEYCODE_L: return KeyCode.L; + case KeyEvent.KEYCODE_M: return KeyCode.M; + case KeyEvent.KEYCODE_N: return KeyCode.N; + case KeyEvent.KEYCODE_O: return KeyCode.O; + case KeyEvent.KEYCODE_P: return KeyCode.P; + case KeyEvent.KEYCODE_Q: return KeyCode.Q; + case KeyEvent.KEYCODE_R: return KeyCode.R; + case KeyEvent.KEYCODE_S: return KeyCode.S; + case KeyEvent.KEYCODE_T: return KeyCode.T; + case KeyEvent.KEYCODE_U: return KeyCode.U; + case KeyEvent.KEYCODE_V: return KeyCode.V; + case KeyEvent.KEYCODE_W: return KeyCode.W; + case KeyEvent.KEYCODE_X: return KeyCode.X; + case KeyEvent.KEYCODE_Y: return KeyCode.Y; + case KeyEvent.KEYCODE_Z: return KeyCode.Z; + case KeyEvent.KEYCODE_COMMA: return KeyCode.COMMA; + case KeyEvent.KEYCODE_PERIOD: return KeyCode.PERIOD; + case KeyEvent.KEYCODE_ALT_LEFT: return KeyCode.ALT; + case KeyEvent.KEYCODE_ALT_RIGHT: return KeyCode.ALT; + case KeyEvent.KEYCODE_SHIFT_LEFT: return KeyCode.SHIFT; + case KeyEvent.KEYCODE_SHIFT_RIGHT: return KeyCode.SHIFT; + case KeyEvent.KEYCODE_TAB: return KeyCode.TAB; + case KeyEvent.KEYCODE_SPACE: return KeyCode.SPACE; + case KeyEvent.KEYCODE_ENTER: return KeyCode.ENTER; + case KeyEvent.KEYCODE_DEL: return KeyCode.BACK_SPACE; + case KeyEvent.KEYCODE_GRAVE: return KeyCode.DEAD_GRAVE; + case KeyEvent.KEYCODE_MINUS: return KeyCode.MINUS; + case KeyEvent.KEYCODE_EQUALS: return KeyCode.EQUALS; + case KeyEvent.KEYCODE_LEFT_BRACKET: return KeyCode.BRACELEFT; + case KeyEvent.KEYCODE_RIGHT_BRACKET: return KeyCode.BRACERIGHT; + case KeyEvent.KEYCODE_BACKSLASH: return KeyCode.BACK_SLASH; + case KeyEvent.KEYCODE_SEMICOLON: return KeyCode.SEMICOLON; + case KeyEvent.KEYCODE_SLASH: return KeyCode.SLASH; + case KeyEvent.KEYCODE_AT: return KeyCode.AT; + case KeyEvent.KEYCODE_PLUS: return KeyCode.PLUS; + case KeyEvent.KEYCODE_MENU: return KeyCode.CONTEXT_MENU; + case KeyEvent.KEYCODE_SEARCH: return KeyCode.FIND; + case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: return KeyCode.PLAY; + case KeyEvent.KEYCODE_MEDIA_STOP: return KeyCode.STOP; + case KeyEvent.KEYCODE_MEDIA_NEXT: return KeyCode.TRACK_NEXT; + case KeyEvent.KEYCODE_MEDIA_PREVIOUS: return KeyCode.TRACK_PREV; + case KeyEvent.KEYCODE_MEDIA_REWIND: return KeyCode.REWIND; + case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: return KeyCode.FAST_FWD; + case KeyEvent.KEYCODE_MUTE: return KeyCode.MUTE; + case KeyEvent.KEYCODE_PAGE_UP: return KeyCode.PAGE_UP; + case KeyEvent.KEYCODE_PAGE_DOWN: return KeyCode.PAGE_DOWN; + case KeyEvent.KEYCODE_BUTTON_A: return KeyCode.GAME_A; + case KeyEvent.KEYCODE_BUTTON_B: return KeyCode.GAME_B; + case KeyEvent.KEYCODE_BUTTON_C: return KeyCode.GAME_C; + case KeyEvent.KEYCODE_BUTTON_X: return KeyCode.GAME_D; + case KeyEvent.KEYCODE_BUTTON_MODE: return KeyCode.MODECHANGE; + case KeyEvent.KEYCODE_ESCAPE: return KeyCode.ESCAPE; + case KeyEvent.KEYCODE_CTRL_LEFT: return KeyCode.CONTROL; + case KeyEvent.KEYCODE_CTRL_RIGHT: return KeyCode.CONTROL; + case KeyEvent.KEYCODE_CAPS_LOCK: return KeyCode.CAPS; + case KeyEvent.KEYCODE_SCROLL_LOCK: return KeyCode.SCROLL_LOCK; + case KeyEvent.KEYCODE_META_LEFT: return KeyCode.META; + case KeyEvent.KEYCODE_META_RIGHT: return KeyCode.META; + case KeyEvent.KEYCODE_SYSRQ: return KeyCode.PRINTSCREEN; + case KeyEvent.KEYCODE_BREAK: return KeyCode.PAUSE; + case KeyEvent.KEYCODE_MOVE_HOME: return KeyCode.BEGIN; + case KeyEvent.KEYCODE_MOVE_END: return KeyCode.END; + case KeyEvent.KEYCODE_INSERT: return KeyCode.INSERT; + case KeyEvent.KEYCODE_MEDIA_PLAY: return KeyCode.PLAY; + case KeyEvent.KEYCODE_MEDIA_EJECT: return KeyCode.EJECT_TOGGLE; + case KeyEvent.KEYCODE_MEDIA_RECORD: return KeyCode.RECORD; + case KeyEvent.KEYCODE_F1: return KeyCode.F1; + case KeyEvent.KEYCODE_F2: return KeyCode.F2; + case KeyEvent.KEYCODE_F3: return KeyCode.F3; + case KeyEvent.KEYCODE_F4: return KeyCode.F4; + case KeyEvent.KEYCODE_F5: return KeyCode.F5; + case KeyEvent.KEYCODE_F6: return KeyCode.F6; + case KeyEvent.KEYCODE_F7: return KeyCode.F7; + case KeyEvent.KEYCODE_F8: return KeyCode.F8; + case KeyEvent.KEYCODE_F9: return KeyCode.F9; + case KeyEvent.KEYCODE_F10: return KeyCode.F10; + case KeyEvent.KEYCODE_F11: return KeyCode.F11; + case KeyEvent.KEYCODE_F12: return KeyCode.F12; + case KeyEvent.KEYCODE_NUM_LOCK: return KeyCode.NUM_LOCK; + case KeyEvent.KEYCODE_NUMPAD_0: return KeyCode.NUMPAD0; + case KeyEvent.KEYCODE_NUMPAD_1: return KeyCode.NUMPAD1; + case KeyEvent.KEYCODE_NUMPAD_2: return KeyCode.NUMPAD2; + case KeyEvent.KEYCODE_NUMPAD_3: return KeyCode.NUMPAD3; + case KeyEvent.KEYCODE_NUMPAD_4: return KeyCode.NUMPAD4; + case KeyEvent.KEYCODE_NUMPAD_5: return KeyCode.NUMPAD5; + case KeyEvent.KEYCODE_NUMPAD_6: return KeyCode.NUMPAD6; + case KeyEvent.KEYCODE_NUMPAD_7: return KeyCode.NUMPAD7; + case KeyEvent.KEYCODE_NUMPAD_8: return KeyCode.NUMPAD8; + case KeyEvent.KEYCODE_NUMPAD_9: return KeyCode.NUMPAD9; + case KeyEvent.KEYCODE_NUMPAD_DIVIDE: return KeyCode.DIVIDE; + case KeyEvent.KEYCODE_NUMPAD_MULTIPLY: return KeyCode.MULTIPLY; + case KeyEvent.KEYCODE_NUMPAD_SUBTRACT: return KeyCode.SUBTRACT; + case KeyEvent.KEYCODE_NUMPAD_ADD: return KeyCode.ADD; + case KeyEvent.KEYCODE_NUMPAD_DOT: return KeyCode.PERIOD; + case KeyEvent.KEYCODE_NUMPAD_COMMA: return KeyCode.COMMA; + case KeyEvent.KEYCODE_NUMPAD_ENTER: return KeyCode.ENTER; + case KeyEvent.KEYCODE_NUMPAD_EQUALS: return KeyCode.EQUALS; + case KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN: return KeyCode.LEFT_PARENTHESIS; + case KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN: return KeyCode.RIGHT_PARENTHESIS; + case KeyEvent.KEYCODE_VOLUME_MUTE: return KeyCode.MUTE; + case KeyEvent.KEYCODE_INFO: return KeyCode.INFO; + case KeyEvent.KEYCODE_CHANNEL_UP: return KeyCode.CHANNEL_UP; + case KeyEvent.KEYCODE_CHANNEL_DOWN: return KeyCode.CHANNEL_DOWN; + case KeyEvent.KEYCODE_PROG_RED: return KeyCode.COLORED_KEY_0; + case KeyEvent.KEYCODE_PROG_GREEN: return KeyCode.COLORED_KEY_1; + case KeyEvent.KEYCODE_PROG_YELLOW: return KeyCode.COLORED_KEY_2; + case KeyEvent.KEYCODE_PROG_BLUE: return KeyCode.COLORED_KEY_3; + case KeyEvent.KEYCODE_KATAKANA_HIRAGANA: return KeyCode.JAPANESE_HIRAGANA; + case KeyEvent.KEYCODE_KANA: return KeyCode.KANA; + default: + return KeyCode.UNDEFINED; + } + } + +} diff --git a/src/android/res/mipmap-hdpi/ic_launcher.png b/src/android/res/mipmap-hdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/android/res/mipmap-mdpi/ic_launcher.png b/src/android/res/mipmap-mdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/android/res/mipmap-xhdpi/ic_launcher.png b/src/android/res/mipmap-xhdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/android/res/mipmap-xxhdpi/ic_launcher.png b/src/android/res/mipmap-xxhdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/android/res/mipmap-xxxhdpi/ic_launcher.png b/src/android/res/mipmap-xxxhdpi/ic_launcher.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/100.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/100.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/1024.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/1024.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/114.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/114.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/120.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/120.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/144.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/144.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/152.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/152.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/167.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/167.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/180.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/180.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/20.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/20.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/29.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/29.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/40.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/40.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/50.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/50.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/57.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/57.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/58.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/58.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/60.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/60.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/72.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/72.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/76.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/76.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/80.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/80.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/87.png b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/87.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/AppIcon.appiconset/Contents.json b/src/ios/assets/Assets.xcassets/AppIcon.appiconset/Contents.json old mode 100644 new mode 100755 diff --git a/src/ios/assets/Assets.xcassets/Contents.json b/src/ios/assets/Assets.xcassets/Contents.json old mode 100644 new mode 100755 index da4a164c..30b95156 --- a/src/ios/assets/Assets.xcassets/Contents.json +++ b/src/ios/assets/Assets.xcassets/Contents.json @@ -1,6 +1,6 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } +{ + "info" : { + "version" : 1, + "author" : "xcode" + } } \ No newline at end of file diff --git a/src/ios/assets/Base.lproj/LaunchScreen.storyboard b/src/ios/assets/Base.lproj/LaunchScreen.storyboard old mode 100644 new mode 100755 index b655cdaa..d632bd56 --- a/src/ios/assets/Base.lproj/LaunchScreen.storyboard +++ b/src/ios/assets/Base.lproj/LaunchScreen.storyboard @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ios/assets/Base.lproj/MainScreen.storyboard b/src/ios/assets/Base.lproj/MainScreen.storyboard old mode 100644 new mode 100755 index 365c6a01..b70fd5e9 --- a/src/ios/assets/Base.lproj/MainScreen.storyboard +++ b/src/ios/assets/Base.lproj/MainScreen.storyboard @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ios/assets/Default-375w-667h@2x~iphone.png b/src/ios/assets/Default-375w-667h@2x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-375w-812h-landscape@3x~iphone.png b/src/ios/assets/Default-375w-812h-landscape@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-375w-812h@3x~iphone.png b/src/ios/assets/Default-375w-812h@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-414w-736h-landscape@3x~iphone.png b/src/ios/assets/Default-414w-736h-landscape@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-414w-736h@3x~iphone.png b/src/ios/assets/Default-414w-736h@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-414w-896h-landscape@3x~iphone.png b/src/ios/assets/Default-414w-896h-landscape@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-414w-896h@3x~iphone.png b/src/ios/assets/Default-414w-896h@3x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-568h@2x~iphone.png b/src/ios/assets/Default-568h@2x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-landscape@2x~ipad.png b/src/ios/assets/Default-landscape@2x~ipad.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-landscape~ipad.png b/src/ios/assets/Default-landscape~ipad.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-portrait@2x~ipad.png b/src/ios/assets/Default-portrait@2x~ipad.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default-portrait~ipad.png b/src/ios/assets/Default-portrait~ipad.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/Default@2x~iphone.png b/src/ios/assets/Default@2x~iphone.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/iTunesArtwork.png b/src/ios/assets/iTunesArtwork.png old mode 100644 new mode 100755 diff --git a/src/ios/assets/iTunesArtwork@2x.png b/src/ios/assets/iTunesArtwork@2x.png old mode 100644 new mode 100755 diff --git a/src/main/java/com/stream_pi/client/Main.java b/src/main/java/com/stream_pi/client/Main.java old mode 100644 new mode 100755 index 65f79390..5c831db8 --- a/src/main/java/com/stream_pi/client/Main.java +++ b/src/main/java/com/stream_pi/client/Main.java @@ -1,63 +1,63 @@ -package com.stream_pi.client; - -import com.stream_pi.client.controller.Controller; -import com.stream_pi.client.info.ClientInfo; - -import com.stream_pi.client.info.StartupFlags; -import javafx.application.Application; -import javafx.scene.Scene; -import javafx.stage.Stage; - -public class Main extends Application { - - - @Override - public void start(Stage stage) - { - Controller d = new Controller(); - Scene s = new Scene(d); - stage.setScene(s); - d.setHostServices(getHostServices()); - d.init(); - } - - - public static void main(String[] args) - { - for(String eachArg : args) - { - if(!eachArg.startsWith("Stream-Pi")) - continue; - - String[] r = eachArg.split("="); - String arg = r[0]; - String val = r[1]; - - switch (arg) { - case "Stream-Pi.startupRunnerFileName": - StartupFlags.RUNNER_FILE_NAME = val; - break; - case "Stream-Pi.showShutDownButton": - StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = val.equals("true"); - break; - case "Stream-Pi.isXMode": - StartupFlags.IS_X_MODE = val.equals("true"); - break; - case "Stream-Pi.isShowFullScreenToggleButton": - StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = val.equals("true"); - break; - case "Stream-Pi.defaultFullScreenMode": - StartupFlags.DEFAULT_FULLSCREEN_MODE = val.equals("true"); - break; - case "Stream-Pi.enableScreenSaverFeature": - StartupFlags.SCREEN_SAVER_FEATURE = val.equals("true"); - break; - case "Stream-Pi.appendPathBeforeRunnerFileToOvercomeJPackageLimitation": - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = val.equals("true"); - break; - } - } - - launch(args); - } -} +package com.stream_pi.client; + +import com.stream_pi.client.controller.Controller; +import com.stream_pi.client.info.ClientInfo; + +import com.stream_pi.client.info.StartupFlags; +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class Main extends Application { + + + @Override + public void start(Stage stage) + { + Controller d = new Controller(); + Scene s = new Scene(d); + stage.setScene(s); + d.setHostServices(getHostServices()); + d.init(); + } + + + public static void main(String[] args) + { + for(String eachArg : args) + { + if(!eachArg.startsWith("Stream-Pi")) + continue; + + String[] r = eachArg.split("="); + String arg = r[0]; + String val = r[1]; + + switch (arg) { + case "Stream-Pi.startupRunnerFileName": + StartupFlags.RUNNER_FILE_NAME = val; + break; + case "Stream-Pi.showShutDownButton": + StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = val.equals("true"); + break; + case "Stream-Pi.isXMode": + StartupFlags.IS_X_MODE = val.equals("true"); + break; + case "Stream-Pi.isShowFullScreenToggleButton": + StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = val.equals("true"); + break; + case "Stream-Pi.defaultFullScreenMode": + StartupFlags.DEFAULT_FULLSCREEN_MODE = val.equals("true"); + break; + case "Stream-Pi.enableScreenSaverFeature": + StartupFlags.SCREEN_SAVER_FEATURE = val.equals("true"); + break; + case "Stream-Pi.appendPathBeforeRunnerFileToOvercomeJPackageLimitation": + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = val.equals("true"); + break; + } + } + + launch(args); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java b/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java new file mode 100755 index 00000000..df910c10 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/AnimateFXInterpolator.java @@ -0,0 +1,13 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Interpolator; + +public final class AnimateFXInterpolator { + + private AnimateFXInterpolator() { + throw new IllegalStateException("AnimateFX Interpolator"); + } + + public static final Interpolator EASE = Interpolator.SPLINE(0.25, 0.1, 0.25, 1); + +} diff --git a/src/main/java/com/stream_pi/client/animations/AnimationFX.java b/src/main/java/com/stream_pi/client/animations/AnimationFX.java new file mode 100755 index 00000000..0d1ad181 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/AnimationFX.java @@ -0,0 +1,206 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Animation; +import javafx.animation.Timeline; +import javafx.event.ActionEvent; +import javafx.event.EventHandler; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public abstract class AnimationFX { + + /** + * Used to specify an animation that repeats indefinitely, until the + * {@code stop()} method is called. + */ + public static final int INDEFINITE = -1; + private Timeline timeline; + private boolean reset; + private Node node; + private AnimationFX nextAnimation; + private boolean hasNextAnimation; + + /** + * Create a new animation + * + * @param node the node to affect + */ + public AnimationFX(Node node) { + super(); + setNode(node); + + } + + /** + * Default constructor + */ + public AnimationFX() { + hasNextAnimation = false; + this.reset = false; + + + } + + /** + * Handle when the animation is finished + * + * @return + */ + private AnimationFX onFinished() { + if (reset) { + resetNode(); + } + if (this.nextAnimation != null) { + this.nextAnimation.play(); + } + return this; + } + + /** + * Set the next animation to play + * + * @param animation + * @return + */ + public AnimationFX playOnFinished(AnimationFX animation) { + setNextAnimation(animation); + return this; + + } + + /** + * Function to reset the node or not when the animation is finished + * + * @param reset + * @return + */ + public AnimationFX setResetOnFinished(boolean reset) { + this.reset = reset; + return this; + } + + /** + * Play the animation + */ + public void play() { + timeline.play(); + } + + /** + * Stop the animation + * + * @return + */ + public AnimationFX stop() { + timeline.stop(); + return this; + } + + /** + * Function the reset the node to original state + * + * @return + */ + abstract AnimationFX resetNode(); + + /** + * Function to initialize the timeline + */ + abstract void initTimeline(); + + + public Timeline getTimeline() { + return timeline; + } + + public void setTimeline(Timeline timeline) { + this.timeline = timeline; + } + + public boolean isResetOnFinished() { + return reset; + } + + protected void setReset(boolean reset) { + this.reset = reset; + } + + public Node getNode() { + return node; + } + + public void setNode(Node node) { + this.node = node; + initTimeline(); + timeline.statusProperty().addListener((observable, oldValue, newValue) -> { + if (newValue.equals(Animation.Status.STOPPED)) { + onFinished(); + } + + }); + } + + public AnimationFX getNextAnimation() { + return nextAnimation; + } + + protected void setNextAnimation(AnimationFX nextAnimation) { + hasNextAnimation = true; + this.nextAnimation = nextAnimation; + } + + public boolean hasNextAnimation() { + return hasNextAnimation; + } + + protected void setHasNextAnimation(boolean hasNextAnimation) { + this.hasNextAnimation = hasNextAnimation; + } + + /** + * Define the number of cycles in this animation + * + * @param value + * @return + */ + public AnimationFX setCycleCount(int value) { + this.timeline.setCycleCount(value); + return this; + } + + /** + * Set the speed factor of the animation + * + * @param value + * @return + */ + public AnimationFX setSpeed(double value) { + this.timeline.setRate(value); + return this; + } + + /** + * Delays the start of an animation + * + * @param value + * @return + */ + public AnimationFX setDelay(Duration value) { + this.timeline.setDelay(value); + return this; + } + + /** + * Set event when the animation ended. + * + * @param value + */ + public final void setOnFinished(EventHandler value) { + this.timeline.setOnFinished(value); + } + +} diff --git a/src/main/java/com/stream_pi/client/animations/Bounce.java b/src/main/java/com/stream_pi/client/animations/Bounce.java new file mode 100755 index 00000000..a10090b3 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Bounce.java @@ -0,0 +1,66 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Bounce extends AnimationFX { + + + /** + * Create new Bounce + * + * @param node The node to affect + */ + public Bounce(Node node) { + super(node); + } + + public Bounce() { + super(); + } + + @Override + public AnimationFX resetNode() { + getNode().setTranslateY(0); + return this; + } + + @Override + void initTimeline() { + setTimeline( + new Timeline( + + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().translateYProperty(), -30, Interpolator.SPLINE(0.755, 0.050, 0.855, 0.060)) + ), + new KeyFrame(Duration.millis(550), + new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(getNode().translateYProperty(), -15, Interpolator.SPLINE(0.755, 0.050, 0.855, 0.060)) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(900), + new KeyValue(getNode().translateYProperty(), -5, Interpolator.SPLINE(0.755, 0.050, 0.855, 0.060)) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().translateYProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ) + + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/Flash.java b/src/main/java/com/stream_pi/client/animations/Flash.java new file mode 100755 index 00000000..8bb9a7a0 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Flash.java @@ -0,0 +1,57 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Flash extends AnimationFX { + + /** + * Create new Flash + * + * @param node The node to affect + */ + public Flash(Node node) { + super(node); + } + + public Flash() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(250), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(750), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ) + + )); + } + +} + diff --git a/src/main/java/com/stream_pi/client/animations/Flip.java b/src/main/java/com/stream_pi/client/animations/Flip.java new file mode 100755 index 00000000..4a9aa993 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Flip.java @@ -0,0 +1,77 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.ParallelCamera; +import javafx.scene.PerspectiveCamera; +import javafx.util.Duration; + +import static javafx.scene.transform.Rotate.Y_AXIS; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Flip extends AnimationFX { + + /** + * Create new Flip + * + * @param node The node to affect + */ + public Flip(Node node) { + super(node); + } + + public Flip() { + } + + @Override + AnimationFX resetNode() { + getNode().setRotate(0); + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + getNode().setTranslateZ(0); + return this; + } + + @Override + void initTimeline() { + getNode().getScene().setCamera(new PerspectiveCamera()); + getNode().setRotationAxis(Y_AXIS); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().rotateProperty(), 360, Interpolator.EASE_OUT) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().rotateProperty(), 190, Interpolator.EASE_OUT), + new KeyValue(getNode().translateZProperty(), -150, Interpolator.EASE_OUT) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().rotateProperty(), 170, Interpolator.EASE_IN), + new KeyValue(getNode().translateZProperty(), -150, Interpolator.EASE_IN) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().scaleXProperty(), 0.95, Interpolator.EASE_IN), + new KeyValue(getNode().scaleYProperty(), 0.95, Interpolator.EASE_IN), + new KeyValue(getNode().scaleZProperty(), 0.95, Interpolator.EASE_IN) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().rotateProperty(), 0, Interpolator.EASE_IN), + new KeyValue(getNode().scaleXProperty(), 1, Interpolator.EASE_IN), + new KeyValue(getNode().scaleYProperty(), 1, Interpolator.EASE_IN), + new KeyValue(getNode().scaleZProperty(), 1, Interpolator.EASE_IN), + new KeyValue(getNode().translateZProperty(), 0, Interpolator.EASE_IN) + ) + )); + //TODO + getTimeline().setOnFinished(event -> getNode().getScene().setCamera(new ParallelCamera())); + + } + +} + diff --git a/src/main/java/com/stream_pi/client/animations/JackInTheBox.java b/src/main/java/com/stream_pi/client/animations/JackInTheBox.java new file mode 100755 index 00000000..202427e5 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/JackInTheBox.java @@ -0,0 +1,65 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class JackInTheBox extends AnimationFX { + + /** + * Create new JackInTheBox animation + * + * @param node The node to affect + */ + public JackInTheBox(Node node) { + super(node); + + } + + public JackInTheBox() { + } + + private Rotate rotate; + + @Override + AnimationFX resetNode() { + getNode().setScaleX(1); + getNode().setScaleZ(1); + getNode().setScaleY(1); + getNode().setOpacity(1); + rotate.setAngle(0); + return this; + } + + @Override + void initTimeline() { + rotate = new Rotate(30, getNode().getBoundsInParent().getWidth() / 2, getNode().getBoundsInParent().getHeight()); + getNode().getTransforms().add(rotate); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(rotate.angleProperty(), 30, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 0.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(rotate.angleProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(rotate.angleProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(rotate.angleProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/Jello.java b/src/main/java/com/stream_pi/client/animations/Jello.java new file mode 100755 index 00000000..629aee72 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Jello.java @@ -0,0 +1,74 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.geometry.Bounds; +import javafx.scene.Node; +import javafx.scene.transform.Shear; +import javafx.util.Duration; + +/** + * @author Remi Lenoir + */ + +public class Jello extends AnimationFX { + /** + * Create new Jello + * + * @param node The node to affect + */ + public Jello(Node node) { + super(node); + } + + public Jello() { + } + + @Override + AnimationFX resetNode() { + shear.setX(0); + shear.setY(0); + return this; + } + + private Shear shear; + + @Override + void initTimeline() { + shear = new Shear(); + Bounds bounds = getNode().getLayoutBounds(); + shear.setPivotX(bounds.getWidth() / 2); + shear.setPivotY(bounds.getHeight() / 2); + getNode().getTransforms().add(shear); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(shear.xProperty(), 0), + new KeyValue(shear.yProperty(), 0)), + new KeyFrame(Duration.millis(111), + new KeyValue(shear.xProperty(), 0.125), + new KeyValue(shear.yProperty(), 0.125)), + new KeyFrame(Duration.millis(222), + new KeyValue(shear.xProperty(), -0.625), + new KeyValue(shear.yProperty(), -0.625)), + new KeyFrame(Duration.millis(333), + new KeyValue(shear.xProperty(), 0.3125), + new KeyValue(shear.yProperty(), 0.3125)), + new KeyFrame(Duration.millis(444), + new KeyValue(shear.xProperty(), -0.15625), + new KeyValue(shear.yProperty(), -0.15625)), + new KeyFrame(Duration.millis(555), + new KeyValue(shear.xProperty(), 0.078125), + new KeyValue(shear.yProperty(), 0.078125)), + new KeyFrame(Duration.millis(666), + new KeyValue(shear.xProperty(), -0.0390625), + new KeyValue(shear.yProperty(), -0.0390625)), + new KeyFrame(Duration.millis(777), + new KeyValue(shear.xProperty(), 0.01953125), + new KeyValue(shear.yProperty(), 0.01953125)), + new KeyFrame(Duration.millis(888), + new KeyValue(shear.xProperty(), 0), + new KeyValue(shear.yProperty(), 0)))); + } + +} diff --git a/src/main/java/com/stream_pi/client/animations/Pulse.java b/src/main/java/com/stream_pi/client/animations/Pulse.java new file mode 100755 index 00000000..7d2116f2 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Pulse.java @@ -0,0 +1,57 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier + */ +public class Pulse extends AnimationFX { + + /** + * Create new Pulse + * + * @param node The node to affect + */ + public Pulse(Node node) { + super(node); + } + + public Pulse() { + } + + + @Override + AnimationFX resetNode() { + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().scaleXProperty(), 1.05, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.05, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.05, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/RubberBand.java b/src/main/java/com/stream_pi/client/animations/RubberBand.java new file mode 100755 index 00000000..251665ae --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RubberBand.java @@ -0,0 +1,80 @@ +package com.stream_pi.client.animations; + + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RubberBand extends AnimationFX { + + /** + * Create new RubberBand + * + * @param node The node to affect + */ + public RubberBand(Node node) { + super(node); + } + + public RubberBand() { + } + + @Override + AnimationFX resetNode() { + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().scaleXProperty(), 1.25, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.75, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().scaleXProperty(), 0.75, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.25, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().scaleXProperty(), 1.15, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.85, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(650), + new KeyValue(getNode().scaleXProperty(), 0.95, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.05, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(750), + new KeyValue(getNode().scaleXProperty(), 1.05, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.95, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } + +} + + + diff --git a/src/main/java/com/stream_pi/client/animations/Shake.java b/src/main/java/com/stream_pi/client/animations/Shake.java new file mode 100755 index 00000000..3869f3de --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Shake.java @@ -0,0 +1,75 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Shake extends AnimationFX { + + /** + * Create new Shake + * + * @param node The node to affect + */ + public Shake(Node node) { + super(node); + } + + public Shake() { + } + + @Override + AnimationFX resetNode() { + + getNode().setTranslateX(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(100), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(getNode().translateXProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().translateXProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().translateXProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().translateXProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(900), + new KeyValue(getNode().translateXProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + + + diff --git a/src/main/java/com/stream_pi/client/animations/Swing.java b/src/main/java/com/stream_pi/client/animations/Swing.java new file mode 100755 index 00000000..7cefb590 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Swing.java @@ -0,0 +1,63 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Swing extends AnimationFX { + + /** + * Create new Swing + * + * @param node The node to affect + */ + public Swing(Node node) { + super(node); + } + + public Swing() { + } + + private Rotate rotation; + + @Override + AnimationFX resetNode() { + rotation.setAngle(0); + return this; + } + + @Override + void initTimeline() { + rotation = new Rotate(); + rotation.setPivotX(getNode().getLayoutBounds().getWidth() / 2.0); + rotation.setPivotY(-getNode().getLayoutBounds().getHeight()); + getNode().getTransforms().add(rotation); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(rotation.angleProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(rotation.angleProperty(), 15, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(rotation.angleProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(rotation.angleProperty(), 5, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(rotation.angleProperty(), -5, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(rotation.angleProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/Tada.java b/src/main/java/com/stream_pi/client/animations/Tada.java new file mode 100755 index 00000000..c981d52d --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Tada.java @@ -0,0 +1,110 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Tada extends AnimationFX { + + /** + * Create new Swing + * + * @param node The node to affect + */ + public Tada(Node node) { + super(node); + } + + public Tada() { + } + + @Override + AnimationFX resetNode() { + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + getNode().setRotationAxis(Rotate.Z_AXIS); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + + ), + new KeyFrame(Duration.millis(100), + new KeyValue(getNode().scaleXProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(getNode().scaleXProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(900), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/Wobble.java b/src/main/java/com/stream_pi/client/animations/Wobble.java new file mode 100755 index 00000000..71b18372 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/Wobble.java @@ -0,0 +1,66 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class Wobble extends AnimationFX { + + /** + * Create new Wobble + * + * @param node The node to affect + */ + public Wobble(Node node) { + super(node); + } + + public Wobble() { + } + + @Override + AnimationFX resetNode() { + getNode().setTranslateX(0); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(150), + new KeyValue(getNode().translateXProperty(), -0.25 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -5, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().translateXProperty(), 0.2 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(450), + new KeyValue(getNode().translateXProperty(), -0.15 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().translateXProperty(), 0.1 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 2, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(750), + new KeyValue(getNode().translateXProperty(), -0.05 * getNode().getBoundsInParent().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} diff --git a/src/main/java/com/stream_pi/client/connection/Client.java b/src/main/java/com/stream_pi/client/connection/Client.java old mode 100644 new mode 100755 index 50c98dba..45b3fd1d --- a/src/main/java/com/stream_pi/client/connection/Client.java +++ b/src/main/java/com/stream_pi/client/connection/Client.java @@ -1,963 +1,963 @@ -package com.stream_pi.client.connection; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; -import com.stream_pi.action_api.action.DisplayTextAlignment; -import com.stream_pi.action_api.action.Location; -import com.stream_pi.action_api.actionproperty.ClientProperties; -import com.stream_pi.action_api.actionproperty.property.Property; -import com.stream_pi.action_api.actionproperty.property.Type; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.comms.Message; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.version.Version; -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.geometry.Orientation; - -import java.io.*; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Logger; - -public class Client extends Thread -{ - - private Socket socket; - - private ObjectOutputStream oos; - private ObjectInputStream ois; - - private AtomicBoolean stop = new AtomicBoolean(false); - - private ClientListener clientListener; - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - private ClientInfo clientInfo; - - private String serverIP; - private int serverPort; - private Logger logger; - - private Runnable onConnectAndSetupToBeRun; - - public Client(String serverIP, int serverPort, ClientListener clientListener, - ExceptionAndAlertHandler exceptionAndAlertHandler, Runnable onConnectAndSetupToBeRun) - { - this.serverIP = serverIP; - this.serverPort = serverPort; - - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.clientInfo = ClientInfo.getInstance(); - this.clientListener = clientListener; - - this.onConnectAndSetupToBeRun = onConnectAndSetupToBeRun; - - logger = Logger.getLogger(Client.class.getName()); - - clientListener.getExecutor().submit(new Task() { - @Override - protected Void call() - { - try - { - try - { - logger.info("Trying to connect to server at "+serverIP+":"+serverPort); - socket = new Socket(); - socket.connect(new InetSocketAddress(serverIP, serverPort), 5000); - clientListener.setConnected(true); - logger.info("Connected to "+socket.getRemoteSocketAddress()+" !"); - } - catch (IOException e) - { - e.printStackTrace(); - clientListener.setConnected(false); - throw new MinorException("Connection Error", "Unable to connect to server. Please check settings and connection and try again."); - } - finally - { - clientListener.updateSettingsConnectDisconnectButton(); - } - - try - { - oos = new ObjectOutputStream(socket.getOutputStream()); - ois = new ObjectInputStream(socket.getInputStream()); - } - catch (IOException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - throw new MinorException("Unable to set up io Streams to server. Check connection and try again."); - } - - start(); - } catch (MinorException e) - { - exceptionAndAlertHandler.handleMinorException(e); - } - return null; - } - }); - } - - public synchronized void exit() - { - if(stop.get()) - return; - - logger.info("Stopping ..."); - - try - { - if(socket!=null) - { - disconnect(); - } - } - catch (SevereException e) - { - logger.severe(e.getMessage()); - exceptionAndAlertHandler.handleSevereException(e); - e.printStackTrace(); - } - } - - - public synchronized void sendMessage(Message message) throws SevereException - { - try - { - oos.writeObject(message); - oos.flush(); - } - catch (IOException e) - { - e.printStackTrace(); - throw new SevereException("Unable to write to io Stream!"); - } - } - - @Override - public void run() { - try - { - while(!stop.get()) - { - try - { - Message message = (Message) ois.readObject(); - - String header = message.getHeader(); - - logger.info("Message Received. Heading : "+header); - - switch (header) - { - case "ready" : onServerReady(); - break; - - case "action_icon" : onActionIconReceived(message); - break; - - case "disconnect" : serverDisconnected(message); - break; - - case "get_client_details" : sendClientDetails(); - break; - - case "get_client_screen_details" : sendClientScreenDetails(); - break; - - case "get_profiles" : sendProfileNamesToServer(); - break; - - case "get_profile_details": sendProfileDetailsToServer(message); - break; - - case "save_action_details": saveActionDetails(message); - break; - - case "delete_action": deleteAction(message); - break; - - case "get_themes": sendThemesToServer(); - break; - - case "save_client_details": saveClientDetails(message); - break; - - case "save_client_profile": saveProfileDetails(message); - break; - - case "delete_profile": deleteProfile(message); - break; - - case "action_failed": actionFailed(message); - break; - - case "set_toggle_status": onSetToggleStatus(message); - break; - - default: logger.warning("Command '"+header+"' does not match records. Make sure client and server versions are equal."); - - } - } - catch (IOException | ClassNotFoundException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - - clientListener.setConnected(false); - clientListener.updateSettingsConnectDisconnectButton(); - clientListener.onDisconnect(); - - if(!stop.get()) - { - //isDisconnect.set(true); //Prevent running disconnect - throw new MinorException("Accidentally disconnected from Server! (Failed at readUTF)"); - } - - exit(); - - return; - } - } - } - catch (SevereException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - - exceptionAndAlertHandler.handleSevereException(e); - } - catch (MinorException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - - exceptionAndAlertHandler.handleMinorException(e); - } - } - - private void onSetToggleStatus(Message message) - { - String[] arr = message.getStringArrValue(); - - String profileID = arr[0]; - String actionID = arr[1]; - boolean newStatus = arr[2].equals("true"); - - boolean currentStatus = clientListener.getToggleStatus(profileID,actionID); - - if(currentStatus == newStatus) - { - return; - } - - ActionBox actionBox = clientListener.getActionBoxByProfileAndID(profileID, actionID); - - if(actionBox!=null) - { - actionBox.setCurrentToggleStatus(newStatus); - Platform.runLater(()-> actionBox.toggle(newStatus)); - } - } - - private void onActionIconReceived(Message message) throws MinorException - { - String profileID = message.getStringArrValue()[0]; - String actionID = message.getStringArrValue()[1]; - String state = message.getStringArrValue()[2]; - - clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon( - actionID, - message.getByteArrValue(), - state - ); - - Action a = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - clientListener.renderAction(profileID, a); - } - - - - //commands - - public synchronized void sendIcon(String profileID, String actionID, String state, byte[] icon) throws SevereException - { - try - { - Thread.sleep(50); - } - catch (InterruptedException e) - { - e.printStackTrace(); - } - - Message message = new Message("action_icon"); - message.setStringArrValue(profileID, actionID, state); - message.setByteArrValue(icon); - sendMessage(message); - } - - public void disconnect() throws SevereException - { - disconnect(""); - } - - public void disconnect(String message) throws SevereException - { - if(stop.get()) - return; - - stop.set(true); - - logger.info("Sending server disconnect message ..."); - - Message m = new Message("disconnect"); - m.setStringValue(message); - sendMessage(m); - - try - { - if(!socket.isClosed()) - socket.close(); - - clientListener.setConnected(false); - clientListener.updateSettingsConnectDisconnectButton(); - } - catch (IOException e) - { - e.printStackTrace(); - throw new SevereException("Unable to close socket"); - } - } - - public void onServerReady() - { - if(onConnectAndSetupToBeRun!=null) - { - onConnectAndSetupToBeRun.run(); - onConnectAndSetupToBeRun = null; - } - } - - public void sendThemesToServer() throws SevereException - { - Message message = new Message("themes"); - - String[] arr = new String[clientListener.getThemes().getThemeList().size()*4]; - - int x = 0; - for(int i = 0;i a = new ArrayList<>(); - - a.add(profileID); - a.add(action.getID()); - a.add(action.getActionType()+""); - - if(action.getActionType() == ActionType.NORMAL || - action.getActionType() == ActionType.TOGGLE) { - a.add(action.getVersion().getText()); - } - else - { - a.add("no"); - } - - if(action.getActionType() ==ActionType.NORMAL || - action.getActionType() == ActionType.TOGGLE) - { - a.add(action.getModuleName()); - } - else - { - a.add("nut"); - } - - //display - - a.add(action.getBgColourHex()); - - //icon - - - StringBuilder allIconStatesNames = new StringBuilder(); - for(String eachState : action.getIcons().keySet()) - { - allIconStatesNames.append(eachState).append("::"); - } - a.add(allIconStatesNames.toString()); - - - a.add(action.getCurrentIconState()+""); - - //text - a.add(action.isShowDisplayText()+""); - a.add(action.getDisplayTextFontColourHex()); - a.add(action.getDisplayText()); - a.add(action.getNameFontSize()+""); - a.add(action.getDisplayTextAlignment()+""); - - //location - - if(action.getLocation() == null) - { - a.add("-1"); - a.add("-1"); - } - else - { - a.add(action.getLocation().getRow()+""); - a.add(action.getLocation().getCol()+""); - } - - a.add(action.getParent()); - - a.add(action.getDelayBeforeExecuting()+""); - - //client properties - - ClientProperties clientProperties = action.getClientProperties(); - - a.add(clientProperties.getSize()+""); - - for(Property property : clientProperties.get()) - { - a.add(property.getName()); - a.add(property.getRawValue()); - } - - - - Message message = new Message("action_details"); - - String[] x = new String[a.size()]; - x = a.toArray(x); - - message.setStringArrValue(x); - sendMessage(message); - - } - - public void saveActionDetails(Message message) - { - String[] r = message.getStringArrValue(); - - String profileID = r[0]; - - String actionID = r[1]; - ActionType actionType = ActionType.valueOf(r[2]); - - //3 - Version - //4 - ModuleName - - //display - String bgColorHex = r[5]; - - String[] iconStates = r[6].split("::"); - String currentIconState = r[7]; - - //text - boolean isShowDisplayText = r[8].equals("true"); - String displayFontColor = r[9]; - String displayText = r[10]; - double displayLabelFontSize = Double.parseDouble(r[11]); - DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[12]); - - //location - String row = r[13]; - String col = r[14]; - - Location location = new Location(Integer.parseInt(row), Integer.parseInt(col)); - - Action action = new Action(actionID, actionType); - - if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE) - { - try - { - action.setVersion(new Version(r[3])); - action.setModuleName(r[4]); - } - catch (Exception e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - } - } - - - action.setBgColourHex(bgColorHex); - - action.setShowDisplayText(isShowDisplayText); - action.setDisplayTextFontColourHex(displayFontColor); - action.setDisplayText(displayText); - action.setDisplayTextAlignment(displayTextAlignment); - action.setNameFontSize(displayLabelFontSize); - action.setCurrentIconState(currentIconState); - - action.setLocation(location); - - - String parent = r[15]; - action.setParent(parent); - - //client properties - - action.setDelayBeforeExecuting(Integer.parseInt(r[16])); - - int clientPropertiesSize = Integer.parseInt(r[17]); - - ClientProperties clientProperties = new ClientProperties(); - - if(actionType == ActionType.FOLDER) - clientProperties.setDuplicatePropertyAllowed(true); - - for(int i = 18;i<((clientPropertiesSize*2) + 18); i+=2) - { - Property property = new Property(r[i], Type.STRING); - property.setRawValue(r[i+1]); - - clientProperties.addProperty(property); - } - - action.setClientProperties(clientProperties); - - try - { - Action old = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID()); - - if(old != null) - { - for(String oldState : old.getIcons().keySet()) - { - boolean isPresent = false; - for(String state : iconStates) - { - if(state.equals(oldState)) - { - isPresent = true; - action.addIcon(state, old.getIcon(state)); - break; - } - } - - if(!isPresent) - { - // State no longer exists. Delete. - - new File(Config.getInstance().getIconsPath()+"/"+actionID+"___"+oldState).delete(); - } - } - } - - clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action); - - clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action); - - clientListener.renderAction(profileID, action); - - if(clientListener.getScreenSaver()!=null) - { - Platform.runLater(()->clientListener.getScreenSaver().restart()); - } - } - catch (Exception e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); - } - } - - public void deleteAction(Message message) - { - try - { - String[] arr = message.getStringArrValue(); - String profileID = arr[0]; - String actionID = arr[1]; - - Action acc = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - - if(acc == null) - { - exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action "+actionID+" since it does not exist.")); - return; - } - - if(acc.getActionType() == ActionType.FOLDER) - { - ArrayList idsToBeRemoved = new ArrayList<>(); - - ArrayList folders = new ArrayList<>(); - String folderToBeDeletedID = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID(); - - folders.add(folderToBeDeletedID); - - boolean startOver = true; - while(startOver) - { - startOver = false; - for(Action action : clientListener.getClientProfiles().getProfileFromID(profileID).getActions()) - { - if(folders.contains(action.getParent())) - { - if(!idsToBeRemoved.contains(action.getID())) - { - idsToBeRemoved.add(action.getID()); - if(action.getActionType() == ActionType.FOLDER) - { - folders.add(action.getID()); - startOver = true; - } - } - } - } - } - - - for(String ids : idsToBeRemoved) - { - clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids); - } - - Platform.runLater(clientListener::renderRootDefaultProfile); - - } - else if (acc.getActionType() == ActionType.COMBINE) - { - for(Property property : acc.getClientProperties().get()) - { - clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue()); - } - } - - - clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID()); - - clientListener.getClientProfiles().getProfileFromID(profileID).saveActions(); - - if(acc.getLocation().getCol()!=-1) - { - Platform.runLater(()-> { - if (clientListener.getCurrentProfile().getID().equals(profileID) - && clientListener.getCurrentParent().equals(acc.getParent())) - { - clientListener.clearActionBox( - acc.getLocation().getCol(), - acc.getLocation().getRow() - ); - } - }); - } - - - } - catch (Exception e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); - } - } - - public void saveClientDetails(Message message) - { - try - { - boolean reInit = false; - - String[] sep = message.getStringArrValue(); - - Config.getInstance().setNickName(sep[0]); - - - Config.getInstance().setStartupProfileID(sep[1]); - - String oldThemeFullName = Config.getInstance().getCurrentThemeFullName(); - String newThemeFullName = sep[2]; - - Config.getInstance().setCurrentThemeFullName(sep[2]); - Config.getInstance().save(); - - if(!oldThemeFullName.equals(newThemeFullName)) - { - Platform.runLater(()-> { - try { - clientListener.initThemes(); - } catch (SevereException e) { - exceptionAndAlertHandler.handleSevereException(e); - } - }); - } - - Platform.runLater(clientListener::loadSettings); - } - catch (SevereException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(e); - } - } - - public void saveProfileDetails(Message message) throws SevereException, MinorException - { - String[] sep = message.getStringArrValue(); - - ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(sep[0]); - - if(clientProfile == null) - { - clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+sep[0]+".xml"), - Config.getInstance().getIconsPath()); - } - - clientProfile.setName(sep[1]); - clientProfile.setRows(Integer.parseInt(sep[2])); - clientProfile.setCols(Integer.parseInt(sep[3])); - clientProfile.setActionSize(Integer.parseInt(sep[4])); - clientProfile.setActionGap(Integer.parseInt(sep[5])); - - try - { - clientListener.getClientProfiles().addProfile(clientProfile); - clientProfile.saveProfileDetails(); - clientListener.refreshGridIfCurrentProfile(sep[0]); - Platform.runLater(clientListener::loadSettings); - } - catch (Exception e) - { - e.printStackTrace(); - throw new SevereException(e.getMessage()); - } - } - - public void deleteProfile(Message message) - { - clientListener.getClientProfiles().deleteProfile(clientListener.getClientProfiles().getProfileFromID( - message.getStringValue() - )); - - if(clientListener.getCurrentProfile().getID().equals(message.getStringValue())) - { - Platform.runLater(clientListener::renderRootDefaultProfile); - } - } - - public void onActionClicked(String profileID, String actionID, boolean toggleState) throws SevereException - { - Message m = new Message("action_clicked"); - m.setStringArrValue(profileID, actionID, toggleState+""); - sendMessage(m); - } - - public void updateOrientationOnClient(Orientation orientation) throws SevereException - { - Message m = new Message("client_orientation"); - m.setStringValue(orientation.toString()); - sendMessage(m); - } - - public void actionFailed(Message message) - { - String[] r = message.getStringArrValue(); - String profileID = r[0]; - String actionID = r[1]; - clientListener.onActionFailed(profileID, actionID); - } -} +package com.stream_pi.client.connection; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; +import com.stream_pi.action_api.action.DisplayTextAlignment; +import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.actionproperty.ClientProperties; +import com.stream_pi.action_api.actionproperty.property.Property; +import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.comms.Message; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.version.Version; +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.geometry.Orientation; + +import java.io.*; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Logger; + +public class Client extends Thread +{ + + private Socket socket; + + private ObjectOutputStream oos; + private ObjectInputStream ois; + + private AtomicBoolean stop = new AtomicBoolean(false); + + private ClientListener clientListener; + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + private ClientInfo clientInfo; + + private String serverIP; + private int serverPort; + private Logger logger; + + private Runnable onConnectAndSetupToBeRun; + + public Client(String serverIP, int serverPort, ClientListener clientListener, + ExceptionAndAlertHandler exceptionAndAlertHandler, Runnable onConnectAndSetupToBeRun) + { + this.serverIP = serverIP; + this.serverPort = serverPort; + + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.clientInfo = ClientInfo.getInstance(); + this.clientListener = clientListener; + + this.onConnectAndSetupToBeRun = onConnectAndSetupToBeRun; + + logger = Logger.getLogger(Client.class.getName()); + + clientListener.getExecutor().submit(new Task() { + @Override + protected Void call() + { + try + { + try + { + logger.info("Trying to connect to server at "+serverIP+":"+serverPort); + socket = new Socket(); + socket.connect(new InetSocketAddress(serverIP, serverPort), 5000); + clientListener.setConnected(true); + logger.info("Connected to "+socket.getRemoteSocketAddress()+" !"); + } + catch (IOException e) + { + e.printStackTrace(); + clientListener.setConnected(false); + throw new MinorException("Connection Error", "Unable to connect to server. Please check settings and connection and try again."); + } + finally + { + clientListener.updateSettingsConnectDisconnectButton(); + } + + try + { + oos = new ObjectOutputStream(socket.getOutputStream()); + ois = new ObjectInputStream(socket.getInputStream()); + } + catch (IOException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + throw new MinorException("Unable to set up io Streams to server. Check connection and try again."); + } + + start(); + } catch (MinorException e) + { + exceptionAndAlertHandler.handleMinorException(e); + } + return null; + } + }); + } + + public synchronized void exit() + { + if(stop.get()) + return; + + logger.info("Stopping ..."); + + try + { + if(socket!=null) + { + disconnect(); + } + } + catch (SevereException e) + { + logger.severe(e.getMessage()); + exceptionAndAlertHandler.handleSevereException(e); + e.printStackTrace(); + } + } + + + public synchronized void sendMessage(Message message) throws SevereException + { + try + { + oos.writeObject(message); + oos.flush(); + } + catch (IOException e) + { + e.printStackTrace(); + throw new SevereException("Unable to write to io Stream!"); + } + } + + @Override + public void run() { + try + { + while(!stop.get()) + { + try + { + Message message = (Message) ois.readObject(); + + String header = message.getHeader(); + + logger.info("Message Received. Heading : "+header); + + switch (header) + { + case "ready" : onServerReady(); + break; + + case "action_icon" : onActionIconReceived(message); + break; + + case "disconnect" : serverDisconnected(message); + break; + + case "get_client_details" : sendClientDetails(); + break; + + case "get_client_screen_details" : sendClientScreenDetails(); + break; + + case "get_profiles" : sendProfileNamesToServer(); + break; + + case "get_profile_details": sendProfileDetailsToServer(message); + break; + + case "save_action_details": saveActionDetails(message); + break; + + case "delete_action": deleteAction(message); + break; + + case "get_themes": sendThemesToServer(); + break; + + case "save_client_details": saveClientDetails(message); + break; + + case "save_client_profile": saveProfileDetails(message); + break; + + case "delete_profile": deleteProfile(message); + break; + + case "action_failed": actionFailed(message); + break; + + case "set_toggle_status": onSetToggleStatus(message); + break; + + default: logger.warning("Command '"+header+"' does not match records. Make sure client and server versions are equal."); + + } + } + catch (IOException | ClassNotFoundException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + + clientListener.setConnected(false); + clientListener.updateSettingsConnectDisconnectButton(); + clientListener.onDisconnect(); + + if(!stop.get()) + { + //isDisconnect.set(true); //Prevent running disconnect + throw new MinorException("Accidentally disconnected from Server! (Failed at readUTF)"); + } + + exit(); + + return; + } + } + } + catch (SevereException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + + exceptionAndAlertHandler.handleSevereException(e); + } + catch (MinorException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + + exceptionAndAlertHandler.handleMinorException(e); + } + } + + private void onSetToggleStatus(Message message) + { + String[] arr = message.getStringArrValue(); + + String profileID = arr[0]; + String actionID = arr[1]; + boolean newStatus = arr[2].equals("true"); + + boolean currentStatus = clientListener.getToggleStatus(profileID,actionID); + + if(currentStatus == newStatus) + { + return; + } + + ActionBox actionBox = clientListener.getActionBoxByProfileAndID(profileID, actionID); + + if(actionBox!=null) + { + actionBox.setCurrentToggleStatus(newStatus); + Platform.runLater(()-> actionBox.toggle(newStatus)); + } + } + + private void onActionIconReceived(Message message) throws MinorException + { + String profileID = message.getStringArrValue()[0]; + String actionID = message.getStringArrValue()[1]; + String state = message.getStringArrValue()[2]; + + clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon( + actionID, + message.getByteArrValue(), + state + ); + + Action a = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + clientListener.renderAction(profileID, a); + } + + + + //commands + + public synchronized void sendIcon(String profileID, String actionID, String state, byte[] icon) throws SevereException + { + try + { + Thread.sleep(50); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + + Message message = new Message("action_icon"); + message.setStringArrValue(profileID, actionID, state); + message.setByteArrValue(icon); + sendMessage(message); + } + + public void disconnect() throws SevereException + { + disconnect(""); + } + + public void disconnect(String message) throws SevereException + { + if(stop.get()) + return; + + stop.set(true); + + logger.info("Sending server disconnect message ..."); + + Message m = new Message("disconnect"); + m.setStringValue(message); + sendMessage(m); + + try + { + if(!socket.isClosed()) + socket.close(); + + clientListener.setConnected(false); + clientListener.updateSettingsConnectDisconnectButton(); + } + catch (IOException e) + { + e.printStackTrace(); + throw new SevereException("Unable to close socket"); + } + } + + public void onServerReady() + { + if(onConnectAndSetupToBeRun!=null) + { + onConnectAndSetupToBeRun.run(); + onConnectAndSetupToBeRun = null; + } + } + + public void sendThemesToServer() throws SevereException + { + Message message = new Message("themes"); + + String[] arr = new String[clientListener.getThemes().getThemeList().size()*4]; + + int x = 0; + for(int i = 0;i a = new ArrayList<>(); + + a.add(profileID); + a.add(action.getID()); + a.add(action.getActionType()+""); + + if(action.getActionType() == ActionType.NORMAL || + action.getActionType() == ActionType.TOGGLE) { + a.add(action.getVersion().getText()); + } + else + { + a.add("no"); + } + + if(action.getActionType() ==ActionType.NORMAL || + action.getActionType() == ActionType.TOGGLE) + { + a.add(action.getModuleName()); + } + else + { + a.add("nut"); + } + + //display + + a.add(action.getBgColourHex()); + + //icon + + + StringBuilder allIconStatesNames = new StringBuilder(); + for(String eachState : action.getIcons().keySet()) + { + allIconStatesNames.append(eachState).append("::"); + } + a.add(allIconStatesNames.toString()); + + + a.add(action.getCurrentIconState()+""); + + //text + a.add(action.isShowDisplayText()+""); + a.add(action.getDisplayTextFontColourHex()); + a.add(action.getDisplayText()); + a.add(action.getNameFontSize()+""); + a.add(action.getDisplayTextAlignment()+""); + + //location + + if(action.getLocation() == null) + { + a.add("-1"); + a.add("-1"); + } + else + { + a.add(action.getLocation().getRow()+""); + a.add(action.getLocation().getCol()+""); + } + + a.add(action.getParent()); + + a.add(action.getDelayBeforeExecuting()+""); + + //client properties + + ClientProperties clientProperties = action.getClientProperties(); + + a.add(clientProperties.getSize()+""); + + for(Property property : clientProperties.get()) + { + a.add(property.getName()); + a.add(property.getRawValue()); + } + + + + Message message = new Message("action_details"); + + String[] x = new String[a.size()]; + x = a.toArray(x); + + message.setStringArrValue(x); + sendMessage(message); + + } + + public void saveActionDetails(Message message) + { + String[] r = message.getStringArrValue(); + + String profileID = r[0]; + + String actionID = r[1]; + ActionType actionType = ActionType.valueOf(r[2]); + + //3 - Version + //4 - ModuleName + + //display + String bgColorHex = r[5]; + + String[] iconStates = r[6].split("::"); + String currentIconState = r[7]; + + //text + boolean isShowDisplayText = r[8].equals("true"); + String displayFontColor = r[9]; + String displayText = r[10]; + double displayLabelFontSize = Double.parseDouble(r[11]); + DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[12]); + + //location + String row = r[13]; + String col = r[14]; + + Location location = new Location(Integer.parseInt(row), Integer.parseInt(col)); + + Action action = new Action(actionID, actionType); + + if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE) + { + try + { + action.setVersion(new Version(r[3])); + action.setModuleName(r[4]); + } + catch (Exception e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + } + } + + + action.setBgColourHex(bgColorHex); + + action.setShowDisplayText(isShowDisplayText); + action.setDisplayTextFontColourHex(displayFontColor); + action.setDisplayText(displayText); + action.setDisplayTextAlignment(displayTextAlignment); + action.setNameFontSize(displayLabelFontSize); + action.setCurrentIconState(currentIconState); + + action.setLocation(location); + + + String parent = r[15]; + action.setParent(parent); + + //client properties + + action.setDelayBeforeExecuting(Integer.parseInt(r[16])); + + int clientPropertiesSize = Integer.parseInt(r[17]); + + ClientProperties clientProperties = new ClientProperties(); + + if(actionType == ActionType.FOLDER) + clientProperties.setDuplicatePropertyAllowed(true); + + for(int i = 18;i<((clientPropertiesSize*2) + 18); i+=2) + { + Property property = new Property(r[i], Type.STRING); + property.setRawValue(r[i+1]); + + clientProperties.addProperty(property); + } + + action.setClientProperties(clientProperties); + + try + { + Action old = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID()); + + if(old != null) + { + for(String oldState : old.getIcons().keySet()) + { + boolean isPresent = false; + for(String state : iconStates) + { + if(state.equals(oldState)) + { + isPresent = true; + action.addIcon(state, old.getIcon(state)); + break; + } + } + + if(!isPresent) + { + // State no longer exists. Delete. + + new File(Config.getInstance().getIconsPath()+"/"+actionID+"___"+oldState).delete(); + } + } + } + + clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action); + + clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action); + + clientListener.renderAction(profileID, action); + + if(clientListener.getScreenSaver()!=null) + { + Platform.runLater(()->clientListener.getScreenSaver().restart()); + } + } + catch (Exception e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); + } + } + + public void deleteAction(Message message) + { + try + { + String[] arr = message.getStringArrValue(); + String profileID = arr[0]; + String actionID = arr[1]; + + Action acc = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + + if(acc == null) + { + exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action "+actionID+" since it does not exist.")); + return; + } + + if(acc.getActionType() == ActionType.FOLDER) + { + ArrayList idsToBeRemoved = new ArrayList<>(); + + ArrayList folders = new ArrayList<>(); + String folderToBeDeletedID = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID(); + + folders.add(folderToBeDeletedID); + + boolean startOver = true; + while(startOver) + { + startOver = false; + for(Action action : clientListener.getClientProfiles().getProfileFromID(profileID).getActions()) + { + if(folders.contains(action.getParent())) + { + if(!idsToBeRemoved.contains(action.getID())) + { + idsToBeRemoved.add(action.getID()); + if(action.getActionType() == ActionType.FOLDER) + { + folders.add(action.getID()); + startOver = true; + } + } + } + } + } + + + for(String ids : idsToBeRemoved) + { + clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids); + } + + Platform.runLater(clientListener::renderRootDefaultProfile); + + } + else if (acc.getActionType() == ActionType.COMBINE) + { + for(Property property : acc.getClientProperties().get()) + { + clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue()); + } + } + + + clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID()); + + clientListener.getClientProfiles().getProfileFromID(profileID).saveActions(); + + if(acc.getLocation().getCol()!=-1) + { + Platform.runLater(()-> { + if (clientListener.getCurrentProfile().getID().equals(profileID) + && clientListener.getCurrentParent().equals(acc.getParent())) + { + clientListener.clearActionBox( + acc.getLocation().getCol(), + acc.getLocation().getRow() + ); + } + }); + } + + + } + catch (Exception e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); + } + } + + public void saveClientDetails(Message message) + { + try + { + boolean reInit = false; + + String[] sep = message.getStringArrValue(); + + Config.getInstance().setNickName(sep[0]); + + + Config.getInstance().setStartupProfileID(sep[1]); + + String oldThemeFullName = Config.getInstance().getCurrentThemeFullName(); + String newThemeFullName = sep[2]; + + Config.getInstance().setCurrentThemeFullName(sep[2]); + Config.getInstance().save(); + + if(!oldThemeFullName.equals(newThemeFullName)) + { + Platform.runLater(()-> { + try { + clientListener.initThemes(); + } catch (SevereException e) { + exceptionAndAlertHandler.handleSevereException(e); + } + }); + } + + Platform.runLater(clientListener::loadSettings); + } + catch (SevereException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleSevereException(e); + } + } + + public void saveProfileDetails(Message message) throws SevereException, MinorException + { + String[] sep = message.getStringArrValue(); + + ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(sep[0]); + + if(clientProfile == null) + { + clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+sep[0]+".xml"), + Config.getInstance().getIconsPath()); + } + + clientProfile.setName(sep[1]); + clientProfile.setRows(Integer.parseInt(sep[2])); + clientProfile.setCols(Integer.parseInt(sep[3])); + clientProfile.setActionSize(Integer.parseInt(sep[4])); + clientProfile.setActionGap(Integer.parseInt(sep[5])); + + try + { + clientListener.getClientProfiles().addProfile(clientProfile); + clientProfile.saveProfileDetails(); + clientListener.refreshGridIfCurrentProfile(sep[0]); + Platform.runLater(clientListener::loadSettings); + } + catch (Exception e) + { + e.printStackTrace(); + throw new SevereException(e.getMessage()); + } + } + + public void deleteProfile(Message message) + { + clientListener.getClientProfiles().deleteProfile(clientListener.getClientProfiles().getProfileFromID( + message.getStringValue() + )); + + if(clientListener.getCurrentProfile().getID().equals(message.getStringValue())) + { + Platform.runLater(clientListener::renderRootDefaultProfile); + } + } + + public void onActionClicked(String profileID, String actionID, boolean toggleState) throws SevereException + { + Message m = new Message("action_clicked"); + m.setStringArrValue(profileID, actionID, toggleState+""); + sendMessage(m); + } + + public void updateOrientationOnClient(Orientation orientation) throws SevereException + { + Message m = new Message("client_orientation"); + m.setStringValue(orientation.toString()); + sendMessage(m); + } + + public void actionFailed(Message message) + { + String[] r = message.getStringArrValue(); + String profileID = r[0]; + String actionID = r[1]; + clientListener.onActionFailed(profileID, actionID); + } +} diff --git a/src/main/java/com/stream_pi/client/controller/ClientListener.java b/src/main/java/com/stream_pi/client/controller/ClientListener.java old mode 100644 new mode 100755 index aedf3ed3..fdd82056 --- a/src/main/java/com/stream_pi/client/controller/ClientListener.java +++ b/src/main/java/com/stream_pi/client/controller/ClientListener.java @@ -1,86 +1,86 @@ -package com.stream_pi.client.controller; - -import com.stream_pi.action_api.action.Action; -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.ClientProfiles; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.theme_api.Themes; -import com.stream_pi.util.exception.SevereException; -import javafx.geometry.Orientation; - -import java.util.concurrent.ExecutorService; - -public interface ClientListener -{ - void onActionFailed(String profileID, String actionID); - void onActionClicked(String profileID, String actionID, boolean toggleState); - ClientProfiles getClientProfiles(); - - Themes getThemes(); - String getDefaultThemeFullName(); - - Client getClient(); - - void renderRootDefaultProfile(); - - void setConnected(boolean isConnected); - boolean isConnected(); - - void renderProfile(ClientProfile clientProfile, boolean freshRender); - - void clearActionBox(int col, int row); - void addBlankActionBox(int col, int row); - void renderAction(String currentProfileID, Action action); - void refreshGridIfCurrentProfile(String currentProfileID); - - ActionBox getActionBox(int col, int row); - - ClientProfile getCurrentProfile(); - - String getCurrentParent(); - - Theme getCurrentTheme(); - - void initLogger() throws SevereException; - void init(); - - void disconnect(String message) throws SevereException; - - void setupClientConnection(); - - void setupClientConnection(Runnable onConnect); - - void updateSettingsConnectDisconnectButton(); - - void onCloseRequest(); - - void loadSettings(); - - double getStageWidth(); - double getStageHeight(); - - void onDisconnect(); - - boolean getToggleStatus(String profileID, String actionID); - - ActionBox getActionBoxByProfileAndID(String profileID, String actionID); - - void openURL(String URL); - - void factoryReset(); - void exitApp(); - - ExecutorService getExecutor(); - - Orientation getCurrentOrientation(); - - void setFirstRun(boolean firstRun); - - ScreenSaver getScreenSaver(); - - void initThemes() throws SevereException; -} +package com.stream_pi.client.controller; + +import com.stream_pi.action_api.action.Action; +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.ClientProfiles; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.theme_api.Themes; +import com.stream_pi.util.exception.SevereException; +import javafx.geometry.Orientation; + +import java.util.concurrent.ExecutorService; + +public interface ClientListener +{ + void onActionFailed(String profileID, String actionID); + void onActionClicked(String profileID, String actionID, boolean toggleState); + ClientProfiles getClientProfiles(); + + Themes getThemes(); + String getDefaultThemeFullName(); + + Client getClient(); + + void renderRootDefaultProfile(); + + void setConnected(boolean isConnected); + boolean isConnected(); + + void renderProfile(ClientProfile clientProfile, boolean freshRender); + + void clearActionBox(int col, int row); + void addBlankActionBox(int col, int row); + void renderAction(String currentProfileID, Action action); + void refreshGridIfCurrentProfile(String currentProfileID); + + ActionBox getActionBox(int col, int row); + + ClientProfile getCurrentProfile(); + + String getCurrentParent(); + + Theme getCurrentTheme(); + + void initLogger() throws SevereException; + void init(); + + void disconnect(String message) throws SevereException; + + void setupClientConnection(); + + void setupClientConnection(Runnable onConnect); + + void updateSettingsConnectDisconnectButton(); + + void onCloseRequest(); + + void loadSettings(); + + double getStageWidth(); + double getStageHeight(); + + void onDisconnect(); + + boolean getToggleStatus(String profileID, String actionID); + + ActionBox getActionBoxByProfileAndID(String profileID, String actionID); + + void openURL(String URL); + + void factoryReset(); + void exitApp(); + + ExecutorService getExecutor(); + + Orientation getCurrentOrientation(); + + void setFirstRun(boolean firstRun); + + ScreenSaver getScreenSaver(); + + void initThemes() throws SevereException; +} diff --git a/src/main/java/com/stream_pi/client/controller/Controller.java b/src/main/java/com/stream_pi/client/controller/Controller.java old mode 100644 new mode 100755 index 993c6fcd..563f9c5e --- a/src/main/java/com/stream_pi/client/controller/Controller.java +++ b/src/main/java/com/stream_pi/client/controller/Controller.java @@ -1,723 +1,723 @@ -package com.stream_pi.client.controller; - -import com.gluonhq.attach.browser.BrowserService; -import com.gluonhq.attach.orientation.OrientationService; -import com.gluonhq.attach.vibration.VibrationService; -import com.stream_pi.action_api.action.Action; -import com.stream_pi.client.Main; -import com.stream_pi.client.connection.Client; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.profile.ClientProfiles; -import com.stream_pi.client.window.Base; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; -import com.stream_pi.util.alert.StreamPiAlert; -import com.stream_pi.util.alert.StreamPiAlertListener; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.gluonhq.attach.lifecycle.LifecycleService; -import com.gluonhq.attach.util.Services; - -import com.stream_pi.util.iohelper.IOHelper; -import com.stream_pi.util.platform.PlatformType; -import com.stream_pi.util.startatboot.StartAtBoot; -import javafx.animation.Interpolator; -import javafx.animation.KeyFrame; -import javafx.animation.KeyValue; -import javafx.animation.Timeline; -import javafx.application.Platform; -import javafx.beans.InvalidationListener; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.geometry.Orientation; -import javafx.scene.Node; -import javafx.scene.input.KeyCombination; -import javafx.scene.layout.StackPane; -import javafx.stage.Screen; -import javafx.util.Duration; - -import java.io.*; -import java.net.URISyntaxException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Level; - - -public class Controller extends Base -{ - private Client client; - - public Controller() - { - client = null; - } - - - private boolean firstRun = true; - private ScreenSaver screenSaver = null; - private ScreenMover screenMover = null; - - @Override - public ScreenSaver getScreenSaver() - { - return screenSaver; - } - - @Override - public void init() - { - try - { - if(firstRun) - initBase(); - - - if(getConfig().isScreenSaverEnabled()) - { - if(screenSaver == null) - { - screenSaver = new ScreenSaver(this, getConfig().getScreenSaverTimeout()); - getChildren().add(screenSaver); - screenSaver.toBack(); - } - else - { - screenSaver.setTimeout(getConfig().getScreenSaverTimeout()); - screenSaver.restart(); - } - } - else - { - if(screenSaver != null) - { - screenSaver.stop(); - getChildren().remove(screenSaver); - screenSaver = null; - } - } - - - if(getClientInfo().getPlatform() != com.stream_pi.util.platform.Platform.ANDROID) - { - if(getConfig().isStartOnBoot()) - { - if(StartupFlags.IS_X_MODE != getConfig().isStartupXMode()) - { - StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), - Main.class.getProtectionDomain().getCodeSource().getLocation(), - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); - - boolean result = startAtBoot.delete(); - if(!result) - { - 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, " + - "delete the old starter file, then exit and restart Stream-Pi as normal user.", StreamPiAlertType.ERROR).show(); - } - else - { - try - { - startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); - getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE); - } - catch (MinorException e) - { - getConfig().setStartOnBoot(false); - handleMinorException(e); - } - } - } - } - - setupFlags(); - - if(!getConfig().getIsFullScreenMode()) - { - getStage().setWidth(getConfig().getStartupWindowWidth()); - getStage().setHeight(getConfig().getStartupWindowHeight()); - } - } - - - setupDashWindow(); - - getStage().show(); - - - if(getConfig().isScreenMoverEnabled()) - { - if(screenMover == null) - { - screenMover = new ScreenMover(getStage(), getConfig().getScreenMoverInterval(), - getConfig().getScreenMoverXChange(), - getConfig().getScreenMoverYChange()); - } - else - { - screenMover.setInterval(getConfig().getScreenMoverInterval()); - screenMover.restart(); - } - } - else - { - if(screenMover != null) - { - screenMover.stop(); - screenMover = null; - } - } - - - if(Config.getInstance().isFirstTimeUse()) - return; - - setupSettingsWindowsAnimations(); - - - - getDashboardPane().getSettingsButton().setOnAction(event -> { - openSettingsTimeLine.play(); - }); - - getSettingsPane().getCloseButton().setOnAction(event -> { - closeSettingsTimeLine.play(); - }); - - setClientProfiles(new ClientProfiles(new File(getConfig().getProfilesPath()), getConfig().getStartupProfileID())); - - if(getClientProfiles().getLoadingErrors().size() > 0) - { - StringBuilder errors = new StringBuilder("Please rectify the following errors and try again"); - - for(MinorException exception : getClientProfiles().getLoadingErrors()) - { - errors.append("\n * ") - .append(exception.getMessage()); - } - - throw new MinorException("Profiles", errors.toString()); - } - - - 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 - ); - - getExecutor().submit(()->{ - try - { - if(isConnected()) - { - getClient().updateOrientationOnClient(getCurrentOrientation()); - } - } - catch (SevereException e) - { - handleSevereException(e); - } - }); - }); - } - }); - } - - renderRootDefaultProfile(); - loadSettings(); - - if(firstRun) - { - if(getConfig().isConnectOnStartup()) - { - setupClientConnection(); - } - firstRun = false; - } - - if(!getClientInfo().isPhone()) - { - getStage().widthProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); - getStage().heightProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); - } - } - catch (SevereException e) - { - handleSevereException(e); - } - catch (MinorException e) - { - handleMinorException(e); - } - } - - private Orientation currentOrientation = null; - - @Override - public Orientation getCurrentOrientation() - { - return currentOrientation; - } - - private void setCurrentOrientation(Orientation currentOrientation) - { - this.currentOrientation = currentOrientation; - } - - public void syncClientSizeDetailsWithServer() - { - if(isConnected()) - { - try { - client.sendClientScreenDetails(); - } catch (SevereException e) { - e.printStackTrace(); - } - } - } - - @Override - public void setupClientConnection() - { - setupClientConnection(null); - } - - @Override - public void setupClientConnection(Runnable onConnect) - { - if(getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) //probably already connecting - return; - - Platform.runLater(()->getSettingsPane().getGeneralTab().setDisableStatus(true)); - client = new Client(getConfig().getSavedServerHostNameOrIP(), getConfig().getSavedServerPort(), this, this, onConnect); - } - - @Override - public void updateSettingsConnectDisconnectButton() { - getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus(); - } - - @Override - public void disconnect(String message) throws SevereException { - client.disconnect(message); - } - - - public void setupDashWindow() - { - getStage().setTitle("Stream-Pi Client"); - getStage().setOnCloseRequest(e->{ - onCloseRequest(); - exitApp(); - }); - } - - - @Override - public void onCloseRequest() - { - try - { - if(isConnected()) - client.exit(); - - if(screenSaver != null) - { - screenSaver.stop(); - } - - if(screenMover != null) - { - screenMover.stop(); - } - - if(getConfig() != null) - { - if(!getClientInfo().isPhone() && !getConfig().getIsFullScreenMode()) - { - getConfig().setStartupWindowSize(getStageWidth(), getStageHeight()); - getConfig().save(); - } - } - } - catch (SevereException e) - { - handleSevereException(e); - } - finally - { - getLogger().info("Shut down"); - closeLogger(); - Config.nullify(); - } - } - - @Override - public void exitApp() - { - getExecutor().shutdown(); - if (ClientInfo.getInstance().getPlatform() == com.stream_pi.util.platform.Platform.ANDROID) - { - Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown); - } - else - { - Platform.exit(); - } - } - - @Override - public void loadSettings() { - try { - getSettingsPane().getGeneralTab().loadData(); - } catch (SevereException e) { - e.printStackTrace(); - handleSevereException(e); - } - } - - @Override - public Client getClient() { - return client; - } - - @Override - public void onDisconnect() { - Platform.runLater(()->getDashboardPane().getActionGridPane().toggleOffAllToggleActions()); - } - - @Override - public boolean getToggleStatus(String profileID, String actionID) - { - return getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus(); - } - - - private Timeline openSettingsTimeLine; - private Timeline closeSettingsTimeLine; - - - private void setupSettingsWindowsAnimations() - { - Node settingsNode = getSettingsPane(); - Node dashboardNode = getDashboardPane(); - - openSettingsTimeLine = new Timeline(); - openSettingsTimeLine.setCycleCount(1); - - - openSettingsTimeLine.getKeyFrames().addAll( - new KeyFrame(Duration.millis(0.0D), - new KeyValue(settingsNode.opacityProperty(), - 0.0D, Interpolator.EASE_IN)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(settingsNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)), - - new KeyFrame(Duration.millis(0.0D), - new KeyValue(dashboardNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(dashboardNode.opacityProperty(), - 0.0D, Interpolator.LINEAR)) - ); - - openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront()); - - - closeSettingsTimeLine = new Timeline(); - closeSettingsTimeLine.setCycleCount(1); - - closeSettingsTimeLine.getKeyFrames().addAll( - new KeyFrame(Duration.millis(0.0D), - new KeyValue(settingsNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(settingsNode.opacityProperty(), - 0.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(0.0D), - new KeyValue(dashboardNode.opacityProperty(), - 0.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(dashboardNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)) - ); - - closeSettingsTimeLine.setOnFinished(event1 -> { - dashboardNode.toFront(); - Platform.runLater(()-> { - try { - getSettingsPane().getGeneralTab().loadData(); - } catch (SevereException e) { - e.printStackTrace(); - - handleSevereException(e); - } - }); - }); - } - - - @Override - public void handleMinorException(MinorException e) - { - handleMinorException(e.getMessage(), e); - } - - @Override - public void handleMinorException(String message, MinorException e) - { - getLogger().log(Level.SEVERE, message, e); - e.printStackTrace(); - - Platform.runLater(()-> { - if(getScreenSaver() != null) - { - getScreenSaver().restart(); - } - - genNewAlert(e.getTitle(), message, StreamPiAlertType.WARNING).show(); - }); - } - - @Override - public void handleSevereException(SevereException e) - { - handleSevereException(e.getMessage(), e); - } - - @Override - public void handleSevereException(String message, SevereException e) - { - getLogger().log(Level.SEVERE, message, e); - e.printStackTrace(); - - - Platform.runLater(()-> - { - if(getScreenSaver() != null) - { - getScreenSaver().restart(); - } - - StreamPiAlert alert = genNewAlert(e.getTitle(), message, StreamPiAlertType.ERROR); - - alert.setOnClicked(new StreamPiAlertListener() - { - @Override - public void onClick(String txt) - { - onCloseRequest(); - exitApp(); - } - }); - alert.show(); - }); - } - - @Override - public void onAlert(String title, String body, StreamPiAlertType alertType) { - Platform.runLater(()-> genNewAlert(title, body, alertType).show()); - } - - public StreamPiAlert genNewAlert(String title, String message, StreamPiAlertType alertType) - { - return new StreamPiAlert(title, message, alertType); - } - - - private boolean isConnected = false; - - @Override - public void onActionFailed(String profileID, String actionID) { - Platform.runLater(()-> getDashboardPane().getActionGridPane().actionFailed(profileID, actionID)); - } - - @Override - public void onActionClicked(String profileID, String actionID, boolean toggleState) - { - try { - - vibratePhone(); - - client.onActionClicked(profileID, actionID, toggleState); - } catch (SevereException e) { - e.printStackTrace(); - handleSevereException(e); - } - } - - public void vibratePhone() - { - if(getConfig().isVibrateOnActionClicked()) - { - VibrationService.create().ifPresent(VibrationService::vibrate); - } - } - - @Override - public void setConnected(boolean isConnected) { - this.isConnected = isConnected; - } - - @Override - public ActionBox getActionBox(int col, int row) - { - return getDashboardPane().getActionGridPane().getActionBox(col, row); - } - - @Override - public boolean isConnected() - { - return isConnected; - } - - @Override - public void renderProfile(ClientProfile clientProfile, boolean freshRender) - { - getDashboardPane().renderProfile(clientProfile, freshRender); - } - - @Override - public void clearActionBox(int col, int row) - { - Platform.runLater(()->getDashboardPane().getActionGridPane().clearActionBox(col, row)); - } - - @Override - public void addBlankActionBox(int col, int row) - { - Platform.runLater(()->getDashboardPane().getActionGridPane().addBlankActionBox(col, row)); - } - - @Override - public void renderAction(String currentProfileID, Action action) - { - Platform.runLater(()->{ - try { - if(getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) && - getCurrentProfile().getID().equals(currentProfileID)) - { - getDashboardPane().getActionGridPane().renderAction(action); - } - - } - catch (Exception e) - { - e.printStackTrace(); - } - }); - } - - - - @Override - public void refreshGridIfCurrentProfile(String profileID) { - if(getCurrentProfile().getID().equals(profileID)) - { - Platform.runLater(()-> getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(profileID), true)); - } - } - - @Override - public ClientProfile getCurrentProfile() { - return getDashboardPane().getActionGridPane().getClientProfile(); - } - - @Override - public String getCurrentParent() - { - return getDashboardPane().getActionGridPane().getCurrentParent(); - } - - - @Override - public ActionBox getActionBoxByProfileAndID(String profileID, String actionID) - { - Action action = getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - - if(!getCurrentProfile().getID().equals(profileID) && !getCurrentParent().equals(action.getParent())) - return null; - - return getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation()); - } - - @Override - public void openURL(String url) - { - if(ClientInfo.getInstance().isPhone()) - { - BrowserService.create().ifPresentOrElse(s-> - { - try - { - s.launchExternalBrowser(url); - } - catch (Exception e ) - { - handleMinorException( - new MinorException("Cant start browser! You can go to Server Settings > About > Contact " + - "and open the links from there.") - ); - } - },()-> handleMinorException( - new MinorException("Sorry!","No browser detected. You can go to Server Settings > About > Contact " + - "and open the links from there.") - )); - } - else - { - if(getClientInfo().getPlatform() == com.stream_pi.util.platform.Platform.LINUX && - !StartupFlags.IS_X_MODE) - { - 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 " + - "and open the links from there.")); - } - else - { - getHostServices().showDocument(url); - } - } - } - - @Override - public void factoryReset() - { - getLogger().info("Reset to factory ..."); - - onCloseRequest(); - - try - { - IOHelper.deleteFile(getClientInfo().getPrePath()); - - setFirstRun(true); - init(); - } - catch (SevereException e) - { - handleSevereException("Unable to successfully factory reset. Delete directory \n'"+getClientInfo().getPrePath()+"/home/rnayabed/HDD_1/projects/stream-pi/server'\nMessage:\n"+e.getMessage(),e); - } - } - - @Override - public void setFirstRun(boolean firstRun) - { - this.firstRun = firstRun; - } -} +package com.stream_pi.client.controller; + +import com.gluonhq.attach.browser.BrowserService; +import com.gluonhq.attach.orientation.OrientationService; +import com.gluonhq.attach.vibration.VibrationService; +import com.stream_pi.action_api.action.Action; +import com.stream_pi.client.Main; +import com.stream_pi.client.connection.Client; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.profile.ClientProfiles; +import com.stream_pi.client.window.Base; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertListener; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.gluonhq.attach.lifecycle.LifecycleService; +import com.gluonhq.attach.util.Services; + +import com.stream_pi.util.iohelper.IOHelper; +import com.stream_pi.util.platform.PlatformType; +import com.stream_pi.util.startatboot.StartAtBoot; +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.application.Platform; +import javafx.beans.InvalidationListener; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.geometry.Orientation; +import javafx.scene.Node; +import javafx.scene.input.KeyCombination; +import javafx.scene.layout.StackPane; +import javafx.stage.Screen; +import javafx.util.Duration; + +import java.io.*; +import java.net.URISyntaxException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.logging.Level; + + +public class Controller extends Base +{ + private Client client; + + public Controller() + { + client = null; + } + + + private boolean firstRun = true; + private ScreenSaver screenSaver = null; + private ScreenMover screenMover = null; + + @Override + public ScreenSaver getScreenSaver() + { + return screenSaver; + } + + @Override + public void init() + { + try + { + if(firstRun) + initBase(); + + + if(getConfig().isScreenSaverEnabled()) + { + if(screenSaver == null) + { + screenSaver = new ScreenSaver(this, getConfig().getScreenSaverTimeout()); + getChildren().add(screenSaver); + screenSaver.toBack(); + } + else + { + screenSaver.setTimeout(getConfig().getScreenSaverTimeout()); + screenSaver.restart(); + } + } + else + { + if(screenSaver != null) + { + screenSaver.stop(); + getChildren().remove(screenSaver); + screenSaver = null; + } + } + + + if(getClientInfo().getPlatform() != com.stream_pi.util.platform.Platform.ANDROID) + { + if(getConfig().isStartOnBoot()) + { + if(StartupFlags.IS_X_MODE != getConfig().isStartupXMode()) + { + StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), + Main.class.getProtectionDomain().getCodeSource().getLocation(), + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); + + boolean result = startAtBoot.delete(); + if(!result) + { + 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, " + + "delete the old starter file, then exit and restart Stream-Pi as normal user.", StreamPiAlertType.ERROR).show(); + } + else + { + try + { + startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); + getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE); + } + catch (MinorException e) + { + getConfig().setStartOnBoot(false); + handleMinorException(e); + } + } + } + } + + setupFlags(); + + if(!getConfig().getIsFullScreenMode()) + { + getStage().setWidth(getConfig().getStartupWindowWidth()); + getStage().setHeight(getConfig().getStartupWindowHeight()); + } + } + + + setupDashWindow(); + + getStage().show(); + + + if(getConfig().isScreenMoverEnabled()) + { + if(screenMover == null) + { + screenMover = new ScreenMover(getStage(), getConfig().getScreenMoverInterval(), + getConfig().getScreenMoverXChange(), + getConfig().getScreenMoverYChange()); + } + else + { + screenMover.setInterval(getConfig().getScreenMoverInterval()); + screenMover.restart(); + } + } + else + { + if(screenMover != null) + { + screenMover.stop(); + screenMover = null; + } + } + + + if(Config.getInstance().isFirstTimeUse()) + return; + + setupSettingsWindowsAnimations(); + + + + getDashboardPane().getSettingsButton().setOnAction(event -> { + openSettingsTimeLine.play(); + }); + + getSettingsPane().getCloseButton().setOnAction(event -> { + closeSettingsTimeLine.play(); + }); + + setClientProfiles(new ClientProfiles(new File(getConfig().getProfilesPath()), getConfig().getStartupProfileID())); + + if(getClientProfiles().getLoadingErrors().size() > 0) + { + StringBuilder errors = new StringBuilder("Please rectify the following errors and try again"); + + for(MinorException exception : getClientProfiles().getLoadingErrors()) + { + errors.append("\n * ") + .append(exception.getMessage()); + } + + throw new MinorException("Profiles", errors.toString()); + } + + + 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 + ); + + getExecutor().submit(()->{ + try + { + if(isConnected()) + { + getClient().updateOrientationOnClient(getCurrentOrientation()); + } + } + catch (SevereException e) + { + handleSevereException(e); + } + }); + }); + } + }); + } + + renderRootDefaultProfile(); + loadSettings(); + + if(firstRun) + { + if(getConfig().isConnectOnStartup()) + { + setupClientConnection(); + } + firstRun = false; + } + + if(!getClientInfo().isPhone()) + { + getStage().widthProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); + getStage().heightProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); + } + } + catch (SevereException e) + { + handleSevereException(e); + } + catch (MinorException e) + { + handleMinorException(e); + } + } + + private Orientation currentOrientation = null; + + @Override + public Orientation getCurrentOrientation() + { + return currentOrientation; + } + + private void setCurrentOrientation(Orientation currentOrientation) + { + this.currentOrientation = currentOrientation; + } + + public void syncClientSizeDetailsWithServer() + { + if(isConnected()) + { + try { + client.sendClientScreenDetails(); + } catch (SevereException e) { + e.printStackTrace(); + } + } + } + + @Override + public void setupClientConnection() + { + setupClientConnection(null); + } + + @Override + public void setupClientConnection(Runnable onConnect) + { + if(getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) //probably already connecting + return; + + Platform.runLater(()->getSettingsPane().getGeneralTab().setDisableStatus(true)); + client = new Client(getConfig().getSavedServerHostNameOrIP(), getConfig().getSavedServerPort(), this, this, onConnect); + } + + @Override + public void updateSettingsConnectDisconnectButton() { + getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus(); + } + + @Override + public void disconnect(String message) throws SevereException { + client.disconnect(message); + } + + + public void setupDashWindow() + { + getStage().setTitle("Stream-Pi Client"); + getStage().setOnCloseRequest(e->{ + onCloseRequest(); + exitApp(); + }); + } + + + @Override + public void onCloseRequest() + { + try + { + if(isConnected()) + client.exit(); + + if(screenSaver != null) + { + screenSaver.stop(); + } + + if(screenMover != null) + { + screenMover.stop(); + } + + if(getConfig() != null) + { + if(!getClientInfo().isPhone() && !getConfig().getIsFullScreenMode()) + { + getConfig().setStartupWindowSize(getStageWidth(), getStageHeight()); + getConfig().save(); + } + } + } + catch (SevereException e) + { + handleSevereException(e); + } + finally + { + getLogger().info("Shut down"); + closeLogger(); + Config.nullify(); + } + } + + @Override + public void exitApp() + { + getExecutor().shutdown(); + if (ClientInfo.getInstance().getPlatform() == com.stream_pi.util.platform.Platform.ANDROID) + { + Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown); + } + else + { + Platform.exit(); + } + } + + @Override + public void loadSettings() { + try { + getSettingsPane().getGeneralTab().loadData(); + } catch (SevereException e) { + e.printStackTrace(); + handleSevereException(e); + } + } + + @Override + public Client getClient() { + return client; + } + + @Override + public void onDisconnect() { + Platform.runLater(()->getDashboardPane().getActionGridPane().toggleOffAllToggleActions()); + } + + @Override + public boolean getToggleStatus(String profileID, String actionID) + { + return getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus(); + } + + + private Timeline openSettingsTimeLine; + private Timeline closeSettingsTimeLine; + + + private void setupSettingsWindowsAnimations() + { + Node settingsNode = getSettingsPane(); + Node dashboardNode = getDashboardPane(); + + openSettingsTimeLine = new Timeline(); + openSettingsTimeLine.setCycleCount(1); + + + openSettingsTimeLine.getKeyFrames().addAll( + new KeyFrame(Duration.millis(0.0D), + new KeyValue(settingsNode.opacityProperty(), + 0.0D, Interpolator.EASE_IN)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(settingsNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)), + + new KeyFrame(Duration.millis(0.0D), + new KeyValue(dashboardNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(dashboardNode.opacityProperty(), + 0.0D, Interpolator.LINEAR)) + ); + + openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront()); + + + closeSettingsTimeLine = new Timeline(); + closeSettingsTimeLine.setCycleCount(1); + + closeSettingsTimeLine.getKeyFrames().addAll( + new KeyFrame(Duration.millis(0.0D), + new KeyValue(settingsNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(settingsNode.opacityProperty(), + 0.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(0.0D), + new KeyValue(dashboardNode.opacityProperty(), + 0.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(dashboardNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)) + ); + + closeSettingsTimeLine.setOnFinished(event1 -> { + dashboardNode.toFront(); + Platform.runLater(()-> { + try { + getSettingsPane().getGeneralTab().loadData(); + } catch (SevereException e) { + e.printStackTrace(); + + handleSevereException(e); + } + }); + }); + } + + + @Override + public void handleMinorException(MinorException e) + { + handleMinorException(e.getMessage(), e); + } + + @Override + public void handleMinorException(String message, MinorException e) + { + getLogger().log(Level.SEVERE, message, e); + e.printStackTrace(); + + Platform.runLater(()-> { + if(getScreenSaver() != null) + { + getScreenSaver().restart(); + } + + genNewAlert(e.getTitle(), message, StreamPiAlertType.WARNING).show(); + }); + } + + @Override + public void handleSevereException(SevereException e) + { + handleSevereException(e.getMessage(), e); + } + + @Override + public void handleSevereException(String message, SevereException e) + { + getLogger().log(Level.SEVERE, message, e); + e.printStackTrace(); + + + Platform.runLater(()-> + { + if(getScreenSaver() != null) + { + getScreenSaver().restart(); + } + + StreamPiAlert alert = genNewAlert(e.getTitle(), message, StreamPiAlertType.ERROR); + + alert.setOnClicked(new StreamPiAlertListener() + { + @Override + public void onClick(String txt) + { + onCloseRequest(); + exitApp(); + } + }); + alert.show(); + }); + } + + @Override + public void onAlert(String title, String body, StreamPiAlertType alertType) { + Platform.runLater(()-> genNewAlert(title, body, alertType).show()); + } + + public StreamPiAlert genNewAlert(String title, String message, StreamPiAlertType alertType) + { + return new StreamPiAlert(title, message, alertType); + } + + + private boolean isConnected = false; + + @Override + public void onActionFailed(String profileID, String actionID) { + Platform.runLater(()-> getDashboardPane().getActionGridPane().actionFailed(profileID, actionID)); + } + + @Override + public void onActionClicked(String profileID, String actionID, boolean toggleState) + { + try { + + vibratePhone(); + + client.onActionClicked(profileID, actionID, toggleState); + } catch (SevereException e) { + e.printStackTrace(); + handleSevereException(e); + } + } + + public void vibratePhone() + { + if(getConfig().isVibrateOnActionClicked()) + { + VibrationService.create().ifPresent(VibrationService::vibrate); + } + } + + @Override + public void setConnected(boolean isConnected) { + this.isConnected = isConnected; + } + + @Override + public ActionBox getActionBox(int col, int row) + { + return getDashboardPane().getActionGridPane().getActionBox(col, row); + } + + @Override + public boolean isConnected() + { + return isConnected; + } + + @Override + public void renderProfile(ClientProfile clientProfile, boolean freshRender) + { + getDashboardPane().renderProfile(clientProfile, freshRender); + } + + @Override + public void clearActionBox(int col, int row) + { + Platform.runLater(()->getDashboardPane().getActionGridPane().clearActionBox(col, row)); + } + + @Override + public void addBlankActionBox(int col, int row) + { + Platform.runLater(()->getDashboardPane().getActionGridPane().addBlankActionBox(col, row)); + } + + @Override + public void renderAction(String currentProfileID, Action action) + { + Platform.runLater(()->{ + try { + if(getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) && + getCurrentProfile().getID().equals(currentProfileID)) + { + getDashboardPane().getActionGridPane().renderAction(action); + } + + } + catch (Exception e) + { + e.printStackTrace(); + } + }); + } + + + + @Override + public void refreshGridIfCurrentProfile(String profileID) { + if(getCurrentProfile().getID().equals(profileID)) + { + Platform.runLater(()-> getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(profileID), true)); + } + } + + @Override + public ClientProfile getCurrentProfile() { + return getDashboardPane().getActionGridPane().getClientProfile(); + } + + @Override + public String getCurrentParent() + { + return getDashboardPane().getActionGridPane().getCurrentParent(); + } + + + @Override + public ActionBox getActionBoxByProfileAndID(String profileID, String actionID) + { + Action action = getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + + if(!getCurrentProfile().getID().equals(profileID) && !getCurrentParent().equals(action.getParent())) + return null; + + return getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation()); + } + + @Override + public void openURL(String url) + { + if(ClientInfo.getInstance().isPhone()) + { + BrowserService.create().ifPresentOrElse(s-> + { + try + { + s.launchExternalBrowser(url); + } + catch (Exception e ) + { + handleMinorException( + new MinorException("Cant start browser! You can go to Server Settings > About > Contact " + + "and open the links from there.") + ); + } + },()-> handleMinorException( + new MinorException("Sorry!","No browser detected. You can go to Server Settings > About > Contact " + + "and open the links from there.") + )); + } + else + { + if(getClientInfo().getPlatform() == com.stream_pi.util.platform.Platform.LINUX && + !StartupFlags.IS_X_MODE) + { + 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 " + + "and open the links from there.")); + } + else + { + getHostServices().showDocument(url); + } + } + } + + @Override + public void factoryReset() + { + getLogger().info("Reset to factory ..."); + + onCloseRequest(); + + try + { + IOHelper.deleteFile(getClientInfo().getPrePath()); + + setFirstRun(true); + init(); + } + catch (SevereException e) + { + handleSevereException("Unable to successfully factory reset. Delete directory \n'"+getClientInfo().getPrePath()+"/home/rnayabed/HDD_1/projects/stream-pi/server'\nMessage:\n"+e.getMessage(),e); + } + } + + @Override + public void setFirstRun(boolean firstRun) + { + this.firstRun = firstRun; + } +} diff --git a/src/main/java/com/stream_pi/client/controller/ScreenMover.java b/src/main/java/com/stream_pi/client/controller/ScreenMover.java old mode 100644 new mode 100755 index bdb799d0..6afa1d21 --- a/src/main/java/com/stream_pi/client/controller/ScreenMover.java +++ b/src/main/java/com/stream_pi/client/controller/ScreenMover.java @@ -1,103 +1,103 @@ -package com.stream_pi.client.controller; - -import com.stream_pi.client.window.Base; -import com.stream_pi.util.exception.SevereException; -import javafx.animation.*; -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.scene.Node; -import javafx.scene.Scene; -import javafx.scene.layout.StackPane; -import javafx.stage.Stage; -import javafx.util.Duration; - -import java.util.Timer; -import java.util.TimerTask; - -public class ScreenMover -{ - private Timer timer; - - private long interval; - - private boolean isOldLocation; - private double originalX, originalY; - private double changeX, changeY; - - private Stage stage; - - public ScreenMover(Stage stage, long interval, int changeX, int changeY) - { - this.stage = stage; - this.changeX = changeX; - this.changeY = changeY; - this.originalX = stage.getX(); - this.originalY = stage.getY(); - this.isOldLocation = true; - this.interval = interval; - - startTimer(); - } - - - public void stop() - { - isOldLocation = true; - shiftScreen(); - - stopTimer(); - } - - public void restart() - { - stop(); - startTimer(); - } - - private void shiftScreen() - { - Platform.runLater(()->{ - if(isOldLocation) - { - isOldLocation = false; - - stage.setX(originalX+changeX); - stage.setY(originalY+changeY); - } - else - { - isOldLocation = true; - - stage.setX(originalX); - stage.setY(originalY); - } - }); - } - - public void setInterval(int seconds) - { - this.interval = seconds; - } - - private void stopTimer() - { - if(timer != null) - { - timer.cancel(); - timer.purge(); - } - } - - private void startTimer() - { - timer = new Timer(); - timer.scheduleAtFixedRate(new TimerTask() - { - @Override - public void run() - { - shiftScreen(); - } - },interval, interval); - } -} +package com.stream_pi.client.controller; + +import com.stream_pi.client.window.Base; +import com.stream_pi.util.exception.SevereException; +import javafx.animation.*; +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; +import javafx.util.Duration; + +import java.util.Timer; +import java.util.TimerTask; + +public class ScreenMover +{ + private Timer timer; + + private long interval; + + private boolean isOldLocation; + private double originalX, originalY; + private double changeX, changeY; + + private Stage stage; + + public ScreenMover(Stage stage, long interval, int changeX, int changeY) + { + this.stage = stage; + this.changeX = changeX; + this.changeY = changeY; + this.originalX = stage.getX(); + this.originalY = stage.getY(); + this.isOldLocation = true; + this.interval = interval; + + startTimer(); + } + + + public void stop() + { + isOldLocation = true; + shiftScreen(); + + stopTimer(); + } + + public void restart() + { + stop(); + startTimer(); + } + + private void shiftScreen() + { + Platform.runLater(()->{ + if(isOldLocation) + { + isOldLocation = false; + + stage.setX(originalX+changeX); + stage.setY(originalY+changeY); + } + else + { + isOldLocation = true; + + stage.setX(originalX); + stage.setY(originalY); + } + }); + } + + public void setInterval(int seconds) + { + this.interval = seconds; + } + + private void stopTimer() + { + if(timer != null) + { + timer.cancel(); + timer.purge(); + } + } + + private void startTimer() + { + timer = new Timer(); + timer.scheduleAtFixedRate(new TimerTask() + { + @Override + public void run() + { + shiftScreen(); + } + },interval, interval); + } +} diff --git a/src/main/java/com/stream_pi/client/controller/ScreenSaver.java b/src/main/java/com/stream_pi/client/controller/ScreenSaver.java old mode 100644 new mode 100755 index 28bac210..c208f52c --- a/src/main/java/com/stream_pi/client/controller/ScreenSaver.java +++ b/src/main/java/com/stream_pi/client/controller/ScreenSaver.java @@ -1,124 +1,124 @@ -package com.stream_pi.client.controller; - -import com.stream_pi.client.window.Base; -import com.stream_pi.util.exception.SevereException; -import javafx.animation.*; -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.scene.Node; -import javafx.scene.layout.StackPane; -import javafx.util.Duration; - -import java.util.Timer; -import java.util.TimerTask; - -public class ScreenSaver extends StackPane -{ - private Timer timer; - - private Timeline showScreenSaverTimeline; - private long timeout; - - public ScreenSaver(Base base, int timeout) - { - this.timeout = timeout* 1000L; - - setOpacity(0); - getStyleClass().add("screensaver"); - - - showScreenSaverTimeline = new Timeline(); - showScreenSaverTimeline.setCycleCount(1); - - - showScreenSaverTimeline.getKeyFrames().addAll( - new KeyFrame(Duration.millis(0.0D), - new KeyValue(opacityProperty(), - 0.0D, Interpolator.EASE_IN)), - new KeyFrame(Duration.seconds(15D), - new KeyValue(opacityProperty(), - 1.0D, Interpolator.LINEAR)) - ); - - startTimer(); - - base.setOnMouseClicked(mouseEvent -> { - restart(); - }); - - } - - public void restart() - { - close(); - restartTimer(); - } - - - - public void stop() - { - stopTimer(); - setOpacity(0); - toBack(); - } - - - private void show() - { - Platform.runLater(()->{ - setOpacity(0); - toFront(); - showScreenSaverTimeline.play(); - }); - } - - private void close() - { - Platform.runLater(()->{ - if(showScreenSaverTimeline.getStatus() == Animation.Status.RUNNING) - { - showScreenSaverTimeline.stop(); - } - - - setOpacity(0.0); - toBack(); - }); - - restartTimer(); - } - - public void setTimeout(int seconds) - { - this.timeout = seconds* 1000L; - } - - public void restartTimer() - { - stopTimer(); - startTimer(); - } - - private void stopTimer() - { - if(timer != null) - { - timer.cancel(); - timer.purge(); - } - } - - private void startTimer() - { - timer = new Timer(); - timer.schedule(new TimerTask() - { - @Override - public void run() - { - show(); - } - },timeout); - } -} +package com.stream_pi.client.controller; + +import com.stream_pi.client.window.Base; +import com.stream_pi.util.exception.SevereException; +import javafx.animation.*; +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.scene.Node; +import javafx.scene.layout.StackPane; +import javafx.util.Duration; + +import java.util.Timer; +import java.util.TimerTask; + +public class ScreenSaver extends StackPane +{ + private Timer timer; + + private Timeline showScreenSaverTimeline; + private long timeout; + + public ScreenSaver(Base base, int timeout) + { + this.timeout = timeout* 1000L; + + setOpacity(0); + getStyleClass().add("screensaver"); + + + showScreenSaverTimeline = new Timeline(); + showScreenSaverTimeline.setCycleCount(1); + + + showScreenSaverTimeline.getKeyFrames().addAll( + new KeyFrame(Duration.millis(0.0D), + new KeyValue(opacityProperty(), + 0.0D, Interpolator.EASE_IN)), + new KeyFrame(Duration.seconds(15D), + new KeyValue(opacityProperty(), + 1.0D, Interpolator.LINEAR)) + ); + + startTimer(); + + base.setOnMouseClicked(mouseEvent -> { + restart(); + }); + + } + + public void restart() + { + close(); + restartTimer(); + } + + + + public void stop() + { + stopTimer(); + setOpacity(0); + toBack(); + } + + + private void show() + { + Platform.runLater(()->{ + setOpacity(0); + toFront(); + showScreenSaverTimeline.play(); + }); + } + + private void close() + { + Platform.runLater(()->{ + if(showScreenSaverTimeline.getStatus() == Animation.Status.RUNNING) + { + showScreenSaverTimeline.stop(); + } + + + setOpacity(0.0); + toBack(); + }); + + restartTimer(); + } + + public void setTimeout(int seconds) + { + this.timeout = seconds* 1000L; + } + + public void restartTimer() + { + stopTimer(); + startTimer(); + } + + private void stopTimer() + { + if(timer != null) + { + timer.cancel(); + timer.purge(); + } + } + + private void startTimer() + { + timer = new Timer(); + timer.schedule(new TimerTask() + { + @Override + public void run() + { + show(); + } + },timeout); + } +} diff --git a/src/main/java/com/stream_pi/client/info/ClientInfo.java b/src/main/java/com/stream_pi/client/info/ClientInfo.java old mode 100644 new mode 100755 index 19b7d8e0..ee884019 --- a/src/main/java/com/stream_pi/client/info/ClientInfo.java +++ b/src/main/java/com/stream_pi/client/info/ClientInfo.java @@ -1,121 +1,121 @@ -/* -ServerInfo.java - -Stores basic information about the server - name, platform type - -Contributors: Debayan Sutradhar (@dubbadhar) - */ - -package com.stream_pi.client.info; - -import com.gluonhq.attach.storage.StorageService; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.platform.Platform; -import com.stream_pi.util.platform.ReleaseStatus; -import com.stream_pi.util.version.Version; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Optional; -import java.util.function.Function; - -public class ClientInfo { - private Version version; - private final ReleaseStatus releaseStatus; - private Platform platform; - - private String prePath; - - private Version minThemeSupportVersion; - private Version minPluginSupportVersion; - private Version commStandardVersion; - - private static ClientInfo instance = null; - - private ClientInfo() - { - version = new Version(1,0,0); - minThemeSupportVersion = new Version(1,0,0); - minPluginSupportVersion = new Version(1,0,0); - commStandardVersion = new Version(1,0,0); - - releaseStatus = ReleaseStatus.EA; - - String osName = System.getProperty("os.name").toLowerCase(); - - prePath = System.getProperty("user.home")+"/Stream-Pi/Client/"; - - if(osName.contains("windows")) - { - platform = Platform.WINDOWS; - } - else if (osName.contains("linux")) - { - platform = Platform.LINUX; - } - else if(osName.contains("android") || osName.contains("ios")) - { - StorageService.create().ifPresent(s-> s.getPrivateStorage().ifPresentOrElse(sp-> prePath = sp.getAbsolutePath()+"/Stream-Pi/Client/", - ()-> prePath = null)); - - platform = Platform.valueOf(osName.toUpperCase()); - } - else if (osName.contains("mac")) - { - platform = Platform.MAC; - } - else - { - platform = Platform.UNKNOWN; - } - } - - public static synchronized ClientInfo getInstance(){ - if(instance == null) - { - instance = new ClientInfo(); - } - - return instance; - } - - public String getPrePath() - { - return prePath; - } - - public Platform getPlatform() - { - return platform; - } - - public Version getVersion() { - return version; - } - - public ReleaseStatus getReleaseStatus() - { - return releaseStatus; - } - - public Version getMinThemeSupportVersion() - { - return minThemeSupportVersion; - } - - public Version getMinPluginSupportVersion() - { - return minPluginSupportVersion; - } - - public Version getCommStandardVersion() - { - return commStandardVersion; - } - - - public boolean isPhone() - { - return getPlatform() == Platform.ANDROID || getPlatform() == Platform.IOS; - } -} +/* +ServerInfo.java + +Stores basic information about the server - name, platform type + +Contributors: Debayan Sutradhar (@dubbadhar) + */ + +package com.stream_pi.client.info; + +import com.gluonhq.attach.storage.StorageService; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.platform.Platform; +import com.stream_pi.util.platform.ReleaseStatus; +import com.stream_pi.util.version.Version; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Optional; +import java.util.function.Function; + +public class ClientInfo { + private Version version; + private final ReleaseStatus releaseStatus; + private Platform platform; + + private String prePath; + + private Version minThemeSupportVersion; + private Version minPluginSupportVersion; + private Version commStandardVersion; + + private static ClientInfo instance = null; + + private ClientInfo() + { + version = new Version(1,0,0); + minThemeSupportVersion = new Version(1,0,0); + minPluginSupportVersion = new Version(1,0,0); + commStandardVersion = new Version(1,0,0); + + releaseStatus = ReleaseStatus.EA; + + String osName = System.getProperty("os.name").toLowerCase(); + + prePath = System.getProperty("user.home")+"/Stream-Pi/Client/"; + + if(osName.contains("windows")) + { + platform = Platform.WINDOWS; + } + else if (osName.contains("linux")) + { + platform = Platform.LINUX; + } + else if(osName.contains("android") || osName.contains("ios")) + { + StorageService.create().ifPresent(s-> s.getPrivateStorage().ifPresentOrElse(sp-> prePath = sp.getAbsolutePath()+"/Stream-Pi/Client/", + ()-> prePath = null)); + + platform = Platform.valueOf(osName.toUpperCase()); + } + else if (osName.contains("mac")) + { + platform = Platform.MAC; + } + else + { + platform = Platform.UNKNOWN; + } + } + + public static synchronized ClientInfo getInstance(){ + if(instance == null) + { + instance = new ClientInfo(); + } + + return instance; + } + + public String getPrePath() + { + return prePath; + } + + public Platform getPlatform() + { + return platform; + } + + public Version getVersion() { + return version; + } + + public ReleaseStatus getReleaseStatus() + { + return releaseStatus; + } + + public Version getMinThemeSupportVersion() + { + return minThemeSupportVersion; + } + + public Version getMinPluginSupportVersion() + { + return minPluginSupportVersion; + } + + public Version getCommStandardVersion() + { + return commStandardVersion; + } + + + public boolean isPhone() + { + return getPlatform() == Platform.ANDROID || getPlatform() == Platform.IOS; + } +} diff --git a/src/main/java/com/stream_pi/client/info/License.java b/src/main/java/com/stream_pi/client/info/License.java old mode 100644 new mode 100755 index 71a8d9de..f8f8466c --- a/src/main/java/com/stream_pi/client/info/License.java +++ b/src/main/java/com/stream_pi/client/info/License.java @@ -1,43 +1,43 @@ -/* -Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macropad -Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones) - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -Written by : Debayan Sutradhar (rnayabed) -*/ - -package com.stream_pi.client.info; - -public class License { - public static String getLicense() - { - return "Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad\n" + - "Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)\n" + - "\n" + - "This program is free software: you can redistribute it and/or modify\n" + - "it under the terms of the GNU General Public License as published by\n" + - "the Free Software Foundation, either version 3 of the License, or\n" + - "(at your option) any later version.\n" + - "\n" + - "This program is distributed in the hope that it will be useful,\n" + - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + - "GNU General Public License for more details.\n" + - "\n\n"+ - "Opensource Libraries/Tech used :\n"+ - "1. JavaFX - GNU General Public License with Classpath Exception\nhttp://openjdk.java.net/legal/gplv2+ce.html\n\n"+ - "2. Gluon Attach - GPL License\nhttps://github.com/gluonhq/attach/blob/master/LICENSE\n\n"+ - "3. Gluon Client Maven Plugin - BSD-3 License\nhttps://github.com/gluonhq/client-maven-plugin/blob/master/LICENSE\n\n" + - "4. Ikonli - Apache License\nhttps://github.com/kordamp/ikonli/blob/master/LICENSE\n\n"+ - "5. Roboto Font - Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0\n\n"+ - "6. ControlsFX - BSD 3-Clause License\nhttps://github.com/controlsfx/controlsfx/blob/jfx-13/license.txt\n\n"; - } -} +/* +Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macropad +Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones) + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Written by : Debayan Sutradhar (rnayabed) +*/ + +package com.stream_pi.client.info; + +public class License { + public static String getLicense() + { + return "Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad\n" + + "Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)\n" + + "\n" + + "This program is free software: you can redistribute it and/or modify\n" + + "it under the terms of the GNU General Public License as published by\n" + + "the Free Software Foundation, either version 3 of the License, or\n" + + "(at your option) any later version.\n" + + "\n" + + "This program is distributed in the hope that it will be useful,\n" + + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + + "GNU General Public License for more details.\n" + + "\n\n"+ + "Opensource Libraries/Tech used :\n"+ + "1. JavaFX - GNU General Public License with Classpath Exception\nhttp://openjdk.java.net/legal/gplv2+ce.html\n\n"+ + "2. Gluon Attach - GPL License\nhttps://github.com/gluonhq/attach/blob/master/LICENSE\n\n"+ + "3. Gluon Client Maven Plugin - BSD-3 License\nhttps://github.com/gluonhq/client-maven-plugin/blob/master/LICENSE\n\n" + + "4. Ikonli - Apache License\nhttps://github.com/kordamp/ikonli/blob/master/LICENSE\n\n"+ + "5. Roboto Font - Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0\n\n"+ + "6. ControlsFX - BSD 3-Clause License\nhttps://github.com/controlsfx/controlsfx/blob/jfx-13/license.txt\n\n"; + } +} diff --git a/src/main/java/com/stream_pi/client/info/StartupFlags.java b/src/main/java/com/stream_pi/client/info/StartupFlags.java old mode 100644 new mode 100755 index ff515f13..1c4dbbaf --- a/src/main/java/com/stream_pi/client/info/StartupFlags.java +++ b/src/main/java/com/stream_pi/client/info/StartupFlags.java @@ -1,12 +1,12 @@ -package com.stream_pi.client.info; - -public class StartupFlags -{ - public static String RUNNER_FILE_NAME = null; - public static boolean IS_SHOW_SHUT_DOWN_BUTTON = false; - public static boolean IS_X_MODE = true; - public static boolean SCREEN_SAVER_FEATURE= false; - public static boolean DEFAULT_FULLSCREEN_MODE=false; - public static boolean SHOW_FULLSCREEN_TOGGLE_BUTTON=true; - public static boolean APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = false; -} +package com.stream_pi.client.info; + +public class StartupFlags +{ + public static String RUNNER_FILE_NAME = null; + public static boolean IS_SHOW_SHUT_DOWN_BUTTON = false; + public static boolean IS_X_MODE = true; + public static boolean SCREEN_SAVER_FEATURE= false; + public static boolean DEFAULT_FULLSCREEN_MODE=false; + public static boolean SHOW_FULLSCREEN_TOGGLE_BUTTON=true; + public static boolean APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = false; +} diff --git a/src/main/java/com/stream_pi/client/io/Config.java b/src/main/java/com/stream_pi/client/io/Config.java old mode 100644 new mode 100755 index 60b042b0..b2d5009d --- a/src/main/java/com/stream_pi/client/io/Config.java +++ b/src/main/java/com/stream_pi/client/io/Config.java @@ -1,551 +1,551 @@ -/* -Config.java - -Contributor(s) : Debayan Sutradhar (@rnayabed) - -handler for config.xml - */ - -package com.stream_pi.client.io; - -import java.io.File; -import java.util.Objects; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.Result; -import javax.xml.transform.Source; -import javax.xml.transform.Transformer; -import javax.xml.transform.TransformerFactory; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import com.stream_pi.client.Main; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.iohelper.IOHelper; -import com.stream_pi.util.platform.Platform; -import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; - -public class Config -{ - private static Config instance = null; - - private final File configFile; - - private Document document; - - private Config() throws SevereException - { - try - { - configFile = new File(ClientInfo.getInstance().getPrePath()+"config.xml"); - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - document = docBuilder.parse(configFile); - } - catch (Exception e) - { - e.printStackTrace(); - throw new SevereException("Config", "unable to read config.xml\n"+e.getMessage()); - } - } - - public static synchronized Config getInstance() throws SevereException - { - if(instance == null) - instance = new Config(); - - return instance; - } - - public static void nullify() - { - instance = null; - } - - public static void unzipToDefaultPrePath() throws Exception - { - IOHelper.unzip(Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath()); - Config.getInstance().setThemesPath(ClientInfo.getInstance().getPrePath()+"Themes/"); - Config.getInstance().setIconsPath(ClientInfo.getInstance().getPrePath()+"Icons/"); - Config.getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath()+"Profiles/"); - - Config.getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE); - - Config.getInstance().save(); - } - - public void save() throws SevereException - { - try - { - Transformer transformer = TransformerFactory.newInstance().newTransformer(); - Result output = new StreamResult(configFile); - Source input = new DOMSource(document); - - transformer.transform(input, output); - } - catch (Exception e) - { - throw new SevereException("Config", "unable to save config.xml"); - } - } - - - //Client Element - - //Default Values - public String getDefaultClientNickName() - { - return "Stream-Pi Client"; - } - - public String getDefaultStartupProfileID() - { - return "default"; - } - - public String getDefaultCurrentAnimationName() - { - return "None"; - } - - public String getDefaultCurrentThemeFullName() - { - return "com.stream_pi.defaultlight"; - } - - public String getDefaultThemesPath() - { - return ClientInfo.getInstance().getPrePath()+"Themes/"; - } - - public String getDefaultProfilesPath() - { - return ClientInfo.getInstance().getPrePath()+"Profiles/"; - } - - public String getDefaultIconsPath() - { - return ClientInfo.getInstance().getPrePath()+"Icons/"; - } - - //Getters - - public String getClientNickName() - { - return XMLConfigHelper.getStringProperty(document, "nickname", getDefaultClientNickName(), false, true, document, configFile); - } - - public String getStartupProfileID() - { - return XMLConfigHelper.getStringProperty(document, "startup-profile", getDefaultStartupProfileID(), false, true, document, configFile); - } - - public String getCurrentThemeFullName() - { - return XMLConfigHelper.getStringProperty(document, "current-theme-full-name", getDefaultCurrentThemeFullName(), false, true, document, configFile); - } - - public String getCurrentAnimationName() { - return XMLConfigHelper.getStringProperty(this.document, "current-animation-name", getDefaultCurrentAnimationName(), false, true, this.document, this.configFile); - } - - public String getThemesPath() - { - Platform platform = ClientInfo.getInstance().getPlatform(); - if(platform != Platform.ANDROID && - platform != Platform.IOS) - return ClientInfo.getInstance().getPrePath() + "Themes/"; - - return XMLConfigHelper.getStringProperty(document, "themes-path", getDefaultThemesPath(), false, true, document, configFile); - } - - public String getProfilesPath() - { - Platform platform = ClientInfo.getInstance().getPlatform(); - if(platform != Platform.ANDROID && - platform != Platform.IOS) - return ClientInfo.getInstance().getPrePath() + "Profiles/"; - - return XMLConfigHelper.getStringProperty(document, "profiles-path", getDefaultProfilesPath(), false, true, document, configFile); - } - - public String getIconsPath() - { - Platform platform = ClientInfo.getInstance().getPlatform(); - if(platform != Platform.ANDROID && - platform != Platform.IOS) - return ClientInfo.getInstance().getPrePath() + "Icons/"; - - return XMLConfigHelper.getStringProperty(document, "icons-path", getDefaultIconsPath(), false, true, document, configFile); - } - - - - //Setters - - public void setNickName(String nickName) - { - document.getElementsByTagName("nickname").item(0).setTextContent(nickName); - } - - public void setStartupProfileID(String id) - { - document.getElementsByTagName("startup-profile").item(0).setTextContent(id); - } - - public void setCurrentThemeFullName(String name) - { - document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); - } - - public void setCurrentAnimationFullName(String name) { - this.document.getElementsByTagName("current-animation-name").item(0).setTextContent(name); - } - - public void setProfilesPath(String profilesPath) - { - document.getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath); - } - - public void setIconsPath(String iconsPath) - { - document.getElementsByTagName("icons-path").item(0).setTextContent(iconsPath); - } - - public void setThemesPath(String themesPath) - { - document.getElementsByTagName("themes-path").item(0).setTextContent(themesPath); - } - - - //comms-server - public Element getCommsServerElement() - { - return (Element) document.getElementsByTagName("comms-server").item(0); - } - - public String getDefaultSavedServerHostNameOrIP() - { - return "127.0.0.1"; - } - - public int getDefaultSavedServerPort() - { - return -1; - } - - - public String getSavedServerHostNameOrIP() - { - return XMLConfigHelper.getStringProperty(getCommsServerElement(), "hostname-ip", getDefaultSavedServerHostNameOrIP(), false, true, document, configFile); - } - - public int getSavedServerPort() - { - return XMLConfigHelper.getIntProperty(getCommsServerElement(), "port", getDefaultSavedServerPort(), false, true, document, configFile); - } - - public void setServerHostNameOrIP(String hostNameOrIP) - { - getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP); - } - - public void setServerPort(int port) - { - getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(port+""); - } - - - - - - //screen-mover - public Element getScreenMoverElement() - { - return (Element) document.getElementsByTagName("screen-mover").item(0); - } - - - //others - public Element getOthersElement() - { - return (Element) document.getElementsByTagName("others").item(0); - } - - //others-default - - public boolean getDefaultStartOnBoot() - { - return false; - } - - public boolean getDefaultIsShowCursor() - { - return true; - } - - public boolean getDefaultFirstTimeUse() - { - return true; - } - - - - public boolean isShowCursor() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "show-cursor", getDefaultIsShowCursor(), false, true, document, configFile); - } - - - public boolean isStartOnBoot() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot", getDefaultStartOnBoot(), false, true, document, configFile); - } - - - public boolean isFirstTimeUse() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile); - } - - public boolean isVibrateOnActionClicked() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "vibrate-on-action-clicked", false, false, true, document, configFile); - } - - public boolean isConnectOnStartup() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "connect-on-startup", false, false, true, document, configFile); - } - - public boolean getIsFullScreenMode() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "full-screen-mode", false, false, true, document, configFile); - } - - - public void setStartOnBoot(boolean value) - { - getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+""); - } - - public void setShowCursor(boolean value) - { - getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(value+""); - } - - public void setFullscreen(boolean value) - { - getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(value+""); - } - - public void setFirstTimeUse(boolean value) - { - getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+""); - } - - public void setVibrateOnActionClicked(boolean value) - { - getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(value+""); - } - - public void setConnectOnStartup(boolean value) - { - getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(value+""); - } - - public void setIsFullScreenMode(boolean value) - { - getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(value+""); - } - - - - private Element getStartupWindowSizeElement() - { - return (Element) document.getElementsByTagName("startup-window-size").item(0); - } - - public double getStartupWindowWidth() - { - return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width", - getDefaultStartupWindowWidth(), false, true, document, configFile); - } - - public double getStartupWindowHeight() - { - return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height", - getDefaultStartupWindowHeight(), false, true, document, configFile); - } - - - public int getDefaultStartupWindowWidth() - { - return 800; - } - - public int getDefaultStartupWindowHeight() - { - return 400; - } - - public void setStartupWindowSize(double width, double height) - { - setStartupWindowWidth(width); - setStartupWindowHeight(height); - } - - public void setStartupWindowWidth(double width) - { - getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+""); - } - - public void setStartupWindowHeight(double height) - { - getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+""); - } - - public void setStartupIsXMode(boolean value) - { - getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(value+""); - } - - public boolean getDefaultIsStartupXMode() - { - return false; - } - - public boolean isStartupXMode() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot-x-mode", getDefaultIsStartupXMode(), false, true, document, configFile); - } - - - public boolean getDefaultIsTryConnectingWhenActionClicked() - { - return false; - } - - public boolean isTryConnectingWhenActionClicked() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "try-connecting-when-action-clicked", getDefaultIsTryConnectingWhenActionClicked(), false, true, document, configFile); - } - - public void setTryConnectingWhenActionClicked(boolean value) - { - getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(value+""); - } - - - public boolean getDefaultScreenSaverEnabled() - { - return false; - } - - public boolean isScreenSaverEnabled() - { - return XMLConfigHelper.getBooleanProperty(getOthersElement(), "screen-saver", getDefaultScreenSaverEnabled(), false, true, document, configFile); - } - - public void setScreenSaverEnabled(boolean value) - { - getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(value+""); - } - - public int getDefaultScreenSaverTimeout() - { - return 60; - } - - public int getScreenSaverTimeout() - { - return XMLConfigHelper.getIntProperty(getOthersElement(), "screen-saver-timeout-seconds", getDefaultScreenSaverTimeout(), false, true, document, configFile); - } - - public void setScreenSaverTimeout(String value) - { - getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value); - } - - public int getDefaultScreenMoverInterval() - { - return 120000; - } - - public int getScreenMoverInterval() - { - return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "interval", getDefaultScreenMoverInterval(), false, true, document, configFile); - } - - public void setScreenMoverInterval(String value) - { - getScreenMoverElement().getElementsByTagName("interval").item(0).setTextContent(value); - } - - public int getDefaultScreenMoverXChange() - { - return 5; - } - - public int getScreenMoverXChange() - { - return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "x-change", getDefaultScreenMoverXChange(), false, true, document, configFile); - } - - public void setScreenMoverXChange(String value) - { - getScreenMoverElement().getElementsByTagName("x-change").item(0).setTextContent(value); - } - - public int getDefaultScreenMoverYChange() - { - return 5; - } - - public int getScreenMoverYChange() - { - return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "y-change", getDefaultScreenMoverYChange(), false, true, document, configFile); - } - - public void setScreenMoverYChange(String value) - { - getScreenMoverElement().getElementsByTagName("y-change").item(0).setTextContent(value); - } - - public boolean getDefaultScreenMoverEnabled() - { - return false; - } - - public boolean isScreenMoverEnabled() - { - return XMLConfigHelper.getBooleanProperty(getScreenMoverElement(), "status", getDefaultScreenMoverEnabled(), false, true, document, configFile); - } - - public void setScreenMoverEnabled(boolean value) - { - getScreenMoverElement().getElementsByTagName("status").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+""); - } -} +/* +Config.java + +Contributor(s) : Debayan Sutradhar (@rnayabed) + +handler for config.xml + */ + +package com.stream_pi.client.io; + +import java.io.File; +import java.util.Objects; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.Result; +import javax.xml.transform.Source; +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import com.stream_pi.client.Main; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.iohelper.IOHelper; +import com.stream_pi.util.platform.Platform; +import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; + +public class Config +{ + private static Config instance = null; + + private final File configFile; + + private Document document; + + private Config() throws SevereException + { + try + { + configFile = new File(ClientInfo.getInstance().getPrePath()+"config.xml"); + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + document = docBuilder.parse(configFile); + } + catch (Exception e) + { + e.printStackTrace(); + throw new SevereException("Config", "unable to read config.xml\n"+e.getMessage()); + } + } + + public static synchronized Config getInstance() throws SevereException + { + if(instance == null) + instance = new Config(); + + return instance; + } + + public static void nullify() + { + instance = null; + } + + public static void unzipToDefaultPrePath() throws Exception + { + IOHelper.unzip(Objects.requireNonNull(Main.class.getResourceAsStream("Default.zip")), ClientInfo.getInstance().getPrePath()); + Config.getInstance().setThemesPath(ClientInfo.getInstance().getPrePath()+"Themes/"); + Config.getInstance().setIconsPath(ClientInfo.getInstance().getPrePath()+"Icons/"); + Config.getInstance().setProfilesPath(ClientInfo.getInstance().getPrePath()+"Profiles/"); + + Config.getInstance().setIsFullScreenMode(StartupFlags.DEFAULT_FULLSCREEN_MODE); + + Config.getInstance().save(); + } + + public void save() throws SevereException + { + try + { + Transformer transformer = TransformerFactory.newInstance().newTransformer(); + Result output = new StreamResult(configFile); + Source input = new DOMSource(document); + + transformer.transform(input, output); + } + catch (Exception e) + { + throw new SevereException("Config", "unable to save config.xml"); + } + } + + + //Client Element + + //Default Values + public String getDefaultClientNickName() + { + return "Stream-Pi Client"; + } + + public String getDefaultStartupProfileID() + { + return "default"; + } + + public String getDefaultCurrentAnimationName() + { + return "None"; + } + + public String getDefaultCurrentThemeFullName() + { + return "com.stream_pi.defaultlight"; + } + + public String getDefaultThemesPath() + { + return ClientInfo.getInstance().getPrePath()+"Themes/"; + } + + public String getDefaultProfilesPath() + { + return ClientInfo.getInstance().getPrePath()+"Profiles/"; + } + + public String getDefaultIconsPath() + { + return ClientInfo.getInstance().getPrePath()+"Icons/"; + } + + //Getters + + public String getClientNickName() + { + return XMLConfigHelper.getStringProperty(document, "nickname", getDefaultClientNickName(), false, true, document, configFile); + } + + public String getStartupProfileID() + { + return XMLConfigHelper.getStringProperty(document, "startup-profile", getDefaultStartupProfileID(), false, true, document, configFile); + } + + public String getCurrentThemeFullName() + { + return XMLConfigHelper.getStringProperty(document, "current-theme-full-name", getDefaultCurrentThemeFullName(), false, true, document, configFile); + } + + public String getCurrentAnimationName() { + return XMLConfigHelper.getStringProperty(this.document, "current-animation-name", getDefaultCurrentAnimationName(), false, true, this.document, this.configFile); + } + + public String getThemesPath() + { + Platform platform = ClientInfo.getInstance().getPlatform(); + if(platform != Platform.ANDROID && + platform != Platform.IOS) + return ClientInfo.getInstance().getPrePath() + "Themes/"; + + return XMLConfigHelper.getStringProperty(document, "themes-path", getDefaultThemesPath(), false, true, document, configFile); + } + + public String getProfilesPath() + { + Platform platform = ClientInfo.getInstance().getPlatform(); + if(platform != Platform.ANDROID && + platform != Platform.IOS) + return ClientInfo.getInstance().getPrePath() + "Profiles/"; + + return XMLConfigHelper.getStringProperty(document, "profiles-path", getDefaultProfilesPath(), false, true, document, configFile); + } + + public String getIconsPath() + { + Platform platform = ClientInfo.getInstance().getPlatform(); + if(platform != Platform.ANDROID && + platform != Platform.IOS) + return ClientInfo.getInstance().getPrePath() + "Icons/"; + + return XMLConfigHelper.getStringProperty(document, "icons-path", getDefaultIconsPath(), false, true, document, configFile); + } + + + + //Setters + + public void setNickName(String nickName) + { + document.getElementsByTagName("nickname").item(0).setTextContent(nickName); + } + + public void setStartupProfileID(String id) + { + document.getElementsByTagName("startup-profile").item(0).setTextContent(id); + } + + public void setCurrentThemeFullName(String name) + { + document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); + } + + public void setCurrentAnimationFullName(String name) { + this.document.getElementsByTagName("current-animation-name").item(0).setTextContent(name); + } + + public void setProfilesPath(String profilesPath) + { + document.getElementsByTagName("profiles-path").item(0).setTextContent(profilesPath); + } + + public void setIconsPath(String iconsPath) + { + document.getElementsByTagName("icons-path").item(0).setTextContent(iconsPath); + } + + public void setThemesPath(String themesPath) + { + document.getElementsByTagName("themes-path").item(0).setTextContent(themesPath); + } + + + //comms-server + public Element getCommsServerElement() + { + return (Element) document.getElementsByTagName("comms-server").item(0); + } + + public String getDefaultSavedServerHostNameOrIP() + { + return "127.0.0.1"; + } + + public int getDefaultSavedServerPort() + { + return -1; + } + + + public String getSavedServerHostNameOrIP() + { + return XMLConfigHelper.getStringProperty(getCommsServerElement(), "hostname-ip", getDefaultSavedServerHostNameOrIP(), false, true, document, configFile); + } + + public int getSavedServerPort() + { + return XMLConfigHelper.getIntProperty(getCommsServerElement(), "port", getDefaultSavedServerPort(), false, true, document, configFile); + } + + public void setServerHostNameOrIP(String hostNameOrIP) + { + getCommsServerElement().getElementsByTagName("hostname-ip").item(0).setTextContent(hostNameOrIP); + } + + public void setServerPort(int port) + { + getCommsServerElement().getElementsByTagName("port").item(0).setTextContent(port+""); + } + + + + + + //screen-mover + public Element getScreenMoverElement() + { + return (Element) document.getElementsByTagName("screen-mover").item(0); + } + + + //others + public Element getOthersElement() + { + return (Element) document.getElementsByTagName("others").item(0); + } + + //others-default + + public boolean getDefaultStartOnBoot() + { + return false; + } + + public boolean getDefaultIsShowCursor() + { + return true; + } + + public boolean getDefaultFirstTimeUse() + { + return true; + } + + + + public boolean isShowCursor() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "show-cursor", getDefaultIsShowCursor(), false, true, document, configFile); + } + + + public boolean isStartOnBoot() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot", getDefaultStartOnBoot(), false, true, document, configFile); + } + + + public boolean isFirstTimeUse() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "first-time-use", true, false, true, document, configFile); + } + + public boolean isVibrateOnActionClicked() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "vibrate-on-action-clicked", false, false, true, document, configFile); + } + + public boolean isConnectOnStartup() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "connect-on-startup", false, false, true, document, configFile); + } + + public boolean getIsFullScreenMode() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "full-screen-mode", false, false, true, document, configFile); + } + + + public void setStartOnBoot(boolean value) + { + getOthersElement().getElementsByTagName("start-on-boot").item(0).setTextContent(value+""); + } + + public void setShowCursor(boolean value) + { + getOthersElement().getElementsByTagName("show-cursor").item(0).setTextContent(value+""); + } + + public void setFullscreen(boolean value) + { + getOthersElement().getElementsByTagName("fullscreen").item(0).setTextContent(value+""); + } + + public void setFirstTimeUse(boolean value) + { + getOthersElement().getElementsByTagName("first-time-use").item(0).setTextContent(value+""); + } + + public void setVibrateOnActionClicked(boolean value) + { + getOthersElement().getElementsByTagName("vibrate-on-action-clicked").item(0).setTextContent(value+""); + } + + public void setConnectOnStartup(boolean value) + { + getOthersElement().getElementsByTagName("connect-on-startup").item(0).setTextContent(value+""); + } + + public void setIsFullScreenMode(boolean value) + { + getOthersElement().getElementsByTagName("full-screen-mode").item(0).setTextContent(value+""); + } + + + + private Element getStartupWindowSizeElement() + { + return (Element) document.getElementsByTagName("startup-window-size").item(0); + } + + public double getStartupWindowWidth() + { + return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "width", + getDefaultStartupWindowWidth(), false, true, document, configFile); + } + + public double getStartupWindowHeight() + { + return XMLConfigHelper.getDoubleProperty(getStartupWindowSizeElement(), "height", + getDefaultStartupWindowHeight(), false, true, document, configFile); + } + + + public int getDefaultStartupWindowWidth() + { + return 800; + } + + public int getDefaultStartupWindowHeight() + { + return 400; + } + + public void setStartupWindowSize(double width, double height) + { + setStartupWindowWidth(width); + setStartupWindowHeight(height); + } + + public void setStartupWindowWidth(double width) + { + getStartupWindowSizeElement().getElementsByTagName("width").item(0).setTextContent(width+""); + } + + public void setStartupWindowHeight(double height) + { + getStartupWindowSizeElement().getElementsByTagName("height").item(0).setTextContent(height+""); + } + + public void setStartupIsXMode(boolean value) + { + getOthersElement().getElementsByTagName("start-on-boot-x-mode").item(0).setTextContent(value+""); + } + + public boolean getDefaultIsStartupXMode() + { + return false; + } + + public boolean isStartupXMode() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "start-on-boot-x-mode", getDefaultIsStartupXMode(), false, true, document, configFile); + } + + + public boolean getDefaultIsTryConnectingWhenActionClicked() + { + return false; + } + + public boolean isTryConnectingWhenActionClicked() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "try-connecting-when-action-clicked", getDefaultIsTryConnectingWhenActionClicked(), false, true, document, configFile); + } + + public void setTryConnectingWhenActionClicked(boolean value) + { + getOthersElement().getElementsByTagName("try-connecting-when-action-clicked").item(0).setTextContent(value+""); + } + + + public boolean getDefaultScreenSaverEnabled() + { + return false; + } + + public boolean isScreenSaverEnabled() + { + return XMLConfigHelper.getBooleanProperty(getOthersElement(), "screen-saver", getDefaultScreenSaverEnabled(), false, true, document, configFile); + } + + public void setScreenSaverEnabled(boolean value) + { + getOthersElement().getElementsByTagName("screen-saver").item(0).setTextContent(value+""); + } + + public int getDefaultScreenSaverTimeout() + { + return 60; + } + + public int getScreenSaverTimeout() + { + return XMLConfigHelper.getIntProperty(getOthersElement(), "screen-saver-timeout-seconds", getDefaultScreenSaverTimeout(), false, true, document, configFile); + } + + public void setScreenSaverTimeout(String value) + { + getOthersElement().getElementsByTagName("screen-saver-timeout-seconds").item(0).setTextContent(value); + } + + public int getDefaultScreenMoverInterval() + { + return 120000; + } + + public int getScreenMoverInterval() + { + return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "interval", getDefaultScreenMoverInterval(), false, true, document, configFile); + } + + public void setScreenMoverInterval(String value) + { + getScreenMoverElement().getElementsByTagName("interval").item(0).setTextContent(value); + } + + public int getDefaultScreenMoverXChange() + { + return 5; + } + + public int getScreenMoverXChange() + { + return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "x-change", getDefaultScreenMoverXChange(), false, true, document, configFile); + } + + public void setScreenMoverXChange(String value) + { + getScreenMoverElement().getElementsByTagName("x-change").item(0).setTextContent(value); + } + + public int getDefaultScreenMoverYChange() + { + return 5; + } + + public int getScreenMoverYChange() + { + return XMLConfigHelper.getIntProperty(getScreenMoverElement(), "y-change", getDefaultScreenMoverYChange(), false, true, document, configFile); + } + + public void setScreenMoverYChange(String value) + { + getScreenMoverElement().getElementsByTagName("y-change").item(0).setTextContent(value); + } + + public boolean getDefaultScreenMoverEnabled() + { + return false; + } + + public boolean isScreenMoverEnabled() + { + return XMLConfigHelper.getBooleanProperty(getScreenMoverElement(), "status", getDefaultScreenMoverEnabled(), false, true, document, configFile); + } + + public void setScreenMoverEnabled(boolean value) + { + getScreenMoverElement().getElementsByTagName("status").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+""); + } +} diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfile.java b/src/main/java/com/stream_pi/client/profile/ClientProfile.java old mode 100644 new mode 100755 index 5764146b..ae556b48 --- a/src/main/java/com/stream_pi/client/profile/ClientProfile.java +++ b/src/main/java/com/stream_pi/client/profile/ClientProfile.java @@ -1,758 +1,758 @@ -package com.stream_pi.client.profile; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.*; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; -import com.stream_pi.action_api.action.DisplayTextAlignment; -import com.stream_pi.action_api.action.Location; -import com.stream_pi.action_api.actionproperty.ClientProperties; -import com.stream_pi.action_api.actionproperty.property.Property; -import com.stream_pi.action_api.actionproperty.property.Type; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.version.Version; -import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class ClientProfile implements Cloneable{ - private String name, ID; - - private int rows, cols, actionSize, actionGap; - - - private HashMap actions; - private String iconsPath; - - private File file; - - private Logger logger; - private Document document; - - public ClientProfile(File file, String iconsPath) throws MinorException - { - this.file = file; - this.iconsPath = iconsPath; - - actions = new HashMap<>(); - - logger = Logger.getLogger(ClientProfile.class.getName()); - - if(!file.exists() && !file.isFile()) - createConfigFile(file); - - try - { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - document = docBuilder.parse(file); - } - catch (Exception e) - { - e.printStackTrace(); - throw new MinorException("profile", "Unable to read profile config file."); - } - - - setID(file.getName().replace(".xml", "")); - load(); - } - - - private Element getProfileElement() - { - return (Element) document.getElementsByTagName("profile").item(0); - } - - private Element getActionsElement() - { - return (Element) document.getElementsByTagName("actions").item(0); - } - - public void load() throws MinorException - { - try - { - actions.clear(); - - logger.info("Loading profile "+getID()+" ..."); - - String name = XMLConfigHelper.getStringProperty(getProfileElement(), "name"); - int rows = XMLConfigHelper.getIntProperty(getProfileElement(), "rows"); - int cols = XMLConfigHelper.getIntProperty(getProfileElement(), "cols"); - int actionSize = XMLConfigHelper.getIntProperty(getProfileElement(), "action-size"); - int actionGap = XMLConfigHelper.getIntProperty(getProfileElement(), "action-gap"); - - setName(name); - setRows(rows); - setCols(cols); - setActionSize(actionSize); - setActionGap(actionGap); - - - //Load Actions - - NodeList actionsNodesList = getActionsElement().getChildNodes(); - - int actionsSize = actionsNodesList.getLength(); - - logger.info("Actions Size : "+actionsSize); - - for(int item = 0; item-1) - { - - Element actionElement = (Element) getActionsElement().getElementsByTagName("action").item(index); - - Element displayElement = (Element) actionElement.getElementsByTagName("display").item(0); - Element backgroundElement = (Element) displayElement.getElementsByTagName("background").item(0); - Element iconElement = (Element) backgroundElement.getElementsByTagName("icon").item(0); - - Element statesElements = (Element) iconElement.getElementsByTagName("states").item(0); - - NodeList statesNodeList = statesElements.getChildNodes(); - - for (int i = 0;i getActions() - { - ArrayList p = new ArrayList<>(); - for(String profile : actions.keySet()) - p.add(actions.get(profile)); - return p; - } - - public String getID() - { - return ID; - } - - public String getName() - { - return name; - } - - public int getRows() - { - return rows; - } - - public int getCols() - { - return cols; - } - - public int getActionSize() - { - return actionSize; - } - - public Action getActionFromID(String ID) - { - return actions.getOrDefault(ID, null); - } - - public int getActionGap() - { - return actionGap; - } - - public void setRows(int rows) - { - this.rows = rows; - } - - public void setCols(int cols) - { - this.cols = cols; - } - - public void setID(String ID) - { - this.ID = ID; - } - - public void setActionSize(int actionSize) - { - this.actionSize = actionSize; - } - - public void setActionGap(int actionGap) - { - this.actionGap = actionGap; - } - - public void setName(String name) - { - this.name = name; - } - - - public Object clone() throws CloneNotSupportedException - { - return super.clone(); - } -} +package com.stream_pi.client.profile; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.logging.Logger; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.*; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; +import com.stream_pi.action_api.action.DisplayTextAlignment; +import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.actionproperty.ClientProperties; +import com.stream_pi.action_api.actionproperty.property.Property; +import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.version.Version; +import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class ClientProfile implements Cloneable{ + private String name, ID; + + private int rows, cols, actionSize, actionGap; + + + private HashMap actions; + private String iconsPath; + + private File file; + + private Logger logger; + private Document document; + + public ClientProfile(File file, String iconsPath) throws MinorException + { + this.file = file; + this.iconsPath = iconsPath; + + actions = new HashMap<>(); + + logger = Logger.getLogger(ClientProfile.class.getName()); + + if(!file.exists() && !file.isFile()) + createConfigFile(file); + + try + { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + document = docBuilder.parse(file); + } + catch (Exception e) + { + e.printStackTrace(); + throw new MinorException("profile", "Unable to read profile config file."); + } + + + setID(file.getName().replace(".xml", "")); + load(); + } + + + private Element getProfileElement() + { + return (Element) document.getElementsByTagName("profile").item(0); + } + + private Element getActionsElement() + { + return (Element) document.getElementsByTagName("actions").item(0); + } + + public void load() throws MinorException + { + try + { + actions.clear(); + + logger.info("Loading profile "+getID()+" ..."); + + String name = XMLConfigHelper.getStringProperty(getProfileElement(), "name"); + int rows = XMLConfigHelper.getIntProperty(getProfileElement(), "rows"); + int cols = XMLConfigHelper.getIntProperty(getProfileElement(), "cols"); + int actionSize = XMLConfigHelper.getIntProperty(getProfileElement(), "action-size"); + int actionGap = XMLConfigHelper.getIntProperty(getProfileElement(), "action-gap"); + + setName(name); + setRows(rows); + setCols(cols); + setActionSize(actionSize); + setActionGap(actionGap); + + + //Load Actions + + NodeList actionsNodesList = getActionsElement().getChildNodes(); + + int actionsSize = actionsNodesList.getLength(); + + logger.info("Actions Size : "+actionsSize); + + for(int item = 0; item-1) + { + + Element actionElement = (Element) getActionsElement().getElementsByTagName("action").item(index); + + Element displayElement = (Element) actionElement.getElementsByTagName("display").item(0); + Element backgroundElement = (Element) displayElement.getElementsByTagName("background").item(0); + Element iconElement = (Element) backgroundElement.getElementsByTagName("icon").item(0); + + Element statesElements = (Element) iconElement.getElementsByTagName("states").item(0); + + NodeList statesNodeList = statesElements.getChildNodes(); + + for (int i = 0;i getActions() + { + ArrayList p = new ArrayList<>(); + for(String profile : actions.keySet()) + p.add(actions.get(profile)); + return p; + } + + public String getID() + { + return ID; + } + + public String getName() + { + return name; + } + + public int getRows() + { + return rows; + } + + public int getCols() + { + return cols; + } + + public int getActionSize() + { + return actionSize; + } + + public Action getActionFromID(String ID) + { + return actions.getOrDefault(ID, null); + } + + public int getActionGap() + { + return actionGap; + } + + public void setRows(int rows) + { + this.rows = rows; + } + + public void setCols(int cols) + { + this.cols = cols; + } + + public void setID(String ID) + { + this.ID = ID; + } + + public void setActionSize(int actionSize) + { + this.actionSize = actionSize; + } + + public void setActionGap(int actionGap) + { + this.actionGap = actionGap; + } + + public void setName(String name) + { + this.name = name; + } + + + public Object clone() throws CloneNotSupportedException + { + return super.clone(); + } +} diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfiles.java b/src/main/java/com/stream_pi/client/profile/ClientProfiles.java old mode 100644 new mode 100755 index 8e4572b8..8d97c991 --- a/src/main/java/com/stream_pi/client/profile/ClientProfiles.java +++ b/src/main/java/com/stream_pi/client/profile/ClientProfiles.java @@ -1,119 +1,119 @@ -package com.stream_pi.client.profile; - -import com.stream_pi.client.io.Config; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.logging.Logger; - -public class ClientProfiles { - - - private File profilesFolder; - private String defaultProfileID; - - private Logger logger; - - public ClientProfiles(File profilesFolder, String defaultProfileID) throws SevereException - { - logger = Logger.getLogger(ClientProfiles.class.getName()); - - this.defaultProfileID = defaultProfileID; - this.profilesFolder = profilesFolder; - clientProfiles = new HashMap<>(); - loadingErrors = new ArrayList<>(); - - loadProfiles(); - } - - public void addProfile(ClientProfile clientProfile) throws CloneNotSupportedException { - clientProfiles.put(clientProfile.getID(), (ClientProfile) clientProfile.clone()); - } - - public void deleteProfile(ClientProfile clientProfile) - { - clientProfiles.remove(clientProfile.getID()); - - clientProfile.deleteProfile(); - } - - private ArrayList loadingErrors; - private HashMap clientProfiles; - - public void loadProfiles() throws SevereException - { - logger.info("Loading profiles ..."); - - - String iconsPath = Config.getInstance().getIconsPath(); - - clientProfiles.clear(); - loadingErrors.clear(); - - if(!profilesFolder.isDirectory()) - { - throw new SevereException("Profiles","Profile folder doesn't exist! Cant continue."); - } - - - File[] profilesFiles = profilesFolder.listFiles(); - if(profilesFiles == null) - { - throw new SevereException("Profiles","profilesFiles returned null. Cant continue!"); - } - - for(File eachProfileFile : profilesFiles) - { - try - { - ClientProfile profile = new ClientProfile(eachProfileFile, iconsPath); - try - { - addProfile(profile); - } - catch (CloneNotSupportedException e) - { - e.printStackTrace(); - throw new SevereException(e.getMessage()); - } - } - catch (MinorException e) - { - if(eachProfileFile.getName().replace(".xml","").equals(defaultProfileID)) - { - throw new SevereException("Profiles", "Default profile bad. Can't continue"); - } - - loadingErrors.add(new MinorException(e.getMessage()+" ("+eachProfileFile.getName().replace(".xml", ""))); - - e.printStackTrace(); - } - } - - logger.info("Loaded all profiles!"); - } - - public ArrayList getLoadingErrors() - { - return loadingErrors; - } - - public ArrayList getClientProfiles() - { - ArrayList p = new ArrayList<>(); - for(String profile : clientProfiles.keySet()) - p.add(clientProfiles.get(profile)); - return p; - } - - public ClientProfile getProfileFromID(String profileID) - { - return clientProfiles.getOrDefault(profileID, null); - } - - - -} +package com.stream_pi.client.profile; + +import com.stream_pi.client.io.Config; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.logging.Logger; + +public class ClientProfiles { + + + private File profilesFolder; + private String defaultProfileID; + + private Logger logger; + + public ClientProfiles(File profilesFolder, String defaultProfileID) throws SevereException + { + logger = Logger.getLogger(ClientProfiles.class.getName()); + + this.defaultProfileID = defaultProfileID; + this.profilesFolder = profilesFolder; + clientProfiles = new HashMap<>(); + loadingErrors = new ArrayList<>(); + + loadProfiles(); + } + + public void addProfile(ClientProfile clientProfile) throws CloneNotSupportedException { + clientProfiles.put(clientProfile.getID(), (ClientProfile) clientProfile.clone()); + } + + public void deleteProfile(ClientProfile clientProfile) + { + clientProfiles.remove(clientProfile.getID()); + + clientProfile.deleteProfile(); + } + + private ArrayList loadingErrors; + private HashMap clientProfiles; + + public void loadProfiles() throws SevereException + { + logger.info("Loading profiles ..."); + + + String iconsPath = Config.getInstance().getIconsPath(); + + clientProfiles.clear(); + loadingErrors.clear(); + + if(!profilesFolder.isDirectory()) + { + throw new SevereException("Profiles","Profile folder doesn't exist! Cant continue."); + } + + + File[] profilesFiles = profilesFolder.listFiles(); + if(profilesFiles == null) + { + throw new SevereException("Profiles","profilesFiles returned null. Cant continue!"); + } + + for(File eachProfileFile : profilesFiles) + { + try + { + ClientProfile profile = new ClientProfile(eachProfileFile, iconsPath); + try + { + addProfile(profile); + } + catch (CloneNotSupportedException e) + { + e.printStackTrace(); + throw new SevereException(e.getMessage()); + } + } + catch (MinorException e) + { + if(eachProfileFile.getName().replace(".xml","").equals(defaultProfileID)) + { + throw new SevereException("Profiles", "Default profile bad. Can't continue"); + } + + loadingErrors.add(new MinorException(e.getMessage()+" ("+eachProfileFile.getName().replace(".xml", ""))); + + e.printStackTrace(); + } + } + + logger.info("Loaded all profiles!"); + } + + public ArrayList getLoadingErrors() + { + return loadingErrors; + } + + public ArrayList getClientProfiles() + { + ArrayList p = new ArrayList<>(); + for(String profile : clientProfiles.keySet()) + p.add(clientProfiles.get(profile)); + return p; + } + + public ClientProfile getProfileFromID(String profileID) + { + return clientProfiles.getOrDefault(profileID, null); + } + + + +} diff --git a/src/main/java/com/stream_pi/client/window/Base.java b/src/main/java/com/stream_pi/client/window/Base.java old mode 100644 new mode 100755 index db32b98e..f283289a --- a/src/main/java/com/stream_pi/client/window/Base.java +++ b/src/main/java/com/stream_pi/client/window/Base.java @@ -1,530 +1,530 @@ -package com.stream_pi.client.window; - -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.controller.ScreenSaver; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; - -import java.io.File; -import java.nio.file.Paths; -import java.util.Objects; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Logger; - -import com.stream_pi.client.Main; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.profile.ClientProfiles; -import com.stream_pi.client.window.dashboard.DashboardBase; -import com.stream_pi.client.window.firsttimeuse.FirstTimeUse; -import com.stream_pi.client.window.settings.SettingsBase; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.theme_api.Themes; -import com.stream_pi.util.alert.StreamPiAlert; -import com.stream_pi.util.combobox.StreamPiComboBox; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler; -import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler; -import com.stream_pi.util.platform.Platform; - -import javafx.application.HostServices; -import javafx.geometry.Insets; -import javafx.scene.CacheHint; -import javafx.scene.Cursor; -import javafx.scene.image.Image; -import javafx.scene.input.KeyCombination; -import javafx.scene.layout.StackPane; -import javafx.scene.text.Font; -import javafx.stage.Screen; -import javafx.stage.Stage; - -public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ClientListener -{ - private final ExecutorService executor = Executors.newCachedThreadPool(); - - private Config config; - - private ClientProfiles clientProfiles; - - private ClientInfo clientInfo; - - private Stage stage; - - public Stage getStage() - { - return stage; - } - - public Logger getLogger() - { - return logger; - } - - private DashboardBase dashboardBase; - private SettingsBase settingsBase; - - private FirstTimeUse firstTimeUse; - - - private StackPane alertStackPane; - - @Override - public ClientProfiles getClientProfiles() { - return clientProfiles; - } - - public void setClientProfiles(ClientProfiles clientProfiles) { - this.clientProfiles = clientProfiles; - } - - private Logger logger = null; - private StreamPiLogFileHandler logFileHandler = null; - private StreamPiLogFallbackHandler logFallbackHandler = null; - - @Override - public void initLogger() - { - try - { - if(logFileHandler != null) - return; - - closeLogger(); - logger = Logger.getLogger("com.stream_pi"); - - if(new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite()) - { - String path = ClientInfo.getInstance().getPrePath()+"../stream-pi-client.log"; - - if(getClientInfo().isPhone()) - path = ClientInfo.getInstance().getPrePath()+"stream-pi-client.log"; - - logFileHandler = new StreamPiLogFileHandler(path); - logger.addHandler(logFileHandler); - } - else - { - logFallbackHandler = new StreamPiLogFallbackHandler(); - logger.addHandler(logFallbackHandler); - } - - } - catch(Exception e) - { - e.printStackTrace(); - - logFallbackHandler = new StreamPiLogFallbackHandler(); - logger.addHandler(logFallbackHandler); - } - } - - public void closeLogger() - { - if(logFileHandler != null) - logFileHandler.close(); - else if(logFallbackHandler != null) - logFallbackHandler.close(); - } - - private HostServices hostServices; - - public void setHostServices(HostServices hostServices) - { - this.hostServices = hostServices; - } - - public HostServices getHostServices() - { - return hostServices; - } - - public void initBase() throws SevereException - { - stage = (Stage) getScene().getWindow(); - - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon256x256.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon48x48.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon32x32.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon24x24.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon16x16.png")))); - - clientInfo = ClientInfo.getInstance(); - dashboardBase = new DashboardBase(this, this); - dashboardBase.prefWidthProperty().bind(widthProperty()); - dashboardBase.prefHeightProperty().bind(heightProperty()); - - settingsBase = new SettingsBase(getHostServices(), this, this); - - alertStackPane = new StackPane(); - alertStackPane.setCache(true); - alertStackPane.setCacheHint(CacheHint.SPEED); - alertStackPane.setPadding(new Insets(10)); - alertStackPane.setOpacity(0); - - StreamPiAlert.setParent(alertStackPane); - StreamPiComboBox.setParent(alertStackPane); - - - getChildren().clear(); - - - getChildren().addAll(alertStackPane); - - if(getClientInfo().isPhone()) - { - dashboardBase.setPadding(new Insets(10)); - settingsBase.setPadding(new Insets(10)); - } - - initLogger(); - - checkPrePathDirectory(); - - - getChildren().addAll(settingsBase, dashboardBase); - - setStyle(null); - - config = Config.getInstance(); - - initThemes(); - - if(config.isFirstTimeUse()) - { - - firstTimeUse = new FirstTimeUse(this, this); - - getChildren().add(firstTimeUse); - - if(getClientInfo().isPhone()) - { - firstTimeUse.setPadding(new Insets(10)); - } - - firstTimeUse.toFront(); - - //resolution check - resizeAccordingToResolution(); - } - else - { - dashboardBase.toFront(); - } - } - - public void initThemes() throws SevereException - { - clearStylesheets(); - if(themes==null) - registerThemes(); - applyDefaultStylesheet(); - applyDefaultTheme(); - applyDefaultIconsStylesheet(); - applyGlobalDefaultStylesheet(); - } - - private void resizeAccordingToResolution() - { - if(!getClientInfo().isPhone()) - { - double height = getScreenHeight(); - double width = getScreenWidth(); - - if(height < 500) - setPrefHeight(320); - - if(width < 500) - setPrefWidth(240); - } - } - - @Override - public ExecutorService getExecutor() - { - return executor; - } - - @Override - public double getStageWidth() - { - if(getClientInfo().isPhone()) - { - return getScreenWidth(); - } - else - { - return getStage().getWidth(); - } - } - - public double getScreenWidth() - { - return Screen.getPrimary().getBounds().getWidth(); - } - - @Override - public double getStageHeight() - { - if(ClientInfo.getInstance().isPhone()) - { - return getScreenHeight(); - } - else - { - return getStage().getHeight(); - } - } - - public double getScreenHeight() - { - return Screen.getPrimary().getBounds().getHeight(); - } - - private void checkPrePathDirectory() throws SevereException - { - try - { - String path = getClientInfo().getPrePath(); - - if(path == null) - { - throwStoragePermErrorAlert("Unable to access file system!"); - return; - } - - File file = new File(path); - - - if(!file.exists()) - { - boolean result = file.mkdirs(); - if(result) - { - Config.unzipToDefaultPrePath(); - - initLogger(); - } - else - { - throwStoragePermErrorAlert("No storage permission. Give it!"); - } - } - } - catch (Exception e) - { - e.printStackTrace(); - throw new SevereException(e.getMessage()); - } - } - - private void throwStoragePermErrorAlert(String msg) throws SevereException - { - resizeAccordingToResolution(); - - clearStylesheets(); - applyDefaultStylesheet(); - applyDefaultIconsStylesheet(); - applyGlobalDefaultStylesheet(); - getStage().show(); - throw new SevereException(msg); - } - - public void setupFlags() throws SevereException - { - //Full Screen - if(Config.getInstance().getIsFullScreenMode()) - { - getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); - getStage().setFullScreen(true); - } - else - { - getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC")); - getStage().setFullScreen(false); - } - - //Cursor - if(Config.getInstance().isShowCursor()) - { - setCursor(Cursor.DEFAULT); - } - else - { - setCursor(Cursor.NONE); - } - } - - - public SettingsBase getSettingsPane() { - return settingsBase; - } - - public DashboardBase getDashboardPane() { - return dashboardBase; - } - - public void renderRootDefaultProfile() - { - getDashboardPane().renderProfile(getClientProfiles().getProfileFromID( - getConfig().getStartupProfileID() - ), true); - } - - - - public void clearStylesheets() - { - getStylesheets().clear(); - } - - - - public void applyDefaultStylesheet() - { - if(clientInfo.getPlatform() != Platform.IOS) - Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13); - - getStylesheets().add(Main.class.getResource("style.css").toExternalForm()); - } - - public void applyDefaultIconsStylesheet() - { - getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm()); - } - - - public Config getConfig() - { - return config; - } - - public ClientInfo getClientInfo() - { - return clientInfo; - } - - private Theme currentTheme; - - @Override - public Theme getCurrentTheme() - { - return currentTheme; - } - - - public void applyTheme(Theme t) - { - logger.info("Applying theme '"+t.getFullName()+"' ..."); - - if(t.getFonts() != null) - { - for(String fontFile : t.getFonts()) - { - Font.loadFont(fontFile.replace("%20",""), 13); - } - } - currentTheme = t; - getStylesheets().addAll(t.getStylesheets()); - - logger.info("... Done!"); - } - - public void applyGlobalDefaultStylesheet() - { - File globalCSSFile = new File(getConfig().getDefaultThemesPath()+"/global.css"); - if(globalCSSFile.exists()) - { - getLogger().info("Found global default style sheet. Adding ..."); - getStylesheets().add(globalCSSFile.toURI().toString()); - } - } - - Themes themes; - public void registerThemes() throws SevereException - { - logger.info("Loading themes ..."); - - themes = new Themes(getConfig().getDefaultThemesPath(), getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), clientInfo.getMinThemeSupportVersion()); - - if(!themes.getErrors().isEmpty()) - { - StringBuilder themeErrors = new StringBuilder(); - - for(MinorException eachException : themes.getErrors()) - { - themeErrors.append("\n * ").append(eachException.getMessage()); - } - - if(themes.getIsBadThemeTheCurrentOne()) - { - if(getConfig().getCurrentThemeFullName().equals(getConfig().getDefaultCurrentThemeFullName())) - { - throw new SevereException("Unable to get default theme ("+getConfig().getDefaultCurrentThemeFullName()+")\n" + - "Please restore the theme or reinstall."); - } - - themeErrors.append("\n\nReverted to default theme! (").append(getConfig().getDefaultCurrentThemeFullName()).append(")"); - - getConfig().setCurrentThemeFullName(getConfig().getDefaultCurrentThemeFullName()); - getConfig().save(); - } - - handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString())); - } - logger.info("...Themes loaded successfully !"); - } - - @Override - public Themes getThemes() - { - return themes; - } - - - public void applyDefaultTheme() - { - logger.info("Applying default theme ..."); - - boolean foundTheme = false; - for(Theme t: themes.getThemeList()) - { - if(t.getFullName().equals(config.getCurrentThemeFullName())) - { - foundTheme = true; - applyTheme(t); - break; - } - } - - if(foundTheme) - { - logger.info("... Done!"); - } - else - { - logger.info("Theme not found. reverting to light theme ..."); - try { - Config.getInstance().setCurrentThemeFullName("com.stream_pi.defaultlight"); - Config.getInstance().save(); - - applyDefaultTheme(); - } - catch (SevereException e) - { - handleSevereException(e); - } - } - - - } - - @Override - public String getDefaultThemeFullName() - { - return config.getCurrentThemeFullName(); - } - - -} +package com.stream_pi.client.window; + +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.controller.ScreenSaver; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; + +import java.io.File; +import java.nio.file.Paths; +import java.util.Objects; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.logging.Logger; + +import com.stream_pi.client.Main; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.profile.ClientProfiles; +import com.stream_pi.client.window.dashboard.DashboardBase; +import com.stream_pi.client.window.firsttimeuse.FirstTimeUse; +import com.stream_pi.client.window.settings.SettingsBase; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.theme_api.Themes; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.combobox.StreamPiComboBox; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler; +import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler; +import com.stream_pi.util.platform.Platform; + +import javafx.application.HostServices; +import javafx.geometry.Insets; +import javafx.scene.CacheHint; +import javafx.scene.Cursor; +import javafx.scene.image.Image; +import javafx.scene.input.KeyCombination; +import javafx.scene.layout.StackPane; +import javafx.scene.text.Font; +import javafx.stage.Screen; +import javafx.stage.Stage; + +public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ClientListener +{ + private final ExecutorService executor = Executors.newCachedThreadPool(); + + private Config config; + + private ClientProfiles clientProfiles; + + private ClientInfo clientInfo; + + private Stage stage; + + public Stage getStage() + { + return stage; + } + + public Logger getLogger() + { + return logger; + } + + private DashboardBase dashboardBase; + private SettingsBase settingsBase; + + private FirstTimeUse firstTimeUse; + + + private StackPane alertStackPane; + + @Override + public ClientProfiles getClientProfiles() { + return clientProfiles; + } + + public void setClientProfiles(ClientProfiles clientProfiles) { + this.clientProfiles = clientProfiles; + } + + private Logger logger = null; + private StreamPiLogFileHandler logFileHandler = null; + private StreamPiLogFallbackHandler logFallbackHandler = null; + + @Override + public void initLogger() + { + try + { + if(logFileHandler != null) + return; + + closeLogger(); + logger = Logger.getLogger("com.stream_pi"); + + if(new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite()) + { + String path = ClientInfo.getInstance().getPrePath()+"../stream-pi-client.log"; + + if(getClientInfo().isPhone()) + path = ClientInfo.getInstance().getPrePath()+"stream-pi-client.log"; + + logFileHandler = new StreamPiLogFileHandler(path); + logger.addHandler(logFileHandler); + } + else + { + logFallbackHandler = new StreamPiLogFallbackHandler(); + logger.addHandler(logFallbackHandler); + } + + } + catch(Exception e) + { + e.printStackTrace(); + + logFallbackHandler = new StreamPiLogFallbackHandler(); + logger.addHandler(logFallbackHandler); + } + } + + public void closeLogger() + { + if(logFileHandler != null) + logFileHandler.close(); + else if(logFallbackHandler != null) + logFallbackHandler.close(); + } + + private HostServices hostServices; + + public void setHostServices(HostServices hostServices) + { + this.hostServices = hostServices; + } + + public HostServices getHostServices() + { + return hostServices; + } + + public void initBase() throws SevereException + { + stage = (Stage) getScene().getWindow(); + + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon256x256.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon48x48.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon32x32.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon24x24.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon16x16.png")))); + + clientInfo = ClientInfo.getInstance(); + dashboardBase = new DashboardBase(this, this); + dashboardBase.prefWidthProperty().bind(widthProperty()); + dashboardBase.prefHeightProperty().bind(heightProperty()); + + settingsBase = new SettingsBase(getHostServices(), this, this); + + alertStackPane = new StackPane(); + alertStackPane.setCache(true); + alertStackPane.setCacheHint(CacheHint.SPEED); + alertStackPane.setPadding(new Insets(10)); + alertStackPane.setOpacity(0); + + StreamPiAlert.setParent(alertStackPane); + StreamPiComboBox.setParent(alertStackPane); + + + getChildren().clear(); + + + getChildren().addAll(alertStackPane); + + if(getClientInfo().isPhone()) + { + dashboardBase.setPadding(new Insets(10)); + settingsBase.setPadding(new Insets(10)); + } + + initLogger(); + + checkPrePathDirectory(); + + + getChildren().addAll(settingsBase, dashboardBase); + + setStyle(null); + + config = Config.getInstance(); + + initThemes(); + + if(config.isFirstTimeUse()) + { + + firstTimeUse = new FirstTimeUse(this, this); + + getChildren().add(firstTimeUse); + + if(getClientInfo().isPhone()) + { + firstTimeUse.setPadding(new Insets(10)); + } + + firstTimeUse.toFront(); + + //resolution check + resizeAccordingToResolution(); + } + else + { + dashboardBase.toFront(); + } + } + + public void initThemes() throws SevereException + { + clearStylesheets(); + if(themes==null) + registerThemes(); + applyDefaultStylesheet(); + applyDefaultTheme(); + applyDefaultIconsStylesheet(); + applyGlobalDefaultStylesheet(); + } + + private void resizeAccordingToResolution() + { + if(!getClientInfo().isPhone()) + { + double height = getScreenHeight(); + double width = getScreenWidth(); + + if(height < 500) + setPrefHeight(320); + + if(width < 500) + setPrefWidth(240); + } + } + + @Override + public ExecutorService getExecutor() + { + return executor; + } + + @Override + public double getStageWidth() + { + if(getClientInfo().isPhone()) + { + return getScreenWidth(); + } + else + { + return getStage().getWidth(); + } + } + + public double getScreenWidth() + { + return Screen.getPrimary().getBounds().getWidth(); + } + + @Override + public double getStageHeight() + { + if(ClientInfo.getInstance().isPhone()) + { + return getScreenHeight(); + } + else + { + return getStage().getHeight(); + } + } + + public double getScreenHeight() + { + return Screen.getPrimary().getBounds().getHeight(); + } + + private void checkPrePathDirectory() throws SevereException + { + try + { + String path = getClientInfo().getPrePath(); + + if(path == null) + { + throwStoragePermErrorAlert("Unable to access file system!"); + return; + } + + File file = new File(path); + + + if(!file.exists()) + { + boolean result = file.mkdirs(); + if(result) + { + Config.unzipToDefaultPrePath(); + + initLogger(); + } + else + { + throwStoragePermErrorAlert("No storage permission. Give it!"); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + throw new SevereException(e.getMessage()); + } + } + + private void throwStoragePermErrorAlert(String msg) throws SevereException + { + resizeAccordingToResolution(); + + clearStylesheets(); + applyDefaultStylesheet(); + applyDefaultIconsStylesheet(); + applyGlobalDefaultStylesheet(); + getStage().show(); + throw new SevereException(msg); + } + + public void setupFlags() throws SevereException + { + //Full Screen + if(Config.getInstance().getIsFullScreenMode()) + { + getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); + getStage().setFullScreen(true); + } + else + { + getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC")); + getStage().setFullScreen(false); + } + + //Cursor + if(Config.getInstance().isShowCursor()) + { + setCursor(Cursor.DEFAULT); + } + else + { + setCursor(Cursor.NONE); + } + } + + + public SettingsBase getSettingsPane() { + return settingsBase; + } + + public DashboardBase getDashboardPane() { + return dashboardBase; + } + + public void renderRootDefaultProfile() + { + getDashboardPane().renderProfile(getClientProfiles().getProfileFromID( + getConfig().getStartupProfileID() + ), true); + } + + + + public void clearStylesheets() + { + getStylesheets().clear(); + } + + + + public void applyDefaultStylesheet() + { + if(clientInfo.getPlatform() != Platform.IOS) + Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13); + + getStylesheets().add(Main.class.getResource("style.css").toExternalForm()); + } + + public void applyDefaultIconsStylesheet() + { + getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm()); + } + + + public Config getConfig() + { + return config; + } + + public ClientInfo getClientInfo() + { + return clientInfo; + } + + private Theme currentTheme; + + @Override + public Theme getCurrentTheme() + { + return currentTheme; + } + + + public void applyTheme(Theme t) + { + logger.info("Applying theme '"+t.getFullName()+"' ..."); + + if(t.getFonts() != null) + { + for(String fontFile : t.getFonts()) + { + Font.loadFont(fontFile.replace("%20",""), 13); + } + } + currentTheme = t; + getStylesheets().addAll(t.getStylesheets()); + + logger.info("... Done!"); + } + + public void applyGlobalDefaultStylesheet() + { + File globalCSSFile = new File(getConfig().getDefaultThemesPath()+"/global.css"); + if(globalCSSFile.exists()) + { + getLogger().info("Found global default style sheet. Adding ..."); + getStylesheets().add(globalCSSFile.toURI().toString()); + } + } + + Themes themes; + public void registerThemes() throws SevereException + { + logger.info("Loading themes ..."); + + themes = new Themes(getConfig().getDefaultThemesPath(), getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), clientInfo.getMinThemeSupportVersion()); + + if(!themes.getErrors().isEmpty()) + { + StringBuilder themeErrors = new StringBuilder(); + + for(MinorException eachException : themes.getErrors()) + { + themeErrors.append("\n * ").append(eachException.getMessage()); + } + + if(themes.getIsBadThemeTheCurrentOne()) + { + if(getConfig().getCurrentThemeFullName().equals(getConfig().getDefaultCurrentThemeFullName())) + { + throw new SevereException("Unable to get default theme ("+getConfig().getDefaultCurrentThemeFullName()+")\n" + + "Please restore the theme or reinstall."); + } + + themeErrors.append("\n\nReverted to default theme! (").append(getConfig().getDefaultCurrentThemeFullName()).append(")"); + + getConfig().setCurrentThemeFullName(getConfig().getDefaultCurrentThemeFullName()); + getConfig().save(); + } + + handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString())); + } + logger.info("...Themes loaded successfully !"); + } + + @Override + public Themes getThemes() + { + return themes; + } + + + public void applyDefaultTheme() + { + logger.info("Applying default theme ..."); + + boolean foundTheme = false; + for(Theme t: themes.getThemeList()) + { + if(t.getFullName().equals(config.getCurrentThemeFullName())) + { + foundTheme = true; + applyTheme(t); + break; + } + } + + if(foundTheme) + { + logger.info("... Done!"); + } + else + { + logger.info("Theme not found. reverting to light theme ..."); + try { + Config.getInstance().setCurrentThemeFullName("com.stream_pi.defaultlight"); + Config.getInstance().save(); + + applyDefaultTheme(); + } + catch (SevereException e) + { + handleSevereException(e); + } + } + + + } + + @Override + public String getDefaultThemeFullName() + { + return config.getCurrentThemeFullName(); + } + + +} diff --git a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java old mode 100644 new mode 100755 index 42c276c1..e70436fa --- a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java +++ b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java @@ -1,15 +1,15 @@ -package com.stream_pi.client.window; - -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; - -public interface ExceptionAndAlertHandler -{ - void onAlert(String title, String body, StreamPiAlertType alertType); - - void handleMinorException(MinorException e); - void handleMinorException(String message, MinorException e); - void handleSevereException(SevereException e); - void handleSevereException(String message, SevereException e); -} +package com.stream_pi.client.window; + +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; + +public interface ExceptionAndAlertHandler +{ + void onAlert(String title, String body, StreamPiAlertType alertType); + + void handleMinorException(MinorException e); + void handleMinorException(String message, MinorException e); + void handleSevereException(SevereException e); + void handleSevereException(String message, SevereException e); +} diff --git a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java old mode 100644 new mode 100755 index c1951e23..d2b5af66 --- a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java @@ -1,78 +1,78 @@ -package com.stream_pi.client.window.dashboard; - -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPane; - -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.control.Button; -import javafx.scene.layout.HBox; -import javafx.scene.layout.VBox; -import org.kordamp.ikonli.javafx.FontIcon; - -public class DashboardBase extends VBox -{ - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - private ActionGridPane actionGridPane; - private Button settingsButton; - - public DashboardBase(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) - { - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - - actionGridPane = new ActionGridPane(exceptionAndAlertHandler, clientListener); - - FontIcon fontIcon = new FontIcon("fas-cog"); - fontIcon.getStyleClass().addAll("dashboard_settings_button_icon"); - - settingsButton = new Button(); - settingsButton.getStyleClass().addAll("dashboard_settings_button"); - settingsButton.setGraphic(fontIcon); - - HBox hBox = new HBox(settingsButton); - hBox.getStyleClass().add("dashboard_settings_button_parent"); - hBox.setPadding(new Insets(0,5,5,0)); - hBox.setAlignment(Pos.CENTER_RIGHT); - - - getChildren().addAll(actionGridPane,hBox); - - getStyleClass().add("dashboard"); - } - - public void renderProfile(ClientProfile clientProfile, boolean freshRender) - { - renderProfile(clientProfile, "root", freshRender); - } - - public void renderProfile(ClientProfile clientProfile, String currentParent, boolean freshRender) - { - actionGridPane.setClientProfile(clientProfile); - actionGridPane.setCurrentParent(currentParent); - actionGridPane.setFreshRender(freshRender); - - actionGridPane.renderGrid(); - actionGridPane.renderActions(); - } - - public void addBlankActionBox(int col, int row) - { - actionGridPane.addBlankActionBox(col, row); - } - - public void clearActionBox(int col, int row) - { - actionGridPane.clearActionBox(col, row); - } - - public ActionGridPane getActionGridPane() { - return actionGridPane; - } - - public Button getSettingsButton() { - return settingsButton; - } -} +package com.stream_pi.client.window.dashboard; + +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPane; + +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import org.kordamp.ikonli.javafx.FontIcon; + +public class DashboardBase extends VBox +{ + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + private ActionGridPane actionGridPane; + private Button settingsButton; + + public DashboardBase(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) + { + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + + actionGridPane = new ActionGridPane(exceptionAndAlertHandler, clientListener); + + FontIcon fontIcon = new FontIcon("fas-cog"); + fontIcon.getStyleClass().addAll("dashboard_settings_button_icon"); + + settingsButton = new Button(); + settingsButton.getStyleClass().addAll("dashboard_settings_button"); + settingsButton.setGraphic(fontIcon); + + HBox hBox = new HBox(settingsButton); + hBox.getStyleClass().add("dashboard_settings_button_parent"); + hBox.setPadding(new Insets(0,5,5,0)); + hBox.setAlignment(Pos.CENTER_RIGHT); + + + getChildren().addAll(actionGridPane,hBox); + + getStyleClass().add("dashboard"); + } + + public void renderProfile(ClientProfile clientProfile, boolean freshRender) + { + renderProfile(clientProfile, "root", freshRender); + } + + public void renderProfile(ClientProfile clientProfile, String currentParent, boolean freshRender) + { + actionGridPane.setClientProfile(clientProfile); + actionGridPane.setCurrentParent(currentParent); + actionGridPane.setFreshRender(freshRender); + + actionGridPane.renderGrid(); + actionGridPane.renderActions(); + } + + public void addBlankActionBox(int col, int row) + { + actionGridPane.addBlankActionBox(col, row); + } + + public void clearActionBox(int col, int row) + { + actionGridPane.clearActionBox(col, row); + } + + public ActionGridPane getActionGridPane() { + return actionGridPane; + } + + public Button getSettingsButton() { + return settingsButton; + } +} diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java old mode 100644 new mode 100755 index e7337e46..3659682e --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java @@ -1,520 +1,521 @@ -package com.stream_pi.client.window.dashboard.actiongridpane; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; -import com.stream_pi.action_api.action.DisplayTextAlignment; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import javafx.animation.Interpolator; -import javafx.animation.KeyFrame; -import javafx.animation.KeyValue; -import javafx.animation.Timeline; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.Label; -import javafx.scene.image.Image; -import javafx.scene.layout.Background; -import javafx.scene.layout.BackgroundImage; -import javafx.scene.layout.BackgroundPosition; -import javafx.scene.layout.BackgroundRepeat; -import javafx.scene.layout.BackgroundSize; -import javafx.scene.layout.StackPane; -import javafx.scene.text.Font; -import javafx.scene.text.TextAlignment; -import javafx.util.Duration; -import org.kordamp.ikonli.javafx.FontIcon; - -import animatefx.animation.*; - -import java.io.ByteArrayInputStream; -import java.util.logging.Logger; - -public class ActionBox extends StackPane -{ - - private Label displayTextLabel; - - private int row; - private int col; - - public int getRow() { - return row; - } - - public int getCol() { - return col; - } - - private Logger logger; - - - - public void clear() - { - setStyle(null); - setAction(null); - setCurrentToggleStatus(false); - getStyleClass().clear(); - setBackground(Background.EMPTY); - removeFontIcon(); - getChildren().clear(); - baseInit(); - } - - private FontIcon statusIcon; - - public void baseInit() - { - displayTextLabel = new Label(); - displayTextLabel.setWrapText(true); - displayTextLabel.setTextAlignment(TextAlignment.CENTER); - displayTextLabel.getStyleClass().add("action_box_display_text_label"); - - displayTextLabel.prefHeightProperty().bind(heightProperty()); - displayTextLabel.prefWidthProperty().bind(widthProperty()); - - - statusIcon = new FontIcon("fas-exclamation-triangle"); - statusIcon.getStyleClass().add("action_box_error_icon"); - statusIcon.setOpacity(0); - statusIcon.setCache(true); - statusIcon.setCacheHint(CacheHint.SPEED); - statusIcon.setIconSize(size - 30); - - - getChildren().addAll(statusIcon, displayTextLabel); - - setMinSize(size, size); - setMaxSize(size, size); - - getStyleClass().clear(); - getStyleClass().add("action_box"); - getStyleClass().add("action_box_"+row+"_"+col); - - setIcon(null); - - setOnMouseClicked(touchEvent -> actionClicked()); - - setOnMousePressed(TouchEvent -> { - if(action != null) - { - getStyleClass().add("action_box_onclick"); - } - }); - setOnMouseReleased(TouchEvent ->{ - if(action != null) - { - getStyleClass().remove("action_box_onclick"); - } - }); - - statusIconAnimation = new Timeline( - new KeyFrame( - Duration.millis(0.0D), - new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)), - new KeyFrame( - Duration.millis(100.0D), - new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)), - new KeyFrame( - Duration.millis(600.0D), - new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)), - new KeyFrame( - Duration.millis(700.0D), - new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT)) - ); - - statusIconAnimation.setOnFinished(event -> { - statusIcon.toBack(); - }); - - setCache(true); - setCacheHint(CacheHint.QUALITY); - } - - public void actionClicked() - { - if(action!=null) - { - if(action.getActionType() == ActionType.FOLDER) - { - getActionGridPaneListener().renderFolder(action.getID()); - } - else - { - if(!getActionGridPaneListener().isConnected()) - { - try - { - if(Config.getInstance().isTryConnectingWhenActionClicked()) - { - clientListener.setupClientConnection(this::actionClicked); - } - else - { - exceptionAndAlertHandler.handleMinorException(new MinorException("Not Connected", "Not Connected to any Server")); - } - return; - } - catch (SevereException e) - { - exceptionAndAlertHandler.handleSevereException(e); - } - } - - if(action.getActionType() == ActionType.COMBINE || action.getActionType() == ActionType.NORMAL) - { - getActionGridPaneListener().normalOrCombineActionClicked(action.getID()); - } - else if(action.getActionType() == ActionType.TOGGLE) - { - toggle(); - getActionGridPaneListener().toggleActionClicked(action.getID(), getCurrentToggleStatus()); - } - } - try { - playActionAnimation(); - } catch (SevereException e) { - Logger.getLogger("").warning(e.getMessage()); - } - } - } - - private Timeline statusIconAnimation; - - public Timeline getStatusIconAnimation() { - return statusIconAnimation; - } - - public ActionGridPaneListener getActionGridPaneListener() { - return actionGridPaneListener; - } - - private int size; - private ActionGridPaneListener actionGridPaneListener; - private ClientListener clientListener; - - public ActionBox(int size, ExceptionAndAlertHandler exceptionAndAlertHandler, - ClientListener clientListener, ActionGridPaneListener actionGridPaneListener, int row, int col) - { - this.actionGridPaneListener = actionGridPaneListener; - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.size = size; - this.row = row; - this.col = col; - this.clientListener = clientListener; - this.logger = Logger.getLogger(""); - - baseInit(); - } - - public Logger getLogger() - { - return logger; - } - - public void setIcon(byte[] iconByteArray) - { - removeFontIcon(); - - if(iconByteArray == null) - { - getStyleClass().remove("action_box_icon_present"); - getStyleClass().add("action_box_icon_not_present"); - setBackground(null); - } - else - { - getStyleClass().add("action_box_icon_present"); - getStyleClass().remove("action_box_icon_not_present"); - - - setBackground( - new Background( - new BackgroundImage(new Image( - new ByteArrayInputStream(iconByteArray), size, size, false, true - ), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, - - new BackgroundSize(100, 100, true, true, true, false)) - ) - ); - } - } - - private Action action = null; - - public Action getAction() { - return action; - } - - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - private String parent; - - public String getStreamPiParent() { - return parent; - } - - public void setStreamPiParent(String parent) { - this.parent = parent; - } - - public void setAction(Action action) - { - this.action = action; - } - - public void playActionAnimation() throws SevereException { - Config config = Config.getInstance(); - switch (config.getCurrentAnimationName()) { - case "None": - return; - case "Flip": - (new Flip(getChildren().get(1))).play(); - case "Bounce": - (new Bounce(getChildren().get(1))).play(); - case "Jack In The Box": - (new JackInTheBox(getChildren().get(1))).play(); - case "Swing": - (new Swing(getChildren().get(1))).play(); - case "Jello": - (new Jello(getChildren().get(1))).play(); - case "Pulse": - (new Pulse(getChildren().get(1))).play(); - case "RubberBand": - (new RubberBand(getChildren().get(1))).play(); - case "Shake": - (new Shake(getChildren().get(1))).play(); - case "Tada": - (new Tada(getChildren().get(1))).play(); - case "Wobble": - (new Wobble(getChildren().get(1))).play(); - } - Logger.getLogger("").warning("Invalid Option/n Please contact quimodotcom to solve this error!"); - } - - public void init() - { - setBackground(null); - setStyle(null); - displayTextLabel.setStyle(null); - - - if(getAction().isShowDisplayText()) - { - setDisplayTextAlignment(action.getDisplayTextAlignment()); - setDisplayTextFontColourAndSize(action.getDisplayTextFontColourHex()); - setDisplayTextLabel(getAction().getDisplayText()); - } - else - setDisplayTextLabel(""); - - setBackgroundColour(action.getBgColourHex()); - - try - { - if(action.getActionType() == ActionType.TOGGLE) - { - toggle(getCurrentToggleStatus()); - } - else - { - if(action.isHasIcon()) - { - if(!action.getCurrentIconState().isBlank()) - { - setIcon(action.getCurrentIcon()); - } - } - else - { - setIcon(null); - } - } - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - - public void setCurrentToggleStatus(boolean currentToggleStatus) - { - if(getAction() != null) - getAction().setCurrentToggleStatus(currentToggleStatus); - } - - public boolean getCurrentToggleStatus() - { - if(getAction() == null) - return false; - - return getAction().getCurrentToggleStatus(); - } - - public void toggle() - { - setCurrentToggleStatus(!getCurrentToggleStatus()); - - toggle(getCurrentToggleStatus()); - } - - public void toggle(boolean isON) - { - String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__"); - - boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true"); - boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true"); - - if(isON) // ON - { - if(action.isHasIcon()) - { - boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on"); - - if(isToggleOnPresent) - { - if(isToggleOnHidden) - { - setDefaultToggleIcon(true); - } - else - { - setIcon(action.getIcons().get("toggle_on")); - } - } - else - { - setDefaultToggleIcon(true); - } - } - else - { - setDefaultToggleIcon(true); - } - } - else // OFF - { - if(action.isHasIcon()) - { - boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off"); - - if(isToggleOffPresent) - { - if(isToggleOffHidden) - { - setDefaultToggleIcon(false); - } - else - { - setIcon(action.getIcons().get("toggle_off")); - } - } - else - { - setDefaultToggleIcon(false); - } - } - else - { - setDefaultToggleIcon(false); - } - } - } - - - public void setDefaultToggleIcon(boolean isToggleOn) - { - String styleClass; - - if(isToggleOn) - { - styleClass = "action_box_toggle_on"; - } - else - { - styleClass = "action_box_toggle_off"; - } - - - setBackground(null); - - - if(fontIcon!=null) - { - fontIcon.getStyleClass().removeIf(s -> s.equals("action_box_toggle_off") || s.equals("action_box_toggle_on")); - } - else - { - fontIcon = new FontIcon(); - fontIcon.setIconSize((int) (size * 0.8)); - getChildren().add(fontIcon); - } - - fontIcon.getStyleClass().add(styleClass); - - fontIcon.toBack(); - } - - public void removeFontIcon() - { - if(fontIcon!=null) - { - getChildren().remove(fontIcon); - fontIcon = null; - } - } - - FontIcon fontIcon = null; - - public void animateStatus() - { - statusIcon.toFront(); - statusIconAnimation.play(); - } - - public void setDisplayTextLabel(String text) - { - displayTextLabel.setText(text); - } - - public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment) - { - if(displayTextAlignment == DisplayTextAlignment.CENTER) - displayTextLabel.setAlignment(Pos.CENTER); - else if (displayTextAlignment == DisplayTextAlignment.BOTTOM) - displayTextLabel.setAlignment(Pos.BOTTOM_CENTER); - else if (displayTextAlignment == DisplayTextAlignment.TOP) - displayTextLabel.setAlignment(Pos.TOP_CENTER); - } - - public void setDisplayTextFontColourAndSize(String colour) - { - String totalStyle = ""; - if(!colour.isEmpty()) - { - totalStyle+="-fx-text-fill : "+colour+";"; - } - - if(getAction().getNameFontSize() > -1) - { - totalStyle+="-fx-font-size: "+getAction().getNameFontSize()+";"; - } - - if(!totalStyle.isBlank()) - { - displayTextLabel.setStyle(totalStyle); - } - } - - - public void setBackgroundColour(String colour) - { - if(!colour.isEmpty()) - setStyle("-fx-background-color : "+colour); - } -} +package com.stream_pi.client.window.dashboard.actiongridpane; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; +import com.stream_pi.action_api.action.DisplayTextAlignment; +import com.stream_pi.client.animations.*; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.Label; +import javafx.scene.image.Image; +import javafx.scene.layout.Background; +import javafx.scene.layout.BackgroundImage; +import javafx.scene.layout.BackgroundPosition; +import javafx.scene.layout.BackgroundRepeat; +import javafx.scene.layout.BackgroundSize; +import javafx.scene.layout.StackPane; +import javafx.scene.text.Font; +import javafx.scene.text.TextAlignment; +import javafx.util.Duration; +import org.kordamp.ikonli.javafx.FontIcon; + +import java.io.ByteArrayInputStream; +import java.util.logging.Logger; + +public class ActionBox extends StackPane +{ + + private Label displayTextLabel; + + private int row; + private int col; + + public int getRow() { + return row; + } + + public int getCol() { + return col; + } + + private Logger logger; + + + + public void clear() + { + setStyle(null); + setAction(null); + setCurrentToggleStatus(false); + getStyleClass().clear(); + setBackground(Background.EMPTY); + removeFontIcon(); + getChildren().clear(); + baseInit(); + } + + private FontIcon statusIcon; + + public void baseInit() + { + displayTextLabel = new Label(); + displayTextLabel.setWrapText(true); + displayTextLabel.setTextAlignment(TextAlignment.CENTER); + displayTextLabel.getStyleClass().add("action_box_display_text_label"); + + displayTextLabel.prefHeightProperty().bind(heightProperty()); + displayTextLabel.prefWidthProperty().bind(widthProperty()); + + + statusIcon = new FontIcon("fas-exclamation-triangle"); + statusIcon.getStyleClass().add("action_box_error_icon"); + statusIcon.setOpacity(0); + statusIcon.setCache(true); + statusIcon.setCacheHint(CacheHint.SPEED); + statusIcon.setIconSize(size - 30); + + + getChildren().addAll(statusIcon, displayTextLabel); + + setMinSize(size, size); + setMaxSize(size, size); + + getStyleClass().clear(); + getStyleClass().add("action_box"); + getStyleClass().add("action_box_"+row+"_"+col); + + setIcon(null); + + setOnMouseClicked(touchEvent -> actionClicked()); + + setOnMousePressed(TouchEvent -> { + if(action != null) + { + getStyleClass().add("action_box_onclick"); + } + }); + setOnMouseReleased(TouchEvent ->{ + if(action != null) + { + getStyleClass().remove("action_box_onclick"); + } + }); + + statusIconAnimation = new Timeline( + new KeyFrame( + Duration.millis(0.0D), + new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_IN)), + new KeyFrame( + Duration.millis(100.0D), + new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_IN)), + new KeyFrame( + Duration.millis(600.0D), + new KeyValue(statusIcon.opacityProperty(), 1.0D, Interpolator.EASE_OUT)), + new KeyFrame( + Duration.millis(700.0D), + new KeyValue(statusIcon.opacityProperty(), 0.0D, Interpolator.EASE_OUT)) + ); + + statusIconAnimation.setOnFinished(event -> { + statusIcon.toBack(); + }); + + setCache(true); + setCacheHint(CacheHint.QUALITY); + } + + public void actionClicked() + { + if(action!=null) + { + if(action.getActionType() == ActionType.FOLDER) + { + getActionGridPaneListener().renderFolder(action.getID()); + } + else + { + if(!getActionGridPaneListener().isConnected()) + { + try + { + if(Config.getInstance().isTryConnectingWhenActionClicked()) + { + clientListener.setupClientConnection(this::actionClicked); + } + else + { + exceptionAndAlertHandler.handleMinorException(new MinorException("Not Connected", "Not Connected to any Server")); + } + return; + } + catch (SevereException e) + { + exceptionAndAlertHandler.handleSevereException(e); + } + } + + if(action.getActionType() == ActionType.COMBINE || action.getActionType() == ActionType.NORMAL) + { + getActionGridPaneListener().normalOrCombineActionClicked(action.getID()); + } + else if(action.getActionType() == ActionType.TOGGLE) + { + toggle(); + getActionGridPaneListener().toggleActionClicked(action.getID(), getCurrentToggleStatus()); + } + } + try { + playActionAnimation(); + } catch (SevereException e) { + Logger.getLogger("").warning(e.getMessage()); + } + } + } + + private Timeline statusIconAnimation; + + public Timeline getStatusIconAnimation() { + return statusIconAnimation; + } + + public ActionGridPaneListener getActionGridPaneListener() { + return actionGridPaneListener; + } + + private int size; + private ActionGridPaneListener actionGridPaneListener; + private ClientListener clientListener; + + public ActionBox(int size, ExceptionAndAlertHandler exceptionAndAlertHandler, + ClientListener clientListener, ActionGridPaneListener actionGridPaneListener, int row, int col) + { + this.actionGridPaneListener = actionGridPaneListener; + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.size = size; + this.row = row; + this.col = col; + this.clientListener = clientListener; + this.logger = Logger.getLogger(""); + + baseInit(); + } + + public Logger getLogger() + { + return logger; + } + + public void setIcon(byte[] iconByteArray) + { + removeFontIcon(); + + if(iconByteArray == null) + { + getStyleClass().remove("action_box_icon_present"); + getStyleClass().add("action_box_icon_not_present"); + setBackground(null); + } + else + { + getStyleClass().add("action_box_icon_present"); + getStyleClass().remove("action_box_icon_not_present"); + + + setBackground( + new Background( + new BackgroundImage(new Image( + new ByteArrayInputStream(iconByteArray), size, size, false, true + ), BackgroundRepeat.NO_REPEAT, BackgroundRepeat.NO_REPEAT, BackgroundPosition.CENTER, + + new BackgroundSize(100, 100, true, true, true, false)) + ) + ); + } + } + + private Action action = null; + + public Action getAction() { + return action; + } + + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + private String parent; + + public String getStreamPiParent() { + return parent; + } + + public void setStreamPiParent(String parent) { + this.parent = parent; + } + + public void setAction(Action action) + { + this.action = action; + } + + public void playActionAnimation() throws SevereException { + Config config = Config.getInstance(); + switch (config.getCurrentAnimationName()) { + case "None": + return; + case "Flip": + new Flip(getChildren().get(1)).play(); + case "Flash": + new Flash(getChildren().get(1)).play(); + case "Bounce": + new Bounce(getChildren().get(1)).play(); + case "Jack In The Box": + new JackInTheBox(getChildren().get(1)).play(); + case "Swing": + new Swing(getChildren().get(1)).play(); + case "Jello": + new Jello(getChildren().get(1)).play(); + case "Pulse": + new Pulse(getChildren().get(1)).play(); + case "RubberBand": + new RubberBand(getChildren().get(1)).play(); + case "Shake": + new Shake(getChildren().get(1)).play(); + case "Tada": + new Tada(getChildren().get(1)).play(); + case "Wobble": + new Wobble(getChildren().get(1)).play(); + } + Logger.getLogger("").warning("Invalid Option/n Please contact quimodotcom to solve this error!"); + } + + public void init() + { + setBackground(null); + setStyle(null); + displayTextLabel.setStyle(null); + + + if(getAction().isShowDisplayText()) + { + setDisplayTextAlignment(action.getDisplayTextAlignment()); + setDisplayTextFontColourAndSize(action.getDisplayTextFontColourHex()); + setDisplayTextLabel(getAction().getDisplayText()); + } + else + setDisplayTextLabel(""); + + setBackgroundColour(action.getBgColourHex()); + + try + { + if(action.getActionType() == ActionType.TOGGLE) + { + toggle(getCurrentToggleStatus()); + } + else + { + if(action.isHasIcon()) + { + if(!action.getCurrentIconState().isBlank()) + { + setIcon(action.getCurrentIcon()); + } + } + else + { + setIcon(null); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + + public void setCurrentToggleStatus(boolean currentToggleStatus) + { + if(getAction() != null) + getAction().setCurrentToggleStatus(currentToggleStatus); + } + + public boolean getCurrentToggleStatus() + { + if(getAction() == null) + return false; + + return getAction().getCurrentToggleStatus(); + } + + public void toggle() + { + setCurrentToggleStatus(!getCurrentToggleStatus()); + + toggle(getCurrentToggleStatus()); + } + + public void toggle(boolean isON) + { + String[] toggleStatesHiddenStatus = action.getCurrentIconState().split("__"); + + boolean isToggleOffHidden = toggleStatesHiddenStatus[0].equals("true"); + boolean isToggleOnHidden = toggleStatesHiddenStatus[1].equals("true"); + + if(isON) // ON + { + if(action.isHasIcon()) + { + boolean isToggleOnPresent = action.getIcons().containsKey("toggle_on"); + + if(isToggleOnPresent) + { + if(isToggleOnHidden) + { + setDefaultToggleIcon(true); + } + else + { + setIcon(action.getIcons().get("toggle_on")); + } + } + else + { + setDefaultToggleIcon(true); + } + } + else + { + setDefaultToggleIcon(true); + } + } + else // OFF + { + if(action.isHasIcon()) + { + boolean isToggleOffPresent = action.getIcons().containsKey("toggle_off"); + + if(isToggleOffPresent) + { + if(isToggleOffHidden) + { + setDefaultToggleIcon(false); + } + else + { + setIcon(action.getIcons().get("toggle_off")); + } + } + else + { + setDefaultToggleIcon(false); + } + } + else + { + setDefaultToggleIcon(false); + } + } + } + + + public void setDefaultToggleIcon(boolean isToggleOn) + { + String styleClass; + + if(isToggleOn) + { + styleClass = "action_box_toggle_on"; + } + else + { + styleClass = "action_box_toggle_off"; + } + + + setBackground(null); + + + if(fontIcon!=null) + { + fontIcon.getStyleClass().removeIf(s -> s.equals("action_box_toggle_off") || s.equals("action_box_toggle_on")); + } + else + { + fontIcon = new FontIcon(); + fontIcon.setIconSize((int) (size * 0.8)); + getChildren().add(fontIcon); + } + + fontIcon.getStyleClass().add(styleClass); + + fontIcon.toBack(); + } + + public void removeFontIcon() + { + if(fontIcon!=null) + { + getChildren().remove(fontIcon); + fontIcon = null; + } + } + + FontIcon fontIcon = null; + + public void animateStatus() + { + statusIcon.toFront(); + statusIconAnimation.play(); + } + + public void setDisplayTextLabel(String text) + { + displayTextLabel.setText(text); + } + + public void setDisplayTextAlignment(DisplayTextAlignment displayTextAlignment) + { + if(displayTextAlignment == DisplayTextAlignment.CENTER) + displayTextLabel.setAlignment(Pos.CENTER); + else if (displayTextAlignment == DisplayTextAlignment.BOTTOM) + displayTextLabel.setAlignment(Pos.BOTTOM_CENTER); + else if (displayTextAlignment == DisplayTextAlignment.TOP) + displayTextLabel.setAlignment(Pos.TOP_CENTER); + } + + public void setDisplayTextFontColourAndSize(String colour) + { + String totalStyle = ""; + if(!colour.isEmpty()) + { + totalStyle+="-fx-text-fill : "+colour+";"; + } + + if(getAction().getNameFontSize() > -1) + { + totalStyle+="-fx-font-size: "+getAction().getNameFontSize()+";"; + } + + if(!totalStyle.isBlank()) + { + displayTextLabel.setStyle(totalStyle); + } + } + + + public void setBackgroundColour(String colour) + { + if(!colour.isEmpty()) + setStyle("-fx-background-color : "+colour); + } +} diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java old mode 100644 new mode 100755 index 1eafe151..e1034d07 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPane.java @@ -1,459 +1,459 @@ -package com.stream_pi.client.window.dashboard.actiongridpane; - -import java.util.logging.Logger; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; -import com.stream_pi.action_api.action.Location; -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.window.ExceptionAndAlertHandler; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import javafx.concurrent.Task; -import javafx.geometry.Insets; -import javafx.geometry.Orientation; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.Node; -import javafx.scene.control.ScrollPane; -import javafx.scene.layout.GridPane; -import javafx.scene.layout.Priority; -import javafx.scene.layout.StackPane; -import javafx.scene.layout.VBox; -import org.kordamp.ikonli.javafx.FontIcon; - -public class ActionGridPane extends ScrollPane implements ActionGridPaneListener -{ - - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - private ClientListener clientListener; - - private ActionBox[][] actionBoxes; - - private GridPane actionsGridPane; - - public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) - { - this.clientListener = clientListener; - - logger = Logger.getLogger(ActionGridPane.class.getName()); - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - - getStyleClass().add("action_grid_pane_parent"); - - actionsGridPane = new GridPane(); - actionsGridPane.setPadding(new Insets(5.0)); - actionsGridPane.getStyleClass().add("action_grid_pane"); - actionsGridPane.prefWidthProperty().bind(widthProperty().subtract(20)); - actionsGridPane.prefHeightProperty().bind(heightProperty().subtract(20)); - - setContent(actionsGridPane); - - actionsGridPane.setAlignment(Pos.CENTER); - - - VBox.setVgrow(this, Priority.ALWAYS); - - setCache(true); - setCacheHint(CacheHint.SPEED); - } - - private String currentParent; - - public void setCurrentParent(String currentParent) { - this.currentParent = currentParent; - } - - public ClientProfile getClientProfile() { - return clientProfile; - } - - private int rows, cols; - - private ClientProfile clientProfile; - - public void setClientProfile(ClientProfile clientProfile) - { - this.clientProfile = clientProfile; - - setCurrentParent("root"); - setRows(clientProfile.getRows()); - setCols(clientProfile.getCols()); - } - - public void actionFailed(String profileID, String actionID) - { - if(getClientProfile().getID().equals(profileID)) - { - Action action = getClientProfile().getActionFromID(actionID); - if(action != null) - { - if(currentParent.equals(action.getParent())) - { - failShow(action); - } - else - { - if(action.getLocation().getCol() == -1) - { - failShow(getClientProfile().getActionFromID(action.getParent())); - } - } - } - } - } - - public void failShow(Action action) - { - actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus(); - } - - - public String getCurrentParent() { - return currentParent; - } - - public StackPane getFolderBackButton() - { - StackPane stackPane = new StackPane(); - stackPane.getStyleClass().add("action_box"); - stackPane.getStyleClass().add("action_box_valid"); - - stackPane.setPrefSize( - getClientProfile().getActionSize(), - getClientProfile().getActionSize() - ); - - FontIcon fontIcon = new FontIcon("fas-chevron-left"); - fontIcon.getStyleClass().add("folder_action_back_button_icon"); - fontIcon.setIconSize(getClientProfile().getActionSize() - 30); - - stackPane.setAlignment(Pos.CENTER); - stackPane.getChildren().add(fontIcon); - - stackPane.setOnMouseClicked(e->returnToPreviousParent()); - - return stackPane; - } - - private boolean isFreshRender = true; - private Node folderBackButton = null; - public void renderGrid() - { - actionsGridPane.setHgap(getClientProfile().getActionGap()); - actionsGridPane.setVgap(getClientProfile().getActionGap()); - - if(isFreshRender) - { - clear(); - actionBoxes = new ActionBox[cols][rows]; - } - - boolean isFolder = false; - - if(getCurrentParent().equals("root")) - { - if(folderBackButton != null) - { - actionsGridPane.getChildren().remove(folderBackButton); - folderBackButton = null; - - actionBoxes[0][0] = addBlankActionBox(0,0); - } - } - else - { - isFolder = true; - - if(folderBackButton != null) - { - actionsGridPane.getChildren().remove(folderBackButton); - folderBackButton = null; - } - else - { - actionsGridPane.getChildren().remove(actionBoxes[0][0]); - } - - folderBackButton = getFolderBackButton(); - actionsGridPane.add(folderBackButton, 0,0); - } - - for(int row = 0; row= rows || action.getLocation().getCol() >= cols) - { - throw new MinorException("Action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" + - " Consider increasing rows/cols from client settings and relocating/deleting it."); - } - - - Location location = action.getLocation(); - - if( getClientProfile().getCols() < location.getCol() || getClientProfile().getRows() < location.getRow()) - return; - - ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()]; - - if(actionBox.getAction()!=null) - { - if(!actionBox.getAction().getID().equals(action.getID())) - { - actionBox.clear(); - } - } - else - { - actionBox.clear(); - } - - - boolean oldToggleStatus = action.getCurrentToggleStatus(); - - - actionBox.setAction(action); - - - actionBox.setCurrentToggleStatus(oldToggleStatus); - - - actionBox.setStreamPiParent(currentParent); - actionBox.init(); - - /*ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), action, exceptionAndAlertHandler, this, location.getRow(), location.getCol()); - - actionBox.setStreamPiParent(currentParent); - - clearActionBox(location.getCol(), location.getRow()); - - System.out.println(location.getCol()+","+location.getRow()); - add(actionBox, location.getRow(), location.getCol()); - - actionBoxes[location.getCol()][location.getRow()] = actionBox;*/ - } - - public void setRows(int rows) - { - this.rows = rows; - } - - public void setCols(int cols) - { - this.cols = cols; - } - - public int getRows() - { - return rows; - } - - public int getCols() - { - return cols; - } - - private String previousParent; - - public void setPreviousParent(String previousParent) { - this.previousParent = previousParent; - } - - public String getPreviousParent() { - return previousParent; - } - - @Override - public void renderFolder(String actionID) { - setCurrentParent(clientProfile.getActionFromID(actionID).getID()); - setPreviousParent(clientProfile.getActionFromID(actionID).getParent()); - renderGrid(); - renderActions(); - } - - @Override - public void normalOrCombineActionClicked(String ID) - { - clientListener.onActionClicked(getClientProfile().getID(), ID, false); - } - - @Override - public void toggleActionClicked(String ID, boolean toggleState) - { - clientListener.onActionClicked(getClientProfile().getID(), ID, toggleState); - } - - @Override - public ActionBox getActionBoxByLocation(Location location) - { - return getActionBox(location.getCol(), location.getRow()); - } - - - @Override - public boolean isConnected() - { - return clientListener.isConnected(); - } - - - public void returnToPreviousParent() - { - setCurrentParent(getPreviousParent()); - - if(!getPreviousParent().equals("root")) - { - System.out.println("parent : "+getPreviousParent()); - setPreviousParent(getClientProfile().getActionFromID( - getPreviousParent() - ).getParent()); - } - - renderGrid(); - renderActions(); - } -} +package com.stream_pi.client.window.dashboard.actiongridpane; + +import java.util.logging.Logger; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; +import com.stream_pi.action_api.action.Location; +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.window.ExceptionAndAlertHandler; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import javafx.concurrent.Task; +import javafx.geometry.Insets; +import javafx.geometry.Orientation; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.Node; +import javafx.scene.control.ScrollPane; +import javafx.scene.layout.GridPane; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import org.kordamp.ikonli.javafx.FontIcon; + +public class ActionGridPane extends ScrollPane implements ActionGridPaneListener +{ + + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + private ClientListener clientListener; + + private ActionBox[][] actionBoxes; + + private GridPane actionsGridPane; + + public ActionGridPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) + { + this.clientListener = clientListener; + + logger = Logger.getLogger(ActionGridPane.class.getName()); + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + + getStyleClass().add("action_grid_pane_parent"); + + actionsGridPane = new GridPane(); + actionsGridPane.setPadding(new Insets(5.0)); + actionsGridPane.getStyleClass().add("action_grid_pane"); + actionsGridPane.prefWidthProperty().bind(widthProperty().subtract(20)); + actionsGridPane.prefHeightProperty().bind(heightProperty().subtract(20)); + + setContent(actionsGridPane); + + actionsGridPane.setAlignment(Pos.CENTER); + + + VBox.setVgrow(this, Priority.ALWAYS); + + setCache(true); + setCacheHint(CacheHint.SPEED); + } + + private String currentParent; + + public void setCurrentParent(String currentParent) { + this.currentParent = currentParent; + } + + public ClientProfile getClientProfile() { + return clientProfile; + } + + private int rows, cols; + + private ClientProfile clientProfile; + + public void setClientProfile(ClientProfile clientProfile) + { + this.clientProfile = clientProfile; + + setCurrentParent("root"); + setRows(clientProfile.getRows()); + setCols(clientProfile.getCols()); + } + + public void actionFailed(String profileID, String actionID) + { + if(getClientProfile().getID().equals(profileID)) + { + Action action = getClientProfile().getActionFromID(actionID); + if(action != null) + { + if(currentParent.equals(action.getParent())) + { + failShow(action); + } + else + { + if(action.getLocation().getCol() == -1) + { + failShow(getClientProfile().getActionFromID(action.getParent())); + } + } + } + } + } + + public void failShow(Action action) + { + actionBoxes[action.getLocation().getCol()][action.getLocation().getRow()].animateStatus(); + } + + + public String getCurrentParent() { + return currentParent; + } + + public StackPane getFolderBackButton() + { + StackPane stackPane = new StackPane(); + stackPane.getStyleClass().add("action_box"); + stackPane.getStyleClass().add("action_box_valid"); + + stackPane.setPrefSize( + getClientProfile().getActionSize(), + getClientProfile().getActionSize() + ); + + FontIcon fontIcon = new FontIcon("fas-chevron-left"); + fontIcon.getStyleClass().add("folder_action_back_button_icon"); + fontIcon.setIconSize(getClientProfile().getActionSize() - 30); + + stackPane.setAlignment(Pos.CENTER); + stackPane.getChildren().add(fontIcon); + + stackPane.setOnMouseClicked(e->returnToPreviousParent()); + + return stackPane; + } + + private boolean isFreshRender = true; + private Node folderBackButton = null; + public void renderGrid() + { + actionsGridPane.setHgap(getClientProfile().getActionGap()); + actionsGridPane.setVgap(getClientProfile().getActionGap()); + + if(isFreshRender) + { + clear(); + actionBoxes = new ActionBox[cols][rows]; + } + + boolean isFolder = false; + + if(getCurrentParent().equals("root")) + { + if(folderBackButton != null) + { + actionsGridPane.getChildren().remove(folderBackButton); + folderBackButton = null; + + actionBoxes[0][0] = addBlankActionBox(0,0); + } + } + else + { + isFolder = true; + + if(folderBackButton != null) + { + actionsGridPane.getChildren().remove(folderBackButton); + folderBackButton = null; + } + else + { + actionsGridPane.getChildren().remove(actionBoxes[0][0]); + } + + folderBackButton = getFolderBackButton(); + actionsGridPane.add(folderBackButton, 0,0); + } + + for(int row = 0; row= rows || action.getLocation().getCol() >= cols) + { + throw new MinorException("Action "+action.getDisplayText()+" ("+action.getID()+") falls outside bounds.\n" + + " Consider increasing rows/cols from client settings and relocating/deleting it."); + } + + + Location location = action.getLocation(); + + if( getClientProfile().getCols() < location.getCol() || getClientProfile().getRows() < location.getRow()) + return; + + ActionBox actionBox = actionBoxes[location.getCol()][location.getRow()]; + + if(actionBox.getAction()!=null) + { + if(!actionBox.getAction().getID().equals(action.getID())) + { + actionBox.clear(); + } + } + else + { + actionBox.clear(); + } + + + boolean oldToggleStatus = action.getCurrentToggleStatus(); + + + actionBox.setAction(action); + + + actionBox.setCurrentToggleStatus(oldToggleStatus); + + + actionBox.setStreamPiParent(currentParent); + actionBox.init(); + + /*ActionBox actionBox = new ActionBox(getClientProfile().getActionSize(), action, exceptionAndAlertHandler, this, location.getRow(), location.getCol()); + + actionBox.setStreamPiParent(currentParent); + + clearActionBox(location.getCol(), location.getRow()); + + System.out.println(location.getCol()+","+location.getRow()); + add(actionBox, location.getRow(), location.getCol()); + + actionBoxes[location.getCol()][location.getRow()] = actionBox;*/ + } + + public void setRows(int rows) + { + this.rows = rows; + } + + public void setCols(int cols) + { + this.cols = cols; + } + + public int getRows() + { + return rows; + } + + public int getCols() + { + return cols; + } + + private String previousParent; + + public void setPreviousParent(String previousParent) { + this.previousParent = previousParent; + } + + public String getPreviousParent() { + return previousParent; + } + + @Override + public void renderFolder(String actionID) { + setCurrentParent(clientProfile.getActionFromID(actionID).getID()); + setPreviousParent(clientProfile.getActionFromID(actionID).getParent()); + renderGrid(); + renderActions(); + } + + @Override + public void normalOrCombineActionClicked(String ID) + { + clientListener.onActionClicked(getClientProfile().getID(), ID, false); + } + + @Override + public void toggleActionClicked(String ID, boolean toggleState) + { + clientListener.onActionClicked(getClientProfile().getID(), ID, toggleState); + } + + @Override + public ActionBox getActionBoxByLocation(Location location) + { + return getActionBox(location.getCol(), location.getRow()); + } + + + @Override + public boolean isConnected() + { + return clientListener.isConnected(); + } + + + public void returnToPreviousParent() + { + setCurrentParent(getPreviousParent()); + + if(!getPreviousParent().equals("root")) + { + System.out.println("parent : "+getPreviousParent()); + setPreviousParent(getClientProfile().getActionFromID( + getPreviousParent() + ).getParent()); + } + + renderGrid(); + renderActions(); + } +} diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java old mode 100644 new mode 100755 index a8290f4c..4023a4c1 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionGridPaneListener.java @@ -1,17 +1,17 @@ -package com.stream_pi.client.window.dashboard.actiongridpane; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.Location; -import com.stream_pi.action_api.otheractions.FolderAction; - -public interface ActionGridPaneListener -{ - void renderFolder(String ID); - - void normalOrCombineActionClicked(String ID); - void toggleActionClicked(String ID, boolean toggleState); - - ActionBox getActionBoxByLocation(Location location); - - boolean isConnected(); -} +package com.stream_pi.client.window.dashboard.actiongridpane; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.otheractions.FolderAction; + +public interface ActionGridPaneListener +{ + void renderFolder(String ID); + + void normalOrCombineActionClicked(String ID); + void toggleActionClicked(String ID, boolean toggleState); + + ActionBox getActionBoxByLocation(Location location); + + boolean isConnected(); +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java old mode 100644 new mode 100755 index 9060a0d7..edcd6108 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java @@ -1,174 +1,174 @@ -package com.stream_pi.client.window.firsttimeuse; - -import com.gluonhq.attach.orientation.OrientationService; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.util.alert.StreamPiAlert; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.uihelper.HBoxInputBox; - -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.geometry.Orientation; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.TextField; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; - -import javax.xml.transform.TransformerException; -import java.io.File; - -public class FinalConfigPane extends VBox -{ - private TextField clientNicknameTextField; - private TextField serverIPHostNameTextField; - private TextField serverPortTextField; - private Button nextButton; - - private ExceptionAndAlertHandler exceptionAndAlertHandler; - private ClientListener clientListener; - - public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener, - Button nextButton) - { - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.clientListener = clientListener; - this.nextButton = nextButton; - - getStyleClass().add("first_time_use_pane_final_config"); - - Label label = new Label("That's it. Now just a little bit and then you're set!"); - label.setWrapText(true); - VBox.setVgrow(label, Priority.ALWAYS); - label.getStyleClass().add("first_time_use_pane_final_config_label"); - - clientNicknameTextField = new TextField(); - serverIPHostNameTextField = new TextField(); - serverPortTextField = new TextField(); - - HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField, 150); - HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField, 150); - HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField, 150); - - getChildren().addAll(label, clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox); - - setSpacing(10.0); - - setVisible(false); - } - - public void makeChangesToNextButton() - { - nextButton.setText("Confirm"); - nextButton.setOnAction(actionEvent -> new Thread(new Task() { - @Override - protected Void call() - { - onConfirmButtonClicked(); - return null; - } - }).start()); - } - - private void onConfirmButtonClicked() - { - Platform.runLater(()->nextButton.setDisable(true)); - - StringBuilder errors = new StringBuilder(); - - if(clientNicknameTextField.getText().isBlank()) - { - errors.append("* Nick name cannot be blank.\n"); - } - - if(serverIPHostNameTextField.getText().isBlank()) - { - errors.append("* Server IP cannot be empty.\n"); - } - - int port = -1; - try - { - port = Integer.parseInt(serverPortTextField.getText()); - - if(port < 1024) - errors.append("* Server Port should be above 1024.\n"); - else if(port > 65535) - errors.append("* Server Port must be lesser than 65535\n"); - } - catch (NumberFormatException exception) - { - errors.append("* Server Port should be a number.\n"); - } - - if(errors.toString().isEmpty()) - { - try - { - Config.getInstance().setNickName(clientNicknameTextField.getText()); - Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText()); - Config.getInstance().setServerPort(port); - Config.getInstance().setFirstTimeUse(false); - - if(ClientInfo.getInstance().isPhone()) - { - Config.getInstance().setScreenMoverEnabled(true); - } - - Config.getInstance().save(); - - ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+ - Config.getInstance().getStartupProfileID()+".xml"), Config.getInstance().getIconsPath()); - - int pre = clientProfile.getActionSize()+(clientProfile.getActionGap()*4); - - - rowsToSet = (int) (clientListener.getStageHeight()/pre); - colsToSet = (int) (clientListener.getStageWidth()/pre); - - if(ClientInfo.getInstance().isPhone()) - { - OrientationService.create().ifPresent(orientationService -> { - if(orientationService.getOrientation().isPresent() && - orientationService.getOrientation().get().equals(Orientation.VERTICAL)) - { - int tmp = rowsToSet; - rowsToSet = colsToSet; - colsToSet = tmp; - } - }); - } - - clientProfile.setCols(colsToSet); - clientProfile.setRows(rowsToSet); - - clientProfile.saveProfileDetails(); - - Platform.runLater(()-> { - clientListener.init(); - clientListener.setupClientConnection(); - }); - } - catch(Exception e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(new SevereException(e.getMessage())); - } - } - else - { - Platform.runLater(()->nextButton.setDisable(false)); - new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors, StreamPiAlertType.ERROR).show(); - } - } - - private int rowsToSet,colsToSet; -} +package com.stream_pi.client.window.firsttimeuse; + +import com.gluonhq.attach.orientation.OrientationService; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.uihelper.HBoxInputBox; + +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.geometry.Orientation; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; + +import javax.xml.transform.TransformerException; +import java.io.File; + +public class FinalConfigPane extends VBox +{ + private TextField clientNicknameTextField; + private TextField serverIPHostNameTextField; + private TextField serverPortTextField; + private Button nextButton; + + private ExceptionAndAlertHandler exceptionAndAlertHandler; + private ClientListener clientListener; + + public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener, + Button nextButton) + { + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.clientListener = clientListener; + this.nextButton = nextButton; + + getStyleClass().add("first_time_use_pane_final_config"); + + Label label = new Label("That's it. Now just a little bit and then you're set!"); + label.setWrapText(true); + VBox.setVgrow(label, Priority.ALWAYS); + label.getStyleClass().add("first_time_use_pane_final_config_label"); + + clientNicknameTextField = new TextField(); + serverIPHostNameTextField = new TextField(); + serverPortTextField = new TextField(); + + HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField, 150); + HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField, 150); + HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField, 150); + + getChildren().addAll(label, clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox); + + setSpacing(10.0); + + setVisible(false); + } + + public void makeChangesToNextButton() + { + nextButton.setText("Confirm"); + nextButton.setOnAction(actionEvent -> new Thread(new Task() { + @Override + protected Void call() + { + onConfirmButtonClicked(); + return null; + } + }).start()); + } + + private void onConfirmButtonClicked() + { + Platform.runLater(()->nextButton.setDisable(true)); + + StringBuilder errors = new StringBuilder(); + + if(clientNicknameTextField.getText().isBlank()) + { + errors.append("* Nick name cannot be blank.\n"); + } + + if(serverIPHostNameTextField.getText().isBlank()) + { + errors.append("* Server IP cannot be empty.\n"); + } + + int port = -1; + try + { + port = Integer.parseInt(serverPortTextField.getText()); + + if(port < 1024) + errors.append("* Server Port should be above 1024.\n"); + else if(port > 65535) + errors.append("* Server Port must be lesser than 65535\n"); + } + catch (NumberFormatException exception) + { + errors.append("* Server Port should be a number.\n"); + } + + if(errors.toString().isEmpty()) + { + try + { + Config.getInstance().setNickName(clientNicknameTextField.getText()); + Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText()); + Config.getInstance().setServerPort(port); + Config.getInstance().setFirstTimeUse(false); + + if(ClientInfo.getInstance().isPhone()) + { + Config.getInstance().setScreenMoverEnabled(true); + } + + Config.getInstance().save(); + + ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+ + Config.getInstance().getStartupProfileID()+".xml"), Config.getInstance().getIconsPath()); + + int pre = clientProfile.getActionSize()+(clientProfile.getActionGap()*4); + + + rowsToSet = (int) (clientListener.getStageHeight()/pre); + colsToSet = (int) (clientListener.getStageWidth()/pre); + + if(ClientInfo.getInstance().isPhone()) + { + OrientationService.create().ifPresent(orientationService -> { + if(orientationService.getOrientation().isPresent() && + orientationService.getOrientation().get().equals(Orientation.VERTICAL)) + { + int tmp = rowsToSet; + rowsToSet = colsToSet; + colsToSet = tmp; + } + }); + } + + clientProfile.setCols(colsToSet); + clientProfile.setRows(rowsToSet); + + clientProfile.saveProfileDetails(); + + Platform.runLater(()-> { + clientListener.init(); + clientListener.setupClientConnection(); + }); + } + catch(Exception e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleSevereException(new SevereException(e.getMessage())); + } + } + else + { + Platform.runLater(()->nextButton.setDisable(false)); + new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors, StreamPiAlertType.ERROR).show(); + } + } + + private int rowsToSet,colsToSet; +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java old mode 100644 new mode 100755 index 857be4fd..927c03a0 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java @@ -1,142 +1,142 @@ -package com.stream_pi.client.window.firsttimeuse; - -import com.stream_pi.client.Main; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.util.uihelper.SpaceFiller; - -import javafx.geometry.Insets; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.StackPane; -import javafx.scene.layout.VBox; -import javafx.scene.text.Font; - -public class FirstTimeUse extends VBox{ - - - public FirstTimeUse(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) - { - getStyleClass().add("first_time_use_pane"); - - setSpacing(10.0); - setPadding(new Insets(5)); - - headingLabel = new Label(); - headingLabel.getStyleClass().add("first_time_use_pane_heading_label"); - - StackPane stackPane = new StackPane(); - stackPane.getStyleClass().add("first_time_use_pane_stackpane"); - - VBox.setVgrow(stackPane, Priority.ALWAYS); - - nextButton = new Button("Next"); - nextButton.setOnAction(event-> onNextButtonClicked()); - - previousButton = new Button("Previous"); - previousButton.setOnAction(event-> onPreviousButtonClicked()); - - HBox buttonBar = new HBox(previousButton, SpaceFiller.horizontal(), nextButton); - buttonBar.getStyleClass().add("first_time_use_pane_button_bar"); - buttonBar.setSpacing(10.0); - - welcomePane = new WelcomePane(); - licensePane = new LicensePane(); - finalConfigPane = new FinalConfigPane(exceptionAndAlertHandler, clientListener, nextButton); - - stackPane.getChildren().addAll( - welcomePane, - licensePane, - finalConfigPane - ); - - getChildren().addAll(headingLabel, stackPane, buttonBar); - - setWindow(WindowName.WELCOME); - } - - private Label headingLabel; - private Button nextButton; - private Button previousButton; - private WelcomePane welcomePane; - private LicensePane licensePane; - private FinalConfigPane finalConfigPane; - - private WindowName windowName; - - private void onNextButtonClicked() - { - if(windowName == WindowName.WELCOME) - { - setWindow(WindowName.LICENSE); - } - else if(windowName == WindowName.LICENSE) - { - setWindow(WindowName.FINAL); - } - } - - private void onPreviousButtonClicked() - { - nextButton.setText("Next"); - - if(windowName == WindowName.FINAL) - { - setWindow(WindowName.LICENSE); - } - else if(windowName == WindowName.LICENSE) - { - setWindow(WindowName.WELCOME); - } - } - - private void setWindow(WindowName windowName) - { - if (windowName == WindowName.WELCOME) - { - this.windowName = WindowName.WELCOME; - welcomePane.toFront(); - welcomePane.setVisible(true); - licensePane.setVisible(false); - finalConfigPane.setVisible(false); - - headingLabel.setText(""); - - nextButton.setText("Next"); - nextButton.setOnAction(event-> onNextButtonClicked()); - previousButton.setVisible(false); - } - else if (windowName == WindowName.LICENSE) - { - this.windowName = WindowName.LICENSE; - licensePane.toFront(); - welcomePane.setVisible(false); - licensePane.setVisible(true); - finalConfigPane.setVisible(false); - - headingLabel.setText("License Agreement"); - - nextButton.setText("Agree and Continue"); - nextButton.setOnAction(event-> onNextButtonClicked()); - previousButton.setVisible(true); - } - else if (windowName == WindowName.FINAL) - { - this.windowName = WindowName.FINAL; - finalConfigPane.toFront(); - welcomePane.setVisible(false); - licensePane.setVisible(false); - finalConfigPane.setVisible(true); - - headingLabel.setText("Finishing up ..."); - - finalConfigPane.makeChangesToNextButton(); - previousButton.setVisible(true); - } - } - - - -} +package com.stream_pi.client.window.firsttimeuse; + +import com.stream_pi.client.Main; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.util.uihelper.SpaceFiller; + +import javafx.geometry.Insets; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import javafx.scene.text.Font; + +public class FirstTimeUse extends VBox{ + + + public FirstTimeUse(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) + { + getStyleClass().add("first_time_use_pane"); + + setSpacing(10.0); + setPadding(new Insets(5)); + + headingLabel = new Label(); + headingLabel.getStyleClass().add("first_time_use_pane_heading_label"); + + StackPane stackPane = new StackPane(); + stackPane.getStyleClass().add("first_time_use_pane_stackpane"); + + VBox.setVgrow(stackPane, Priority.ALWAYS); + + nextButton = new Button("Next"); + nextButton.setOnAction(event-> onNextButtonClicked()); + + previousButton = new Button("Previous"); + previousButton.setOnAction(event-> onPreviousButtonClicked()); + + HBox buttonBar = new HBox(previousButton, SpaceFiller.horizontal(), nextButton); + buttonBar.getStyleClass().add("first_time_use_pane_button_bar"); + buttonBar.setSpacing(10.0); + + welcomePane = new WelcomePane(); + licensePane = new LicensePane(); + finalConfigPane = new FinalConfigPane(exceptionAndAlertHandler, clientListener, nextButton); + + stackPane.getChildren().addAll( + welcomePane, + licensePane, + finalConfigPane + ); + + getChildren().addAll(headingLabel, stackPane, buttonBar); + + setWindow(WindowName.WELCOME); + } + + private Label headingLabel; + private Button nextButton; + private Button previousButton; + private WelcomePane welcomePane; + private LicensePane licensePane; + private FinalConfigPane finalConfigPane; + + private WindowName windowName; + + private void onNextButtonClicked() + { + if(windowName == WindowName.WELCOME) + { + setWindow(WindowName.LICENSE); + } + else if(windowName == WindowName.LICENSE) + { + setWindow(WindowName.FINAL); + } + } + + private void onPreviousButtonClicked() + { + nextButton.setText("Next"); + + if(windowName == WindowName.FINAL) + { + setWindow(WindowName.LICENSE); + } + else if(windowName == WindowName.LICENSE) + { + setWindow(WindowName.WELCOME); + } + } + + private void setWindow(WindowName windowName) + { + if (windowName == WindowName.WELCOME) + { + this.windowName = WindowName.WELCOME; + welcomePane.toFront(); + welcomePane.setVisible(true); + licensePane.setVisible(false); + finalConfigPane.setVisible(false); + + headingLabel.setText(""); + + nextButton.setText("Next"); + nextButton.setOnAction(event-> onNextButtonClicked()); + previousButton.setVisible(false); + } + else if (windowName == WindowName.LICENSE) + { + this.windowName = WindowName.LICENSE; + licensePane.toFront(); + welcomePane.setVisible(false); + licensePane.setVisible(true); + finalConfigPane.setVisible(false); + + headingLabel.setText("License Agreement"); + + nextButton.setText("Agree and Continue"); + nextButton.setOnAction(event-> onNextButtonClicked()); + previousButton.setVisible(true); + } + else if (windowName == WindowName.FINAL) + { + this.windowName = WindowName.FINAL; + finalConfigPane.toFront(); + welcomePane.setVisible(false); + licensePane.setVisible(false); + finalConfigPane.setVisible(true); + + headingLabel.setText("Finishing up ..."); + + finalConfigPane.makeChangesToNextButton(); + previousButton.setVisible(true); + } + } + + + +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java old mode 100644 new mode 100755 index aa35e97c..521e5df2 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java @@ -1,24 +1,24 @@ -package com.stream_pi.client.window.firsttimeuse; - -import com.stream_pi.client.info.License; - -import javafx.scene.control.Label; -import javafx.scene.control.TextArea; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; - -public class LicensePane extends VBox { - public LicensePane() - { - getStyleClass().add("first_time_use_pane_license"); - - TextArea licenseTextArea = new TextArea(License.getLicense()); - licenseTextArea.setWrapText(false); - licenseTextArea.setEditable(false); - - licenseTextArea.prefWidthProperty().bind(widthProperty()); - VBox.setVgrow(licenseTextArea, Priority.ALWAYS); - - getChildren().addAll(licenseTextArea); - } -} +package com.stream_pi.client.window.firsttimeuse; + +import com.stream_pi.client.info.License; + +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; + +public class LicensePane extends VBox { + public LicensePane() + { + getStyleClass().add("first_time_use_pane_license"); + + TextArea licenseTextArea = new TextArea(License.getLicense()); + licenseTextArea.setWrapText(false); + licenseTextArea.setEditable(false); + + licenseTextArea.prefWidthProperty().bind(widthProperty()); + VBox.setVgrow(licenseTextArea, Priority.ALWAYS); + + getChildren().addAll(licenseTextArea); + } +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java old mode 100644 new mode 100755 index cb0c59b0..1363cfd6 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java @@ -1,29 +1,29 @@ -package com.stream_pi.client.window.firsttimeuse; - -import javafx.geometry.Pos; -import javafx.scene.control.Label; -import javafx.scene.layout.VBox; - -public class WelcomePane extends VBox{ - public WelcomePane() - { - getStyleClass().add("first_time_use_pane_welcome"); - - Label welcomeLabel = new Label("Welcome!"); - welcomeLabel.setWrapText(true); - welcomeLabel.setAlignment(Pos.CENTER); - welcomeLabel.getStyleClass().add("first_time_use_welcome_pane_welcome_label"); - - Label nextToContinue = new Label("Please click \"Next\" to start the Setup process"); - nextToContinue.setWrapText(true); - nextToContinue.setAlignment(Pos.CENTER); - nextToContinue.getStyleClass().add("first_time_use_welcome_pane_next_to_continue_label"); - - - setAlignment(Pos.CENTER); - setSpacing(5.0); - getChildren().addAll(welcomeLabel, nextToContinue); - - setVisible(false); - } -} +package com.stream_pi.client.window.firsttimeuse; + +import javafx.geometry.Pos; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; + +public class WelcomePane extends VBox{ + public WelcomePane() + { + getStyleClass().add("first_time_use_pane_welcome"); + + Label welcomeLabel = new Label("Welcome!"); + welcomeLabel.setWrapText(true); + welcomeLabel.setAlignment(Pos.CENTER); + welcomeLabel.getStyleClass().add("first_time_use_welcome_pane_welcome_label"); + + Label nextToContinue = new Label("Please click \"Next\" to start the Setup process"); + nextToContinue.setWrapText(true); + nextToContinue.setAlignment(Pos.CENTER); + nextToContinue.getStyleClass().add("first_time_use_welcome_pane_next_to_continue_label"); + + + setAlignment(Pos.CENTER); + setSpacing(5.0); + getChildren().addAll(welcomeLabel, nextToContinue); + + setVisible(false); + } +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java old mode 100644 new mode 100755 index 84a8214f..8256a3a6 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java @@ -1,5 +1,5 @@ -package com.stream_pi.client.window.firsttimeuse; - -public enum WindowName { - WELCOME, LICENSE, FINAL -} +package com.stream_pi.client.window.firsttimeuse; + +public enum WindowName { + WELCOME, LICENSE, FINAL +} diff --git a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java old mode 100644 new mode 100755 index eaeaccbf..9e76a180 --- a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java @@ -1,173 +1,173 @@ -package com.stream_pi.client.window.settings.About; - -import com.stream_pi.action_api.ActionAPI; -import com.stream_pi.client.Main; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.info.ClientInfo; -import javafx.application.HostServices; -import javafx.event.Event; -import javafx.event.EventHandler; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.*; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.input.SwipeEvent; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.management.ManagementFactory; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Objects; -import java.util.logging.Logger; - -public class AboutTab extends ScrollPane -{ - private ClientListener clientListener; - - private ContributorsTab contributorsTab; - private VBox mainVBox; - - public AboutTab(ClientListener clientListener) - { - this.clientListener = clientListener; - - getStyleClass().add("about_parent"); - - setPadding(new Insets(5)); - - mainVBox = new VBox(); - mainVBox.getStyleClass().add("about"); - mainVBox.setSpacing(5.0); - - - mainVBox.setAlignment(Pos.TOP_CENTER); - - Image appIcon = new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))); - ImageView appIconImageView = new ImageView(appIcon); - appIconImageView.setFitHeight(146); - appIconImageView.setFitWidth(132); - - - Tab contributorsT = new Tab("Contributors"); - contributorsTab = new ContributorsTab(); - contributorsT.setContent(contributorsTab); - - - TabPane tabPane = new TabPane(); - tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); - - tabPane.getStyleClass().add("settings_about_tab_internal"); - tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); - tabPane.setMaxWidth(600); - VBox.setVgrow(tabPane, Priority.ALWAYS); - - Tab licenseTab = new Tab("License"); - licenseTab.setContent(new LicenseTab()); - - - - Tab contactTab = new Tab("Contact"); - contactTab.setContent(new ContactTab(clientListener)); - - tabPane.getTabs().addAll(licenseTab, contributorsT, contactTab); - - - Hyperlink donateButton = new Hyperlink("DONATE"); - donateButton.setOnAction(event -> openWebpage("https://www.patreon.com/streampi")); - donateButton.getStyleClass().add("about_donate_hyperlink"); - - - ClientInfo clientInfo = ClientInfo.getInstance(); - - Label versionText = new Label(clientInfo.getVersion().getText() + " - "+ clientInfo.getPlatform().getUIName() + " - "+ clientInfo.getReleaseStatus().getUIName()); - versionText.getStyleClass().add("about_version_label"); - - Label commStandardLabel = new Label("Comm Standard "+clientInfo.getCommStandardVersion().getText()); - commStandardLabel.getStyleClass().add("about_comm_standard_label"); - - Label minThemeAPILabel = new Label("Min ThemeAPI "+clientInfo.getMinThemeSupportVersion().getText()); - minThemeAPILabel.getStyleClass().add("about_min_theme_api_label"); - - Label minActionAPILabel = new Label("Min ActionAPI "+clientInfo.getMinPluginSupportVersion().getText()); - minActionAPILabel.getStyleClass().add("about_min_action_api_label"); - - Label currentActionAPILabel = new Label("ActionAPI "+ ActionAPI.API_VERSION.getText()); - currentActionAPILabel.getStyleClass().add("about_current_action_api_label"); - - HBox hBox1 = new HBox(versionText); - - hBox1.setAlignment(Pos.CENTER); - hBox1.setSpacing(10); - - Label javaVersionLabel = new Label("Java "+System.getProperty("java.version")); - javaVersionLabel.getStyleClass().add("about_java_version"); - - Label javafxVersionLabel = new Label("JavaFX "+System.getProperty("javafx.version")); - javafxVersionLabel.getStyleClass().add("about_javafx_version"); - - Label javaGCLabel = new Label("GC: "+ ManagementFactory.getGarbageCollectorMXBeans().get(0).getName()); - javaGCLabel.getStyleClass().add("about_java_gc"); - - HBox hBox2 = new HBox(javaVersionLabel, getSep(), - javafxVersionLabel); - - hBox2.setAlignment(Pos.CENTER); - hBox2.setSpacing(10); - - - Label disclaimerLabel = new Label("This contributor list shows only those who have contributed " + - "to the Client Source code.\nTo know about the contributors of Action API, Theme API, Util, " + - "visit the respective repositories. If you want to know about the Core Team instead, please visit the website."); - - disclaimerLabel.getStyleClass().add("about_license_contributors_disclaimer_label"); - - disclaimerLabel.prefWidthProperty().bind(tabPane.widthProperty()); - - disclaimerLabel.setWrapText(true); - - - mainVBox.getChildren().addAll(appIconImageView, tabPane, disclaimerLabel, - donateButton, hBox1, hBox2,javaGCLabel); - mainVBox.prefWidthProperty().bind(widthProperty().subtract(30)); - - setContent(mainVBox); - - InputStream inputStream = Main.class.getResourceAsStream("build-date"); - if(inputStream != null) - { - try - { - Logger.getLogger(getClass().getName()).info("build-date present"); - Label buildDateLabel = new Label("Build date/time: " + new String(inputStream.readAllBytes())); - buildDateLabel.getStyleClass().add("build-date-label"); - mainVBox.getChildren().add(buildDateLabel); - } - catch (IOException e) - { - Logger.getLogger(getClass().getName()).info("build-date not present"); - } - } - - setCache(true); - setCacheHint(CacheHint.SPEED); - } - - private Label getSep() - { - Label label = new Label("|"); - label.getStyleClass().add("separator_ui_label"); - return label; - } - - public void openWebpage(String url) - { - clientListener.openURL(url); - } -} +package com.stream_pi.client.window.settings.About; + +import com.stream_pi.action_api.ActionAPI; +import com.stream_pi.client.Main; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.info.ClientInfo; +import javafx.application.HostServices; +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.*; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.SwipeEvent; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.management.ManagementFactory; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Objects; +import java.util.logging.Logger; + +public class AboutTab extends ScrollPane +{ + private ClientListener clientListener; + + private ContributorsTab contributorsTab; + private VBox mainVBox; + + public AboutTab(ClientListener clientListener) + { + this.clientListener = clientListener; + + getStyleClass().add("about_parent"); + + setPadding(new Insets(5)); + + mainVBox = new VBox(); + mainVBox.getStyleClass().add("about"); + mainVBox.setSpacing(5.0); + + + mainVBox.setAlignment(Pos.TOP_CENTER); + + Image appIcon = new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))); + ImageView appIconImageView = new ImageView(appIcon); + appIconImageView.setFitHeight(146); + appIconImageView.setFitWidth(132); + + + Tab contributorsT = new Tab("Contributors"); + contributorsTab = new ContributorsTab(); + contributorsT.setContent(contributorsTab); + + + TabPane tabPane = new TabPane(); + tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); + + tabPane.getStyleClass().add("settings_about_tab_internal"); + tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); + tabPane.setMaxWidth(600); + VBox.setVgrow(tabPane, Priority.ALWAYS); + + Tab licenseTab = new Tab("License"); + licenseTab.setContent(new LicenseTab()); + + + + Tab contactTab = new Tab("Contact"); + contactTab.setContent(new ContactTab(clientListener)); + + tabPane.getTabs().addAll(licenseTab, contributorsT, contactTab); + + + Hyperlink donateButton = new Hyperlink("DONATE"); + donateButton.setOnAction(event -> openWebpage("https://www.patreon.com/streampi")); + donateButton.getStyleClass().add("about_donate_hyperlink"); + + + ClientInfo clientInfo = ClientInfo.getInstance(); + + Label versionText = new Label(clientInfo.getVersion().getText() + " - "+ clientInfo.getPlatform().getUIName() + " - "+ clientInfo.getReleaseStatus().getUIName()); + versionText.getStyleClass().add("about_version_label"); + + Label commStandardLabel = new Label("Comm Standard "+clientInfo.getCommStandardVersion().getText()); + commStandardLabel.getStyleClass().add("about_comm_standard_label"); + + Label minThemeAPILabel = new Label("Min ThemeAPI "+clientInfo.getMinThemeSupportVersion().getText()); + minThemeAPILabel.getStyleClass().add("about_min_theme_api_label"); + + Label minActionAPILabel = new Label("Min ActionAPI "+clientInfo.getMinPluginSupportVersion().getText()); + minActionAPILabel.getStyleClass().add("about_min_action_api_label"); + + Label currentActionAPILabel = new Label("ActionAPI "+ ActionAPI.API_VERSION.getText()); + currentActionAPILabel.getStyleClass().add("about_current_action_api_label"); + + HBox hBox1 = new HBox(versionText); + + hBox1.setAlignment(Pos.CENTER); + hBox1.setSpacing(10); + + Label javaVersionLabel = new Label("Java "+System.getProperty("java.version")); + javaVersionLabel.getStyleClass().add("about_java_version"); + + Label javafxVersionLabel = new Label("JavaFX "+System.getProperty("javafx.version")); + javafxVersionLabel.getStyleClass().add("about_javafx_version"); + + Label javaGCLabel = new Label("GC: "+ ManagementFactory.getGarbageCollectorMXBeans().get(0).getName()); + javaGCLabel.getStyleClass().add("about_java_gc"); + + HBox hBox2 = new HBox(javaVersionLabel, getSep(), + javafxVersionLabel); + + hBox2.setAlignment(Pos.CENTER); + hBox2.setSpacing(10); + + + Label disclaimerLabel = new Label("This contributor list shows only those who have contributed " + + "to the Client Source code.\nTo know about the contributors of Action API, Theme API, Util, " + + "visit the respective repositories. If you want to know about the Core Team instead, please visit the website."); + + disclaimerLabel.getStyleClass().add("about_license_contributors_disclaimer_label"); + + disclaimerLabel.prefWidthProperty().bind(tabPane.widthProperty()); + + disclaimerLabel.setWrapText(true); + + + mainVBox.getChildren().addAll(appIconImageView, tabPane, disclaimerLabel, + donateButton, hBox1, hBox2,javaGCLabel); + mainVBox.prefWidthProperty().bind(widthProperty().subtract(30)); + + setContent(mainVBox); + + InputStream inputStream = Main.class.getResourceAsStream("build-date"); + if(inputStream != null) + { + try + { + Logger.getLogger(getClass().getName()).info("build-date present"); + Label buildDateLabel = new Label("Build date/time: " + new String(inputStream.readAllBytes())); + buildDateLabel.getStyleClass().add("build-date-label"); + mainVBox.getChildren().add(buildDateLabel); + } + catch (IOException e) + { + Logger.getLogger(getClass().getName()).info("build-date not present"); + } + } + + setCache(true); + setCacheHint(CacheHint.SPEED); + } + + private Label getSep() + { + Label label = new Label("|"); + label.getStyleClass().add("separator_ui_label"); + return label; + } + + public void openWebpage(String url) + { + clientListener.openURL(url); + } +} diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java old mode 100644 new mode 100755 index 04005b2b..2eb64a7e --- a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java @@ -1,50 +1,50 @@ -package com.stream_pi.client.window.settings.About; - -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.util.contactlinks.ContactLinks; -import javafx.application.HostServices; -import javafx.scene.control.Hyperlink; -import javafx.scene.control.ScrollPane; -import javafx.scene.layout.VBox; - - -public class ContactTab extends ScrollPane -{ - private ClientListener clientListener; - - public ContactTab(ClientListener clientListener) - { - this.clientListener = clientListener; - - getStyleClass().add("about_contact_tab_scroll_pane"); - - Hyperlink github = new Hyperlink("GitHub"); - github.setOnAction(event -> openWebpage(ContactLinks.getGitHub())); - - Hyperlink discord = new Hyperlink("Discord"); - discord.setOnAction(event -> openWebpage(ContactLinks.getDiscord())); - - Hyperlink website = new Hyperlink("Website"); - website.setOnAction(event -> openWebpage(ContactLinks.getWebsite())); - - Hyperlink twitter = new Hyperlink("Twitter"); - twitter.setOnAction(event -> openWebpage(ContactLinks.getTwitter())); - - Hyperlink matrix = new Hyperlink("Matrix"); - matrix.setOnAction(event -> openWebpage(ContactLinks.getMatrix())); - - - VBox vBox = new VBox(github, discord, website, twitter, matrix); - vBox.setSpacing(10.0); - - setContent(vBox); - } - - - public void openWebpage(String url) - { - clientListener.openURL(url); - } - -} +package com.stream_pi.client.window.settings.About; + +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.util.contactlinks.ContactLinks; +import javafx.application.HostServices; +import javafx.scene.control.Hyperlink; +import javafx.scene.control.ScrollPane; +import javafx.scene.layout.VBox; + + +public class ContactTab extends ScrollPane +{ + private ClientListener clientListener; + + public ContactTab(ClientListener clientListener) + { + this.clientListener = clientListener; + + getStyleClass().add("about_contact_tab_scroll_pane"); + + Hyperlink github = new Hyperlink("GitHub"); + github.setOnAction(event -> openWebpage(ContactLinks.getGitHub())); + + Hyperlink discord = new Hyperlink("Discord"); + discord.setOnAction(event -> openWebpage(ContactLinks.getDiscord())); + + Hyperlink website = new Hyperlink("Website"); + website.setOnAction(event -> openWebpage(ContactLinks.getWebsite())); + + Hyperlink twitter = new Hyperlink("Twitter"); + twitter.setOnAction(event -> openWebpage(ContactLinks.getTwitter())); + + Hyperlink matrix = new Hyperlink("Matrix"); + matrix.setOnAction(event -> openWebpage(ContactLinks.getMatrix())); + + + VBox vBox = new VBox(github, discord, website, twitter, matrix); + vBox.setSpacing(10.0); + + setContent(vBox); + } + + + public void openWebpage(String url) + { + clientListener.openURL(url); + } + +} diff --git a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java old mode 100644 new mode 100755 index 03258429..f0496c7d --- a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java @@ -1,49 +1,49 @@ -package com.stream_pi.client.window.settings.About; - -public class Contributor -{ - public String name = null; - public String email = null; - public String description = null; - public String location = null; - - public Contributor(String name, String email, String description, String location) - { - this.name = name; - this.email = email; - this.description = description; - this.location = location; - } - - public void setName(String name) { - this.name = name; - } - - public void setEmail(String email) { - this.email = email; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } - - public String getDescription() { - return description; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } +package com.stream_pi.client.window.settings.About; + +public class Contributor +{ + public String name = null; + public String email = null; + public String description = null; + public String location = null; + + public Contributor(String name, String email, String description, String location) + { + this.name = name; + this.email = email; + this.description = description; + this.location = location; + } + + public void setName(String name) { + this.name = name; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public String getEmail() { + return email; + } + + public String getDescription() { + return description; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } } \ No newline at end of file diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java old mode 100644 new mode 100755 index 4a69636e..ad7711c5 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java @@ -1,76 +1,76 @@ -package com.stream_pi.client.window.settings.About; - -import javafx.scene.CacheHint; -import javafx.scene.control.Label; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.cell.PropertyValueFactory; -import javafx.scene.layout.VBox; - -public class ContributorsTab extends VBox -{ - TableView tableView; - - public ContributorsTab() - { - getStyleClass().add("about_license_contributors_vbox"); - - tableView = new TableView<>(); - tableView.getStyleClass().add("about_license_contributors_table_view"); - - TableColumn descriptionColumn = new TableColumn<>("Description"); - descriptionColumn.setReorderable(false); - descriptionColumn.setPrefWidth(250); - descriptionColumn.setResizable(false); - descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description")); - - TableColumn nameColumn = new TableColumn<>("Name (GitHub)"); - nameColumn.setReorderable(false); - nameColumn.setPrefWidth(220); - nameColumn.setResizable(false); - nameColumn.setCellValueFactory(new PropertyValueFactory<>("name")); - - TableColumn emailColumn = new TableColumn<>("Email"); - emailColumn.setReorderable(false); - emailColumn.setPrefWidth(200); - emailColumn.setResizable(false); - emailColumn.setCellValueFactory(new PropertyValueFactory<>("email")); - - TableColumn locationColumn = new TableColumn<>("Location"); - locationColumn.setReorderable(false); - locationColumn.setPrefWidth(100); - locationColumn.setResizable(false); - locationColumn.setCellValueFactory(new PropertyValueFactory<>("location")); - - - tableView.getColumns().addAll(descriptionColumn, nameColumn, emailColumn, locationColumn); - - tableView.setPrefWidth(descriptionColumn.getPrefWidth() + nameColumn.getPrefWidth() + emailColumn.getPrefWidth()); - - tableView.getItems().addAll( - new Contributor("Debayan Sutradhar (rnayabed)", - "debayansutradhar3@gmail.com", - "Founder, Author, Maintainer", - "India"), - new Contributor("Samuel Quiñones (SamuelQuinones)", - "sdquinones1@gmail.com", - "Founder", - "United States"), - new Contributor("Abhinay Agarwal (abhinayagarwal)", - "abhinay_agarwal@live.com", - "Refactoring, Fixes", - "India") - ); - - getChildren().addAll(tableView); - - - setCache(true); - setCacheHint(CacheHint.SPEED); - } - - public TableView getTableView() - { - return tableView; - } -} +package com.stream_pi.client.window.settings.About; + +import javafx.scene.CacheHint; +import javafx.scene.control.Label; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.layout.VBox; + +public class ContributorsTab extends VBox +{ + TableView tableView; + + public ContributorsTab() + { + getStyleClass().add("about_license_contributors_vbox"); + + tableView = new TableView<>(); + tableView.getStyleClass().add("about_license_contributors_table_view"); + + TableColumn descriptionColumn = new TableColumn<>("Description"); + descriptionColumn.setReorderable(false); + descriptionColumn.setPrefWidth(250); + descriptionColumn.setResizable(false); + descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description")); + + TableColumn nameColumn = new TableColumn<>("Name (GitHub)"); + nameColumn.setReorderable(false); + nameColumn.setPrefWidth(220); + nameColumn.setResizable(false); + nameColumn.setCellValueFactory(new PropertyValueFactory<>("name")); + + TableColumn emailColumn = new TableColumn<>("Email"); + emailColumn.setReorderable(false); + emailColumn.setPrefWidth(200); + emailColumn.setResizable(false); + emailColumn.setCellValueFactory(new PropertyValueFactory<>("email")); + + TableColumn locationColumn = new TableColumn<>("Location"); + locationColumn.setReorderable(false); + locationColumn.setPrefWidth(100); + locationColumn.setResizable(false); + locationColumn.setCellValueFactory(new PropertyValueFactory<>("location")); + + + tableView.getColumns().addAll(descriptionColumn, nameColumn, emailColumn, locationColumn); + + tableView.setPrefWidth(descriptionColumn.getPrefWidth() + nameColumn.getPrefWidth() + emailColumn.getPrefWidth()); + + tableView.getItems().addAll( + new Contributor("Debayan Sutradhar (rnayabed)", + "debayansutradhar3@gmail.com", + "Founder, Author, Maintainer", + "India"), + new Contributor("Samuel Quiñones (SamuelQuinones)", + "sdquinones1@gmail.com", + "Founder", + "United States"), + new Contributor("Abhinay Agarwal (abhinayagarwal)", + "abhinay_agarwal@live.com", + "Refactoring, Fixes", + "India") + ); + + getChildren().addAll(tableView); + + + setCache(true); + setCacheHint(CacheHint.SPEED); + } + + public TableView getTableView() + { + return tableView; + } +} diff --git a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java old mode 100644 new mode 100755 index 88ab9746..990d319d --- a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java @@ -1,16 +1,16 @@ -package com.stream_pi.client.window.settings.About; - - -import com.stream_pi.client.info.License; -import javafx.scene.control.TextArea; - -public class LicenseTab extends TextArea -{ - public LicenseTab() - { - setText(License.getLicense()); - getStyleClass().add("about_license_text_area"); - setWrapText(false); - setEditable(false); - } -} +package com.stream_pi.client.window.settings.About; + + +import com.stream_pi.client.info.License; +import javafx.scene.control.TextArea; + +public class LicenseTab extends TextArea +{ + public LicenseTab() + { + setText(License.getLicense()); + getStyleClass().add("about_license_text_area"); + setWrapText(false); + setEditable(false); + } +} diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java old mode 100644 new mode 100755 index d98e649a..e996f4d3 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -1,792 +1,792 @@ -package com.stream_pi.client.window.settings; - -import com.gluonhq.attach.vibration.VibrationService; -import com.stream_pi.client.Main; -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.window.ExceptionAndAlertHandler; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.util.alert.StreamPiAlert; -import com.stream_pi.util.alert.StreamPiAlertListener; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.checkforupdates.CheckForUpdates; -import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick; -import com.stream_pi.util.combobox.StreamPiComboBox; -import com.stream_pi.util.combobox.StreamPiComboBoxFactory; -import com.stream_pi.util.combobox.StreamPiComboBoxListener; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.platform.PlatformType; -import com.stream_pi.util.startatboot.StartAtBoot; -import com.stream_pi.util.uihelper.HBoxInputBox; -import com.stream_pi.util.uihelper.HBoxWithSpaceBetween; -import com.stream_pi.util.uihelper.SpaceFiller; -import javafx.application.HostServices; -import javafx.event.ActionEvent; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.*; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; -import java.util.Arrays; -import java.util.List; -import org.controlsfx.control.ToggleSwitch; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.logging.Logger; - -public class GeneralTab extends VBox -{ - private ExceptionAndAlertHandler exceptionAndAlertHandler; - private ClientListener clientListener; - private HostServices hostServices; - - private TextField serverPortTextField; - private TextField serverHostNameOrIPTextField; - - private TextField screenTimeoutTextField; - - private StreamPiComboBox clientProfileComboBox; - private StreamPiComboBox themeComboBox; - private StreamPiComboBox animationComboBox; - - private TextField nickNameTextField; - - private Button saveButton; - private Button connectDisconnectButton; - private Button shutdownButton; - - private HBoxWithSpaceBetween startOnBootHBox; - private ToggleSwitch startOnBootToggleSwitch; - - private HBoxWithSpaceBetween screenSaverHBox; - private ToggleSwitch screenSaverToggleSwitch; - - private HBoxWithSpaceBetween screenMoverHBox; - private ToggleSwitch screenMoverToggleSwitch; - - private HBoxWithSpaceBetween tryConnectingToServerIfActionClickedHBox; - private ToggleSwitch tryConnectingToServerIfActionClickedToggleSwitch; - - private HBoxWithSpaceBetween connectOnStartupHBox; - private ToggleSwitch connectOnStartupToggleSwitch; - - private HBoxWithSpaceBetween vibrateOnActionPressHBox; - private ToggleSwitch vibrateOnActionPressToggleSwitch; - - private HBoxWithSpaceBetween fullScreenModeHBox; - private ToggleSwitch fullScreenModeToggleSwitch; - - private HBoxWithSpaceBetween showCursorHBox; - private ToggleSwitch showCursorToggleSwitch; - - private HBoxWithSpaceBetween invertRowsColsHBox; - private ToggleSwitch invertRowsColsToggleSwitch; - - private TextField themesPathTextField; - private TextField iconsPathTextField; - private TextField profilesPathTextField; - - private final Button factoryResetButton; - - private Logger logger; - - - private final Button checkForUpdatesButton; - - private HBoxInputBox screenTimeoutSecondsHBoxInputBox; - - private List animationList; - - public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler, - ClientListener clientListener, HostServices hostServices) - { - this.animationList = Arrays.asList(new String[] { - "None", "Bounce", "Flip", "Jack In The Box", "Jello", "Pulse", "RubberBand", "Shake", "Swing", "Tada", - "Wobble" - }); - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.clientListener = clientListener; - this.hostServices = hostServices; - - logger = Logger.getLogger(""); - - serverPortTextField = new TextField(); - screenTimeoutTextField = new TextField(); - - - serverHostNameOrIPTextField = new TextField(); - nickNameTextField = new TextField(); - - clientProfileComboBox = new StreamPiComboBox<>(); - - clientProfileComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() - { - @Override - public String getOptionDisplayText(ClientProfile object) - { - return object.getName(); - } - }); - animationComboBox = new StreamPiComboBox(); - - animationComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() - { - @Override - public String getOptionDisplayText(String object) - { - return object; - } - }); - - - clientProfileComboBox.setStreamPiComboBoxListener(new StreamPiComboBoxListener(){ - @Override - public void onNewItemSelected(ClientProfile selectedItem) - { - clientListener.renderProfile(selectedItem, true); - } - }); - - - themeComboBox = new StreamPiComboBox<>(); - themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() - { - @Override - public String getOptionDisplayText(Theme object) - { - return object.getShortName(); - } - }); - - themesPathTextField = new TextField(); - iconsPathTextField = new TextField(); - profilesPathTextField = new TextField(); - - startOnBootToggleSwitch = new ToggleSwitch(); - startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", startOnBootToggleSwitch); - startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty()); - - screenSaverToggleSwitch = new ToggleSwitch(); - screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", screenSaverToggleSwitch); - screenSaverHBox.managedProperty().bind(screenSaverHBox.visibleProperty()); - - screenMoverToggleSwitch = new ToggleSwitch(); - screenMoverHBox = new HBoxWithSpaceBetween("OLED Burn-In Protector", screenMoverToggleSwitch); - screenMoverHBox.managedProperty().bind(screenMoverHBox.visibleProperty()); - - tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch(); - tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", tryConnectingToServerIfActionClickedToggleSwitch); - tryConnectingToServerIfActionClickedHBox.managedProperty().bind(tryConnectingToServerIfActionClickedHBox.visibleProperty()); - - fullScreenModeToggleSwitch = new ToggleSwitch(); - fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", fullScreenModeToggleSwitch); - fullScreenModeHBox.managedProperty().bind(fullScreenModeHBox.visibleProperty()); - - vibrateOnActionPressToggleSwitch = new ToggleSwitch(); - vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", vibrateOnActionPressToggleSwitch); - vibrateOnActionPressHBox.managedProperty().bind(vibrateOnActionPressHBox.visibleProperty()); - - connectOnStartupToggleSwitch = new ToggleSwitch(); - connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", connectOnStartupToggleSwitch); - connectOnStartupHBox.managedProperty().bind(connectOnStartupHBox.visibleProperty()); - - showCursorToggleSwitch = new ToggleSwitch(); - showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", showCursorToggleSwitch); - showCursorHBox.managedProperty().bind(showCursorHBox.visibleProperty()); - - invertRowsColsToggleSwitch = new ToggleSwitch(); - invertRowsColsHBox = new HBoxWithSpaceBetween("Invert Grid on Rotate", invertRowsColsToggleSwitch); - invertRowsColsHBox.managedProperty().bind(invertRowsColsHBox.visibleProperty()); - - int prefWidth = 200; - - HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", themesPathTextField, prefWidth); - themesPathInputBox.managedProperty().bind(themesPathInputBox.visibleProperty()); - - - HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", iconsPathTextField, prefWidth); - iconsPathInputBox.managedProperty().bind(iconsPathInputBox.visibleProperty()); - - - HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", profilesPathTextField, prefWidth); - profilesPathInputBox.managedProperty().bind(profilesPathInputBox.visibleProperty()); - - checkForUpdatesButton = new Button("Check for updates"); - checkForUpdatesButton.setOnAction(event->checkForUpdates()); - - factoryResetButton = new Button("Factory Reset"); - factoryResetButton.setOnAction(actionEvent -> onFactoryResetButtonClicked()); - - - screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", screenTimeoutTextField, prefWidth); - screenTimeoutSecondsHBoxInputBox.managedProperty().bind(screenTimeoutSecondsHBoxInputBox.visibleProperty()); - screenTimeoutTextField.disableProperty().bind(screenSaverToggleSwitch.selectedProperty().not()); - - saveButton = new Button("Save"); - saveButton.setOnAction(event->onSaveButtonClicked()); - - connectDisconnectButton = new Button("Connect"); - connectDisconnectButton.setOnAction(event -> onConnectDisconnectButtonClicked()); - - - Button exitButton = new Button("Exit"); - exitButton.setOnAction(event -> onExitButtonClicked()); - - HBox buttonBar = new HBox(connectDisconnectButton, saveButton); - - shutdownButton = new Button("Shutdown"); - shutdownButton.managedProperty().bind(shutdownButton.visibleProperty()); - shutdownButton.setOnAction(event -> onShutdownButtonClicked()); - - - VBox vBox = new VBox( - generateSubHeading("Connection"), - new HBoxInputBox("Device Name", nickNameTextField, prefWidth), - new HBoxInputBox("Host Name/IP", serverHostNameOrIPTextField, prefWidth), - new HBoxInputBox("Port", serverPortTextField, prefWidth), - generateSubHeading("Client"), - new HBox( - new Label("Current profile"), - SpaceFiller.horizontal(), - clientProfileComboBox - ), - new HBox( - new Label("Theme"), - SpaceFiller.horizontal(), - themeComboBox - ), - new HBox( - new Label("Action Animation"), - SpaceFiller.horizontal(), - animationComboBox - ), - generateSubHeading("Others"), - themesPathInputBox, - iconsPathInputBox, - profilesPathInputBox, - screenTimeoutSecondsHBoxInputBox, - invertRowsColsHBox, - screenSaverHBox, - screenMoverHBox, - tryConnectingToServerIfActionClickedHBox, - fullScreenModeHBox, - connectOnStartupHBox, - vibrateOnActionPressHBox, - startOnBootHBox, - showCursorHBox, - checkForUpdatesButton, - shutdownButton, - factoryResetButton - ); - - - vBox.getStyleClass().add("settings_base_vbox"); - - vBox.setSpacing(10.0); - vBox.setPadding(new Insets(5)); - - ScrollPane scrollPane = new ScrollPane(); - scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); - VBox.setVgrow(scrollPane, Priority.ALWAYS); - scrollPane.getStyleClass().add("settings_base_scroll_pane"); - scrollPane.setContent(vBox); - - vBox.setMinWidth(300); - - vBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(30)); - - - buttonBar.getStyleClass().add("settings_button_bar"); - - - buttonBar.setPadding(new Insets(0,5,5,0)); - buttonBar.setSpacing(5.0); - buttonBar.setAlignment(Pos.CENTER_RIGHT); - - setSpacing(10.0); - - getChildren().addAll( - scrollPane, - buttonBar - ); - - setCache(true); - setCacheHint(CacheHint.SPEED); - - - //Perform platform checks - - if(ClientInfo.getInstance().isPhone()) - { - themesPathInputBox.setVisible(false); - iconsPathInputBox.setVisible(false); - profilesPathInputBox.setVisible(false); - - startOnBootHBox.setVisible(false); - showCursorHBox.setVisible(false); - fullScreenModeHBox.setVisible(false); - shutdownButton.setVisible(false); - } - else - { - invertRowsColsHBox.setVisible(false); - vibrateOnActionPressHBox.setVisible(false); - buttonBar.getChildren().add(exitButton); - - - fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON); - - shutdownButton.setVisible(StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON); - } - - - screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); - screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); - } - - private Label generateSubHeading(String text) - { - Label label = new Label(text); - label.getStyleClass().add("general_settings_sub_heading"); - return label; - } - - private Logger getLogger() - { - return logger; - } - - private void checkForUpdates() - { - new CheckForUpdates(checkForUpdatesButton, - PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() { - @Override - public void handle(ActionEvent actionEvent) { - if(ClientInfo.getInstance().isPhone()) - { - clientListener.openURL(getURL()); - } - else - { - hostServices.showDocument(getURL()); - } - } - }); - } - - private void onFactoryResetButtonClicked() - { - StreamPiAlert confirmation = new StreamPiAlert("Warning","Are you sure?\n" + - "This will erase everything.",StreamPiAlertType.WARNING); - - String yesButton = "Yes"; - String noButton = "No"; - - confirmation.setButtons(yesButton, noButton); - - confirmation.setOnClicked(new StreamPiAlertListener() { - @Override - public void onClick(String s) { - if(s.equals(yesButton)) - { - clientListener.factoryReset(); - } - } - }); - - confirmation.show(); - } - - - public void onExitButtonClicked() - { - clientListener.onCloseRequest(); - clientListener.exitApp(); - } - - public void setDisableStatus(boolean status) - { - saveButton.setDisable(status); - connectDisconnectButton.setDisable(status); - } - - public Button getConnectDisconnectButton() - { - return connectDisconnectButton; - } - - public void onShutdownButtonClicked() - { - clientListener.onCloseRequest(); - - try - { - Runtime.getRuntime().exec("sudo halt"); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public void onConnectDisconnectButtonClicked() - { - try - { - if(clientListener.isConnected()) - clientListener.disconnect("Client disconnected from settings"); - else - clientListener.setupClientConnection(); - } - catch (SevereException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(e); - } - } - - public void setConnectDisconnectButtonStatus() - { - javafx.application.Platform.runLater(()->{ - setDisableStatus(false); - - if(clientListener.isConnected()) - connectDisconnectButton.setText("Disconnect"); - else - connectDisconnectButton.setText("Connect"); - }); - - } - - public void loadData() throws SevereException - { - Config config = Config.getInstance(); - - nickNameTextField.setText(config.getClientNickName()); - - serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP()); - serverPortTextField.setText(config.getSavedServerPort()+""); - - screenTimeoutTextField.setText(config.getScreenSaverTimeout()+""); - screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); - screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); - animationComboBox.setOptions(animationList); - clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles()); - - int ind = 0; - for(int i = 0;i 65535) - errors.append("* Server Port must be lesser than 65535\n"); - } - catch (NumberFormatException exception) - { - errors.append("* Server Port should be a number.\n"); - } - - - int screenSaverTimeout = -1; - try - { - screenSaverTimeout = Integer.parseInt(serverPortTextField.getText()); - - if(screenSaverTimeout < 15) - errors.append("* Screen Timeout cannot be below 15 seconds.\n"); - } - catch (NumberFormatException exception) - { - errors.append("* Screen Timeout should be a number.\n"); - } - - - if(serverHostNameOrIPTextField.getText().isBlank()) - { - errors.append("* Server IP cannot be empty.\n"); - } - - if(nickNameTextField.getText().isBlank()) - { - errors.append("* Nick name cannot be blank.\n"); - } - else - { - if(nickNameTextField.getText().equals("about maker")) - { - new StreamPiAlert("किसने बनाया ? / কে বানিয়েছে ?","ZGViYXlhbiAtIGluZGlh\n" + - "boka XD").show(); - } - } - - - if(!errors.toString().isEmpty()) - { - exceptionAndAlertHandler.handleMinorException(new MinorException( - "You made mistakes", - "Please fix the errors and try again :\n"+errors.toString() - )); - return; - } - - - - try - { - boolean toBeReloaded = false; - - boolean syncWithServer = false; - - Config config = Config.getInstance(); - - if(!config.getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName())) - { - syncWithServer = true; - - try - { - config.setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName()); - config.save(); - clientListener.initThemes(); - } - catch(SevereException e) - { - exceptionAndAlertHandler.handleSevereException(e); - } - } - - if (!config.getCurrentAnimationName().equals(animationComboBox.getCurrentSelectedItem())) - { - syncWithServer = true; - - try - { - config.setCurrentAnimationFullName(animationComboBox.getCurrentSelectedItem()); - config.save(); - } catch (SevereException e) - { - exceptionAndAlertHandler.handleSevereException(e); - } - } - - if(!config.getClientNickName().equals(nickNameTextField.getText())) - { - syncWithServer = true; - } - - config.setNickName(nickNameTextField.getText()); - - if(port != config.getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP())) - { - syncWithServer = true; - } - - config.setServerPort(port); - config.setServerHostNameOrIP(serverHostNameOrIPTextField.getText()); - - boolean isFullScreen = fullScreenModeToggleSwitch.isSelected(); - - if(config.getIsFullScreenMode() != isFullScreen) - { - toBeReloaded = true; - } - - config.setIsFullScreenMode(isFullScreen); - - - - config.setTryConnectingWhenActionClicked(tryConnectingToServerIfActionClickedToggleSwitch.isSelected()); - - - - boolean startOnBoot = startOnBootToggleSwitch.isSelected(); - - if(config.isStartOnBoot() != startOnBoot) - { - StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), - Main.class.getProtectionDomain().getCodeSource().getLocation(), - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); - - if(startOnBoot) - { - try - { - startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); - config.setStartupIsXMode(StartupFlags.IS_X_MODE); - } - catch (MinorException e) - { - exceptionAndAlertHandler.handleMinorException(e); - startOnBoot = false; - } - } - else - { - boolean result = startAtBoot.delete(); - if(!result) - new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show(); - } - } - - config.setStartOnBoot(startOnBoot); - - if(!config.isShowCursor() ==showCursorToggleSwitch.isSelected()) - toBeReloaded = true; - - config.setShowCursor(showCursorToggleSwitch.isSelected()); - - - if(!config.getThemesPath().equals(themesPathTextField.getText())) - toBeReloaded = true; - - config.setThemesPath(themesPathTextField.getText()); - - - if(!config.getIconsPath().equals(iconsPathTextField.getText())) - toBeReloaded = true; - - config.setIconsPath(iconsPathTextField.getText()); - - if(!config.getProfilesPath().equals(profilesPathTextField.getText())) - toBeReloaded = true; - - config.setProfilesPath(profilesPathTextField.getText()); - - if(config.isScreenSaverEnabled() != screenSaverToggleSwitch.isSelected()) - toBeReloaded = true; - - config.setScreenSaverEnabled(screenSaverToggleSwitch.isSelected()); - - if(config.isScreenMoverEnabled() != screenMoverToggleSwitch.isSelected()) - toBeReloaded = true; - - config.setScreenMoverEnabled(screenMoverToggleSwitch.isSelected()); - - if(!(screenSaverTimeout+"").equals(screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) - { - config.setScreenSaverTimeout(screenTimeoutTextField.getText()); - - clientListener.getScreenSaver().setTimeout(config.getScreenSaverTimeout()); - clientListener.getScreenSaver().restartTimer(); - } - - - config.setConnectOnStartup(connectOnStartupToggleSwitch.isSelected()); - - boolean isVibrateOnActionClicked = vibrateOnActionPressToggleSwitch.isSelected(); - - if(config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked) - { - if(VibrationService.create().isEmpty()) - { - isVibrateOnActionClicked = false; - new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show(); - } - } - - config.setVibrateOnActionClicked(isVibrateOnActionClicked); - config.setInvertRowsColsOnDeviceRotate(invertRowsColsToggleSwitch.isSelected()); - - config.save(); - - loadData(); - - - if(syncWithServer) - { - if(clientListener.isConnected()) - { - clientListener.getClient().updateClientDetails(); - } - } - - if(toBeReloaded) - { - if(!ClientInfo.getInstance().isPhone() && !config.getIsFullScreenMode()) - { - config.setStartupWindowSize(clientListener.getStageWidth(), clientListener.getStageHeight()); - config.save(); - } - - clientListener.init(); - clientListener.renderRootDefaultProfile(); - } - } - catch (SevereException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(e); - } - catch (MinorException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleMinorException(e); - } - } - -} +package com.stream_pi.client.window.settings; + +import com.gluonhq.attach.vibration.VibrationService; +import com.stream_pi.client.Main; +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.window.ExceptionAndAlertHandler; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertListener; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.checkforupdates.CheckForUpdates; +import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick; +import com.stream_pi.util.combobox.StreamPiComboBox; +import com.stream_pi.util.combobox.StreamPiComboBoxFactory; +import com.stream_pi.util.combobox.StreamPiComboBoxListener; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.platform.PlatformType; +import com.stream_pi.util.startatboot.StartAtBoot; +import com.stream_pi.util.uihelper.HBoxInputBox; +import com.stream_pi.util.uihelper.HBoxWithSpaceBetween; +import com.stream_pi.util.uihelper.SpaceFiller; +import javafx.application.HostServices; +import javafx.event.ActionEvent; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.*; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; +import java.util.Arrays; +import java.util.List; +import org.controlsfx.control.ToggleSwitch; + +import java.io.File; +import java.net.URISyntaxException; +import java.util.logging.Logger; + +public class GeneralTab extends VBox +{ + private ExceptionAndAlertHandler exceptionAndAlertHandler; + private ClientListener clientListener; + private HostServices hostServices; + + private TextField serverPortTextField; + private TextField serverHostNameOrIPTextField; + + private TextField screenTimeoutTextField; + + private StreamPiComboBox clientProfileComboBox; + private StreamPiComboBox themeComboBox; + private StreamPiComboBox animationComboBox; + + private TextField nickNameTextField; + + private Button saveButton; + private Button connectDisconnectButton; + private Button shutdownButton; + + private HBoxWithSpaceBetween startOnBootHBox; + private ToggleSwitch startOnBootToggleSwitch; + + private HBoxWithSpaceBetween screenSaverHBox; + private ToggleSwitch screenSaverToggleSwitch; + + private HBoxWithSpaceBetween screenMoverHBox; + private ToggleSwitch screenMoverToggleSwitch; + + private HBoxWithSpaceBetween tryConnectingToServerIfActionClickedHBox; + private ToggleSwitch tryConnectingToServerIfActionClickedToggleSwitch; + + private HBoxWithSpaceBetween connectOnStartupHBox; + private ToggleSwitch connectOnStartupToggleSwitch; + + private HBoxWithSpaceBetween vibrateOnActionPressHBox; + private ToggleSwitch vibrateOnActionPressToggleSwitch; + + private HBoxWithSpaceBetween fullScreenModeHBox; + private ToggleSwitch fullScreenModeToggleSwitch; + + private HBoxWithSpaceBetween showCursorHBox; + private ToggleSwitch showCursorToggleSwitch; + + private HBoxWithSpaceBetween invertRowsColsHBox; + private ToggleSwitch invertRowsColsToggleSwitch; + + private TextField themesPathTextField; + private TextField iconsPathTextField; + private TextField profilesPathTextField; + + private final Button factoryResetButton; + + private Logger logger; + + + private final Button checkForUpdatesButton; + + private HBoxInputBox screenTimeoutSecondsHBoxInputBox; + + private List animationList; + + public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler, + ClientListener clientListener, HostServices hostServices) + { + this.animationList = Arrays.asList(new String[] { + "None", "Bounce", "Flip", "Flash", "Jack In The Box", "Jello", "Pulse", "RubberBand", "Shake", "Swing", "Tada", + "Wobble" + }); + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.clientListener = clientListener; + this.hostServices = hostServices; + + logger = Logger.getLogger(""); + + serverPortTextField = new TextField(); + screenTimeoutTextField = new TextField(); + + + serverHostNameOrIPTextField = new TextField(); + nickNameTextField = new TextField(); + + clientProfileComboBox = new StreamPiComboBox<>(); + + clientProfileComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(ClientProfile object) + { + return object.getName(); + } + }); + animationComboBox = new StreamPiComboBox(); + + animationComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(String object) + { + return object; + } + }); + + + clientProfileComboBox.setStreamPiComboBoxListener(new StreamPiComboBoxListener(){ + @Override + public void onNewItemSelected(ClientProfile selectedItem) + { + clientListener.renderProfile(selectedItem, true); + } + }); + + + themeComboBox = new StreamPiComboBox<>(); + themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(Theme object) + { + return object.getShortName(); + } + }); + + themesPathTextField = new TextField(); + iconsPathTextField = new TextField(); + profilesPathTextField = new TextField(); + + startOnBootToggleSwitch = new ToggleSwitch(); + startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", startOnBootToggleSwitch); + startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty()); + + screenSaverToggleSwitch = new ToggleSwitch(); + screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", screenSaverToggleSwitch); + screenSaverHBox.managedProperty().bind(screenSaverHBox.visibleProperty()); + + screenMoverToggleSwitch = new ToggleSwitch(); + screenMoverHBox = new HBoxWithSpaceBetween("OLED Burn-In Protector", screenMoverToggleSwitch); + screenMoverHBox.managedProperty().bind(screenMoverHBox.visibleProperty()); + + tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch(); + tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", tryConnectingToServerIfActionClickedToggleSwitch); + tryConnectingToServerIfActionClickedHBox.managedProperty().bind(tryConnectingToServerIfActionClickedHBox.visibleProperty()); + + fullScreenModeToggleSwitch = new ToggleSwitch(); + fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", fullScreenModeToggleSwitch); + fullScreenModeHBox.managedProperty().bind(fullScreenModeHBox.visibleProperty()); + + vibrateOnActionPressToggleSwitch = new ToggleSwitch(); + vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", vibrateOnActionPressToggleSwitch); + vibrateOnActionPressHBox.managedProperty().bind(vibrateOnActionPressHBox.visibleProperty()); + + connectOnStartupToggleSwitch = new ToggleSwitch(); + connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", connectOnStartupToggleSwitch); + connectOnStartupHBox.managedProperty().bind(connectOnStartupHBox.visibleProperty()); + + showCursorToggleSwitch = new ToggleSwitch(); + showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", showCursorToggleSwitch); + showCursorHBox.managedProperty().bind(showCursorHBox.visibleProperty()); + + invertRowsColsToggleSwitch = new ToggleSwitch(); + invertRowsColsHBox = new HBoxWithSpaceBetween("Invert Grid on Rotate", invertRowsColsToggleSwitch); + invertRowsColsHBox.managedProperty().bind(invertRowsColsHBox.visibleProperty()); + + int prefWidth = 200; + + HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", themesPathTextField, prefWidth); + themesPathInputBox.managedProperty().bind(themesPathInputBox.visibleProperty()); + + + HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", iconsPathTextField, prefWidth); + iconsPathInputBox.managedProperty().bind(iconsPathInputBox.visibleProperty()); + + + HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", profilesPathTextField, prefWidth); + profilesPathInputBox.managedProperty().bind(profilesPathInputBox.visibleProperty()); + + checkForUpdatesButton = new Button("Check for updates"); + checkForUpdatesButton.setOnAction(event->checkForUpdates()); + + factoryResetButton = new Button("Factory Reset"); + factoryResetButton.setOnAction(actionEvent -> onFactoryResetButtonClicked()); + + + screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", screenTimeoutTextField, prefWidth); + screenTimeoutSecondsHBoxInputBox.managedProperty().bind(screenTimeoutSecondsHBoxInputBox.visibleProperty()); + screenTimeoutTextField.disableProperty().bind(screenSaverToggleSwitch.selectedProperty().not()); + + saveButton = new Button("Save"); + saveButton.setOnAction(event->onSaveButtonClicked()); + + connectDisconnectButton = new Button("Connect"); + connectDisconnectButton.setOnAction(event -> onConnectDisconnectButtonClicked()); + + + Button exitButton = new Button("Exit"); + exitButton.setOnAction(event -> onExitButtonClicked()); + + HBox buttonBar = new HBox(connectDisconnectButton, saveButton); + + shutdownButton = new Button("Shutdown"); + shutdownButton.managedProperty().bind(shutdownButton.visibleProperty()); + shutdownButton.setOnAction(event -> onShutdownButtonClicked()); + + + VBox vBox = new VBox( + generateSubHeading("Connection"), + new HBoxInputBox("Device Name", nickNameTextField, prefWidth), + new HBoxInputBox("Host Name/IP", serverHostNameOrIPTextField, prefWidth), + new HBoxInputBox("Port", serverPortTextField, prefWidth), + generateSubHeading("Client"), + new HBox( + new Label("Current profile"), + SpaceFiller.horizontal(), + clientProfileComboBox + ), + new HBox( + new Label("Theme"), + SpaceFiller.horizontal(), + themeComboBox + ), + new HBox( + new Label("Action Animation"), + SpaceFiller.horizontal(), + animationComboBox + ), + generateSubHeading("Others"), + themesPathInputBox, + iconsPathInputBox, + profilesPathInputBox, + screenTimeoutSecondsHBoxInputBox, + invertRowsColsHBox, + screenSaverHBox, + screenMoverHBox, + tryConnectingToServerIfActionClickedHBox, + fullScreenModeHBox, + connectOnStartupHBox, + vibrateOnActionPressHBox, + startOnBootHBox, + showCursorHBox, + checkForUpdatesButton, + shutdownButton, + factoryResetButton + ); + + + vBox.getStyleClass().add("settings_base_vbox"); + + vBox.setSpacing(10.0); + vBox.setPadding(new Insets(5)); + + ScrollPane scrollPane = new ScrollPane(); + scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); + VBox.setVgrow(scrollPane, Priority.ALWAYS); + scrollPane.getStyleClass().add("settings_base_scroll_pane"); + scrollPane.setContent(vBox); + + vBox.setMinWidth(300); + + vBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(30)); + + + buttonBar.getStyleClass().add("settings_button_bar"); + + + buttonBar.setPadding(new Insets(0,5,5,0)); + buttonBar.setSpacing(5.0); + buttonBar.setAlignment(Pos.CENTER_RIGHT); + + setSpacing(10.0); + + getChildren().addAll( + scrollPane, + buttonBar + ); + + setCache(true); + setCacheHint(CacheHint.SPEED); + + + //Perform platform checks + + if(ClientInfo.getInstance().isPhone()) + { + themesPathInputBox.setVisible(false); + iconsPathInputBox.setVisible(false); + profilesPathInputBox.setVisible(false); + + startOnBootHBox.setVisible(false); + showCursorHBox.setVisible(false); + fullScreenModeHBox.setVisible(false); + shutdownButton.setVisible(false); + } + else + { + invertRowsColsHBox.setVisible(false); + vibrateOnActionPressHBox.setVisible(false); + buttonBar.getChildren().add(exitButton); + + + fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON); + + shutdownButton.setVisible(StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON); + } + + + screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); + screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); + } + + private Label generateSubHeading(String text) + { + Label label = new Label(text); + label.getStyleClass().add("general_settings_sub_heading"); + return label; + } + + private Logger getLogger() + { + return logger; + } + + private void checkForUpdates() + { + new CheckForUpdates(checkForUpdatesButton, + PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() { + @Override + public void handle(ActionEvent actionEvent) { + if(ClientInfo.getInstance().isPhone()) + { + clientListener.openURL(getURL()); + } + else + { + hostServices.showDocument(getURL()); + } + } + }); + } + + private void onFactoryResetButtonClicked() + { + StreamPiAlert confirmation = new StreamPiAlert("Warning","Are you sure?\n" + + "This will erase everything.",StreamPiAlertType.WARNING); + + String yesButton = "Yes"; + String noButton = "No"; + + confirmation.setButtons(yesButton, noButton); + + confirmation.setOnClicked(new StreamPiAlertListener() { + @Override + public void onClick(String s) { + if(s.equals(yesButton)) + { + clientListener.factoryReset(); + } + } + }); + + confirmation.show(); + } + + + public void onExitButtonClicked() + { + clientListener.onCloseRequest(); + clientListener.exitApp(); + } + + public void setDisableStatus(boolean status) + { + saveButton.setDisable(status); + connectDisconnectButton.setDisable(status); + } + + public Button getConnectDisconnectButton() + { + return connectDisconnectButton; + } + + public void onShutdownButtonClicked() + { + clientListener.onCloseRequest(); + + try + { + Runtime.getRuntime().exec("sudo halt"); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void onConnectDisconnectButtonClicked() + { + try + { + if(clientListener.isConnected()) + clientListener.disconnect("Client disconnected from settings"); + else + clientListener.setupClientConnection(); + } + catch (SevereException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleSevereException(e); + } + } + + public void setConnectDisconnectButtonStatus() + { + javafx.application.Platform.runLater(()->{ + setDisableStatus(false); + + if(clientListener.isConnected()) + connectDisconnectButton.setText("Disconnect"); + else + connectDisconnectButton.setText("Connect"); + }); + + } + + public void loadData() throws SevereException + { + Config config = Config.getInstance(); + + nickNameTextField.setText(config.getClientNickName()); + + serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP()); + serverPortTextField.setText(config.getSavedServerPort()+""); + + screenTimeoutTextField.setText(config.getScreenSaverTimeout()+""); + screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); + screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); + animationComboBox.setOptions(animationList); + clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles()); + + int ind = 0; + for(int i = 0;i 65535) + errors.append("* Server Port must be lesser than 65535\n"); + } + catch (NumberFormatException exception) + { + errors.append("* Server Port should be a number.\n"); + } + + + int screenSaverTimeout = -1; + try + { + screenSaverTimeout = Integer.parseInt(serverPortTextField.getText()); + + if(screenSaverTimeout < 15) + errors.append("* Screen Timeout cannot be below 15 seconds.\n"); + } + catch (NumberFormatException exception) + { + errors.append("* Screen Timeout should be a number.\n"); + } + + + if(serverHostNameOrIPTextField.getText().isBlank()) + { + errors.append("* Server IP cannot be empty.\n"); + } + + if(nickNameTextField.getText().isBlank()) + { + errors.append("* Nick name cannot be blank.\n"); + } + else + { + if(nickNameTextField.getText().equals("about maker")) + { + new StreamPiAlert("किसने बनाया ? / কে বানিয়েছে ?","ZGViYXlhbiAtIGluZGlh\n" + + "boka XD").show(); + } + } + + + if(!errors.toString().isEmpty()) + { + exceptionAndAlertHandler.handleMinorException(new MinorException( + "You made mistakes", + "Please fix the errors and try again :\n"+errors.toString() + )); + return; + } + + + + try + { + boolean toBeReloaded = false; + + boolean syncWithServer = false; + + Config config = Config.getInstance(); + + if(!config.getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName())) + { + syncWithServer = true; + + try + { + config.setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName()); + config.save(); + clientListener.initThemes(); + } + catch(SevereException e) + { + exceptionAndAlertHandler.handleSevereException(e); + } + } + + if (!config.getCurrentAnimationName().equals(animationComboBox.getCurrentSelectedItem())) + { + syncWithServer = true; + + try + { + config.setCurrentAnimationFullName(animationComboBox.getCurrentSelectedItem()); + config.save(); + } catch (SevereException e) + { + exceptionAndAlertHandler.handleSevereException(e); + } + } + + if(!config.getClientNickName().equals(nickNameTextField.getText())) + { + syncWithServer = true; + } + + config.setNickName(nickNameTextField.getText()); + + if(port != config.getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP())) + { + syncWithServer = true; + } + + config.setServerPort(port); + config.setServerHostNameOrIP(serverHostNameOrIPTextField.getText()); + + boolean isFullScreen = fullScreenModeToggleSwitch.isSelected(); + + if(config.getIsFullScreenMode() != isFullScreen) + { + toBeReloaded = true; + } + + config.setIsFullScreenMode(isFullScreen); + + + + config.setTryConnectingWhenActionClicked(tryConnectingToServerIfActionClickedToggleSwitch.isSelected()); + + + + boolean startOnBoot = startOnBootToggleSwitch.isSelected(); + + if(config.isStartOnBoot() != startOnBoot) + { + StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), + Main.class.getProtectionDomain().getCodeSource().getLocation(), + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); + + if(startOnBoot) + { + try + { + startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); + config.setStartupIsXMode(StartupFlags.IS_X_MODE); + } + catch (MinorException e) + { + exceptionAndAlertHandler.handleMinorException(e); + startOnBoot = false; + } + } + else + { + boolean result = startAtBoot.delete(); + if(!result) + new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show(); + } + } + + config.setStartOnBoot(startOnBoot); + + if(!config.isShowCursor() ==showCursorToggleSwitch.isSelected()) + toBeReloaded = true; + + config.setShowCursor(showCursorToggleSwitch.isSelected()); + + + if(!config.getThemesPath().equals(themesPathTextField.getText())) + toBeReloaded = true; + + config.setThemesPath(themesPathTextField.getText()); + + + if(!config.getIconsPath().equals(iconsPathTextField.getText())) + toBeReloaded = true; + + config.setIconsPath(iconsPathTextField.getText()); + + if(!config.getProfilesPath().equals(profilesPathTextField.getText())) + toBeReloaded = true; + + config.setProfilesPath(profilesPathTextField.getText()); + + if(config.isScreenSaverEnabled() != screenSaverToggleSwitch.isSelected()) + toBeReloaded = true; + + config.setScreenSaverEnabled(screenSaverToggleSwitch.isSelected()); + + if(config.isScreenMoverEnabled() != screenMoverToggleSwitch.isSelected()) + toBeReloaded = true; + + config.setScreenMoverEnabled(screenMoverToggleSwitch.isSelected()); + + if(!(screenSaverTimeout+"").equals(screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) + { + config.setScreenSaverTimeout(screenTimeoutTextField.getText()); + + clientListener.getScreenSaver().setTimeout(config.getScreenSaverTimeout()); + clientListener.getScreenSaver().restartTimer(); + } + + + config.setConnectOnStartup(connectOnStartupToggleSwitch.isSelected()); + + boolean isVibrateOnActionClicked = vibrateOnActionPressToggleSwitch.isSelected(); + + if(config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked) + { + if(VibrationService.create().isEmpty()) + { + isVibrateOnActionClicked = false; + new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show(); + } + } + + config.setVibrateOnActionClicked(isVibrateOnActionClicked); + config.setInvertRowsColsOnDeviceRotate(invertRowsColsToggleSwitch.isSelected()); + + config.save(); + + loadData(); + + + if(syncWithServer) + { + if(clientListener.isConnected()) + { + clientListener.getClient().updateClientDetails(); + } + } + + if(toBeReloaded) + { + if(!ClientInfo.getInstance().isPhone() && !config.getIsFullScreenMode()) + { + config.setStartupWindowSize(clientListener.getStageWidth(), clientListener.getStageHeight()); + config.save(); + } + + clientListener.init(); + clientListener.renderRootDefaultProfile(); + } + } + catch (SevereException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleSevereException(e); + } + catch (MinorException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleMinorException(e); + } + } + +} diff --git a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java old mode 100644 new mode 100755 index 818461aa..1f6ba834 --- a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java +++ b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java @@ -1,73 +1,73 @@ -package com.stream_pi.client.window.settings; - -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.window.settings.About.AboutTab; - -import javafx.application.HostServices; -import javafx.event.Event; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.*; -import javafx.scene.input.SwipeEvent; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; - -public class SettingsBase extends VBox -{ - private TabPane tabPane; - - private GeneralTab generalTab; - - private Button closeButton; - - private HostServices hostServices; - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - public SettingsBase(HostServices hostServices, ExceptionAndAlertHandler exceptionAndAlertHandler, - ClientListener clientListener) - { - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.hostServices = hostServices; - - tabPane = new TabPane(); - tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); - tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); - VBox.setVgrow(tabPane, Priority.ALWAYS); - - Tab generalSettingsTab = new Tab("Settings"); - generalTab = new GeneralTab(exceptionAndAlertHandler, clientListener, hostServices); - generalSettingsTab.setContent(generalTab); - - Tab aboutTab = new Tab("About"); - aboutTab.setContent(new AboutTab(clientListener)); - - tabPane.getTabs().addAll(generalSettingsTab, aboutTab); - - setAlignment(Pos.TOP_RIGHT); - - closeButton = new Button("Close"); - VBox.setMargin(closeButton, new Insets(5.0)); - - getChildren().addAll(tabPane, closeButton); - - setCache(true); - setCacheHint(CacheHint.SPEED); - } - - public void setDefaultTabToGeneral() - { - tabPane.getSelectionModel().selectFirst(); - } - - public Button getCloseButton() - { - return closeButton; - } - - public GeneralTab getGeneralTab() - { - return generalTab; - } -} +package com.stream_pi.client.window.settings; + +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.client.window.settings.About.AboutTab; + +import javafx.application.HostServices; +import javafx.event.Event; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.*; +import javafx.scene.input.SwipeEvent; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; + +public class SettingsBase extends VBox +{ + private TabPane tabPane; + + private GeneralTab generalTab; + + private Button closeButton; + + private HostServices hostServices; + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + public SettingsBase(HostServices hostServices, ExceptionAndAlertHandler exceptionAndAlertHandler, + ClientListener clientListener) + { + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.hostServices = hostServices; + + tabPane = new TabPane(); + tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); + tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); + VBox.setVgrow(tabPane, Priority.ALWAYS); + + Tab generalSettingsTab = new Tab("Settings"); + generalTab = new GeneralTab(exceptionAndAlertHandler, clientListener, hostServices); + generalSettingsTab.setContent(generalTab); + + Tab aboutTab = new Tab("About"); + aboutTab.setContent(new AboutTab(clientListener)); + + tabPane.getTabs().addAll(generalSettingsTab, aboutTab); + + setAlignment(Pos.TOP_RIGHT); + + closeButton = new Button("Close"); + VBox.setMargin(closeButton, new Insets(5.0)); + + getChildren().addAll(tabPane, closeButton); + + setCache(true); + setCacheHint(CacheHint.SPEED); + } + + public void setDefaultTabToGeneral() + { + tabPane.getSelectionModel().selectFirst(); + } + + public Button getCloseButton() + { + return closeButton; + } + + public GeneralTab getGeneralTab() + { + return generalTab; + } +} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java old mode 100644 new mode 100755 index dbb09f65..785d6866 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,32 +1,30 @@ -module com.stream_pi.client { - requires javafx.base; - requires javafx.graphics; - requires javafx.controls; - requires org.kordamp.iconli.core; - requires org.kordamp.ikonli.javafx; - - requires com.gluonhq.attach.lifecycle; - requires com.gluonhq.attach.util; - requires com.gluonhq.attach.storage; - requires com.gluonhq.attach.browser; - requires com.gluonhq.attach.vibration; - requires com.gluonhq.attach.orientation; - - requires java.management; - - requires java.xml; - - requires AnimateFX; - - opens com.stream_pi.client.window.settings.About to javafx.base; - - requires com.stream_pi.util; - requires com.stream_pi.theme_api; - requires com.stream_pi.action_api; - - requires org.kordamp.ikonli.fontawesome5; - - requires org.controlsfx.controls; - - exports com.stream_pi.client; +module com.stream_pi.client { + requires javafx.base; + requires javafx.graphics; + requires javafx.controls; + requires org.kordamp.iconli.core; + requires org.kordamp.ikonli.javafx; + + requires com.gluonhq.attach.lifecycle; + requires com.gluonhq.attach.util; + requires com.gluonhq.attach.storage; + requires com.gluonhq.attach.browser; + requires com.gluonhq.attach.vibration; + requires com.gluonhq.attach.orientation; + + requires java.management; + + requires java.xml; + + opens com.stream_pi.client.window.settings.About to javafx.base; + + requires com.stream_pi.util; + requires com.stream_pi.theme_api; + requires com.stream_pi.action_api; + + requires org.kordamp.ikonli.fontawesome5; + + requires org.controlsfx.controls; + + exports com.stream_pi.client; } \ No newline at end of file diff --git a/src/main/resources/META-INF/native-image/resource-config.json b/src/main/resources/META-INF/native-image/resource-config.json old mode 100644 new mode 100755 index 4d36bca6..ada64776 --- a/src/main/resources/META-INF/native-image/resource-config.json +++ b/src/main/resources/META-INF/native-image/resource-config.json @@ -1,7 +1,7 @@ -{ - "resources": [ - {"pattern": ".*/Default.zip$"}, - {"pattern": ".*/build-date$"}, - {"pattern": ".*/(EmailBoard|NumericBoard|TextBoard|UriBoard).txt$"} - ] -} +{ + "resources": [ + {"pattern": ".*/Default.zip$"}, + {"pattern": ".*/build-date$"}, + {"pattern": ".*/(EmailBoard|NumericBoard|TextBoard|UriBoard).txt$"} + ] +} diff --git a/src/main/resources/META-INF/native-image/serialization-config.json b/src/main/resources/META-INF/native-image/serialization-config.json old mode 100644 new mode 100755 index e9ed2160..3eda68ef --- a/src/main/resources/META-INF/native-image/serialization-config.json +++ b/src/main/resources/META-INF/native-image/serialization-config.json @@ -1,11 +1,11 @@ -[ - {"name":"com.stream_pi.util.comms.Message"}, - {"name": "java.lang.String"}, - {"name": "java.lang.String[]"}, - {"name": "byte"}, - {"name": "byte[]"}, - {"name": "int"}, - {"name": "int[]"}, - {"name": "double"}, - {"name": "double[]"} +[ + {"name":"com.stream_pi.util.comms.Message"}, + {"name": "java.lang.String"}, + {"name": "java.lang.String[]"}, + {"name": "byte"}, + {"name": "byte[]"}, + {"name": "int"}, + {"name": "int[]"}, + {"name": "double"}, + {"name": "double[]"} ] \ No newline at end of file diff --git a/src/main/resources/com/stream_pi/client/Default.zip b/src/main/resources/com/stream_pi/client/Default.zip old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/Roboto.ttf b/src/main/resources/com/stream_pi/client/Roboto.ttf old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/app_icon.png b/src/main/resources/com/stream_pi/client/app_icon.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/default_icons.css b/src/main/resources/com/stream_pi/client/default_icons.css old mode 100644 new mode 100755 index c37e4968..e41e344c --- a/src/main/resources/com/stream_pi/client/default_icons.css +++ b/src/main/resources/com/stream_pi/client/default_icons.css @@ -1,28 +1,28 @@ -.alert_error_icon -{ - -fx-icon-color: RED; -} - -.alert_information_icon -{ - -fx-icon-color: BLUE; -} - -.alert_warning_icon -{ - -fx-icon-color: #ffcc00; -} - -.action_box_error_icon{ - -fx-icon-color:red; -} - -.action_box_toggle_on -{ - -fx-icon-code: fas-toggle-on; -} - -.action_box_toggle_off -{ - -fx-icon-code: fas-toggle-off; +.alert_error_icon +{ + -fx-icon-color: RED; +} + +.alert_information_icon +{ + -fx-icon-color: BLUE; +} + +.alert_warning_icon +{ + -fx-icon-color: #ffcc00; +} + +.action_box_error_icon{ + -fx-icon-color:red; +} + +.action_box_toggle_on +{ + -fx-icon-code: fas-toggle-on; +} + +.action_box_toggle_off +{ + -fx-icon-code: fas-toggle-off; } \ No newline at end of file diff --git a/src/main/resources/com/stream_pi/client/icon16x16.png b/src/main/resources/com/stream_pi/client/icon16x16.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/icon24x24.png b/src/main/resources/com/stream_pi/client/icon24x24.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/icon256x256.png b/src/main/resources/com/stream_pi/client/icon256x256.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/icon32x32.png b/src/main/resources/com/stream_pi/client/icon32x32.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/icon48x48.png b/src/main/resources/com/stream_pi/client/icon48x48.png old mode 100644 new mode 100755 diff --git a/src/main/resources/com/stream_pi/client/style.css b/src/main/resources/com/stream_pi/client/style.css old mode 100644 new mode 100755 index ec02a2ca..38568d15 --- a/src/main/resources/com/stream_pi/client/style.css +++ b/src/main/resources/com/stream_pi/client/style.css @@ -1,220 +1,220 @@ -.root { - -fx-font-family : 'Roboto'; -} - - -.action_box -{ - -fx-border-width: 1px; - -fx-border-color : grey; -} - -.action_box_icon_present -{ - -} - -.action_box_icon_not_present -{ - -} - -.action_box_onclick -{ - -} - -.settings_heading_label -{ - -fx-font-size: 20; -} - -.alert_header -{ - -fx-padding: 5; -} - -.alert_pane -{ - -fx-border-width : 5; - -fx-border-radius : 5; - -fx-background-radius : 5; - -fx-max-width : 400; - -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 ); -} - -.alert_header_icon -{ - -fx-icon-size : 30; -} - -.alert_content_pane -{ - -fx-padding: 5; -} - -.alert_pane_parent, .combobox_pane_parent -{ - -fx-background-color : rgba(0,0,0,0.5); -} - -.alert_pane_header_text -{ - -fx-font-size: 18; -} - -.alert_button_bar -{ - -fx-alignment: CENTER_RIGHT; - -fx-spacing: 5; - -fx-padding: 5; -} - -.alert_scroll_pane -{ - -fx-max-height : 300; -} - - -.combo_box -{ - -fx-alignment:CENTER_LEFT; - -fx-pref-width:200; - -fx-padding: 5; - -fx-border-width : 1; - -fx-border-color : grey; - -fx-border-radius : 5; -} - -.combo_box_popup -{ - -fx-border-width : 5; - -fx-border-radius : 5; - -fx-background-radius : 5; - -fx-max-height : 300; - -fx-max-width : 410; - -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 ); -} - -.combo_box_popup_vbox -{ - -fx-padding: 5 5 0 5; - -fx-spacing:5; -} - -.combo_box_drop_down_icon -{ - -fx-icon-code: fas-caret-down; - -fx-icon-size: 14; -} - -.action_grid_pane_parent -{ - -fx-background-color:transparent; -} - -.first_time_use_pane_heading_label -{ - -fx-font-size: 20; -} - -.first_time_use_pane_stackpane -{ - -} - -.first_time_use_pane_welcome -{ - -} - -.first_time_use_pane_license -{ - -fx-spacing : 10; -} - -.first_time_use_pane_final_config -{ - -} - -.first_time_use_pane_final_config_label -{ - -} - -.first_time_use_welcome_pane_welcome_label -{ - -fx-font-size: 30; -} - -.first_time_use_welcome_pane_next_to_continue_label -{ - -fx-font-size: 15; -} - -.scroll-pane -{ - -fx-focus-color:transparent; - -fx-faint-focus-color:transparent; -} - -/*Alert Classes added to default stylesheet to show init error, if occurs */ -.action_box_display_text_label -{ - -fx-background-color : transparent; - /*-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 5, 0.3, 0.0, 0.0);*/ -} - -.alert_pane -{ - -fx-background-color : white; - -fx-border-color : white; -} - -.alert_content_pane -{ - -fx-background-color: white; - -fx-padding: 5; -} - -.alert_scroll_pane -{ - -fx-background: white; - -fx-border-color:white; -} - -.alert_button_bar -{ - -fx-background-color:white; -} - - -.about_donate_hyperlink -{ - -fx-padding : 10 0 0 0; - -fx-font-size : 25; - -fx-border-color: transparent; -} - -.screensaver -{ - -fx-background-color: black; -} - -.separator_ui_label -{ - -fx-text-fill: grey; -} - - -.action_grid_pane_parent, .action_grid_pane -{ - -fx-background: transparent; -} - -.general_settings_sub_heading -{ - -fx-font-size: 18; - -fx-padding: 10 0 5 0; +.root { + -fx-font-family : 'Roboto'; +} + + +.action_box +{ + -fx-border-width: 1px; + -fx-border-color : grey; +} + +.action_box_icon_present +{ + +} + +.action_box_icon_not_present +{ + +} + +.action_box_onclick +{ + +} + +.settings_heading_label +{ + -fx-font-size: 20; +} + +.alert_header +{ + -fx-padding: 5; +} + +.alert_pane +{ + -fx-border-width : 5; + -fx-border-radius : 5; + -fx-background-radius : 5; + -fx-max-width : 400; + -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 ); +} + +.alert_header_icon +{ + -fx-icon-size : 30; +} + +.alert_content_pane +{ + -fx-padding: 5; +} + +.alert_pane_parent, .combobox_pane_parent +{ + -fx-background-color : rgba(0,0,0,0.5); +} + +.alert_pane_header_text +{ + -fx-font-size: 18; +} + +.alert_button_bar +{ + -fx-alignment: CENTER_RIGHT; + -fx-spacing: 5; + -fx-padding: 5; +} + +.alert_scroll_pane +{ + -fx-max-height : 300; +} + + +.combo_box +{ + -fx-alignment:CENTER_LEFT; + -fx-pref-width:200; + -fx-padding: 5; + -fx-border-width : 1; + -fx-border-color : grey; + -fx-border-radius : 5; +} + +.combo_box_popup +{ + -fx-border-width : 5; + -fx-border-radius : 5; + -fx-background-radius : 5; + -fx-max-height : 300; + -fx-max-width : 410; + -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 ); +} + +.combo_box_popup_vbox +{ + -fx-padding: 5 5 0 5; + -fx-spacing:5; +} + +.combo_box_drop_down_icon +{ + -fx-icon-code: fas-caret-down; + -fx-icon-size: 14; +} + +.action_grid_pane_parent +{ + -fx-background-color:transparent; +} + +.first_time_use_pane_heading_label +{ + -fx-font-size: 20; +} + +.first_time_use_pane_stackpane +{ + +} + +.first_time_use_pane_welcome +{ + +} + +.first_time_use_pane_license +{ + -fx-spacing : 10; +} + +.first_time_use_pane_final_config +{ + +} + +.first_time_use_pane_final_config_label +{ + +} + +.first_time_use_welcome_pane_welcome_label +{ + -fx-font-size: 30; +} + +.first_time_use_welcome_pane_next_to_continue_label +{ + -fx-font-size: 15; +} + +.scroll-pane +{ + -fx-focus-color:transparent; + -fx-faint-focus-color:transparent; +} + +/*Alert Classes added to default stylesheet to show init error, if occurs */ +.action_box_display_text_label +{ + -fx-background-color : transparent; + /*-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 5, 0.3, 0.0, 0.0);*/ +} + +.alert_pane +{ + -fx-background-color : white; + -fx-border-color : white; +} + +.alert_content_pane +{ + -fx-background-color: white; + -fx-padding: 5; +} + +.alert_scroll_pane +{ + -fx-background: white; + -fx-border-color:white; +} + +.alert_button_bar +{ + -fx-background-color:white; +} + + +.about_donate_hyperlink +{ + -fx-padding : 10 0 0 0; + -fx-font-size : 25; + -fx-border-color: transparent; +} + +.screensaver +{ + -fx-background-color: black; +} + +.separator_ui_label +{ + -fx-text-fill: grey; +} + + +.action_grid_pane_parent, .action_grid_pane +{ + -fx-background: transparent; +} + +.general_settings_sub_heading +{ + -fx-font-size: 18; + -fx-padding: 10 0 5 0; } \ No newline at end of file diff --git a/style_classes.txt b/style_classes.txt old mode 100644 new mode 100755 index a7c6cb3e..3bdb3602 --- a/style_classes.txt +++ b/style_classes.txt @@ -1,44 +1,44 @@ -This list is outdated. Some classes are missing/no longer work. This will be updated soon - -Dashboard - dashboard - Settings HBox Bar - dashboard_settings_button_parent - Settings Button - dashboard_settings_button - Icon - dashboard_settings_button_icon - - - Action Grid Pane Parent - action_grid_pane_parent - Action Grid Pane (Grid Pane) - action_grid_pane - Action Box - action_box - if folder back button : - Icon : folder_action_back_button_icon - - Is Icon Present ? - yes : action_box_icon_present - no : action_box_icon_not_present - Is Action Valid (is plugin by module name found) ? - yes : action_box_valid - no : action_box_invalid - - Action On Click : action_box_onclick - - Error Icon - action_box_error_icon - - Display Text Label - action_box_display_text_label - -Settings - settings_base - Settings heading label - settings_heading_label - Scroll Pane - settings_base_scroll_pane - Base VBox - settings_base_vbox - - Button Bar - settings_button_bar - -First Time Use - first_time_use_pane - Heading Label - first_time_use_pane_heading_label - Stack Pane - first_time_use_pane_stackpane - Welcome Pane - first_time_use_pane_welcome - Head - first_time_use_welcome_pane_welcome_label - Small Label - first_time_use_welcome_pane_next_to_continue_label - License Pane - first_time_use_pane_license - Final Config - first_time_use_pane_final_config - Scroll Pane - first_time_use_final_config_pane_scroll_pane +This list is outdated. Some classes are missing/no longer work. This will be updated soon + +Dashboard - dashboard + Settings HBox Bar - dashboard_settings_button_parent + Settings Button - dashboard_settings_button + Icon - dashboard_settings_button_icon + + + Action Grid Pane Parent - action_grid_pane_parent + Action Grid Pane (Grid Pane) - action_grid_pane + Action Box - action_box + if folder back button : + Icon : folder_action_back_button_icon + + Is Icon Present ? + yes : action_box_icon_present + no : action_box_icon_not_present + Is Action Valid (is plugin by module name found) ? + yes : action_box_valid + no : action_box_invalid + + Action On Click : action_box_onclick + + Error Icon - action_box_error_icon + + Display Text Label - action_box_display_text_label + +Settings - settings_base + Settings heading label - settings_heading_label + Scroll Pane - settings_base_scroll_pane + Base VBox - settings_base_vbox + + Button Bar - settings_button_bar + +First Time Use - first_time_use_pane + Heading Label - first_time_use_pane_heading_label + Stack Pane - first_time_use_pane_stackpane + Welcome Pane - first_time_use_pane_welcome + Head - first_time_use_welcome_pane_welcome_label + Small Label - first_time_use_welcome_pane_next_to_continue_label + License Pane - first_time_use_pane_license + Final Config - first_time_use_pane_final_config + Scroll Pane - first_time_use_final_config_pane_scroll_pane Button Bar - first_time_use_pane_button_bar \ No newline at end of file From b83f6bb079f00adb8e8b759e06a34a4b7a01f6f9 Mon Sep 17 00:00:00 2001 From: quimodotcom Date: Mon, 30 Aug 2021 18:39:49 +0100 Subject: [PATCH 08/12] animations finally work well. --- .DS_Store | Bin 0 -> 6148 bytes .../client/animations/AnimationFX.java | 2 - .../stream_pi/client/animations/BounceIn.java | 72 ++++++++++++++++++ .../client/animations/BounceOut.java | 61 +++++++++++++++ .../stream_pi/client/animations/FadeIn.java | 46 +++++++++++ .../stream_pi/client/animations/FadeOut.java | 41 ++++++++++ .../stream_pi/client/animations/RollIn.java | 53 +++++++++++++ .../stream_pi/client/animations/RollOut.java | 53 +++++++++++++ .../stream_pi/client/animations/RotateIn.java | 50 ++++++++++++ .../client/animations/RotateOut.java | 48 ++++++++++++ .../stream_pi/client/animations/ZoomIn.java | 54 +++++++++++++ .../stream_pi/client/animations/ZoomOut.java | 57 ++++++++++++++ .../java/com/stream_pi/client/io/Config.java | 2 +- .../dashboard/actiongridpane/ActionBox.java | 33 +++++++- .../settings/About/ContributorsTab.java | 6 +- .../client/window/settings/GeneralTab.java | 32 ++++---- 16 files changed, 584 insertions(+), 26 deletions(-) create mode 100644 .DS_Store create mode 100755 src/main/java/com/stream_pi/client/animations/BounceIn.java create mode 100755 src/main/java/com/stream_pi/client/animations/BounceOut.java create mode 100755 src/main/java/com/stream_pi/client/animations/FadeIn.java create mode 100755 src/main/java/com/stream_pi/client/animations/FadeOut.java create mode 100755 src/main/java/com/stream_pi/client/animations/RollIn.java create mode 100755 src/main/java/com/stream_pi/client/animations/RollOut.java create mode 100755 src/main/java/com/stream_pi/client/animations/RotateIn.java create mode 100755 src/main/java/com/stream_pi/client/animations/RotateOut.java create mode 100755 src/main/java/com/stream_pi/client/animations/ZoomIn.java create mode 100755 src/main/java/com/stream_pi/client/animations/ZoomOut.java diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000000000000000000000000000000000000..b2679f66a60ccc09e0018f6f776348f20ec8a4fa GIT binary patch literal 6148 zcmeHKO>fgc5S>jz;}9VQ38Y?-EOCuW+Crp?i<_p0O2DB;Z~zqSI06gD8^sQ36-Dy7 z{1~qM68;M(c(c2a8YdjMAVhbfnYSPFZ13B6*GojAH;eX(T14c)8Edx@wix%bZ&<~& zaHmk$$SFHZYqxglPTgrb@BEK)?&m>1%X-1|4cA^unS`ry5Wb2> z^Fiz0iA?h#PDfKkh@%lw-oB30NX~n5mPVQ4`ntnuIE_JTcdB z+V11S?sD01?mv9=^nCCs8K?3JPYx4URh8W_xB?!(8S`gF$SorF1j2y-+s4hGh2EjluC=>%!l|**LGzs3-_# iJ5~kWig)44(C2ai=ou_Dq6KC@1e6RmSOxy70>1zaeVFb5 literal 0 HcmV?d00001 diff --git a/src/main/java/com/stream_pi/client/animations/AnimationFX.java b/src/main/java/com/stream_pi/client/animations/AnimationFX.java index 0d1ad181..faa54c7b 100755 --- a/src/main/java/com/stream_pi/client/animations/AnimationFX.java +++ b/src/main/java/com/stream_pi/client/animations/AnimationFX.java @@ -41,8 +41,6 @@ public AnimationFX(Node node) { public AnimationFX() { hasNextAnimation = false; this.reset = false; - - } /** diff --git a/src/main/java/com/stream_pi/client/animations/BounceIn.java b/src/main/java/com/stream_pi/client/animations/BounceIn.java new file mode 100755 index 00000000..38263d1e --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/BounceIn.java @@ -0,0 +1,72 @@ +package com.stream_pi.client.animations; + +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class BounceIn extends AnimationFX { + + + /** + * Create new BounceIn + * + * @param node The node to affect + */ + public BounceIn(Node node) { + super(node); + + } + + public BounceIn() { + super(); + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setScaleX(1); + getNode().setScaleY(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 0, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleXProperty(), 0.3, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 0.3, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(getNode().scaleXProperty(), 1.1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 1.1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().scaleXProperty(), 0.9, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 0.9, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleXProperty(), 1.03, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 1.03, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().scaleXProperty(), 0.97, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 0.97, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleXProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)), + new KeyValue(getNode().scaleYProperty(), 1, Interpolator.SPLINE(0.215, 0.610, 0.355, 1.000)) + ) + + )); + + } +} diff --git a/src/main/java/com/stream_pi/client/animations/BounceOut.java b/src/main/java/com/stream_pi/client/animations/BounceOut.java new file mode 100755 index 00000000..518cc51d --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/BounceOut.java @@ -0,0 +1,61 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class BounceOut extends AnimationFX { + + /** + * Create new BounceOut animation + * + * @param node The node to affect + */ + public BounceOut(final Node node) { + super(node); + } + + public BounceOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setScaleX(1); + getNode().setScaleY(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(getNode().scaleXProperty(), 0.9, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.9, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(550), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.3, AnimateFXInterpolator.EASE) + ) + + )); + } + + +} diff --git a/src/main/java/com/stream_pi/client/animations/FadeIn.java b/src/main/java/com/stream_pi/client/animations/FadeIn.java new file mode 100755 index 00000000..208afa3a --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/FadeIn.java @@ -0,0 +1,46 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ + +public class FadeIn extends AnimationFX { + + /** + * Create a new FadeIn animation + * + * @param node the node to affect + */ + public FadeIn(Node node) { + super(node); + } + + public FadeIn() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ) + + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/FadeOut.java b/src/main/java/com/stream_pi/client/animations/FadeOut.java new file mode 100755 index 00000000..2827c85e --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/FadeOut.java @@ -0,0 +1,41 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class FadeOut extends AnimationFX { + /** + * Create a new FadeOut animation + * @param node the node to affect + */ + public FadeOut(Node node) { + super(node); + } + + public FadeOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/RollIn.java b/src/main/java/com/stream_pi/client/animations/RollIn.java new file mode 100755 index 00000000..afef776e --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RollIn.java @@ -0,0 +1,53 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RollIn extends AnimationFX { + + /** + * Create new RollIn + * + * @param node The node to affect + */ + public RollIn(Node node) { + super(node); + } + + public RollIn() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setTranslateX(0); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().translateXProperty(), -getNode().getBoundsInLocal().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), -120, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } + + +} + diff --git a/src/main/java/com/stream_pi/client/animations/RollOut.java b/src/main/java/com/stream_pi/client/animations/RollOut.java new file mode 100755 index 00000000..018ed4f1 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RollOut.java @@ -0,0 +1,53 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RollOut extends AnimationFX { + + /** + * Create new RollOut + * + * @param node The node to affect + */ + public RollOut(Node node) { + super(node); + } + + public RollOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setTranslateX(0); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().translateXProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().translateXProperty(), getNode().getBoundsInLocal().getWidth(), AnimateFXInterpolator.EASE), + new KeyValue(getNode().rotateProperty(), 120, AnimateFXInterpolator.EASE) + ) + )); + } + + +} + diff --git a/src/main/java/com/stream_pi/client/animations/RotateIn.java b/src/main/java/com/stream_pi/client/animations/RotateIn.java new file mode 100755 index 00000000..5450bd40 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RotateIn.java @@ -0,0 +1,50 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RotateIn extends AnimationFX { + + /** + * Create new RotateIn + * + * @param node The node to affect + */ + public RotateIn(Node node) { + super(node); + } + + public RotateIn() { + } + + @Override + AnimationFX resetNode() { + getNode().setRotate(0); + getNode().setOpacity(1); + return this; + } + + @Override + void initTimeline() { + getNode().setRotationAxis(Rotate.Z_AXIS); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().rotateProperty(), -200, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } + + +} diff --git a/src/main/java/com/stream_pi/client/animations/RotateOut.java b/src/main/java/com/stream_pi/client/animations/RotateOut.java new file mode 100755 index 00000000..db59e620 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/RotateOut.java @@ -0,0 +1,48 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.scene.transform.Rotate; +import javafx.util.Duration; + +/** + * @author Loïc Sculier aka typhon0 + */ +public class RotateOut extends AnimationFX { + + /** + * Create new RotateOut + * + * @param node The node to affect + */ + public RotateOut(Node node) { + super(node); + } + + public RotateOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setRotate(0); + return this; + } + + @Override + void initTimeline() { + getNode().setRotationAxis(Rotate.Z_AXIS); + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().rotateProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().rotateProperty(), 200, AnimateFXInterpolator.EASE), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} diff --git a/src/main/java/com/stream_pi/client/animations/ZoomIn.java b/src/main/java/com/stream_pi/client/animations/ZoomIn.java new file mode 100755 index 00000000..f0346955 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/ZoomIn.java @@ -0,0 +1,54 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class ZoomIn extends AnimationFX { + + /** + * Create new ZoomIn + * + * @param node The node to affect + */ + public ZoomIn(Node node) { + super(node); + } + + public ZoomIn() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 1, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/animations/ZoomOut.java b/src/main/java/com/stream_pi/client/animations/ZoomOut.java new file mode 100755 index 00000000..e67bbfed --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/ZoomOut.java @@ -0,0 +1,57 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class ZoomOut extends AnimationFX { + + /** + * Create new ZoomOut + * + * @param node The node to affect + */ + public ZoomOut(Node node) { + super(node); + } + + public ZoomOut() { + } + + @Override + AnimationFX resetNode() { + getNode().setOpacity(1); + getNode().setScaleX(1); + getNode().setScaleY(1); + getNode().setScaleZ(1); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleXProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleYProperty(), 0.3, AnimateFXInterpolator.EASE), + new KeyValue(getNode().scaleZProperty(), 0.3, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + diff --git a/src/main/java/com/stream_pi/client/io/Config.java b/src/main/java/com/stream_pi/client/io/Config.java index b2d5009d..1ec2c822 100755 --- a/src/main/java/com/stream_pi/client/io/Config.java +++ b/src/main/java/com/stream_pi/client/io/Config.java @@ -205,7 +205,7 @@ public void setCurrentThemeFullName(String name) document.getElementsByTagName("current-theme-full-name").item(0).setTextContent(name); } - public void setCurrentAnimationFullName(String name) { + public void setCurrentAnimationName(String name) { this.document.getElementsByTagName("current-animation-name").item(0).setTextContent(name); } diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java index 3659682e..9fc488cd 100755 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java @@ -268,33 +268,58 @@ public void setAction(Action action) public void playActionAnimation() throws SevereException { Config config = Config.getInstance(); + switch (config.getCurrentAnimationName()) { case "None": return; case "Flip": new Flip(getChildren().get(1)).play(); - case "Flash": - new Flash(getChildren().get(1)).play(); + break; case "Bounce": new Bounce(getChildren().get(1)).play(); + break; + case "Bounce In/Out": + new BounceOut(getChildren().get(1)).playOnFinished(new BounceIn(getChildren().get(1))).play(); + break; + case "Fade In/Out": + new FadeOut(getChildren().get(1)).playOnFinished(new FadeIn(getChildren().get(1))).play(); + break; + case "Roll In/Out": + new RollOut(getChildren().get(1)).playOnFinished(new RollIn(getChildren().get(1))).play(); + break; + case "Rotate In/Out": + new RotateOut(getChildren().get(1)).playOnFinished(new RotateIn(getChildren().get(1))).play(); + break; + case "Zoom In/Out": + new ZoomOut(getChildren().get(1)).playOnFinished(new ZoomIn(getChildren().get(1))).play(); + break; case "Jack In The Box": new JackInTheBox(getChildren().get(1)).play(); + break; case "Swing": new Swing(getChildren().get(1)).play(); + break; case "Jello": new Jello(getChildren().get(1)).play(); + break; case "Pulse": new Pulse(getChildren().get(1)).play(); + break; case "RubberBand": new RubberBand(getChildren().get(1)).play(); + break; case "Shake": new Shake(getChildren().get(1)).play(); + break; case "Tada": new Tada(getChildren().get(1)).play(); + break; case "Wobble": new Wobble(getChildren().get(1)).play(); - } - Logger.getLogger("").warning("Invalid Option/n Please contact quimodotcom to solve this error!"); + break; + default: + Logger.getLogger("").warning("Invalid Option/n Please contact quimodotcom to solve this error!"); + } } public void init() diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java index ad7711c5..9b7339ea 100755 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java @@ -59,7 +59,11 @@ public ContributorsTab() new Contributor("Abhinay Agarwal (abhinayagarwal)", "abhinay_agarwal@live.com", "Refactoring, Fixes", - "India") + "India"), + new Contributor("Evan Donald (quimodotcom)", + "evandonald01@gmail.com", + "Action Animations", + "United Kingdom") ); getChildren().addAll(tableView); diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java index e996f4d3..dc0110a6 100755 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -107,10 +107,7 @@ public class GeneralTab extends VBox public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener, HostServices hostServices) { - this.animationList = Arrays.asList(new String[] { - "None", "Bounce", "Flip", "Flash", "Jack In The Box", "Jello", "Pulse", "RubberBand", "Shake", "Swing", "Tada", - "Wobble" - }); + animationList = Arrays.asList("None", "Bounce", "Bounce In/Out", "Fade In/Out", "Flash", "Flip", "Jack In The Box", "Jello", "Pulse", "Roll In/Out", "Rotate In/Out", "RubberBand", "Shake", "Swing", "Tada", "Wobble", "Zoom In/Out"); this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.clientListener = clientListener; this.hostServices = hostServices; @@ -495,21 +492,21 @@ public void loadData() throws SevereException themeComboBox.setOptions(clientListener.getThemes().getThemeList()); int ind2 = 0; - for(int i = 0;i 65535) new StreamPiAlert("किसने बनाया ? / কে বানিয়েছে ?","ZGViYXlhbiAtIGluZGlh\n" + "boka XD").show(); } + + if(nickNameTextField.getText().equals("quimo is pog")) + { + new StreamPiAlert("wow! i am very cool! i found an easter egg made by quimo!\n" + + "good job").show(); + } } @@ -624,14 +627,7 @@ else if(port > 65535) { syncWithServer = true; - try - { - config.setCurrentAnimationFullName(animationComboBox.getCurrentSelectedItem()); - config.save(); - } catch (SevereException e) - { - exceptionAndAlertHandler.handleSevereException(e); - } + config.setCurrentAnimationName(animationComboBox.getCurrentSelectedItem()); } if(!config.getClientNickName().equals(nickNameTextField.getText())) From ff565810d8a628944d96452c1727a8458dade4ef Mon Sep 17 00:00:00 2001 From: quimodotcom Date: Mon, 30 Aug 2021 20:04:28 +0100 Subject: [PATCH 09/12] Delete .DS_Store --- .DS_Store | Bin 6148 -> 0 bytes 1 file changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .DS_Store diff --git a/.DS_Store b/.DS_Store deleted file mode 100644 index b2679f66a60ccc09e0018f6f776348f20ec8a4fa..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 6148 zcmeHKO>fgc5S>jz;}9VQ38Y?-EOCuW+Crp?i<_p0O2DB;Z~zqSI06gD8^sQ36-Dy7 z{1~qM68;M(c(c2a8YdjMAVhbfnYSPFZ13B6*GojAH;eX(T14c)8Edx@wix%bZ&<~& zaHmk$$SFHZYqxglPTgrb@BEK)?&m>1%X-1|4cA^unS`ry5Wb2> z^Fiz0iA?h#PDfKkh@%lw-oB30NX~n5mPVQ4`ntnuIE_JTcdB z+V11S?sD01?mv9=^nCCs8K?3JPYx4URh8W_xB?!(8S`gF$SorF1j2y-+s4hGh2EjluC=>%!l|**LGzs3-_# iJ5~kWig)44(C2ai=ou_Dq6KC@1e6RmSOxy70>1zaeVFb5 From bc6a44b00b0edeabf5772f8d3f1e6a69056c6738 Mon Sep 17 00:00:00 2001 From: quimodotcom Date: Tue, 31 Aug 2021 19:35:10 +0100 Subject: [PATCH 10/12] duration changes to animations and added features --- .../client/animations/BounceOut.java | 6 +- .../stream_pi/client/animations/FadeOut.java | 2 +- .../client/animations/ShakeUpDown.java | 75 +++++++++++++++++++ .../dashboard/actiongridpane/ActionBox.java | 5 +- .../client/window/settings/GeneralTab.java | 2 +- 5 files changed, 84 insertions(+), 6 deletions(-) create mode 100755 src/main/java/com/stream_pi/client/animations/ShakeUpDown.java diff --git a/src/main/java/com/stream_pi/client/animations/BounceOut.java b/src/main/java/com/stream_pi/client/animations/BounceOut.java index 518cc51d..b9ff2ec8 100755 --- a/src/main/java/com/stream_pi/client/animations/BounceOut.java +++ b/src/main/java/com/stream_pi/client/animations/BounceOut.java @@ -39,16 +39,16 @@ void initTimeline() { new KeyValue(getNode().scaleXProperty(), 1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleYProperty(), 1, AnimateFXInterpolator.EASE) ), - new KeyFrame(Duration.millis(200), + new KeyFrame(Duration.millis(50), new KeyValue(getNode().scaleXProperty(), 0.9, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleYProperty(), 0.9, AnimateFXInterpolator.EASE) ), - new KeyFrame(Duration.millis(550), + new KeyFrame(Duration.millis(112), new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleXProperty(), 1.1, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleYProperty(), 1.1, AnimateFXInterpolator.EASE) ), - new KeyFrame(Duration.millis(1000), + new KeyFrame(Duration.millis(225), new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleXProperty(), 0.3, AnimateFXInterpolator.EASE), new KeyValue(getNode().scaleYProperty(), 0.3, AnimateFXInterpolator.EASE) diff --git a/src/main/java/com/stream_pi/client/animations/FadeOut.java b/src/main/java/com/stream_pi/client/animations/FadeOut.java index 2827c85e..3045437c 100755 --- a/src/main/java/com/stream_pi/client/animations/FadeOut.java +++ b/src/main/java/com/stream_pi/client/animations/FadeOut.java @@ -33,7 +33,7 @@ void initTimeline() { new KeyFrame(Duration.millis(0), new KeyValue(getNode().opacityProperty(), 1, AnimateFXInterpolator.EASE) ), - new KeyFrame(Duration.millis(1000), + new KeyFrame(Duration.millis(50), new KeyValue(getNode().opacityProperty(), 0, AnimateFXInterpolator.EASE) ) )); diff --git a/src/main/java/com/stream_pi/client/animations/ShakeUpDown.java b/src/main/java/com/stream_pi/client/animations/ShakeUpDown.java new file mode 100755 index 00000000..98c32dd1 --- /dev/null +++ b/src/main/java/com/stream_pi/client/animations/ShakeUpDown.java @@ -0,0 +1,75 @@ +package com.stream_pi.client.animations; + +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.scene.Node; +import javafx.util.Duration; + + +/** + * @author Loïc Sculier aka typhon0 + */ +public class ShakeUpDown extends AnimationFX { + + /** + * Create new Shake + * + * @param node The node to affect + */ + public ShakeUpDown(Node node) { + super(node); + } + + public ShakeUpDown() { + } + + @Override + AnimationFX resetNode() { + + getNode().setTranslateX(0); + return this; + } + + @Override + void initTimeline() { + setTimeline(new Timeline( + new KeyFrame(Duration.millis(0), + new KeyValue(getNode().translateYProperty(), 0, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(100), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(200), + new KeyValue(getNode().translateYProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(300), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(400), + new KeyValue(getNode().translateYProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(500), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(600), + new KeyValue(getNode().translateYProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(700), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(800), + new KeyValue(getNode().translateYProperty(), 10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(900), + new KeyValue(getNode().translateYProperty(), -10, AnimateFXInterpolator.EASE) + ), + new KeyFrame(Duration.millis(1000), + new KeyValue(getNode().translateYProperty(), 0, AnimateFXInterpolator.EASE) + ) + )); + } +} + + + diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java index 9fc488cd..d2bbbe36 100755 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java @@ -308,9 +308,12 @@ public void playActionAnimation() throws SevereException { case "RubberBand": new RubberBand(getChildren().get(1)).play(); break; - case "Shake": + case "Shake Left/Right": new Shake(getChildren().get(1)).play(); break; + case "Shake Up/Down": + new ShakeUpDown(getChildren().get(1)).play(); + break; case "Tada": new Tada(getChildren().get(1)).play(); break; diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java index dc0110a6..a5a8f3b7 100755 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -107,7 +107,7 @@ public class GeneralTab extends VBox public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener, HostServices hostServices) { - animationList = Arrays.asList("None", "Bounce", "Bounce In/Out", "Fade In/Out", "Flash", "Flip", "Jack In The Box", "Jello", "Pulse", "Roll In/Out", "Rotate In/Out", "RubberBand", "Shake", "Swing", "Tada", "Wobble", "Zoom In/Out"); + animationList = Arrays.asList("None", "Bounce", "Bounce In/Out", "Fade In/Out", "Flash", "Flip", "Jack In The Box", "Jello", "Pulse", "Roll In/Out", "Rotate In/Out", "RubberBand", "Shake Left/Right", "Shake Up/Down","Swing", "Tada", "Wobble", "Zoom In/Out"); this.exceptionAndAlertHandler = exceptionAndAlertHandler; this.clientListener = clientListener; this.hostServices = hostServices; From 8736b335ac9d32f55b25940b313e4c6cd6a82b91 Mon Sep 17 00:00:00 2001 From: quimodotcom Date: Wed, 1 Sep 2021 18:11:42 +0100 Subject: [PATCH 11/12] backtracking to original source --- LICENSE.txt | 1346 ++++++------ README.md | 56 +- assets/launchers/aarch64-jvm/run_console | 36 +- assets/launchers/aarch64-jvm/run_desktop | 8 +- assets/launchers/aarch64-native/run_console | 36 +- assets/launchers/aarch64-native/run_desktop | 8 +- assets/launchers/arm32-jvm/run_console | 36 +- assets/launchers/arm32-jvm/run_desktop | 8 +- pom.xml | 2 +- src/android/AndroidManifest.xml | 46 +- src/android/mods/MainActivity.java | 1150 +++++----- src/ios/assets/Assets.xcassets/Contents.json | 10 +- .../assets/Base.lproj/LaunchScreen.storyboard | 64 +- .../assets/Base.lproj/MainScreen.storyboard | 64 +- src/main/java/com/stream_pi/client/Main.java | 126 +- .../stream_pi/client/connection/Client.java | 1926 ++++++++--------- .../client/controller/ClientListener.java | 172 +- .../client/controller/Controller.java | 1446 ++++++------- .../client/controller/ScreenMover.java | 206 +- .../client/controller/ScreenSaver.java | 248 +-- .../com/stream_pi/client/info/ClientInfo.java | 242 +-- .../com/stream_pi/client/info/License.java | 86 +- .../stream_pi/client/info/StartupFlags.java | 24 +- .../client/profile/ClientProfile.java | 1516 ++++++------- .../client/profile/ClientProfiles.java | 238 +- .../com/stream_pi/client/window/Base.java | 1060 ++++----- .../window/ExceptionAndAlertHandler.java | 30 +- .../window/dashboard/DashboardBase.java | 156 +- .../dashboard/actiongridpane/ActionBox.java | 33 +- .../window/firsttimeuse/FinalConfigPane.java | 348 +-- .../window/firsttimeuse/FirstTimeUse.java | 284 +-- .../window/firsttimeuse/LicensePane.java | 48 +- .../window/firsttimeuse/WelcomePane.java | 58 +- .../window/firsttimeuse/WindowName.java | 10 +- .../window/settings/About/AboutTab.java | 346 +-- .../window/settings/About/ContactTab.java | 100 +- .../window/settings/About/Contributor.java | 96 +- .../settings/About/ContributorsTab.java | 156 +- .../window/settings/About/LicenseTab.java | 32 +- .../client/window/settings/GeneralTab.java | 1531 +++++++------ .../client/window/settings/SettingsBase.java | 146 +- src/main/java/module-info.java | 58 +- .../native-image/resource-config.json | 14 +- .../native-image/serialization-config.json | 20 +- .../com/stream_pi/client/default_icons.css | 54 +- .../resources/com/stream_pi/client/style.css | 438 ++-- style_classes.txt | 86 +- 47 files changed, 7077 insertions(+), 7127 deletions(-) diff --git a/LICENSE.txt b/LICENSE.txt index 871ce8e6..e72bfdda 100755 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,674 +1,674 @@ - GNU GENERAL PUBLIC LICENSE - Version 3, 29 June 2007 - - Copyright (C) 2007 Free Software Foundation, Inc. - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - - Preamble - - The GNU General Public License is a free, copyleft license for -software and other kinds of works. - - The licenses for most software and other practical works are designed -to take away your freedom to share and change the works. By contrast, -the GNU General Public License is intended to guarantee your freedom to -share and change all versions of a program--to make sure it remains free -software for all its users. We, the Free Software Foundation, use the -GNU General Public License for most of our software; it applies also to -any other work released this way by its authors. You can apply it to -your programs, too. - - When we speak of free software, we are referring to freedom, not -price. Our General Public Licenses are designed to make sure that you -have the freedom to distribute copies of free software (and charge for -them if you wish), that you receive source code or can get it if you -want it, that you can change the software or use pieces of it in new -free programs, and that you know you can do these things. - - To protect your rights, we need to prevent others from denying you -these rights or asking you to surrender the rights. Therefore, you have -certain responsibilities if you distribute copies of the software, or if -you modify it: responsibilities to respect the freedom of others. - - For example, if you distribute copies of such a program, whether -gratis or for a fee, you must pass on to the recipients the same -freedoms that you received. You must make sure that they, too, receive -or can get the source code. And you must show them these terms so they -know their rights. - - Developers that use the GNU GPL protect your rights with two steps: -(1) assert copyright on the software, and (2) offer you this License -giving you legal permission to copy, distribute and/or modify it. - - For the developers' and authors' protection, the GPL clearly explains -that there is no warranty for this free software. For both users' and -authors' sake, the GPL requires that modified versions be marked as -changed, so that their problems will not be attributed erroneously to -authors of previous versions. - - Some devices are designed to deny users access to install or run -modified versions of the software inside them, although the manufacturer -can do so. This is fundamentally incompatible with the aim of -protecting users' freedom to change the software. The systematic -pattern of such abuse occurs in the area of products for individuals to -use, which is precisely where it is most unacceptable. Therefore, we -have designed this version of the GPL to prohibit the practice for those -products. If such problems arise substantially in other domains, we -stand ready to extend this provision to those domains in future versions -of the GPL, as needed to protect the freedom of users. - - Finally, every program is threatened constantly by software patents. -States should not allow patents to restrict development and use of -software on general-purpose computers, but in those that do, we wish to -avoid the special danger that patents applied to a free program could -make it effectively proprietary. To prevent this, the GPL assures that -patents cannot be used to render the program non-free. - - The precise terms and conditions for copying, distribution and -modification follow. - - TERMS AND CONDITIONS - - 0. Definitions. - - "This License" refers to version 3 of the GNU General Public License. - - "Copyright" also means copyright-like laws that apply to other kinds of -works, such as semiconductor masks. - - "The Program" refers to any copyrightable work licensed under this -License. Each licensee is addressed as "you". "Licensees" and -"recipients" may be individuals or organizations. - - To "modify" a work means to copy from or adapt all or part of the work -in a fashion requiring copyright permission, other than the making of an -exact copy. The resulting work is called a "modified version" of the -earlier work or a work "based on" the earlier work. - - A "covered work" means either the unmodified Program or a work based -on the Program. - - To "propagate" a work means to do anything with it that, without -permission, would make you directly or secondarily liable for -infringement under applicable copyright law, except executing it on a -computer or modifying a private copy. Propagation includes copying, -distribution (with or without modification), making available to the -public, and in some countries other activities as well. - - To "convey" a work means any kind of propagation that enables other -parties to make or receive copies. Mere interaction with a user through -a computer network, with no transfer of a copy, is not conveying. - - An interactive user interface displays "Appropriate Legal Notices" -to the extent that it includes a convenient and prominently visible -feature that (1) displays an appropriate copyright notice, and (2) -tells the user that there is no warranty for the work (except to the -extent that warranties are provided), that licensees may convey the -work under this License, and how to view a copy of this License. If -the interface presents a list of user commands or options, such as a -menu, a prominent item in the list meets this criterion. - - 1. Source Code. - - The "source code" for a work means the preferred form of the work -for making modifications to it. "Object code" means any non-source -form of a work. - - A "Standard Interface" means an interface that either is an official -standard defined by a recognized standards body, or, in the case of -interfaces specified for a particular programming language, one that -is widely used among developers working in that language. - - The "System Libraries" of an executable work include anything, other -than the work as a whole, that (a) is included in the normal form of -packaging a Major Component, but which is not part of that Major -Component, and (b) serves only to enable use of the work with that -Major Component, or to implement a Standard Interface for which an -implementation is available to the public in source code form. A -"Major Component", in this context, means a major essential component -(kernel, window system, and so on) of the specific operating system -(if any) on which the executable work runs, or a compiler used to -produce the work, or an object code interpreter used to run it. - - The "Corresponding Source" for a work in object code form means all -the source code needed to generate, install, and (for an executable -work) run the object code and to modify the work, including scripts to -control those activities. However, it does not include the work's -System Libraries, or general-purpose tools or generally available free -programs which are used unmodified in performing those activities but -which are not part of the work. For example, Corresponding Source -includes interface definition files associated with source files for -the work, and the source code for shared libraries and dynamically -linked subprograms that the work is specifically designed to require, -such as by intimate data communication or control flow between those -subprograms and other parts of the work. - - The Corresponding Source need not include anything that users -can regenerate automatically from other parts of the Corresponding -Source. - - The Corresponding Source for a work in source code form is that -same work. - - 2. Basic Permissions. - - All rights granted under this License are granted for the term of -copyright on the Program, and are irrevocable provided the stated -conditions are met. This License explicitly affirms your unlimited -permission to run the unmodified Program. The output from running a -covered work is covered by this License only if the output, given its -content, constitutes a covered work. This License acknowledges your -rights of fair use or other equivalent, as provided by copyright law. - - You may make, run and propagate covered works that you do not -convey, without conditions so long as your license otherwise remains -in force. You may convey covered works to others for the sole purpose -of having them make modifications exclusively for you, or provide you -with facilities for running those works, provided that you comply with -the terms of this License in conveying all material for which you do -not control copyright. Those thus making or running the covered works -for you must do so exclusively on your behalf, under your direction -and control, on terms that prohibit them from making any copies of -your copyrighted material outside their relationship with you. - - Conveying under any other circumstances is permitted solely under -the conditions stated below. Sublicensing is not allowed; section 10 -makes it unnecessary. - - 3. Protecting Users' Legal Rights From Anti-Circumvention Law. - - No covered work shall be deemed part of an effective technological -measure under any applicable law fulfilling obligations under article -11 of the WIPO copyright treaty adopted on 20 December 1996, or -similar laws prohibiting or restricting circumvention of such -measures. - - When you convey a covered work, you waive any legal power to forbid -circumvention of technological measures to the extent such circumvention -is effected by exercising rights under this License with respect to -the covered work, and you disclaim any intention to limit operation or -modification of the work as a means of enforcing, against the work's -users, your or third parties' legal rights to forbid circumvention of -technological measures. - - 4. Conveying Verbatim Copies. - - You may convey verbatim copies of the Program's source code as you -receive it, in any medium, provided that you conspicuously and -appropriately publish on each copy an appropriate copyright notice; -keep intact all notices stating that this License and any -non-permissive terms added in accord with section 7 apply to the code; -keep intact all notices of the absence of any warranty; and give all -recipients a copy of this License along with the Program. - - You may charge any price or no price for each copy that you convey, -and you may offer support or warranty protection for a fee. - - 5. Conveying Modified Source Versions. - - You may convey a work based on the Program, or the modifications to -produce it from the Program, in the form of source code under the -terms of section 4, provided that you also meet all of these conditions: - - a) The work must carry prominent notices stating that you modified - it, and giving a relevant date. - - b) The work must carry prominent notices stating that it is - released under this License and any conditions added under section - 7. This requirement modifies the requirement in section 4 to - "keep intact all notices". - - c) You must license the entire work, as a whole, under this - License to anyone who comes into possession of a copy. This - License will therefore apply, along with any applicable section 7 - additional terms, to the whole of the work, and all its parts, - regardless of how they are packaged. This License gives no - permission to license the work in any other way, but it does not - invalidate such permission if you have separately received it. - - d) If the work has interactive user interfaces, each must display - Appropriate Legal Notices; however, if the Program has interactive - interfaces that do not display Appropriate Legal Notices, your - work need not make them do so. - - A compilation of a covered work with other separate and independent -works, which are not by their nature extensions of the covered work, -and which are not combined with it such as to form a larger program, -in or on a volume of a storage or distribution medium, is called an -"aggregate" if the compilation and its resulting copyright are not -used to limit the access or legal rights of the compilation's users -beyond what the individual works permit. Inclusion of a covered work -in an aggregate does not cause this License to apply to the other -parts of the aggregate. - - 6. Conveying Non-Source Forms. - - You may convey a covered work in object code form under the terms -of sections 4 and 5, provided that you also convey the -machine-readable Corresponding Source under the terms of this License, -in one of these ways: - - a) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by the - Corresponding Source fixed on a durable physical medium - customarily used for software interchange. - - b) Convey the object code in, or embodied in, a physical product - (including a physical distribution medium), accompanied by a - written offer, valid for at least three years and valid for as - long as you offer spare parts or customer support for that product - model, to give anyone who possesses the object code either (1) a - copy of the Corresponding Source for all the software in the - product that is covered by this License, on a durable physical - medium customarily used for software interchange, for a price no - more than your reasonable cost of physically performing this - conveying of source, or (2) access to copy the - Corresponding Source from a network server at no charge. - - c) Convey individual copies of the object code with a copy of the - written offer to provide the Corresponding Source. This - alternative is allowed only occasionally and noncommercially, and - only if you received the object code with such an offer, in accord - with subsection 6b. - - d) Convey the object code by offering access from a designated - place (gratis or for a charge), and offer equivalent access to the - Corresponding Source in the same way through the same place at no - further charge. You need not require recipients to copy the - Corresponding Source along with the object code. If the place to - copy the object code is a network server, the Corresponding Source - may be on a different server (operated by you or a third party) - that supports equivalent copying facilities, provided you maintain - clear directions next to the object code saying where to find the - Corresponding Source. Regardless of what server hosts the - Corresponding Source, you remain obligated to ensure that it is - available for as long as needed to satisfy these requirements. - - e) Convey the object code using peer-to-peer transmission, provided - you inform other peers where the object code and Corresponding - Source of the work are being offered to the general public at no - charge under subsection 6d. - - A separable portion of the object code, whose source code is excluded -from the Corresponding Source as a System Library, need not be -included in conveying the object code work. - - A "User Product" is either (1) a "consumer product", which means any -tangible personal property which is normally used for personal, family, -or household purposes, or (2) anything designed or sold for incorporation -into a dwelling. In determining whether a product is a consumer product, -doubtful cases shall be resolved in favor of coverage. For a particular -product received by a particular user, "normally used" refers to a -typical or common use of that class of product, regardless of the status -of the particular user or of the way in which the particular user -actually uses, or expects or is expected to use, the product. A product -is a consumer product regardless of whether the product has substantial -commercial, industrial or non-consumer uses, unless such uses represent -the only significant mode of use of the product. - - "Installation Information" for a User Product means any methods, -procedures, authorization keys, or other information required to install -and execute modified versions of a covered work in that User Product from -a modified version of its Corresponding Source. The information must -suffice to ensure that the continued functioning of the modified object -code is in no case prevented or interfered with solely because -modification has been made. - - If you convey an object code work under this section in, or with, or -specifically for use in, a User Product, and the conveying occurs as -part of a transaction in which the right of possession and use of the -User Product is transferred to the recipient in perpetuity or for a -fixed term (regardless of how the transaction is characterized), the -Corresponding Source conveyed under this section must be accompanied -by the Installation Information. But this requirement does not apply -if neither you nor any third party retains the ability to install -modified object code on the User Product (for example, the work has -been installed in ROM). - - The requirement to provide Installation Information does not include a -requirement to continue to provide support service, warranty, or updates -for a work that has been modified or installed by the recipient, or for -the User Product in which it has been modified or installed. Access to a -network may be denied when the modification itself materially and -adversely affects the operation of the network or violates the rules and -protocols for communication across the network. - - Corresponding Source conveyed, and Installation Information provided, -in accord with this section must be in a format that is publicly -documented (and with an implementation available to the public in -source code form), and must require no special password or key for -unpacking, reading or copying. - - 7. Additional Terms. - - "Additional permissions" are terms that supplement the terms of this -License by making exceptions from one or more of its conditions. -Additional permissions that are applicable to the entire Program shall -be treated as though they were included in this License, to the extent -that they are valid under applicable law. If additional permissions -apply only to part of the Program, that part may be used separately -under those permissions, but the entire Program remains governed by -this License without regard to the additional permissions. - - When you convey a copy of a covered work, you may at your option -remove any additional permissions from that copy, or from any part of -it. (Additional permissions may be written to require their own -removal in certain cases when you modify the work.) You may place -additional permissions on material, added by you to a covered work, -for which you have or can give appropriate copyright permission. - - Notwithstanding any other provision of this License, for material you -add to a covered work, you may (if authorized by the copyright holders of -that material) supplement the terms of this License with terms: - - a) Disclaiming warranty or limiting liability differently from the - terms of sections 15 and 16 of this License; or - - b) Requiring preservation of specified reasonable legal notices or - author attributions in that material or in the Appropriate Legal - Notices displayed by works containing it; or - - c) Prohibiting misrepresentation of the origin of that material, or - requiring that modified versions of such material be marked in - reasonable ways as different from the original version; or - - d) Limiting the use for publicity purposes of names of licensors or - authors of the material; or - - e) Declining to grant rights under trademark law for use of some - trade names, trademarks, or service marks; or - - f) Requiring indemnification of licensors and authors of that - material by anyone who conveys the material (or modified versions of - it) with contractual assumptions of liability to the recipient, for - any liability that these contractual assumptions directly impose on - those licensors and authors. - - All other non-permissive additional terms are considered "further -restrictions" within the meaning of section 10. If the Program as you -received it, or any part of it, contains a notice stating that it is -governed by this License along with a term that is a further -restriction, you may remove that term. If a license document contains -a further restriction but permits relicensing or conveying under this -License, you may add to a covered work material governed by the terms -of that license document, provided that the further restriction does -not survive such relicensing or conveying. - - If you add terms to a covered work in accord with this section, you -must place, in the relevant source files, a statement of the -additional terms that apply to those files, or a notice indicating -where to find the applicable terms. - - Additional terms, permissive or non-permissive, may be stated in the -form of a separately written license, or stated as exceptions; -the above requirements apply either way. - - 8. Termination. - - You may not propagate or modify a covered work except as expressly -provided under this License. Any attempt otherwise to propagate or -modify it is void, and will automatically terminate your rights under -this License (including any patent licenses granted under the third -paragraph of section 11). - - However, if you cease all violation of this License, then your -license from a particular copyright holder is reinstated (a) -provisionally, unless and until the copyright holder explicitly and -finally terminates your license, and (b) permanently, if the copyright -holder fails to notify you of the violation by some reasonable means -prior to 60 days after the cessation. - - Moreover, your license from a particular copyright holder is -reinstated permanently if the copyright holder notifies you of the -violation by some reasonable means, this is the first time you have -received notice of violation of this License (for any work) from that -copyright holder, and you cure the violation prior to 30 days after -your receipt of the notice. - - Termination of your rights under this section does not terminate the -licenses of parties who have received copies or rights from you under -this License. If your rights have been terminated and not permanently -reinstated, you do not qualify to receive new licenses for the same -material under section 10. - - 9. Acceptance Not Required for Having Copies. - - You are not required to accept this License in order to receive or -run a copy of the Program. Ancillary propagation of a covered work -occurring solely as a consequence of using peer-to-peer transmission -to receive a copy likewise does not require acceptance. However, -nothing other than this License grants you permission to propagate or -modify any covered work. These actions infringe copyright if you do -not accept this License. Therefore, by modifying or propagating a -covered work, you indicate your acceptance of this License to do so. - - 10. Automatic Licensing of Downstream Recipients. - - Each time you convey a covered work, the recipient automatically -receives a license from the original licensors, to run, modify and -propagate that work, subject to this License. You are not responsible -for enforcing compliance by third parties with this License. - - An "entity transaction" is a transaction transferring control of an -organization, or substantially all assets of one, or subdividing an -organization, or merging organizations. If propagation of a covered -work results from an entity transaction, each party to that -transaction who receives a copy of the work also receives whatever -licenses to the work the party's predecessor in interest had or could -give under the previous paragraph, plus a right to possession of the -Corresponding Source of the work from the predecessor in interest, if -the predecessor has it or can get it with reasonable efforts. - - You may not impose any further restrictions on the exercise of the -rights granted or affirmed under this License. For example, you may -not impose a license fee, royalty, or other charge for exercise of -rights granted under this License, and you may not initiate litigation -(including a cross-claim or counterclaim in a lawsuit) alleging that -any patent claim is infringed by making, using, selling, offering for -sale, or importing the Program or any portion of it. - - 11. Patents. - - A "contributor" is a copyright holder who authorizes use under this -License of the Program or a work on which the Program is based. The -work thus licensed is called the contributor's "contributor version". - - A contributor's "essential patent claims" are all patent claims -owned or controlled by the contributor, whether already acquired or -hereafter acquired, that would be infringed by some manner, permitted -by this License, of making, using, or selling its contributor version, -but do not include claims that would be infringed only as a -consequence of further modification of the contributor version. For -purposes of this definition, "control" includes the right to grant -patent sublicenses in a manner consistent with the requirements of -this License. - - Each contributor grants you a non-exclusive, worldwide, royalty-free -patent license under the contributor's essential patent claims, to -make, use, sell, offer for sale, import and otherwise run, modify and -propagate the contents of its contributor version. - - In the following three paragraphs, a "patent license" is any express -agreement or commitment, however denominated, not to enforce a patent -(such as an express permission to practice a patent or covenant not to -sue for patent infringement). To "grant" such a patent license to a -party means to make such an agreement or commitment not to enforce a -patent against the party. - - If you convey a covered work, knowingly relying on a patent license, -and the Corresponding Source of the work is not available for anyone -to copy, free of charge and under the terms of this License, through a -publicly available network server or other readily accessible means, -then you must either (1) cause the Corresponding Source to be so -available, or (2) arrange to deprive yourself of the benefit of the -patent license for this particular work, or (3) arrange, in a manner -consistent with the requirements of this License, to extend the patent -license to downstream recipients. "Knowingly relying" means you have -actual knowledge that, but for the patent license, your conveying the -covered work in a country, or your recipient's use of the covered work -in a country, would infringe one or more identifiable patents in that -country that you have reason to believe are valid. - - If, pursuant to or in connection with a single transaction or -arrangement, you convey, or propagate by procuring conveyance of, a -covered work, and grant a patent license to some of the parties -receiving the covered work authorizing them to use, propagate, modify -or convey a specific copy of the covered work, then the patent license -you grant is automatically extended to all recipients of the covered -work and works based on it. - - A patent license is "discriminatory" if it does not include within -the scope of its coverage, prohibits the exercise of, or is -conditioned on the non-exercise of one or more of the rights that are -specifically granted under this License. You may not convey a covered -work if you are a party to an arrangement with a third party that is -in the business of distributing software, under which you make payment -to the third party based on the extent of your activity of conveying -the work, and under which the third party grants, to any of the -parties who would receive the covered work from you, a discriminatory -patent license (a) in connection with copies of the covered work -conveyed by you (or copies made from those copies), or (b) primarily -for and in connection with specific products or compilations that -contain the covered work, unless you entered into that arrangement, -or that patent license was granted, prior to 28 March 2007. - - Nothing in this License shall be construed as excluding or limiting -any implied license or other defenses to infringement that may -otherwise be available to you under applicable patent law. - - 12. No Surrender of Others' Freedom. - - If conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot convey a -covered work so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you may -not convey it at all. For example, if you agree to terms that obligate you -to collect a royalty for further conveying from those to whom you convey -the Program, the only way you could satisfy both those terms and this -License would be to refrain entirely from conveying the Program. - - 13. Use with the GNU Affero General Public License. - - Notwithstanding any other provision of this License, you have -permission to link or combine any covered work with a work licensed -under version 3 of the GNU Affero General Public License into a single -combined work, and to convey the resulting work. The terms of this -License will continue to apply to the part which is the covered work, -but the special requirements of the GNU Affero General Public License, -section 13, concerning interaction through a network will apply to the -combination as such. - - 14. Revised Versions of this License. - - The Free Software Foundation may publish revised and/or new versions of -the GNU General Public License from time to time. Such new versions will -be similar in spirit to the present version, but may differ in detail to -address new problems or concerns. - - Each version is given a distinguishing version number. If the -Program specifies that a certain numbered version of the GNU General -Public License "or any later version" applies to it, you have the -option of following the terms and conditions either of that numbered -version or of any later version published by the Free Software -Foundation. If the Program does not specify a version number of the -GNU General Public License, you may choose any version ever published -by the Free Software Foundation. - - If the Program specifies that a proxy can decide which future -versions of the GNU General Public License can be used, that proxy's -public statement of acceptance of a version permanently authorizes you -to choose that version for the Program. - - Later license versions may give you additional or different -permissions. However, no additional obligations are imposed on any -author or copyright holder as a result of your choosing to follow a -later version. - - 15. Disclaimer of Warranty. - - THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY -APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT -HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY -OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, -THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM -IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF -ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. Limitation of Liability. - - IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING -WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS -THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY -GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE -USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF -DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD -PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), -EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF -SUCH DAMAGES. - - 17. Interpretation of Sections 15 and 16. - - If the disclaimer of warranty and limitation of liability provided -above cannot be given local legal effect according to their terms, -reviewing courts shall apply local law that most closely approximates -an absolute waiver of all civil liability in connection with the -Program, unless a warranty or assumption of liability accompanies a -copy of the Program in return for a fee. - - END OF TERMS AND CONDITIONS - - How to Apply These Terms to Your New Programs - - If you develop a new program, and you want it to be of the greatest -possible use to the public, the best way to achieve this is to make it -free software which everyone can redistribute and change under these terms. - - To do so, attach the following notices to the program. It is safest -to attach them to the start of each source file to most effectively -state the exclusion of warranty; and each file should have at least -the "copyright" line and a pointer to where the full notice is found. - - - Copyright (C) - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see . - -Also add information on how to contact you by electronic and paper mail. - - If the program does terminal interaction, make it output a short -notice like this when it starts in an interactive mode: - - Copyright (C) - This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. - This is free software, and you are welcome to redistribute it - under certain conditions; type `show c' for details. - -The hypothetical commands `show w' and `show c' should show the appropriate -parts of the General Public License. Of course, your program's commands -might be different; for a GUI interface, you would use an "about box". - - You should also get your employer (if you work as a programmer) or school, -if any, to sign a "copyright disclaimer" for the program, if necessary. -For more information on this, and how to apply and follow the GNU GPL, see -. - - The GNU General Public License does not permit incorporating your program -into proprietary programs. If your program is a subroutine library, you -may consider it more useful to permit linking proprietary applications with -the library. If this is what you want to do, use the GNU Lesser General -Public License instead of this License. But first, please read + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read . \ No newline at end of file diff --git a/README.md b/README.md index dc74e123..aac43c76 100755 --- a/README.md +++ b/README.md @@ -1,28 +1,28 @@ -# Stream-Pi Client - -![version](https://img.shields.io/badge/Version-1.0.0-green) - -## Prerequisites - -- Java >= 11 -- Maven >= 3.6.3 - -Note: If compiling the Android binary (apk) then GraalVM 21.1.0 (Java 11) should be used as JDK, or the path to it should be -set as value of environment variable `GRAALVM_HOME`. - -## Quick Start - -This project depends on the following Stream-Pi modules: - -- [Stream-Pi Action API](https://github.com/stream-pi/action-api) -- [Stream-Pi Theme API](https://github.com/stream-pi/theme-api) -- [Stream-Pi Utilities](https://github.com/stream-pi/util) - - -## Download binaries - -Downloadable Binaries for available platforms are available [here](https://github.com/stream-pi/client/releases). - -## Compile and Run from source - -Run `mvn clean javafx:run` +# Stream-Pi Client + +![version](https://img.shields.io/badge/Version-1.0.0-green) + +## Prerequisites + +- Java >= 11 +- Maven >= 3.6.3 + +Note: If compiling the Android binary (apk) then GraalVM 21.1.0 (Java 11) should be used as JDK, or the path to it should be +set as value of environment variable `GRAALVM_HOME`. + +## Quick Start + +This project depends on the following Stream-Pi modules: + +- [Stream-Pi Action API](https://github.com/stream-pi/action-api) +- [Stream-Pi Theme API](https://github.com/stream-pi/theme-api) +- [Stream-Pi Utilities](https://github.com/stream-pi/util) + + +## Download binaries + +Downloadable Binaries for available platforms are available [here](https://github.com/stream-pi/client/releases). + +## Compile and Run from source + +Run `mvn clean javafx:run` diff --git a/assets/launchers/aarch64-jvm/run_console b/assets/launchers/aarch64-jvm/run_console index 7ec8a3eb..72de8843 100755 --- a/assets/launchers/aarch64-jvm/run_console +++ b/assets/launchers/aarch64-jvm/run_console @@ -1,18 +1,18 @@ -#!/bin/bash -cd "${0%/*}" -export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true -export DISPLAY_CARD0=/dev/dri/card0 -export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 - -if ! jre/bin/java -Xmx700m -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD0 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card0, trying to launch using card1 - - if ! jre/bin/java -Xmx700m -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD1 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card1. Is your KMS driver turned on? - else - echo success using card1 - fi -else - echo success using card0 -fi - +#!/bin/bash +cd "${0%/*}" +export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true +export DISPLAY_CARD0=/dev/dri/card0 +export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 + +if ! jre/bin/java -Xmx700m -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD0 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card0, trying to launch using card1 + + if ! jre/bin/java -Xmx700m -XX:+UnlockExperimentalVMOptions -XX:+UseZGC -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD1 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card1. Is your KMS driver turned on? + else + echo success using card1 + fi +else + echo success using card0 +fi + diff --git a/assets/launchers/aarch64-jvm/run_desktop b/assets/launchers/aarch64-jvm/run_desktop index be856ab1..a2d88f3e 100755 --- a/assets/launchers/aarch64-jvm/run_desktop +++ b/assets/launchers/aarch64-jvm/run_desktop @@ -1,4 +1,4 @@ -#!/bin/bash -cd "${0%/*}" - -DISPLAY=:0 jre/bin/java -Xmx700m --module-path . --add-modules ALL-MODULE-PATH -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx com.stream_pi.client.Main Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true +#!/bin/bash +cd "${0%/*}" + +DISPLAY=:0 jre/bin/java -Xmx700m --module-path . --add-modules ALL-MODULE-PATH -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx com.stream_pi.client.Main Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true diff --git a/assets/launchers/aarch64-native/run_console b/assets/launchers/aarch64-native/run_console index 102a632e..e4f94e8d 100755 --- a/assets/launchers/aarch64-native/run_console +++ b/assets/launchers/aarch64-native/run_console @@ -1,18 +1,18 @@ -#!/bin/bash -cd "${0%/*}" -export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true -export DISPLAY_CARD0=/dev/dri/card0 -export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 - -if ! ./client -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dmonocle.platform=EGL -Degl.displayid=$DISPLAY_CARD0 Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card0, trying to launch using card1 - - if ! ./client -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dmonocle.platform=EGL -Degl.displayid=$DISPLAY_CARD1 Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card1. Is your KMS driver turned on? - else - echo success using card1 - fi -else - echo success using card0 -fi - +#!/bin/bash +cd "${0%/*}" +export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true +export DISPLAY_CARD0=/dev/dri/card0 +export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 + +if ! ./client -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dmonocle.platform=EGL -Degl.displayid=$DISPLAY_CARD0 Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card0, trying to launch using card1 + + if ! ./client -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dmonocle.platform=EGL -Degl.displayid=$DISPLAY_CARD1 Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card1. Is your KMS driver turned on? + else + echo success using card1 + fi +else + echo success using card0 +fi + diff --git a/assets/launchers/aarch64-native/run_desktop b/assets/launchers/aarch64-native/run_desktop index d5b6ab59..691d8f09 100755 --- a/assets/launchers/aarch64-native/run_desktop +++ b/assets/launchers/aarch64-native/run_desktop @@ -1,4 +1,4 @@ -#!/bin/bash -cd "${0%/*}" - -DISPLAY=:0 ./client -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true +#!/bin/bash +cd "${0%/*}" + +DISPLAY=:0 ./client -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true diff --git a/assets/launchers/arm32-jvm/run_console b/assets/launchers/arm32-jvm/run_console index 2d9968c2..22b36fa3 100755 --- a/assets/launchers/arm32-jvm/run_console +++ b/assets/launchers/arm32-jvm/run_console @@ -1,18 +1,18 @@ -#!/bin/bash -cd "${0%/*}" -export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true -export DISPLAY_CARD0=/dev/dri/card0 -export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 - -if ! jre/bin/java -Xmx700m -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD0 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card0, trying to launch using card1 - - if ! jre/bin/java -Xmx700m -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD1 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then - echo failed to launch using card1. Is your KMS driver turned on? - else - echo success using card1 - fi -else - echo success using card0 -fi - +#!/bin/bash +cd "${0%/*}" +export ENABLE_GLUON_COMMERCIAL_EXTENSIONS=true +export DISPLAY_CARD0=/dev/dri/card0 +export DISPLAY_CARD1=/dev/dri/card1 # For Raspberry Pi 4 + +if ! jre/bin/java -Xmx700m -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD0 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card0, trying to launch using card1 + + if ! jre/bin/java -Xmx700m -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.isEmbedded=true -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.virtualKeyboard=javafx -Dembedded=monocle -Dglass.platform=Monocle -Dmonocle.platform=EGL -Djava.library.path=. -Dmonocle.egl.lib=./libgluon_drm.so -Degl.displayid=$DISPLAY_CARD1 --module-path . --add-modules ALL-MODULE-PATH com.stream_pi.client.Main Stream-Pi.enableScreenSaverFeature=true Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_console Stream-Pi.isXMode=false Stream-Pi.isShowFullScreenToggleButton=false Stream-Pi.defaultFullScreenMode=true; then + echo failed to launch using card1. Is your KMS driver turned on? + else + echo success using card1 + fi +else + echo success using card0 +fi + diff --git a/assets/launchers/arm32-jvm/run_desktop b/assets/launchers/arm32-jvm/run_desktop index be856ab1..a2d88f3e 100755 --- a/assets/launchers/arm32-jvm/run_desktop +++ b/assets/launchers/arm32-jvm/run_desktop @@ -1,4 +1,4 @@ -#!/bin/bash -cd "${0%/*}" - -DISPLAY=:0 jre/bin/java -Xmx700m --module-path . --add-modules ALL-MODULE-PATH -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx com.stream_pi.client.Main Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true +#!/bin/bash +cd "${0%/*}" + +DISPLAY=:0 jre/bin/java -Xmx700m --module-path . --add-modules ALL-MODULE-PATH -Djavafx.platform=gtk -Djavafx.verbose=true -Dprism.verbose=true -Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.virtualKeyboard=javafx com.stream_pi.client.Main Stream-Pi.showShutDownButton=true Stream-Pi.startupRunnerFileName=run_desktop Stream-Pi.isXMode=true Stream-Pi.defaultFullScreenMode=true diff --git a/pom.xml b/pom.xml index 1da0b657..090f1d03 100755 --- a/pom.xml +++ b/pom.xml @@ -44,7 +44,7 @@ javafx-controls ${javafx.version} - + org.openjfx javafx-base diff --git a/src/android/AndroidManifest.xml b/src/android/AndroidManifest.xml index d6bc2d6e..a65dbe05 100755 --- a/src/android/AndroidManifest.xml +++ b/src/android/AndroidManifest.xml @@ -1,23 +1,23 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + diff --git a/src/android/mods/MainActivity.java b/src/android/mods/MainActivity.java index ae9c33fb..1614aebd 100755 --- a/src/android/mods/MainActivity.java +++ b/src/android/mods/MainActivity.java @@ -1,575 +1,575 @@ -/* - * Copyright (c) 2019, 2020, Gluon - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED - * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE - * DISCLAIMED. IN NO EVENT SHALL GLUON BE LIABLE FOR ANY - * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES - * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; - * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND - * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package com.gluonhq.helloandroid; - -import android.app.Activity; -import android.content.Context; -import android.content.Intent; -import android.content.pm.ActivityInfo; -import android.content.pm.PackageManager; -import android.content.pm.PackageManager.NameNotFoundException; -import android.graphics.PixelFormat; -import android.graphics.Rect; -import android.os.Bundle; -import android.util.DisplayMetrics; -import android.util.Log; - -import android.view.inputmethod.InputConnection; - -import android.view.KeyEvent; -import android.view.KeyCharacterMap; -import android.view.MotionEvent; -import android.view.Surface; -import android.view.SurfaceHolder; -import android.view.SurfaceView; -import android.view.ViewGroup; -import android.view.Window; -import android.view.WindowManager; -import android.view.WindowManager.LayoutParams; -import android.view.inputmethod.InputMethodManager; -import android.widget.FrameLayout; - -import java.util.TimeZone; -import javafx.scene.input.KeyCode; - -public class MainActivity extends Activity implements SurfaceHolder.Callback, - SurfaceHolder.Callback2 { - - private static MainActivity instance; - private static FrameLayout mViewGroup; - private static SurfaceView mView; - private long nativeWindowPtr; - private float density; - - private static final String TAG = "GraalActivity"; - - boolean graalStarted = false; - - private static InputMethodManager imm; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Log.v(TAG, "onCreate start, using Android Logging v1"); - Log.v(TAG, "Using modded MainActivity to prevent device lock"); - System.err.println("onCreate called, writing this to System.err"); - super.onCreate(savedInstanceState); - - getWindow().requestFeature(Window.FEATURE_NO_TITLE); - getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); - getWindow().setSoftInputMode( - WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED - | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); - getWindow().setFormat(PixelFormat.RGBA_8888); - - - mView = new InternalSurfaceView(this); - mView.getHolder().addCallback(this); - mViewGroup = new FrameLayout(this); - mViewGroup.addView(mView); - setContentView(mViewGroup); - instance = this; - - imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); - Log.v(TAG, "onCreate done"); - } - - @Override - public void surfaceCreated(SurfaceHolder holder) { - Log.v(TAG, "surfaceCreated for "+this); - Log.v(TAG, "loading substrate library"); - System.loadLibrary("substrate"); - Log.v(TAG, "loaded substrate library"); - nativeSetSurface(holder.getSurface()); - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - density = metrics.density; - Log.v(TAG, "metrics = "+metrics+", density = "+density); - nativeWindowPtr = surfaceReady(holder.getSurface(), density); - Rect currentBounds = new Rect(); - mView.getRootView().getWindowVisibleDisplayFrame(currentBounds); - - Log.v(TAG, "Surface created, native code informed about it, nativeWindow at "+nativeWindowPtr); - if (graalStarted) { - Log.v(TAG, "GraalApp is already started."); - } else { - Log.v(TAG, "We will now launch Graal in a separate thread"); - final String[] launchArgs = { - "-Duser.home=" + getApplicationInfo().dataDir, - "-Djava.io.tmpdir=" + getApplicationInfo().dataDir, - "-Duser.timezone=" + TimeZone.getDefault().getID(), - "-DLaunch.URL=" + System.getProperty("Launch.URL", ""), - "-DLaunch.LocalNotification=" + System.getProperty("Launch.LocalNotification", ""), - "-DLaunch.PushNotification=" + System.getProperty("Launch.PushNotification", "") - }; - Thread t = new Thread() { - @Override public void run() { - startGraalApp(launchArgs); - } - }; - t.start(); - graalStarted = true; - Log.v(TAG, "graalStarted true"); - } - Log.v(TAG, "surfaceCreated done"); - } - - - - @Override - public void surfaceChanged(SurfaceHolder holder, int format, int width, - int height) { - Log.v(TAG, "surfaceChanged start"); - Log.v(TAG, "[MainActivity] surfaceChanged, format = "+format+", width = "+width+", height = "+height); - nativeSetSurface(holder.getSurface()); - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - density = metrics.density; - Log.v(TAG, "surfaceChanged done, metrics = "+metrics+", density = "+density); - } - - @Override - public void surfaceDestroyed(SurfaceHolder holder) { - System.err.println("[MainGraalActivity] surfaceDestroyed, ignore for now"); - // _surfaceChanged(null); - } - - @Override - public void surfaceRedrawNeeded(SurfaceHolder holder) { - Log.v(TAG, "SurfaceRedraw needed start"); - DisplayMetrics metrics = new DisplayMetrics(); - getWindowManager().getDefaultDisplay().getMetrics(metrics); - Log.v(TAG, "ask native graallayer to redraw surface"); - nativeSurfaceRedrawNeeded(); - try { - Thread.sleep(500); - Log.v(TAG, "surfaceredraw needed part 1 done"); - nativeSurfaceRedrawNeeded(); - } catch (Exception e) { - e.printStackTrace(); - } - Log.v(TAG, "surfaceredraw needed (and wait) done"); - } - - @Override - public void onActivityResult(int requestCode, int resultCode, Intent intent) { - Log.v(TAG, "onActivityResult with requestCode " + requestCode + " and resultCode = " + resultCode + " and intent = " + intent); - nativeDispatchActivityResult(requestCode, resultCode, intent); - } - - static MainActivity getInstance() { - return instance; - } - - static ViewGroup getViewGroup() { - return mViewGroup; - } - - private static void showIME() { - Log.v(TAG, "Called notify_showIME for imm = "+imm+", mv = "+mView); - instance.runOnUiThread(new Runnable() { - @Override - public void run() { - mView.requestFocus(); - boolean answer = imm.showSoftInput(mView, 0); - Log.v(TAG, "Done calling notify_showIME, answer = " + answer); - } - }); - } - - private static void hideIME() { - Log.v(TAG, "Called notify_hideIME"); - instance.runOnUiThread(new Runnable() { - @Override - public void run() { - mView.requestFocus(); - boolean answer = imm.hideSoftInputFromWindow(mView.getWindowToken(), 0); - Log.v(TAG, "Done Calling notify_hideIME, answer = " + answer); - } - }); - } - - - private native void startGraalApp(String[] launchArgs); - private native long surfaceReady(Surface surface, float density); - private native void nativeSetSurface(Surface surface); - private native void nativeSurfaceRedrawNeeded(); - private native void nativeGotTouchEvent(int pcount, int[] actions, int[] ids, int[] touchXs, int[] touchYs); - private native void nativeGotKeyEvent(int action, int keycode); - private native void nativedispatchKeyEvent(int type, int key, char[] chars, int charCount, int modifiers); - private native void nativeDispatchLifecycleEvent(String event); - private native void nativeDispatchActivityResult(int requestCode, int resultCode, Intent intent); - - class InternalSurfaceView extends SurfaceView { - private static final int ACTION_POINTER_STILL = -1; - - public InternalSurfaceView(Context context) { - super(context); - setFocusableInTouchMode(true); - setFocusable(true); - } - - @Override - public boolean dispatchTouchEvent(MotionEvent event) { - int action = event.getAction(); - int actionCode = action & MotionEvent.ACTION_MASK; - final int pcount = event.getPointerCount(); - final int[] actions = new int[pcount]; - final int[] ids = new int[pcount]; - final int[] touchXs = new int[pcount]; - final int[] touchYs = new int[pcount]; - Log.v(TAG, "Activity, get touch event, pcount = "+pcount); - if (pcount > 1) { - //multitouch - if (actionCode == MotionEvent.ACTION_POINTER_DOWN - || actionCode == MotionEvent.ACTION_POINTER_UP) { - - int pointerIndex = event.getActionIndex(); - for (int i = 0; i < pcount; i++) { - actions[i] = pointerIndex == i ? actionCode : ACTION_POINTER_STILL; - ids[i] = event.getPointerId(i); - touchXs[i] = (int) (event.getX(i)/density); - touchYs[i] = (int) (event.getY(i)/density); - } - } else if (actionCode == MotionEvent.ACTION_MOVE) { - for (int i = 0; i < pcount; i++) { - touchXs[i] = (int) (event.getX(i)/density); - touchYs[i] = (int) (event.getY(i)/density); - actions[i] = MotionEvent.ACTION_MOVE; - ids[i] = event.getPointerId(i); - } - } - } else { - //single touch - actions[0] = actionCode; - ids[0] = event.getPointerId(0); - touchXs[0] = (int) (event.getX()/density); - touchYs[0] = (int) (event.getY()/density); - } - if (!isFocused()) { - Log.v(TAG, "View wasn't focused, requesting focus"); - requestFocus(); - } - nativeGotTouchEvent(pcount, actions, ids, touchXs, touchYs); - return true; - } - - @Override - public boolean dispatchKeyEvent(final KeyEvent event) { - Log.v(TAG, "Activity, process get key event, action = "+event.getAction()); - processAndroidKeyEvent (event); - // nativeGotKeyEvent(event.getAction(), event.getKeyCode()); - return true; - } - } - - @Override - protected void onDestroy() { - Log.v(TAG, "onDestroy"); - super.onDestroy(); - notifyLifecycleEvent("destroy"); - android.os.Process.killProcess(android.os.Process.myPid()); - } - - @Override - protected void onPause() { - Log.v(TAG, "onPause"); - super.onPause(); - notifyLifecycleEvent("pause"); - } - - @Override - protected void onResume() { - Log.v(TAG, "onResume"); - super.onResume(); - notifyLifecycleEvent("resume"); - Log.v(TAG, "onResume done"); - } - - @Override - protected void onStart() { - Log.v(TAG, "onStart"); - super.onStart(); - notifyLifecycleEvent("start"); - Log.v(TAG, "onStart done"); - } - - @Override - protected void onRestart() { - Log.v(TAG, "onRestart"); - super.onRestart(); - notifyLifecycleEvent("restart"); - } - - @Override - protected void onStop() { - Log.v(TAG, "onStop"); - super.onStop(); - notifyLifecycleEvent("stop"); - } - - private void notifyLifecycleEvent(String event) { - if (graalStarted) { - nativeDispatchLifecycleEvent(event); - } - } - - public final static int PRESS = 111; - public final static int RELEASE = 112; - public final static int TYPED = 113; - - private int deadKey = 0; - - void processAndroidKeyEvent (KeyEvent event) { - System.out.println("KeyEvent: " + event+" with action = "+event.getAction()); - int jfxModifiers = mapAndroidModifierToJfx(event.getMetaState()); - switch (event.getAction()) { - case KeyEvent.ACTION_DOWN: - KeyCode jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); -System.out.println ("[JVDBG] eventkeycode = "+event.getKeyCode()+" and jfxkc = "+jfxKeyCode+" with code "+ jfxKeyCode.impl_getCode()); - nativedispatchKeyEvent(PRESS, jfxKeyCode.impl_getCode(), jfxKeyCode.impl_getChar().toCharArray(), jfxKeyCode.impl_getChar().toCharArray().length, jfxModifiers); - break; - - case KeyEvent.ACTION_UP: - jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); - nativedispatchKeyEvent(RELEASE, jfxKeyCode.impl_getCode(), jfxKeyCode.impl_getChar().toCharArray(), jfxKeyCode.impl_getChar().toCharArray().length, jfxModifiers); - int unicodeChar = event.getUnicodeChar(); - if ((unicodeChar & KeyCharacterMap.COMBINING_ACCENT) != 0) { - deadKey = unicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK; - return; - } - - if (deadKey != 0 && unicodeChar != 0) { - unicodeChar = KeyCharacterMap.getDeadChar(deadKey, unicodeChar); - deadKey = 0; - } - - if (unicodeChar != 0) { - nativedispatchKeyEvent(TYPED, KeyCode.UNDEFINED.impl_getCode(), Character.toChars(unicodeChar), 1, jfxModifiers); - } - - break; - - case KeyEvent.ACTION_MULTIPLE: - if (event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN) { - nativedispatchKeyEvent(TYPED, KeyCode.UNDEFINED.impl_getCode(), event.getCharacters().toCharArray(), event.getCharacters().toCharArray().length, jfxModifiers); - } else { - jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); - for (int i = 0; i < event.getRepeatCount(); i++) { - nativedispatchKeyEvent(PRESS, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); - nativedispatchKeyEvent(RELEASE, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); - nativedispatchKeyEvent(TYPED, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); - } - } - - break; - default: - System.err.println("DalvikInput.onKeyEvent Unknown Action " + event.getAction()); - break; - } - } - - private final static int MODIFIER_SHIFT = 1; - private final static int MODIFIER_CONTROL = 2; - private final static int MODIFIER_ALT = 4; - private final static int MODIFIER_WINDOWS = 8; - - - private static int mapAndroidModifierToJfx(int androidMetaStates) { - int jfxModifiers = 0; - - if ((androidMetaStates & KeyEvent.META_SHIFT_MASK) != 0) { - jfxModifiers += MODIFIER_SHIFT; - } - - if ((androidMetaStates & KeyEvent.META_CTRL_MASK) != 0) { - jfxModifiers += MODIFIER_CONTROL; - } - - if ((androidMetaStates & KeyEvent.META_ALT_MASK) != 0) { - jfxModifiers += MODIFIER_ALT; - } - - if ((androidMetaStates & KeyEvent.META_META_ON) != 0) { - jfxModifiers += MODIFIER_WINDOWS; - } - return jfxModifiers; - } - - - private static KeyCode mapAndroidKeyCodeToJfx(int keycode) { - switch (keycode) { - case KeyEvent.KEYCODE_UNKNOWN: return KeyCode.UNDEFINED; - case KeyEvent.KEYCODE_HOME: return KeyCode.HOME; - case KeyEvent.KEYCODE_BACK: return KeyCode.ESCAPE; // special back key mapped to ESC - case KeyEvent.KEYCODE_0: return KeyCode.DIGIT0; - case KeyEvent.KEYCODE_1: return KeyCode.DIGIT1; - case KeyEvent.KEYCODE_2: return KeyCode.DIGIT2; - case KeyEvent.KEYCODE_3: return KeyCode.DIGIT3; - case KeyEvent.KEYCODE_4: return KeyCode.DIGIT4; - case KeyEvent.KEYCODE_5: return KeyCode.DIGIT5; - case KeyEvent.KEYCODE_6: return KeyCode.DIGIT6; - case KeyEvent.KEYCODE_7: return KeyCode.DIGIT7; - case KeyEvent.KEYCODE_8: return KeyCode.DIGIT8; - case KeyEvent.KEYCODE_9: return KeyCode.DIGIT9; - case KeyEvent.KEYCODE_STAR: return KeyCode.STAR; - case KeyEvent.KEYCODE_POUND: return KeyCode.POUND; - case KeyEvent.KEYCODE_DPAD_UP: return KeyCode.UP; - case KeyEvent.KEYCODE_DPAD_DOWN: return KeyCode.DOWN; - case KeyEvent.KEYCODE_DPAD_LEFT: return KeyCode.LEFT; - case KeyEvent.KEYCODE_DPAD_RIGHT: return KeyCode.RIGHT; - case KeyEvent.KEYCODE_VOLUME_UP: return KeyCode.VOLUME_UP; - case KeyEvent.KEYCODE_VOLUME_DOWN: return KeyCode.VOLUME_DOWN; - case KeyEvent.KEYCODE_POWER: return KeyCode.POWER; - case KeyEvent.KEYCODE_CLEAR: return KeyCode.CLEAR; - case KeyEvent.KEYCODE_A: return KeyCode.A; - case KeyEvent.KEYCODE_B: return KeyCode.B; - case KeyEvent.KEYCODE_C: return KeyCode.C; - case KeyEvent.KEYCODE_D: return KeyCode.D; - case KeyEvent.KEYCODE_E: return KeyCode.E; - case KeyEvent.KEYCODE_F: return KeyCode.F; - case KeyEvent.KEYCODE_G: return KeyCode.G; - case KeyEvent.KEYCODE_H: return KeyCode.H; - case KeyEvent.KEYCODE_I: return KeyCode.I; - case KeyEvent.KEYCODE_J: return KeyCode.J; - case KeyEvent.KEYCODE_K: return KeyCode.K; - case KeyEvent.KEYCODE_L: return KeyCode.L; - case KeyEvent.KEYCODE_M: return KeyCode.M; - case KeyEvent.KEYCODE_N: return KeyCode.N; - case KeyEvent.KEYCODE_O: return KeyCode.O; - case KeyEvent.KEYCODE_P: return KeyCode.P; - case KeyEvent.KEYCODE_Q: return KeyCode.Q; - case KeyEvent.KEYCODE_R: return KeyCode.R; - case KeyEvent.KEYCODE_S: return KeyCode.S; - case KeyEvent.KEYCODE_T: return KeyCode.T; - case KeyEvent.KEYCODE_U: return KeyCode.U; - case KeyEvent.KEYCODE_V: return KeyCode.V; - case KeyEvent.KEYCODE_W: return KeyCode.W; - case KeyEvent.KEYCODE_X: return KeyCode.X; - case KeyEvent.KEYCODE_Y: return KeyCode.Y; - case KeyEvent.KEYCODE_Z: return KeyCode.Z; - case KeyEvent.KEYCODE_COMMA: return KeyCode.COMMA; - case KeyEvent.KEYCODE_PERIOD: return KeyCode.PERIOD; - case KeyEvent.KEYCODE_ALT_LEFT: return KeyCode.ALT; - case KeyEvent.KEYCODE_ALT_RIGHT: return KeyCode.ALT; - case KeyEvent.KEYCODE_SHIFT_LEFT: return KeyCode.SHIFT; - case KeyEvent.KEYCODE_SHIFT_RIGHT: return KeyCode.SHIFT; - case KeyEvent.KEYCODE_TAB: return KeyCode.TAB; - case KeyEvent.KEYCODE_SPACE: return KeyCode.SPACE; - case KeyEvent.KEYCODE_ENTER: return KeyCode.ENTER; - case KeyEvent.KEYCODE_DEL: return KeyCode.BACK_SPACE; - case KeyEvent.KEYCODE_GRAVE: return KeyCode.DEAD_GRAVE; - case KeyEvent.KEYCODE_MINUS: return KeyCode.MINUS; - case KeyEvent.KEYCODE_EQUALS: return KeyCode.EQUALS; - case KeyEvent.KEYCODE_LEFT_BRACKET: return KeyCode.BRACELEFT; - case KeyEvent.KEYCODE_RIGHT_BRACKET: return KeyCode.BRACERIGHT; - case KeyEvent.KEYCODE_BACKSLASH: return KeyCode.BACK_SLASH; - case KeyEvent.KEYCODE_SEMICOLON: return KeyCode.SEMICOLON; - case KeyEvent.KEYCODE_SLASH: return KeyCode.SLASH; - case KeyEvent.KEYCODE_AT: return KeyCode.AT; - case KeyEvent.KEYCODE_PLUS: return KeyCode.PLUS; - case KeyEvent.KEYCODE_MENU: return KeyCode.CONTEXT_MENU; - case KeyEvent.KEYCODE_SEARCH: return KeyCode.FIND; - case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: return KeyCode.PLAY; - case KeyEvent.KEYCODE_MEDIA_STOP: return KeyCode.STOP; - case KeyEvent.KEYCODE_MEDIA_NEXT: return KeyCode.TRACK_NEXT; - case KeyEvent.KEYCODE_MEDIA_PREVIOUS: return KeyCode.TRACK_PREV; - case KeyEvent.KEYCODE_MEDIA_REWIND: return KeyCode.REWIND; - case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: return KeyCode.FAST_FWD; - case KeyEvent.KEYCODE_MUTE: return KeyCode.MUTE; - case KeyEvent.KEYCODE_PAGE_UP: return KeyCode.PAGE_UP; - case KeyEvent.KEYCODE_PAGE_DOWN: return KeyCode.PAGE_DOWN; - case KeyEvent.KEYCODE_BUTTON_A: return KeyCode.GAME_A; - case KeyEvent.KEYCODE_BUTTON_B: return KeyCode.GAME_B; - case KeyEvent.KEYCODE_BUTTON_C: return KeyCode.GAME_C; - case KeyEvent.KEYCODE_BUTTON_X: return KeyCode.GAME_D; - case KeyEvent.KEYCODE_BUTTON_MODE: return KeyCode.MODECHANGE; - case KeyEvent.KEYCODE_ESCAPE: return KeyCode.ESCAPE; - case KeyEvent.KEYCODE_CTRL_LEFT: return KeyCode.CONTROL; - case KeyEvent.KEYCODE_CTRL_RIGHT: return KeyCode.CONTROL; - case KeyEvent.KEYCODE_CAPS_LOCK: return KeyCode.CAPS; - case KeyEvent.KEYCODE_SCROLL_LOCK: return KeyCode.SCROLL_LOCK; - case KeyEvent.KEYCODE_META_LEFT: return KeyCode.META; - case KeyEvent.KEYCODE_META_RIGHT: return KeyCode.META; - case KeyEvent.KEYCODE_SYSRQ: return KeyCode.PRINTSCREEN; - case KeyEvent.KEYCODE_BREAK: return KeyCode.PAUSE; - case KeyEvent.KEYCODE_MOVE_HOME: return KeyCode.BEGIN; - case KeyEvent.KEYCODE_MOVE_END: return KeyCode.END; - case KeyEvent.KEYCODE_INSERT: return KeyCode.INSERT; - case KeyEvent.KEYCODE_MEDIA_PLAY: return KeyCode.PLAY; - case KeyEvent.KEYCODE_MEDIA_EJECT: return KeyCode.EJECT_TOGGLE; - case KeyEvent.KEYCODE_MEDIA_RECORD: return KeyCode.RECORD; - case KeyEvent.KEYCODE_F1: return KeyCode.F1; - case KeyEvent.KEYCODE_F2: return KeyCode.F2; - case KeyEvent.KEYCODE_F3: return KeyCode.F3; - case KeyEvent.KEYCODE_F4: return KeyCode.F4; - case KeyEvent.KEYCODE_F5: return KeyCode.F5; - case KeyEvent.KEYCODE_F6: return KeyCode.F6; - case KeyEvent.KEYCODE_F7: return KeyCode.F7; - case KeyEvent.KEYCODE_F8: return KeyCode.F8; - case KeyEvent.KEYCODE_F9: return KeyCode.F9; - case KeyEvent.KEYCODE_F10: return KeyCode.F10; - case KeyEvent.KEYCODE_F11: return KeyCode.F11; - case KeyEvent.KEYCODE_F12: return KeyCode.F12; - case KeyEvent.KEYCODE_NUM_LOCK: return KeyCode.NUM_LOCK; - case KeyEvent.KEYCODE_NUMPAD_0: return KeyCode.NUMPAD0; - case KeyEvent.KEYCODE_NUMPAD_1: return KeyCode.NUMPAD1; - case KeyEvent.KEYCODE_NUMPAD_2: return KeyCode.NUMPAD2; - case KeyEvent.KEYCODE_NUMPAD_3: return KeyCode.NUMPAD3; - case KeyEvent.KEYCODE_NUMPAD_4: return KeyCode.NUMPAD4; - case KeyEvent.KEYCODE_NUMPAD_5: return KeyCode.NUMPAD5; - case KeyEvent.KEYCODE_NUMPAD_6: return KeyCode.NUMPAD6; - case KeyEvent.KEYCODE_NUMPAD_7: return KeyCode.NUMPAD7; - case KeyEvent.KEYCODE_NUMPAD_8: return KeyCode.NUMPAD8; - case KeyEvent.KEYCODE_NUMPAD_9: return KeyCode.NUMPAD9; - case KeyEvent.KEYCODE_NUMPAD_DIVIDE: return KeyCode.DIVIDE; - case KeyEvent.KEYCODE_NUMPAD_MULTIPLY: return KeyCode.MULTIPLY; - case KeyEvent.KEYCODE_NUMPAD_SUBTRACT: return KeyCode.SUBTRACT; - case KeyEvent.KEYCODE_NUMPAD_ADD: return KeyCode.ADD; - case KeyEvent.KEYCODE_NUMPAD_DOT: return KeyCode.PERIOD; - case KeyEvent.KEYCODE_NUMPAD_COMMA: return KeyCode.COMMA; - case KeyEvent.KEYCODE_NUMPAD_ENTER: return KeyCode.ENTER; - case KeyEvent.KEYCODE_NUMPAD_EQUALS: return KeyCode.EQUALS; - case KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN: return KeyCode.LEFT_PARENTHESIS; - case KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN: return KeyCode.RIGHT_PARENTHESIS; - case KeyEvent.KEYCODE_VOLUME_MUTE: return KeyCode.MUTE; - case KeyEvent.KEYCODE_INFO: return KeyCode.INFO; - case KeyEvent.KEYCODE_CHANNEL_UP: return KeyCode.CHANNEL_UP; - case KeyEvent.KEYCODE_CHANNEL_DOWN: return KeyCode.CHANNEL_DOWN; - case KeyEvent.KEYCODE_PROG_RED: return KeyCode.COLORED_KEY_0; - case KeyEvent.KEYCODE_PROG_GREEN: return KeyCode.COLORED_KEY_1; - case KeyEvent.KEYCODE_PROG_YELLOW: return KeyCode.COLORED_KEY_2; - case KeyEvent.KEYCODE_PROG_BLUE: return KeyCode.COLORED_KEY_3; - case KeyEvent.KEYCODE_KATAKANA_HIRAGANA: return KeyCode.JAPANESE_HIRAGANA; - case KeyEvent.KEYCODE_KANA: return KeyCode.KANA; - default: - return KeyCode.UNDEFINED; - } - } - -} +/* + * Copyright (c) 2019, 2020, Gluon + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL GLUON BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package com.gluonhq.helloandroid; + +import android.app.Activity; +import android.content.Context; +import android.content.Intent; +import android.content.pm.ActivityInfo; +import android.content.pm.PackageManager; +import android.content.pm.PackageManager.NameNotFoundException; +import android.graphics.PixelFormat; +import android.graphics.Rect; +import android.os.Bundle; +import android.util.DisplayMetrics; +import android.util.Log; + +import android.view.inputmethod.InputConnection; + +import android.view.KeyEvent; +import android.view.KeyCharacterMap; +import android.view.MotionEvent; +import android.view.Surface; +import android.view.SurfaceHolder; +import android.view.SurfaceView; +import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.view.WindowManager.LayoutParams; +import android.view.inputmethod.InputMethodManager; +import android.widget.FrameLayout; + +import java.util.TimeZone; +import javafx.scene.input.KeyCode; + +public class MainActivity extends Activity implements SurfaceHolder.Callback, + SurfaceHolder.Callback2 { + + private static MainActivity instance; + private static FrameLayout mViewGroup; + private static SurfaceView mView; + private long nativeWindowPtr; + private float density; + + private static final String TAG = "GraalActivity"; + + boolean graalStarted = false; + + private static InputMethodManager imm; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Log.v(TAG, "onCreate start, using Android Logging v1"); + Log.v(TAG, "Using modded MainActivity to prevent device lock"); + System.err.println("onCreate called, writing this to System.err"); + super.onCreate(savedInstanceState); + + getWindow().requestFeature(Window.FEATURE_NO_TITLE); + getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); + getWindow().setSoftInputMode( + WindowManager.LayoutParams.SOFT_INPUT_STATE_UNSPECIFIED + | WindowManager.LayoutParams.SOFT_INPUT_ADJUST_NOTHING); + getWindow().setFormat(PixelFormat.RGBA_8888); + + + mView = new InternalSurfaceView(this); + mView.getHolder().addCallback(this); + mViewGroup = new FrameLayout(this); + mViewGroup.addView(mView); + setContentView(mViewGroup); + instance = this; + + imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE); + Log.v(TAG, "onCreate done"); + } + + @Override + public void surfaceCreated(SurfaceHolder holder) { + Log.v(TAG, "surfaceCreated for "+this); + Log.v(TAG, "loading substrate library"); + System.loadLibrary("substrate"); + Log.v(TAG, "loaded substrate library"); + nativeSetSurface(holder.getSurface()); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + density = metrics.density; + Log.v(TAG, "metrics = "+metrics+", density = "+density); + nativeWindowPtr = surfaceReady(holder.getSurface(), density); + Rect currentBounds = new Rect(); + mView.getRootView().getWindowVisibleDisplayFrame(currentBounds); + + Log.v(TAG, "Surface created, native code informed about it, nativeWindow at "+nativeWindowPtr); + if (graalStarted) { + Log.v(TAG, "GraalApp is already started."); + } else { + Log.v(TAG, "We will now launch Graal in a separate thread"); + final String[] launchArgs = { + "-Duser.home=" + getApplicationInfo().dataDir, + "-Djava.io.tmpdir=" + getApplicationInfo().dataDir, + "-Duser.timezone=" + TimeZone.getDefault().getID(), + "-DLaunch.URL=" + System.getProperty("Launch.URL", ""), + "-DLaunch.LocalNotification=" + System.getProperty("Launch.LocalNotification", ""), + "-DLaunch.PushNotification=" + System.getProperty("Launch.PushNotification", "") + }; + Thread t = new Thread() { + @Override public void run() { + startGraalApp(launchArgs); + } + }; + t.start(); + graalStarted = true; + Log.v(TAG, "graalStarted true"); + } + Log.v(TAG, "surfaceCreated done"); + } + + + + @Override + public void surfaceChanged(SurfaceHolder holder, int format, int width, + int height) { + Log.v(TAG, "surfaceChanged start"); + Log.v(TAG, "[MainActivity] surfaceChanged, format = "+format+", width = "+width+", height = "+height); + nativeSetSurface(holder.getSurface()); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + density = metrics.density; + Log.v(TAG, "surfaceChanged done, metrics = "+metrics+", density = "+density); + } + + @Override + public void surfaceDestroyed(SurfaceHolder holder) { + System.err.println("[MainGraalActivity] surfaceDestroyed, ignore for now"); + // _surfaceChanged(null); + } + + @Override + public void surfaceRedrawNeeded(SurfaceHolder holder) { + Log.v(TAG, "SurfaceRedraw needed start"); + DisplayMetrics metrics = new DisplayMetrics(); + getWindowManager().getDefaultDisplay().getMetrics(metrics); + Log.v(TAG, "ask native graallayer to redraw surface"); + nativeSurfaceRedrawNeeded(); + try { + Thread.sleep(500); + Log.v(TAG, "surfaceredraw needed part 1 done"); + nativeSurfaceRedrawNeeded(); + } catch (Exception e) { + e.printStackTrace(); + } + Log.v(TAG, "surfaceredraw needed (and wait) done"); + } + + @Override + public void onActivityResult(int requestCode, int resultCode, Intent intent) { + Log.v(TAG, "onActivityResult with requestCode " + requestCode + " and resultCode = " + resultCode + " and intent = " + intent); + nativeDispatchActivityResult(requestCode, resultCode, intent); + } + + static MainActivity getInstance() { + return instance; + } + + static ViewGroup getViewGroup() { + return mViewGroup; + } + + private static void showIME() { + Log.v(TAG, "Called notify_showIME for imm = "+imm+", mv = "+mView); + instance.runOnUiThread(new Runnable() { + @Override + public void run() { + mView.requestFocus(); + boolean answer = imm.showSoftInput(mView, 0); + Log.v(TAG, "Done calling notify_showIME, answer = " + answer); + } + }); + } + + private static void hideIME() { + Log.v(TAG, "Called notify_hideIME"); + instance.runOnUiThread(new Runnable() { + @Override + public void run() { + mView.requestFocus(); + boolean answer = imm.hideSoftInputFromWindow(mView.getWindowToken(), 0); + Log.v(TAG, "Done Calling notify_hideIME, answer = " + answer); + } + }); + } + + + private native void startGraalApp(String[] launchArgs); + private native long surfaceReady(Surface surface, float density); + private native void nativeSetSurface(Surface surface); + private native void nativeSurfaceRedrawNeeded(); + private native void nativeGotTouchEvent(int pcount, int[] actions, int[] ids, int[] touchXs, int[] touchYs); + private native void nativeGotKeyEvent(int action, int keycode); + private native void nativedispatchKeyEvent(int type, int key, char[] chars, int charCount, int modifiers); + private native void nativeDispatchLifecycleEvent(String event); + private native void nativeDispatchActivityResult(int requestCode, int resultCode, Intent intent); + + class InternalSurfaceView extends SurfaceView { + private static final int ACTION_POINTER_STILL = -1; + + public InternalSurfaceView(Context context) { + super(context); + setFocusableInTouchMode(true); + setFocusable(true); + } + + @Override + public boolean dispatchTouchEvent(MotionEvent event) { + int action = event.getAction(); + int actionCode = action & MotionEvent.ACTION_MASK; + final int pcount = event.getPointerCount(); + final int[] actions = new int[pcount]; + final int[] ids = new int[pcount]; + final int[] touchXs = new int[pcount]; + final int[] touchYs = new int[pcount]; + Log.v(TAG, "Activity, get touch event, pcount = "+pcount); + if (pcount > 1) { + //multitouch + if (actionCode == MotionEvent.ACTION_POINTER_DOWN + || actionCode == MotionEvent.ACTION_POINTER_UP) { + + int pointerIndex = event.getActionIndex(); + for (int i = 0; i < pcount; i++) { + actions[i] = pointerIndex == i ? actionCode : ACTION_POINTER_STILL; + ids[i] = event.getPointerId(i); + touchXs[i] = (int) (event.getX(i)/density); + touchYs[i] = (int) (event.getY(i)/density); + } + } else if (actionCode == MotionEvent.ACTION_MOVE) { + for (int i = 0; i < pcount; i++) { + touchXs[i] = (int) (event.getX(i)/density); + touchYs[i] = (int) (event.getY(i)/density); + actions[i] = MotionEvent.ACTION_MOVE; + ids[i] = event.getPointerId(i); + } + } + } else { + //single touch + actions[0] = actionCode; + ids[0] = event.getPointerId(0); + touchXs[0] = (int) (event.getX()/density); + touchYs[0] = (int) (event.getY()/density); + } + if (!isFocused()) { + Log.v(TAG, "View wasn't focused, requesting focus"); + requestFocus(); + } + nativeGotTouchEvent(pcount, actions, ids, touchXs, touchYs); + return true; + } + + @Override + public boolean dispatchKeyEvent(final KeyEvent event) { + Log.v(TAG, "Activity, process get key event, action = "+event.getAction()); + processAndroidKeyEvent (event); + // nativeGotKeyEvent(event.getAction(), event.getKeyCode()); + return true; + } + } + + @Override + protected void onDestroy() { + Log.v(TAG, "onDestroy"); + super.onDestroy(); + notifyLifecycleEvent("destroy"); + android.os.Process.killProcess(android.os.Process.myPid()); + } + + @Override + protected void onPause() { + Log.v(TAG, "onPause"); + super.onPause(); + notifyLifecycleEvent("pause"); + } + + @Override + protected void onResume() { + Log.v(TAG, "onResume"); + super.onResume(); + notifyLifecycleEvent("resume"); + Log.v(TAG, "onResume done"); + } + + @Override + protected void onStart() { + Log.v(TAG, "onStart"); + super.onStart(); + notifyLifecycleEvent("start"); + Log.v(TAG, "onStart done"); + } + + @Override + protected void onRestart() { + Log.v(TAG, "onRestart"); + super.onRestart(); + notifyLifecycleEvent("restart"); + } + + @Override + protected void onStop() { + Log.v(TAG, "onStop"); + super.onStop(); + notifyLifecycleEvent("stop"); + } + + private void notifyLifecycleEvent(String event) { + if (graalStarted) { + nativeDispatchLifecycleEvent(event); + } + } + + public final static int PRESS = 111; + public final static int RELEASE = 112; + public final static int TYPED = 113; + + private int deadKey = 0; + + void processAndroidKeyEvent (KeyEvent event) { + System.out.println("KeyEvent: " + event+" with action = "+event.getAction()); + int jfxModifiers = mapAndroidModifierToJfx(event.getMetaState()); + switch (event.getAction()) { + case KeyEvent.ACTION_DOWN: + KeyCode jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); +System.out.println ("[JVDBG] eventkeycode = "+event.getKeyCode()+" and jfxkc = "+jfxKeyCode+" with code "+ jfxKeyCode.impl_getCode()); + nativedispatchKeyEvent(PRESS, jfxKeyCode.impl_getCode(), jfxKeyCode.impl_getChar().toCharArray(), jfxKeyCode.impl_getChar().toCharArray().length, jfxModifiers); + break; + + case KeyEvent.ACTION_UP: + jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); + nativedispatchKeyEvent(RELEASE, jfxKeyCode.impl_getCode(), jfxKeyCode.impl_getChar().toCharArray(), jfxKeyCode.impl_getChar().toCharArray().length, jfxModifiers); + int unicodeChar = event.getUnicodeChar(); + if ((unicodeChar & KeyCharacterMap.COMBINING_ACCENT) != 0) { + deadKey = unicodeChar & KeyCharacterMap.COMBINING_ACCENT_MASK; + return; + } + + if (deadKey != 0 && unicodeChar != 0) { + unicodeChar = KeyCharacterMap.getDeadChar(deadKey, unicodeChar); + deadKey = 0; + } + + if (unicodeChar != 0) { + nativedispatchKeyEvent(TYPED, KeyCode.UNDEFINED.impl_getCode(), Character.toChars(unicodeChar), 1, jfxModifiers); + } + + break; + + case KeyEvent.ACTION_MULTIPLE: + if (event.getKeyCode() == KeyEvent.KEYCODE_UNKNOWN) { + nativedispatchKeyEvent(TYPED, KeyCode.UNDEFINED.impl_getCode(), event.getCharacters().toCharArray(), event.getCharacters().toCharArray().length, jfxModifiers); + } else { + jfxKeyCode = mapAndroidKeyCodeToJfx(event.getKeyCode()); + for (int i = 0; i < event.getRepeatCount(); i++) { + nativedispatchKeyEvent(PRESS, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); + nativedispatchKeyEvent(RELEASE, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); + nativedispatchKeyEvent(TYPED, jfxKeyCode.impl_getCode(), null, 0, jfxModifiers); + } + } + + break; + default: + System.err.println("DalvikInput.onKeyEvent Unknown Action " + event.getAction()); + break; + } + } + + private final static int MODIFIER_SHIFT = 1; + private final static int MODIFIER_CONTROL = 2; + private final static int MODIFIER_ALT = 4; + private final static int MODIFIER_WINDOWS = 8; + + + private static int mapAndroidModifierToJfx(int androidMetaStates) { + int jfxModifiers = 0; + + if ((androidMetaStates & KeyEvent.META_SHIFT_MASK) != 0) { + jfxModifiers += MODIFIER_SHIFT; + } + + if ((androidMetaStates & KeyEvent.META_CTRL_MASK) != 0) { + jfxModifiers += MODIFIER_CONTROL; + } + + if ((androidMetaStates & KeyEvent.META_ALT_MASK) != 0) { + jfxModifiers += MODIFIER_ALT; + } + + if ((androidMetaStates & KeyEvent.META_META_ON) != 0) { + jfxModifiers += MODIFIER_WINDOWS; + } + return jfxModifiers; + } + + + private static KeyCode mapAndroidKeyCodeToJfx(int keycode) { + switch (keycode) { + case KeyEvent.KEYCODE_UNKNOWN: return KeyCode.UNDEFINED; + case KeyEvent.KEYCODE_HOME: return KeyCode.HOME; + case KeyEvent.KEYCODE_BACK: return KeyCode.ESCAPE; // special back key mapped to ESC + case KeyEvent.KEYCODE_0: return KeyCode.DIGIT0; + case KeyEvent.KEYCODE_1: return KeyCode.DIGIT1; + case KeyEvent.KEYCODE_2: return KeyCode.DIGIT2; + case KeyEvent.KEYCODE_3: return KeyCode.DIGIT3; + case KeyEvent.KEYCODE_4: return KeyCode.DIGIT4; + case KeyEvent.KEYCODE_5: return KeyCode.DIGIT5; + case KeyEvent.KEYCODE_6: return KeyCode.DIGIT6; + case KeyEvent.KEYCODE_7: return KeyCode.DIGIT7; + case KeyEvent.KEYCODE_8: return KeyCode.DIGIT8; + case KeyEvent.KEYCODE_9: return KeyCode.DIGIT9; + case KeyEvent.KEYCODE_STAR: return KeyCode.STAR; + case KeyEvent.KEYCODE_POUND: return KeyCode.POUND; + case KeyEvent.KEYCODE_DPAD_UP: return KeyCode.UP; + case KeyEvent.KEYCODE_DPAD_DOWN: return KeyCode.DOWN; + case KeyEvent.KEYCODE_DPAD_LEFT: return KeyCode.LEFT; + case KeyEvent.KEYCODE_DPAD_RIGHT: return KeyCode.RIGHT; + case KeyEvent.KEYCODE_VOLUME_UP: return KeyCode.VOLUME_UP; + case KeyEvent.KEYCODE_VOLUME_DOWN: return KeyCode.VOLUME_DOWN; + case KeyEvent.KEYCODE_POWER: return KeyCode.POWER; + case KeyEvent.KEYCODE_CLEAR: return KeyCode.CLEAR; + case KeyEvent.KEYCODE_A: return KeyCode.A; + case KeyEvent.KEYCODE_B: return KeyCode.B; + case KeyEvent.KEYCODE_C: return KeyCode.C; + case KeyEvent.KEYCODE_D: return KeyCode.D; + case KeyEvent.KEYCODE_E: return KeyCode.E; + case KeyEvent.KEYCODE_F: return KeyCode.F; + case KeyEvent.KEYCODE_G: return KeyCode.G; + case KeyEvent.KEYCODE_H: return KeyCode.H; + case KeyEvent.KEYCODE_I: return KeyCode.I; + case KeyEvent.KEYCODE_J: return KeyCode.J; + case KeyEvent.KEYCODE_K: return KeyCode.K; + case KeyEvent.KEYCODE_L: return KeyCode.L; + case KeyEvent.KEYCODE_M: return KeyCode.M; + case KeyEvent.KEYCODE_N: return KeyCode.N; + case KeyEvent.KEYCODE_O: return KeyCode.O; + case KeyEvent.KEYCODE_P: return KeyCode.P; + case KeyEvent.KEYCODE_Q: return KeyCode.Q; + case KeyEvent.KEYCODE_R: return KeyCode.R; + case KeyEvent.KEYCODE_S: return KeyCode.S; + case KeyEvent.KEYCODE_T: return KeyCode.T; + case KeyEvent.KEYCODE_U: return KeyCode.U; + case KeyEvent.KEYCODE_V: return KeyCode.V; + case KeyEvent.KEYCODE_W: return KeyCode.W; + case KeyEvent.KEYCODE_X: return KeyCode.X; + case KeyEvent.KEYCODE_Y: return KeyCode.Y; + case KeyEvent.KEYCODE_Z: return KeyCode.Z; + case KeyEvent.KEYCODE_COMMA: return KeyCode.COMMA; + case KeyEvent.KEYCODE_PERIOD: return KeyCode.PERIOD; + case KeyEvent.KEYCODE_ALT_LEFT: return KeyCode.ALT; + case KeyEvent.KEYCODE_ALT_RIGHT: return KeyCode.ALT; + case KeyEvent.KEYCODE_SHIFT_LEFT: return KeyCode.SHIFT; + case KeyEvent.KEYCODE_SHIFT_RIGHT: return KeyCode.SHIFT; + case KeyEvent.KEYCODE_TAB: return KeyCode.TAB; + case KeyEvent.KEYCODE_SPACE: return KeyCode.SPACE; + case KeyEvent.KEYCODE_ENTER: return KeyCode.ENTER; + case KeyEvent.KEYCODE_DEL: return KeyCode.BACK_SPACE; + case KeyEvent.KEYCODE_GRAVE: return KeyCode.DEAD_GRAVE; + case KeyEvent.KEYCODE_MINUS: return KeyCode.MINUS; + case KeyEvent.KEYCODE_EQUALS: return KeyCode.EQUALS; + case KeyEvent.KEYCODE_LEFT_BRACKET: return KeyCode.BRACELEFT; + case KeyEvent.KEYCODE_RIGHT_BRACKET: return KeyCode.BRACERIGHT; + case KeyEvent.KEYCODE_BACKSLASH: return KeyCode.BACK_SLASH; + case KeyEvent.KEYCODE_SEMICOLON: return KeyCode.SEMICOLON; + case KeyEvent.KEYCODE_SLASH: return KeyCode.SLASH; + case KeyEvent.KEYCODE_AT: return KeyCode.AT; + case KeyEvent.KEYCODE_PLUS: return KeyCode.PLUS; + case KeyEvent.KEYCODE_MENU: return KeyCode.CONTEXT_MENU; + case KeyEvent.KEYCODE_SEARCH: return KeyCode.FIND; + case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE: return KeyCode.PLAY; + case KeyEvent.KEYCODE_MEDIA_STOP: return KeyCode.STOP; + case KeyEvent.KEYCODE_MEDIA_NEXT: return KeyCode.TRACK_NEXT; + case KeyEvent.KEYCODE_MEDIA_PREVIOUS: return KeyCode.TRACK_PREV; + case KeyEvent.KEYCODE_MEDIA_REWIND: return KeyCode.REWIND; + case KeyEvent.KEYCODE_MEDIA_FAST_FORWARD: return KeyCode.FAST_FWD; + case KeyEvent.KEYCODE_MUTE: return KeyCode.MUTE; + case KeyEvent.KEYCODE_PAGE_UP: return KeyCode.PAGE_UP; + case KeyEvent.KEYCODE_PAGE_DOWN: return KeyCode.PAGE_DOWN; + case KeyEvent.KEYCODE_BUTTON_A: return KeyCode.GAME_A; + case KeyEvent.KEYCODE_BUTTON_B: return KeyCode.GAME_B; + case KeyEvent.KEYCODE_BUTTON_C: return KeyCode.GAME_C; + case KeyEvent.KEYCODE_BUTTON_X: return KeyCode.GAME_D; + case KeyEvent.KEYCODE_BUTTON_MODE: return KeyCode.MODECHANGE; + case KeyEvent.KEYCODE_ESCAPE: return KeyCode.ESCAPE; + case KeyEvent.KEYCODE_CTRL_LEFT: return KeyCode.CONTROL; + case KeyEvent.KEYCODE_CTRL_RIGHT: return KeyCode.CONTROL; + case KeyEvent.KEYCODE_CAPS_LOCK: return KeyCode.CAPS; + case KeyEvent.KEYCODE_SCROLL_LOCK: return KeyCode.SCROLL_LOCK; + case KeyEvent.KEYCODE_META_LEFT: return KeyCode.META; + case KeyEvent.KEYCODE_META_RIGHT: return KeyCode.META; + case KeyEvent.KEYCODE_SYSRQ: return KeyCode.PRINTSCREEN; + case KeyEvent.KEYCODE_BREAK: return KeyCode.PAUSE; + case KeyEvent.KEYCODE_MOVE_HOME: return KeyCode.BEGIN; + case KeyEvent.KEYCODE_MOVE_END: return KeyCode.END; + case KeyEvent.KEYCODE_INSERT: return KeyCode.INSERT; + case KeyEvent.KEYCODE_MEDIA_PLAY: return KeyCode.PLAY; + case KeyEvent.KEYCODE_MEDIA_EJECT: return KeyCode.EJECT_TOGGLE; + case KeyEvent.KEYCODE_MEDIA_RECORD: return KeyCode.RECORD; + case KeyEvent.KEYCODE_F1: return KeyCode.F1; + case KeyEvent.KEYCODE_F2: return KeyCode.F2; + case KeyEvent.KEYCODE_F3: return KeyCode.F3; + case KeyEvent.KEYCODE_F4: return KeyCode.F4; + case KeyEvent.KEYCODE_F5: return KeyCode.F5; + case KeyEvent.KEYCODE_F6: return KeyCode.F6; + case KeyEvent.KEYCODE_F7: return KeyCode.F7; + case KeyEvent.KEYCODE_F8: return KeyCode.F8; + case KeyEvent.KEYCODE_F9: return KeyCode.F9; + case KeyEvent.KEYCODE_F10: return KeyCode.F10; + case KeyEvent.KEYCODE_F11: return KeyCode.F11; + case KeyEvent.KEYCODE_F12: return KeyCode.F12; + case KeyEvent.KEYCODE_NUM_LOCK: return KeyCode.NUM_LOCK; + case KeyEvent.KEYCODE_NUMPAD_0: return KeyCode.NUMPAD0; + case KeyEvent.KEYCODE_NUMPAD_1: return KeyCode.NUMPAD1; + case KeyEvent.KEYCODE_NUMPAD_2: return KeyCode.NUMPAD2; + case KeyEvent.KEYCODE_NUMPAD_3: return KeyCode.NUMPAD3; + case KeyEvent.KEYCODE_NUMPAD_4: return KeyCode.NUMPAD4; + case KeyEvent.KEYCODE_NUMPAD_5: return KeyCode.NUMPAD5; + case KeyEvent.KEYCODE_NUMPAD_6: return KeyCode.NUMPAD6; + case KeyEvent.KEYCODE_NUMPAD_7: return KeyCode.NUMPAD7; + case KeyEvent.KEYCODE_NUMPAD_8: return KeyCode.NUMPAD8; + case KeyEvent.KEYCODE_NUMPAD_9: return KeyCode.NUMPAD9; + case KeyEvent.KEYCODE_NUMPAD_DIVIDE: return KeyCode.DIVIDE; + case KeyEvent.KEYCODE_NUMPAD_MULTIPLY: return KeyCode.MULTIPLY; + case KeyEvent.KEYCODE_NUMPAD_SUBTRACT: return KeyCode.SUBTRACT; + case KeyEvent.KEYCODE_NUMPAD_ADD: return KeyCode.ADD; + case KeyEvent.KEYCODE_NUMPAD_DOT: return KeyCode.PERIOD; + case KeyEvent.KEYCODE_NUMPAD_COMMA: return KeyCode.COMMA; + case KeyEvent.KEYCODE_NUMPAD_ENTER: return KeyCode.ENTER; + case KeyEvent.KEYCODE_NUMPAD_EQUALS: return KeyCode.EQUALS; + case KeyEvent.KEYCODE_NUMPAD_LEFT_PAREN: return KeyCode.LEFT_PARENTHESIS; + case KeyEvent.KEYCODE_NUMPAD_RIGHT_PAREN: return KeyCode.RIGHT_PARENTHESIS; + case KeyEvent.KEYCODE_VOLUME_MUTE: return KeyCode.MUTE; + case KeyEvent.KEYCODE_INFO: return KeyCode.INFO; + case KeyEvent.KEYCODE_CHANNEL_UP: return KeyCode.CHANNEL_UP; + case KeyEvent.KEYCODE_CHANNEL_DOWN: return KeyCode.CHANNEL_DOWN; + case KeyEvent.KEYCODE_PROG_RED: return KeyCode.COLORED_KEY_0; + case KeyEvent.KEYCODE_PROG_GREEN: return KeyCode.COLORED_KEY_1; + case KeyEvent.KEYCODE_PROG_YELLOW: return KeyCode.COLORED_KEY_2; + case KeyEvent.KEYCODE_PROG_BLUE: return KeyCode.COLORED_KEY_3; + case KeyEvent.KEYCODE_KATAKANA_HIRAGANA: return KeyCode.JAPANESE_HIRAGANA; + case KeyEvent.KEYCODE_KANA: return KeyCode.KANA; + default: + return KeyCode.UNDEFINED; + } + } + +} diff --git a/src/ios/assets/Assets.xcassets/Contents.json b/src/ios/assets/Assets.xcassets/Contents.json index 30b95156..da4a164c 100755 --- a/src/ios/assets/Assets.xcassets/Contents.json +++ b/src/ios/assets/Assets.xcassets/Contents.json @@ -1,6 +1,6 @@ -{ - "info" : { - "version" : 1, - "author" : "xcode" - } +{ + "info" : { + "version" : 1, + "author" : "xcode" + } } \ No newline at end of file diff --git a/src/ios/assets/Base.lproj/LaunchScreen.storyboard b/src/ios/assets/Base.lproj/LaunchScreen.storyboard index d632bd56..b655cdaa 100755 --- a/src/ios/assets/Base.lproj/LaunchScreen.storyboard +++ b/src/ios/assets/Base.lproj/LaunchScreen.storyboard @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/ios/assets/Base.lproj/MainScreen.storyboard b/src/ios/assets/Base.lproj/MainScreen.storyboard index b70fd5e9..365c6a01 100755 --- a/src/ios/assets/Base.lproj/MainScreen.storyboard +++ b/src/ios/assets/Base.lproj/MainScreen.storyboard @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/stream_pi/client/Main.java b/src/main/java/com/stream_pi/client/Main.java index 5c831db8..65f79390 100755 --- a/src/main/java/com/stream_pi/client/Main.java +++ b/src/main/java/com/stream_pi/client/Main.java @@ -1,63 +1,63 @@ -package com.stream_pi.client; - -import com.stream_pi.client.controller.Controller; -import com.stream_pi.client.info.ClientInfo; - -import com.stream_pi.client.info.StartupFlags; -import javafx.application.Application; -import javafx.scene.Scene; -import javafx.stage.Stage; - -public class Main extends Application { - - - @Override - public void start(Stage stage) - { - Controller d = new Controller(); - Scene s = new Scene(d); - stage.setScene(s); - d.setHostServices(getHostServices()); - d.init(); - } - - - public static void main(String[] args) - { - for(String eachArg : args) - { - if(!eachArg.startsWith("Stream-Pi")) - continue; - - String[] r = eachArg.split("="); - String arg = r[0]; - String val = r[1]; - - switch (arg) { - case "Stream-Pi.startupRunnerFileName": - StartupFlags.RUNNER_FILE_NAME = val; - break; - case "Stream-Pi.showShutDownButton": - StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = val.equals("true"); - break; - case "Stream-Pi.isXMode": - StartupFlags.IS_X_MODE = val.equals("true"); - break; - case "Stream-Pi.isShowFullScreenToggleButton": - StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = val.equals("true"); - break; - case "Stream-Pi.defaultFullScreenMode": - StartupFlags.DEFAULT_FULLSCREEN_MODE = val.equals("true"); - break; - case "Stream-Pi.enableScreenSaverFeature": - StartupFlags.SCREEN_SAVER_FEATURE = val.equals("true"); - break; - case "Stream-Pi.appendPathBeforeRunnerFileToOvercomeJPackageLimitation": - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = val.equals("true"); - break; - } - } - - launch(args); - } -} +package com.stream_pi.client; + +import com.stream_pi.client.controller.Controller; +import com.stream_pi.client.info.ClientInfo; + +import com.stream_pi.client.info.StartupFlags; +import javafx.application.Application; +import javafx.scene.Scene; +import javafx.stage.Stage; + +public class Main extends Application { + + + @Override + public void start(Stage stage) + { + Controller d = new Controller(); + Scene s = new Scene(d); + stage.setScene(s); + d.setHostServices(getHostServices()); + d.init(); + } + + + public static void main(String[] args) + { + for(String eachArg : args) + { + if(!eachArg.startsWith("Stream-Pi")) + continue; + + String[] r = eachArg.split("="); + String arg = r[0]; + String val = r[1]; + + switch (arg) { + case "Stream-Pi.startupRunnerFileName": + StartupFlags.RUNNER_FILE_NAME = val; + break; + case "Stream-Pi.showShutDownButton": + StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON = val.equals("true"); + break; + case "Stream-Pi.isXMode": + StartupFlags.IS_X_MODE = val.equals("true"); + break; + case "Stream-Pi.isShowFullScreenToggleButton": + StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON = val.equals("true"); + break; + case "Stream-Pi.defaultFullScreenMode": + StartupFlags.DEFAULT_FULLSCREEN_MODE = val.equals("true"); + break; + case "Stream-Pi.enableScreenSaverFeature": + StartupFlags.SCREEN_SAVER_FEATURE = val.equals("true"); + break; + case "Stream-Pi.appendPathBeforeRunnerFileToOvercomeJPackageLimitation": + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = val.equals("true"); + break; + } + } + + launch(args); + } +} diff --git a/src/main/java/com/stream_pi/client/connection/Client.java b/src/main/java/com/stream_pi/client/connection/Client.java index 45b3fd1d..50c98dba 100755 --- a/src/main/java/com/stream_pi/client/connection/Client.java +++ b/src/main/java/com/stream_pi/client/connection/Client.java @@ -1,963 +1,963 @@ -package com.stream_pi.client.connection; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; -import com.stream_pi.action_api.action.DisplayTextAlignment; -import com.stream_pi.action_api.action.Location; -import com.stream_pi.action_api.actionproperty.ClientProperties; -import com.stream_pi.action_api.actionproperty.property.Property; -import com.stream_pi.action_api.actionproperty.property.Type; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.comms.Message; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.version.Version; -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.geometry.Orientation; - -import java.io.*; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.util.ArrayList; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Logger; - -public class Client extends Thread -{ - - private Socket socket; - - private ObjectOutputStream oos; - private ObjectInputStream ois; - - private AtomicBoolean stop = new AtomicBoolean(false); - - private ClientListener clientListener; - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - private ClientInfo clientInfo; - - private String serverIP; - private int serverPort; - private Logger logger; - - private Runnable onConnectAndSetupToBeRun; - - public Client(String serverIP, int serverPort, ClientListener clientListener, - ExceptionAndAlertHandler exceptionAndAlertHandler, Runnable onConnectAndSetupToBeRun) - { - this.serverIP = serverIP; - this.serverPort = serverPort; - - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.clientInfo = ClientInfo.getInstance(); - this.clientListener = clientListener; - - this.onConnectAndSetupToBeRun = onConnectAndSetupToBeRun; - - logger = Logger.getLogger(Client.class.getName()); - - clientListener.getExecutor().submit(new Task() { - @Override - protected Void call() - { - try - { - try - { - logger.info("Trying to connect to server at "+serverIP+":"+serverPort); - socket = new Socket(); - socket.connect(new InetSocketAddress(serverIP, serverPort), 5000); - clientListener.setConnected(true); - logger.info("Connected to "+socket.getRemoteSocketAddress()+" !"); - } - catch (IOException e) - { - e.printStackTrace(); - clientListener.setConnected(false); - throw new MinorException("Connection Error", "Unable to connect to server. Please check settings and connection and try again."); - } - finally - { - clientListener.updateSettingsConnectDisconnectButton(); - } - - try - { - oos = new ObjectOutputStream(socket.getOutputStream()); - ois = new ObjectInputStream(socket.getInputStream()); - } - catch (IOException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - throw new MinorException("Unable to set up io Streams to server. Check connection and try again."); - } - - start(); - } catch (MinorException e) - { - exceptionAndAlertHandler.handleMinorException(e); - } - return null; - } - }); - } - - public synchronized void exit() - { - if(stop.get()) - return; - - logger.info("Stopping ..."); - - try - { - if(socket!=null) - { - disconnect(); - } - } - catch (SevereException e) - { - logger.severe(e.getMessage()); - exceptionAndAlertHandler.handleSevereException(e); - e.printStackTrace(); - } - } - - - public synchronized void sendMessage(Message message) throws SevereException - { - try - { - oos.writeObject(message); - oos.flush(); - } - catch (IOException e) - { - e.printStackTrace(); - throw new SevereException("Unable to write to io Stream!"); - } - } - - @Override - public void run() { - try - { - while(!stop.get()) - { - try - { - Message message = (Message) ois.readObject(); - - String header = message.getHeader(); - - logger.info("Message Received. Heading : "+header); - - switch (header) - { - case "ready" : onServerReady(); - break; - - case "action_icon" : onActionIconReceived(message); - break; - - case "disconnect" : serverDisconnected(message); - break; - - case "get_client_details" : sendClientDetails(); - break; - - case "get_client_screen_details" : sendClientScreenDetails(); - break; - - case "get_profiles" : sendProfileNamesToServer(); - break; - - case "get_profile_details": sendProfileDetailsToServer(message); - break; - - case "save_action_details": saveActionDetails(message); - break; - - case "delete_action": deleteAction(message); - break; - - case "get_themes": sendThemesToServer(); - break; - - case "save_client_details": saveClientDetails(message); - break; - - case "save_client_profile": saveProfileDetails(message); - break; - - case "delete_profile": deleteProfile(message); - break; - - case "action_failed": actionFailed(message); - break; - - case "set_toggle_status": onSetToggleStatus(message); - break; - - default: logger.warning("Command '"+header+"' does not match records. Make sure client and server versions are equal."); - - } - } - catch (IOException | ClassNotFoundException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - - clientListener.setConnected(false); - clientListener.updateSettingsConnectDisconnectButton(); - clientListener.onDisconnect(); - - if(!stop.get()) - { - //isDisconnect.set(true); //Prevent running disconnect - throw new MinorException("Accidentally disconnected from Server! (Failed at readUTF)"); - } - - exit(); - - return; - } - } - } - catch (SevereException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - - exceptionAndAlertHandler.handleSevereException(e); - } - catch (MinorException e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - - exceptionAndAlertHandler.handleMinorException(e); - } - } - - private void onSetToggleStatus(Message message) - { - String[] arr = message.getStringArrValue(); - - String profileID = arr[0]; - String actionID = arr[1]; - boolean newStatus = arr[2].equals("true"); - - boolean currentStatus = clientListener.getToggleStatus(profileID,actionID); - - if(currentStatus == newStatus) - { - return; - } - - ActionBox actionBox = clientListener.getActionBoxByProfileAndID(profileID, actionID); - - if(actionBox!=null) - { - actionBox.setCurrentToggleStatus(newStatus); - Platform.runLater(()-> actionBox.toggle(newStatus)); - } - } - - private void onActionIconReceived(Message message) throws MinorException - { - String profileID = message.getStringArrValue()[0]; - String actionID = message.getStringArrValue()[1]; - String state = message.getStringArrValue()[2]; - - clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon( - actionID, - message.getByteArrValue(), - state - ); - - Action a = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - clientListener.renderAction(profileID, a); - } - - - - //commands - - public synchronized void sendIcon(String profileID, String actionID, String state, byte[] icon) throws SevereException - { - try - { - Thread.sleep(50); - } - catch (InterruptedException e) - { - e.printStackTrace(); - } - - Message message = new Message("action_icon"); - message.setStringArrValue(profileID, actionID, state); - message.setByteArrValue(icon); - sendMessage(message); - } - - public void disconnect() throws SevereException - { - disconnect(""); - } - - public void disconnect(String message) throws SevereException - { - if(stop.get()) - return; - - stop.set(true); - - logger.info("Sending server disconnect message ..."); - - Message m = new Message("disconnect"); - m.setStringValue(message); - sendMessage(m); - - try - { - if(!socket.isClosed()) - socket.close(); - - clientListener.setConnected(false); - clientListener.updateSettingsConnectDisconnectButton(); - } - catch (IOException e) - { - e.printStackTrace(); - throw new SevereException("Unable to close socket"); - } - } - - public void onServerReady() - { - if(onConnectAndSetupToBeRun!=null) - { - onConnectAndSetupToBeRun.run(); - onConnectAndSetupToBeRun = null; - } - } - - public void sendThemesToServer() throws SevereException - { - Message message = new Message("themes"); - - String[] arr = new String[clientListener.getThemes().getThemeList().size()*4]; - - int x = 0; - for(int i = 0;i a = new ArrayList<>(); - - a.add(profileID); - a.add(action.getID()); - a.add(action.getActionType()+""); - - if(action.getActionType() == ActionType.NORMAL || - action.getActionType() == ActionType.TOGGLE) { - a.add(action.getVersion().getText()); - } - else - { - a.add("no"); - } - - if(action.getActionType() ==ActionType.NORMAL || - action.getActionType() == ActionType.TOGGLE) - { - a.add(action.getModuleName()); - } - else - { - a.add("nut"); - } - - //display - - a.add(action.getBgColourHex()); - - //icon - - - StringBuilder allIconStatesNames = new StringBuilder(); - for(String eachState : action.getIcons().keySet()) - { - allIconStatesNames.append(eachState).append("::"); - } - a.add(allIconStatesNames.toString()); - - - a.add(action.getCurrentIconState()+""); - - //text - a.add(action.isShowDisplayText()+""); - a.add(action.getDisplayTextFontColourHex()); - a.add(action.getDisplayText()); - a.add(action.getNameFontSize()+""); - a.add(action.getDisplayTextAlignment()+""); - - //location - - if(action.getLocation() == null) - { - a.add("-1"); - a.add("-1"); - } - else - { - a.add(action.getLocation().getRow()+""); - a.add(action.getLocation().getCol()+""); - } - - a.add(action.getParent()); - - a.add(action.getDelayBeforeExecuting()+""); - - //client properties - - ClientProperties clientProperties = action.getClientProperties(); - - a.add(clientProperties.getSize()+""); - - for(Property property : clientProperties.get()) - { - a.add(property.getName()); - a.add(property.getRawValue()); - } - - - - Message message = new Message("action_details"); - - String[] x = new String[a.size()]; - x = a.toArray(x); - - message.setStringArrValue(x); - sendMessage(message); - - } - - public void saveActionDetails(Message message) - { - String[] r = message.getStringArrValue(); - - String profileID = r[0]; - - String actionID = r[1]; - ActionType actionType = ActionType.valueOf(r[2]); - - //3 - Version - //4 - ModuleName - - //display - String bgColorHex = r[5]; - - String[] iconStates = r[6].split("::"); - String currentIconState = r[7]; - - //text - boolean isShowDisplayText = r[8].equals("true"); - String displayFontColor = r[9]; - String displayText = r[10]; - double displayLabelFontSize = Double.parseDouble(r[11]); - DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[12]); - - //location - String row = r[13]; - String col = r[14]; - - Location location = new Location(Integer.parseInt(row), Integer.parseInt(col)); - - Action action = new Action(actionID, actionType); - - if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE) - { - try - { - action.setVersion(new Version(r[3])); - action.setModuleName(r[4]); - } - catch (Exception e) - { - logger.severe(e.getMessage()); - e.printStackTrace(); - } - } - - - action.setBgColourHex(bgColorHex); - - action.setShowDisplayText(isShowDisplayText); - action.setDisplayTextFontColourHex(displayFontColor); - action.setDisplayText(displayText); - action.setDisplayTextAlignment(displayTextAlignment); - action.setNameFontSize(displayLabelFontSize); - action.setCurrentIconState(currentIconState); - - action.setLocation(location); - - - String parent = r[15]; - action.setParent(parent); - - //client properties - - action.setDelayBeforeExecuting(Integer.parseInt(r[16])); - - int clientPropertiesSize = Integer.parseInt(r[17]); - - ClientProperties clientProperties = new ClientProperties(); - - if(actionType == ActionType.FOLDER) - clientProperties.setDuplicatePropertyAllowed(true); - - for(int i = 18;i<((clientPropertiesSize*2) + 18); i+=2) - { - Property property = new Property(r[i], Type.STRING); - property.setRawValue(r[i+1]); - - clientProperties.addProperty(property); - } - - action.setClientProperties(clientProperties); - - try - { - Action old = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID()); - - if(old != null) - { - for(String oldState : old.getIcons().keySet()) - { - boolean isPresent = false; - for(String state : iconStates) - { - if(state.equals(oldState)) - { - isPresent = true; - action.addIcon(state, old.getIcon(state)); - break; - } - } - - if(!isPresent) - { - // State no longer exists. Delete. - - new File(Config.getInstance().getIconsPath()+"/"+actionID+"___"+oldState).delete(); - } - } - } - - clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action); - - clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action); - - clientListener.renderAction(profileID, action); - - if(clientListener.getScreenSaver()!=null) - { - Platform.runLater(()->clientListener.getScreenSaver().restart()); - } - } - catch (Exception e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); - } - } - - public void deleteAction(Message message) - { - try - { - String[] arr = message.getStringArrValue(); - String profileID = arr[0]; - String actionID = arr[1]; - - Action acc = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - - if(acc == null) - { - exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action "+actionID+" since it does not exist.")); - return; - } - - if(acc.getActionType() == ActionType.FOLDER) - { - ArrayList idsToBeRemoved = new ArrayList<>(); - - ArrayList folders = new ArrayList<>(); - String folderToBeDeletedID = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID(); - - folders.add(folderToBeDeletedID); - - boolean startOver = true; - while(startOver) - { - startOver = false; - for(Action action : clientListener.getClientProfiles().getProfileFromID(profileID).getActions()) - { - if(folders.contains(action.getParent())) - { - if(!idsToBeRemoved.contains(action.getID())) - { - idsToBeRemoved.add(action.getID()); - if(action.getActionType() == ActionType.FOLDER) - { - folders.add(action.getID()); - startOver = true; - } - } - } - } - } - - - for(String ids : idsToBeRemoved) - { - clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids); - } - - Platform.runLater(clientListener::renderRootDefaultProfile); - - } - else if (acc.getActionType() == ActionType.COMBINE) - { - for(Property property : acc.getClientProperties().get()) - { - clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue()); - } - } - - - clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID()); - - clientListener.getClientProfiles().getProfileFromID(profileID).saveActions(); - - if(acc.getLocation().getCol()!=-1) - { - Platform.runLater(()-> { - if (clientListener.getCurrentProfile().getID().equals(profileID) - && clientListener.getCurrentParent().equals(acc.getParent())) - { - clientListener.clearActionBox( - acc.getLocation().getCol(), - acc.getLocation().getRow() - ); - } - }); - } - - - } - catch (Exception e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); - } - } - - public void saveClientDetails(Message message) - { - try - { - boolean reInit = false; - - String[] sep = message.getStringArrValue(); - - Config.getInstance().setNickName(sep[0]); - - - Config.getInstance().setStartupProfileID(sep[1]); - - String oldThemeFullName = Config.getInstance().getCurrentThemeFullName(); - String newThemeFullName = sep[2]; - - Config.getInstance().setCurrentThemeFullName(sep[2]); - Config.getInstance().save(); - - if(!oldThemeFullName.equals(newThemeFullName)) - { - Platform.runLater(()-> { - try { - clientListener.initThemes(); - } catch (SevereException e) { - exceptionAndAlertHandler.handleSevereException(e); - } - }); - } - - Platform.runLater(clientListener::loadSettings); - } - catch (SevereException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(e); - } - } - - public void saveProfileDetails(Message message) throws SevereException, MinorException - { - String[] sep = message.getStringArrValue(); - - ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(sep[0]); - - if(clientProfile == null) - { - clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+sep[0]+".xml"), - Config.getInstance().getIconsPath()); - } - - clientProfile.setName(sep[1]); - clientProfile.setRows(Integer.parseInt(sep[2])); - clientProfile.setCols(Integer.parseInt(sep[3])); - clientProfile.setActionSize(Integer.parseInt(sep[4])); - clientProfile.setActionGap(Integer.parseInt(sep[5])); - - try - { - clientListener.getClientProfiles().addProfile(clientProfile); - clientProfile.saveProfileDetails(); - clientListener.refreshGridIfCurrentProfile(sep[0]); - Platform.runLater(clientListener::loadSettings); - } - catch (Exception e) - { - e.printStackTrace(); - throw new SevereException(e.getMessage()); - } - } - - public void deleteProfile(Message message) - { - clientListener.getClientProfiles().deleteProfile(clientListener.getClientProfiles().getProfileFromID( - message.getStringValue() - )); - - if(clientListener.getCurrentProfile().getID().equals(message.getStringValue())) - { - Platform.runLater(clientListener::renderRootDefaultProfile); - } - } - - public void onActionClicked(String profileID, String actionID, boolean toggleState) throws SevereException - { - Message m = new Message("action_clicked"); - m.setStringArrValue(profileID, actionID, toggleState+""); - sendMessage(m); - } - - public void updateOrientationOnClient(Orientation orientation) throws SevereException - { - Message m = new Message("client_orientation"); - m.setStringValue(orientation.toString()); - sendMessage(m); - } - - public void actionFailed(Message message) - { - String[] r = message.getStringArrValue(); - String profileID = r[0]; - String actionID = r[1]; - clientListener.onActionFailed(profileID, actionID); - } -} +package com.stream_pi.client.connection; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; +import com.stream_pi.action_api.action.DisplayTextAlignment; +import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.actionproperty.ClientProperties; +import com.stream_pi.action_api.actionproperty.property.Property; +import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.comms.Message; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.version.Version; +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.geometry.Orientation; + +import java.io.*; +import java.net.InetSocketAddress; +import java.net.Socket; +import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicBoolean; +import java.util.logging.Logger; + +public class Client extends Thread +{ + + private Socket socket; + + private ObjectOutputStream oos; + private ObjectInputStream ois; + + private AtomicBoolean stop = new AtomicBoolean(false); + + private ClientListener clientListener; + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + private ClientInfo clientInfo; + + private String serverIP; + private int serverPort; + private Logger logger; + + private Runnable onConnectAndSetupToBeRun; + + public Client(String serverIP, int serverPort, ClientListener clientListener, + ExceptionAndAlertHandler exceptionAndAlertHandler, Runnable onConnectAndSetupToBeRun) + { + this.serverIP = serverIP; + this.serverPort = serverPort; + + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.clientInfo = ClientInfo.getInstance(); + this.clientListener = clientListener; + + this.onConnectAndSetupToBeRun = onConnectAndSetupToBeRun; + + logger = Logger.getLogger(Client.class.getName()); + + clientListener.getExecutor().submit(new Task() { + @Override + protected Void call() + { + try + { + try + { + logger.info("Trying to connect to server at "+serverIP+":"+serverPort); + socket = new Socket(); + socket.connect(new InetSocketAddress(serverIP, serverPort), 5000); + clientListener.setConnected(true); + logger.info("Connected to "+socket.getRemoteSocketAddress()+" !"); + } + catch (IOException e) + { + e.printStackTrace(); + clientListener.setConnected(false); + throw new MinorException("Connection Error", "Unable to connect to server. Please check settings and connection and try again."); + } + finally + { + clientListener.updateSettingsConnectDisconnectButton(); + } + + try + { + oos = new ObjectOutputStream(socket.getOutputStream()); + ois = new ObjectInputStream(socket.getInputStream()); + } + catch (IOException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + throw new MinorException("Unable to set up io Streams to server. Check connection and try again."); + } + + start(); + } catch (MinorException e) + { + exceptionAndAlertHandler.handleMinorException(e); + } + return null; + } + }); + } + + public synchronized void exit() + { + if(stop.get()) + return; + + logger.info("Stopping ..."); + + try + { + if(socket!=null) + { + disconnect(); + } + } + catch (SevereException e) + { + logger.severe(e.getMessage()); + exceptionAndAlertHandler.handleSevereException(e); + e.printStackTrace(); + } + } + + + public synchronized void sendMessage(Message message) throws SevereException + { + try + { + oos.writeObject(message); + oos.flush(); + } + catch (IOException e) + { + e.printStackTrace(); + throw new SevereException("Unable to write to io Stream!"); + } + } + + @Override + public void run() { + try + { + while(!stop.get()) + { + try + { + Message message = (Message) ois.readObject(); + + String header = message.getHeader(); + + logger.info("Message Received. Heading : "+header); + + switch (header) + { + case "ready" : onServerReady(); + break; + + case "action_icon" : onActionIconReceived(message); + break; + + case "disconnect" : serverDisconnected(message); + break; + + case "get_client_details" : sendClientDetails(); + break; + + case "get_client_screen_details" : sendClientScreenDetails(); + break; + + case "get_profiles" : sendProfileNamesToServer(); + break; + + case "get_profile_details": sendProfileDetailsToServer(message); + break; + + case "save_action_details": saveActionDetails(message); + break; + + case "delete_action": deleteAction(message); + break; + + case "get_themes": sendThemesToServer(); + break; + + case "save_client_details": saveClientDetails(message); + break; + + case "save_client_profile": saveProfileDetails(message); + break; + + case "delete_profile": deleteProfile(message); + break; + + case "action_failed": actionFailed(message); + break; + + case "set_toggle_status": onSetToggleStatus(message); + break; + + default: logger.warning("Command '"+header+"' does not match records. Make sure client and server versions are equal."); + + } + } + catch (IOException | ClassNotFoundException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + + clientListener.setConnected(false); + clientListener.updateSettingsConnectDisconnectButton(); + clientListener.onDisconnect(); + + if(!stop.get()) + { + //isDisconnect.set(true); //Prevent running disconnect + throw new MinorException("Accidentally disconnected from Server! (Failed at readUTF)"); + } + + exit(); + + return; + } + } + } + catch (SevereException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + + exceptionAndAlertHandler.handleSevereException(e); + } + catch (MinorException e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + + exceptionAndAlertHandler.handleMinorException(e); + } + } + + private void onSetToggleStatus(Message message) + { + String[] arr = message.getStringArrValue(); + + String profileID = arr[0]; + String actionID = arr[1]; + boolean newStatus = arr[2].equals("true"); + + boolean currentStatus = clientListener.getToggleStatus(profileID,actionID); + + if(currentStatus == newStatus) + { + return; + } + + ActionBox actionBox = clientListener.getActionBoxByProfileAndID(profileID, actionID); + + if(actionBox!=null) + { + actionBox.setCurrentToggleStatus(newStatus); + Platform.runLater(()-> actionBox.toggle(newStatus)); + } + } + + private void onActionIconReceived(Message message) throws MinorException + { + String profileID = message.getStringArrValue()[0]; + String actionID = message.getStringArrValue()[1]; + String state = message.getStringArrValue()[2]; + + clientListener.getClientProfiles().getProfileFromID(profileID).saveActionIcon( + actionID, + message.getByteArrValue(), + state + ); + + Action a = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + clientListener.renderAction(profileID, a); + } + + + + //commands + + public synchronized void sendIcon(String profileID, String actionID, String state, byte[] icon) throws SevereException + { + try + { + Thread.sleep(50); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + + Message message = new Message("action_icon"); + message.setStringArrValue(profileID, actionID, state); + message.setByteArrValue(icon); + sendMessage(message); + } + + public void disconnect() throws SevereException + { + disconnect(""); + } + + public void disconnect(String message) throws SevereException + { + if(stop.get()) + return; + + stop.set(true); + + logger.info("Sending server disconnect message ..."); + + Message m = new Message("disconnect"); + m.setStringValue(message); + sendMessage(m); + + try + { + if(!socket.isClosed()) + socket.close(); + + clientListener.setConnected(false); + clientListener.updateSettingsConnectDisconnectButton(); + } + catch (IOException e) + { + e.printStackTrace(); + throw new SevereException("Unable to close socket"); + } + } + + public void onServerReady() + { + if(onConnectAndSetupToBeRun!=null) + { + onConnectAndSetupToBeRun.run(); + onConnectAndSetupToBeRun = null; + } + } + + public void sendThemesToServer() throws SevereException + { + Message message = new Message("themes"); + + String[] arr = new String[clientListener.getThemes().getThemeList().size()*4]; + + int x = 0; + for(int i = 0;i a = new ArrayList<>(); + + a.add(profileID); + a.add(action.getID()); + a.add(action.getActionType()+""); + + if(action.getActionType() == ActionType.NORMAL || + action.getActionType() == ActionType.TOGGLE) { + a.add(action.getVersion().getText()); + } + else + { + a.add("no"); + } + + if(action.getActionType() ==ActionType.NORMAL || + action.getActionType() == ActionType.TOGGLE) + { + a.add(action.getModuleName()); + } + else + { + a.add("nut"); + } + + //display + + a.add(action.getBgColourHex()); + + //icon + + + StringBuilder allIconStatesNames = new StringBuilder(); + for(String eachState : action.getIcons().keySet()) + { + allIconStatesNames.append(eachState).append("::"); + } + a.add(allIconStatesNames.toString()); + + + a.add(action.getCurrentIconState()+""); + + //text + a.add(action.isShowDisplayText()+""); + a.add(action.getDisplayTextFontColourHex()); + a.add(action.getDisplayText()); + a.add(action.getNameFontSize()+""); + a.add(action.getDisplayTextAlignment()+""); + + //location + + if(action.getLocation() == null) + { + a.add("-1"); + a.add("-1"); + } + else + { + a.add(action.getLocation().getRow()+""); + a.add(action.getLocation().getCol()+""); + } + + a.add(action.getParent()); + + a.add(action.getDelayBeforeExecuting()+""); + + //client properties + + ClientProperties clientProperties = action.getClientProperties(); + + a.add(clientProperties.getSize()+""); + + for(Property property : clientProperties.get()) + { + a.add(property.getName()); + a.add(property.getRawValue()); + } + + + + Message message = new Message("action_details"); + + String[] x = new String[a.size()]; + x = a.toArray(x); + + message.setStringArrValue(x); + sendMessage(message); + + } + + public void saveActionDetails(Message message) + { + String[] r = message.getStringArrValue(); + + String profileID = r[0]; + + String actionID = r[1]; + ActionType actionType = ActionType.valueOf(r[2]); + + //3 - Version + //4 - ModuleName + + //display + String bgColorHex = r[5]; + + String[] iconStates = r[6].split("::"); + String currentIconState = r[7]; + + //text + boolean isShowDisplayText = r[8].equals("true"); + String displayFontColor = r[9]; + String displayText = r[10]; + double displayLabelFontSize = Double.parseDouble(r[11]); + DisplayTextAlignment displayTextAlignment = DisplayTextAlignment.valueOf(r[12]); + + //location + String row = r[13]; + String col = r[14]; + + Location location = new Location(Integer.parseInt(row), Integer.parseInt(col)); + + Action action = new Action(actionID, actionType); + + if(actionType == ActionType.NORMAL || actionType == ActionType.TOGGLE) + { + try + { + action.setVersion(new Version(r[3])); + action.setModuleName(r[4]); + } + catch (Exception e) + { + logger.severe(e.getMessage()); + e.printStackTrace(); + } + } + + + action.setBgColourHex(bgColorHex); + + action.setShowDisplayText(isShowDisplayText); + action.setDisplayTextFontColourHex(displayFontColor); + action.setDisplayText(displayText); + action.setDisplayTextAlignment(displayTextAlignment); + action.setNameFontSize(displayLabelFontSize); + action.setCurrentIconState(currentIconState); + + action.setLocation(location); + + + String parent = r[15]; + action.setParent(parent); + + //client properties + + action.setDelayBeforeExecuting(Integer.parseInt(r[16])); + + int clientPropertiesSize = Integer.parseInt(r[17]); + + ClientProperties clientProperties = new ClientProperties(); + + if(actionType == ActionType.FOLDER) + clientProperties.setDuplicatePropertyAllowed(true); + + for(int i = 18;i<((clientPropertiesSize*2) + 18); i+=2) + { + Property property = new Property(r[i], Type.STRING); + property.setRawValue(r[i+1]); + + clientProperties.addProperty(property); + } + + action.setClientProperties(clientProperties); + + try + { + Action old = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(action.getID()); + + if(old != null) + { + for(String oldState : old.getIcons().keySet()) + { + boolean isPresent = false; + for(String state : iconStates) + { + if(state.equals(oldState)) + { + isPresent = true; + action.addIcon(state, old.getIcon(state)); + break; + } + } + + if(!isPresent) + { + // State no longer exists. Delete. + + new File(Config.getInstance().getIconsPath()+"/"+actionID+"___"+oldState).delete(); + } + } + } + + clientListener.getClientProfiles().getProfileFromID(profileID).addAction(action); + + clientListener.getClientProfiles().getProfileFromID(profileID).saveAction(action); + + clientListener.renderAction(profileID, action); + + if(clientListener.getScreenSaver()!=null) + { + Platform.runLater(()->clientListener.getScreenSaver().restart()); + } + } + catch (Exception e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); + } + } + + public void deleteAction(Message message) + { + try + { + String[] arr = message.getStringArrValue(); + String profileID = arr[0]; + String actionID = arr[1]; + + Action acc = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + + if(acc == null) + { + exceptionAndAlertHandler.handleMinorException(new MinorException("Unable to delete action "+actionID+" since it does not exist.")); + return; + } + + if(acc.getActionType() == ActionType.FOLDER) + { + ArrayList idsToBeRemoved = new ArrayList<>(); + + ArrayList folders = new ArrayList<>(); + String folderToBeDeletedID = clientListener.getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getID(); + + folders.add(folderToBeDeletedID); + + boolean startOver = true; + while(startOver) + { + startOver = false; + for(Action action : clientListener.getClientProfiles().getProfileFromID(profileID).getActions()) + { + if(folders.contains(action.getParent())) + { + if(!idsToBeRemoved.contains(action.getID())) + { + idsToBeRemoved.add(action.getID()); + if(action.getActionType() == ActionType.FOLDER) + { + folders.add(action.getID()); + startOver = true; + } + } + } + } + } + + + for(String ids : idsToBeRemoved) + { + clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(ids); + } + + Platform.runLater(clientListener::renderRootDefaultProfile); + + } + else if (acc.getActionType() == ActionType.COMBINE) + { + for(Property property : acc.getClientProperties().get()) + { + clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(property.getRawValue()); + } + } + + + clientListener.getClientProfiles().getProfileFromID(profileID).removeAction(acc.getID()); + + clientListener.getClientProfiles().getProfileFromID(profileID).saveActions(); + + if(acc.getLocation().getCol()!=-1) + { + Platform.runLater(()-> { + if (clientListener.getCurrentProfile().getID().equals(profileID) + && clientListener.getCurrentParent().equals(acc.getParent())) + { + clientListener.clearActionBox( + acc.getLocation().getCol(), + acc.getLocation().getRow() + ); + } + }); + } + + + } + catch (Exception e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleMinorException(new MinorException(e.getMessage())); + } + } + + public void saveClientDetails(Message message) + { + try + { + boolean reInit = false; + + String[] sep = message.getStringArrValue(); + + Config.getInstance().setNickName(sep[0]); + + + Config.getInstance().setStartupProfileID(sep[1]); + + String oldThemeFullName = Config.getInstance().getCurrentThemeFullName(); + String newThemeFullName = sep[2]; + + Config.getInstance().setCurrentThemeFullName(sep[2]); + Config.getInstance().save(); + + if(!oldThemeFullName.equals(newThemeFullName)) + { + Platform.runLater(()-> { + try { + clientListener.initThemes(); + } catch (SevereException e) { + exceptionAndAlertHandler.handleSevereException(e); + } + }); + } + + Platform.runLater(clientListener::loadSettings); + } + catch (SevereException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleSevereException(e); + } + } + + public void saveProfileDetails(Message message) throws SevereException, MinorException + { + String[] sep = message.getStringArrValue(); + + ClientProfile clientProfile = clientListener.getClientProfiles().getProfileFromID(sep[0]); + + if(clientProfile == null) + { + clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+sep[0]+".xml"), + Config.getInstance().getIconsPath()); + } + + clientProfile.setName(sep[1]); + clientProfile.setRows(Integer.parseInt(sep[2])); + clientProfile.setCols(Integer.parseInt(sep[3])); + clientProfile.setActionSize(Integer.parseInt(sep[4])); + clientProfile.setActionGap(Integer.parseInt(sep[5])); + + try + { + clientListener.getClientProfiles().addProfile(clientProfile); + clientProfile.saveProfileDetails(); + clientListener.refreshGridIfCurrentProfile(sep[0]); + Platform.runLater(clientListener::loadSettings); + } + catch (Exception e) + { + e.printStackTrace(); + throw new SevereException(e.getMessage()); + } + } + + public void deleteProfile(Message message) + { + clientListener.getClientProfiles().deleteProfile(clientListener.getClientProfiles().getProfileFromID( + message.getStringValue() + )); + + if(clientListener.getCurrentProfile().getID().equals(message.getStringValue())) + { + Platform.runLater(clientListener::renderRootDefaultProfile); + } + } + + public void onActionClicked(String profileID, String actionID, boolean toggleState) throws SevereException + { + Message m = new Message("action_clicked"); + m.setStringArrValue(profileID, actionID, toggleState+""); + sendMessage(m); + } + + public void updateOrientationOnClient(Orientation orientation) throws SevereException + { + Message m = new Message("client_orientation"); + m.setStringValue(orientation.toString()); + sendMessage(m); + } + + public void actionFailed(Message message) + { + String[] r = message.getStringArrValue(); + String profileID = r[0]; + String actionID = r[1]; + clientListener.onActionFailed(profileID, actionID); + } +} diff --git a/src/main/java/com/stream_pi/client/controller/ClientListener.java b/src/main/java/com/stream_pi/client/controller/ClientListener.java index fdd82056..aedf3ed3 100755 --- a/src/main/java/com/stream_pi/client/controller/ClientListener.java +++ b/src/main/java/com/stream_pi/client/controller/ClientListener.java @@ -1,86 +1,86 @@ -package com.stream_pi.client.controller; - -import com.stream_pi.action_api.action.Action; -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.ClientProfiles; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.theme_api.Themes; -import com.stream_pi.util.exception.SevereException; -import javafx.geometry.Orientation; - -import java.util.concurrent.ExecutorService; - -public interface ClientListener -{ - void onActionFailed(String profileID, String actionID); - void onActionClicked(String profileID, String actionID, boolean toggleState); - ClientProfiles getClientProfiles(); - - Themes getThemes(); - String getDefaultThemeFullName(); - - Client getClient(); - - void renderRootDefaultProfile(); - - void setConnected(boolean isConnected); - boolean isConnected(); - - void renderProfile(ClientProfile clientProfile, boolean freshRender); - - void clearActionBox(int col, int row); - void addBlankActionBox(int col, int row); - void renderAction(String currentProfileID, Action action); - void refreshGridIfCurrentProfile(String currentProfileID); - - ActionBox getActionBox(int col, int row); - - ClientProfile getCurrentProfile(); - - String getCurrentParent(); - - Theme getCurrentTheme(); - - void initLogger() throws SevereException; - void init(); - - void disconnect(String message) throws SevereException; - - void setupClientConnection(); - - void setupClientConnection(Runnable onConnect); - - void updateSettingsConnectDisconnectButton(); - - void onCloseRequest(); - - void loadSettings(); - - double getStageWidth(); - double getStageHeight(); - - void onDisconnect(); - - boolean getToggleStatus(String profileID, String actionID); - - ActionBox getActionBoxByProfileAndID(String profileID, String actionID); - - void openURL(String URL); - - void factoryReset(); - void exitApp(); - - ExecutorService getExecutor(); - - Orientation getCurrentOrientation(); - - void setFirstRun(boolean firstRun); - - ScreenSaver getScreenSaver(); - - void initThemes() throws SevereException; -} +package com.stream_pi.client.controller; + +import com.stream_pi.action_api.action.Action; +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.ClientProfiles; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.theme_api.Themes; +import com.stream_pi.util.exception.SevereException; +import javafx.geometry.Orientation; + +import java.util.concurrent.ExecutorService; + +public interface ClientListener +{ + void onActionFailed(String profileID, String actionID); + void onActionClicked(String profileID, String actionID, boolean toggleState); + ClientProfiles getClientProfiles(); + + Themes getThemes(); + String getDefaultThemeFullName(); + + Client getClient(); + + void renderRootDefaultProfile(); + + void setConnected(boolean isConnected); + boolean isConnected(); + + void renderProfile(ClientProfile clientProfile, boolean freshRender); + + void clearActionBox(int col, int row); + void addBlankActionBox(int col, int row); + void renderAction(String currentProfileID, Action action); + void refreshGridIfCurrentProfile(String currentProfileID); + + ActionBox getActionBox(int col, int row); + + ClientProfile getCurrentProfile(); + + String getCurrentParent(); + + Theme getCurrentTheme(); + + void initLogger() throws SevereException; + void init(); + + void disconnect(String message) throws SevereException; + + void setupClientConnection(); + + void setupClientConnection(Runnable onConnect); + + void updateSettingsConnectDisconnectButton(); + + void onCloseRequest(); + + void loadSettings(); + + double getStageWidth(); + double getStageHeight(); + + void onDisconnect(); + + boolean getToggleStatus(String profileID, String actionID); + + ActionBox getActionBoxByProfileAndID(String profileID, String actionID); + + void openURL(String URL); + + void factoryReset(); + void exitApp(); + + ExecutorService getExecutor(); + + Orientation getCurrentOrientation(); + + void setFirstRun(boolean firstRun); + + ScreenSaver getScreenSaver(); + + void initThemes() throws SevereException; +} diff --git a/src/main/java/com/stream_pi/client/controller/Controller.java b/src/main/java/com/stream_pi/client/controller/Controller.java index 563f9c5e..993c6fcd 100755 --- a/src/main/java/com/stream_pi/client/controller/Controller.java +++ b/src/main/java/com/stream_pi/client/controller/Controller.java @@ -1,723 +1,723 @@ -package com.stream_pi.client.controller; - -import com.gluonhq.attach.browser.BrowserService; -import com.gluonhq.attach.orientation.OrientationService; -import com.gluonhq.attach.vibration.VibrationService; -import com.stream_pi.action_api.action.Action; -import com.stream_pi.client.Main; -import com.stream_pi.client.connection.Client; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.profile.ClientProfiles; -import com.stream_pi.client.window.Base; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; -import com.stream_pi.util.alert.StreamPiAlert; -import com.stream_pi.util.alert.StreamPiAlertListener; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.gluonhq.attach.lifecycle.LifecycleService; -import com.gluonhq.attach.util.Services; - -import com.stream_pi.util.iohelper.IOHelper; -import com.stream_pi.util.platform.PlatformType; -import com.stream_pi.util.startatboot.StartAtBoot; -import javafx.animation.Interpolator; -import javafx.animation.KeyFrame; -import javafx.animation.KeyValue; -import javafx.animation.Timeline; -import javafx.application.Platform; -import javafx.beans.InvalidationListener; -import javafx.beans.value.ChangeListener; -import javafx.beans.value.ObservableValue; -import javafx.geometry.Orientation; -import javafx.scene.Node; -import javafx.scene.input.KeyCombination; -import javafx.scene.layout.StackPane; -import javafx.stage.Screen; -import javafx.util.Duration; - -import java.io.*; -import java.net.URISyntaxException; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Level; - - -public class Controller extends Base -{ - private Client client; - - public Controller() - { - client = null; - } - - - private boolean firstRun = true; - private ScreenSaver screenSaver = null; - private ScreenMover screenMover = null; - - @Override - public ScreenSaver getScreenSaver() - { - return screenSaver; - } - - @Override - public void init() - { - try - { - if(firstRun) - initBase(); - - - if(getConfig().isScreenSaverEnabled()) - { - if(screenSaver == null) - { - screenSaver = new ScreenSaver(this, getConfig().getScreenSaverTimeout()); - getChildren().add(screenSaver); - screenSaver.toBack(); - } - else - { - screenSaver.setTimeout(getConfig().getScreenSaverTimeout()); - screenSaver.restart(); - } - } - else - { - if(screenSaver != null) - { - screenSaver.stop(); - getChildren().remove(screenSaver); - screenSaver = null; - } - } - - - if(getClientInfo().getPlatform() != com.stream_pi.util.platform.Platform.ANDROID) - { - if(getConfig().isStartOnBoot()) - { - if(StartupFlags.IS_X_MODE != getConfig().isStartupXMode()) - { - StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), - Main.class.getProtectionDomain().getCodeSource().getLocation(), - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); - - boolean result = startAtBoot.delete(); - if(!result) - { - 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, " + - "delete the old starter file, then exit and restart Stream-Pi as normal user.", StreamPiAlertType.ERROR).show(); - } - else - { - try - { - startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); - getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE); - } - catch (MinorException e) - { - getConfig().setStartOnBoot(false); - handleMinorException(e); - } - } - } - } - - setupFlags(); - - if(!getConfig().getIsFullScreenMode()) - { - getStage().setWidth(getConfig().getStartupWindowWidth()); - getStage().setHeight(getConfig().getStartupWindowHeight()); - } - } - - - setupDashWindow(); - - getStage().show(); - - - if(getConfig().isScreenMoverEnabled()) - { - if(screenMover == null) - { - screenMover = new ScreenMover(getStage(), getConfig().getScreenMoverInterval(), - getConfig().getScreenMoverXChange(), - getConfig().getScreenMoverYChange()); - } - else - { - screenMover.setInterval(getConfig().getScreenMoverInterval()); - screenMover.restart(); - } - } - else - { - if(screenMover != null) - { - screenMover.stop(); - screenMover = null; - } - } - - - if(Config.getInstance().isFirstTimeUse()) - return; - - setupSettingsWindowsAnimations(); - - - - getDashboardPane().getSettingsButton().setOnAction(event -> { - openSettingsTimeLine.play(); - }); - - getSettingsPane().getCloseButton().setOnAction(event -> { - closeSettingsTimeLine.play(); - }); - - setClientProfiles(new ClientProfiles(new File(getConfig().getProfilesPath()), getConfig().getStartupProfileID())); - - if(getClientProfiles().getLoadingErrors().size() > 0) - { - StringBuilder errors = new StringBuilder("Please rectify the following errors and try again"); - - for(MinorException exception : getClientProfiles().getLoadingErrors()) - { - errors.append("\n * ") - .append(exception.getMessage()); - } - - throw new MinorException("Profiles", errors.toString()); - } - - - 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 - ); - - getExecutor().submit(()->{ - try - { - if(isConnected()) - { - getClient().updateOrientationOnClient(getCurrentOrientation()); - } - } - catch (SevereException e) - { - handleSevereException(e); - } - }); - }); - } - }); - } - - renderRootDefaultProfile(); - loadSettings(); - - if(firstRun) - { - if(getConfig().isConnectOnStartup()) - { - setupClientConnection(); - } - firstRun = false; - } - - if(!getClientInfo().isPhone()) - { - getStage().widthProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); - getStage().heightProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); - } - } - catch (SevereException e) - { - handleSevereException(e); - } - catch (MinorException e) - { - handleMinorException(e); - } - } - - private Orientation currentOrientation = null; - - @Override - public Orientation getCurrentOrientation() - { - return currentOrientation; - } - - private void setCurrentOrientation(Orientation currentOrientation) - { - this.currentOrientation = currentOrientation; - } - - public void syncClientSizeDetailsWithServer() - { - if(isConnected()) - { - try { - client.sendClientScreenDetails(); - } catch (SevereException e) { - e.printStackTrace(); - } - } - } - - @Override - public void setupClientConnection() - { - setupClientConnection(null); - } - - @Override - public void setupClientConnection(Runnable onConnect) - { - if(getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) //probably already connecting - return; - - Platform.runLater(()->getSettingsPane().getGeneralTab().setDisableStatus(true)); - client = new Client(getConfig().getSavedServerHostNameOrIP(), getConfig().getSavedServerPort(), this, this, onConnect); - } - - @Override - public void updateSettingsConnectDisconnectButton() { - getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus(); - } - - @Override - public void disconnect(String message) throws SevereException { - client.disconnect(message); - } - - - public void setupDashWindow() - { - getStage().setTitle("Stream-Pi Client"); - getStage().setOnCloseRequest(e->{ - onCloseRequest(); - exitApp(); - }); - } - - - @Override - public void onCloseRequest() - { - try - { - if(isConnected()) - client.exit(); - - if(screenSaver != null) - { - screenSaver.stop(); - } - - if(screenMover != null) - { - screenMover.stop(); - } - - if(getConfig() != null) - { - if(!getClientInfo().isPhone() && !getConfig().getIsFullScreenMode()) - { - getConfig().setStartupWindowSize(getStageWidth(), getStageHeight()); - getConfig().save(); - } - } - } - catch (SevereException e) - { - handleSevereException(e); - } - finally - { - getLogger().info("Shut down"); - closeLogger(); - Config.nullify(); - } - } - - @Override - public void exitApp() - { - getExecutor().shutdown(); - if (ClientInfo.getInstance().getPlatform() == com.stream_pi.util.platform.Platform.ANDROID) - { - Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown); - } - else - { - Platform.exit(); - } - } - - @Override - public void loadSettings() { - try { - getSettingsPane().getGeneralTab().loadData(); - } catch (SevereException e) { - e.printStackTrace(); - handleSevereException(e); - } - } - - @Override - public Client getClient() { - return client; - } - - @Override - public void onDisconnect() { - Platform.runLater(()->getDashboardPane().getActionGridPane().toggleOffAllToggleActions()); - } - - @Override - public boolean getToggleStatus(String profileID, String actionID) - { - return getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus(); - } - - - private Timeline openSettingsTimeLine; - private Timeline closeSettingsTimeLine; - - - private void setupSettingsWindowsAnimations() - { - Node settingsNode = getSettingsPane(); - Node dashboardNode = getDashboardPane(); - - openSettingsTimeLine = new Timeline(); - openSettingsTimeLine.setCycleCount(1); - - - openSettingsTimeLine.getKeyFrames().addAll( - new KeyFrame(Duration.millis(0.0D), - new KeyValue(settingsNode.opacityProperty(), - 0.0D, Interpolator.EASE_IN)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(settingsNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)), - - new KeyFrame(Duration.millis(0.0D), - new KeyValue(dashboardNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(dashboardNode.opacityProperty(), - 0.0D, Interpolator.LINEAR)) - ); - - openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront()); - - - closeSettingsTimeLine = new Timeline(); - closeSettingsTimeLine.setCycleCount(1); - - closeSettingsTimeLine.getKeyFrames().addAll( - new KeyFrame(Duration.millis(0.0D), - new KeyValue(settingsNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(settingsNode.opacityProperty(), - 0.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(0.0D), - new KeyValue(dashboardNode.opacityProperty(), - 0.0D, Interpolator.LINEAR)), - new KeyFrame(Duration.millis(90.0D), - new KeyValue(dashboardNode.opacityProperty(), - 1.0D, Interpolator.LINEAR)) - ); - - closeSettingsTimeLine.setOnFinished(event1 -> { - dashboardNode.toFront(); - Platform.runLater(()-> { - try { - getSettingsPane().getGeneralTab().loadData(); - } catch (SevereException e) { - e.printStackTrace(); - - handleSevereException(e); - } - }); - }); - } - - - @Override - public void handleMinorException(MinorException e) - { - handleMinorException(e.getMessage(), e); - } - - @Override - public void handleMinorException(String message, MinorException e) - { - getLogger().log(Level.SEVERE, message, e); - e.printStackTrace(); - - Platform.runLater(()-> { - if(getScreenSaver() != null) - { - getScreenSaver().restart(); - } - - genNewAlert(e.getTitle(), message, StreamPiAlertType.WARNING).show(); - }); - } - - @Override - public void handleSevereException(SevereException e) - { - handleSevereException(e.getMessage(), e); - } - - @Override - public void handleSevereException(String message, SevereException e) - { - getLogger().log(Level.SEVERE, message, e); - e.printStackTrace(); - - - Platform.runLater(()-> - { - if(getScreenSaver() != null) - { - getScreenSaver().restart(); - } - - StreamPiAlert alert = genNewAlert(e.getTitle(), message, StreamPiAlertType.ERROR); - - alert.setOnClicked(new StreamPiAlertListener() - { - @Override - public void onClick(String txt) - { - onCloseRequest(); - exitApp(); - } - }); - alert.show(); - }); - } - - @Override - public void onAlert(String title, String body, StreamPiAlertType alertType) { - Platform.runLater(()-> genNewAlert(title, body, alertType).show()); - } - - public StreamPiAlert genNewAlert(String title, String message, StreamPiAlertType alertType) - { - return new StreamPiAlert(title, message, alertType); - } - - - private boolean isConnected = false; - - @Override - public void onActionFailed(String profileID, String actionID) { - Platform.runLater(()-> getDashboardPane().getActionGridPane().actionFailed(profileID, actionID)); - } - - @Override - public void onActionClicked(String profileID, String actionID, boolean toggleState) - { - try { - - vibratePhone(); - - client.onActionClicked(profileID, actionID, toggleState); - } catch (SevereException e) { - e.printStackTrace(); - handleSevereException(e); - } - } - - public void vibratePhone() - { - if(getConfig().isVibrateOnActionClicked()) - { - VibrationService.create().ifPresent(VibrationService::vibrate); - } - } - - @Override - public void setConnected(boolean isConnected) { - this.isConnected = isConnected; - } - - @Override - public ActionBox getActionBox(int col, int row) - { - return getDashboardPane().getActionGridPane().getActionBox(col, row); - } - - @Override - public boolean isConnected() - { - return isConnected; - } - - @Override - public void renderProfile(ClientProfile clientProfile, boolean freshRender) - { - getDashboardPane().renderProfile(clientProfile, freshRender); - } - - @Override - public void clearActionBox(int col, int row) - { - Platform.runLater(()->getDashboardPane().getActionGridPane().clearActionBox(col, row)); - } - - @Override - public void addBlankActionBox(int col, int row) - { - Platform.runLater(()->getDashboardPane().getActionGridPane().addBlankActionBox(col, row)); - } - - @Override - public void renderAction(String currentProfileID, Action action) - { - Platform.runLater(()->{ - try { - if(getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) && - getCurrentProfile().getID().equals(currentProfileID)) - { - getDashboardPane().getActionGridPane().renderAction(action); - } - - } - catch (Exception e) - { - e.printStackTrace(); - } - }); - } - - - - @Override - public void refreshGridIfCurrentProfile(String profileID) { - if(getCurrentProfile().getID().equals(profileID)) - { - Platform.runLater(()-> getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(profileID), true)); - } - } - - @Override - public ClientProfile getCurrentProfile() { - return getDashboardPane().getActionGridPane().getClientProfile(); - } - - @Override - public String getCurrentParent() - { - return getDashboardPane().getActionGridPane().getCurrentParent(); - } - - - @Override - public ActionBox getActionBoxByProfileAndID(String profileID, String actionID) - { - Action action = getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); - - if(!getCurrentProfile().getID().equals(profileID) && !getCurrentParent().equals(action.getParent())) - return null; - - return getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation()); - } - - @Override - public void openURL(String url) - { - if(ClientInfo.getInstance().isPhone()) - { - BrowserService.create().ifPresentOrElse(s-> - { - try - { - s.launchExternalBrowser(url); - } - catch (Exception e ) - { - handleMinorException( - new MinorException("Cant start browser! You can go to Server Settings > About > Contact " + - "and open the links from there.") - ); - } - },()-> handleMinorException( - new MinorException("Sorry!","No browser detected. You can go to Server Settings > About > Contact " + - "and open the links from there.") - )); - } - else - { - if(getClientInfo().getPlatform() == com.stream_pi.util.platform.Platform.LINUX && - !StartupFlags.IS_X_MODE) - { - 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 " + - "and open the links from there.")); - } - else - { - getHostServices().showDocument(url); - } - } - } - - @Override - public void factoryReset() - { - getLogger().info("Reset to factory ..."); - - onCloseRequest(); - - try - { - IOHelper.deleteFile(getClientInfo().getPrePath()); - - setFirstRun(true); - init(); - } - catch (SevereException e) - { - handleSevereException("Unable to successfully factory reset. Delete directory \n'"+getClientInfo().getPrePath()+"/home/rnayabed/HDD_1/projects/stream-pi/server'\nMessage:\n"+e.getMessage(),e); - } - } - - @Override - public void setFirstRun(boolean firstRun) - { - this.firstRun = firstRun; - } -} +package com.stream_pi.client.controller; + +import com.gluonhq.attach.browser.BrowserService; +import com.gluonhq.attach.orientation.OrientationService; +import com.gluonhq.attach.vibration.VibrationService; +import com.stream_pi.action_api.action.Action; +import com.stream_pi.client.Main; +import com.stream_pi.client.connection.Client; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.profile.ClientProfiles; +import com.stream_pi.client.window.Base; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionBox; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPaneListener; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertListener; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.gluonhq.attach.lifecycle.LifecycleService; +import com.gluonhq.attach.util.Services; + +import com.stream_pi.util.iohelper.IOHelper; +import com.stream_pi.util.platform.PlatformType; +import com.stream_pi.util.startatboot.StartAtBoot; +import javafx.animation.Interpolator; +import javafx.animation.KeyFrame; +import javafx.animation.KeyValue; +import javafx.animation.Timeline; +import javafx.application.Platform; +import javafx.beans.InvalidationListener; +import javafx.beans.value.ChangeListener; +import javafx.beans.value.ObservableValue; +import javafx.geometry.Orientation; +import javafx.scene.Node; +import javafx.scene.input.KeyCombination; +import javafx.scene.layout.StackPane; +import javafx.stage.Screen; +import javafx.util.Duration; + +import java.io.*; +import java.net.URISyntaxException; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.logging.Level; + + +public class Controller extends Base +{ + private Client client; + + public Controller() + { + client = null; + } + + + private boolean firstRun = true; + private ScreenSaver screenSaver = null; + private ScreenMover screenMover = null; + + @Override + public ScreenSaver getScreenSaver() + { + return screenSaver; + } + + @Override + public void init() + { + try + { + if(firstRun) + initBase(); + + + if(getConfig().isScreenSaverEnabled()) + { + if(screenSaver == null) + { + screenSaver = new ScreenSaver(this, getConfig().getScreenSaverTimeout()); + getChildren().add(screenSaver); + screenSaver.toBack(); + } + else + { + screenSaver.setTimeout(getConfig().getScreenSaverTimeout()); + screenSaver.restart(); + } + } + else + { + if(screenSaver != null) + { + screenSaver.stop(); + getChildren().remove(screenSaver); + screenSaver = null; + } + } + + + if(getClientInfo().getPlatform() != com.stream_pi.util.platform.Platform.ANDROID) + { + if(getConfig().isStartOnBoot()) + { + if(StartupFlags.IS_X_MODE != getConfig().isStartupXMode()) + { + StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), + Main.class.getProtectionDomain().getCodeSource().getLocation(), + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); + + boolean result = startAtBoot.delete(); + if(!result) + { + 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, " + + "delete the old starter file, then exit and restart Stream-Pi as normal user.", StreamPiAlertType.ERROR).show(); + } + else + { + try + { + startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); + getConfig().setStartupIsXMode(StartupFlags.IS_X_MODE); + } + catch (MinorException e) + { + getConfig().setStartOnBoot(false); + handleMinorException(e); + } + } + } + } + + setupFlags(); + + if(!getConfig().getIsFullScreenMode()) + { + getStage().setWidth(getConfig().getStartupWindowWidth()); + getStage().setHeight(getConfig().getStartupWindowHeight()); + } + } + + + setupDashWindow(); + + getStage().show(); + + + if(getConfig().isScreenMoverEnabled()) + { + if(screenMover == null) + { + screenMover = new ScreenMover(getStage(), getConfig().getScreenMoverInterval(), + getConfig().getScreenMoverXChange(), + getConfig().getScreenMoverYChange()); + } + else + { + screenMover.setInterval(getConfig().getScreenMoverInterval()); + screenMover.restart(); + } + } + else + { + if(screenMover != null) + { + screenMover.stop(); + screenMover = null; + } + } + + + if(Config.getInstance().isFirstTimeUse()) + return; + + setupSettingsWindowsAnimations(); + + + + getDashboardPane().getSettingsButton().setOnAction(event -> { + openSettingsTimeLine.play(); + }); + + getSettingsPane().getCloseButton().setOnAction(event -> { + closeSettingsTimeLine.play(); + }); + + setClientProfiles(new ClientProfiles(new File(getConfig().getProfilesPath()), getConfig().getStartupProfileID())); + + if(getClientProfiles().getLoadingErrors().size() > 0) + { + StringBuilder errors = new StringBuilder("Please rectify the following errors and try again"); + + for(MinorException exception : getClientProfiles().getLoadingErrors()) + { + errors.append("\n * ") + .append(exception.getMessage()); + } + + throw new MinorException("Profiles", errors.toString()); + } + + + 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 + ); + + getExecutor().submit(()->{ + try + { + if(isConnected()) + { + getClient().updateOrientationOnClient(getCurrentOrientation()); + } + } + catch (SevereException e) + { + handleSevereException(e); + } + }); + }); + } + }); + } + + renderRootDefaultProfile(); + loadSettings(); + + if(firstRun) + { + if(getConfig().isConnectOnStartup()) + { + setupClientConnection(); + } + firstRun = false; + } + + if(!getClientInfo().isPhone()) + { + getStage().widthProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); + getStage().heightProperty().addListener((observableValue, orientation, t1) -> syncClientSizeDetailsWithServer()); + } + } + catch (SevereException e) + { + handleSevereException(e); + } + catch (MinorException e) + { + handleMinorException(e); + } + } + + private Orientation currentOrientation = null; + + @Override + public Orientation getCurrentOrientation() + { + return currentOrientation; + } + + private void setCurrentOrientation(Orientation currentOrientation) + { + this.currentOrientation = currentOrientation; + } + + public void syncClientSizeDetailsWithServer() + { + if(isConnected()) + { + try { + client.sendClientScreenDetails(); + } catch (SevereException e) { + e.printStackTrace(); + } + } + } + + @Override + public void setupClientConnection() + { + setupClientConnection(null); + } + + @Override + public void setupClientConnection(Runnable onConnect) + { + if(getSettingsPane().getGeneralTab().getConnectDisconnectButton().isDisabled()) //probably already connecting + return; + + Platform.runLater(()->getSettingsPane().getGeneralTab().setDisableStatus(true)); + client = new Client(getConfig().getSavedServerHostNameOrIP(), getConfig().getSavedServerPort(), this, this, onConnect); + } + + @Override + public void updateSettingsConnectDisconnectButton() { + getSettingsPane().getGeneralTab().setConnectDisconnectButtonStatus(); + } + + @Override + public void disconnect(String message) throws SevereException { + client.disconnect(message); + } + + + public void setupDashWindow() + { + getStage().setTitle("Stream-Pi Client"); + getStage().setOnCloseRequest(e->{ + onCloseRequest(); + exitApp(); + }); + } + + + @Override + public void onCloseRequest() + { + try + { + if(isConnected()) + client.exit(); + + if(screenSaver != null) + { + screenSaver.stop(); + } + + if(screenMover != null) + { + screenMover.stop(); + } + + if(getConfig() != null) + { + if(!getClientInfo().isPhone() && !getConfig().getIsFullScreenMode()) + { + getConfig().setStartupWindowSize(getStageWidth(), getStageHeight()); + getConfig().save(); + } + } + } + catch (SevereException e) + { + handleSevereException(e); + } + finally + { + getLogger().info("Shut down"); + closeLogger(); + Config.nullify(); + } + } + + @Override + public void exitApp() + { + getExecutor().shutdown(); + if (ClientInfo.getInstance().getPlatform() == com.stream_pi.util.platform.Platform.ANDROID) + { + Services.get(LifecycleService.class).ifPresent(LifecycleService::shutdown); + } + else + { + Platform.exit(); + } + } + + @Override + public void loadSettings() { + try { + getSettingsPane().getGeneralTab().loadData(); + } catch (SevereException e) { + e.printStackTrace(); + handleSevereException(e); + } + } + + @Override + public Client getClient() { + return client; + } + + @Override + public void onDisconnect() { + Platform.runLater(()->getDashboardPane().getActionGridPane().toggleOffAllToggleActions()); + } + + @Override + public boolean getToggleStatus(String profileID, String actionID) + { + return getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID).getCurrentToggleStatus(); + } + + + private Timeline openSettingsTimeLine; + private Timeline closeSettingsTimeLine; + + + private void setupSettingsWindowsAnimations() + { + Node settingsNode = getSettingsPane(); + Node dashboardNode = getDashboardPane(); + + openSettingsTimeLine = new Timeline(); + openSettingsTimeLine.setCycleCount(1); + + + openSettingsTimeLine.getKeyFrames().addAll( + new KeyFrame(Duration.millis(0.0D), + new KeyValue(settingsNode.opacityProperty(), + 0.0D, Interpolator.EASE_IN)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(settingsNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)), + + new KeyFrame(Duration.millis(0.0D), + new KeyValue(dashboardNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(dashboardNode.opacityProperty(), + 0.0D, Interpolator.LINEAR)) + ); + + openSettingsTimeLine.setOnFinished(event1 -> settingsNode.toFront()); + + + closeSettingsTimeLine = new Timeline(); + closeSettingsTimeLine.setCycleCount(1); + + closeSettingsTimeLine.getKeyFrames().addAll( + new KeyFrame(Duration.millis(0.0D), + new KeyValue(settingsNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(settingsNode.opacityProperty(), + 0.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(0.0D), + new KeyValue(dashboardNode.opacityProperty(), + 0.0D, Interpolator.LINEAR)), + new KeyFrame(Duration.millis(90.0D), + new KeyValue(dashboardNode.opacityProperty(), + 1.0D, Interpolator.LINEAR)) + ); + + closeSettingsTimeLine.setOnFinished(event1 -> { + dashboardNode.toFront(); + Platform.runLater(()-> { + try { + getSettingsPane().getGeneralTab().loadData(); + } catch (SevereException e) { + e.printStackTrace(); + + handleSevereException(e); + } + }); + }); + } + + + @Override + public void handleMinorException(MinorException e) + { + handleMinorException(e.getMessage(), e); + } + + @Override + public void handleMinorException(String message, MinorException e) + { + getLogger().log(Level.SEVERE, message, e); + e.printStackTrace(); + + Platform.runLater(()-> { + if(getScreenSaver() != null) + { + getScreenSaver().restart(); + } + + genNewAlert(e.getTitle(), message, StreamPiAlertType.WARNING).show(); + }); + } + + @Override + public void handleSevereException(SevereException e) + { + handleSevereException(e.getMessage(), e); + } + + @Override + public void handleSevereException(String message, SevereException e) + { + getLogger().log(Level.SEVERE, message, e); + e.printStackTrace(); + + + Platform.runLater(()-> + { + if(getScreenSaver() != null) + { + getScreenSaver().restart(); + } + + StreamPiAlert alert = genNewAlert(e.getTitle(), message, StreamPiAlertType.ERROR); + + alert.setOnClicked(new StreamPiAlertListener() + { + @Override + public void onClick(String txt) + { + onCloseRequest(); + exitApp(); + } + }); + alert.show(); + }); + } + + @Override + public void onAlert(String title, String body, StreamPiAlertType alertType) { + Platform.runLater(()-> genNewAlert(title, body, alertType).show()); + } + + public StreamPiAlert genNewAlert(String title, String message, StreamPiAlertType alertType) + { + return new StreamPiAlert(title, message, alertType); + } + + + private boolean isConnected = false; + + @Override + public void onActionFailed(String profileID, String actionID) { + Platform.runLater(()-> getDashboardPane().getActionGridPane().actionFailed(profileID, actionID)); + } + + @Override + public void onActionClicked(String profileID, String actionID, boolean toggleState) + { + try { + + vibratePhone(); + + client.onActionClicked(profileID, actionID, toggleState); + } catch (SevereException e) { + e.printStackTrace(); + handleSevereException(e); + } + } + + public void vibratePhone() + { + if(getConfig().isVibrateOnActionClicked()) + { + VibrationService.create().ifPresent(VibrationService::vibrate); + } + } + + @Override + public void setConnected(boolean isConnected) { + this.isConnected = isConnected; + } + + @Override + public ActionBox getActionBox(int col, int row) + { + return getDashboardPane().getActionGridPane().getActionBox(col, row); + } + + @Override + public boolean isConnected() + { + return isConnected; + } + + @Override + public void renderProfile(ClientProfile clientProfile, boolean freshRender) + { + getDashboardPane().renderProfile(clientProfile, freshRender); + } + + @Override + public void clearActionBox(int col, int row) + { + Platform.runLater(()->getDashboardPane().getActionGridPane().clearActionBox(col, row)); + } + + @Override + public void addBlankActionBox(int col, int row) + { + Platform.runLater(()->getDashboardPane().getActionGridPane().addBlankActionBox(col, row)); + } + + @Override + public void renderAction(String currentProfileID, Action action) + { + Platform.runLater(()->{ + try { + if(getDashboardPane().getActionGridPane().getCurrentParent().equals(action.getParent()) && + getCurrentProfile().getID().equals(currentProfileID)) + { + getDashboardPane().getActionGridPane().renderAction(action); + } + + } + catch (Exception e) + { + e.printStackTrace(); + } + }); + } + + + + @Override + public void refreshGridIfCurrentProfile(String profileID) { + if(getCurrentProfile().getID().equals(profileID)) + { + Platform.runLater(()-> getDashboardPane().renderProfile(getClientProfiles().getProfileFromID(profileID), true)); + } + } + + @Override + public ClientProfile getCurrentProfile() { + return getDashboardPane().getActionGridPane().getClientProfile(); + } + + @Override + public String getCurrentParent() + { + return getDashboardPane().getActionGridPane().getCurrentParent(); + } + + + @Override + public ActionBox getActionBoxByProfileAndID(String profileID, String actionID) + { + Action action = getClientProfiles().getProfileFromID(profileID).getActionFromID(actionID); + + if(!getCurrentProfile().getID().equals(profileID) && !getCurrentParent().equals(action.getParent())) + return null; + + return getDashboardPane().getActionGridPane().getActionBoxByLocation(action.getLocation()); + } + + @Override + public void openURL(String url) + { + if(ClientInfo.getInstance().isPhone()) + { + BrowserService.create().ifPresentOrElse(s-> + { + try + { + s.launchExternalBrowser(url); + } + catch (Exception e ) + { + handleMinorException( + new MinorException("Cant start browser! You can go to Server Settings > About > Contact " + + "and open the links from there.") + ); + } + },()-> handleMinorException( + new MinorException("Sorry!","No browser detected. You can go to Server Settings > About > Contact " + + "and open the links from there.") + )); + } + else + { + if(getClientInfo().getPlatform() == com.stream_pi.util.platform.Platform.LINUX && + !StartupFlags.IS_X_MODE) + { + 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 " + + "and open the links from there.")); + } + else + { + getHostServices().showDocument(url); + } + } + } + + @Override + public void factoryReset() + { + getLogger().info("Reset to factory ..."); + + onCloseRequest(); + + try + { + IOHelper.deleteFile(getClientInfo().getPrePath()); + + setFirstRun(true); + init(); + } + catch (SevereException e) + { + handleSevereException("Unable to successfully factory reset. Delete directory \n'"+getClientInfo().getPrePath()+"/home/rnayabed/HDD_1/projects/stream-pi/server'\nMessage:\n"+e.getMessage(),e); + } + } + + @Override + public void setFirstRun(boolean firstRun) + { + this.firstRun = firstRun; + } +} diff --git a/src/main/java/com/stream_pi/client/controller/ScreenMover.java b/src/main/java/com/stream_pi/client/controller/ScreenMover.java index 6afa1d21..bdb799d0 100755 --- a/src/main/java/com/stream_pi/client/controller/ScreenMover.java +++ b/src/main/java/com/stream_pi/client/controller/ScreenMover.java @@ -1,103 +1,103 @@ -package com.stream_pi.client.controller; - -import com.stream_pi.client.window.Base; -import com.stream_pi.util.exception.SevereException; -import javafx.animation.*; -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.scene.Node; -import javafx.scene.Scene; -import javafx.scene.layout.StackPane; -import javafx.stage.Stage; -import javafx.util.Duration; - -import java.util.Timer; -import java.util.TimerTask; - -public class ScreenMover -{ - private Timer timer; - - private long interval; - - private boolean isOldLocation; - private double originalX, originalY; - private double changeX, changeY; - - private Stage stage; - - public ScreenMover(Stage stage, long interval, int changeX, int changeY) - { - this.stage = stage; - this.changeX = changeX; - this.changeY = changeY; - this.originalX = stage.getX(); - this.originalY = stage.getY(); - this.isOldLocation = true; - this.interval = interval; - - startTimer(); - } - - - public void stop() - { - isOldLocation = true; - shiftScreen(); - - stopTimer(); - } - - public void restart() - { - stop(); - startTimer(); - } - - private void shiftScreen() - { - Platform.runLater(()->{ - if(isOldLocation) - { - isOldLocation = false; - - stage.setX(originalX+changeX); - stage.setY(originalY+changeY); - } - else - { - isOldLocation = true; - - stage.setX(originalX); - stage.setY(originalY); - } - }); - } - - public void setInterval(int seconds) - { - this.interval = seconds; - } - - private void stopTimer() - { - if(timer != null) - { - timer.cancel(); - timer.purge(); - } - } - - private void startTimer() - { - timer = new Timer(); - timer.scheduleAtFixedRate(new TimerTask() - { - @Override - public void run() - { - shiftScreen(); - } - },interval, interval); - } -} +package com.stream_pi.client.controller; + +import com.stream_pi.client.window.Base; +import com.stream_pi.util.exception.SevereException; +import javafx.animation.*; +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.scene.Node; +import javafx.scene.Scene; +import javafx.scene.layout.StackPane; +import javafx.stage.Stage; +import javafx.util.Duration; + +import java.util.Timer; +import java.util.TimerTask; + +public class ScreenMover +{ + private Timer timer; + + private long interval; + + private boolean isOldLocation; + private double originalX, originalY; + private double changeX, changeY; + + private Stage stage; + + public ScreenMover(Stage stage, long interval, int changeX, int changeY) + { + this.stage = stage; + this.changeX = changeX; + this.changeY = changeY; + this.originalX = stage.getX(); + this.originalY = stage.getY(); + this.isOldLocation = true; + this.interval = interval; + + startTimer(); + } + + + public void stop() + { + isOldLocation = true; + shiftScreen(); + + stopTimer(); + } + + public void restart() + { + stop(); + startTimer(); + } + + private void shiftScreen() + { + Platform.runLater(()->{ + if(isOldLocation) + { + isOldLocation = false; + + stage.setX(originalX+changeX); + stage.setY(originalY+changeY); + } + else + { + isOldLocation = true; + + stage.setX(originalX); + stage.setY(originalY); + } + }); + } + + public void setInterval(int seconds) + { + this.interval = seconds; + } + + private void stopTimer() + { + if(timer != null) + { + timer.cancel(); + timer.purge(); + } + } + + private void startTimer() + { + timer = new Timer(); + timer.scheduleAtFixedRate(new TimerTask() + { + @Override + public void run() + { + shiftScreen(); + } + },interval, interval); + } +} diff --git a/src/main/java/com/stream_pi/client/controller/ScreenSaver.java b/src/main/java/com/stream_pi/client/controller/ScreenSaver.java index c208f52c..28bac210 100755 --- a/src/main/java/com/stream_pi/client/controller/ScreenSaver.java +++ b/src/main/java/com/stream_pi/client/controller/ScreenSaver.java @@ -1,124 +1,124 @@ -package com.stream_pi.client.controller; - -import com.stream_pi.client.window.Base; -import com.stream_pi.util.exception.SevereException; -import javafx.animation.*; -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.scene.Node; -import javafx.scene.layout.StackPane; -import javafx.util.Duration; - -import java.util.Timer; -import java.util.TimerTask; - -public class ScreenSaver extends StackPane -{ - private Timer timer; - - private Timeline showScreenSaverTimeline; - private long timeout; - - public ScreenSaver(Base base, int timeout) - { - this.timeout = timeout* 1000L; - - setOpacity(0); - getStyleClass().add("screensaver"); - - - showScreenSaverTimeline = new Timeline(); - showScreenSaverTimeline.setCycleCount(1); - - - showScreenSaverTimeline.getKeyFrames().addAll( - new KeyFrame(Duration.millis(0.0D), - new KeyValue(opacityProperty(), - 0.0D, Interpolator.EASE_IN)), - new KeyFrame(Duration.seconds(15D), - new KeyValue(opacityProperty(), - 1.0D, Interpolator.LINEAR)) - ); - - startTimer(); - - base.setOnMouseClicked(mouseEvent -> { - restart(); - }); - - } - - public void restart() - { - close(); - restartTimer(); - } - - - - public void stop() - { - stopTimer(); - setOpacity(0); - toBack(); - } - - - private void show() - { - Platform.runLater(()->{ - setOpacity(0); - toFront(); - showScreenSaverTimeline.play(); - }); - } - - private void close() - { - Platform.runLater(()->{ - if(showScreenSaverTimeline.getStatus() == Animation.Status.RUNNING) - { - showScreenSaverTimeline.stop(); - } - - - setOpacity(0.0); - toBack(); - }); - - restartTimer(); - } - - public void setTimeout(int seconds) - { - this.timeout = seconds* 1000L; - } - - public void restartTimer() - { - stopTimer(); - startTimer(); - } - - private void stopTimer() - { - if(timer != null) - { - timer.cancel(); - timer.purge(); - } - } - - private void startTimer() - { - timer = new Timer(); - timer.schedule(new TimerTask() - { - @Override - public void run() - { - show(); - } - },timeout); - } -} +package com.stream_pi.client.controller; + +import com.stream_pi.client.window.Base; +import com.stream_pi.util.exception.SevereException; +import javafx.animation.*; +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.scene.Node; +import javafx.scene.layout.StackPane; +import javafx.util.Duration; + +import java.util.Timer; +import java.util.TimerTask; + +public class ScreenSaver extends StackPane +{ + private Timer timer; + + private Timeline showScreenSaverTimeline; + private long timeout; + + public ScreenSaver(Base base, int timeout) + { + this.timeout = timeout* 1000L; + + setOpacity(0); + getStyleClass().add("screensaver"); + + + showScreenSaverTimeline = new Timeline(); + showScreenSaverTimeline.setCycleCount(1); + + + showScreenSaverTimeline.getKeyFrames().addAll( + new KeyFrame(Duration.millis(0.0D), + new KeyValue(opacityProperty(), + 0.0D, Interpolator.EASE_IN)), + new KeyFrame(Duration.seconds(15D), + new KeyValue(opacityProperty(), + 1.0D, Interpolator.LINEAR)) + ); + + startTimer(); + + base.setOnMouseClicked(mouseEvent -> { + restart(); + }); + + } + + public void restart() + { + close(); + restartTimer(); + } + + + + public void stop() + { + stopTimer(); + setOpacity(0); + toBack(); + } + + + private void show() + { + Platform.runLater(()->{ + setOpacity(0); + toFront(); + showScreenSaverTimeline.play(); + }); + } + + private void close() + { + Platform.runLater(()->{ + if(showScreenSaverTimeline.getStatus() == Animation.Status.RUNNING) + { + showScreenSaverTimeline.stop(); + } + + + setOpacity(0.0); + toBack(); + }); + + restartTimer(); + } + + public void setTimeout(int seconds) + { + this.timeout = seconds* 1000L; + } + + public void restartTimer() + { + stopTimer(); + startTimer(); + } + + private void stopTimer() + { + if(timer != null) + { + timer.cancel(); + timer.purge(); + } + } + + private void startTimer() + { + timer = new Timer(); + timer.schedule(new TimerTask() + { + @Override + public void run() + { + show(); + } + },timeout); + } +} diff --git a/src/main/java/com/stream_pi/client/info/ClientInfo.java b/src/main/java/com/stream_pi/client/info/ClientInfo.java index ee884019..19b7d8e0 100755 --- a/src/main/java/com/stream_pi/client/info/ClientInfo.java +++ b/src/main/java/com/stream_pi/client/info/ClientInfo.java @@ -1,121 +1,121 @@ -/* -ServerInfo.java - -Stores basic information about the server - name, platform type - -Contributors: Debayan Sutradhar (@dubbadhar) - */ - -package com.stream_pi.client.info; - -import com.gluonhq.attach.storage.StorageService; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.platform.Platform; -import com.stream_pi.util.platform.ReleaseStatus; -import com.stream_pi.util.version.Version; - -import java.io.File; -import java.io.FileNotFoundException; -import java.util.Optional; -import java.util.function.Function; - -public class ClientInfo { - private Version version; - private final ReleaseStatus releaseStatus; - private Platform platform; - - private String prePath; - - private Version minThemeSupportVersion; - private Version minPluginSupportVersion; - private Version commStandardVersion; - - private static ClientInfo instance = null; - - private ClientInfo() - { - version = new Version(1,0,0); - minThemeSupportVersion = new Version(1,0,0); - minPluginSupportVersion = new Version(1,0,0); - commStandardVersion = new Version(1,0,0); - - releaseStatus = ReleaseStatus.EA; - - String osName = System.getProperty("os.name").toLowerCase(); - - prePath = System.getProperty("user.home")+"/Stream-Pi/Client/"; - - if(osName.contains("windows")) - { - platform = Platform.WINDOWS; - } - else if (osName.contains("linux")) - { - platform = Platform.LINUX; - } - else if(osName.contains("android") || osName.contains("ios")) - { - StorageService.create().ifPresent(s-> s.getPrivateStorage().ifPresentOrElse(sp-> prePath = sp.getAbsolutePath()+"/Stream-Pi/Client/", - ()-> prePath = null)); - - platform = Platform.valueOf(osName.toUpperCase()); - } - else if (osName.contains("mac")) - { - platform = Platform.MAC; - } - else - { - platform = Platform.UNKNOWN; - } - } - - public static synchronized ClientInfo getInstance(){ - if(instance == null) - { - instance = new ClientInfo(); - } - - return instance; - } - - public String getPrePath() - { - return prePath; - } - - public Platform getPlatform() - { - return platform; - } - - public Version getVersion() { - return version; - } - - public ReleaseStatus getReleaseStatus() - { - return releaseStatus; - } - - public Version getMinThemeSupportVersion() - { - return minThemeSupportVersion; - } - - public Version getMinPluginSupportVersion() - { - return minPluginSupportVersion; - } - - public Version getCommStandardVersion() - { - return commStandardVersion; - } - - - public boolean isPhone() - { - return getPlatform() == Platform.ANDROID || getPlatform() == Platform.IOS; - } -} +/* +ServerInfo.java + +Stores basic information about the server - name, platform type + +Contributors: Debayan Sutradhar (@dubbadhar) + */ + +package com.stream_pi.client.info; + +import com.gluonhq.attach.storage.StorageService; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.platform.Platform; +import com.stream_pi.util.platform.ReleaseStatus; +import com.stream_pi.util.version.Version; + +import java.io.File; +import java.io.FileNotFoundException; +import java.util.Optional; +import java.util.function.Function; + +public class ClientInfo { + private Version version; + private final ReleaseStatus releaseStatus; + private Platform platform; + + private String prePath; + + private Version minThemeSupportVersion; + private Version minPluginSupportVersion; + private Version commStandardVersion; + + private static ClientInfo instance = null; + + private ClientInfo() + { + version = new Version(1,0,0); + minThemeSupportVersion = new Version(1,0,0); + minPluginSupportVersion = new Version(1,0,0); + commStandardVersion = new Version(1,0,0); + + releaseStatus = ReleaseStatus.EA; + + String osName = System.getProperty("os.name").toLowerCase(); + + prePath = System.getProperty("user.home")+"/Stream-Pi/Client/"; + + if(osName.contains("windows")) + { + platform = Platform.WINDOWS; + } + else if (osName.contains("linux")) + { + platform = Platform.LINUX; + } + else if(osName.contains("android") || osName.contains("ios")) + { + StorageService.create().ifPresent(s-> s.getPrivateStorage().ifPresentOrElse(sp-> prePath = sp.getAbsolutePath()+"/Stream-Pi/Client/", + ()-> prePath = null)); + + platform = Platform.valueOf(osName.toUpperCase()); + } + else if (osName.contains("mac")) + { + platform = Platform.MAC; + } + else + { + platform = Platform.UNKNOWN; + } + } + + public static synchronized ClientInfo getInstance(){ + if(instance == null) + { + instance = new ClientInfo(); + } + + return instance; + } + + public String getPrePath() + { + return prePath; + } + + public Platform getPlatform() + { + return platform; + } + + public Version getVersion() { + return version; + } + + public ReleaseStatus getReleaseStatus() + { + return releaseStatus; + } + + public Version getMinThemeSupportVersion() + { + return minThemeSupportVersion; + } + + public Version getMinPluginSupportVersion() + { + return minPluginSupportVersion; + } + + public Version getCommStandardVersion() + { + return commStandardVersion; + } + + + public boolean isPhone() + { + return getPlatform() == Platform.ANDROID || getPlatform() == Platform.IOS; + } +} diff --git a/src/main/java/com/stream_pi/client/info/License.java b/src/main/java/com/stream_pi/client/info/License.java index f8f8466c..71a8d9de 100755 --- a/src/main/java/com/stream_pi/client/info/License.java +++ b/src/main/java/com/stream_pi/client/info/License.java @@ -1,43 +1,43 @@ -/* -Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macropad -Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones) - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, either version 3 of the License, or -(at your option) any later version. -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -Written by : Debayan Sutradhar (rnayabed) -*/ - -package com.stream_pi.client.info; - -public class License { - public static String getLicense() - { - return "Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad\n" + - "Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)\n" + - "\n" + - "This program is free software: you can redistribute it and/or modify\n" + - "it under the terms of the GNU General Public License as published by\n" + - "the Free Software Foundation, either version 3 of the License, or\n" + - "(at your option) any later version.\n" + - "\n" + - "This program is distributed in the hope that it will be useful,\n" + - "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + - "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + - "GNU General Public License for more details.\n" + - "\n\n"+ - "Opensource Libraries/Tech used :\n"+ - "1. JavaFX - GNU General Public License with Classpath Exception\nhttp://openjdk.java.net/legal/gplv2+ce.html\n\n"+ - "2. Gluon Attach - GPL License\nhttps://github.com/gluonhq/attach/blob/master/LICENSE\n\n"+ - "3. Gluon Client Maven Plugin - BSD-3 License\nhttps://github.com/gluonhq/client-maven-plugin/blob/master/LICENSE\n\n" + - "4. Ikonli - Apache License\nhttps://github.com/kordamp/ikonli/blob/master/LICENSE\n\n"+ - "5. Roboto Font - Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0\n\n"+ - "6. ControlsFX - BSD 3-Clause License\nhttps://github.com/controlsfx/controlsfx/blob/jfx-13/license.txt\n\n"; - } -} +/* +Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macropad +Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones) + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation, either version 3 of the License, or +(at your option) any later version. +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +Written by : Debayan Sutradhar (rnayabed) +*/ + +package com.stream_pi.client.info; + +public class License { + public static String getLicense() + { + return "Stream-Pi - Free & Open-Source Modular Cross-Platform Programmable Macro Pad\n" + + "Copyright (C) 2019-2021 Debayan Sutradhar (rnayabed), Samuel Quiñones (SamuelQuinones)\n" + + "\n" + + "This program is free software: you can redistribute it and/or modify\n" + + "it under the terms of the GNU General Public License as published by\n" + + "the Free Software Foundation, either version 3 of the License, or\n" + + "(at your option) any later version.\n" + + "\n" + + "This program is distributed in the hope that it will be useful,\n" + + "but WITHOUT ANY WARRANTY; without even the implied warranty of\n" + + "MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n" + + "GNU General Public License for more details.\n" + + "\n\n"+ + "Opensource Libraries/Tech used :\n"+ + "1. JavaFX - GNU General Public License with Classpath Exception\nhttp://openjdk.java.net/legal/gplv2+ce.html\n\n"+ + "2. Gluon Attach - GPL License\nhttps://github.com/gluonhq/attach/blob/master/LICENSE\n\n"+ + "3. Gluon Client Maven Plugin - BSD-3 License\nhttps://github.com/gluonhq/client-maven-plugin/blob/master/LICENSE\n\n" + + "4. Ikonli - Apache License\nhttps://github.com/kordamp/ikonli/blob/master/LICENSE\n\n"+ + "5. Roboto Font - Apache License 2.0\nhttp://www.apache.org/licenses/LICENSE-2.0\n\n"+ + "6. ControlsFX - BSD 3-Clause License\nhttps://github.com/controlsfx/controlsfx/blob/jfx-13/license.txt\n\n"; + } +} diff --git a/src/main/java/com/stream_pi/client/info/StartupFlags.java b/src/main/java/com/stream_pi/client/info/StartupFlags.java index 1c4dbbaf..ff515f13 100755 --- a/src/main/java/com/stream_pi/client/info/StartupFlags.java +++ b/src/main/java/com/stream_pi/client/info/StartupFlags.java @@ -1,12 +1,12 @@ -package com.stream_pi.client.info; - -public class StartupFlags -{ - public static String RUNNER_FILE_NAME = null; - public static boolean IS_SHOW_SHUT_DOWN_BUTTON = false; - public static boolean IS_X_MODE = true; - public static boolean SCREEN_SAVER_FEATURE= false; - public static boolean DEFAULT_FULLSCREEN_MODE=false; - public static boolean SHOW_FULLSCREEN_TOGGLE_BUTTON=true; - public static boolean APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = false; -} +package com.stream_pi.client.info; + +public class StartupFlags +{ + public static String RUNNER_FILE_NAME = null; + public static boolean IS_SHOW_SHUT_DOWN_BUTTON = false; + public static boolean IS_X_MODE = true; + public static boolean SCREEN_SAVER_FEATURE= false; + public static boolean DEFAULT_FULLSCREEN_MODE=false; + public static boolean SHOW_FULLSCREEN_TOGGLE_BUTTON=true; + public static boolean APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION = false; +} diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfile.java b/src/main/java/com/stream_pi/client/profile/ClientProfile.java index ae556b48..5764146b 100755 --- a/src/main/java/com/stream_pi/client/profile/ClientProfile.java +++ b/src/main/java/com/stream_pi/client/profile/ClientProfile.java @@ -1,758 +1,758 @@ -package com.stream_pi.client.profile; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.OutputStream; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.transform.*; -import javax.xml.transform.dom.DOMSource; -import javax.xml.transform.stream.StreamResult; - -import com.stream_pi.action_api.action.Action; -import com.stream_pi.action_api.action.ActionType; -import com.stream_pi.action_api.action.DisplayTextAlignment; -import com.stream_pi.action_api.action.Location; -import com.stream_pi.action_api.actionproperty.ClientProperties; -import com.stream_pi.action_api.actionproperty.property.Property; -import com.stream_pi.action_api.actionproperty.property.Type; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.version.Version; -import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -public class ClientProfile implements Cloneable{ - private String name, ID; - - private int rows, cols, actionSize, actionGap; - - - private HashMap actions; - private String iconsPath; - - private File file; - - private Logger logger; - private Document document; - - public ClientProfile(File file, String iconsPath) throws MinorException - { - this.file = file; - this.iconsPath = iconsPath; - - actions = new HashMap<>(); - - logger = Logger.getLogger(ClientProfile.class.getName()); - - if(!file.exists() && !file.isFile()) - createConfigFile(file); - - try - { - DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); - DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); - document = docBuilder.parse(file); - } - catch (Exception e) - { - e.printStackTrace(); - throw new MinorException("profile", "Unable to read profile config file."); - } - - - setID(file.getName().replace(".xml", "")); - load(); - } - - - private Element getProfileElement() - { - return (Element) document.getElementsByTagName("profile").item(0); - } - - private Element getActionsElement() - { - return (Element) document.getElementsByTagName("actions").item(0); - } - - public void load() throws MinorException - { - try - { - actions.clear(); - - logger.info("Loading profile "+getID()+" ..."); - - String name = XMLConfigHelper.getStringProperty(getProfileElement(), "name"); - int rows = XMLConfigHelper.getIntProperty(getProfileElement(), "rows"); - int cols = XMLConfigHelper.getIntProperty(getProfileElement(), "cols"); - int actionSize = XMLConfigHelper.getIntProperty(getProfileElement(), "action-size"); - int actionGap = XMLConfigHelper.getIntProperty(getProfileElement(), "action-gap"); - - setName(name); - setRows(rows); - setCols(cols); - setActionSize(actionSize); - setActionGap(actionGap); - - - //Load Actions - - NodeList actionsNodesList = getActionsElement().getChildNodes(); - - int actionsSize = actionsNodesList.getLength(); - - logger.info("Actions Size : "+actionsSize); - - for(int item = 0; item-1) - { - - Element actionElement = (Element) getActionsElement().getElementsByTagName("action").item(index); - - Element displayElement = (Element) actionElement.getElementsByTagName("display").item(0); - Element backgroundElement = (Element) displayElement.getElementsByTagName("background").item(0); - Element iconElement = (Element) backgroundElement.getElementsByTagName("icon").item(0); - - Element statesElements = (Element) iconElement.getElementsByTagName("states").item(0); - - NodeList statesNodeList = statesElements.getChildNodes(); - - for (int i = 0;i getActions() - { - ArrayList p = new ArrayList<>(); - for(String profile : actions.keySet()) - p.add(actions.get(profile)); - return p; - } - - public String getID() - { - return ID; - } - - public String getName() - { - return name; - } - - public int getRows() - { - return rows; - } - - public int getCols() - { - return cols; - } - - public int getActionSize() - { - return actionSize; - } - - public Action getActionFromID(String ID) - { - return actions.getOrDefault(ID, null); - } - - public int getActionGap() - { - return actionGap; - } - - public void setRows(int rows) - { - this.rows = rows; - } - - public void setCols(int cols) - { - this.cols = cols; - } - - public void setID(String ID) - { - this.ID = ID; - } - - public void setActionSize(int actionSize) - { - this.actionSize = actionSize; - } - - public void setActionGap(int actionGap) - { - this.actionGap = actionGap; - } - - public void setName(String name) - { - this.name = name; - } - - - public Object clone() throws CloneNotSupportedException - { - return super.clone(); - } -} +package com.stream_pi.client.profile; + +import java.io.File; +import java.io.FileOutputStream; +import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.logging.Logger; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.transform.*; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.stream.StreamResult; + +import com.stream_pi.action_api.action.Action; +import com.stream_pi.action_api.action.ActionType; +import com.stream_pi.action_api.action.DisplayTextAlignment; +import com.stream_pi.action_api.action.Location; +import com.stream_pi.action_api.actionproperty.ClientProperties; +import com.stream_pi.action_api.actionproperty.property.Property; +import com.stream_pi.action_api.actionproperty.property.Type; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.version.Version; +import com.stream_pi.util.xmlconfighelper.XMLConfigHelper; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +public class ClientProfile implements Cloneable{ + private String name, ID; + + private int rows, cols, actionSize, actionGap; + + + private HashMap actions; + private String iconsPath; + + private File file; + + private Logger logger; + private Document document; + + public ClientProfile(File file, String iconsPath) throws MinorException + { + this.file = file; + this.iconsPath = iconsPath; + + actions = new HashMap<>(); + + logger = Logger.getLogger(ClientProfile.class.getName()); + + if(!file.exists() && !file.isFile()) + createConfigFile(file); + + try + { + DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance(); + DocumentBuilder docBuilder = docFactory.newDocumentBuilder(); + document = docBuilder.parse(file); + } + catch (Exception e) + { + e.printStackTrace(); + throw new MinorException("profile", "Unable to read profile config file."); + } + + + setID(file.getName().replace(".xml", "")); + load(); + } + + + private Element getProfileElement() + { + return (Element) document.getElementsByTagName("profile").item(0); + } + + private Element getActionsElement() + { + return (Element) document.getElementsByTagName("actions").item(0); + } + + public void load() throws MinorException + { + try + { + actions.clear(); + + logger.info("Loading profile "+getID()+" ..."); + + String name = XMLConfigHelper.getStringProperty(getProfileElement(), "name"); + int rows = XMLConfigHelper.getIntProperty(getProfileElement(), "rows"); + int cols = XMLConfigHelper.getIntProperty(getProfileElement(), "cols"); + int actionSize = XMLConfigHelper.getIntProperty(getProfileElement(), "action-size"); + int actionGap = XMLConfigHelper.getIntProperty(getProfileElement(), "action-gap"); + + setName(name); + setRows(rows); + setCols(cols); + setActionSize(actionSize); + setActionGap(actionGap); + + + //Load Actions + + NodeList actionsNodesList = getActionsElement().getChildNodes(); + + int actionsSize = actionsNodesList.getLength(); + + logger.info("Actions Size : "+actionsSize); + + for(int item = 0; item-1) + { + + Element actionElement = (Element) getActionsElement().getElementsByTagName("action").item(index); + + Element displayElement = (Element) actionElement.getElementsByTagName("display").item(0); + Element backgroundElement = (Element) displayElement.getElementsByTagName("background").item(0); + Element iconElement = (Element) backgroundElement.getElementsByTagName("icon").item(0); + + Element statesElements = (Element) iconElement.getElementsByTagName("states").item(0); + + NodeList statesNodeList = statesElements.getChildNodes(); + + for (int i = 0;i getActions() + { + ArrayList p = new ArrayList<>(); + for(String profile : actions.keySet()) + p.add(actions.get(profile)); + return p; + } + + public String getID() + { + return ID; + } + + public String getName() + { + return name; + } + + public int getRows() + { + return rows; + } + + public int getCols() + { + return cols; + } + + public int getActionSize() + { + return actionSize; + } + + public Action getActionFromID(String ID) + { + return actions.getOrDefault(ID, null); + } + + public int getActionGap() + { + return actionGap; + } + + public void setRows(int rows) + { + this.rows = rows; + } + + public void setCols(int cols) + { + this.cols = cols; + } + + public void setID(String ID) + { + this.ID = ID; + } + + public void setActionSize(int actionSize) + { + this.actionSize = actionSize; + } + + public void setActionGap(int actionGap) + { + this.actionGap = actionGap; + } + + public void setName(String name) + { + this.name = name; + } + + + public Object clone() throws CloneNotSupportedException + { + return super.clone(); + } +} diff --git a/src/main/java/com/stream_pi/client/profile/ClientProfiles.java b/src/main/java/com/stream_pi/client/profile/ClientProfiles.java index 8d97c991..8e4572b8 100755 --- a/src/main/java/com/stream_pi/client/profile/ClientProfiles.java +++ b/src/main/java/com/stream_pi/client/profile/ClientProfiles.java @@ -1,119 +1,119 @@ -package com.stream_pi.client.profile; - -import com.stream_pi.client.io.Config; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; - -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.logging.Logger; - -public class ClientProfiles { - - - private File profilesFolder; - private String defaultProfileID; - - private Logger logger; - - public ClientProfiles(File profilesFolder, String defaultProfileID) throws SevereException - { - logger = Logger.getLogger(ClientProfiles.class.getName()); - - this.defaultProfileID = defaultProfileID; - this.profilesFolder = profilesFolder; - clientProfiles = new HashMap<>(); - loadingErrors = new ArrayList<>(); - - loadProfiles(); - } - - public void addProfile(ClientProfile clientProfile) throws CloneNotSupportedException { - clientProfiles.put(clientProfile.getID(), (ClientProfile) clientProfile.clone()); - } - - public void deleteProfile(ClientProfile clientProfile) - { - clientProfiles.remove(clientProfile.getID()); - - clientProfile.deleteProfile(); - } - - private ArrayList loadingErrors; - private HashMap clientProfiles; - - public void loadProfiles() throws SevereException - { - logger.info("Loading profiles ..."); - - - String iconsPath = Config.getInstance().getIconsPath(); - - clientProfiles.clear(); - loadingErrors.clear(); - - if(!profilesFolder.isDirectory()) - { - throw new SevereException("Profiles","Profile folder doesn't exist! Cant continue."); - } - - - File[] profilesFiles = profilesFolder.listFiles(); - if(profilesFiles == null) - { - throw new SevereException("Profiles","profilesFiles returned null. Cant continue!"); - } - - for(File eachProfileFile : profilesFiles) - { - try - { - ClientProfile profile = new ClientProfile(eachProfileFile, iconsPath); - try - { - addProfile(profile); - } - catch (CloneNotSupportedException e) - { - e.printStackTrace(); - throw new SevereException(e.getMessage()); - } - } - catch (MinorException e) - { - if(eachProfileFile.getName().replace(".xml","").equals(defaultProfileID)) - { - throw new SevereException("Profiles", "Default profile bad. Can't continue"); - } - - loadingErrors.add(new MinorException(e.getMessage()+" ("+eachProfileFile.getName().replace(".xml", ""))); - - e.printStackTrace(); - } - } - - logger.info("Loaded all profiles!"); - } - - public ArrayList getLoadingErrors() - { - return loadingErrors; - } - - public ArrayList getClientProfiles() - { - ArrayList p = new ArrayList<>(); - for(String profile : clientProfiles.keySet()) - p.add(clientProfiles.get(profile)); - return p; - } - - public ClientProfile getProfileFromID(String profileID) - { - return clientProfiles.getOrDefault(profileID, null); - } - - - -} +package com.stream_pi.client.profile; + +import com.stream_pi.client.io.Config; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.logging.Logger; + +public class ClientProfiles { + + + private File profilesFolder; + private String defaultProfileID; + + private Logger logger; + + public ClientProfiles(File profilesFolder, String defaultProfileID) throws SevereException + { + logger = Logger.getLogger(ClientProfiles.class.getName()); + + this.defaultProfileID = defaultProfileID; + this.profilesFolder = profilesFolder; + clientProfiles = new HashMap<>(); + loadingErrors = new ArrayList<>(); + + loadProfiles(); + } + + public void addProfile(ClientProfile clientProfile) throws CloneNotSupportedException { + clientProfiles.put(clientProfile.getID(), (ClientProfile) clientProfile.clone()); + } + + public void deleteProfile(ClientProfile clientProfile) + { + clientProfiles.remove(clientProfile.getID()); + + clientProfile.deleteProfile(); + } + + private ArrayList loadingErrors; + private HashMap clientProfiles; + + public void loadProfiles() throws SevereException + { + logger.info("Loading profiles ..."); + + + String iconsPath = Config.getInstance().getIconsPath(); + + clientProfiles.clear(); + loadingErrors.clear(); + + if(!profilesFolder.isDirectory()) + { + throw new SevereException("Profiles","Profile folder doesn't exist! Cant continue."); + } + + + File[] profilesFiles = profilesFolder.listFiles(); + if(profilesFiles == null) + { + throw new SevereException("Profiles","profilesFiles returned null. Cant continue!"); + } + + for(File eachProfileFile : profilesFiles) + { + try + { + ClientProfile profile = new ClientProfile(eachProfileFile, iconsPath); + try + { + addProfile(profile); + } + catch (CloneNotSupportedException e) + { + e.printStackTrace(); + throw new SevereException(e.getMessage()); + } + } + catch (MinorException e) + { + if(eachProfileFile.getName().replace(".xml","").equals(defaultProfileID)) + { + throw new SevereException("Profiles", "Default profile bad. Can't continue"); + } + + loadingErrors.add(new MinorException(e.getMessage()+" ("+eachProfileFile.getName().replace(".xml", ""))); + + e.printStackTrace(); + } + } + + logger.info("Loaded all profiles!"); + } + + public ArrayList getLoadingErrors() + { + return loadingErrors; + } + + public ArrayList getClientProfiles() + { + ArrayList p = new ArrayList<>(); + for(String profile : clientProfiles.keySet()) + p.add(clientProfiles.get(profile)); + return p; + } + + public ClientProfile getProfileFromID(String profileID) + { + return clientProfiles.getOrDefault(profileID, null); + } + + + +} diff --git a/src/main/java/com/stream_pi/client/window/Base.java b/src/main/java/com/stream_pi/client/window/Base.java index f283289a..db32b98e 100755 --- a/src/main/java/com/stream_pi/client/window/Base.java +++ b/src/main/java/com/stream_pi/client/window/Base.java @@ -1,530 +1,530 @@ -package com.stream_pi.client.window; - -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.controller.ScreenSaver; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; - -import java.io.File; -import java.nio.file.Paths; -import java.util.Objects; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; -import java.util.logging.Logger; - -import com.stream_pi.client.Main; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.profile.ClientProfiles; -import com.stream_pi.client.window.dashboard.DashboardBase; -import com.stream_pi.client.window.firsttimeuse.FirstTimeUse; -import com.stream_pi.client.window.settings.SettingsBase; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.theme_api.Themes; -import com.stream_pi.util.alert.StreamPiAlert; -import com.stream_pi.util.combobox.StreamPiComboBox; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler; -import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler; -import com.stream_pi.util.platform.Platform; - -import javafx.application.HostServices; -import javafx.geometry.Insets; -import javafx.scene.CacheHint; -import javafx.scene.Cursor; -import javafx.scene.image.Image; -import javafx.scene.input.KeyCombination; -import javafx.scene.layout.StackPane; -import javafx.scene.text.Font; -import javafx.stage.Screen; -import javafx.stage.Stage; - -public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ClientListener -{ - private final ExecutorService executor = Executors.newCachedThreadPool(); - - private Config config; - - private ClientProfiles clientProfiles; - - private ClientInfo clientInfo; - - private Stage stage; - - public Stage getStage() - { - return stage; - } - - public Logger getLogger() - { - return logger; - } - - private DashboardBase dashboardBase; - private SettingsBase settingsBase; - - private FirstTimeUse firstTimeUse; - - - private StackPane alertStackPane; - - @Override - public ClientProfiles getClientProfiles() { - return clientProfiles; - } - - public void setClientProfiles(ClientProfiles clientProfiles) { - this.clientProfiles = clientProfiles; - } - - private Logger logger = null; - private StreamPiLogFileHandler logFileHandler = null; - private StreamPiLogFallbackHandler logFallbackHandler = null; - - @Override - public void initLogger() - { - try - { - if(logFileHandler != null) - return; - - closeLogger(); - logger = Logger.getLogger("com.stream_pi"); - - if(new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite()) - { - String path = ClientInfo.getInstance().getPrePath()+"../stream-pi-client.log"; - - if(getClientInfo().isPhone()) - path = ClientInfo.getInstance().getPrePath()+"stream-pi-client.log"; - - logFileHandler = new StreamPiLogFileHandler(path); - logger.addHandler(logFileHandler); - } - else - { - logFallbackHandler = new StreamPiLogFallbackHandler(); - logger.addHandler(logFallbackHandler); - } - - } - catch(Exception e) - { - e.printStackTrace(); - - logFallbackHandler = new StreamPiLogFallbackHandler(); - logger.addHandler(logFallbackHandler); - } - } - - public void closeLogger() - { - if(logFileHandler != null) - logFileHandler.close(); - else if(logFallbackHandler != null) - logFallbackHandler.close(); - } - - private HostServices hostServices; - - public void setHostServices(HostServices hostServices) - { - this.hostServices = hostServices; - } - - public HostServices getHostServices() - { - return hostServices; - } - - public void initBase() throws SevereException - { - stage = (Stage) getScene().getWindow(); - - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon256x256.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon48x48.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon32x32.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon24x24.png")))); - getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon16x16.png")))); - - clientInfo = ClientInfo.getInstance(); - dashboardBase = new DashboardBase(this, this); - dashboardBase.prefWidthProperty().bind(widthProperty()); - dashboardBase.prefHeightProperty().bind(heightProperty()); - - settingsBase = new SettingsBase(getHostServices(), this, this); - - alertStackPane = new StackPane(); - alertStackPane.setCache(true); - alertStackPane.setCacheHint(CacheHint.SPEED); - alertStackPane.setPadding(new Insets(10)); - alertStackPane.setOpacity(0); - - StreamPiAlert.setParent(alertStackPane); - StreamPiComboBox.setParent(alertStackPane); - - - getChildren().clear(); - - - getChildren().addAll(alertStackPane); - - if(getClientInfo().isPhone()) - { - dashboardBase.setPadding(new Insets(10)); - settingsBase.setPadding(new Insets(10)); - } - - initLogger(); - - checkPrePathDirectory(); - - - getChildren().addAll(settingsBase, dashboardBase); - - setStyle(null); - - config = Config.getInstance(); - - initThemes(); - - if(config.isFirstTimeUse()) - { - - firstTimeUse = new FirstTimeUse(this, this); - - getChildren().add(firstTimeUse); - - if(getClientInfo().isPhone()) - { - firstTimeUse.setPadding(new Insets(10)); - } - - firstTimeUse.toFront(); - - //resolution check - resizeAccordingToResolution(); - } - else - { - dashboardBase.toFront(); - } - } - - public void initThemes() throws SevereException - { - clearStylesheets(); - if(themes==null) - registerThemes(); - applyDefaultStylesheet(); - applyDefaultTheme(); - applyDefaultIconsStylesheet(); - applyGlobalDefaultStylesheet(); - } - - private void resizeAccordingToResolution() - { - if(!getClientInfo().isPhone()) - { - double height = getScreenHeight(); - double width = getScreenWidth(); - - if(height < 500) - setPrefHeight(320); - - if(width < 500) - setPrefWidth(240); - } - } - - @Override - public ExecutorService getExecutor() - { - return executor; - } - - @Override - public double getStageWidth() - { - if(getClientInfo().isPhone()) - { - return getScreenWidth(); - } - else - { - return getStage().getWidth(); - } - } - - public double getScreenWidth() - { - return Screen.getPrimary().getBounds().getWidth(); - } - - @Override - public double getStageHeight() - { - if(ClientInfo.getInstance().isPhone()) - { - return getScreenHeight(); - } - else - { - return getStage().getHeight(); - } - } - - public double getScreenHeight() - { - return Screen.getPrimary().getBounds().getHeight(); - } - - private void checkPrePathDirectory() throws SevereException - { - try - { - String path = getClientInfo().getPrePath(); - - if(path == null) - { - throwStoragePermErrorAlert("Unable to access file system!"); - return; - } - - File file = new File(path); - - - if(!file.exists()) - { - boolean result = file.mkdirs(); - if(result) - { - Config.unzipToDefaultPrePath(); - - initLogger(); - } - else - { - throwStoragePermErrorAlert("No storage permission. Give it!"); - } - } - } - catch (Exception e) - { - e.printStackTrace(); - throw new SevereException(e.getMessage()); - } - } - - private void throwStoragePermErrorAlert(String msg) throws SevereException - { - resizeAccordingToResolution(); - - clearStylesheets(); - applyDefaultStylesheet(); - applyDefaultIconsStylesheet(); - applyGlobalDefaultStylesheet(); - getStage().show(); - throw new SevereException(msg); - } - - public void setupFlags() throws SevereException - { - //Full Screen - if(Config.getInstance().getIsFullScreenMode()) - { - getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); - getStage().setFullScreen(true); - } - else - { - getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC")); - getStage().setFullScreen(false); - } - - //Cursor - if(Config.getInstance().isShowCursor()) - { - setCursor(Cursor.DEFAULT); - } - else - { - setCursor(Cursor.NONE); - } - } - - - public SettingsBase getSettingsPane() { - return settingsBase; - } - - public DashboardBase getDashboardPane() { - return dashboardBase; - } - - public void renderRootDefaultProfile() - { - getDashboardPane().renderProfile(getClientProfiles().getProfileFromID( - getConfig().getStartupProfileID() - ), true); - } - - - - public void clearStylesheets() - { - getStylesheets().clear(); - } - - - - public void applyDefaultStylesheet() - { - if(clientInfo.getPlatform() != Platform.IOS) - Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13); - - getStylesheets().add(Main.class.getResource("style.css").toExternalForm()); - } - - public void applyDefaultIconsStylesheet() - { - getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm()); - } - - - public Config getConfig() - { - return config; - } - - public ClientInfo getClientInfo() - { - return clientInfo; - } - - private Theme currentTheme; - - @Override - public Theme getCurrentTheme() - { - return currentTheme; - } - - - public void applyTheme(Theme t) - { - logger.info("Applying theme '"+t.getFullName()+"' ..."); - - if(t.getFonts() != null) - { - for(String fontFile : t.getFonts()) - { - Font.loadFont(fontFile.replace("%20",""), 13); - } - } - currentTheme = t; - getStylesheets().addAll(t.getStylesheets()); - - logger.info("... Done!"); - } - - public void applyGlobalDefaultStylesheet() - { - File globalCSSFile = new File(getConfig().getDefaultThemesPath()+"/global.css"); - if(globalCSSFile.exists()) - { - getLogger().info("Found global default style sheet. Adding ..."); - getStylesheets().add(globalCSSFile.toURI().toString()); - } - } - - Themes themes; - public void registerThemes() throws SevereException - { - logger.info("Loading themes ..."); - - themes = new Themes(getConfig().getDefaultThemesPath(), getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), clientInfo.getMinThemeSupportVersion()); - - if(!themes.getErrors().isEmpty()) - { - StringBuilder themeErrors = new StringBuilder(); - - for(MinorException eachException : themes.getErrors()) - { - themeErrors.append("\n * ").append(eachException.getMessage()); - } - - if(themes.getIsBadThemeTheCurrentOne()) - { - if(getConfig().getCurrentThemeFullName().equals(getConfig().getDefaultCurrentThemeFullName())) - { - throw new SevereException("Unable to get default theme ("+getConfig().getDefaultCurrentThemeFullName()+")\n" + - "Please restore the theme or reinstall."); - } - - themeErrors.append("\n\nReverted to default theme! (").append(getConfig().getDefaultCurrentThemeFullName()).append(")"); - - getConfig().setCurrentThemeFullName(getConfig().getDefaultCurrentThemeFullName()); - getConfig().save(); - } - - handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString())); - } - logger.info("...Themes loaded successfully !"); - } - - @Override - public Themes getThemes() - { - return themes; - } - - - public void applyDefaultTheme() - { - logger.info("Applying default theme ..."); - - boolean foundTheme = false; - for(Theme t: themes.getThemeList()) - { - if(t.getFullName().equals(config.getCurrentThemeFullName())) - { - foundTheme = true; - applyTheme(t); - break; - } - } - - if(foundTheme) - { - logger.info("... Done!"); - } - else - { - logger.info("Theme not found. reverting to light theme ..."); - try { - Config.getInstance().setCurrentThemeFullName("com.stream_pi.defaultlight"); - Config.getInstance().save(); - - applyDefaultTheme(); - } - catch (SevereException e) - { - handleSevereException(e); - } - } - - - } - - @Override - public String getDefaultThemeFullName() - { - return config.getCurrentThemeFullName(); - } - - -} +package com.stream_pi.client.window; + +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.controller.ScreenSaver; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; + +import java.io.File; +import java.nio.file.Paths; +import java.util.Objects; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; +import java.util.logging.Logger; + +import com.stream_pi.client.Main; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.profile.ClientProfiles; +import com.stream_pi.client.window.dashboard.DashboardBase; +import com.stream_pi.client.window.firsttimeuse.FirstTimeUse; +import com.stream_pi.client.window.settings.SettingsBase; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.theme_api.Themes; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.combobox.StreamPiComboBox; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.loggerhelper.StreamPiLogFallbackHandler; +import com.stream_pi.util.loggerhelper.StreamPiLogFileHandler; +import com.stream_pi.util.platform.Platform; + +import javafx.application.HostServices; +import javafx.geometry.Insets; +import javafx.scene.CacheHint; +import javafx.scene.Cursor; +import javafx.scene.image.Image; +import javafx.scene.input.KeyCombination; +import javafx.scene.layout.StackPane; +import javafx.scene.text.Font; +import javafx.stage.Screen; +import javafx.stage.Stage; + +public abstract class Base extends StackPane implements ExceptionAndAlertHandler, ClientListener +{ + private final ExecutorService executor = Executors.newCachedThreadPool(); + + private Config config; + + private ClientProfiles clientProfiles; + + private ClientInfo clientInfo; + + private Stage stage; + + public Stage getStage() + { + return stage; + } + + public Logger getLogger() + { + return logger; + } + + private DashboardBase dashboardBase; + private SettingsBase settingsBase; + + private FirstTimeUse firstTimeUse; + + + private StackPane alertStackPane; + + @Override + public ClientProfiles getClientProfiles() { + return clientProfiles; + } + + public void setClientProfiles(ClientProfiles clientProfiles) { + this.clientProfiles = clientProfiles; + } + + private Logger logger = null; + private StreamPiLogFileHandler logFileHandler = null; + private StreamPiLogFallbackHandler logFallbackHandler = null; + + @Override + public void initLogger() + { + try + { + if(logFileHandler != null) + return; + + closeLogger(); + logger = Logger.getLogger("com.stream_pi"); + + if(new File(ClientInfo.getInstance().getPrePath()).getAbsoluteFile().getParentFile().canWrite()) + { + String path = ClientInfo.getInstance().getPrePath()+"../stream-pi-client.log"; + + if(getClientInfo().isPhone()) + path = ClientInfo.getInstance().getPrePath()+"stream-pi-client.log"; + + logFileHandler = new StreamPiLogFileHandler(path); + logger.addHandler(logFileHandler); + } + else + { + logFallbackHandler = new StreamPiLogFallbackHandler(); + logger.addHandler(logFallbackHandler); + } + + } + catch(Exception e) + { + e.printStackTrace(); + + logFallbackHandler = new StreamPiLogFallbackHandler(); + logger.addHandler(logFallbackHandler); + } + } + + public void closeLogger() + { + if(logFileHandler != null) + logFileHandler.close(); + else if(logFallbackHandler != null) + logFallbackHandler.close(); + } + + private HostServices hostServices; + + public void setHostServices(HostServices hostServices) + { + this.hostServices = hostServices; + } + + public HostServices getHostServices() + { + return hostServices; + } + + public void initBase() throws SevereException + { + stage = (Stage) getScene().getWindow(); + + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon256x256.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon48x48.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon32x32.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon24x24.png")))); + getStage().getIcons().add(new Image(Objects.requireNonNull(Main.class.getResourceAsStream("icon16x16.png")))); + + clientInfo = ClientInfo.getInstance(); + dashboardBase = new DashboardBase(this, this); + dashboardBase.prefWidthProperty().bind(widthProperty()); + dashboardBase.prefHeightProperty().bind(heightProperty()); + + settingsBase = new SettingsBase(getHostServices(), this, this); + + alertStackPane = new StackPane(); + alertStackPane.setCache(true); + alertStackPane.setCacheHint(CacheHint.SPEED); + alertStackPane.setPadding(new Insets(10)); + alertStackPane.setOpacity(0); + + StreamPiAlert.setParent(alertStackPane); + StreamPiComboBox.setParent(alertStackPane); + + + getChildren().clear(); + + + getChildren().addAll(alertStackPane); + + if(getClientInfo().isPhone()) + { + dashboardBase.setPadding(new Insets(10)); + settingsBase.setPadding(new Insets(10)); + } + + initLogger(); + + checkPrePathDirectory(); + + + getChildren().addAll(settingsBase, dashboardBase); + + setStyle(null); + + config = Config.getInstance(); + + initThemes(); + + if(config.isFirstTimeUse()) + { + + firstTimeUse = new FirstTimeUse(this, this); + + getChildren().add(firstTimeUse); + + if(getClientInfo().isPhone()) + { + firstTimeUse.setPadding(new Insets(10)); + } + + firstTimeUse.toFront(); + + //resolution check + resizeAccordingToResolution(); + } + else + { + dashboardBase.toFront(); + } + } + + public void initThemes() throws SevereException + { + clearStylesheets(); + if(themes==null) + registerThemes(); + applyDefaultStylesheet(); + applyDefaultTheme(); + applyDefaultIconsStylesheet(); + applyGlobalDefaultStylesheet(); + } + + private void resizeAccordingToResolution() + { + if(!getClientInfo().isPhone()) + { + double height = getScreenHeight(); + double width = getScreenWidth(); + + if(height < 500) + setPrefHeight(320); + + if(width < 500) + setPrefWidth(240); + } + } + + @Override + public ExecutorService getExecutor() + { + return executor; + } + + @Override + public double getStageWidth() + { + if(getClientInfo().isPhone()) + { + return getScreenWidth(); + } + else + { + return getStage().getWidth(); + } + } + + public double getScreenWidth() + { + return Screen.getPrimary().getBounds().getWidth(); + } + + @Override + public double getStageHeight() + { + if(ClientInfo.getInstance().isPhone()) + { + return getScreenHeight(); + } + else + { + return getStage().getHeight(); + } + } + + public double getScreenHeight() + { + return Screen.getPrimary().getBounds().getHeight(); + } + + private void checkPrePathDirectory() throws SevereException + { + try + { + String path = getClientInfo().getPrePath(); + + if(path == null) + { + throwStoragePermErrorAlert("Unable to access file system!"); + return; + } + + File file = new File(path); + + + if(!file.exists()) + { + boolean result = file.mkdirs(); + if(result) + { + Config.unzipToDefaultPrePath(); + + initLogger(); + } + else + { + throwStoragePermErrorAlert("No storage permission. Give it!"); + } + } + } + catch (Exception e) + { + e.printStackTrace(); + throw new SevereException(e.getMessage()); + } + } + + private void throwStoragePermErrorAlert(String msg) throws SevereException + { + resizeAccordingToResolution(); + + clearStylesheets(); + applyDefaultStylesheet(); + applyDefaultIconsStylesheet(); + applyGlobalDefaultStylesheet(); + getStage().show(); + throw new SevereException(msg); + } + + public void setupFlags() throws SevereException + { + //Full Screen + if(Config.getInstance().getIsFullScreenMode()) + { + getStage().setFullScreenExitKeyCombination(KeyCombination.NO_MATCH); + getStage().setFullScreen(true); + } + else + { + getStage().setFullScreenExitKeyCombination(KeyCombination.keyCombination("ESC")); + getStage().setFullScreen(false); + } + + //Cursor + if(Config.getInstance().isShowCursor()) + { + setCursor(Cursor.DEFAULT); + } + else + { + setCursor(Cursor.NONE); + } + } + + + public SettingsBase getSettingsPane() { + return settingsBase; + } + + public DashboardBase getDashboardPane() { + return dashboardBase; + } + + public void renderRootDefaultProfile() + { + getDashboardPane().renderProfile(getClientProfiles().getProfileFromID( + getConfig().getStartupProfileID() + ), true); + } + + + + public void clearStylesheets() + { + getStylesheets().clear(); + } + + + + public void applyDefaultStylesheet() + { + if(clientInfo.getPlatform() != Platform.IOS) + Font.loadFont(Main.class.getResourceAsStream("Roboto.ttf"), 13); + + getStylesheets().add(Main.class.getResource("style.css").toExternalForm()); + } + + public void applyDefaultIconsStylesheet() + { + getStylesheets().add(Main.class.getResource("default_icons.css").toExternalForm()); + } + + + public Config getConfig() + { + return config; + } + + public ClientInfo getClientInfo() + { + return clientInfo; + } + + private Theme currentTheme; + + @Override + public Theme getCurrentTheme() + { + return currentTheme; + } + + + public void applyTheme(Theme t) + { + logger.info("Applying theme '"+t.getFullName()+"' ..."); + + if(t.getFonts() != null) + { + for(String fontFile : t.getFonts()) + { + Font.loadFont(fontFile.replace("%20",""), 13); + } + } + currentTheme = t; + getStylesheets().addAll(t.getStylesheets()); + + logger.info("... Done!"); + } + + public void applyGlobalDefaultStylesheet() + { + File globalCSSFile = new File(getConfig().getDefaultThemesPath()+"/global.css"); + if(globalCSSFile.exists()) + { + getLogger().info("Found global default style sheet. Adding ..."); + getStylesheets().add(globalCSSFile.toURI().toString()); + } + } + + Themes themes; + public void registerThemes() throws SevereException + { + logger.info("Loading themes ..."); + + themes = new Themes(getConfig().getDefaultThemesPath(), getConfig().getThemesPath(), getConfig().getCurrentThemeFullName(), clientInfo.getMinThemeSupportVersion()); + + if(!themes.getErrors().isEmpty()) + { + StringBuilder themeErrors = new StringBuilder(); + + for(MinorException eachException : themes.getErrors()) + { + themeErrors.append("\n * ").append(eachException.getMessage()); + } + + if(themes.getIsBadThemeTheCurrentOne()) + { + if(getConfig().getCurrentThemeFullName().equals(getConfig().getDefaultCurrentThemeFullName())) + { + throw new SevereException("Unable to get default theme ("+getConfig().getDefaultCurrentThemeFullName()+")\n" + + "Please restore the theme or reinstall."); + } + + themeErrors.append("\n\nReverted to default theme! (").append(getConfig().getDefaultCurrentThemeFullName()).append(")"); + + getConfig().setCurrentThemeFullName(getConfig().getDefaultCurrentThemeFullName()); + getConfig().save(); + } + + handleMinorException(new MinorException("Theme Loading issues", themeErrors.toString())); + } + logger.info("...Themes loaded successfully !"); + } + + @Override + public Themes getThemes() + { + return themes; + } + + + public void applyDefaultTheme() + { + logger.info("Applying default theme ..."); + + boolean foundTheme = false; + for(Theme t: themes.getThemeList()) + { + if(t.getFullName().equals(config.getCurrentThemeFullName())) + { + foundTheme = true; + applyTheme(t); + break; + } + } + + if(foundTheme) + { + logger.info("... Done!"); + } + else + { + logger.info("Theme not found. reverting to light theme ..."); + try { + Config.getInstance().setCurrentThemeFullName("com.stream_pi.defaultlight"); + Config.getInstance().save(); + + applyDefaultTheme(); + } + catch (SevereException e) + { + handleSevereException(e); + } + } + + + } + + @Override + public String getDefaultThemeFullName() + { + return config.getCurrentThemeFullName(); + } + + +} diff --git a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java index e70436fa..42c276c1 100755 --- a/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java +++ b/src/main/java/com/stream_pi/client/window/ExceptionAndAlertHandler.java @@ -1,15 +1,15 @@ -package com.stream_pi.client.window; - -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; - -public interface ExceptionAndAlertHandler -{ - void onAlert(String title, String body, StreamPiAlertType alertType); - - void handleMinorException(MinorException e); - void handleMinorException(String message, MinorException e); - void handleSevereException(SevereException e); - void handleSevereException(String message, SevereException e); -} +package com.stream_pi.client.window; + +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; + +public interface ExceptionAndAlertHandler +{ + void onAlert(String title, String body, StreamPiAlertType alertType); + + void handleMinorException(MinorException e); + void handleMinorException(String message, MinorException e); + void handleSevereException(SevereException e); + void handleSevereException(String message, SevereException e); +} diff --git a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java index d2b5af66..c1951e23 100755 --- a/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/DashboardBase.java @@ -1,78 +1,78 @@ -package com.stream_pi.client.window.dashboard; - -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPane; - -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.control.Button; -import javafx.scene.layout.HBox; -import javafx.scene.layout.VBox; -import org.kordamp.ikonli.javafx.FontIcon; - -public class DashboardBase extends VBox -{ - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - private ActionGridPane actionGridPane; - private Button settingsButton; - - public DashboardBase(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) - { - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - - actionGridPane = new ActionGridPane(exceptionAndAlertHandler, clientListener); - - FontIcon fontIcon = new FontIcon("fas-cog"); - fontIcon.getStyleClass().addAll("dashboard_settings_button_icon"); - - settingsButton = new Button(); - settingsButton.getStyleClass().addAll("dashboard_settings_button"); - settingsButton.setGraphic(fontIcon); - - HBox hBox = new HBox(settingsButton); - hBox.getStyleClass().add("dashboard_settings_button_parent"); - hBox.setPadding(new Insets(0,5,5,0)); - hBox.setAlignment(Pos.CENTER_RIGHT); - - - getChildren().addAll(actionGridPane,hBox); - - getStyleClass().add("dashboard"); - } - - public void renderProfile(ClientProfile clientProfile, boolean freshRender) - { - renderProfile(clientProfile, "root", freshRender); - } - - public void renderProfile(ClientProfile clientProfile, String currentParent, boolean freshRender) - { - actionGridPane.setClientProfile(clientProfile); - actionGridPane.setCurrentParent(currentParent); - actionGridPane.setFreshRender(freshRender); - - actionGridPane.renderGrid(); - actionGridPane.renderActions(); - } - - public void addBlankActionBox(int col, int row) - { - actionGridPane.addBlankActionBox(col, row); - } - - public void clearActionBox(int col, int row) - { - actionGridPane.clearActionBox(col, row); - } - - public ActionGridPane getActionGridPane() { - return actionGridPane; - } - - public Button getSettingsButton() { - return settingsButton; - } -} +package com.stream_pi.client.window.dashboard; + +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.client.window.dashboard.actiongridpane.ActionGridPane; + +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.control.Button; +import javafx.scene.layout.HBox; +import javafx.scene.layout.VBox; +import org.kordamp.ikonli.javafx.FontIcon; + +public class DashboardBase extends VBox +{ + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + private ActionGridPane actionGridPane; + private Button settingsButton; + + public DashboardBase(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) + { + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + + actionGridPane = new ActionGridPane(exceptionAndAlertHandler, clientListener); + + FontIcon fontIcon = new FontIcon("fas-cog"); + fontIcon.getStyleClass().addAll("dashboard_settings_button_icon"); + + settingsButton = new Button(); + settingsButton.getStyleClass().addAll("dashboard_settings_button"); + settingsButton.setGraphic(fontIcon); + + HBox hBox = new HBox(settingsButton); + hBox.getStyleClass().add("dashboard_settings_button_parent"); + hBox.setPadding(new Insets(0,5,5,0)); + hBox.setAlignment(Pos.CENTER_RIGHT); + + + getChildren().addAll(actionGridPane,hBox); + + getStyleClass().add("dashboard"); + } + + public void renderProfile(ClientProfile clientProfile, boolean freshRender) + { + renderProfile(clientProfile, "root", freshRender); + } + + public void renderProfile(ClientProfile clientProfile, String currentParent, boolean freshRender) + { + actionGridPane.setClientProfile(clientProfile); + actionGridPane.setCurrentParent(currentParent); + actionGridPane.setFreshRender(freshRender); + + actionGridPane.renderGrid(); + actionGridPane.renderActions(); + } + + public void addBlankActionBox(int col, int row) + { + actionGridPane.addBlankActionBox(col, row); + } + + public void clearActionBox(int col, int row) + { + actionGridPane.clearActionBox(col, row); + } + + public ActionGridPane getActionGridPane() { + return actionGridPane; + } + + public Button getSettingsButton() { + return settingsButton; + } +} diff --git a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java index d2bbbe36..f0e828ee 100755 --- a/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java +++ b/src/main/java/com/stream_pi/client/window/dashboard/actiongridpane/ActionBox.java @@ -273,52 +273,51 @@ public void playActionAnimation() throws SevereException { case "None": return; case "Flip": - new Flip(getChildren().get(1)).play(); - break; + new Flip(getChildren().get(1).getParent()).play(); case "Bounce": - new Bounce(getChildren().get(1)).play(); + new Bounce(getChildren().get(1).getParent()).play(); break; case "Bounce In/Out": - new BounceOut(getChildren().get(1)).playOnFinished(new BounceIn(getChildren().get(1))).play(); + new BounceOut(getChildren().get(1).getParent()).playOnFinished(new BounceIn(getChildren().get(1).getParent())).play(); break; case "Fade In/Out": - new FadeOut(getChildren().get(1)).playOnFinished(new FadeIn(getChildren().get(1))).play(); + new FadeOut(getChildren().get(1).getParent()).playOnFinished(new FadeIn(getChildren().get(1).getParent())).play(); break; case "Roll In/Out": - new RollOut(getChildren().get(1)).playOnFinished(new RollIn(getChildren().get(1))).play(); + new RollOut(getChildren().get(1).getParent()).playOnFinished(new RollIn(getChildren().get(1).getParent())).play(); break; case "Rotate In/Out": - new RotateOut(getChildren().get(1)).playOnFinished(new RotateIn(getChildren().get(1))).play(); + new RotateOut(getChildren().get(1).getParent()).playOnFinished(new RotateIn(getChildren().get(1).getParent())).play(); break; case "Zoom In/Out": - new ZoomOut(getChildren().get(1)).playOnFinished(new ZoomIn(getChildren().get(1))).play(); + new ZoomOut(getChildren().get(1).getParent()).playOnFinished(new ZoomIn(getChildren().get(1).getParent())).play(); break; case "Jack In The Box": - new JackInTheBox(getChildren().get(1)).play(); + new JackInTheBox(getChildren().get(1).getParent()).play(); break; case "Swing": - new Swing(getChildren().get(1)).play(); + new Swing(getChildren().get(1).getParent()).play(); break; case "Jello": - new Jello(getChildren().get(1)).play(); + new Jello(getChildren().get(1).getParent()).play(); break; case "Pulse": - new Pulse(getChildren().get(1)).play(); + new Pulse(getChildren().get(1).getParent()).play(); break; case "RubberBand": - new RubberBand(getChildren().get(1)).play(); + new RubberBand(getChildren().get(1).getParent()).play(); break; case "Shake Left/Right": - new Shake(getChildren().get(1)).play(); + new Shake(getChildren().get(1).getParent()).play(); break; case "Shake Up/Down": - new ShakeUpDown(getChildren().get(1)).play(); + new ShakeUpDown(getChildren().get(1).getParent()).play(); break; case "Tada": - new Tada(getChildren().get(1)).play(); + new Tada(getChildren().get(1).getParent()).play(); break; case "Wobble": - new Wobble(getChildren().get(1)).play(); + new Wobble(getChildren().get(1).getParent()).play(); break; default: Logger.getLogger("").warning("Invalid Option/n Please contact quimodotcom to solve this error!"); diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java index edcd6108..9060a0d7 100755 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FinalConfigPane.java @@ -1,174 +1,174 @@ -package com.stream_pi.client.window.firsttimeuse; - -import com.gluonhq.attach.orientation.OrientationService; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.info.StartupFlags; -import com.stream_pi.client.io.Config; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.client.profile.ClientProfile; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.util.alert.StreamPiAlert; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.uihelper.HBoxInputBox; - -import javafx.application.Platform; -import javafx.concurrent.Task; -import javafx.geometry.Orientation; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.control.ScrollPane; -import javafx.scene.control.TextField; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; - -import javax.xml.transform.TransformerException; -import java.io.File; - -public class FinalConfigPane extends VBox -{ - private TextField clientNicknameTextField; - private TextField serverIPHostNameTextField; - private TextField serverPortTextField; - private Button nextButton; - - private ExceptionAndAlertHandler exceptionAndAlertHandler; - private ClientListener clientListener; - - public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener, - Button nextButton) - { - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.clientListener = clientListener; - this.nextButton = nextButton; - - getStyleClass().add("first_time_use_pane_final_config"); - - Label label = new Label("That's it. Now just a little bit and then you're set!"); - label.setWrapText(true); - VBox.setVgrow(label, Priority.ALWAYS); - label.getStyleClass().add("first_time_use_pane_final_config_label"); - - clientNicknameTextField = new TextField(); - serverIPHostNameTextField = new TextField(); - serverPortTextField = new TextField(); - - HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField, 150); - HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField, 150); - HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField, 150); - - getChildren().addAll(label, clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox); - - setSpacing(10.0); - - setVisible(false); - } - - public void makeChangesToNextButton() - { - nextButton.setText("Confirm"); - nextButton.setOnAction(actionEvent -> new Thread(new Task() { - @Override - protected Void call() - { - onConfirmButtonClicked(); - return null; - } - }).start()); - } - - private void onConfirmButtonClicked() - { - Platform.runLater(()->nextButton.setDisable(true)); - - StringBuilder errors = new StringBuilder(); - - if(clientNicknameTextField.getText().isBlank()) - { - errors.append("* Nick name cannot be blank.\n"); - } - - if(serverIPHostNameTextField.getText().isBlank()) - { - errors.append("* Server IP cannot be empty.\n"); - } - - int port = -1; - try - { - port = Integer.parseInt(serverPortTextField.getText()); - - if(port < 1024) - errors.append("* Server Port should be above 1024.\n"); - else if(port > 65535) - errors.append("* Server Port must be lesser than 65535\n"); - } - catch (NumberFormatException exception) - { - errors.append("* Server Port should be a number.\n"); - } - - if(errors.toString().isEmpty()) - { - try - { - Config.getInstance().setNickName(clientNicknameTextField.getText()); - Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText()); - Config.getInstance().setServerPort(port); - Config.getInstance().setFirstTimeUse(false); - - if(ClientInfo.getInstance().isPhone()) - { - Config.getInstance().setScreenMoverEnabled(true); - } - - Config.getInstance().save(); - - ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+ - Config.getInstance().getStartupProfileID()+".xml"), Config.getInstance().getIconsPath()); - - int pre = clientProfile.getActionSize()+(clientProfile.getActionGap()*4); - - - rowsToSet = (int) (clientListener.getStageHeight()/pre); - colsToSet = (int) (clientListener.getStageWidth()/pre); - - if(ClientInfo.getInstance().isPhone()) - { - OrientationService.create().ifPresent(orientationService -> { - if(orientationService.getOrientation().isPresent() && - orientationService.getOrientation().get().equals(Orientation.VERTICAL)) - { - int tmp = rowsToSet; - rowsToSet = colsToSet; - colsToSet = tmp; - } - }); - } - - clientProfile.setCols(colsToSet); - clientProfile.setRows(rowsToSet); - - clientProfile.saveProfileDetails(); - - Platform.runLater(()-> { - clientListener.init(); - clientListener.setupClientConnection(); - }); - } - catch(Exception e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(new SevereException(e.getMessage())); - } - } - else - { - Platform.runLater(()->nextButton.setDisable(false)); - new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors, StreamPiAlertType.ERROR).show(); - } - } - - private int rowsToSet,colsToSet; -} +package com.stream_pi.client.window.firsttimeuse; + +import com.gluonhq.attach.orientation.OrientationService; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.info.StartupFlags; +import com.stream_pi.client.io.Config; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.client.profile.ClientProfile; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.uihelper.HBoxInputBox; + +import javafx.application.Platform; +import javafx.concurrent.Task; +import javafx.geometry.Orientation; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.control.ScrollPane; +import javafx.scene.control.TextField; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; + +import javax.xml.transform.TransformerException; +import java.io.File; + +public class FinalConfigPane extends VBox +{ + private TextField clientNicknameTextField; + private TextField serverIPHostNameTextField; + private TextField serverPortTextField; + private Button nextButton; + + private ExceptionAndAlertHandler exceptionAndAlertHandler; + private ClientListener clientListener; + + public FinalConfigPane(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener, + Button nextButton) + { + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.clientListener = clientListener; + this.nextButton = nextButton; + + getStyleClass().add("first_time_use_pane_final_config"); + + Label label = new Label("That's it. Now just a little bit and then you're set!"); + label.setWrapText(true); + VBox.setVgrow(label, Priority.ALWAYS); + label.getStyleClass().add("first_time_use_pane_final_config_label"); + + clientNicknameTextField = new TextField(); + serverIPHostNameTextField = new TextField(); + serverPortTextField = new TextField(); + + HBoxInputBox clientNickNameInputBox = new HBoxInputBox("Nickname", clientNicknameTextField, 150); + HBoxInputBox serverIPHostNameInputBox = new HBoxInputBox("Server IP", serverIPHostNameTextField, 150); + HBoxInputBox serverIPPortInputBox = new HBoxInputBox("Server Port", serverPortTextField, 150); + + getChildren().addAll(label, clientNickNameInputBox, serverIPHostNameInputBox, serverIPPortInputBox); + + setSpacing(10.0); + + setVisible(false); + } + + public void makeChangesToNextButton() + { + nextButton.setText("Confirm"); + nextButton.setOnAction(actionEvent -> new Thread(new Task() { + @Override + protected Void call() + { + onConfirmButtonClicked(); + return null; + } + }).start()); + } + + private void onConfirmButtonClicked() + { + Platform.runLater(()->nextButton.setDisable(true)); + + StringBuilder errors = new StringBuilder(); + + if(clientNicknameTextField.getText().isBlank()) + { + errors.append("* Nick name cannot be blank.\n"); + } + + if(serverIPHostNameTextField.getText().isBlank()) + { + errors.append("* Server IP cannot be empty.\n"); + } + + int port = -1; + try + { + port = Integer.parseInt(serverPortTextField.getText()); + + if(port < 1024) + errors.append("* Server Port should be above 1024.\n"); + else if(port > 65535) + errors.append("* Server Port must be lesser than 65535\n"); + } + catch (NumberFormatException exception) + { + errors.append("* Server Port should be a number.\n"); + } + + if(errors.toString().isEmpty()) + { + try + { + Config.getInstance().setNickName(clientNicknameTextField.getText()); + Config.getInstance().setServerHostNameOrIP(serverIPHostNameTextField.getText()); + Config.getInstance().setServerPort(port); + Config.getInstance().setFirstTimeUse(false); + + if(ClientInfo.getInstance().isPhone()) + { + Config.getInstance().setScreenMoverEnabled(true); + } + + Config.getInstance().save(); + + ClientProfile clientProfile = new ClientProfile(new File(Config.getInstance().getProfilesPath()+"/"+ + Config.getInstance().getStartupProfileID()+".xml"), Config.getInstance().getIconsPath()); + + int pre = clientProfile.getActionSize()+(clientProfile.getActionGap()*4); + + + rowsToSet = (int) (clientListener.getStageHeight()/pre); + colsToSet = (int) (clientListener.getStageWidth()/pre); + + if(ClientInfo.getInstance().isPhone()) + { + OrientationService.create().ifPresent(orientationService -> { + if(orientationService.getOrientation().isPresent() && + orientationService.getOrientation().get().equals(Orientation.VERTICAL)) + { + int tmp = rowsToSet; + rowsToSet = colsToSet; + colsToSet = tmp; + } + }); + } + + clientProfile.setCols(colsToSet); + clientProfile.setRows(rowsToSet); + + clientProfile.saveProfileDetails(); + + Platform.runLater(()-> { + clientListener.init(); + clientListener.setupClientConnection(); + }); + } + catch(Exception e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleSevereException(new SevereException(e.getMessage())); + } + } + else + { + Platform.runLater(()->nextButton.setDisable(false)); + new StreamPiAlert("Uh Oh", "Please rectify the following errors and try again:\n"+errors, StreamPiAlertType.ERROR).show(); + } + } + + private int rowsToSet,colsToSet; +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java index 927c03a0..857be4fd 100755 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/FirstTimeUse.java @@ -1,142 +1,142 @@ -package com.stream_pi.client.window.firsttimeuse; - -import com.stream_pi.client.Main; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.util.uihelper.SpaceFiller; - -import javafx.geometry.Insets; -import javafx.scene.control.Button; -import javafx.scene.control.Label; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.StackPane; -import javafx.scene.layout.VBox; -import javafx.scene.text.Font; - -public class FirstTimeUse extends VBox{ - - - public FirstTimeUse(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) - { - getStyleClass().add("first_time_use_pane"); - - setSpacing(10.0); - setPadding(new Insets(5)); - - headingLabel = new Label(); - headingLabel.getStyleClass().add("first_time_use_pane_heading_label"); - - StackPane stackPane = new StackPane(); - stackPane.getStyleClass().add("first_time_use_pane_stackpane"); - - VBox.setVgrow(stackPane, Priority.ALWAYS); - - nextButton = new Button("Next"); - nextButton.setOnAction(event-> onNextButtonClicked()); - - previousButton = new Button("Previous"); - previousButton.setOnAction(event-> onPreviousButtonClicked()); - - HBox buttonBar = new HBox(previousButton, SpaceFiller.horizontal(), nextButton); - buttonBar.getStyleClass().add("first_time_use_pane_button_bar"); - buttonBar.setSpacing(10.0); - - welcomePane = new WelcomePane(); - licensePane = new LicensePane(); - finalConfigPane = new FinalConfigPane(exceptionAndAlertHandler, clientListener, nextButton); - - stackPane.getChildren().addAll( - welcomePane, - licensePane, - finalConfigPane - ); - - getChildren().addAll(headingLabel, stackPane, buttonBar); - - setWindow(WindowName.WELCOME); - } - - private Label headingLabel; - private Button nextButton; - private Button previousButton; - private WelcomePane welcomePane; - private LicensePane licensePane; - private FinalConfigPane finalConfigPane; - - private WindowName windowName; - - private void onNextButtonClicked() - { - if(windowName == WindowName.WELCOME) - { - setWindow(WindowName.LICENSE); - } - else if(windowName == WindowName.LICENSE) - { - setWindow(WindowName.FINAL); - } - } - - private void onPreviousButtonClicked() - { - nextButton.setText("Next"); - - if(windowName == WindowName.FINAL) - { - setWindow(WindowName.LICENSE); - } - else if(windowName == WindowName.LICENSE) - { - setWindow(WindowName.WELCOME); - } - } - - private void setWindow(WindowName windowName) - { - if (windowName == WindowName.WELCOME) - { - this.windowName = WindowName.WELCOME; - welcomePane.toFront(); - welcomePane.setVisible(true); - licensePane.setVisible(false); - finalConfigPane.setVisible(false); - - headingLabel.setText(""); - - nextButton.setText("Next"); - nextButton.setOnAction(event-> onNextButtonClicked()); - previousButton.setVisible(false); - } - else if (windowName == WindowName.LICENSE) - { - this.windowName = WindowName.LICENSE; - licensePane.toFront(); - welcomePane.setVisible(false); - licensePane.setVisible(true); - finalConfigPane.setVisible(false); - - headingLabel.setText("License Agreement"); - - nextButton.setText("Agree and Continue"); - nextButton.setOnAction(event-> onNextButtonClicked()); - previousButton.setVisible(true); - } - else if (windowName == WindowName.FINAL) - { - this.windowName = WindowName.FINAL; - finalConfigPane.toFront(); - welcomePane.setVisible(false); - licensePane.setVisible(false); - finalConfigPane.setVisible(true); - - headingLabel.setText("Finishing up ..."); - - finalConfigPane.makeChangesToNextButton(); - previousButton.setVisible(true); - } - } - - - -} +package com.stream_pi.client.window.firsttimeuse; + +import com.stream_pi.client.Main; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.util.uihelper.SpaceFiller; + +import javafx.geometry.Insets; +import javafx.scene.control.Button; +import javafx.scene.control.Label; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.StackPane; +import javafx.scene.layout.VBox; +import javafx.scene.text.Font; + +public class FirstTimeUse extends VBox{ + + + public FirstTimeUse(ExceptionAndAlertHandler exceptionAndAlertHandler, ClientListener clientListener) + { + getStyleClass().add("first_time_use_pane"); + + setSpacing(10.0); + setPadding(new Insets(5)); + + headingLabel = new Label(); + headingLabel.getStyleClass().add("first_time_use_pane_heading_label"); + + StackPane stackPane = new StackPane(); + stackPane.getStyleClass().add("first_time_use_pane_stackpane"); + + VBox.setVgrow(stackPane, Priority.ALWAYS); + + nextButton = new Button("Next"); + nextButton.setOnAction(event-> onNextButtonClicked()); + + previousButton = new Button("Previous"); + previousButton.setOnAction(event-> onPreviousButtonClicked()); + + HBox buttonBar = new HBox(previousButton, SpaceFiller.horizontal(), nextButton); + buttonBar.getStyleClass().add("first_time_use_pane_button_bar"); + buttonBar.setSpacing(10.0); + + welcomePane = new WelcomePane(); + licensePane = new LicensePane(); + finalConfigPane = new FinalConfigPane(exceptionAndAlertHandler, clientListener, nextButton); + + stackPane.getChildren().addAll( + welcomePane, + licensePane, + finalConfigPane + ); + + getChildren().addAll(headingLabel, stackPane, buttonBar); + + setWindow(WindowName.WELCOME); + } + + private Label headingLabel; + private Button nextButton; + private Button previousButton; + private WelcomePane welcomePane; + private LicensePane licensePane; + private FinalConfigPane finalConfigPane; + + private WindowName windowName; + + private void onNextButtonClicked() + { + if(windowName == WindowName.WELCOME) + { + setWindow(WindowName.LICENSE); + } + else if(windowName == WindowName.LICENSE) + { + setWindow(WindowName.FINAL); + } + } + + private void onPreviousButtonClicked() + { + nextButton.setText("Next"); + + if(windowName == WindowName.FINAL) + { + setWindow(WindowName.LICENSE); + } + else if(windowName == WindowName.LICENSE) + { + setWindow(WindowName.WELCOME); + } + } + + private void setWindow(WindowName windowName) + { + if (windowName == WindowName.WELCOME) + { + this.windowName = WindowName.WELCOME; + welcomePane.toFront(); + welcomePane.setVisible(true); + licensePane.setVisible(false); + finalConfigPane.setVisible(false); + + headingLabel.setText(""); + + nextButton.setText("Next"); + nextButton.setOnAction(event-> onNextButtonClicked()); + previousButton.setVisible(false); + } + else if (windowName == WindowName.LICENSE) + { + this.windowName = WindowName.LICENSE; + licensePane.toFront(); + welcomePane.setVisible(false); + licensePane.setVisible(true); + finalConfigPane.setVisible(false); + + headingLabel.setText("License Agreement"); + + nextButton.setText("Agree and Continue"); + nextButton.setOnAction(event-> onNextButtonClicked()); + previousButton.setVisible(true); + } + else if (windowName == WindowName.FINAL) + { + this.windowName = WindowName.FINAL; + finalConfigPane.toFront(); + welcomePane.setVisible(false); + licensePane.setVisible(false); + finalConfigPane.setVisible(true); + + headingLabel.setText("Finishing up ..."); + + finalConfigPane.makeChangesToNextButton(); + previousButton.setVisible(true); + } + } + + + +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java index 521e5df2..aa35e97c 100755 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/LicensePane.java @@ -1,24 +1,24 @@ -package com.stream_pi.client.window.firsttimeuse; - -import com.stream_pi.client.info.License; - -import javafx.scene.control.Label; -import javafx.scene.control.TextArea; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; - -public class LicensePane extends VBox { - public LicensePane() - { - getStyleClass().add("first_time_use_pane_license"); - - TextArea licenseTextArea = new TextArea(License.getLicense()); - licenseTextArea.setWrapText(false); - licenseTextArea.setEditable(false); - - licenseTextArea.prefWidthProperty().bind(widthProperty()); - VBox.setVgrow(licenseTextArea, Priority.ALWAYS); - - getChildren().addAll(licenseTextArea); - } -} +package com.stream_pi.client.window.firsttimeuse; + +import com.stream_pi.client.info.License; + +import javafx.scene.control.Label; +import javafx.scene.control.TextArea; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; + +public class LicensePane extends VBox { + public LicensePane() + { + getStyleClass().add("first_time_use_pane_license"); + + TextArea licenseTextArea = new TextArea(License.getLicense()); + licenseTextArea.setWrapText(false); + licenseTextArea.setEditable(false); + + licenseTextArea.prefWidthProperty().bind(widthProperty()); + VBox.setVgrow(licenseTextArea, Priority.ALWAYS); + + getChildren().addAll(licenseTextArea); + } +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java index 1363cfd6..cb0c59b0 100755 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WelcomePane.java @@ -1,29 +1,29 @@ -package com.stream_pi.client.window.firsttimeuse; - -import javafx.geometry.Pos; -import javafx.scene.control.Label; -import javafx.scene.layout.VBox; - -public class WelcomePane extends VBox{ - public WelcomePane() - { - getStyleClass().add("first_time_use_pane_welcome"); - - Label welcomeLabel = new Label("Welcome!"); - welcomeLabel.setWrapText(true); - welcomeLabel.setAlignment(Pos.CENTER); - welcomeLabel.getStyleClass().add("first_time_use_welcome_pane_welcome_label"); - - Label nextToContinue = new Label("Please click \"Next\" to start the Setup process"); - nextToContinue.setWrapText(true); - nextToContinue.setAlignment(Pos.CENTER); - nextToContinue.getStyleClass().add("first_time_use_welcome_pane_next_to_continue_label"); - - - setAlignment(Pos.CENTER); - setSpacing(5.0); - getChildren().addAll(welcomeLabel, nextToContinue); - - setVisible(false); - } -} +package com.stream_pi.client.window.firsttimeuse; + +import javafx.geometry.Pos; +import javafx.scene.control.Label; +import javafx.scene.layout.VBox; + +public class WelcomePane extends VBox{ + public WelcomePane() + { + getStyleClass().add("first_time_use_pane_welcome"); + + Label welcomeLabel = new Label("Welcome!"); + welcomeLabel.setWrapText(true); + welcomeLabel.setAlignment(Pos.CENTER); + welcomeLabel.getStyleClass().add("first_time_use_welcome_pane_welcome_label"); + + Label nextToContinue = new Label("Please click \"Next\" to start the Setup process"); + nextToContinue.setWrapText(true); + nextToContinue.setAlignment(Pos.CENTER); + nextToContinue.getStyleClass().add("first_time_use_welcome_pane_next_to_continue_label"); + + + setAlignment(Pos.CENTER); + setSpacing(5.0); + getChildren().addAll(welcomeLabel, nextToContinue); + + setVisible(false); + } +} diff --git a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java index 8256a3a6..84a8214f 100755 --- a/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java +++ b/src/main/java/com/stream_pi/client/window/firsttimeuse/WindowName.java @@ -1,5 +1,5 @@ -package com.stream_pi.client.window.firsttimeuse; - -public enum WindowName { - WELCOME, LICENSE, FINAL -} +package com.stream_pi.client.window.firsttimeuse; + +public enum WindowName { + WELCOME, LICENSE, FINAL +} diff --git a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java index 9e76a180..eaeaccbf 100755 --- a/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/AboutTab.java @@ -1,173 +1,173 @@ -package com.stream_pi.client.window.settings.About; - -import com.stream_pi.action_api.ActionAPI; -import com.stream_pi.client.Main; -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.info.ClientInfo; -import javafx.application.HostServices; -import javafx.event.Event; -import javafx.event.EventHandler; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.*; -import javafx.scene.image.Image; -import javafx.scene.image.ImageView; -import javafx.scene.input.SwipeEvent; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; - -import java.io.IOException; -import java.io.InputStream; -import java.lang.management.ManagementFactory; -import java.net.URL; -import java.nio.file.Files; -import java.nio.file.Paths; -import java.util.Objects; -import java.util.logging.Logger; - -public class AboutTab extends ScrollPane -{ - private ClientListener clientListener; - - private ContributorsTab contributorsTab; - private VBox mainVBox; - - public AboutTab(ClientListener clientListener) - { - this.clientListener = clientListener; - - getStyleClass().add("about_parent"); - - setPadding(new Insets(5)); - - mainVBox = new VBox(); - mainVBox.getStyleClass().add("about"); - mainVBox.setSpacing(5.0); - - - mainVBox.setAlignment(Pos.TOP_CENTER); - - Image appIcon = new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))); - ImageView appIconImageView = new ImageView(appIcon); - appIconImageView.setFitHeight(146); - appIconImageView.setFitWidth(132); - - - Tab contributorsT = new Tab("Contributors"); - contributorsTab = new ContributorsTab(); - contributorsT.setContent(contributorsTab); - - - TabPane tabPane = new TabPane(); - tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); - - tabPane.getStyleClass().add("settings_about_tab_internal"); - tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); - tabPane.setMaxWidth(600); - VBox.setVgrow(tabPane, Priority.ALWAYS); - - Tab licenseTab = new Tab("License"); - licenseTab.setContent(new LicenseTab()); - - - - Tab contactTab = new Tab("Contact"); - contactTab.setContent(new ContactTab(clientListener)); - - tabPane.getTabs().addAll(licenseTab, contributorsT, contactTab); - - - Hyperlink donateButton = new Hyperlink("DONATE"); - donateButton.setOnAction(event -> openWebpage("https://www.patreon.com/streampi")); - donateButton.getStyleClass().add("about_donate_hyperlink"); - - - ClientInfo clientInfo = ClientInfo.getInstance(); - - Label versionText = new Label(clientInfo.getVersion().getText() + " - "+ clientInfo.getPlatform().getUIName() + " - "+ clientInfo.getReleaseStatus().getUIName()); - versionText.getStyleClass().add("about_version_label"); - - Label commStandardLabel = new Label("Comm Standard "+clientInfo.getCommStandardVersion().getText()); - commStandardLabel.getStyleClass().add("about_comm_standard_label"); - - Label minThemeAPILabel = new Label("Min ThemeAPI "+clientInfo.getMinThemeSupportVersion().getText()); - minThemeAPILabel.getStyleClass().add("about_min_theme_api_label"); - - Label minActionAPILabel = new Label("Min ActionAPI "+clientInfo.getMinPluginSupportVersion().getText()); - minActionAPILabel.getStyleClass().add("about_min_action_api_label"); - - Label currentActionAPILabel = new Label("ActionAPI "+ ActionAPI.API_VERSION.getText()); - currentActionAPILabel.getStyleClass().add("about_current_action_api_label"); - - HBox hBox1 = new HBox(versionText); - - hBox1.setAlignment(Pos.CENTER); - hBox1.setSpacing(10); - - Label javaVersionLabel = new Label("Java "+System.getProperty("java.version")); - javaVersionLabel.getStyleClass().add("about_java_version"); - - Label javafxVersionLabel = new Label("JavaFX "+System.getProperty("javafx.version")); - javafxVersionLabel.getStyleClass().add("about_javafx_version"); - - Label javaGCLabel = new Label("GC: "+ ManagementFactory.getGarbageCollectorMXBeans().get(0).getName()); - javaGCLabel.getStyleClass().add("about_java_gc"); - - HBox hBox2 = new HBox(javaVersionLabel, getSep(), - javafxVersionLabel); - - hBox2.setAlignment(Pos.CENTER); - hBox2.setSpacing(10); - - - Label disclaimerLabel = new Label("This contributor list shows only those who have contributed " + - "to the Client Source code.\nTo know about the contributors of Action API, Theme API, Util, " + - "visit the respective repositories. If you want to know about the Core Team instead, please visit the website."); - - disclaimerLabel.getStyleClass().add("about_license_contributors_disclaimer_label"); - - disclaimerLabel.prefWidthProperty().bind(tabPane.widthProperty()); - - disclaimerLabel.setWrapText(true); - - - mainVBox.getChildren().addAll(appIconImageView, tabPane, disclaimerLabel, - donateButton, hBox1, hBox2,javaGCLabel); - mainVBox.prefWidthProperty().bind(widthProperty().subtract(30)); - - setContent(mainVBox); - - InputStream inputStream = Main.class.getResourceAsStream("build-date"); - if(inputStream != null) - { - try - { - Logger.getLogger(getClass().getName()).info("build-date present"); - Label buildDateLabel = new Label("Build date/time: " + new String(inputStream.readAllBytes())); - buildDateLabel.getStyleClass().add("build-date-label"); - mainVBox.getChildren().add(buildDateLabel); - } - catch (IOException e) - { - Logger.getLogger(getClass().getName()).info("build-date not present"); - } - } - - setCache(true); - setCacheHint(CacheHint.SPEED); - } - - private Label getSep() - { - Label label = new Label("|"); - label.getStyleClass().add("separator_ui_label"); - return label; - } - - public void openWebpage(String url) - { - clientListener.openURL(url); - } -} +package com.stream_pi.client.window.settings.About; + +import com.stream_pi.action_api.ActionAPI; +import com.stream_pi.client.Main; +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.info.ClientInfo; +import javafx.application.HostServices; +import javafx.event.Event; +import javafx.event.EventHandler; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.*; +import javafx.scene.image.Image; +import javafx.scene.image.ImageView; +import javafx.scene.input.SwipeEvent; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; + +import java.io.IOException; +import java.io.InputStream; +import java.lang.management.ManagementFactory; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.Objects; +import java.util.logging.Logger; + +public class AboutTab extends ScrollPane +{ + private ClientListener clientListener; + + private ContributorsTab contributorsTab; + private VBox mainVBox; + + public AboutTab(ClientListener clientListener) + { + this.clientListener = clientListener; + + getStyleClass().add("about_parent"); + + setPadding(new Insets(5)); + + mainVBox = new VBox(); + mainVBox.getStyleClass().add("about"); + mainVBox.setSpacing(5.0); + + + mainVBox.setAlignment(Pos.TOP_CENTER); + + Image appIcon = new Image(Objects.requireNonNull(Main.class.getResourceAsStream("app_icon.png"))); + ImageView appIconImageView = new ImageView(appIcon); + appIconImageView.setFitHeight(146); + appIconImageView.setFitWidth(132); + + + Tab contributorsT = new Tab("Contributors"); + contributorsTab = new ContributorsTab(); + contributorsT.setContent(contributorsTab); + + + TabPane tabPane = new TabPane(); + tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); + + tabPane.getStyleClass().add("settings_about_tab_internal"); + tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); + tabPane.setMaxWidth(600); + VBox.setVgrow(tabPane, Priority.ALWAYS); + + Tab licenseTab = new Tab("License"); + licenseTab.setContent(new LicenseTab()); + + + + Tab contactTab = new Tab("Contact"); + contactTab.setContent(new ContactTab(clientListener)); + + tabPane.getTabs().addAll(licenseTab, contributorsT, contactTab); + + + Hyperlink donateButton = new Hyperlink("DONATE"); + donateButton.setOnAction(event -> openWebpage("https://www.patreon.com/streampi")); + donateButton.getStyleClass().add("about_donate_hyperlink"); + + + ClientInfo clientInfo = ClientInfo.getInstance(); + + Label versionText = new Label(clientInfo.getVersion().getText() + " - "+ clientInfo.getPlatform().getUIName() + " - "+ clientInfo.getReleaseStatus().getUIName()); + versionText.getStyleClass().add("about_version_label"); + + Label commStandardLabel = new Label("Comm Standard "+clientInfo.getCommStandardVersion().getText()); + commStandardLabel.getStyleClass().add("about_comm_standard_label"); + + Label minThemeAPILabel = new Label("Min ThemeAPI "+clientInfo.getMinThemeSupportVersion().getText()); + minThemeAPILabel.getStyleClass().add("about_min_theme_api_label"); + + Label minActionAPILabel = new Label("Min ActionAPI "+clientInfo.getMinPluginSupportVersion().getText()); + minActionAPILabel.getStyleClass().add("about_min_action_api_label"); + + Label currentActionAPILabel = new Label("ActionAPI "+ ActionAPI.API_VERSION.getText()); + currentActionAPILabel.getStyleClass().add("about_current_action_api_label"); + + HBox hBox1 = new HBox(versionText); + + hBox1.setAlignment(Pos.CENTER); + hBox1.setSpacing(10); + + Label javaVersionLabel = new Label("Java "+System.getProperty("java.version")); + javaVersionLabel.getStyleClass().add("about_java_version"); + + Label javafxVersionLabel = new Label("JavaFX "+System.getProperty("javafx.version")); + javafxVersionLabel.getStyleClass().add("about_javafx_version"); + + Label javaGCLabel = new Label("GC: "+ ManagementFactory.getGarbageCollectorMXBeans().get(0).getName()); + javaGCLabel.getStyleClass().add("about_java_gc"); + + HBox hBox2 = new HBox(javaVersionLabel, getSep(), + javafxVersionLabel); + + hBox2.setAlignment(Pos.CENTER); + hBox2.setSpacing(10); + + + Label disclaimerLabel = new Label("This contributor list shows only those who have contributed " + + "to the Client Source code.\nTo know about the contributors of Action API, Theme API, Util, " + + "visit the respective repositories. If you want to know about the Core Team instead, please visit the website."); + + disclaimerLabel.getStyleClass().add("about_license_contributors_disclaimer_label"); + + disclaimerLabel.prefWidthProperty().bind(tabPane.widthProperty()); + + disclaimerLabel.setWrapText(true); + + + mainVBox.getChildren().addAll(appIconImageView, tabPane, disclaimerLabel, + donateButton, hBox1, hBox2,javaGCLabel); + mainVBox.prefWidthProperty().bind(widthProperty().subtract(30)); + + setContent(mainVBox); + + InputStream inputStream = Main.class.getResourceAsStream("build-date"); + if(inputStream != null) + { + try + { + Logger.getLogger(getClass().getName()).info("build-date present"); + Label buildDateLabel = new Label("Build date/time: " + new String(inputStream.readAllBytes())); + buildDateLabel.getStyleClass().add("build-date-label"); + mainVBox.getChildren().add(buildDateLabel); + } + catch (IOException e) + { + Logger.getLogger(getClass().getName()).info("build-date not present"); + } + } + + setCache(true); + setCacheHint(CacheHint.SPEED); + } + + private Label getSep() + { + Label label = new Label("|"); + label.getStyleClass().add("separator_ui_label"); + return label; + } + + public void openWebpage(String url) + { + clientListener.openURL(url); + } +} diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java index 2eb64a7e..04005b2b 100755 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContactTab.java @@ -1,50 +1,50 @@ -package com.stream_pi.client.window.settings.About; - -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.info.ClientInfo; -import com.stream_pi.util.contactlinks.ContactLinks; -import javafx.application.HostServices; -import javafx.scene.control.Hyperlink; -import javafx.scene.control.ScrollPane; -import javafx.scene.layout.VBox; - - -public class ContactTab extends ScrollPane -{ - private ClientListener clientListener; - - public ContactTab(ClientListener clientListener) - { - this.clientListener = clientListener; - - getStyleClass().add("about_contact_tab_scroll_pane"); - - Hyperlink github = new Hyperlink("GitHub"); - github.setOnAction(event -> openWebpage(ContactLinks.getGitHub())); - - Hyperlink discord = new Hyperlink("Discord"); - discord.setOnAction(event -> openWebpage(ContactLinks.getDiscord())); - - Hyperlink website = new Hyperlink("Website"); - website.setOnAction(event -> openWebpage(ContactLinks.getWebsite())); - - Hyperlink twitter = new Hyperlink("Twitter"); - twitter.setOnAction(event -> openWebpage(ContactLinks.getTwitter())); - - Hyperlink matrix = new Hyperlink("Matrix"); - matrix.setOnAction(event -> openWebpage(ContactLinks.getMatrix())); - - - VBox vBox = new VBox(github, discord, website, twitter, matrix); - vBox.setSpacing(10.0); - - setContent(vBox); - } - - - public void openWebpage(String url) - { - clientListener.openURL(url); - } - -} +package com.stream_pi.client.window.settings.About; + +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.info.ClientInfo; +import com.stream_pi.util.contactlinks.ContactLinks; +import javafx.application.HostServices; +import javafx.scene.control.Hyperlink; +import javafx.scene.control.ScrollPane; +import javafx.scene.layout.VBox; + + +public class ContactTab extends ScrollPane +{ + private ClientListener clientListener; + + public ContactTab(ClientListener clientListener) + { + this.clientListener = clientListener; + + getStyleClass().add("about_contact_tab_scroll_pane"); + + Hyperlink github = new Hyperlink("GitHub"); + github.setOnAction(event -> openWebpage(ContactLinks.getGitHub())); + + Hyperlink discord = new Hyperlink("Discord"); + discord.setOnAction(event -> openWebpage(ContactLinks.getDiscord())); + + Hyperlink website = new Hyperlink("Website"); + website.setOnAction(event -> openWebpage(ContactLinks.getWebsite())); + + Hyperlink twitter = new Hyperlink("Twitter"); + twitter.setOnAction(event -> openWebpage(ContactLinks.getTwitter())); + + Hyperlink matrix = new Hyperlink("Matrix"); + matrix.setOnAction(event -> openWebpage(ContactLinks.getMatrix())); + + + VBox vBox = new VBox(github, discord, website, twitter, matrix); + vBox.setSpacing(10.0); + + setContent(vBox); + } + + + public void openWebpage(String url) + { + clientListener.openURL(url); + } + +} diff --git a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java index f0496c7d..03258429 100755 --- a/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/Contributor.java @@ -1,49 +1,49 @@ -package com.stream_pi.client.window.settings.About; - -public class Contributor -{ - public String name = null; - public String email = null; - public String description = null; - public String location = null; - - public Contributor(String name, String email, String description, String location) - { - this.name = name; - this.email = email; - this.description = description; - this.location = location; - } - - public void setName(String name) { - this.name = name; - } - - public void setEmail(String email) { - this.email = email; - } - - public void setDescription(String description) { - this.description = description; - } - - public String getName() { - return name; - } - - public String getEmail() { - return email; - } - - public String getDescription() { - return description; - } - - public String getLocation() { - return location; - } - - public void setLocation(String location) { - this.location = location; - } +package com.stream_pi.client.window.settings.About; + +public class Contributor +{ + public String name = null; + public String email = null; + public String description = null; + public String location = null; + + public Contributor(String name, String email, String description, String location) + { + this.name = name; + this.email = email; + this.description = description; + this.location = location; + } + + public void setName(String name) { + this.name = name; + } + + public void setEmail(String email) { + this.email = email; + } + + public void setDescription(String description) { + this.description = description; + } + + public String getName() { + return name; + } + + public String getEmail() { + return email; + } + + public String getDescription() { + return description; + } + + public String getLocation() { + return location; + } + + public void setLocation(String location) { + this.location = location; + } } \ No newline at end of file diff --git a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java index 9b7339ea..4a69636e 100755 --- a/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/ContributorsTab.java @@ -1,80 +1,76 @@ -package com.stream_pi.client.window.settings.About; - -import javafx.scene.CacheHint; -import javafx.scene.control.Label; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.cell.PropertyValueFactory; -import javafx.scene.layout.VBox; - -public class ContributorsTab extends VBox -{ - TableView tableView; - - public ContributorsTab() - { - getStyleClass().add("about_license_contributors_vbox"); - - tableView = new TableView<>(); - tableView.getStyleClass().add("about_license_contributors_table_view"); - - TableColumn descriptionColumn = new TableColumn<>("Description"); - descriptionColumn.setReorderable(false); - descriptionColumn.setPrefWidth(250); - descriptionColumn.setResizable(false); - descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description")); - - TableColumn nameColumn = new TableColumn<>("Name (GitHub)"); - nameColumn.setReorderable(false); - nameColumn.setPrefWidth(220); - nameColumn.setResizable(false); - nameColumn.setCellValueFactory(new PropertyValueFactory<>("name")); - - TableColumn emailColumn = new TableColumn<>("Email"); - emailColumn.setReorderable(false); - emailColumn.setPrefWidth(200); - emailColumn.setResizable(false); - emailColumn.setCellValueFactory(new PropertyValueFactory<>("email")); - - TableColumn locationColumn = new TableColumn<>("Location"); - locationColumn.setReorderable(false); - locationColumn.setPrefWidth(100); - locationColumn.setResizable(false); - locationColumn.setCellValueFactory(new PropertyValueFactory<>("location")); - - - tableView.getColumns().addAll(descriptionColumn, nameColumn, emailColumn, locationColumn); - - tableView.setPrefWidth(descriptionColumn.getPrefWidth() + nameColumn.getPrefWidth() + emailColumn.getPrefWidth()); - - tableView.getItems().addAll( - new Contributor("Debayan Sutradhar (rnayabed)", - "debayansutradhar3@gmail.com", - "Founder, Author, Maintainer", - "India"), - new Contributor("Samuel Quiñones (SamuelQuinones)", - "sdquinones1@gmail.com", - "Founder", - "United States"), - new Contributor("Abhinay Agarwal (abhinayagarwal)", - "abhinay_agarwal@live.com", - "Refactoring, Fixes", - "India"), - new Contributor("Evan Donald (quimodotcom)", - "evandonald01@gmail.com", - "Action Animations", - "United Kingdom") - ); - - getChildren().addAll(tableView); - - - setCache(true); - setCacheHint(CacheHint.SPEED); - } - - public TableView getTableView() - { - return tableView; - } -} +package com.stream_pi.client.window.settings.About; + +import javafx.scene.CacheHint; +import javafx.scene.control.Label; +import javafx.scene.control.TableColumn; +import javafx.scene.control.TableView; +import javafx.scene.control.cell.PropertyValueFactory; +import javafx.scene.layout.VBox; + +public class ContributorsTab extends VBox +{ + TableView tableView; + + public ContributorsTab() + { + getStyleClass().add("about_license_contributors_vbox"); + + tableView = new TableView<>(); + tableView.getStyleClass().add("about_license_contributors_table_view"); + + TableColumn descriptionColumn = new TableColumn<>("Description"); + descriptionColumn.setReorderable(false); + descriptionColumn.setPrefWidth(250); + descriptionColumn.setResizable(false); + descriptionColumn.setCellValueFactory(new PropertyValueFactory<>("description")); + + TableColumn nameColumn = new TableColumn<>("Name (GitHub)"); + nameColumn.setReorderable(false); + nameColumn.setPrefWidth(220); + nameColumn.setResizable(false); + nameColumn.setCellValueFactory(new PropertyValueFactory<>("name")); + + TableColumn emailColumn = new TableColumn<>("Email"); + emailColumn.setReorderable(false); + emailColumn.setPrefWidth(200); + emailColumn.setResizable(false); + emailColumn.setCellValueFactory(new PropertyValueFactory<>("email")); + + TableColumn locationColumn = new TableColumn<>("Location"); + locationColumn.setReorderable(false); + locationColumn.setPrefWidth(100); + locationColumn.setResizable(false); + locationColumn.setCellValueFactory(new PropertyValueFactory<>("location")); + + + tableView.getColumns().addAll(descriptionColumn, nameColumn, emailColumn, locationColumn); + + tableView.setPrefWidth(descriptionColumn.getPrefWidth() + nameColumn.getPrefWidth() + emailColumn.getPrefWidth()); + + tableView.getItems().addAll( + new Contributor("Debayan Sutradhar (rnayabed)", + "debayansutradhar3@gmail.com", + "Founder, Author, Maintainer", + "India"), + new Contributor("Samuel Quiñones (SamuelQuinones)", + "sdquinones1@gmail.com", + "Founder", + "United States"), + new Contributor("Abhinay Agarwal (abhinayagarwal)", + "abhinay_agarwal@live.com", + "Refactoring, Fixes", + "India") + ); + + getChildren().addAll(tableView); + + + setCache(true); + setCacheHint(CacheHint.SPEED); + } + + public TableView getTableView() + { + return tableView; + } +} diff --git a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java index 990d319d..88ab9746 100755 --- a/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/About/LicenseTab.java @@ -1,16 +1,16 @@ -package com.stream_pi.client.window.settings.About; - - -import com.stream_pi.client.info.License; -import javafx.scene.control.TextArea; - -public class LicenseTab extends TextArea -{ - public LicenseTab() - { - setText(License.getLicense()); - getStyleClass().add("about_license_text_area"); - setWrapText(false); - setEditable(false); - } -} +package com.stream_pi.client.window.settings.About; + + +import com.stream_pi.client.info.License; +import javafx.scene.control.TextArea; + +public class LicenseTab extends TextArea +{ + public LicenseTab() + { + setText(License.getLicense()); + getStyleClass().add("about_license_text_area"); + setWrapText(false); + setEditable(false); + } +} diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java index a5a8f3b7..5100fd89 100755 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -1,788 +1,743 @@ -package com.stream_pi.client.window.settings; - -import com.gluonhq.attach.vibration.VibrationService; -import com.stream_pi.client.Main; -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.window.ExceptionAndAlertHandler; -import com.stream_pi.theme_api.Theme; -import com.stream_pi.util.alert.StreamPiAlert; -import com.stream_pi.util.alert.StreamPiAlertListener; -import com.stream_pi.util.alert.StreamPiAlertType; -import com.stream_pi.util.checkforupdates.CheckForUpdates; -import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick; -import com.stream_pi.util.combobox.StreamPiComboBox; -import com.stream_pi.util.combobox.StreamPiComboBoxFactory; -import com.stream_pi.util.combobox.StreamPiComboBoxListener; -import com.stream_pi.util.exception.MinorException; -import com.stream_pi.util.exception.SevereException; -import com.stream_pi.util.platform.PlatformType; -import com.stream_pi.util.startatboot.StartAtBoot; -import com.stream_pi.util.uihelper.HBoxInputBox; -import com.stream_pi.util.uihelper.HBoxWithSpaceBetween; -import com.stream_pi.util.uihelper.SpaceFiller; -import javafx.application.HostServices; -import javafx.event.ActionEvent; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.*; -import javafx.scene.layout.HBox; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; -import java.util.Arrays; -import java.util.List; -import org.controlsfx.control.ToggleSwitch; - -import java.io.File; -import java.net.URISyntaxException; -import java.util.logging.Logger; - -public class GeneralTab extends VBox -{ - private ExceptionAndAlertHandler exceptionAndAlertHandler; - private ClientListener clientListener; - private HostServices hostServices; - - private TextField serverPortTextField; - private TextField serverHostNameOrIPTextField; - - private TextField screenTimeoutTextField; - - private StreamPiComboBox clientProfileComboBox; - private StreamPiComboBox themeComboBox; - private StreamPiComboBox animationComboBox; - - private TextField nickNameTextField; - - private Button saveButton; - private Button connectDisconnectButton; - private Button shutdownButton; - - private HBoxWithSpaceBetween startOnBootHBox; - private ToggleSwitch startOnBootToggleSwitch; - - private HBoxWithSpaceBetween screenSaverHBox; - private ToggleSwitch screenSaverToggleSwitch; - - private HBoxWithSpaceBetween screenMoverHBox; - private ToggleSwitch screenMoverToggleSwitch; - - private HBoxWithSpaceBetween tryConnectingToServerIfActionClickedHBox; - private ToggleSwitch tryConnectingToServerIfActionClickedToggleSwitch; - - private HBoxWithSpaceBetween connectOnStartupHBox; - private ToggleSwitch connectOnStartupToggleSwitch; - - private HBoxWithSpaceBetween vibrateOnActionPressHBox; - private ToggleSwitch vibrateOnActionPressToggleSwitch; - - private HBoxWithSpaceBetween fullScreenModeHBox; - private ToggleSwitch fullScreenModeToggleSwitch; - - private HBoxWithSpaceBetween showCursorHBox; - private ToggleSwitch showCursorToggleSwitch; - - private HBoxWithSpaceBetween invertRowsColsHBox; - private ToggleSwitch invertRowsColsToggleSwitch; - - private TextField themesPathTextField; - private TextField iconsPathTextField; - private TextField profilesPathTextField; - - private final Button factoryResetButton; - - private Logger logger; - - - private final Button checkForUpdatesButton; - - private HBoxInputBox screenTimeoutSecondsHBoxInputBox; - - private List animationList; - - public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler, - ClientListener clientListener, HostServices hostServices) - { - animationList = Arrays.asList("None", "Bounce", "Bounce In/Out", "Fade In/Out", "Flash", "Flip", "Jack In The Box", "Jello", "Pulse", "Roll In/Out", "Rotate In/Out", "RubberBand", "Shake Left/Right", "Shake Up/Down","Swing", "Tada", "Wobble", "Zoom In/Out"); - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.clientListener = clientListener; - this.hostServices = hostServices; - - logger = Logger.getLogger(""); - - serverPortTextField = new TextField(); - screenTimeoutTextField = new TextField(); - - - serverHostNameOrIPTextField = new TextField(); - nickNameTextField = new TextField(); - - clientProfileComboBox = new StreamPiComboBox<>(); - - clientProfileComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() - { - @Override - public String getOptionDisplayText(ClientProfile object) - { - return object.getName(); - } - }); - animationComboBox = new StreamPiComboBox(); - - animationComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() - { - @Override - public String getOptionDisplayText(String object) - { - return object; - } - }); - - - clientProfileComboBox.setStreamPiComboBoxListener(new StreamPiComboBoxListener(){ - @Override - public void onNewItemSelected(ClientProfile selectedItem) - { - clientListener.renderProfile(selectedItem, true); - } - }); - - - themeComboBox = new StreamPiComboBox<>(); - themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() - { - @Override - public String getOptionDisplayText(Theme object) - { - return object.getShortName(); - } - }); - - themesPathTextField = new TextField(); - iconsPathTextField = new TextField(); - profilesPathTextField = new TextField(); - - startOnBootToggleSwitch = new ToggleSwitch(); - startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", startOnBootToggleSwitch); - startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty()); - - screenSaverToggleSwitch = new ToggleSwitch(); - screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", screenSaverToggleSwitch); - screenSaverHBox.managedProperty().bind(screenSaverHBox.visibleProperty()); - - screenMoverToggleSwitch = new ToggleSwitch(); - screenMoverHBox = new HBoxWithSpaceBetween("OLED Burn-In Protector", screenMoverToggleSwitch); - screenMoverHBox.managedProperty().bind(screenMoverHBox.visibleProperty()); - - tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch(); - tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", tryConnectingToServerIfActionClickedToggleSwitch); - tryConnectingToServerIfActionClickedHBox.managedProperty().bind(tryConnectingToServerIfActionClickedHBox.visibleProperty()); - - fullScreenModeToggleSwitch = new ToggleSwitch(); - fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", fullScreenModeToggleSwitch); - fullScreenModeHBox.managedProperty().bind(fullScreenModeHBox.visibleProperty()); - - vibrateOnActionPressToggleSwitch = new ToggleSwitch(); - vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", vibrateOnActionPressToggleSwitch); - vibrateOnActionPressHBox.managedProperty().bind(vibrateOnActionPressHBox.visibleProperty()); - - connectOnStartupToggleSwitch = new ToggleSwitch(); - connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", connectOnStartupToggleSwitch); - connectOnStartupHBox.managedProperty().bind(connectOnStartupHBox.visibleProperty()); - - showCursorToggleSwitch = new ToggleSwitch(); - showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", showCursorToggleSwitch); - showCursorHBox.managedProperty().bind(showCursorHBox.visibleProperty()); - - invertRowsColsToggleSwitch = new ToggleSwitch(); - invertRowsColsHBox = new HBoxWithSpaceBetween("Invert Grid on Rotate", invertRowsColsToggleSwitch); - invertRowsColsHBox.managedProperty().bind(invertRowsColsHBox.visibleProperty()); - - int prefWidth = 200; - - HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", themesPathTextField, prefWidth); - themesPathInputBox.managedProperty().bind(themesPathInputBox.visibleProperty()); - - - HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", iconsPathTextField, prefWidth); - iconsPathInputBox.managedProperty().bind(iconsPathInputBox.visibleProperty()); - - - HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", profilesPathTextField, prefWidth); - profilesPathInputBox.managedProperty().bind(profilesPathInputBox.visibleProperty()); - - checkForUpdatesButton = new Button("Check for updates"); - checkForUpdatesButton.setOnAction(event->checkForUpdates()); - - factoryResetButton = new Button("Factory Reset"); - factoryResetButton.setOnAction(actionEvent -> onFactoryResetButtonClicked()); - - - screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", screenTimeoutTextField, prefWidth); - screenTimeoutSecondsHBoxInputBox.managedProperty().bind(screenTimeoutSecondsHBoxInputBox.visibleProperty()); - screenTimeoutTextField.disableProperty().bind(screenSaverToggleSwitch.selectedProperty().not()); - - saveButton = new Button("Save"); - saveButton.setOnAction(event->onSaveButtonClicked()); - - connectDisconnectButton = new Button("Connect"); - connectDisconnectButton.setOnAction(event -> onConnectDisconnectButtonClicked()); - - - Button exitButton = new Button("Exit"); - exitButton.setOnAction(event -> onExitButtonClicked()); - - HBox buttonBar = new HBox(connectDisconnectButton, saveButton); - - shutdownButton = new Button("Shutdown"); - shutdownButton.managedProperty().bind(shutdownButton.visibleProperty()); - shutdownButton.setOnAction(event -> onShutdownButtonClicked()); - - - VBox vBox = new VBox( - generateSubHeading("Connection"), - new HBoxInputBox("Device Name", nickNameTextField, prefWidth), - new HBoxInputBox("Host Name/IP", serverHostNameOrIPTextField, prefWidth), - new HBoxInputBox("Port", serverPortTextField, prefWidth), - generateSubHeading("Client"), - new HBox( - new Label("Current profile"), - SpaceFiller.horizontal(), - clientProfileComboBox - ), - new HBox( - new Label("Theme"), - SpaceFiller.horizontal(), - themeComboBox - ), - new HBox( - new Label("Action Animation"), - SpaceFiller.horizontal(), - animationComboBox - ), - generateSubHeading("Others"), - themesPathInputBox, - iconsPathInputBox, - profilesPathInputBox, - screenTimeoutSecondsHBoxInputBox, - invertRowsColsHBox, - screenSaverHBox, - screenMoverHBox, - tryConnectingToServerIfActionClickedHBox, - fullScreenModeHBox, - connectOnStartupHBox, - vibrateOnActionPressHBox, - startOnBootHBox, - showCursorHBox, - checkForUpdatesButton, - shutdownButton, - factoryResetButton - ); - - - vBox.getStyleClass().add("settings_base_vbox"); - - vBox.setSpacing(10.0); - vBox.setPadding(new Insets(5)); - - ScrollPane scrollPane = new ScrollPane(); - scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); - VBox.setVgrow(scrollPane, Priority.ALWAYS); - scrollPane.getStyleClass().add("settings_base_scroll_pane"); - scrollPane.setContent(vBox); - - vBox.setMinWidth(300); - - vBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(30)); - - - buttonBar.getStyleClass().add("settings_button_bar"); - - - buttonBar.setPadding(new Insets(0,5,5,0)); - buttonBar.setSpacing(5.0); - buttonBar.setAlignment(Pos.CENTER_RIGHT); - - setSpacing(10.0); - - getChildren().addAll( - scrollPane, - buttonBar - ); - - setCache(true); - setCacheHint(CacheHint.SPEED); - - - //Perform platform checks - - if(ClientInfo.getInstance().isPhone()) - { - themesPathInputBox.setVisible(false); - iconsPathInputBox.setVisible(false); - profilesPathInputBox.setVisible(false); - - startOnBootHBox.setVisible(false); - showCursorHBox.setVisible(false); - fullScreenModeHBox.setVisible(false); - shutdownButton.setVisible(false); - } - else - { - invertRowsColsHBox.setVisible(false); - vibrateOnActionPressHBox.setVisible(false); - buttonBar.getChildren().add(exitButton); - - - fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON); - - shutdownButton.setVisible(StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON); - } - - - screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); - screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); - } - - private Label generateSubHeading(String text) - { - Label label = new Label(text); - label.getStyleClass().add("general_settings_sub_heading"); - return label; - } - - private Logger getLogger() - { - return logger; - } - - private void checkForUpdates() - { - new CheckForUpdates(checkForUpdatesButton, - PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() { - @Override - public void handle(ActionEvent actionEvent) { - if(ClientInfo.getInstance().isPhone()) - { - clientListener.openURL(getURL()); - } - else - { - hostServices.showDocument(getURL()); - } - } - }); - } - - private void onFactoryResetButtonClicked() - { - StreamPiAlert confirmation = new StreamPiAlert("Warning","Are you sure?\n" + - "This will erase everything.",StreamPiAlertType.WARNING); - - String yesButton = "Yes"; - String noButton = "No"; - - confirmation.setButtons(yesButton, noButton); - - confirmation.setOnClicked(new StreamPiAlertListener() { - @Override - public void onClick(String s) { - if(s.equals(yesButton)) - { - clientListener.factoryReset(); - } - } - }); - - confirmation.show(); - } - - - public void onExitButtonClicked() - { - clientListener.onCloseRequest(); - clientListener.exitApp(); - } - - public void setDisableStatus(boolean status) - { - saveButton.setDisable(status); - connectDisconnectButton.setDisable(status); - } - - public Button getConnectDisconnectButton() - { - return connectDisconnectButton; - } - - public void onShutdownButtonClicked() - { - clientListener.onCloseRequest(); - - try - { - Runtime.getRuntime().exec("sudo halt"); - } - catch (Exception e) - { - e.printStackTrace(); - } - } - - public void onConnectDisconnectButtonClicked() - { - try - { - if(clientListener.isConnected()) - clientListener.disconnect("Client disconnected from settings"); - else - clientListener.setupClientConnection(); - } - catch (SevereException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(e); - } - } - - public void setConnectDisconnectButtonStatus() - { - javafx.application.Platform.runLater(()->{ - setDisableStatus(false); - - if(clientListener.isConnected()) - connectDisconnectButton.setText("Disconnect"); - else - connectDisconnectButton.setText("Connect"); - }); - - } - - public void loadData() throws SevereException - { - Config config = Config.getInstance(); - - nickNameTextField.setText(config.getClientNickName()); - - serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP()); - serverPortTextField.setText(config.getSavedServerPort()+""); - - screenTimeoutTextField.setText(config.getScreenSaverTimeout()+""); - screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); - screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); - animationComboBox.setOptions(animationList); - clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles()); - - int ind = 0; - for(int i = 0;i 65535) - errors.append("* Server Port must be lesser than 65535\n"); - } - catch (NumberFormatException exception) - { - errors.append("* Server Port should be a number.\n"); - } - - - int screenSaverTimeout = -1; - try - { - screenSaverTimeout = Integer.parseInt(serverPortTextField.getText()); - - if(screenSaverTimeout < 15) - errors.append("* Screen Timeout cannot be below 15 seconds.\n"); - } - catch (NumberFormatException exception) - { - errors.append("* Screen Timeout should be a number.\n"); - } - - - if(serverHostNameOrIPTextField.getText().isBlank()) - { - errors.append("* Server IP cannot be empty.\n"); - } - - if(nickNameTextField.getText().isBlank()) - { - errors.append("* Nick name cannot be blank.\n"); - } - else - { - if(nickNameTextField.getText().equals("about maker")) - { - new StreamPiAlert("किसने बनाया ? / কে বানিয়েছে ?","ZGViYXlhbiAtIGluZGlh\n" + - "boka XD").show(); - } - - if(nickNameTextField.getText().equals("quimo is pog")) - { - new StreamPiAlert("wow! i am very cool! i found an easter egg made by quimo!\n" + - "good job").show(); - } - } - - - if(!errors.toString().isEmpty()) - { - exceptionAndAlertHandler.handleMinorException(new MinorException( - "You made mistakes", - "Please fix the errors and try again :\n"+errors.toString() - )); - return; - } - - - - try - { - boolean toBeReloaded = false; - - boolean syncWithServer = false; - - Config config = Config.getInstance(); - - if(!config.getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName())) - { - syncWithServer = true; - - try - { - config.setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName()); - config.save(); - clientListener.initThemes(); - } - catch(SevereException e) - { - exceptionAndAlertHandler.handleSevereException(e); - } - } - - if (!config.getCurrentAnimationName().equals(animationComboBox.getCurrentSelectedItem())) - { - syncWithServer = true; - - config.setCurrentAnimationName(animationComboBox.getCurrentSelectedItem()); - } - - if(!config.getClientNickName().equals(nickNameTextField.getText())) - { - syncWithServer = true; - } - - config.setNickName(nickNameTextField.getText()); - - if(port != config.getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP())) - { - syncWithServer = true; - } - - config.setServerPort(port); - config.setServerHostNameOrIP(serverHostNameOrIPTextField.getText()); - - boolean isFullScreen = fullScreenModeToggleSwitch.isSelected(); - - if(config.getIsFullScreenMode() != isFullScreen) - { - toBeReloaded = true; - } - - config.setIsFullScreenMode(isFullScreen); - - - - config.setTryConnectingWhenActionClicked(tryConnectingToServerIfActionClickedToggleSwitch.isSelected()); - - - - boolean startOnBoot = startOnBootToggleSwitch.isSelected(); - - if(config.isStartOnBoot() != startOnBoot) - { - StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), - Main.class.getProtectionDomain().getCodeSource().getLocation(), - StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); - - if(startOnBoot) - { - try - { - startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); - config.setStartupIsXMode(StartupFlags.IS_X_MODE); - } - catch (MinorException e) - { - exceptionAndAlertHandler.handleMinorException(e); - startOnBoot = false; - } - } - else - { - boolean result = startAtBoot.delete(); - if(!result) - new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show(); - } - } - - config.setStartOnBoot(startOnBoot); - - if(!config.isShowCursor() ==showCursorToggleSwitch.isSelected()) - toBeReloaded = true; - - config.setShowCursor(showCursorToggleSwitch.isSelected()); - - - if(!config.getThemesPath().equals(themesPathTextField.getText())) - toBeReloaded = true; - - config.setThemesPath(themesPathTextField.getText()); - - - if(!config.getIconsPath().equals(iconsPathTextField.getText())) - toBeReloaded = true; - - config.setIconsPath(iconsPathTextField.getText()); - - if(!config.getProfilesPath().equals(profilesPathTextField.getText())) - toBeReloaded = true; - - config.setProfilesPath(profilesPathTextField.getText()); - - if(config.isScreenSaverEnabled() != screenSaverToggleSwitch.isSelected()) - toBeReloaded = true; - - config.setScreenSaverEnabled(screenSaverToggleSwitch.isSelected()); - - if(config.isScreenMoverEnabled() != screenMoverToggleSwitch.isSelected()) - toBeReloaded = true; - - config.setScreenMoverEnabled(screenMoverToggleSwitch.isSelected()); - - if(!(screenSaverTimeout+"").equals(screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) - { - config.setScreenSaverTimeout(screenTimeoutTextField.getText()); - - clientListener.getScreenSaver().setTimeout(config.getScreenSaverTimeout()); - clientListener.getScreenSaver().restartTimer(); - } - - - config.setConnectOnStartup(connectOnStartupToggleSwitch.isSelected()); - - boolean isVibrateOnActionClicked = vibrateOnActionPressToggleSwitch.isSelected(); - - if(config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked) - { - if(VibrationService.create().isEmpty()) - { - isVibrateOnActionClicked = false; - new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show(); - } - } - - config.setVibrateOnActionClicked(isVibrateOnActionClicked); - config.setInvertRowsColsOnDeviceRotate(invertRowsColsToggleSwitch.isSelected()); - - config.save(); - - loadData(); - - - if(syncWithServer) - { - if(clientListener.isConnected()) - { - clientListener.getClient().updateClientDetails(); - } - } - - if(toBeReloaded) - { - if(!ClientInfo.getInstance().isPhone() && !config.getIsFullScreenMode()) - { - config.setStartupWindowSize(clientListener.getStageWidth(), clientListener.getStageHeight()); - config.save(); - } - - clientListener.init(); - clientListener.renderRootDefaultProfile(); - } - } - catch (SevereException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleSevereException(e); - } - catch (MinorException e) - { - e.printStackTrace(); - exceptionAndAlertHandler.handleMinorException(e); - } - } - -} +package com.stream_pi.client.window.settings; + +import com.gluonhq.attach.vibration.VibrationService; +import com.stream_pi.client.Main; +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.window.ExceptionAndAlertHandler; +import com.stream_pi.theme_api.Theme; +import com.stream_pi.util.alert.StreamPiAlert; +import com.stream_pi.util.alert.StreamPiAlertListener; +import com.stream_pi.util.alert.StreamPiAlertType; +import com.stream_pi.util.checkforupdates.CheckForUpdates; +import com.stream_pi.util.checkforupdates.UpdateHyperlinkOnClick; +import com.stream_pi.util.combobox.StreamPiComboBox; +import com.stream_pi.util.combobox.StreamPiComboBoxFactory; +import com.stream_pi.util.combobox.StreamPiComboBoxListener; +import com.stream_pi.util.exception.MinorException; +import com.stream_pi.util.exception.SevereException; +import com.stream_pi.util.platform.Platform; +import com.stream_pi.util.platform.PlatformType; +import com.stream_pi.util.startatboot.StartAtBoot; +import com.stream_pi.util.uihelper.HBoxInputBox; +import com.stream_pi.util.uihelper.HBoxWithSpaceBetween; +import com.stream_pi.util.uihelper.SpaceFiller; +import javafx.application.HostServices; +import javafx.event.ActionEvent; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.*; +import javafx.scene.layout.HBox; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; +import org.controlsfx.control.ToggleSwitch; + +import java.io.File; +import java.net.URISyntaxException; +import java.util.logging.Logger; + +public class GeneralTab extends VBox +{ + private ExceptionAndAlertHandler exceptionAndAlertHandler; + private ClientListener clientListener; + private HostServices hostServices; + + private TextField serverPortTextField; + private TextField serverHostNameOrIPTextField; + + private TextField screenTimeoutTextField; + + private StreamPiComboBox clientProfileComboBox; + private StreamPiComboBox themeComboBox; + + private TextField nickNameTextField; + + private Button saveButton; + private Button connectDisconnectButton; + private Button shutdownButton; + + private HBoxWithSpaceBetween startOnBootHBox; + private ToggleSwitch startOnBootToggleSwitch; + + private HBoxWithSpaceBetween screenSaverHBox; + private ToggleSwitch screenSaverToggleSwitch; + + private HBoxWithSpaceBetween screenMoverHBox; + private ToggleSwitch screenMoverToggleSwitch; + + private HBoxWithSpaceBetween tryConnectingToServerIfActionClickedHBox; + private ToggleSwitch tryConnectingToServerIfActionClickedToggleSwitch; + + private HBoxWithSpaceBetween connectOnStartupHBox; + private ToggleSwitch connectOnStartupToggleSwitch; + + private HBoxWithSpaceBetween vibrateOnActionPressHBox; + private ToggleSwitch vibrateOnActionPressToggleSwitch; + + private HBoxWithSpaceBetween fullScreenModeHBox; + private ToggleSwitch fullScreenModeToggleSwitch; + + private HBoxWithSpaceBetween showCursorHBox; + private ToggleSwitch showCursorToggleSwitch; + + private HBoxWithSpaceBetween invertRowsColsHBox; + private ToggleSwitch invertRowsColsToggleSwitch; + + private TextField themesPathTextField; + private TextField iconsPathTextField; + private TextField profilesPathTextField; + + private final Button factoryResetButton; + + private Logger logger; + + + private final Button checkForUpdatesButton; + + private HBoxInputBox screenTimeoutSecondsHBoxInputBox; + + public GeneralTab(ExceptionAndAlertHandler exceptionAndAlertHandler, + ClientListener clientListener, HostServices hostServices) + { + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.clientListener = clientListener; + this.hostServices = hostServices; + + logger = Logger.getLogger(""); + + serverPortTextField = new TextField(); + screenTimeoutTextField = new TextField(); + + + serverHostNameOrIPTextField = new TextField(); + nickNameTextField = new TextField(); + + clientProfileComboBox = new StreamPiComboBox<>(); + + clientProfileComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(ClientProfile object) + { + return object.getName(); + } + }); + + clientProfileComboBox.setStreamPiComboBoxListener(new StreamPiComboBoxListener(){ + @Override + public void onNewItemSelected(ClientProfile selectedItem) + { + clientListener.renderProfile(selectedItem, true); + } + }); + + + themeComboBox = new StreamPiComboBox<>(); + themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(Theme object) + { + return object.getShortName(); + } + }); + + themesPathTextField = new TextField(); + iconsPathTextField = new TextField(); + profilesPathTextField = new TextField(); + + startOnBootToggleSwitch = new ToggleSwitch(); + startOnBootHBox = new HBoxWithSpaceBetween("Start On Boot", startOnBootToggleSwitch); + startOnBootHBox.managedProperty().bind(startOnBootHBox.visibleProperty()); + + screenSaverToggleSwitch = new ToggleSwitch(); + screenSaverHBox = new HBoxWithSpaceBetween("Screen Saver", screenSaverToggleSwitch); + screenSaverHBox.managedProperty().bind(screenSaverHBox.visibleProperty()); + + screenMoverToggleSwitch = new ToggleSwitch(); + screenMoverHBox = new HBoxWithSpaceBetween("OLED Burn-In Protector", screenMoverToggleSwitch); + screenMoverHBox.managedProperty().bind(screenMoverHBox.visibleProperty()); + + tryConnectingToServerIfActionClickedToggleSwitch = new ToggleSwitch(); + tryConnectingToServerIfActionClickedHBox = new HBoxWithSpaceBetween("Try connect to server on action click", tryConnectingToServerIfActionClickedToggleSwitch); + tryConnectingToServerIfActionClickedHBox.managedProperty().bind(tryConnectingToServerIfActionClickedHBox.visibleProperty()); + + fullScreenModeToggleSwitch = new ToggleSwitch(); + fullScreenModeHBox = new HBoxWithSpaceBetween("Full Screen", fullScreenModeToggleSwitch); + fullScreenModeHBox.managedProperty().bind(fullScreenModeHBox.visibleProperty()); + + vibrateOnActionPressToggleSwitch = new ToggleSwitch(); + vibrateOnActionPressHBox = new HBoxWithSpaceBetween("Vibrate On Action Press", vibrateOnActionPressToggleSwitch); + vibrateOnActionPressHBox.managedProperty().bind(vibrateOnActionPressHBox.visibleProperty()); + + connectOnStartupToggleSwitch = new ToggleSwitch(); + connectOnStartupHBox = new HBoxWithSpaceBetween("Connect On Startup", connectOnStartupToggleSwitch); + connectOnStartupHBox.managedProperty().bind(connectOnStartupHBox.visibleProperty()); + + showCursorToggleSwitch = new ToggleSwitch(); + showCursorHBox = new HBoxWithSpaceBetween("Show Cursor", showCursorToggleSwitch); + showCursorHBox.managedProperty().bind(showCursorHBox.visibleProperty()); + + invertRowsColsToggleSwitch = new ToggleSwitch(); + invertRowsColsHBox = new HBoxWithSpaceBetween("Invert Grid on Rotate", invertRowsColsToggleSwitch); + invertRowsColsHBox.managedProperty().bind(invertRowsColsHBox.visibleProperty()); + + int prefWidth = 200; + + HBoxInputBox themesPathInputBox = new HBoxInputBox("Themes Path", themesPathTextField, prefWidth); + themesPathInputBox.managedProperty().bind(themesPathInputBox.visibleProperty()); + + + HBoxInputBox iconsPathInputBox = new HBoxInputBox("Icons Path", iconsPathTextField, prefWidth); + iconsPathInputBox.managedProperty().bind(iconsPathInputBox.visibleProperty()); + + + HBoxInputBox profilesPathInputBox = new HBoxInputBox("Profiles Path", profilesPathTextField, prefWidth); + profilesPathInputBox.managedProperty().bind(profilesPathInputBox.visibleProperty()); + + checkForUpdatesButton = new Button("Check for updates"); + checkForUpdatesButton.setOnAction(event->checkForUpdates()); + + factoryResetButton = new Button("Factory Reset"); + factoryResetButton.setOnAction(actionEvent -> onFactoryResetButtonClicked()); + + + screenTimeoutSecondsHBoxInputBox = new HBoxInputBox("Screen Timeout (seconds)", screenTimeoutTextField, prefWidth); + screenTimeoutSecondsHBoxInputBox.managedProperty().bind(screenTimeoutSecondsHBoxInputBox.visibleProperty()); + screenTimeoutTextField.disableProperty().bind(screenSaverToggleSwitch.selectedProperty().not()); + + saveButton = new Button("Save"); + saveButton.setOnAction(event->onSaveButtonClicked()); + + connectDisconnectButton = new Button("Connect"); + connectDisconnectButton.setOnAction(event -> onConnectDisconnectButtonClicked()); + + + Button exitButton = new Button("Exit"); + exitButton.setOnAction(event -> onExitButtonClicked()); + + HBox buttonBar = new HBox(connectDisconnectButton, saveButton); + + shutdownButton = new Button("Shutdown"); + shutdownButton.managedProperty().bind(shutdownButton.visibleProperty()); + shutdownButton.setOnAction(event -> onShutdownButtonClicked()); + + + VBox vBox = new VBox( + generateSubHeading("Connection"), + new HBoxInputBox("Device Name", nickNameTextField, prefWidth), + new HBoxInputBox("Host Name/IP", serverHostNameOrIPTextField, prefWidth), + new HBoxInputBox("Port", serverPortTextField, prefWidth), + generateSubHeading("Client"), + new HBox( + new Label("Current profile"), + SpaceFiller.horizontal(), + clientProfileComboBox + ), + new HBox( + new Label("Theme"), + SpaceFiller.horizontal(), + themeComboBox + ), + generateSubHeading("Others"), + themesPathInputBox, + iconsPathInputBox, + profilesPathInputBox, + screenTimeoutSecondsHBoxInputBox, + invertRowsColsHBox, + screenSaverHBox, + screenMoverHBox, + tryConnectingToServerIfActionClickedHBox, + fullScreenModeHBox, + connectOnStartupHBox, + vibrateOnActionPressHBox, + startOnBootHBox, + showCursorHBox, + checkForUpdatesButton, + shutdownButton, + factoryResetButton + ); + + + vBox.getStyleClass().add("settings_base_vbox"); + + vBox.setSpacing(10.0); + vBox.setPadding(new Insets(5)); + + ScrollPane scrollPane = new ScrollPane(); + scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.AS_NEEDED); + VBox.setVgrow(scrollPane, Priority.ALWAYS); + scrollPane.getStyleClass().add("settings_base_scroll_pane"); + scrollPane.setContent(vBox); + + vBox.setMinWidth(300); + + vBox.prefWidthProperty().bind(scrollPane.widthProperty().subtract(30)); + + + buttonBar.getStyleClass().add("settings_button_bar"); + + + buttonBar.setPadding(new Insets(0,5,5,0)); + buttonBar.setSpacing(5.0); + buttonBar.setAlignment(Pos.CENTER_RIGHT); + + setSpacing(10.0); + + getChildren().addAll( + scrollPane, + buttonBar + ); + + setCache(true); + setCacheHint(CacheHint.SPEED); + + + //Perform platform checks + + if(ClientInfo.getInstance().isPhone()) + { + themesPathInputBox.setVisible(false); + iconsPathInputBox.setVisible(false); + profilesPathInputBox.setVisible(false); + + startOnBootHBox.setVisible(false); + showCursorHBox.setVisible(false); + fullScreenModeHBox.setVisible(false); + shutdownButton.setVisible(false); + } + else + { + invertRowsColsHBox.setVisible(false); + vibrateOnActionPressHBox.setVisible(false); + buttonBar.getChildren().add(exitButton); + + + fullScreenModeHBox.setVisible(StartupFlags.SHOW_FULLSCREEN_TOGGLE_BUTTON); + + shutdownButton.setVisible(StartupFlags.IS_SHOW_SHUT_DOWN_BUTTON); + } + + + screenSaverHBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); + screenTimeoutSecondsHBoxInputBox.setVisible(StartupFlags.SCREEN_SAVER_FEATURE); + } + + private Label generateSubHeading(String text) + { + Label label = new Label(text); + label.getStyleClass().add("general_settings_sub_heading"); + return label; + } + + private Logger getLogger() + { + return logger; + } + + private void checkForUpdates() + { + new CheckForUpdates(checkForUpdatesButton, + PlatformType.CLIENT, ClientInfo.getInstance().getVersion(), new UpdateHyperlinkOnClick() { + @Override + public void handle(ActionEvent actionEvent) { + if(ClientInfo.getInstance().isPhone()) + { + clientListener.openURL(getURL()); + } + else + { + hostServices.showDocument(getURL()); + } + } + }); + } + + private void onFactoryResetButtonClicked() + { + StreamPiAlert confirmation = new StreamPiAlert("Warning","Are you sure?\n" + + "This will erase everything.",StreamPiAlertType.WARNING); + + String yesButton = "Yes"; + String noButton = "No"; + + confirmation.setButtons(yesButton, noButton); + + confirmation.setOnClicked(new StreamPiAlertListener() { + @Override + public void onClick(String s) { + if(s.equals(yesButton)) + { + clientListener.factoryReset(); + } + } + }); + + confirmation.show(); + } + + + public void onExitButtonClicked() + { + clientListener.onCloseRequest(); + clientListener.exitApp(); + } + + public void setDisableStatus(boolean status) + { + saveButton.setDisable(status); + connectDisconnectButton.setDisable(status); + } + + public Button getConnectDisconnectButton() + { + return connectDisconnectButton; + } + + public void onShutdownButtonClicked() + { + clientListener.onCloseRequest(); + + try + { + Runtime.getRuntime().exec("sudo halt"); + } + catch (Exception e) + { + e.printStackTrace(); + } + } + + public void onConnectDisconnectButtonClicked() + { + try + { + if(clientListener.isConnected()) + clientListener.disconnect("Client disconnected from settings"); + else + clientListener.setupClientConnection(); + } + catch (SevereException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleSevereException(e); + } + } + + public void setConnectDisconnectButtonStatus() + { + javafx.application.Platform.runLater(()->{ + setDisableStatus(false); + + if(clientListener.isConnected()) + connectDisconnectButton.setText("Disconnect"); + else + connectDisconnectButton.setText("Connect"); + }); + + } + + public void loadData() throws SevereException + { + Config config = Config.getInstance(); + + nickNameTextField.setText(config.getClientNickName()); + + serverHostNameOrIPTextField.setText(config.getSavedServerHostNameOrIP()); + serverPortTextField.setText(config.getSavedServerPort()+""); + + screenTimeoutTextField.setText(config.getScreenSaverTimeout()+""); + screenSaverToggleSwitch.setSelected(config.isScreenSaverEnabled()); + screenMoverToggleSwitch.setSelected(config.isScreenMoverEnabled()); + + clientProfileComboBox.setOptions(clientListener.getClientProfiles().getClientProfiles()); + + int ind = 0; + for(int i = 0;i 65535) + errors.append("* Server Port must be lesser than 65535\n"); + } + catch (NumberFormatException exception) + { + errors.append("* Server Port should be a number.\n"); + } + + + int screenSaverTimeout = -1; + try + { + screenSaverTimeout = Integer.parseInt(serverPortTextField.getText()); + + if(screenSaverTimeout < 15) + errors.append("* Screen Timeout cannot be below 15 seconds.\n"); + } + catch (NumberFormatException exception) + { + errors.append("* Screen Timeout should be a number.\n"); + } + + + if(serverHostNameOrIPTextField.getText().isBlank()) + { + errors.append("* Server IP cannot be empty.\n"); + } + + if(nickNameTextField.getText().isBlank()) + { + errors.append("* Nick name cannot be blank.\n"); + } + else + { + if(nickNameTextField.getText().equals("about maker")) + { + new StreamPiAlert("किसने बनाया ? / কে বানিয়েছে ?","ZGViYXlhbiAtIGluZGlh\n" + + "boka XD").show(); + } + } + + + if(!errors.toString().isEmpty()) + { + exceptionAndAlertHandler.handleMinorException(new MinorException( + "You made mistakes", + "Please fix the errors and try again :\n"+errors.toString() + )); + return; + } + + + + try + { + boolean toBeReloaded = false; + + boolean syncWithServer = false; + + Config config = Config.getInstance(); + + if(!config.getCurrentThemeFullName().equals(themeComboBox.getCurrentSelectedItem().getFullName())) + { + syncWithServer = true; + + try + { + config.setCurrentThemeFullName(themeComboBox.getCurrentSelectedItem().getFullName()); + config.save(); + clientListener.initThemes(); + } + catch(SevereException e) + { + exceptionAndAlertHandler.handleSevereException(e); + } + } + + if(!config.getClientNickName().equals(nickNameTextField.getText())) + { + syncWithServer = true; + } + + config.setNickName(nickNameTextField.getText()); + + if(port != config.getSavedServerPort() || !serverHostNameOrIPTextField.getText().equals(config.getSavedServerHostNameOrIP())) + { + syncWithServer = true; + } + + config.setServerPort(port); + config.setServerHostNameOrIP(serverHostNameOrIPTextField.getText()); + + boolean isFullScreen = fullScreenModeToggleSwitch.isSelected(); + + if(config.getIsFullScreenMode() != isFullScreen) + { + toBeReloaded = true; + } + + config.setIsFullScreenMode(isFullScreen); + + + + config.setTryConnectingWhenActionClicked(tryConnectingToServerIfActionClickedToggleSwitch.isSelected()); + + + + boolean startOnBoot = startOnBootToggleSwitch.isSelected(); + + if(config.isStartOnBoot() != startOnBoot) + { + StartAtBoot startAtBoot = new StartAtBoot(PlatformType.CLIENT, ClientInfo.getInstance().getPlatform(), + Main.class.getProtectionDomain().getCodeSource().getLocation(), + StartupFlags.APPEND_PATH_BEFORE_RUNNER_FILE_TO_OVERCOME_JPACKAGE_LIMITATION); + + if(startOnBoot) + { + try + { + startAtBoot.create(StartupFlags.RUNNER_FILE_NAME, StartupFlags.IS_X_MODE); + config.setStartupIsXMode(StartupFlags.IS_X_MODE); + } + catch (MinorException e) + { + exceptionAndAlertHandler.handleMinorException(e); + startOnBoot = false; + } + } + else + { + boolean result = startAtBoot.delete(); + if(!result) + new StreamPiAlert("Uh Oh!", "Unable to delete starter file", StreamPiAlertType.ERROR).show(); + } + } + + config.setStartOnBoot(startOnBoot); + + if(!config.isShowCursor() ==showCursorToggleSwitch.isSelected()) + toBeReloaded = true; + + config.setShowCursor(showCursorToggleSwitch.isSelected()); + + + if(!config.getThemesPath().equals(themesPathTextField.getText())) + toBeReloaded = true; + + config.setThemesPath(themesPathTextField.getText()); + + + if(!config.getIconsPath().equals(iconsPathTextField.getText())) + toBeReloaded = true; + + config.setIconsPath(iconsPathTextField.getText()); + + if(!config.getProfilesPath().equals(profilesPathTextField.getText())) + toBeReloaded = true; + + config.setProfilesPath(profilesPathTextField.getText()); + + if(config.isScreenSaverEnabled() != screenSaverToggleSwitch.isSelected()) + toBeReloaded = true; + + config.setScreenSaverEnabled(screenSaverToggleSwitch.isSelected()); + + if(config.isScreenMoverEnabled() != screenMoverToggleSwitch.isSelected()) + toBeReloaded = true; + + config.setScreenMoverEnabled(screenMoverToggleSwitch.isSelected()); + + if(!(screenSaverTimeout+"").equals(screenTimeoutTextField.getText()) && config.isScreenSaverEnabled()) + { + config.setScreenSaverTimeout(screenTimeoutTextField.getText()); + + clientListener.getScreenSaver().setTimeout(config.getScreenSaverTimeout()); + clientListener.getScreenSaver().restartTimer(); + } + + + config.setConnectOnStartup(connectOnStartupToggleSwitch.isSelected()); + + boolean isVibrateOnActionClicked = vibrateOnActionPressToggleSwitch.isSelected(); + + if(config.isVibrateOnActionClicked() != isVibrateOnActionClicked && isVibrateOnActionClicked) + { + if(VibrationService.create().isEmpty()) + { + isVibrateOnActionClicked = false; + new StreamPiAlert("Uh Oh!", "Vibration not supported", StreamPiAlertType.ERROR).show(); + } + } + + config.setVibrateOnActionClicked(isVibrateOnActionClicked); + config.setInvertRowsColsOnDeviceRotate(invertRowsColsToggleSwitch.isSelected()); + + config.save(); + + loadData(); + + + if(syncWithServer) + { + if(clientListener.isConnected()) + { + clientListener.getClient().updateClientDetails(); + } + } + + if(toBeReloaded) + { + if(!ClientInfo.getInstance().isPhone() && !config.getIsFullScreenMode()) + { + config.setStartupWindowSize(clientListener.getStageWidth(), clientListener.getStageHeight()); + config.save(); + } + + clientListener.init(); + clientListener.renderRootDefaultProfile(); + } + } + catch (SevereException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleSevereException(e); + } + catch (MinorException e) + { + e.printStackTrace(); + exceptionAndAlertHandler.handleMinorException(e); + } + } + +} diff --git a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java index 1f6ba834..818461aa 100755 --- a/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java +++ b/src/main/java/com/stream_pi/client/window/settings/SettingsBase.java @@ -1,73 +1,73 @@ -package com.stream_pi.client.window.settings; - -import com.stream_pi.client.controller.ClientListener; -import com.stream_pi.client.window.ExceptionAndAlertHandler; -import com.stream_pi.client.window.settings.About.AboutTab; - -import javafx.application.HostServices; -import javafx.event.Event; -import javafx.geometry.Insets; -import javafx.geometry.Pos; -import javafx.scene.CacheHint; -import javafx.scene.control.*; -import javafx.scene.input.SwipeEvent; -import javafx.scene.layout.Priority; -import javafx.scene.layout.VBox; - -public class SettingsBase extends VBox -{ - private TabPane tabPane; - - private GeneralTab generalTab; - - private Button closeButton; - - private HostServices hostServices; - private ExceptionAndAlertHandler exceptionAndAlertHandler; - - public SettingsBase(HostServices hostServices, ExceptionAndAlertHandler exceptionAndAlertHandler, - ClientListener clientListener) - { - this.exceptionAndAlertHandler = exceptionAndAlertHandler; - this.hostServices = hostServices; - - tabPane = new TabPane(); - tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); - tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); - VBox.setVgrow(tabPane, Priority.ALWAYS); - - Tab generalSettingsTab = new Tab("Settings"); - generalTab = new GeneralTab(exceptionAndAlertHandler, clientListener, hostServices); - generalSettingsTab.setContent(generalTab); - - Tab aboutTab = new Tab("About"); - aboutTab.setContent(new AboutTab(clientListener)); - - tabPane.getTabs().addAll(generalSettingsTab, aboutTab); - - setAlignment(Pos.TOP_RIGHT); - - closeButton = new Button("Close"); - VBox.setMargin(closeButton, new Insets(5.0)); - - getChildren().addAll(tabPane, closeButton); - - setCache(true); - setCacheHint(CacheHint.SPEED); - } - - public void setDefaultTabToGeneral() - { - tabPane.getSelectionModel().selectFirst(); - } - - public Button getCloseButton() - { - return closeButton; - } - - public GeneralTab getGeneralTab() - { - return generalTab; - } -} +package com.stream_pi.client.window.settings; + +import com.stream_pi.client.controller.ClientListener; +import com.stream_pi.client.window.ExceptionAndAlertHandler; +import com.stream_pi.client.window.settings.About.AboutTab; + +import javafx.application.HostServices; +import javafx.event.Event; +import javafx.geometry.Insets; +import javafx.geometry.Pos; +import javafx.scene.CacheHint; +import javafx.scene.control.*; +import javafx.scene.input.SwipeEvent; +import javafx.scene.layout.Priority; +import javafx.scene.layout.VBox; + +public class SettingsBase extends VBox +{ + private TabPane tabPane; + + private GeneralTab generalTab; + + private Button closeButton; + + private HostServices hostServices; + private ExceptionAndAlertHandler exceptionAndAlertHandler; + + public SettingsBase(HostServices hostServices, ExceptionAndAlertHandler exceptionAndAlertHandler, + ClientListener clientListener) + { + this.exceptionAndAlertHandler = exceptionAndAlertHandler; + this.hostServices = hostServices; + + tabPane = new TabPane(); + tabPane.addEventFilter(SwipeEvent.ANY, Event::consume); + tabPane.setTabClosingPolicy(TabPane.TabClosingPolicy.UNAVAILABLE); + VBox.setVgrow(tabPane, Priority.ALWAYS); + + Tab generalSettingsTab = new Tab("Settings"); + generalTab = new GeneralTab(exceptionAndAlertHandler, clientListener, hostServices); + generalSettingsTab.setContent(generalTab); + + Tab aboutTab = new Tab("About"); + aboutTab.setContent(new AboutTab(clientListener)); + + tabPane.getTabs().addAll(generalSettingsTab, aboutTab); + + setAlignment(Pos.TOP_RIGHT); + + closeButton = new Button("Close"); + VBox.setMargin(closeButton, new Insets(5.0)); + + getChildren().addAll(tabPane, closeButton); + + setCache(true); + setCacheHint(CacheHint.SPEED); + } + + public void setDefaultTabToGeneral() + { + tabPane.getSelectionModel().selectFirst(); + } + + public Button getCloseButton() + { + return closeButton; + } + + public GeneralTab getGeneralTab() + { + return generalTab; + } +} diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java index 785d6866..8d7223ec 100755 --- a/src/main/java/module-info.java +++ b/src/main/java/module-info.java @@ -1,30 +1,30 @@ -module com.stream_pi.client { - requires javafx.base; - requires javafx.graphics; - requires javafx.controls; - requires org.kordamp.iconli.core; - requires org.kordamp.ikonli.javafx; - - requires com.gluonhq.attach.lifecycle; - requires com.gluonhq.attach.util; - requires com.gluonhq.attach.storage; - requires com.gluonhq.attach.browser; - requires com.gluonhq.attach.vibration; - requires com.gluonhq.attach.orientation; - - requires java.management; - - requires java.xml; - - opens com.stream_pi.client.window.settings.About to javafx.base; - - requires com.stream_pi.util; - requires com.stream_pi.theme_api; - requires com.stream_pi.action_api; - - requires org.kordamp.ikonli.fontawesome5; - - requires org.controlsfx.controls; - - exports com.stream_pi.client; +module com.stream_pi.client { + requires javafx.base; + requires javafx.graphics; + requires javafx.controls; + requires org.kordamp.iconli.core; + requires org.kordamp.ikonli.javafx; + + requires com.gluonhq.attach.lifecycle; + requires com.gluonhq.attach.util; + requires com.gluonhq.attach.storage; + requires com.gluonhq.attach.browser; + requires com.gluonhq.attach.vibration; + requires com.gluonhq.attach.orientation; + + requires java.management; + + requires java.xml; + + opens com.stream_pi.client.window.settings.About to javafx.base; + + requires com.stream_pi.util; + requires com.stream_pi.theme_api; + requires com.stream_pi.action_api; + + requires org.kordamp.ikonli.fontawesome5; + + requires org.controlsfx.controls; + + exports com.stream_pi.client; } \ No newline at end of file diff --git a/src/main/resources/META-INF/native-image/resource-config.json b/src/main/resources/META-INF/native-image/resource-config.json index ada64776..4d36bca6 100755 --- a/src/main/resources/META-INF/native-image/resource-config.json +++ b/src/main/resources/META-INF/native-image/resource-config.json @@ -1,7 +1,7 @@ -{ - "resources": [ - {"pattern": ".*/Default.zip$"}, - {"pattern": ".*/build-date$"}, - {"pattern": ".*/(EmailBoard|NumericBoard|TextBoard|UriBoard).txt$"} - ] -} +{ + "resources": [ + {"pattern": ".*/Default.zip$"}, + {"pattern": ".*/build-date$"}, + {"pattern": ".*/(EmailBoard|NumericBoard|TextBoard|UriBoard).txt$"} + ] +} diff --git a/src/main/resources/META-INF/native-image/serialization-config.json b/src/main/resources/META-INF/native-image/serialization-config.json index 3eda68ef..e9ed2160 100755 --- a/src/main/resources/META-INF/native-image/serialization-config.json +++ b/src/main/resources/META-INF/native-image/serialization-config.json @@ -1,11 +1,11 @@ -[ - {"name":"com.stream_pi.util.comms.Message"}, - {"name": "java.lang.String"}, - {"name": "java.lang.String[]"}, - {"name": "byte"}, - {"name": "byte[]"}, - {"name": "int"}, - {"name": "int[]"}, - {"name": "double"}, - {"name": "double[]"} +[ + {"name":"com.stream_pi.util.comms.Message"}, + {"name": "java.lang.String"}, + {"name": "java.lang.String[]"}, + {"name": "byte"}, + {"name": "byte[]"}, + {"name": "int"}, + {"name": "int[]"}, + {"name": "double"}, + {"name": "double[]"} ] \ No newline at end of file diff --git a/src/main/resources/com/stream_pi/client/default_icons.css b/src/main/resources/com/stream_pi/client/default_icons.css index e41e344c..c37e4968 100755 --- a/src/main/resources/com/stream_pi/client/default_icons.css +++ b/src/main/resources/com/stream_pi/client/default_icons.css @@ -1,28 +1,28 @@ -.alert_error_icon -{ - -fx-icon-color: RED; -} - -.alert_information_icon -{ - -fx-icon-color: BLUE; -} - -.alert_warning_icon -{ - -fx-icon-color: #ffcc00; -} - -.action_box_error_icon{ - -fx-icon-color:red; -} - -.action_box_toggle_on -{ - -fx-icon-code: fas-toggle-on; -} - -.action_box_toggle_off -{ - -fx-icon-code: fas-toggle-off; +.alert_error_icon +{ + -fx-icon-color: RED; +} + +.alert_information_icon +{ + -fx-icon-color: BLUE; +} + +.alert_warning_icon +{ + -fx-icon-color: #ffcc00; +} + +.action_box_error_icon{ + -fx-icon-color:red; +} + +.action_box_toggle_on +{ + -fx-icon-code: fas-toggle-on; +} + +.action_box_toggle_off +{ + -fx-icon-code: fas-toggle-off; } \ No newline at end of file diff --git a/src/main/resources/com/stream_pi/client/style.css b/src/main/resources/com/stream_pi/client/style.css index 38568d15..ec02a2ca 100755 --- a/src/main/resources/com/stream_pi/client/style.css +++ b/src/main/resources/com/stream_pi/client/style.css @@ -1,220 +1,220 @@ -.root { - -fx-font-family : 'Roboto'; -} - - -.action_box -{ - -fx-border-width: 1px; - -fx-border-color : grey; -} - -.action_box_icon_present -{ - -} - -.action_box_icon_not_present -{ - -} - -.action_box_onclick -{ - -} - -.settings_heading_label -{ - -fx-font-size: 20; -} - -.alert_header -{ - -fx-padding: 5; -} - -.alert_pane -{ - -fx-border-width : 5; - -fx-border-radius : 5; - -fx-background-radius : 5; - -fx-max-width : 400; - -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 ); -} - -.alert_header_icon -{ - -fx-icon-size : 30; -} - -.alert_content_pane -{ - -fx-padding: 5; -} - -.alert_pane_parent, .combobox_pane_parent -{ - -fx-background-color : rgba(0,0,0,0.5); -} - -.alert_pane_header_text -{ - -fx-font-size: 18; -} - -.alert_button_bar -{ - -fx-alignment: CENTER_RIGHT; - -fx-spacing: 5; - -fx-padding: 5; -} - -.alert_scroll_pane -{ - -fx-max-height : 300; -} - - -.combo_box -{ - -fx-alignment:CENTER_LEFT; - -fx-pref-width:200; - -fx-padding: 5; - -fx-border-width : 1; - -fx-border-color : grey; - -fx-border-radius : 5; -} - -.combo_box_popup -{ - -fx-border-width : 5; - -fx-border-radius : 5; - -fx-background-radius : 5; - -fx-max-height : 300; - -fx-max-width : 410; - -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 ); -} - -.combo_box_popup_vbox -{ - -fx-padding: 5 5 0 5; - -fx-spacing:5; -} - -.combo_box_drop_down_icon -{ - -fx-icon-code: fas-caret-down; - -fx-icon-size: 14; -} - -.action_grid_pane_parent -{ - -fx-background-color:transparent; -} - -.first_time_use_pane_heading_label -{ - -fx-font-size: 20; -} - -.first_time_use_pane_stackpane -{ - -} - -.first_time_use_pane_welcome -{ - -} - -.first_time_use_pane_license -{ - -fx-spacing : 10; -} - -.first_time_use_pane_final_config -{ - -} - -.first_time_use_pane_final_config_label -{ - -} - -.first_time_use_welcome_pane_welcome_label -{ - -fx-font-size: 30; -} - -.first_time_use_welcome_pane_next_to_continue_label -{ - -fx-font-size: 15; -} - -.scroll-pane -{ - -fx-focus-color:transparent; - -fx-faint-focus-color:transparent; -} - -/*Alert Classes added to default stylesheet to show init error, if occurs */ -.action_box_display_text_label -{ - -fx-background-color : transparent; - /*-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 5, 0.3, 0.0, 0.0);*/ -} - -.alert_pane -{ - -fx-background-color : white; - -fx-border-color : white; -} - -.alert_content_pane -{ - -fx-background-color: white; - -fx-padding: 5; -} - -.alert_scroll_pane -{ - -fx-background: white; - -fx-border-color:white; -} - -.alert_button_bar -{ - -fx-background-color:white; -} - - -.about_donate_hyperlink -{ - -fx-padding : 10 0 0 0; - -fx-font-size : 25; - -fx-border-color: transparent; -} - -.screensaver -{ - -fx-background-color: black; -} - -.separator_ui_label -{ - -fx-text-fill: grey; -} - - -.action_grid_pane_parent, .action_grid_pane -{ - -fx-background: transparent; -} - -.general_settings_sub_heading -{ - -fx-font-size: 18; - -fx-padding: 10 0 5 0; +.root { + -fx-font-family : 'Roboto'; +} + + +.action_box +{ + -fx-border-width: 1px; + -fx-border-color : grey; +} + +.action_box_icon_present +{ + +} + +.action_box_icon_not_present +{ + +} + +.action_box_onclick +{ + +} + +.settings_heading_label +{ + -fx-font-size: 20; +} + +.alert_header +{ + -fx-padding: 5; +} + +.alert_pane +{ + -fx-border-width : 5; + -fx-border-radius : 5; + -fx-background-radius : 5; + -fx-max-width : 400; + -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 ); +} + +.alert_header_icon +{ + -fx-icon-size : 30; +} + +.alert_content_pane +{ + -fx-padding: 5; +} + +.alert_pane_parent, .combobox_pane_parent +{ + -fx-background-color : rgba(0,0,0,0.5); +} + +.alert_pane_header_text +{ + -fx-font-size: 18; +} + +.alert_button_bar +{ + -fx-alignment: CENTER_RIGHT; + -fx-spacing: 5; + -fx-padding: 5; +} + +.alert_scroll_pane +{ + -fx-max-height : 300; +} + + +.combo_box +{ + -fx-alignment:CENTER_LEFT; + -fx-pref-width:200; + -fx-padding: 5; + -fx-border-width : 1; + -fx-border-color : grey; + -fx-border-radius : 5; +} + +.combo_box_popup +{ + -fx-border-width : 5; + -fx-border-radius : 5; + -fx-background-radius : 5; + -fx-max-height : 300; + -fx-max-width : 410; + -fx-effect: dropshadow( three-pass-box , rgba(0,0,0,0.6) , 5, 0.0 , 0.0 , 0 ); +} + +.combo_box_popup_vbox +{ + -fx-padding: 5 5 0 5; + -fx-spacing:5; +} + +.combo_box_drop_down_icon +{ + -fx-icon-code: fas-caret-down; + -fx-icon-size: 14; +} + +.action_grid_pane_parent +{ + -fx-background-color:transparent; +} + +.first_time_use_pane_heading_label +{ + -fx-font-size: 20; +} + +.first_time_use_pane_stackpane +{ + +} + +.first_time_use_pane_welcome +{ + +} + +.first_time_use_pane_license +{ + -fx-spacing : 10; +} + +.first_time_use_pane_final_config +{ + +} + +.first_time_use_pane_final_config_label +{ + +} + +.first_time_use_welcome_pane_welcome_label +{ + -fx-font-size: 30; +} + +.first_time_use_welcome_pane_next_to_continue_label +{ + -fx-font-size: 15; +} + +.scroll-pane +{ + -fx-focus-color:transparent; + -fx-faint-focus-color:transparent; +} + +/*Alert Classes added to default stylesheet to show init error, if occurs */ +.action_box_display_text_label +{ + -fx-background-color : transparent; + /*-fx-effect: dropshadow(gaussian, rgba(0, 0, 0, 0.3), 5, 0.3, 0.0, 0.0);*/ +} + +.alert_pane +{ + -fx-background-color : white; + -fx-border-color : white; +} + +.alert_content_pane +{ + -fx-background-color: white; + -fx-padding: 5; +} + +.alert_scroll_pane +{ + -fx-background: white; + -fx-border-color:white; +} + +.alert_button_bar +{ + -fx-background-color:white; +} + + +.about_donate_hyperlink +{ + -fx-padding : 10 0 0 0; + -fx-font-size : 25; + -fx-border-color: transparent; +} + +.screensaver +{ + -fx-background-color: black; +} + +.separator_ui_label +{ + -fx-text-fill: grey; +} + + +.action_grid_pane_parent, .action_grid_pane +{ + -fx-background: transparent; +} + +.general_settings_sub_heading +{ + -fx-font-size: 18; + -fx-padding: 10 0 5 0; } \ No newline at end of file diff --git a/style_classes.txt b/style_classes.txt index 3bdb3602..a7c6cb3e 100755 --- a/style_classes.txt +++ b/style_classes.txt @@ -1,44 +1,44 @@ -This list is outdated. Some classes are missing/no longer work. This will be updated soon - -Dashboard - dashboard - Settings HBox Bar - dashboard_settings_button_parent - Settings Button - dashboard_settings_button - Icon - dashboard_settings_button_icon - - - Action Grid Pane Parent - action_grid_pane_parent - Action Grid Pane (Grid Pane) - action_grid_pane - Action Box - action_box - if folder back button : - Icon : folder_action_back_button_icon - - Is Icon Present ? - yes : action_box_icon_present - no : action_box_icon_not_present - Is Action Valid (is plugin by module name found) ? - yes : action_box_valid - no : action_box_invalid - - Action On Click : action_box_onclick - - Error Icon - action_box_error_icon - - Display Text Label - action_box_display_text_label - -Settings - settings_base - Settings heading label - settings_heading_label - Scroll Pane - settings_base_scroll_pane - Base VBox - settings_base_vbox - - Button Bar - settings_button_bar - -First Time Use - first_time_use_pane - Heading Label - first_time_use_pane_heading_label - Stack Pane - first_time_use_pane_stackpane - Welcome Pane - first_time_use_pane_welcome - Head - first_time_use_welcome_pane_welcome_label - Small Label - first_time_use_welcome_pane_next_to_continue_label - License Pane - first_time_use_pane_license - Final Config - first_time_use_pane_final_config - Scroll Pane - first_time_use_final_config_pane_scroll_pane +This list is outdated. Some classes are missing/no longer work. This will be updated soon + +Dashboard - dashboard + Settings HBox Bar - dashboard_settings_button_parent + Settings Button - dashboard_settings_button + Icon - dashboard_settings_button_icon + + + Action Grid Pane Parent - action_grid_pane_parent + Action Grid Pane (Grid Pane) - action_grid_pane + Action Box - action_box + if folder back button : + Icon : folder_action_back_button_icon + + Is Icon Present ? + yes : action_box_icon_present + no : action_box_icon_not_present + Is Action Valid (is plugin by module name found) ? + yes : action_box_valid + no : action_box_invalid + + Action On Click : action_box_onclick + + Error Icon - action_box_error_icon + + Display Text Label - action_box_display_text_label + +Settings - settings_base + Settings heading label - settings_heading_label + Scroll Pane - settings_base_scroll_pane + Base VBox - settings_base_vbox + + Button Bar - settings_button_bar + +First Time Use - first_time_use_pane + Heading Label - first_time_use_pane_heading_label + Stack Pane - first_time_use_pane_stackpane + Welcome Pane - first_time_use_pane_welcome + Head - first_time_use_welcome_pane_welcome_label + Small Label - first_time_use_welcome_pane_next_to_continue_label + License Pane - first_time_use_pane_license + Final Config - first_time_use_pane_final_config + Scroll Pane - first_time_use_final_config_pane_scroll_pane Button Bar - first_time_use_pane_button_bar \ No newline at end of file From 9ffb6f372ceb96cea9c040582efbfac28e372bff Mon Sep 17 00:00:00 2001 From: quimodotcom Date: Wed, 1 Sep 2021 18:50:05 +0100 Subject: [PATCH 12/12] Update GeneralTab.java --- .../client/window/settings/GeneralTab.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java index 5100fd89..a06ee685 100755 --- a/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java +++ b/src/main/java/com/stream_pi/client/window/settings/GeneralTab.java @@ -37,6 +37,8 @@ import org.controlsfx.control.ToggleSwitch; import java.io.File; +import java.util.List; +import java.util.Arrays; import java.net.URISyntaxException; import java.util.logging.Logger; @@ -53,6 +55,7 @@ public class GeneralTab extends VBox private StreamPiComboBox clientProfileComboBox; private StreamPiComboBox themeComboBox; + private StreamPiComboBox animationComboBox; private TextField nickNameTextField; @@ -134,7 +137,16 @@ public void onNewItemSelected(ClientProfile selectedItem) clientListener.renderProfile(selectedItem, true); } }); - + + animationComboBox = new StreamPiComboBox<>(); + animationComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() + { + @Override + public String getOptionDisplayText(String object) + { + return object; + } + }); themeComboBox = new StreamPiComboBox<>(); themeComboBox.setStreamPiComboBoxFactory(new StreamPiComboBoxFactory() @@ -243,6 +255,11 @@ public String getOptionDisplayText(Theme object) SpaceFiller.horizontal(), themeComboBox ), + new HBox( + new Label("Action Animation"), + SpaceFiller.horizontal(), + animationComboBox + ), generateSubHeading("Others"), themesPathInputBox, iconsPathInputBox, @@ -479,8 +496,23 @@ public void loadData() throws SevereException break; } } + + List animationList = Arrays.asList("None", "Bounce", "Bounce In/Out", "Fade In/Out", "Flash", "Flip", "Jack In The Box", "Jello", "Pulse", "Roll In/Out", "Rotate In/Out", "RubberBand", "Shake Left/Right", "Shake Up/Down", "Swing", "Tada", "Wobble", "Zoom In/Out"); + + animationComboBox.setOptions(animationList); + + int ind3 = 0; + for(int i = 0;i 65535) exceptionAndAlertHandler.handleSevereException(e); } } + + if(!config.getCurrentThemeFullName().equals(animationComboBox.getCurrentSelectedItem())) + { + syncWithServer = true; + + config.setCurrentAnimationName(animationComboBox.getCurrentSelectedItem()); + } if(!config.getClientNickName().equals(nickNameTextField.getText())) {