diff --git a/bin/application/DBController.class b/bin/application/DBController.class index 1dd0f16..3a16c35 100644 Binary files a/bin/application/DBController.class and b/bin/application/DBController.class differ diff --git a/bin/application/Main.class b/bin/application/Main.class index 663459a..1785f2c 100644 Binary files a/bin/application/Main.class and b/bin/application/Main.class differ diff --git a/bin/application/MainWindowController$1.class b/bin/application/MainWindowController$1.class index c392df7..2f56f86 100644 Binary files a/bin/application/MainWindowController$1.class and b/bin/application/MainWindowController$1.class differ diff --git a/bin/application/MainWindowController$2.class b/bin/application/MainWindowController$2.class index d6a1ab4..8d0e66f 100644 Binary files a/bin/application/MainWindowController$2.class and b/bin/application/MainWindowController$2.class differ diff --git a/bin/application/MainWindowController$3.class b/bin/application/MainWindowController$3.class index fc86b80..fd2ba6f 100644 Binary files a/bin/application/MainWindowController$3.class and b/bin/application/MainWindowController$3.class differ diff --git a/bin/application/MainWindowController$4.class b/bin/application/MainWindowController$4.class index 66c3735..6295a3c 100644 Binary files a/bin/application/MainWindowController$4.class and b/bin/application/MainWindowController$4.class differ diff --git a/bin/application/MainWindowController$5.class b/bin/application/MainWindowController$5.class index 64a6d23..b1192f9 100644 Binary files a/bin/application/MainWindowController$5.class and b/bin/application/MainWindowController$5.class differ diff --git a/bin/application/MainWindowController$6.class b/bin/application/MainWindowController$6.class index 5f0c70e..22546ed 100644 Binary files a/bin/application/MainWindowController$6.class and b/bin/application/MainWindowController$6.class differ diff --git a/bin/application/MainWindowController$7.class b/bin/application/MainWindowController$7.class index 9f1378c..771b730 100644 Binary files a/bin/application/MainWindowController$7.class and b/bin/application/MainWindowController$7.class differ diff --git a/bin/application/MainWindowController.class b/bin/application/MainWindowController.class index 734c784..0f81e85 100644 Binary files a/bin/application/MainWindowController.class and b/bin/application/MainWindowController.class differ diff --git a/bin/application/updater.class b/bin/application/updater.class index dd8ed1e..7d0f789 100644 Binary files a/bin/application/updater.class and b/bin/application/updater.class differ diff --git a/bin/recources/HomeFlix-Local_de_DE.properties b/bin/recources/HomeFlix-Local_de_DE.properties index 4fb3706..bfa591e 100644 --- a/bin/recources/HomeFlix-Local_de_DE.properties +++ b/bin/recources/HomeFlix-Local_de_DE.properties @@ -8,6 +8,7 @@ openFolder = Ordner \u00F6ffnen chooseFolder = Ordner ausw\u00E4hlen fontSize = Schriftgr\u00F6\u00DFe: checkUpdates = Auf Update pr\u00FCfen +checkingUpdates = Es wird nach Updates gesucht... updateBtnavail = Update verf\u00FCgbar updateBtnNotavail = Kein Update verf\u00FCgbar autoUpdate = beim Start nach Updates suchen: diff --git a/bin/recources/HomeFlix-Local_en_US.properties b/bin/recources/HomeFlix-Local_en_US.properties index 41de6ea..e221122 100644 --- a/bin/recources/HomeFlix-Local_en_US.properties +++ b/bin/recources/HomeFlix-Local_en_US.properties @@ -8,6 +8,7 @@ openFolder = open Folder chooseFolder = choose Directory fontSize = font size: checkUpdates = check for updates +checkingUpdates = checking for updates... updateBtnavail = update available updateBtnNotavail = no update available autoUpdate = check at startup for updates: diff --git a/src/application/DBController.java b/src/application/DBController.java index a6bfde2..06e2a69 100644 --- a/src/application/DBController.java +++ b/src/application/DBController.java @@ -232,7 +232,7 @@ public class DBController { try { //load local Data Statement stmt = connection.createStatement(); - ResultSet rs = stmt.executeQuery("SELECT * FROM film_local"); + ResultSet rs = stmt.executeQuery("SELECT * FROM film_local ORDER BY titel"); while (rs.next()) { if(rs.getString(4).equals("favorite_black")){ mainWindowController.localFilms.add( new tableData(1, 1, 1, rs.getDouble(1), "1", rs.getString(2), rs.getString(3), new ImageView(favorite_black),rs.getBoolean(5))); @@ -244,7 +244,7 @@ public class DBController { rs.close(); //load streaming Data TODO check if there are streaming data before loading -> maybe there is an issue now - rs = stmt.executeQuery("SELECT * FROM film_streaming;"); + rs = stmt.executeQuery("SELECT * FROM film_streaming ORDER BY titel;"); while (rs.next()) { if(rs.getString(8).equals("favorite_black")){ mainWindowController.streamingFilms.add(new tableData(rs.getInt(1), rs.getInt(2), rs.getInt(3), rs.getDouble(4), rs.getString(5), rs.getString(6), rs.getString(7), new ImageView(favorite_black),rs.getBoolean(9))); @@ -330,7 +330,7 @@ public class DBController { * @throws FileNotFoundException * @throws IOException */ - private void checkAddEntry() throws SQLException, FileNotFoundException, IOException{ //TODO sort alphabetical + private void checkAddEntry() throws SQLException, FileNotFoundException, IOException{ System.out.println("checking for entrys to add to DB ..."); String[] entries = new File(mainWindowController.getPath()).list(); Statement stmt = connection.createStatement(); diff --git a/src/application/Main.java b/src/application/Main.java index c8d8ca7..00e8242 100644 --- a/src/application/Main.java +++ b/src/application/Main.java @@ -45,9 +45,9 @@ public class Main extends Application { private String streamingPathWin = System.getProperty("user.home") + "\\Documents\\HomeFlix"; private String streamingPathLinux = System.getProperty("user.home") + "/HomeFlix"; private String color = "ee3523"; - private String autoUpdate = "0"; private String mode = "local"; //local or streaming private String local = System.getProperty("user.language")+"_"+System.getProperty("user.country"); + private boolean autoUpdate = false; private double size = 17; private ResourceBundle bundle; private MainWindowController mainWindowController; @@ -77,7 +77,7 @@ public class Main extends Application { mainWindowController.setAutoUpdate(autoUpdate); //set auto-update mainWindowController.setMain(this); //call setMain - //Linux if directory exists -> check config.xml + //Linux if directory exists -> check config.xml if(System.getProperty("os.name").equals("Linux")){ if(dirLinux.exists() != true){ dirLinux.mkdir(); diff --git a/src/application/MainWindowController.java b/src/application/MainWindowController.java index 5bb6564..82e2b8c 100644 --- a/src/application/MainWindowController.java +++ b/src/application/MainWindowController.java @@ -182,6 +182,7 @@ public class MainWindowController { private boolean menutrue = false; //saves the position of menubtn (opened or closed) private boolean settingstrue = false; private boolean streamingSettingsTrue = false; + private boolean autoUpdate = false; static boolean firststart = false; private int hashA = -2055934614; private String version = "0.5.0"; @@ -196,22 +197,20 @@ public class MainWindowController { String errorUpdateD; String errorUpdateV; + String noFilmFound; private String errorPlay; private String errorOpenStream; private String errorMode; private String errorLoad; private String errorSave; - String noFilmFound; private String infoText; private String linuxBugText; private String vlcNotInstalled; - private String aktBuildNumber; private String path; private String streamingPath; private String color; private String name; private String datPath; - private String autoUpdate; private String mode; @SuppressWarnings("unused") private String ratingSortType; @@ -472,21 +471,21 @@ public class MainWindowController { @FXML private void updateBtnAction(){ -// Updater.update(buildURL, downloadLink, aktBuildNumber, buildNumber); System.out.println(Updater.getState()); if(Updater.getState() == State.NEW){ Updater.start(); }else{ Updater.run(); } + } @FXML private void autoupdateBtnAction(){ - if(autoUpdate.equals("0")){ - setAutoUpdate("1"); + if(autoUpdate){ + setAutoUpdate(false); }else{ - setAutoUpdate("0"); + setAutoUpdate(true); } saveSettings(); } @@ -519,7 +518,7 @@ public class MainWindowController { //"Main" Method called in Main.java main() when starting void setMain(Main main) { this.main = main; - Updater = new updater(this,buildURL, downloadLink, aktBuildNumber, buildNumber); + Updater = new updater(this,buildURL, downloadLink, buildNumber); dbController = new DBController(this); ApiQuery = new apiQuery(this, dbController); } @@ -760,10 +759,14 @@ public class MainWindowController { updateBtn.setFont(Font.font("System", 12)); cbLocal.setItems(locals); - //TODO rework! - if(autoUpdate.equals("1")){ + if(autoUpdate){ autoupdateBtn.setSelected(true); - Updater.start(); + try { + Updater.start(); + Updater.join(); + } catch (InterruptedException e) { + e.printStackTrace(); + } }else{ autoupdateBtn.setSelected(false); } @@ -1022,7 +1025,7 @@ public class MainWindowController { try { props.setProperty("path", getPath()); //writes path into property props.setProperty("color", getColor()); - props.setProperty("autoUpdate", getAutoUpdate()); + props.setProperty("autoUpdate", String.valueOf(isAutoUpdate())); props.setProperty("size", getSize().toString()); props.setProperty("local", getLocal()); props.setProperty("streamingPath", getStreamingPath()); @@ -1058,7 +1061,7 @@ public class MainWindowController { streamingPath = props.getProperty("streamingPath"); color = props.getProperty("color"); size = Double.parseDouble(props.getProperty("size")); - autoUpdate = props.getProperty("autoUpdate"); + autoUpdate = Boolean.parseBoolean(props.getProperty("autoUpdate")); local = props.getProperty("local"); mode = props.getProperty("mode"); ratingSortType = props.getProperty("ratingSortType"); @@ -1068,7 +1071,7 @@ public class MainWindowController { showErrorMsg(errorSave, e); e.printStackTrace(); } -// showErrorMsg(errorLoad, e); //TODO das soll beim ersten start nicht erscheinen +// showErrorMsg(errorLoad, e); //TODO This should not be visible at first startup } } @@ -1113,11 +1116,11 @@ public class MainWindowController { return size; } - public void setAutoUpdate(String input){ + public void setAutoUpdate(boolean input){ this.autoUpdate = input; } - public String getAutoUpdate(){ + public boolean isAutoUpdate(){ return autoUpdate; } diff --git a/src/application/updater.java b/src/application/updater.java index 5425c8f..2201323 100644 --- a/src/application/updater.java +++ b/src/application/updater.java @@ -12,43 +12,51 @@ import java.net.URL; import java.nio.channels.Channels; import java.nio.channels.ReadableByteChannel; +import javafx.application.Platform; + public class updater extends Thread{ private MainWindowController mainWindowController; private String buildURL; private String downloadLink; - private String aktBuildNumber; + private String updateBuildNumber; private String buildNumber; - public updater(MainWindowController m, String buildURL,String downloadLink,String aktBuildNumber,String buildNumber){ + public updater(MainWindowController m, String buildURL,String downloadLink,String buildNumber){ mainWindowController=m; this.buildURL=buildURL; this.downloadLink=downloadLink; - this.aktBuildNumber=aktBuildNumber; this.buildNumber=buildNumber; } public void run(){ System.out.println("check for updates ..."); + Platform.runLater(() -> { + mainWindowController.updateBtn.setText(mainWindowController.bundle.getString("checkingUpdates")); + }); try { - URL url = new URL(buildURL); //URL der Datei mit aktueller Versionsnummer + URL url = new URL(buildURL); //URL of the text file with the current build number BufferedReader in = new BufferedReader(new InputStreamReader(url.openStream())); - aktBuildNumber = in.readLine(); //schreibt inputstream in String + updateBuildNumber = in.readLine(); //write InputStream in String in.close(); } catch (IOException e1) { mainWindowController.showErrorMsg(mainWindowController.errorUpdateV, e1); } - System.out.println("Build: "+buildNumber+", Update: "+aktBuildNumber); + System.out.println("Build: "+buildNumber+", Update: "+updateBuildNumber); - //vergleicht die Versionsnummern, bei aktversion > version wird ein Update durchgrf�hrt + //Compares the program BuildNumber with the current BuildNumber if program BuildNumber < current BuildNumber then perform a update int iversion = Integer.parseInt(buildNumber); - int iaktVersion = Integer.parseInt(aktBuildNumber.replace(".", "")); + int iaktVersion = Integer.parseInt(updateBuildNumber.replace(".", "")); if(iversion >= iaktVersion){ -// mainWindowController.updateBtn.setText(mainWindowController.bundle.getString("updateBtnNotavail")); + Platform.runLater(() -> { + mainWindowController.updateBtn.setText(mainWindowController.bundle.getString("updateBtnNotavail")); + }); System.out.println("no update available"); }else{ -// mainWindowController.updateBtn.setText(mainWindowController.bundle.getString("updateBtnavail")); + Platform.runLater(() -> { + mainWindowController.updateBtn.setText(mainWindowController.bundle.getString("updateBtnavail")); + }); System.out.println("update available"); try { URL website; @@ -57,7 +65,7 @@ public class updater extends Thread{ String updateDataURL = in.readLine(); website = new URL(updateDataURL); //Update URL ReadableByteChannel rbc = Channels.newChannel(website.openStream()); //open new Stream/Channel - FileOutputStream fos = new FileOutputStream("ProjectHomeFlix.jar"); //nea fileoutputstram for ProjectHomeFLix.jar + FileOutputStream fos = new FileOutputStream("ProjectHomeFlix.jar"); //new FileOutputStream for ProjectHomeFLix.jar fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); //gets file from 0 to max size fos.close(); //close fos (extrem wichtig!) Runtime.getRuntime().exec("java -jar ProjectHomeFlix.jar"); //start again diff --git a/src/recources/HomeFlix-Local_de_DE.properties b/src/recources/HomeFlix-Local_de_DE.properties index 4fb3706..bfa591e 100644 --- a/src/recources/HomeFlix-Local_de_DE.properties +++ b/src/recources/HomeFlix-Local_de_DE.properties @@ -8,6 +8,7 @@ openFolder = Ordner \u00F6ffnen chooseFolder = Ordner ausw\u00E4hlen fontSize = Schriftgr\u00F6\u00DFe: checkUpdates = Auf Update pr\u00FCfen +checkingUpdates = Es wird nach Updates gesucht... updateBtnavail = Update verf\u00FCgbar updateBtnNotavail = Kein Update verf\u00FCgbar autoUpdate = beim Start nach Updates suchen: diff --git a/src/recources/HomeFlix-Local_en_US.properties b/src/recources/HomeFlix-Local_en_US.properties index 41de6ea..e221122 100644 --- a/src/recources/HomeFlix-Local_en_US.properties +++ b/src/recources/HomeFlix-Local_en_US.properties @@ -8,6 +8,7 @@ openFolder = open Folder chooseFolder = choose Directory fontSize = font size: checkUpdates = check for updates +checkingUpdates = checking for updates... updateBtnavail = update available updateBtnNotavail = no update available autoUpdate = check at startup for updates: