diff --git a/AppPreferences.java b/AppPreferences.java index 3241ff2..60f8011 100644 --- a/AppPreferences.java +++ b/AppPreferences.java @@ -40,23 +40,23 @@ public class AppPreferences { return preferences.getBoolean("LOAD_LISTS_ON_START", false); // Don't populate lists by-default } - // Save lists itself of the latest opened folders (used only in Controller.class) - public void setList(String whichList, String value){ - preferences.put(whichList, value); - } - // Return lists itself of the latest opened folders (used only in Controller.class) - public String getList(String whichList){ - return preferences.get(whichList, ""); + /** Convert strings array to singls string. Used in: + * setSubsExtensionsList + * setSubsCodepageList + */ + private void storeSingleStringList(String whichList, String[] strArr){ + StringBuilder collect = new StringBuilder(); + for (String e : strArr) { + collect.append(e); + collect.append("@@@"); // If there is some idiot who will use @@@ in file extension I'll find him. + } + String strToStore = collect.toString(); + preferences.put(whichList, strToStore); } - /** Handle lists of the subtitles extensions selector */ + /** Handle lists of the subtitles extensions selector */ public void setSubsExtensionsList(String[] subsList){ - String stringToStore = ""; - for (String e : subsList) { - stringToStore += e; - stringToStore += "@@@"; // If there is some idiot who will use @@@ in file extension I'll find him. - } - preferences.put("SUBS_EXTENSIONS_LIST", stringToStore); + storeSingleStringList("SUBS_EXTENSIONS_LIST", subsList); } public String[] getSubsExtensionsList(){ @@ -65,12 +65,7 @@ public class AppPreferences { /** Handle lists of the subtitles codepage selector */ public void setSubsCodepageList(String[] subsCodepageList){ - String stringToStore = ""; - for (String e : subsCodepageList) { - stringToStore += e; - stringToStore += "@@@"; // If there is some idiot who will use @@@ in file extension I'll find him. - } - preferences.put("SUBS_CODEPAGE_LIST", stringToStore); + storeSingleStringList("SUBS_CODEPAGE_LIST", subsCodepageList); } public String[] getSubsCodepageList(){ @@ -80,6 +75,7 @@ public class AppPreferences { // Save & recover selected by user Subtitles format public void setLastTimeUsedSusExt(String selected){ preferences.put("SUBS_EXT_LAST_TIME_SELECTED", selected); } public String getLastTimeUsedSubsExt(){ return preferences.get("SUBS_EXT_LAST_TIME_SELECTED", ""); } + // Save & recover selected by user Subtitles codepage public void setLastTimeUsedSubsCodepage(String selected){ preferences.put("SUBS_CODEPAGE_LAST_TIME_SELECTED", selected); } public String getLastTimeUsedSubsCodepage(){ return preferences.get("SUBS_CODEPAGE_LAST_TIME_SELECTED", ""); } @@ -89,4 +85,22 @@ public class AppPreferences { return preferences.getBoolean("FULL_SCREEN_SELECTED", false); } public void setFullScreenSelected(boolean set){ preferences.putBoolean("FULL_SCREEN_SELECTED", set); } + + /** Lists managment */ + // Return lists itself of the latest opened folders (used only in Controller.class) + private String getList(String whichList){ + return preferences.get(whichList, ""); + } + // Save lists itself of the latest opened folders (used only in Controller.class) + private void setList(String whichList, String value){ + preferences.put(whichList, value); + } + + public String getListMKV(){ return getList("MKV"); } + public String getListMKA(){ return getList("MKA"); } + public String getListSUB(){ return getList("SUB"); } + + public void setListMKV(String value){setList("MKV", value);} + public void setListMKA(String value){setList("MKA", value);} + public void setListSUB(String value){setList("SUB", value);} } diff --git a/Controller.java b/Controller.java index 473a178..bb8cb11 100644 --- a/Controller.java +++ b/Controller.java @@ -25,11 +25,20 @@ public class Controller implements Initializable { private ControllerMKA mkaPaneController; // Get preferences - // Class of settings used private AppPreferences appPreferences = new AppPreferences(); private ResourceBundle resourceBundle; + + @FXML + private CheckMenuItem fullScreen; + + // Get host services for opening URLs etc. + private HostServices hostServices; + + @FXML + private TabPane tabPane; + @Override public void initialize(URL url, ResourceBundle rb) { // Register this controller in mediator @@ -61,28 +70,19 @@ public class Controller implements Initializable { /* Populating settings from the previous run /*/ // Populating lists if (appPreferences.getLoadListsOnStart()){ // TODO: probably should be dedicated method in abstract class defined - if (!appPreferences.getList("MKV").isEmpty()){ - mkvPaneController.getFilesFromFolder(new File(appPreferences.getList("MKV")), ".mkv"); + if (!appPreferences.getListMKV().isEmpty()){ + mkvPaneController.getFilesFromFolder(new File(appPreferences.getListMKV()), ".mkv"); } - if (!appPreferences.getList("MKA").isEmpty()){ - mkaPaneController.getFilesFromFolder(new File(appPreferences.getList("MKA")), ".mka"); + if (!appPreferences.getListMKA().isEmpty()){ + mkaPaneController.getFilesFromFolder(new File(appPreferences.getListMKA()), ".mka"); } - if (!appPreferences.getList("SUB").isEmpty()){ - subPaneController.getFilesFromFolder(new File(appPreferences.getList("SUB")), appPreferences.getLastTimeUsedSubsExt()); + if (!appPreferences.getListSUB().isEmpty()){ + subPaneController.getFilesFromFolder(new File(appPreferences.getListSUB()), appPreferences.getLastTimeUsedSubsExt()); } } fullScreen.setSelected(appPreferences.getFullScreenSelected()); } - @FXML - private CheckMenuItem fullScreen; - - // Get host services for opening URLs etc. - private HostServices hostServices; - - @FXML - private TabPane tabPane; - public void setHostServices(HostServices hostServices) { this.hostServices = hostServices; } @@ -194,19 +194,19 @@ public class Controller implements Initializable { if (appPreferences.getLoadListsOnStart()) { if (mkvPaneController.paneFileList.isEmpty()) - appPreferences.setList("MKV", ""); + appPreferences.setListMKV(""); else - appPreferences.setList("MKV", mkvPaneController.paneFileList.get(0).getParent()); + appPreferences.setListMKV(mkvPaneController.paneFileList.get(0).getParent()); if (mkaPaneController.paneFileList.isEmpty()) - appPreferences.setList("MKA", ""); + appPreferences.setListMKA(""); else - appPreferences.setList("MKA", mkaPaneController.paneFileList.get(0).getParent()); + appPreferences.setListMKA(mkaPaneController.paneFileList.get(0).getParent()); if (subPaneController.paneFileList.isEmpty()) - appPreferences.setList("SUB", ""); + appPreferences.setListSUB(""); else { - appPreferences.setList("SUB", subPaneController.paneFileList.get(0).getParent()); + appPreferences.setListSUB(subPaneController.paneFileList.get(0).getParent()); } } appPreferences.setLastTimeUsedSusExt(subPaneController.subtExt.getValue()); @@ -216,10 +216,10 @@ public class Controller implements Initializable { Platform.exit(); } + @FXML private void infoBnt(){ new AboutWindow(this.hostServices); } // TODO: fix this shit with hostSerivces that doesn't work @ linux - /** SETTINGS HANDLE */ @FXML private void settingsBtn(){ new SettingsWindow(); } diff --git a/Main.java b/Main.java index e85ff6c..578ebf4 100644 --- a/Main.java +++ b/Main.java @@ -3,7 +3,7 @@ package mplayer4anime; * Name: mplayer4anime * * Author: Dmitry Isaenko * * License: GNU GPL v.3 * -* Version: 0.8.2 * +* Version: 0.8.3 * * Site: https://developersu.blogspot.com/ * * 2018, Russia * ***********************************************/ diff --git a/appPanes/ControllerPane.java b/appPanes/ControllerPane.java index efaf231..45d9384 100644 --- a/appPanes/ControllerPane.java +++ b/appPanes/ControllerPane.java @@ -18,7 +18,7 @@ import java.util.ResourceBundle; public abstract class ControllerPane implements Initializable { - private ResourceBundle resourceBundle; // TODO: consider access thorough mediator + private ResourceBundle resourceBundle; // use folderToOpen same variable in all panes private static String folderToOpen; @@ -136,7 +136,6 @@ public abstract class ControllerPane implements Initializable { paneListView.getSelectionModel().select(index+1); } } - @FXML private void Del(){ paneFileList.remove(paneListView.getSelectionModel().getSelectedItem()); } diff --git a/localization/locale_en.properties b/localization/locale_en.properties index e087e64..bc16918 100644 --- a/localization/locale_en.properties +++ b/localization/locale_en.properties @@ -1,5 +1,5 @@ about_line1=mplayer4amine distributes under GNU GPLv3 license. -about_line2=Release: v0.8.2 +about_line2=Release: v0.8.3 about_line3=Development & maintenance by Dmitry Isaenko. about_AboutName=About main_tab_audio=Audio diff --git a/localization/locale_ru.properties b/localization/locale_ru.properties index 8e7817d..bf4beeb 100644 --- a/localization/locale_ru.properties +++ b/localization/locale_ru.properties @@ -1,5 +1,5 @@ about_line1=mplayer4amine \u0440\u0430\u0441\u043F\u0440\u043E\u0441\u0442\u0440\u0430\u043D\u044F\u0435\u0442\u0441\u044F \u043F\u043E \u043B\u0438\u0446\u0435\u043D\u0437\u0438\u0438 GNU GPLv3. -about_line2=\u0420\u0435\u043B\u0438\u0437: v0.8.2 +about_line2=\u0420\u0435\u043B\u0438\u0437: v0.8.3 about_line3=\u0420\u0430\u0437\u0440\u0430\u0431\u043E\u0442\u0430\u043D\u043E \u0438 \u043F\u043E\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442\u0441\u044F \u0414\u043C\u0438\u0442\u0440\u0438\u0435\u043C \u0418\u0441\u0430\u0435\u043D\u043A\u043E. about_AboutName=\u041E \u043F\u0440\u0438\u043B\u043E\u0436\u0435\u043D\u0438\u0438 main_tab_audio=\u0410\u0443\u0434\u0438\u043E