Skip to content

Commit

Permalink
english and lres adjustments for windows
Browse files Browse the repository at this point in the history
  • Loading branch information
francescotescari committed Jul 20, 2020
1 parent 51c6501 commit d9dd017
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 14 deletions.
3 changes: 1 addition & 2 deletions src/com/xiaomitool/v2/gui/GuiUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,9 @@ public static void specialComboBox(ComboBox<String> 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);

}
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
12 changes: 6 additions & 6 deletions src/com/xiaomitool/v2/gui/fxml/SettingsFrame.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
</VBox>
<HBox alignment="CENTER" prefHeight="28.0" prefWidth="420.0">
<children>
<CheckBox fx:id="CHECK_SAVE_LOGIN" contentDisplay="CENTER" mnemonicParsing="false" prefHeight="21.0" prefWidth="290.0" text="Keep login session token on tool exit" textAlignment="CENTER">
<CheckBox fx:id="CHECK_SAVE_LOGIN" contentDisplay="CENTER" mnemonicParsing="false" prefHeight="21.0" prefWidth="350.0" text="Keep login session token on tool exit" textAlignment="CENTER">
<font>
<Font size="15.0" />
</font>
Expand All @@ -115,36 +115,36 @@
</HBox>
<VBox alignment="CENTER" spacing="10.0">
<children>
<Button fx:id="BUTTON_RESET" minWidth="290.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="290.0" text="Reset default settings">
<Button fx:id="BUTTON_RESET" minWidth="350.0" mnemonicParsing="false" prefHeight="30.0" text="Reset default settings">
<font>
<Font size="14.0" />
</font>
<VBox.margin>
<Insets />
</VBox.margin>
</Button>
<Button fx:id="BUTTON_CLEAR" minWidth="290.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="290.0" text="Clear downloads and extraction directories">
<Button fx:id="BUTTON_CLEAR" minWidth="350.0" mnemonicParsing="false" prefHeight="30.0" text="Clear downloads and extraction directories">
<font>
<Font size="14.0" />
</font>
<VBox.margin>
<Insets />
</VBox.margin>
</Button>
<Button fx:id="BUTTON_FEEDBACK" minWidth="290.0" mnemonicParsing="false" prefHeight="30.0" prefWidth="290.0" text="Send feedback">
<Button fx:id="BUTTON_FEEDBACK" minWidth="350.0" mnemonicParsing="false" prefHeight="30.0" text="Send feedback">
<font>
<Font size="14.0" />
</font>
<VBox.margin>
<Insets />
</VBox.margin>
</Button>
<ComboBox fx:id="REGION_COMBO" prefHeight="30.0" prefWidth="290.0" promptText="Select your region">
<ComboBox fx:id="REGION_COMBO" prefHeight="30.0" prefWidth="350.0" promptText="Select your region">
<VBox.margin>
<Insets />
</VBox.margin>
</ComboBox>
<ComboBox fx:id="LANG_COMBO" prefHeight="30.0" prefWidth="290.0" promptText="Select your language" />
<ComboBox fx:id="LANG_COMBO" prefHeight="30.0" prefWidth="350.0" promptText="Select your language" />
</children>
<VBox.margin>
<Insets />
Expand Down
4 changes: 3 additions & 1 deletion src/com/xiaomitool/v2/language/LRes.java
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand Down Expand Up @@ -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"),
Expand Down
14 changes: 9 additions & 5 deletions src/com/xiaomitool/v2/language/Lang.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand All @@ -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());
}
Expand Down

0 comments on commit d9dd017

Please sign in to comment.