Skip to content

Commit

Permalink
Updated MiBandWFTool to 1.3.9
Browse files Browse the repository at this point in the history
Fixed check of MiBandTool on change via Menu
Fixed save background position
  • Loading branch information
MonsterDruide1 committed Aug 28, 2019
1 parent 6c6e4d0 commit 42d0af7
Show file tree
Hide file tree
Showing 21 changed files with 89 additions and 73 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"Steps": 500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 75,
"Calories": 34,
"Distance": 750,
"Pulse": 44,
"CurrentWeather": "Unknown",
Expand All @@ -25,7 +25,7 @@
"Steps": 1000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 150,
"Calories": 68,
"Distance": 1500,
"Pulse": 48,
"CurrentWeather": "Unknown",
Expand All @@ -46,7 +46,7 @@
"Steps": 1500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 225,
"Calories": 102,
"Distance": 2250,
"Pulse": 52,
"CurrentWeather": "PartlyCloudy",
Expand All @@ -67,7 +67,7 @@
"Steps": 2000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 300,
"Calories": 136,
"Distance": 3000,
"Pulse": 56,
"CurrentWeather": "CloudyAndRain",
Expand All @@ -88,7 +88,7 @@
"Steps": 2500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 375,
"Calories": 170,
"Distance": 3750,
"Pulse": 60,
"CurrentWeather": "CloudyAndSnow",
Expand All @@ -109,7 +109,7 @@
"Steps": 3000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 450,
"Calories": 204,
"Distance": 4500,
"Pulse": 64,
"CurrentWeather": "Sunny",
Expand All @@ -130,7 +130,7 @@
"Steps": 3500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 525,
"Calories": 238,
"Distance": 5250,
"Pulse": 68,
"CurrentWeather": "Cloudy",
Expand All @@ -151,7 +151,7 @@
"Steps": 4000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 600,
"Calories": 272,
"Distance": 6000,
"Pulse": 72,
"CurrentWeather": "LightRain",
Expand All @@ -172,7 +172,7 @@
"Steps": 4500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 675,
"Calories": 306,
"Distance": 6750,
"Pulse": 76,
"CurrentWeather": "LightSnow",
Expand All @@ -193,7 +193,7 @@
"Steps": 5000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 750,
"Calories": 340,
"Distance": 7500,
"Pulse": 80,
"CurrentWeather": "Rain",
Expand All @@ -214,7 +214,7 @@
"Steps": 5500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 825,
"Calories": 374,
"Distance": 8250,
"Pulse": 84,
"CurrentWeather": "Snow",
Expand All @@ -235,7 +235,7 @@
"Steps": 6000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 900,
"Calories": 408,
"Distance": 9000,
"Pulse": 88,
"CurrentWeather": "HeavySnow",
Expand All @@ -256,7 +256,7 @@
"Steps": 6500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 975,
"Calories": 442,
"Distance": 9750,
"Pulse": 92,
"CurrentWeather": "HeavyRain",
Expand All @@ -277,7 +277,7 @@
"Steps": 7000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 1050,
"Calories": 476,
"Distance": 10500,
"Pulse": 96,
"CurrentWeather": "SandStorm",
Expand All @@ -298,7 +298,7 @@
"Steps": 7500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 1125,
"Calories": 510,
"Distance": 11250,
"Pulse": 100,
"CurrentWeather": "SnowAndRain",
Expand All @@ -319,7 +319,7 @@
"Steps": 8000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 1200,
"Calories": 544,
"Distance": 12000,
"Pulse": 104,
"CurrentWeather": "Fog",
Expand All @@ -340,7 +340,7 @@
"Steps": 8500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 1275,
"Calories": 578,
"Distance": 12750,
"Pulse": 108,
"CurrentWeather": "Haze",
Expand All @@ -361,7 +361,7 @@
"Steps": 9000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 1350,
"Calories": 612,
"Distance": 13500,
"Pulse": 112,
"CurrentWeather": "Storm",
Expand All @@ -382,7 +382,7 @@
"Steps": 9500,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 1425,
"Calories": 646,
"Distance": 14250,
"Pulse": 116,
"CurrentWeather": "VeryHeavySnow",
Expand All @@ -403,7 +403,7 @@
"Steps": 10000,
"Goal": 10000,
"PulseGoal": 140,
"Calories": 1500,
"Calories": 680,
"Distance": 15000,
"Pulse": 120,
"CurrentWeather": "FloatingDust",
Expand Down
Binary file modified MiBand4Editor/MiBandWFTool/Resources.dll
Binary file not shown.
Binary file modified MiBand4Editor/MiBandWFTool/WatchFace.Parser.dll
Binary file not shown.
Binary file modified MiBand4Editor/MiBandWFTool/WatchFace.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions MiBand4Editor/MiBandWFTool/WatchFace.exe.config
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,7 @@
<!-- *******PLEASE CHANGE ONLY VALUE****** -->
<!-- 0-SimpleChinese, 1-Chinese, 2-English -->
<add key="WeekDaysLanguage" value="0"/>
<!-- Default 500 in miliseconds (50-1000) -->
<add key="PreviewSpeed" value="500"/>
</appSettings>
</configuration>
12 changes: 6 additions & 6 deletions MiBand4Editor/src/display/EditMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,9 @@ else if(parent.getName().startsWith(BGItem.class.toString())) {
edit.add(twoDigitsDay);
}
if(parent.getName().startsWith(Calories.class.toString())) {
JMenuItem delimiterIndex = new JMenuItem(main.getInLang("editMenu_edit_delimiterIndex"));
delimiterIndex.addActionListener(this);
edit.add(delimiterIndex);
JMenuItem suffixIndex = new JMenuItem(main.getInLang("editMenu_edit_suffixIndex"));
suffixIndex.addActionListener(this);
edit.add(suffixIndex);
}
if(parent.getName().startsWith(Pulse.class.toString())) {
JMenuItem delimiterIndex = new JMenuItem(main.getInLang("editMenu_edit_noDataIndex"));
Expand Down Expand Up @@ -508,9 +508,6 @@ private void editDelimiterIndex() {
if(element instanceof MonthAndDay) {
((MonthAndDay)element).changeDelimiterIndex(delimiterIndex);
}
else if(element instanceof Calories) {
((Calories)element).changeDelimiterIndex(delimiterIndex);
}
main.addElement(element,parent.getWidth(),parent.getHeight());
} catch (FileNotFoundException e1) {
JOptionPane.showMessageDialog(null, main.getInLang("error_imageNotFound_multi_title")+e1.getMessage(), main.getInLang("error_imageNotFound_multi_title"), JOptionPane.ERROR_MESSAGE);
Expand Down Expand Up @@ -579,6 +576,9 @@ private void editSuffixIndex() {
if(element instanceof Distance) {
((Distance)element).changeSuffixImageIndex(suffixIndex);
}
if(element instanceof Calories) {
((Calories)element).changeSuffixIndex(suffixIndex);
}
main.addElement(element,parent.getWidth(),parent.getHeight());
} catch (FileNotFoundException e1) {
JOptionPane.showMessageDialog(null, main.getInLang("error_imageNotFound_multi_title")+e1.getMessage(), main.getInLang("error_imageNotFound_multi_title"), JOptionPane.ERROR_MESSAGE);
Expand Down
6 changes: 3 additions & 3 deletions MiBand4Editor/src/display/MainMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -359,9 +359,9 @@ private void addActivityCalories() {
int spacing = Integer.parseInt(JOptionPane.showInputDialog(parent.getInLang("edit_spacing")));
int imageIndex = Integer.parseInt(JOptionPane.showInputDialog(parent.getInLang("edit_imageIndex")));
int imageCount = Integer.parseInt(JOptionPane.showInputDialog(parent.getInLang("edit_imageCount")));
int delimiterIndex = Integer.parseInt(JOptionPane.showInputDialog(parent.getInLang("edit_delimiterIndex")));
int suffixIndex = Integer.parseInt(JOptionPane.showInputDialog(parent.getInLang("edit_suffixIndex")));
try {
Calories group = new Calories(parent.lastClick.x/3, parent.lastClick.y/3, alignment, spacing, imageIndex, imageCount, delimiterIndex);
Calories group = new Calories(parent.lastClick.x/3, parent.lastClick.y/3, alignment, spacing, imageIndex, imageCount, suffixIndex);
parent.addElement(group);
JPopupMenu activity = (JPopupMenu) menu.getSubElements()[0].getSubElements()[0].getSubElements()[2].getSubElements()[0];
((JMenuItem)activity.getSubElements()[2]).setEnabled(false);
Expand Down Expand Up @@ -537,7 +537,7 @@ private void generate() {
try {
Builder builder = new Builder();
builder.generateBackground(parent.bgItems.toArray(new BGItem[0]));
builder.generateJSON(parent.elements);
builder.generateJSON(parent.elements,parent.panel.getBGX(),parent.panel.getBGY());
File[][] disabled = builder.disableUnneededImgs(parent.elements);
builder.runBuilder();
builder.reenableImgs(disabled);
Expand Down
10 changes: 9 additions & 1 deletion MiBand4Editor/src/display/SnapPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public SnapPanel(MiBand4Editor main) throws IOException {
addMouseListener(this);
addMouseMotionListener(this);
try {
BufferedReader br = new BufferedReader(new FileReader(new File(MiBand4Editor.currentPath.getAbsolutePath()+"\\watchface.json")));
BufferedReader br = new BufferedReader(new FileReader(new File(MiBand4Editor.currentPath.getAbsolutePath()+"\\real_watchface.json")));
String line = "";
StringBuilder builder = new StringBuilder();
while((line=br.readLine())!=null) {
Expand Down Expand Up @@ -210,4 +210,12 @@ public void readBGCoords() throws IOException {
JSONObject image = all.getJSONObject("Background").getJSONObject("Image");
backgroundCoords = new Point(image.getInt("X"),image.getInt("Y"));
}

public int getBGX() {
return backgroundCoords.x;
}

public int getBGY() {
return backgroundCoords.y;
}
}
14 changes: 10 additions & 4 deletions MiBand4Editor/src/display/TopMenu.java
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ private void save() {
try {
Builder builder = new Builder();
builder.generateBackground(parent.bgItems.toArray(new BGItem[0]));
builder.generateJSON(parent.elements);
builder.generateJSON(parent.elements,parent.panel.getBGX(),parent.panel.getBGY());
} catch (IOException e1) {
e1.printStackTrace();
}
Expand Down Expand Up @@ -249,7 +249,7 @@ private void saveAs() {
Builder builder = new Builder();
try {
builder.generateBackground(parent.bgItems.toArray(new BGItem[0]));
builder.generateJSON(parent.elements);
builder.generateJSON(parent.elements,parent.panel.getBGX(),parent.panel.getBGY());
} catch (IOException e) {
e.printStackTrace();
}
Expand All @@ -261,7 +261,7 @@ private void generate() {
try {
Builder builder = new Builder();
builder.generateBackground(parent.bgItems.toArray(new BGItem[0]));
builder.generateJSON(parent.elements);
builder.generateJSON(parent.elements,parent.panel.getBGX(),parent.panel.getBGY());
File[][] disabled = builder.disableUnneededImgs(parent.elements);
builder.runBuilder();
builder.reenableImgs(disabled);
Expand Down Expand Up @@ -460,7 +460,13 @@ public String getDescription() {
f.setAcceptAllFileFilterUsed(false);
f.showOpenDialog(null);
StaticHelpers.setJavaLookAndFeel();
MiBand4Editor.toolPath=f.getSelectedFile();
try {
if(parent.isValidToolpath(f.getSelectedFile())) {
MiBand4Editor.toolPath=f.getSelectedFile();
}
} catch (IOException e) {
e.printStackTrace();
}
}

}
20 changes: 10 additions & 10 deletions MiBand4Editor/src/elements/activity/Calories.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,16 @@
public class Calories extends Element{

Number stepsGoal;
int delimiterImageIndex;
int suffixImageIndex;

public Calories(int x, int y, String textAlignment, int spacing, int imageIndex, int imagesCount, int delimiterImageIndex) throws IOException, UnequalDimensionsException {
stepsGoal = new Number(x,y,textAlignment,spacing,imageIndex,imagesCount);
this.delimiterImageIndex=delimiterImageIndex;
public Calories(int x, int y, String textAlignment, int spacing, int imageIndex, int imagesCount, int suffixImageIndex) throws IOException, UnequalDimensionsException {
stepsGoal = new Number(x,y,textAlignment,spacing,imageIndex,imagesCount,5);
this.suffixImageIndex=suffixImageIndex;
}

public Calories(JSONObject jsonObject) {
stepsGoal = new Number(jsonObject.getJSONObject("Number"));
delimiterImageIndex=jsonObject.getInt("DelimiterImageIndex");
suffixImageIndex=jsonObject.getInt("SuffixImageIndex");
}

public JPanel getPreview(int w, int h) throws IOException {
Expand All @@ -44,7 +44,7 @@ public JPanel getPreview(int w, int h) throws IOException {
TopalignedLabel label2 = new TopalignedLabel(stepsGoal.getImage(0));
TopalignedLabel label3 = new TopalignedLabel(stepsGoal.getImage(0));
TopalignedLabel label4 = new TopalignedLabel(stepsGoal.getImage(0));
TopalignedLabel label5 = new TopalignedLabel(StaticHelpers.getJLabelFromImage(delimiterImageIndex));
TopalignedLabel label5 = new TopalignedLabel(StaticHelpers.getJLabelFromImage(suffixImageIndex));
panel.add(label1);
panel.add(label2);
panel.add(label3);
Expand Down Expand Up @@ -105,7 +105,7 @@ public String getJSON() {
builder.append(" \"Calories\": {\r\n");
builder.append(stepsGoal.getJSON());
builder.append(",\r\n");
builder.append(" \"DelimiterImageIndex\": "+delimiterImageIndex);
builder.append(" \"SuffixImageIndex\": "+suffixImageIndex);
builder.append("\r\n }");
return builder.toString();
}
Expand All @@ -118,7 +118,7 @@ public File[] getUsedImgs() {
all[i]=used[i];
}
String absolutePath = MiBand4Editor.currentPath.getAbsolutePath();
String iFormatted = String.format("%04d", delimiterImageIndex);
String iFormatted = String.format("%04d", suffixImageIndex);
all[all.length-1]=new File(absolutePath+"\\"+iFormatted+".png");
return all;
}
Expand All @@ -143,8 +143,8 @@ public void resizeToCoords(int x, int y) {
stepsGoal.resizeToCoords(x, y);
}

public void changeDelimiterIndex(int delimiterIndex) {
delimiterImageIndex=delimiterIndex;
public void changeSuffixIndex(int suffixImageIndex) {
this.suffixImageIndex=suffixImageIndex;
}

public Point getLocation() {
Expand Down
2 changes: 1 addition & 1 deletion MiBand4Editor/src/elements/activity/Distance.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class Distance extends Element{
int decimalPointImageIndex;

public Distance(int x, int y, String textAlignment, int spacing, int imageIndex, int imagesCount, int suffixImageIndex, int decimalPointImageIndex) throws IOException, UnequalDimensionsException {
distance = new Number(x,y,textAlignment,spacing,imageIndex,imagesCount);
distance = new Number(x,y,textAlignment,spacing,imageIndex,imagesCount,6);
this.suffixImageIndex=suffixImageIndex;
this.decimalPointImageIndex=decimalPointImageIndex;
}
Expand Down
6 changes: 3 additions & 3 deletions MiBand4Editor/src/elements/activity/Pulse.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@ public class Pulse extends Element{
int noDataImageIndex;

public Pulse(int x, int y, String textAlignment, int spacing, int imageIndex, int imagesCount, int noDataImageIndex) throws IOException, UnequalDimensionsException {
pulse = new Number(x,y,textAlignment,spacing,imageIndex,imagesCount);
pulse = new Number(x,y,textAlignment,spacing,imageIndex,imagesCount,3);
this.noDataImageIndex=noDataImageIndex;
}

public Pulse(JSONObject jsonObject) {
pulse = new Number(jsonObject.getJSONObject("Pulse"));
pulse = new Number(jsonObject.getJSONObject("Number"));
noDataImageIndex = jsonObject.getInt("NoDataImageIndex");
}

Expand Down Expand Up @@ -98,7 +98,7 @@ public void setCoords(int x, int y) {
public String getJSON() {
StringBuilder builder = new StringBuilder();
builder.append(" \"Pulse\": {\r\n");
builder.append(pulse.getJSON("Pulse"));
builder.append(pulse.getJSON());
builder.append(",\r\n");
builder.append(" \"NoDataImageIndex\": "+noDataImageIndex);
builder.append("\r\n }");
Expand Down
Loading

0 comments on commit 42d0af7

Please sign in to comment.