diff --git a/src/com/xiaomitool/v2/gui/GuiUtils.java b/src/com/xiaomitool/v2/gui/GuiUtils.java index c3f4982..99bc984 100644 --- a/src/com/xiaomitool/v2/gui/GuiUtils.java +++ b/src/com/xiaomitool/v2/gui/GuiUtils.java @@ -173,10 +173,9 @@ public static void specialComboBox(ComboBox combo, LRes closedFormat, in public void updateItem(String item, boolean empty) { super.updateItem(item, empty); setFont(Font.font(this.getFont().getName(), fontSize)); + setAlignment(Pos.CENTER); if (item != null) { setText(closedFormat.toString(item)); - setAlignment(Pos.CENTER_LEFT); - } } }); diff --git a/src/com/xiaomitool/v2/gui/controller/MainWindowController.java b/src/com/xiaomitool/v2/gui/controller/MainWindowController.java index 7fb619d..0cd2b5e 100644 --- a/src/com/xiaomitool/v2/gui/controller/MainWindowController.java +++ b/src/com/xiaomitool/v2/gui/controller/MainWindowController.java @@ -75,6 +75,8 @@ private void initText() { version += " (" + ToolManager.TOOL_VERSION_EX + ")"; } VERSION_NUMBER.setText(version); + TRANSLATED_LINK.setText(LRes.TRANSLATOR.toString()); + LOGIN_LINK.setText(LRes.LOGIN.toString()); GuiUtils.tooltip(IMG_SETTINGS, LRes.TIP_WINDOW_SETTINGS); translateUrl = LRes.TRANSLATED_URL.toString(); } diff --git a/src/com/xiaomitool/v2/gui/controller/SettingsController.java b/src/com/xiaomitool/v2/gui/controller/SettingsController.java index 31aeec6..0d0b809 100644 --- a/src/com/xiaomitool/v2/gui/controller/SettingsController.java +++ b/src/com/xiaomitool/v2/gui/controller/SettingsController.java @@ -158,6 +158,7 @@ private void initTexts() { LABEL_EXTRACT.setText(LRes.SETTINGS_EXTRACT_DIR.toString()); BUTTON_DOWNLOAD.setText(LRes.CHOOSE.toString()); BUTTON_CLEAR.setText(LRes.SETTINGS_CLEAR.toString()); + BUTTON_RESET.setText(LRes.SETTINGS_RESET.toString()); BUTTON_EXTRACT.setText(LRes.CHOOSE.toString()); CHECK_SAVE_LOGIN.setText(LRes.SETTINGS_SAVE_SESSION.toString()); BUTTON_FEEDBACK.setText(LRes.SEND_FEEDBACK.toString()); diff --git a/src/com/xiaomitool/v2/gui/fxml/SettingsFrame.fxml b/src/com/xiaomitool/v2/gui/fxml/SettingsFrame.fxml index 0debad6..4484f1e 100644 --- a/src/com/xiaomitool/v2/gui/fxml/SettingsFrame.fxml +++ b/src/com/xiaomitool/v2/gui/fxml/SettingsFrame.fxml @@ -103,7 +103,7 @@ - + @@ -115,7 +115,7 @@ - - - - + - + diff --git a/src/com/xiaomitool/v2/language/LRes.java b/src/com/xiaomitool/v2/language/LRes.java index 42c77d7..7cc333f 100644 --- a/src/com/xiaomitool/v2/language/LRes.java +++ b/src/com/xiaomitool/v2/language/LRes.java @@ -16,8 +16,11 @@ public enum LRes { SETTINGS_EXTRACT_DIR("Extraction directory"), SETTINGS_SAVE_SESSION("Save user login session"), SETTINGS_CLEAR("Clear download and extraction directories"), + SETTINGS_RESET("Reset default settings"), CHOOSE("Choose"), + LOGIN("Login"), TRANSLATED_BY("Translated by"), + TRANSLATOR(""), TRANSLATED_URL("https://www.xiaomitool.com"), CHOOSE_RECOVER_DEVICE("My device is bricked\nI want to unbrick it."), CHOOSE_MOD_DEVICE("My device works normally\nI want to mod it."), @@ -113,7 +116,6 @@ public enum LRes { PROCEDURE_EXC_TEXT("There was an error during the installation procedure.\nError description:"), PROCEDURE_EXC_TEXT_2("Error family code:%1$s\nError origin:%s\n\nPress \"%2$s\" to try again the failed procedure.\nPress \"%3$s\" to go a step back and try again the entire latest step\nPress \"%4$s\" to cancel the procedure and abort the installation process"), PROCEDURE_EXC_DETAILS("Error type: %1$s\nError description: %2$s"), - PROCEDURE_EXC_ADV_DETAILS("Advanced error details"), CANCEL("Cancel"), STEP_BACK("Step back"), DRIVER_FIXING_MTP("Fixing MTP driver issues"), diff --git a/src/com/xiaomitool/v2/language/Lang.java b/src/com/xiaomitool/v2/language/Lang.java index 208fccd..3f500d0 100644 --- a/src/com/xiaomitool/v2/language/Lang.java +++ b/src/com/xiaomitool/v2/language/Lang.java @@ -7,6 +7,7 @@ import com.xiaomitool.v2.resources.ResourcesManager; import com.xiaomitool.v2.utility.Pair; import com.xiaomitool.v2.utility.utils.SettingsUtils; +import org.apache.commons.codec.digest.DigestUtils; import org.json.JSONArray; import org.json.JSONObject; import org.w3c.dom.Document; @@ -21,6 +22,7 @@ import javax.xml.transform.TransformerFactory; import javax.xml.transform.dom.DOMSource; import javax.xml.transform.stream.StreamResult; +import java.io.BufferedInputStream; import java.io.FileInputStream; import java.io.FileWriter; import java.io.InputStream; @@ -88,7 +90,7 @@ public static void saveToXmlFile(Path filepath) throws Exception { for (LRes l : LRes.values()) { Element el = doc.createElement(STRING_ELEMNENT_NAME); el.setAttribute(STRING_ID, l.getKey()); - el.setTextContent(l.toEnglish()); + el.setTextContent(l.toEnglish().replace("\n","\\n")); root.appendChild(el); } DOMSource source = new DOMSource(doc); @@ -162,8 +164,11 @@ private static void loadLangCode(String langCode) throws Exception { if (rightHash != null){ boolean needToDownload = true; if (present){ - //TODO CHECK LOCAL FILE HASH - needToDownload = false; + String md5 = ""; + try (BufferedInputStream in = new BufferedInputStream(new FileInputStream(localFile.toFile()))) { + md5 = DigestUtils.md5Hex(in); + } + needToDownload = !rightHash.equalsIgnoreCase(md5); } if (needToDownload){ downloadLangFile(langCode, localFile); @@ -177,12 +182,11 @@ private static void loadLangCode(String langCode) throws Exception { } private static void downloadLangFile(String langCode, Path destination) throws Exception{ + Log.info("Downloading lang file: "+langCode); EasyResponse response = EasyHttp.get(langHost+"/"+langCode+".xml"); if (!response.isAllRight()){ throw new Exception("Failed to download the lang file: "+response.getCode()); } - String a = response.getBody(); - System.out.println(a); try (FileWriter writer = new FileWriter(destination.toFile())){ writer.write(response.getBody()); }