Windows Fixes Pt. 1

This commit is contained in:
Marcel Michael Kapfer 2015-07-29 18:00:10 +02:00
parent fab340487c
commit ea2b9efaae
17 changed files with 446 additions and 405 deletions

0
.gitignore vendored Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

0
src/META-INF/MANIFEST.MF Normal file → Executable file
View File

2
src/de/marcelkapfer/c/morseconverter/Main.form Normal file → Executable file
View File

@ -122,7 +122,7 @@
<properties/> <properties/>
<border type="none"/> <border type="none"/>
<children> <children>
<component id="c0dac" class="javax.swing.JTextPane" default-binding="true"> <component id="c0dac" class="javax.swing.JTextPane" binding="aboutText">
<constraints/> <constraints/>
<properties> <properties>
<contentType value="text/html"/> <contentType value="text/html"/>

20
src/de/marcelkapfer/c/morseconverter/Main.java Normal file → Executable file
View File

@ -31,17 +31,22 @@ import de.marcelkapfer.c.morseconverter.update.Update;
import de.marcelkapfer.c.morseconverter.update.UpdateDialog; import de.marcelkapfer.c.morseconverter.update.UpdateDialog;
import javax.swing.*; import javax.swing.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.Element;
import javax.swing.text.html.HTMLDocument;
import javax.swing.text.html.HTMLEditorKit;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent; import java.awt.event.ActionEvent;
import java.awt.event.ActionListener; import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter; import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.io.IOException;
import java.util.ResourceBundle; import java.util.ResourceBundle;
public class Main extends JFrame { public class Main extends JFrame {
// Version numbers for update check // Version numbers for update check
public static final int currentVersion = 190; public static final int currentVersion = 191;
public static int latestVersion = currentVersion; public static int latestVersion = currentVersion;
public static ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text"); public static ResourceBundle resourceBundle = ResourceBundle.getBundle("de.marcelkapfer.c.morseconverter.text");
@ -53,9 +58,21 @@ public class Main extends JFrame {
private JTextArea outputAreaNormalMorse; private JTextArea outputAreaNormalMorse;
private JButton updateDialogButton; private JButton updateDialogButton;
private JLabel updateAvailable; private JLabel updateAvailable;
private JTextPane aboutText;
// Contains mainly listeners // Contains mainly listeners
public Main() { public Main() {
HTMLEditorKit htmlEditorKit = new HTMLEditorKit();
HTMLDocument htmlDocument = (HTMLDocument) htmlEditorKit.createDefaultDocument();
Element element = htmlDocument.getDefaultRootElement();
try {
htmlDocument.setInnerHTML(element, resourceBundle.getString("about"));
} catch (BadLocationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
aboutText.setDocument(htmlDocument);
// Listener for the writtenMorse input field // Listener for the writtenMorse input field
inputAreaWrittenMorse.addKeyListener(new KeyAdapter() { inputAreaWrittenMorse.addKeyListener(new KeyAdapter() {
@Override @Override
@ -108,6 +125,7 @@ public class Main extends JFrame {
main.setIconImage(Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/res/icon-xxxhdpi.png"))); main.setIconImage(Toolkit.getDefaultToolkit().getImage(Main.class.getResource("/res/icon-xxxhdpi.png")));
// MAKE IT HAPPEN :D // MAKE IT HAPPEN :D
main.setVisible(true); main.setVisible(true);
System.out.print(System.lineSeparator());
} }
// Method for converting writtenMorse // Method for converting writtenMorse

View File

@ -65,7 +65,12 @@ public class DecodeNormalMorseManager {
input.delete(0, 1); input.delete(0, 1);
} else if(input.toString().startsWith(System.lineSeparator())) { } else if(input.toString().startsWith(System.lineSeparator())) {
output.append(System.lineSeparator()); output.append(System.lineSeparator());
input.deleteCharAt(input.indexOf(System.lineSeparator())); int indexLineSeparator = input.indexOf(System.lineSeparator());
input.delete(indexLineSeparator, indexLineSeparator + System.lineSeparator().length());
} else if (input.toString().startsWith("\n")) {
output.append(System.lineSeparator());
int indexLineSeparator = input.indexOf("\n");
input.deleteCharAt(indexLineSeparator);
} else if (input.toString().startsWith("A")) { } else if (input.toString().startsWith("A")) {
output.append(".- "); output.append(".- ");
input.delete(0, 1); input.delete(0, 1);
@ -235,7 +240,7 @@ public class DecodeNormalMorseManager {
output.append("...-..- "); output.append("...-..- ");
input.delete(0, 1); input.delete(0, 1);
} else { } else {
output.replace(0, output.length(), "Code not listed or wrong."); return "Code not listed or wrong.";
} }
} }
if (output.toString().endsWith(" ")) { if (output.toString().endsWith(" ")) {

View File

@ -64,9 +64,14 @@ public class DecodeWrittenMorseManager {
} }
output.append("+"); output.append("+");
input.delete(0, 1); input.delete(0, 1);
} else if(input.toString().startsWith(System.lineSeparator())) { } else if (input.toString().startsWith(System.lineSeparator())) {
output.append(System.lineSeparator()); output.append(System.lineSeparator());
input.deleteCharAt(input.indexOf(System.lineSeparator())); int indexLineSeparator = input.indexOf(System.lineSeparator());
input.delete(indexLineSeparator, indexLineSeparator + System.lineSeparator().length());
} else if (input.toString().startsWith("\n")) {
output.append(System.lineSeparator());
int indexLineSeparator = input.indexOf("\n");
input.deleteCharAt(indexLineSeparator);
} else if (input.toString().startsWith("A")) { } else if (input.toString().startsWith("A")) {
output.append("01#"); output.append("01#");
input.delete(0, 1); input.delete(0, 1);
@ -236,7 +241,7 @@ public class DecodeWrittenMorseManager {
output.append("0001001#"); output.append("0001001#");
input.delete(0, 1); input.delete(0, 1);
} else { } else {
output.replace(0, output.length(), "Code not listed or wrong."); return "Code not listed or wrong.";
} }
} }
if (output.toString().endsWith("#")) { if (output.toString().endsWith("#")) {

View File

@ -51,7 +51,11 @@ public class EncodeNormalMorseManager {
inputToSign.delete(d, d + 7); inputToSign.delete(d, d + 7);
} else if(inputToSign.toString().startsWith(System.lineSeparator())){ } else if(inputToSign.toString().startsWith(System.lineSeparator())){
output.append(System.lineSeparator()); output.append(System.lineSeparator());
inputToSign.deleteCharAt(0); inputToSign.delete(0, System.lineSeparator().length());
} else if (input.toString().startsWith("\n")) {
output.append(System.lineSeparator());
int indexLineSeparator = input.indexOf("\n");
inputToSign.deleteCharAt(indexLineSeparator);
} else if (inputToSign.toString().substring(d, d + 3).equals(" ")) { } else if (inputToSign.toString().substring(d, d + 3).equals(" ")) {
if (d == 0) { if (d == 0) {
inputToSign.delete(0, 3); inputToSign.delete(0, 3);
@ -190,7 +194,7 @@ public class EncodeNormalMorseManager {
} else if (sign.toString().equals("........")) { } else if (sign.toString().equals("........")) {
output.append("Error"); output.append("Error");
} else { } else {
output.replace(0, output.length(), "Code not listed or wrong."); return "Code not listed or wrong.";
} }
} }
return output.toString(); return output.toString();

View File

@ -51,11 +51,20 @@ public class EncodeWrittenMorseManager {
if (d == 0) { if (d == 0) {
if (inputToSign.toString().startsWith("+")) { if (inputToSign.toString().startsWith("+")) {
output.append(" "); output.append(" ");
inputToSign.deleteCharAt(0);
} }
if (inputToSign.toString().startsWith(System.lineSeparator())){ if (inputToSign.toString().startsWith(System.lineSeparator())){
output.append(System.lineSeparator()); output.append(System.lineSeparator());
inputToSign.delete(0, System.lineSeparator().length());
} }
if (inputToSign.toString().startsWith("#")){
inputToSign.deleteCharAt(0); inputToSign.deleteCharAt(0);
}
if (input.toString().startsWith("\n")) {
output.append(System.lineSeparator());
int indexLineSeparator = input.indexOf("\n");
inputToSign.deleteCharAt(indexLineSeparator);
}
} else { } else {
sign.replace(0, sign.length(), inputToSign sign.replace(0, sign.length(), inputToSign
.toString().substring(0, d)); .toString().substring(0, d));
@ -191,7 +200,7 @@ public class EncodeWrittenMorseManager {
} else if (sign.toString().equals("00000000")) { } else if (sign.toString().equals("00000000")) {
output.append("Error"); output.append("Error");
} else { } else {
output.replace(0, output.length(), "Code not listed or wrong."); return "Code not listed or wrong.";
} }
} }
return output.toString(); return output.toString();

2
src/de/marcelkapfer/c/morseconverter/text.properties Normal file → Executable file
View File

@ -1,4 +1,4 @@
about=<html>\n<head>\n</head>\n<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.0 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Developer</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Contact</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>License</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Bug</b><br>If you found a bug, please write me a mail to marcelmichaelkapfer@yahoo.co.nz with a short description of the problem.\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>You can find a detailed guide on marcel-kapfer.de/writtenmorse/\#howto_desktop\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Missing Code</b><br>If you discovered, that a code is missing, then write me a mail to marcelmichaelkapfer@yahoo.co.nz and tell me about it.\n</p>\n</p>\n</body>\n</html> about=<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.1 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Developer</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Contact</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>License</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Bug</b><br>If you found a bug, please write me a mail to marcelmichaelkapfer@yahoo.co.nz with a short description of the problem.\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>You can find a detailed guide on marcel-kapfer.de/writtenmorse/\#howto_desktop\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Missing Code</b><br>If you discovered, that a code is missing, then write me a mail to marcelmichaelkapfer@yahoo.co.nz and tell me about it.\n</p>\n</p>\n</body>
aboutUpdateAvailable=Update available aboutUpdateAvailable=Update available
aboutUpdateAvailableButton=Install Update aboutUpdateAvailableButton=Install Update
inputText=Enter your text inputText=Enter your text

View File

@ -1,4 +1,4 @@
about=<html>\n<head>\n</head>\n<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.0 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Entwickler</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Kontakt</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Lizenz</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehler</b><br>Wenn Du einen Fehler gefunden hast, schreibe mir bitte ein E-Mail an marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>Du kannst eine ausführliche Anleitung auf marcel-kapfer.de/writtenmorse/\#howto_android finden.\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehlender Code</b><br>Wenn Du auf einen fehlenden Code aufmerksam geworden bist, dann schreibe eine E-Mail an marcelmichaelkapfer@yahoo.co.nz.\n</p>\n</p>\n</body>\n</html> about=<body style\="font-family\: sans-serif">\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Version</b><br>1.9.1 alpha\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Entwickler</b><br>Marcel Michael Kapfer\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Website</b><br>marcel-kapfer.de/writtenmorse\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Kontakt</b><br>marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Lizenz</b><br>GNU GPL v3.0\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehler</b><br>Wenn Du einen Fehler gefunden hast, schreibe mir bitte ein E-Mail an marcelmichaelkapfer@yahoo.co.nz\n</p>\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>How to</b><br>Du kannst eine ausführliche Anleitung auf marcel-kapfer.de/writtenmorse/\#howto_android finden.\n<p style\="margin-top\: 5px; margin-right\: 5px; margin-bottom\: 5px; margin-left\: 5px">\n<b>Fehlender Code</b><br>Wenn Du auf einen fehlenden Code aufmerksam geworden bist, dann schreibe eine E-Mail an marcelmichaelkapfer@yahoo.co.nz.\n</p>\n</p>\n</body>
aboutUpdateAvailable=Update verfügbar aboutUpdateAvailable=Update verfügbar
aboutUpdateAvailableButton=Update installieren aboutUpdateAvailableButton=Update installieren
inputText=Geben Sie einen Text ein inputText=Geben Sie einen Text ein

View File

View File

View File