From 9af3ad26bdb9676e82b6d00816ed9e0f87360dfa Mon Sep 17 00:00:00 2001 From: Seil0 Date: Fri, 21 Jun 2019 21:16:53 +0200 Subject: [PATCH] implemented settings as nested conroller --- .../HomeFlix/application/FilmDetailView.java | 22 ++ .../HomeFlix/application/Main.java | 120 +----- .../application/MainWindowController.java | 359 +++++------------- .../application/SeriesDetailView.java | 22 ++ .../HomeFlix/application/SettingsView.java | 238 +++++++++++- .../HomeFlix/controller/DBController.java | 4 +- .../controller/SourcesController.java | 3 - .../HomeFlix/controller/UpdateController.java | 27 +- .../Alerts/JFX2BtnCancelAlert.java | 9 +- src/main/resources/fxml/MainWindow.fxml | 122 +----- src/main/resources/fxml/SettingsView.fxml | 4 +- .../locals/HomeFlix-Local_de_DE.properties | 1 + .../locals/HomeFlix-Local_en_US.properties | 1 + 13 files changed, 405 insertions(+), 527 deletions(-) diff --git a/src/main/java/kellerkinder/HomeFlix/application/FilmDetailView.java b/src/main/java/kellerkinder/HomeFlix/application/FilmDetailView.java index 1dae333..5c23192 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/FilmDetailView.java +++ b/src/main/java/kellerkinder/HomeFlix/application/FilmDetailView.java @@ -1,3 +1,25 @@ +/** + * Project-HomeFlix + * + * Copyright 2016-2019 <@Seil0> + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + */ + package kellerkinder.HomeFlix.application; import java.awt.Desktop; diff --git a/src/main/java/kellerkinder/HomeFlix/application/Main.java b/src/main/java/kellerkinder/HomeFlix/application/Main.java index e280d72..1b281aa 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/Main.java +++ b/src/main/java/kellerkinder/HomeFlix/application/Main.java @@ -19,55 +19,38 @@ * MA 02110-1301, USA. * */ + package kellerkinder.HomeFlix.application; import java.io.File; import java.io.IOException; -import java.util.Locale; -import java.util.ResourceBundle; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import org.kellerkinder.Alerts.JFX2BtnCancelAlert; import javafx.application.Application; -import javafx.event.ActionEvent; -import javafx.event.EventHandler; import javafx.fxml.FXMLLoader; import javafx.scene.Scene; import javafx.scene.image.Image; import javafx.scene.layout.AnchorPane; -import javafx.stage.DirectoryChooser; -import javafx.stage.FileChooser; import javafx.stage.Stage; import kellerkinder.HomeFlix.controller.XMLController; public class Main extends Application { - private Stage primaryStage; private Scene scene; private AnchorPane pane; private MainWindowController mainWindowController; private static XMLController xmlController; - private ResourceBundle bundle; private static Logger LOGGER; + public static final String version = "0.7.90"; + public static final String buildNumber = "171"; + public static final String versionName = "toothless dragon"; @Override public void start(Stage primaryStage) throws IOException { - LOGGER.info("OS: " + XMLController.getOsName() + " " + XMLController.getOsVers() + " " + XMLController.getOsVers()); - LOGGER.info("Java: " + XMLController.getJavaVend() + " " + XMLController.getJavaVers()); - LOGGER.info("User: " + XMLController.getUserName() + " " + XMLController.getUserHome()); - - this.primaryStage = primaryStage; - mainWindow(); - } - - /** - * initialize the mainWindowController, GUI and load the saved settings or call addFirstSource - * initialize the primaryStage and set the file/directory paths - */ - private void mainWindow(){ + //initialize the mainWindowController and the primaryStage try { FXMLLoader loader = new FXMLLoader(); loader.setLocation(getClass().getResource("/fxml/MainWindow.fxml")); @@ -87,22 +70,8 @@ public class Main extends Application { mainWindowController = loader.getController(); //Link of FXMLController and controller class mainWindowController.init(); - - // startup checks - if (!XMLController.getConfigFile().exists()) { - XMLController.getDirHomeFlix().mkdir(); - System.out.println("config not found"); - - addFirstSource(); - xmlController.saveSettings(); - } - - if (!XMLController.getPosterCache().exists()) { - XMLController.getPosterCache().mkdir(); - } - } catch (IOException e) { - LOGGER.error(e); + LOGGER.error("Error while loading in Main", e); } } @@ -125,70 +94,23 @@ public class Main extends Application { logFile.delete(); LOGGER = LogManager.getLogger(Main.class.getName()); + LOGGER.info("OS: " + XMLController.getOsName() + " " + XMLController.getOsVers() + " " + XMLController.getOsVers()); + LOGGER.info("Java: " + XMLController.getJavaVend() + " " + XMLController.getJavaVers()); + LOGGER.info("User: " + XMLController.getUserName() + " " + XMLController.getUserHome()); + xmlController = new XMLController(); - launch(args); - } - - /** TODO this should move - * we need to get the path for the first source from the user and add it to - * sources.json, if the user ends the file-/directory-chooser the program will exit - */ - private void addFirstSource() { - switch (XMLController.getSysLocal()) { - case "en_US": - bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US); // us_english - break; - case "de_DE": - bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.GERMAN); // de_german - break; - default: - bundle = ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US); // default local - break; + + if (XMLController.getConfigFile().exists()) { + xmlController.loadSettings(); + } else { + xmlController.saveSettings(); + } + + if (!XMLController.getPosterCache().exists()) { + XMLController.getPosterCache().mkdir(); } - JFX2BtnCancelAlert selectFirstSource = new JFX2BtnCancelAlert(bundle.getString("addSourceHeader"), - bundle.getString("addSourceBody"), - "-fx-button-type: RAISED; -fx-background-color: #ee3523; -fx-text-fill: BLACK;", - bundle.getString("addDirectory"), bundle.getString("addStreamSource"), - bundle.getString("cancelBtnText"), primaryStage); - - // directory action - EventHandler btn1Action = new EventHandler() { - @Override - public void handle(ActionEvent event) { - DirectoryChooser directoryChooser = new DirectoryChooser(); - directoryChooser.setTitle(bundle.getString("addDirectory")); - File selectedFolder = directoryChooser.showDialog(primaryStage); - if (selectedFolder != null && selectedFolder.exists()) { - mainWindowController.addSource(selectedFolder.getPath(), "local"); - selectFirstSource.getAlert().close(); - } else { - LOGGER.error("The selected folder dosen't exist!"); - System.exit(1); - } - } - }; - - // streaming action - EventHandler btn2Action = new EventHandler() { - @Override - public void handle(ActionEvent event) { - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle("addStreamSource"); - File selectedFile = fileChooser.showOpenDialog(primaryStage); - if (selectedFile != null && selectedFile.exists()) { - mainWindowController.addSource(selectedFile.getPath(), "stream"); - selectFirstSource.getAlert().close(); - } else { - LOGGER.error("The selected file dosen't exist!"); - System.exit(1); - } - } - }; - - selectFirstSource.setBtn1Action(btn1Action); - selectFirstSource.setBtn2Action(btn2Action); - selectFirstSource.showAndWait(); + launch(args); } - + } diff --git a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java index beeeb0f..fd173de 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java +++ b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java @@ -41,28 +41,21 @@ import java.util.concurrent.TimeUnit; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; +import org.kellerkinder.Alerts.JFX2BtnCancelAlert; import org.kellerkinder.Alerts.JFXInfoAlert; import com.eclipsesource.json.Json; import com.eclipsesource.json.JsonArray; import com.eclipsesource.json.JsonObject; import com.jfoenix.controls.JFXButton; -import com.jfoenix.controls.JFXColorPicker; import com.jfoenix.controls.JFXHamburger; -import com.jfoenix.controls.JFXSlider; -import com.jfoenix.controls.JFXToggleButton; import com.jfoenix.transitions.hamburger.HamburgerBackArrowBasicTransition; import javafx.animation.TranslateTransition; import javafx.collections.FXCollections; import javafx.collections.ObservableList; import javafx.fxml.FXML; -import javafx.scene.control.ChoiceBox; -import javafx.scene.control.Label; import javafx.scene.control.ScrollPane; -import javafx.scene.control.TableColumn; -import javafx.scene.control.TableView; -import javafx.scene.control.TreeItem; import javafx.scene.effect.BoxBlur; import javafx.scene.control.ScrollPane.ScrollBarPolicy; import javafx.scene.input.MouseEvent; @@ -70,8 +63,6 @@ import javafx.scene.layout.AnchorPane; import javafx.scene.layout.FlowPane; import javafx.scene.layout.HBox; import javafx.scene.layout.VBox; -import javafx.scene.paint.Color; -import javafx.scene.text.Font; import javafx.stage.DirectoryChooser; import javafx.stage.FileChooser; import javafx.stage.Stage; @@ -82,7 +73,6 @@ import kellerkinder.HomeFlix.controller.UpdateController; import kellerkinder.HomeFlix.controller.XMLController; import kellerkinder.HomeFlix.datatypes.FilmTabelDataType; import kellerkinder.HomeFlix.datatypes.PosterModeElement; -import kellerkinder.HomeFlix.datatypes.SourceDataType; import kellerkinder.HomeFlix.player.Player; public class MainWindowController { @@ -99,34 +89,7 @@ public class MainWindowController { @FXML private JFXButton settingsBtn; // settings - @FXML private ScrollPane settingsScrollPane; - - @FXML private JFXButton updateBtn; - @FXML private JFXButton addDirectoryBtn; - @FXML private JFXButton addStreamSourceBtn; - @FXML private JFXToggleButton autoUpdateToggleBtn; - @FXML private JFXToggleButton autoplayToggleBtn; - - @FXML private JFXColorPicker colorPicker; - - @FXML private ChoiceBox languageChoisBox = new ChoiceBox<>(); - @FXML private ChoiceBox branchChoisBox = new ChoiceBox<>(); - - @FXML private JFXSlider fontsizeSlider; - - @FXML private Label homeflixSettingsLbl; - @FXML private Label mainColorLbl; - @FXML private Label fontsizeLbl; - @FXML private Label languageLbl; - @FXML private Label updateLbl; - @FXML private Label branchLbl; - @FXML private Label sourcesLbl; - @FXML private Label versionLbl; - - @FXML private TableView sourcesTable; - @FXML private TreeItem sourceRoot = new TreeItem<>(new SourceDataType("", "")); - @FXML private TableColumn sourceColumn; - @FXML private TableColumn modeColumn; + @FXML private SettingsView settingsViewController; // poster-mode @FXML private ScrollPane posterModeScrollPane; @@ -144,18 +107,11 @@ public class MainWindowController { private boolean menuTrue = false; - private final String version = "0.7.90"; - private final String buildNumber = "171"; - private final String versionName = "toothless dragon"; private String btnStyle; private FilmTabelDataType currentTableFilm = new FilmTabelDataType("", "", "", "", false, null); - private ObservableList languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)"); - private ObservableList branches = FXCollections.observableArrayList("stable", "beta"); - private ObservableList filmsList = FXCollections.observableArrayList(); private ObservableList posterEmenents = FXCollections.observableArrayList(); - private static ObservableList sourcesList = FXCollections.observableArrayList(); private LocalDate lastValidCache = LocalDate.now().minusDays(30); // current date - 30 days is the last valid cache date public MainWindowController() { @@ -171,66 +127,36 @@ public class MainWindowController { return instance; } - @FXML public void initialize() { instance = this; xmlController = new XMLController(); dbController = DBController.getInstance(); + + if (!new File(XMLController.getDirHomeFlix() + "/sources.json").exists()) { + XMLController.getDirHomeFlix().mkdir(); + LOGGER.warn("sources file not found"); + + addFirstSource(); + xmlController.saveSettings(); + } } public void init() { - LOGGER.info("Initializing Project-HomeFlix build " + buildNumber); - - xmlController.loadSettings(); // load settings - checkAutoUpdate(); + LOGGER.info("Initializing Project-HomeFlix build " + Main.buildNumber); // initialize the GUI and the DBController primaryStage = (Stage) mainAnchorPane.getScene().getWindow(); // set primary stage for dialogs - initTabel(); - initUI(); + posterModeScrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS); + setLocalUI(); + applyColor(); // TODO only on first start + initActions(); dbController.init(); // load data list in gui - addSourceToTable(); posterModeStartup(); - } - - // Initialize general UI elements - private void initUI() { - //JFXScrollPane.smoothScrolling(posterModeScrollPane); - posterModeScrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS); - settingsScrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS); - versionLbl.setText("Version: " + version + " (Build: " + buildNumber + ")"); - fontsizeSlider.setValue(XMLController.getFontSize()); - colorPicker.setValue(Color.valueOf(XMLController.getColor())); - - updateBtn.setFont(Font.font("System", 12)); - autoUpdateToggleBtn.setSelected(XMLController.isAutoUpdate()); - autoplayToggleBtn.setSelected(XMLController.isAutoplay()); - languageChoisBox.setItems(languages); - branchChoisBox.setItems(branches); - - if (XMLController.isUseBeta()) { - branchChoisBox.getSelectionModel().select(1); - } else { - branchChoisBox.getSelectionModel().select(0); - } - - setLocalUI(); - applyColor(); - } - - /** - * Initialize the tables (treeTableViewfilm and sourcesTable) only needed for - * Tabel-Mode - */ - private void initTabel() { - // sourcesTreeTable - sourceColumn.setCellValueFactory(cellData -> cellData.getValue().pathProperty()); - modeColumn.setCellValueFactory(cellData -> cellData.getValue().modeProperty()); - sourcesTable.setItems(sourcesList); + checkAutoUpdate(); // TODO async } // Initializing the actions @@ -250,37 +176,12 @@ public class MainWindowController { burgerTask.play(); menuTrue = true; } - if (settingsScrollPane.isVisible()) { - settingsScrollPane.setVisible(false); - } - }); - - languageChoisBox.getSelectionModel().selectedIndexProperty().addListener((e, oldValue, newValue) -> { - String local = languageChoisBox.getItems().get((int) newValue).toString(); - local = local.substring(local.length() - 6, local.length() - 1); // reading only en_US from English (en_US) - XMLController.setUsrLocal(local); - setLocalUI(); - xmlController.saveSettings(); - }); - - branchChoisBox.getSelectionModel().selectedIndexProperty().addListener((e, oldValue, newValue) -> { - if (branchChoisBox.getItems().get((int) newValue).toString() == "beta") { - XMLController.setUseBeta(true); - } else { - XMLController.setUseBeta(false); - } - xmlController.saveSettings(); - }); - - fontsizeSlider.valueProperty().addListener(e -> { - XMLController.setFontSize(fontsizeSlider.getValue()); - // TODO add functionality for postermode - - xmlController.saveSettings(); - }); - - // Poster-Mode actions + if (settingsViewController.isVisible()) { + settingsViewController.setVisible(false); + } + });primaryStage.setMinHeight(600.00 + 34); // 34 -> window decoration + primaryStage.setMinWidth(1130.00); } // Table-Mode fxml actions @@ -293,7 +194,7 @@ public class MainWindowController { } if (isSupportedFormat(currentTableFilm)) { - new Player(getCurrentStreamUrl()); + new Player(currentTableFilm.getStreamUrl()); } else { LOGGER.error("using fallback player!"); if (System.getProperty("os.name").contains("Linux")) { @@ -317,7 +218,7 @@ public class MainWindowController { vlcInfoAlert.showAndWait(); } else { try { - new ProcessBuilder("vlc", getCurrentStreamUrl()).start(); + new ProcessBuilder("vlc", currentTableFilm.getStreamUrl()).start(); } catch (IOException e) { LOGGER.warn("An error has occurred while opening the file!", e); } @@ -325,7 +226,7 @@ public class MainWindowController { } else if (System.getProperty("os.name").contains("Windows") || System.getProperty("os.name").contains("Mac OS X")) { try { - Desktop.getDesktop().open(new File(getCurrentStreamUrl())); + Desktop.getDesktop().open(new File(currentTableFilm.getStreamUrl())); } catch (IOException e) { LOGGER.warn("An error has occurred while opening the file!", e); } @@ -335,119 +236,78 @@ public class MainWindowController { } } } - - @FXML - private void openfolderbtnclicked() { - File dest = new File(getCurrentStreamUrl()).getParentFile(); - - if (!System.getProperty("os.name").contains("Linux")) { - try { - Desktop.getDesktop().open(dest); - } catch (IOException e) { - e.printStackTrace(); - } - } - } // general fxml actions @FXML private void aboutBtnAction() { - String bodyText = "Project HomeFlix \nVersion: " + version + " (Build: " + buildNumber + ") \"" + versionName - + "\" \n" + XMLController.getLocalBundle().getString("infoText"); + String bodyText = "Project HomeFlix \nVersion: " + Main.version + " (Build: " + Main.buildNumber + ") \"" + + Main.versionName + "\" \n" + XMLController.getLocalBundle().getString("infoText"); JFXInfoAlert infoAlert = new JFXInfoAlert("Project HomeFlix", bodyText, btnStyle, primaryStage); infoAlert.showAndWait(); } @FXML private void settingsBtnclicked() { - settingsScrollPane.setVisible(!settingsScrollPane.isVisible()); + settingsViewController.setVisible(!settingsViewController.isVisible()); } - - @FXML - private void addDirectoryBtnAction() { - DirectoryChooser directoryChooser = new DirectoryChooser(); - directoryChooser.setTitle(XMLController.getLocalBundle().getString("addDirectory")); - File selectedFolder = directoryChooser.showDialog(primaryStage); - if (selectedFolder != null && selectedFolder.exists()) { - addSource(selectedFolder.getPath(), "local"); - } else { - LOGGER.error("The selected folder dosen't exist!"); - } - } - - @FXML - private void addStreamSourceBtnAction() { - FileChooser fileChooser = new FileChooser(); - fileChooser.setTitle(XMLController.getLocalBundle().getString("addStreamSource")); - File selectedFile = fileChooser.showOpenDialog(primaryStage); - if (selectedFile != null && selectedFile.exists()) { - addSource(selectedFile.getPath(), "stream"); - } else { - LOGGER.error("The selected file dosen't exist!"); - } - } - - @FXML - private void colorPickerAction() { - XMLController.setColor(colorPicker.getValue().toString().substring(2, 10)); - xmlController.saveSettings(); - applyColor(); - } - - @FXML - private void updateBtnAction() { - updateController = new UpdateController(this, buildNumber, XMLController.isUseBeta()); - Thread updateThread = new Thread(updateController); - updateThread.setName("Updater"); - updateThread.start(); - } - - @FXML - private void autoUpdateToggleBtnAction() { - XMLController.setAutoUpdate(!XMLController.isAutoUpdate()); - xmlController.saveSettings(); - } - - @FXML - private void autoplayToggleBtnAction() { - XMLController.setAutoplay(!XMLController.isAutoplay()); - xmlController.saveSettings(); - } - + /** - * refresh all films in filmsList and in filmsTable clear the FilmsList and - * FilmRoot children, then update the database + * we need to get the path for the first source from the user and add it to + * sources.json, if the user ends the file-/directory-chooser the program will exit */ - private void refreshAllFilms() { - filmsList.clear(); - dbController.refreshDataBase(); // refreshes the database after a source path was added - filmsList = dbController.getStreamsList(); // returns a list of all films stored in the database - } + private void addFirstSource() { + JFX2BtnCancelAlert selectFirstSource = new JFX2BtnCancelAlert( + XMLController.getLocalBundle().getString("addSourceHeader"), + XMLController.getLocalBundle().getString("addSourceBody"), + "-fx-button-type: RAISED; -fx-background-color: #ee3523; -fx-text-fill: BLACK;", + XMLController.getLocalBundle().getString("addDirectory"), + XMLController.getLocalBundle().getString("addStreamSource"), + XMLController.getLocalBundle().getString("cancelBtnText"), primaryStage); - // add a all elements of sourcesList to the sources table on the settings pane - public void addSourceToTable() { - for (SourceDataType source : sourcesList) { - sourceRoot.getChildren().add(new TreeItem(source)); // add data to root-node - } + // directory action + selectFirstSource.setBtn1Action(e -> { + DirectoryChooser directoryChooser = new DirectoryChooser(); + directoryChooser.setTitle(XMLController.getLocalBundle().getString("addDirectory")); + File selectedFolder = directoryChooser.showDialog(primaryStage); + if (selectedFolder != null && selectedFolder.exists()) { + selectFirstSource.getAlert().close(); + writeSource(selectedFolder.getPath(), "local"); + } else { + LOGGER.error("The selected folder dosen't exist!"); + System.exit(1); + } + }); + + // streaming action + selectFirstSource.setBtn2Action(e -> { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle(XMLController.getLocalBundle().getString("addStreamSource")); + File selectedFile = fileChooser.showOpenDialog(primaryStage); + if (selectedFile != null && selectedFile.exists()) { + selectFirstSource.getAlert().close(); + writeSource(selectedFile.getPath(), "stream"); + } else { + LOGGER.error("The selected file dosen't exist!"); + System.exit(1); + } + }); + + selectFirstSource.showAndWait(); } /** - * add a source to the newsources list + * add a source to the sources file * * @param path to the source * @param mode of the source (local or streaming) */ - public void addSource(String path, String mode) { + void writeSource(String path, String mode) { JsonArray newsources = null; - + try { // read old array File oldSources = new File(XMLController.getDirHomeFlix() + "/sources.json"); - if (oldSources.exists()) { - newsources = Json.parse(new FileReader(XMLController.getDirHomeFlix() + "/sources.json")).asArray(); - } else { - newsources = Json.array(); - } + newsources = oldSources.exists() ? Json.parse(new FileReader(XMLController.getDirHomeFlix() + "/sources.json")).asArray() : Json.array(); // add new source JsonObject source = Json.object().add("path", path).add("mode", mode); @@ -456,37 +316,28 @@ public class MainWindowController { newsources.writeTo(writer); writer.close(); } catch (IOException e) { - LOGGER.error(e); + LOGGER.error("Error while writing sources file!", e); } - - // clear old sources list/table - getSourcesList().clear(); - sourceRoot.getChildren().clear(); - - refreshAllFilms(); // refresh the FilmsList - checkAllPosters(); // check if there is anything to cache } /** * set the color of the GUI-Elements if usedColor is less than checkColor set * text fill white, else black */ - private void applyColor() { + void applyColor() { String menuBtnStyle; BigInteger usedColor = new BigInteger(XMLController.getColor(), 16); BigInteger checkColor = new BigInteger("78909cff", 16); + menuHam.getStyleClass().clear(); + if (usedColor.compareTo(checkColor) == -1) { btnStyle = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; -fx-text-fill: WHITE;"; menuBtnStyle = "-fx-text-fill: WHITE;"; - - menuHam.getStyleClass().clear(); menuHam.getStyleClass().add("jfx-hamburgerW"); } else { btnStyle = "-fx-button-type: RAISED; -fx-background-color: #" + XMLController.getColor() + "; -fx-text-fill: BLACK;"; menuBtnStyle = "-fx-text-fill: BLACK;"; - - menuHam.getStyleClass().clear(); menuHam.getStyleClass().add("jfx-hamburgerB"); } @@ -494,14 +345,11 @@ public class MainWindowController { sideMenuVBox.setStyle("-fx-background-color: #" + XMLController.getColor() + ";"); topHBox.setStyle("-fx-background-color: #" + XMLController.getColor() + ";"); - // normal buttons - addDirectoryBtn.setStyle(btnStyle); - addStreamSourceBtn.setStyle(btnStyle); - updateBtn.setStyle(btnStyle); - // menu buttons settingsBtn.setStyle(menuBtnStyle); aboutBtn.setStyle(menuBtnStyle); + + settingsViewController.updateColor(btnStyle); } // slide in in 400ms @@ -524,37 +372,26 @@ public class MainWindowController { /** * set the local based on the languageChoisBox selection */ - private void setLocalUI() { + void setLocalUI() { + // TODO switch expressions switch (XMLController.getUsrLocal()) { case "en_US": XMLController.setLocalBundle(ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US)); // us_English - languageChoisBox.getSelectionModel().select(0); break; case "de_DE": XMLController.setLocalBundle(ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.GERMAN)); // German - languageChoisBox.getSelectionModel().select(1); break; default: XMLController.setLocalBundle(ResourceBundle.getBundle("locals.HomeFlix-Local", Locale.US)); // default local - languageChoisBox.getSelectionModel().select(0); break; } + settingsViewController.updateGUILocal(); filmDetailViewController.updateGUILocal(); seriesDetailViewController.updateGUILocal(); aboutBtn.setText(XMLController.getLocalBundle().getString("info")); settingsBtn.setText(XMLController.getLocalBundle().getString("settings")); - updateBtn.setText(XMLController.getLocalBundle().getString("checkUpdates")); - addDirectoryBtn.setText(XMLController.getLocalBundle().getString("addDirectory")); - addStreamSourceBtn.setText(XMLController.getLocalBundle().getString("addStreamSource")); - homeflixSettingsLbl.setText(XMLController.getLocalBundle().getString("homeflixSettingsLbl")); - mainColorLbl.setText(XMLController.getLocalBundle().getString("mainColorLbl")); - fontsizeLbl.setText(XMLController.getLocalBundle().getString("fontsizeLbl")); - languageLbl.setText(XMLController.getLocalBundle().getString("languageLbl")); - autoUpdateToggleBtn.setText(XMLController.getLocalBundle().getString("autoUpdate")); - autoplayToggleBtn.setText(XMLController.getLocalBundle().getString("autoplay")); - branchLbl.setText(XMLController.getLocalBundle().getString("branchLbl")); } // if AutoUpdate, then check for updates @@ -563,7 +400,7 @@ public class MainWindowController { if (XMLController.isAutoUpdate()) { try { LOGGER.info("AutoUpdate: looking for updates on startup ..."); - updateController = new UpdateController(this, buildNumber, XMLController.isUseBeta()); + updateController = new UpdateController(settingsViewController); // TODO this is will crash Thread updateThread = new Thread(updateController); updateThread.setName("Updater"); updateThread.start(); @@ -599,7 +436,7 @@ public class MainWindowController { /** * check if all posters are cached, if not cache the missing ones */ - private void checkAllPosters() { + void checkAllPosters() { // get all not cached entries, none of them should have a cached poster ExecutorService executor = Executors.newFixedThreadPool(5); @@ -621,14 +458,14 @@ public class MainWindowController { } // update all elements from the database - refreshAllFilms(); + dbController.refreshDataBase(); // refreshes the database after a source path was added System.out.println("finished refresh"); } /** * add all cached films/series to the PosterMode GUI */ - private void addAllPosters() { + void addAllPosters() { // refresh the posterModeElements list posterEmenents.clear(); posterEmenents = dbController.getPosterElementsList(); // returns a list of all PosterElements stored in the database @@ -637,7 +474,6 @@ public class MainWindowController { for (PosterModeElement element : posterEmenents) { element.getButton().addEventHandler(MouseEvent.MOUSE_CLICKED, (event) -> { enableBlur(); // blur the FlowPane - System.out.println("selected: " + element.getStreamURL()); // if the selected element is a file it's a film, else a series if (new File(element.getStreamURL()).isFile() || element.getStreamURL().contains("http")) { @@ -656,15 +492,14 @@ public class MainWindowController { System.out.println("added gui elements"); } - // TODO can this be done in dbController? + // TODO can this be done in dbController? with dbController.refreshDataBase(); /** * check if the cache is to old, if so update asynchron */ private void checkCache() { ExecutorService executor = Executors.newFixedThreadPool(5); - // TODO if filmlist is not used anymore, it cann be removed - for(FilmTabelDataType entry : filmsList) { + for(FilmTabelDataType entry : dbController.getStreamsList()) { if (dbController.getCacheDate(entry.getStreamUrl()).isBefore(lastValidCache)) { System.out.println(entry.getTitle() + " chached on: " + dbController.getCacheDate(entry.getStreamUrl())); Runnable OMDbAPIWorker = new OMDbAPIController(entry, XMLController.getOmdbAPIKey()); @@ -686,26 +521,4 @@ public class MainWindowController { public void disableBlur() { posterModeFlowPane.setEffect(null); } - - // getter and setter - - public FilmTabelDataType getCurrentTableFilm() { - return currentTableFilm; - } - - public String getCurrentTitle() { - return currentTableFilm.getTitle(); - } - - public String getCurrentStreamUrl() { - return currentTableFilm.getStreamUrl(); - } - - public static ObservableList getSourcesList() { - return sourcesList; - } - - public JFXButton getUpdateBtn() { - return updateBtn; - } } diff --git a/src/main/java/kellerkinder/HomeFlix/application/SeriesDetailView.java b/src/main/java/kellerkinder/HomeFlix/application/SeriesDetailView.java index dbdf814..4e70597 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/SeriesDetailView.java +++ b/src/main/java/kellerkinder/HomeFlix/application/SeriesDetailView.java @@ -1,3 +1,25 @@ +/** + * Project-HomeFlix + * + * Copyright 2016-2019 <@Seil0> + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + */ + package kellerkinder.HomeFlix.application; import java.awt.Desktop; diff --git a/src/main/java/kellerkinder/HomeFlix/application/SettingsView.java b/src/main/java/kellerkinder/HomeFlix/application/SettingsView.java index d5e35bc..bfc7694 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/SettingsView.java +++ b/src/main/java/kellerkinder/HomeFlix/application/SettingsView.java @@ -1,10 +1,47 @@ +/** + * Project-HomeFlix + * + * Copyright 2016-2019 <@Seil0> + * + * 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, + * MA 02110-1301, USA. + * + */ + package kellerkinder.HomeFlix.application; +import java.io.File; +import java.io.FileReader; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; + +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import com.eclipsesource.json.Json; +import com.eclipsesource.json.JsonArray; +import com.eclipsesource.json.JsonObject; +import com.eclipsesource.json.JsonValue; import com.jfoenix.controls.JFXButton; import com.jfoenix.controls.JFXColorPicker; import com.jfoenix.controls.JFXSlider; import com.jfoenix.controls.JFXToggleButton; +import javafx.collections.FXCollections; +import javafx.collections.ObservableList; import javafx.event.ActionEvent; import javafx.fxml.FXML; import javafx.scene.control.ChoiceBox; @@ -12,7 +49,14 @@ import javafx.scene.control.Label; import javafx.scene.control.ScrollPane; import javafx.scene.control.TableColumn; import javafx.scene.control.TableView; +import javafx.scene.control.ScrollPane.ScrollBarPolicy; import javafx.scene.layout.AnchorPane; +import javafx.scene.paint.Color; +import javafx.stage.DirectoryChooser; +import javafx.stage.FileChooser; +import kellerkinder.HomeFlix.controller.DBController; +import kellerkinder.HomeFlix.controller.UpdateController; +import kellerkinder.HomeFlix.controller.XMLController; import kellerkinder.HomeFlix.datatypes.SourceDataType; public class SettingsView { @@ -47,37 +91,209 @@ public class SettingsView { @FXML private TableColumn sourceColumn; @FXML private TableColumn modeColumn; + private XMLController xmlController; + private static final Logger LOGGER = LogManager.getLogger(FilmDetailView.class.getName()); + private ObservableList languages = FXCollections.observableArrayList("English (en_US)", "Deutsch (de_DE)"); + private ObservableList branches = FXCollections.observableArrayList("stable", "beta"); + private static ObservableList sourcesList = FXCollections.observableArrayList(); + public void initialize() { - System.out.println("geht"); + xmlController = new XMLController(); + + // initialize the GUI elements + settingsScrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS); + versionLbl.setText("Version: " + Main.version + " (Build: " + Main.buildNumber + ")"); + fontsizeSlider.setValue(XMLController.getFontSize()); + colorPicker.setValue(Color.valueOf(XMLController.getColor())); + + autoUpdateToggleBtn.setSelected(XMLController.isAutoUpdate()); + autoplayToggleBtn.setSelected(XMLController.isAutoplay()); + languageChoisBox.setItems(languages); + branchChoisBox.setItems(branches); + + branchChoisBox.getSelectionModel().select(XMLController.isUseBeta() ? 1 : 0); + // TODO switch expressions + switch (XMLController.getUsrLocal()) { + case "en_US": + languageChoisBox.getSelectionModel().select(0); + break; + case "de_DE": + languageChoisBox.getSelectionModel().select(1); + break; + default: + languageChoisBox.getSelectionModel().select(0); + break; + } + + // initialize the sources table + sourceColumn.setCellValueFactory(cellData -> cellData.getValue().pathProperty()); + modeColumn.setCellValueFactory(cellData -> cellData.getValue().modeProperty()); + sourcesTable.setItems(sourcesList); + + initActions(); + loadInitSources(); } - @FXML void addDirectoryBtnAction(ActionEvent event) { + private void initActions() { + languageChoisBox.getSelectionModel().selectedIndexProperty().addListener((e, oldValue, newValue) -> { + String local = languageChoisBox.getItems().get((int) newValue).toString(); + local = local.substring(local.length() - 6, local.length() - 1); // reading only en_US from English (en_US) + XMLController.setUsrLocal(local); + xmlController.saveSettings(); + MainWindowController.getInstance().setLocalUI(); + }); + + branchChoisBox.getSelectionModel().selectedIndexProperty().addListener((e, oldValue, newValue) -> { + if (branchChoisBox.getItems().get((int) newValue).toString() == "beta") { + XMLController.setUseBeta(true); + } else { + XMLController.setUseBeta(false); + } + xmlController.saveSettings(); + }); + + fontsizeSlider.valueProperty().addListener(e -> { + XMLController.setFontSize(fontsizeSlider.getValue()); + xmlController.saveSettings(); + + // TODO add functionality for postermode + }); + } + + @FXML + private void addDirectoryBtnAction(ActionEvent event) { + DirectoryChooser directoryChooser = new DirectoryChooser(); + directoryChooser.setTitle(XMLController.getLocalBundle().getString("addDirectory")); + File selectedFolder = directoryChooser.showDialog(settingsScrollPane.getScene().getWindow()); + if (selectedFolder != null && selectedFolder.exists()) { + addSource(selectedFolder.getPath(), "local"); + } else { + LOGGER.error("The selected folder dosen't exist!"); + } } @FXML - void addStreamSourceBtnAction(ActionEvent event) { - + private void addStreamSourceBtnAction(ActionEvent event) { + FileChooser fileChooser = new FileChooser(); + fileChooser.setTitle(XMLController.getLocalBundle().getString("addStreamSource")); + File selectedFile = fileChooser.showOpenDialog(settingsScrollPane.getScene().getWindow()); + if (selectedFile != null && selectedFile.exists()) { + addSource(selectedFile.getPath(), "stream"); + } else { + LOGGER.error("The selected file dosen't exist!"); + } } @FXML - void autoUpdateToggleBtnAction(ActionEvent event) { - + private void autoUpdateToggleBtnAction(ActionEvent event) { + XMLController.setAutoUpdate(!XMLController.isAutoUpdate()); + xmlController.saveSettings(); } @FXML - void autoplayToggleBtnAction(ActionEvent event) { - + private void autoplayToggleBtnAction(ActionEvent event) { + XMLController.setAutoplay(!XMLController.isAutoplay()); + xmlController.saveSettings(); } @FXML - void colorPickerAction(ActionEvent event) { - + private void colorPickerAction(ActionEvent event) { + XMLController.setColor(colorPicker.getValue().toString().substring(2, 10)); + xmlController.saveSettings(); + MainWindowController.getInstance().applyColor(); } @FXML - void updateBtnAction(ActionEvent event) { + private void updateBtnAction(ActionEvent event) { + Thread updateThread = new Thread(new UpdateController(this)); + updateThread.setName("Updater"); + updateThread.start(); + } + + /** TODO can this be done async? + * add a source to the sources file and load all new streams + * @param path to the source + * @param mode of the source (local or streaming) + */ + void addSource(String path, String mode) { + JsonArray newsources = null; + try {settingsScrollPane.setVbarPolicy(ScrollBarPolicy.ALWAYS); + // read old array + File oldSources = new File(XMLController.getDirHomeFlix() + "/sources.json"); + newsources = oldSources.exists() ? Json.parse(new FileReader(XMLController.getDirHomeFlix() + "/sources.json")).asArray() : Json.array(); + + // add new source + JsonObject source = Json.object().add("path", path).add("mode", mode); + newsources.add(source); + Writer writer = new FileWriter(XMLController.getDirHomeFlix() + "/sources.json"); + newsources.writeTo(writer); + writer.close(); + } catch (IOException e) { + LOGGER.error(e); + } + + // update the sourcesTable + sourcesList.add(new SourceDataType(path, mode)); + + DBController.getInstance().refreshDataBase(); // refreshes the database after a source path was added + MainWindowController.getInstance().checkAllPosters(); // check if there is anything new to cache + MainWindowController.getInstance().addAllPosters(); + } + + // add a all elements of sourcesList to the sources table on the settings pane + private void loadInitSources() { + try { + // create a JsonArray, containing all sources, add each source to the mwc, get all films from it + JsonArray sources = Json.parse(new FileReader(XMLController.getDirHomeFlix() + "/sources.json")).asArray(); + for (JsonValue source : sources) { + String path = source.asObject().getString("path", ""); + String mode = source.asObject().getString("mode", ""); + sourcesList.add(new SourceDataType(path, mode)); + } + } catch (Exception e) { + e.printStackTrace(); + } + } + + public void updateColor(String btnStyle) { + updateBtn.setStyle(btnStyle); + addDirectoryBtn.setStyle(btnStyle); + addStreamSourceBtn.setStyle(btnStyle); + + autoUpdateToggleBtn.setToggleColor(Color.valueOf(XMLController.getColor())); + autoUpdateToggleBtn.setToggleLineColor(Color.valueOf(XMLController.getColor())); + autoplayToggleBtn.setToggleColor(Color.valueOf(XMLController.getColor())); + autoplayToggleBtn.setToggleLineColor(Color.valueOf(XMLController.getColor())); + } + + public void updateGUILocal() { + homeflixSettingsLbl.setText(XMLController.getLocalBundle().getString("homeflixSettingsLbl")); + mainColorLbl.setText(XMLController.getLocalBundle().getString("mainColorLbl")); + fontsizeLbl.setText(XMLController.getLocalBundle().getString("fontsizeLbl")); + languageLbl.setText(XMLController.getLocalBundle().getString("languageLbl")); + branchLbl.setText(XMLController.getLocalBundle().getString("branchLbl")); + sourcesLbl.setText(XMLController.getLocalBundle().getString("sourcesLbl")); + + updateBtn.setText(XMLController.getLocalBundle().getString("checkUpdates")); + addDirectoryBtn.setText(XMLController.getLocalBundle().getString("addDirectory")); + addStreamSourceBtn.setText(XMLController.getLocalBundle().getString("addStreamSource")); + + autoUpdateToggleBtn.setText(XMLController.getLocalBundle().getString("autoUpdate")); + autoplayToggleBtn.setText(XMLController.getLocalBundle().getString("autoplay")); + } + + public void setVisible(boolean visible) { + settingsScrollPane.setVisible(visible); + } + + public boolean isVisible() { + return settingsScrollPane.isVisible(); + } + + public JFXButton getUpdateBtn() { + return updateBtn; } } diff --git a/src/main/java/kellerkinder/HomeFlix/controller/DBController.java b/src/main/java/kellerkinder/HomeFlix/controller/DBController.java index c06e846..8b0d4ee 100644 --- a/src/main/java/kellerkinder/HomeFlix/controller/DBController.java +++ b/src/main/java/kellerkinder/HomeFlix/controller/DBController.java @@ -52,8 +52,8 @@ public class DBController { private static DBController instance = null; private String DB_PATH; - private Image favorite_black = new Image("icons/ic_favorite_black_18dp_1x.png"); - private Image favorite_border_black = new Image("icons/ic_favorite_border_black_18dp_1x.png"); + private Image favorite_black = new Image("icons/baseline_favorite_black_48dp.png"); // TODO this should be removed + private Image favorite_border_black = new Image("icons/baseline_favorite_border_black_48dp.png"); // TODO this too private List databaseStreams = new ArrayList(); // contains all films stored in the database private List sourceStreams = new ArrayList(); // contains all films from the sources private Connection connection = null; diff --git a/src/main/java/kellerkinder/HomeFlix/controller/SourcesController.java b/src/main/java/kellerkinder/HomeFlix/controller/SourcesController.java index 7e5c213..76dc8fc 100644 --- a/src/main/java/kellerkinder/HomeFlix/controller/SourcesController.java +++ b/src/main/java/kellerkinder/HomeFlix/controller/SourcesController.java @@ -37,9 +37,7 @@ import com.eclipsesource.json.JsonArray; import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; -import kellerkinder.HomeFlix.application.MainWindowController; import kellerkinder.HomeFlix.datatypes.DatabaseDataType; -import kellerkinder.HomeFlix.datatypes.SourceDataType; public class SourcesController { @@ -61,7 +59,6 @@ public class SourcesController { for (JsonValue source : sources) { String path = source.asObject().getString("path", ""); String mode = source.asObject().getString("mode", ""); - MainWindowController.getSourcesList().add(new SourceDataType(path, mode)); // TODO if (mode.equals("local")) addLocalSource(path); diff --git a/src/main/java/kellerkinder/HomeFlix/controller/UpdateController.java b/src/main/java/kellerkinder/HomeFlix/controller/UpdateController.java index 3c7caf1..ace49cd 100644 --- a/src/main/java/kellerkinder/HomeFlix/controller/UpdateController.java +++ b/src/main/java/kellerkinder/HomeFlix/controller/UpdateController.java @@ -41,12 +41,12 @@ import com.eclipsesource.json.JsonObject; import com.eclipsesource.json.JsonValue; import javafx.application.Platform; -import kellerkinder.HomeFlix.application.MainWindowController; +import kellerkinder.HomeFlix.application.Main; +import kellerkinder.HomeFlix.application.SettingsView; public class UpdateController implements Runnable { - private MainWindowController mainWindowController; - private int buildNumber; + private SettingsView settingsViewController; private int updateBuildNumber; // tag_name from gitea private String apiOutput; @SuppressWarnings("unused") @@ -57,7 +57,6 @@ public class UpdateController implements Runnable { private String giteaApiRelease = "https://git.mosad.xyz/api/v1/repos/Seil0/Project-HomeFlix/releases"; private URL giteaApiUrl; - private boolean useBeta; private static final Logger LOGGER = LogManager.getLogger(UpdateController.class.getName()); /** @@ -66,17 +65,15 @@ public class UpdateController implements Runnable { * @param buildNumber the buildNumber of the used HomeFlix version * @param useBeta if the updater should query the beta channel */ - public UpdateController(MainWindowController mwc, String buildNumber, boolean useBeta) { - mainWindowController = mwc; - this.buildNumber = Integer.parseInt(buildNumber); - this.useBeta = useBeta; + public UpdateController(SettingsView svc) { + settingsViewController = svc; } @Override public void run() { - LOGGER.info("beta:" + useBeta + "; checking for updates ..."); + LOGGER.info("beta:" + XMLController.isUseBeta() + "; checking for updates ..."); Platform.runLater(() -> { - mainWindowController.getUpdateBtn().setText(XMLController.getLocalBundle().getString("updateBtnChecking")); + settingsViewController.getUpdateBtn().setText(XMLController.getLocalBundle().getString("updateBtnChecking")); }); try { @@ -96,7 +93,7 @@ public class UpdateController implements Runnable { JsonObject objectAsset = object.asObject().get("assets").asArray().get(0).asObject(); for(JsonValue objectIt : objectArray) { - if(objectIt.asObject().getBoolean("prerelease", false) == useBeta) { + if(objectIt.asObject().getBoolean("prerelease", false) == XMLController.isUseBeta()) { // we found the needed release either beta or not object = objectIt; objectAsset = objectIt.asObject().get("assets").asArray().get(0).asObject(); @@ -108,20 +105,20 @@ public class UpdateController implements Runnable { updateName = object.asObject().getString("name", ""); updateChanges = object.asObject().getString("body", ""); - LOGGER.info("Build: " + buildNumber + ", Update: " + updateBuildNumber); + LOGGER.info("Build: " + Main.buildNumber + ", Update: " + updateBuildNumber); /** * Compare the program BuildNumber with the current BuildNumber * if buildNumber < updateBuildNumber then perform a update */ - if (buildNumber >= updateBuildNumber) { + if (Integer.parseInt(Main.buildNumber) >= updateBuildNumber) { Platform.runLater(() -> { - mainWindowController.getUpdateBtn().setText(XMLController.getLocalBundle().getString("updateBtnNoUpdateAvailable")); + settingsViewController.getUpdateBtn().setText(XMLController.getLocalBundle().getString("updateBtnNoUpdateAvailable")); }); LOGGER.info("no update available"); } else { Platform.runLater(() -> { - mainWindowController.getUpdateBtn().setText(XMLController.getLocalBundle().getString("updateBtnUpdateAvailable")); + settingsViewController.getUpdateBtn().setText(XMLController.getLocalBundle().getString("updateBtnUpdateAvailable")); }); LOGGER.info("update available"); browserDownloadUrl = objectAsset.getString("browser_download_url", ""); diff --git a/src/main/java/org/kellerkinder/Alerts/JFX2BtnCancelAlert.java b/src/main/java/org/kellerkinder/Alerts/JFX2BtnCancelAlert.java index 9fc68d6..2821b11 100644 --- a/src/main/java/org/kellerkinder/Alerts/JFX2BtnCancelAlert.java +++ b/src/main/java/org/kellerkinder/Alerts/JFX2BtnCancelAlert.java @@ -90,7 +90,7 @@ public class JFX2BtnCancelAlert { JFXButton cancelBtn = new JFXButton(); cancelBtn.setText(cancelText); cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> alert.close()); - cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> System.exit(0)); + cancelBtn.addEventHandler(ActionEvent.ACTION, (e)-> System.exit(0)); // TODO only on first start cancelBtn.setButtonType(com.jfoenix.controls.JFXButton.ButtonType.RAISED); cancelBtn.setPrefHeight(32); cancelBtn.setStyle(btnStyle); @@ -99,6 +99,13 @@ public class JFX2BtnCancelAlert { content.setActions(btnOne, btnTwo, cancelBtn); content.setHeading(new Text(headingText)); content.setBody(new Text(bodyText)); + + // TODO only on first start + Stage stage = (Stage) alert.getDialogPane().getScene().getWindow(); + stage.setMinWidth(416); + stage.setMinHeight(162); + stage.setOnCloseRequest(event -> System.exit(0)); + alert.setContent(content); alert.showAndWait(); } diff --git a/src/main/resources/fxml/MainWindow.fxml b/src/main/resources/fxml/MainWindow.fxml index 239c5d2..9a243b2 100644 --- a/src/main/resources/fxml/MainWindow.fxml +++ b/src/main/resources/fxml/MainWindow.fxml @@ -1,17 +1,9 @@ - - - - - - - - @@ -31,119 +23,7 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + diff --git a/src/main/resources/fxml/SettingsView.fxml b/src/main/resources/fxml/SettingsView.fxml index d5d8790..62f05e6 100644 --- a/src/main/resources/fxml/SettingsView.fxml +++ b/src/main/resources/fxml/SettingsView.fxml @@ -16,9 +16,9 @@ - + - + diff --git a/src/main/resources/locals/HomeFlix-Local_de_DE.properties b/src/main/resources/locals/HomeFlix-Local_de_DE.properties index 5363deb..1b7279d 100644 --- a/src/main/resources/locals/HomeFlix-Local_de_DE.properties +++ b/src/main/resources/locals/HomeFlix-Local_de_DE.properties @@ -22,6 +22,7 @@ updateBtnNoUpdateAvailable = Kein Update verf\u00FCgbar autoUpdate = beim Start nach Updates suchen: autoplay = autoplay branchLbl = Updatezweig +sourcesLbl = Quellen #column translations columnStreamUrl = Datei Name diff --git a/src/main/resources/locals/HomeFlix-Local_en_US.properties b/src/main/resources/locals/HomeFlix-Local_en_US.properties index c303d44..a2166c7 100644 --- a/src/main/resources/locals/HomeFlix-Local_en_US.properties +++ b/src/main/resources/locals/HomeFlix-Local_en_US.properties @@ -22,6 +22,7 @@ updateBtnNoUpdateAvailable = no update available autoUpdate = check at startup for updates: autoplay = autoplay branchLbl = Branch +sourcesLbl = Quellen #column translations columnStreamUrl = File Name