diff --git a/README.md b/README.md index 4c7d899..3c31438 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,10 @@ If you use different MacOS (not Mojave) - check release section for another JAR Table 'Status' = 'Uploaded' does not means that file installed. It means that it has been sent to NS without any issues! That's what this app about. Handling successful/failed installation is a purpose of the other side application (TinFoil/GoldLeaf). (And they don't provide any feedback interfaces so I can't detect success/failure.) +## Translators! Traducteurs! Traductores! Übersetzer! Թարգմանիչներ! +If you want to see this app translated to your language, go grab [this file](https://github.com/developersu/ns-usbloader/blob/master/src/main/resources/locale.properties) and translate it. +Upload somewhere (pastebin? google drive? whatever else). [Create new issue](https://github.com/developersu/ns-usbloader/issues) and post a link. I'll grab it and add. + ## TODO: - [x] macOS QA v0.1 (Mojave) - [x] macOS QA v0.2.2 (Mojave) diff --git a/src/main/java/nsusbloader/Controllers/NSLMainController.java b/src/main/java/nsusbloader/Controllers/NSLMainController.java index 04c1522..2ae90bd 100644 --- a/src/main/java/nsusbloader/Controllers/NSLMainController.java +++ b/src/main/java/nsusbloader/Controllers/NSLMainController.java @@ -5,6 +5,8 @@ import javafx.collections.ObservableList; import javafx.fxml.FXML; import javafx.fxml.Initializable; import javafx.scene.control.*; +import javafx.scene.input.DragEvent; +import javafx.scene.input.TransferMode; import javafx.scene.layout.Pane; import javafx.scene.layout.Region; import javafx.stage.FileChooser; @@ -15,6 +17,7 @@ import nsusbloader.USB.UsbCommunications; import java.io.File; import java.net.URL; +import java.util.ArrayList; import java.util.List; import java.util.ResourceBundle; @@ -136,7 +139,7 @@ public class NSLMainController implements Initializable { private void uploadBtnAction(){ if (usbThread == null || !usbThread.isAlive()){ List nspToUpload; - if ((nspToUpload = tableFilesListController.getFiles()) == null) { + if ((nspToUpload = tableFilesListController.getFilesForUpload()) == null) { logArea.setText(resourceBundle.getString("logsNoFolderFileSelected")); return; }else { @@ -188,6 +191,51 @@ public class NSLMainController implements Initializable { uploadStopBtn.getStyleClass().add("buttonUp"); } } + /** + * Drag-n-drop support (dragOver consumer) + * */ + @FXML + private void handleDragOver(DragEvent event){ + if (event.getDragboard().hasFiles()) + event.acceptTransferModes(TransferMode.ANY); + } + /** + * Drag-n-drop support (drop consumer) + * */ + @FXML + private void handleDrop(DragEvent event){ + List filesDropped = new ArrayList<>(); + try { + for (File fileOrDir : event.getDragboard().getFiles()) { + if (fileOrDir.getName().toLowerCase().endsWith(".nsp")) + filesDropped.add(fileOrDir); + else if (fileOrDir.isDirectory()) + for (File file : fileOrDir.listFiles()) + if (file.getName().toLowerCase().endsWith(".nsp")) + filesDropped.add(file); + } + } + catch (SecurityException se){ + se.printStackTrace(); + } + if (!filesDropped.isEmpty()) { + List filesAlreadyInTable; + if ((filesAlreadyInTable = tableFilesListController.getFiles()) != null) { + filesDropped.removeAll(filesAlreadyInTable); // Get what we already have and add new file(s) + if (!filesDropped.isEmpty()) { + filesDropped.addAll(tableFilesListController.getFiles()); + tableFilesListController.setFiles(filesDropped); + } + } + else { + tableFilesListController.setFiles(filesDropped); + uploadStopBtn.setDisable(false); + } + } + + event.setDropCompleted(true); + + } /** * Save preferences before exit * */ diff --git a/src/main/java/nsusbloader/Controllers/NSTableViewController.java b/src/main/java/nsusbloader/Controllers/NSTableViewController.java index 9e1670c..6b5a9da 100644 --- a/src/main/java/nsusbloader/Controllers/NSTableViewController.java +++ b/src/main/java/nsusbloader/Controllers/NSTableViewController.java @@ -124,12 +124,27 @@ public class NSTableViewController implements Initializable { rowsObsLst.get(0).setMarkForUpload(true); } } + /** + * Return all files no matter how they're marked + * */ + public List getFiles(){ + List files = new ArrayList<>(); + if (rowsObsLst.isEmpty()) + return null; + else + for (NSLRowModel model: rowsObsLst) + files.add(model.getNspFile()); + if (!files.isEmpty()) + return files; + else + return null; + } /** * Return files ready for upload. Requested from NSLMainController only -> uploadBtnAction() //TODO: set undefined * @return null if no files marked for upload * List if there are files * */ - public List getFiles(){ + public List getFilesForUpload(){ List files = new ArrayList<>(); if (rowsObsLst.isEmpty()) return null; diff --git a/src/main/java/nsusbloader/NSLMain.java b/src/main/java/nsusbloader/NSLMain.java index ca8f8f3..f07169d 100644 --- a/src/main/java/nsusbloader/NSLMain.java +++ b/src/main/java/nsusbloader/NSLMain.java @@ -18,10 +18,8 @@ public class NSLMain extends Application { FXMLLoader loader = new FXMLLoader(getClass().getResource("/NSLMain.fxml")); - ResourceBundle rb; Locale userLocale = new Locale(Locale.getDefault().getISO3Language()); // NOTE: user locale based on ISO3 Language codes - rb = ResourceBundle.getBundle("locale", userLocale); - + ResourceBundle rb = ResourceBundle.getBundle("locale", userLocale); loader.setResources(rb); Parent root = loader.load(); diff --git a/src/main/resources/NSLMain.fxml b/src/main/resources/NSLMain.fxml index ae1ddba..1ce9f82 100644 --- a/src/main/resources/NSLMain.fxml +++ b/src/main/resources/NSLMain.fxml @@ -17,7 +17,7 @@ - +