Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Added Splash screen to Drifty GUI #400

Merged
merged 23 commits into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
29dce4a
test: Added tests for Environment and LinkType
SaptarshiSarkar12 Dec 24, 2023
2649643
test: Added tests for UnitConverter class and added links in LinkType…
SaptarshiSarkar12 Dec 24, 2023
2059146
Merge branch 'master' of github.com:SaptarshiSarkar12/Drifty into add…
SaptarshiSarkar12 Dec 25, 2023
ef19011
feat: Added Tests for File Downloader
SaptarshiSarkar12 Dec 25, 2023
550d2fc
Merge branch 'master' of github.com:SaptarshiSarkar12/Drifty into add…
SaptarshiSarkar12 Dec 25, 2023
9ad3974
fix(tests): Fixed a warning in Spotify Song Download Testing
SaptarshiSarkar12 Dec 25, 2023
938b746
fix(tests): Fixed an edge case in Instagram Video Download
SaptarshiSarkar12 Dec 25, 2023
f8aa617
feat(CI:tests): Added GH Action to run tests
SaptarshiSarkar12 Dec 25, 2023
7647746
fix: Fixed linter issues
SaptarshiSarkar12 Dec 25, 2023
11e8ad9
fix(test): Fixed Threading issues in setting versions of Executables
SaptarshiSarkar12 Dec 25, 2023
3ccafb7
fix(test): Fixed missing ffmpeg problem for spotDL
SaptarshiSarkar12 Dec 25, 2023
6d71fc7
fix(test): Fixed missing ffmpeg problem for spotDL
SaptarshiSarkar12 Dec 25, 2023
45b901e
chore: Updated yt-dlp to the latest version
SaptarshiSarkar12 Dec 26, 2023
33c1502
feat: Added `Splash Screen` in Drifty GUI
SaptarshiSarkar12 Dec 27, 2023
94d327f
chore: Removed commited changes from other branches
SaptarshiSarkar12 Dec 27, 2023
2df61d2
Merge branch 'master' of github.com:SaptarshiSarkar12/Drifty into 280…
SaptarshiSarkar12 Dec 27, 2023
252e18d
chore: Added Splash screen class in the java reflection list for nati…
SaptarshiSarkar12 Dec 27, 2023
ca9c003
chore: Added app identifier in native executable configuration
SaptarshiSarkar12 Dec 27, 2023
bf766dd
chore: Removed unintended changes
SaptarshiSarkar12 Dec 27, 2023
b392ee9
chore: Removed unintended changes
SaptarshiSarkar12 Dec 27, 2023
4878c7a
Merge branch 'master' of github.com:SaptarshiSarkar12/Drifty into 280…
SaptarshiSarkar12 Dec 28, 2023
0f163f1
Merge branch 'master' of github.com:SaptarshiSarkar12/Drifty into 280…
SaptarshiSarkar12 Dec 29, 2023
66f7fb5
docs: Added docker command flags for running the latest Drifty GUI do…
SaptarshiSarkar12 Dec 30, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Core/src/main/java/init/Environment.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public static void setMessageBroker(MessageBroker messageBroker) {
}

public static void checkAndUpdateYtDlp() {
AppSettings.SET.ytDlpUpdating(true);
msgBroker.msgInitInfo("Checking for component (yt-dlp) update ...");
String command = Program.get(YT_DLP);
ProcessBuilder ytDlpUpdateProcess = new ProcessBuilder(command, "-U");
Expand All @@ -75,6 +76,8 @@ public static void checkAndUpdateYtDlp() {
msgBroker.msgInitError("Failed to update yt-dlp! " + e.getMessage());
} catch (InterruptedException e) {
msgBroker.msgInitError("Component (yt-dlp) update process was interrupted! " + e.getMessage());
} finally {
AppSettings.SET.ytDlpUpdating(false);
}
}

Expand Down
4 changes: 4 additions & 0 deletions Core/src/main/java/preferences/Clear.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,8 @@ public void ytDlpVersion() {
public void spotDLVersion() {
preferences.remove(SPOTDL_VERSION);
}

public void ytDlpUpdating() {
preferences.remove(YT_DLP_UPDATING);
}
}
4 changes: 4 additions & 0 deletions Core/src/main/java/preferences/Get.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,8 @@ public String ytDlpVersion() {
public String spotDLVersion() {
return preferences.get(SPOTDL_VERSION, "");
}

public boolean ytDlpUpdating() {
return preferences.getBoolean(YT_DLP_UPDATING, false);
}
}
1 change: 1 addition & 0 deletions Core/src/main/java/preferences/Labels.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@ public interface Labels {
String LAST_FOLDER = "LAST_FOLDER";
String YT_DLP_VERSION = "YT_DLP_VERSION";
String SPOTDL_VERSION = "SPOTDL_VERSION";
String YT_DLP_UPDATING = "YT_DLP_UPDATING";
}
5 changes: 5 additions & 0 deletions Core/src/main/java/preferences/Set.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ public void spotDLVersion(String version) {
AppSettings.CLEAR.spotDLVersion();
preferences.put(SPOTDL_VERSION, version);
}

public void ytDlpUpdating(boolean isInitializing) {
AppSettings.CLEAR.ytDlpUpdating();
preferences.putBoolean(YT_DLP_UPDATING, isInitializing);
}
}
Binary file modified Core/src/main/resources/yt-dlp
Binary file not shown.
3 changes: 1 addition & 2 deletions Docker/macOS Docker Build Instructions.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,5 +107,4 @@ We have finally set up everything required to run the Docker image of **Drifty G
socat TCP-LISTEN:6000,reuseaddr,fork UNIX-CLIENT:\"$DISPLAY\"&
open -a Xquartz
docker compose run -e DISPLAY=192.168.1.10:0 gui
```
Remember to change the tag to the version/branch you want to use.
```
2 changes: 1 addition & 1 deletion GUI/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
<arg>${system-native-image-arg}</arg>
<arg>${compatibility-arg}</arg>
</nativeImageArgs>
<appIdentifier>${gui.main-class}</appIdentifier>
<appIdentifier>Drifty GUI</appIdentifier>
<releaseConfiguration>
<vendor>Drifty</vendor>
<description>Drifty is an open-source interactive file downloader system</description>
Expand Down
25 changes: 15 additions & 10 deletions GUI/src/main/java/main/Drifty_GUI.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
package main;

import gui_init.Environment;
import gui_preferences.AppSettings;
SaptarshiSarkar12 marked this conversation as resolved.
Show resolved Hide resolved
import gui_support.Constants;
import gui_utils.MessageBroker;
import javafx.application.Application;
import javafx.application.Preloader;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
Expand All @@ -17,17 +19,12 @@
import javafx.scene.text.Font;
import javafx.scene.text.FontWeight;
import javafx.stage.Stage;
import preferences.AppSettings;
import properties.Mode;
import ui.ConfirmationDialog;
import ui.UIController;
import ui.MainGridPane;
import ui.ManageFolders;
import ui.*;
import utils.Utility;

import static gui_support.Constants.GUI_APPLICATION_TERMINATED;
import static javafx.scene.layout.AnchorPane.*;
import static javafx.scene.layout.AnchorPane.setRightAnchor;
import static support.Constants.DRIFTY_WEBSITE_URL;
import static support.Constants.VERSION_NUMBER;

Expand All @@ -37,19 +34,29 @@ public class Drifty_GUI extends Application {
private Scene scene;

public static void main(String[] args) {
System.setProperty("javafx.preloader", Splash.class.getCanonicalName());
launch(args);
}

@Override
public void init() {
System.setProperty("apple.laf.useScreenMenuBar", "true");
Mode.setGUIMode();
msgBroker = new MessageBroker();
Environment.setMessageBroker(msgBroker);
msgBroker.msgLogInfo("Drifty GUI (Graphical User Interface) Application Started !");
Environment.initializeEnvironment();
launch(args);
}

@Override
public void start(Stage primaryStage) {
Environment.initializeEnvironment();
this.primaryStage = Constants.getStage("Drifty GUI", true);
this.primaryStage.setMinWidth(Constants.SCREEN_WIDTH * .46);
this.primaryStage.setMinHeight(Constants.SCREEN_HEIGHT * .8125);
createScene();
this.primaryStage.setScene(scene);
notifyPreloader(new Preloader.StateChangeNotification(Preloader.StateChangeNotification.Type.BEFORE_LOAD));
this.primaryStage.show();
}

private void createScene() {
Expand All @@ -62,8 +69,6 @@ private void createScene() {
placeControl(menu, 0, 0, 0, -1);
scene = Constants.getScene(ap);
scene.setOnContextMenuRequested(e -> getRightClickContextMenu().show(scene.getWindow(), e.getScreenX(), e.getScreenY()));
primaryStage.setScene(scene);
primaryStage.show();
menu.setUseSystemMenuBar(true);
UIController.initLogic(gridPane);
primaryStage.focusedProperty().addListener(((observable, oldValue, newValue) -> {
Expand Down
62 changes: 62 additions & 0 deletions GUI/src/main/java/ui/Splash.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
package ui;

import gui_support.Constants;
import javafx.animation.PauseTransition;
import javafx.application.Preloader;
import javafx.geometry.Pos;
import javafx.scene.Scene;
import javafx.scene.image.Image;
import javafx.scene.image.ImageView;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;
import javafx.stage.Stage;
import javafx.stage.StageStyle;
import javafx.util.Duration;
import preferences.AppSettings;

import java.util.Objects;

public class Splash extends Preloader {
private Stage stage;
private Scene scene;

@Override
public void init() {
Image splashImage = new Image(Objects.requireNonNull(Constants.SPLASH).toExternalForm());
ImageView ivSplash = new ImageView(splashImage);
double fitWidth = Constants.SCREEN_WIDTH * .45;
ivSplash.setPreserveRatio(true);
ivSplash.setFitWidth(fitWidth);
VBox vBox = new VBox();
vBox.getChildren().addAll(ivSplash);
vBox.setAlignment(Pos.CENTER);
vBox.setStyle("-fx-background-color: transparent");
scene = new Scene(vBox);
scene.setFill(Color.TRANSPARENT);
}

@Override
public void start(Stage primaryStage) {
stage = Constants.getStage("Splash", false);
stage.initStyle(StageStyle.TRANSPARENT);
stage.setAlwaysOnTop(true);
stage.setScene(scene);
stage.show();
}

@Override
public void handleStateChangeNotification(StateChangeNotification info) {
StateChangeNotification.Type type = info.getType();
if (Objects.requireNonNull(type) == StateChangeNotification.Type.BEFORE_LOAD) {
double time;
if (AppSettings.GET.ytDlpUpdating()) {
time = 2.0;
} else {
time = 1.0;
}
PauseTransition delay = new PauseTransition(Duration.seconds(time));
delay.setOnFinished(event -> stage.close());
delay.play();
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -489,5 +489,9 @@
"name":"support.JobHistory",
"allDeclaredFields":true,
"methods":[{"name":"<init>","parameterTypes":[] }]
},
{
"name":"ui.Splash",
"methods":[{"name":"<init>","parameterTypes":[] }]
}
]
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ For **Users** :
```
**For Drifty GUI**,
```bash
docker run -e DISPLAY=$DISPLAY --net=host ghcr.io/saptarshisarkar12/drifty-gui:master
docker run -e DISPLAY=$DISPLAY --net=host -v /tmp/.X11-unix:/tmp/.X11-unix ghcr.io/saptarshisarkar12/drifty-gui:master
```
3. Drifty will open, and you can now use it 🎉!

Expand Down