diff --git a/.idea/libraries/support_v4_19_1_0.xml b/.idea/libraries/support_v4_19_1_0.xml
index 8ccc0a7..76c7304 100644
--- a/.idea/libraries/support_v4_19_1_0.xml
+++ b/.idea/libraries/support_v4_19_1_0.xml
@@ -1,11 +1,11 @@
-
+
-
+
\ No newline at end of file
diff --git a/.idea/vcs.xml b/.idea/vcs.xml
index def6a6a..c80f219 100644
--- a/.idea/vcs.xml
+++ b/.idea/vcs.xml
@@ -1,7 +1,7 @@
-
+
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index f5976f8..d25853b 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -35,7 +35,12 @@
-
+
+
+
+
+
+
@@ -59,15 +64,15 @@
-
-
-
+
+
+
@@ -133,31 +138,33 @@
-
+
-
+
-
-
-
+
+
+
+
+
+
+
-
+
-
+
-
-
-
+
@@ -754,12 +761,15 @@
-
-
-
-
+
+
-
+
+
+
+
+
+
@@ -785,7 +795,9 @@
+
+
@@ -794,172 +806,8 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -979,6 +827,7 @@
+
@@ -1151,25 +1000,26 @@
-
-
+
+
+
-
+
-
+
@@ -1179,7 +1029,6 @@
-
@@ -1230,32 +1079,53 @@
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
+
@@ -1581,17 +1451,6 @@
-
-
-
-
-
-
-
-
-
-
-
@@ -1639,20 +1498,33 @@
-
-
-
-
+
+
+
+
+
+
+
-
+
+
+
+
+
+
+
+
+
+
+
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java b/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java
index 5301e0f..79f0de4 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java
@@ -29,7 +29,7 @@ public class MainActivity extends FragmentActivity {
public String[] fragments = new String[] {"R.id.main", "R.id.morse", "R.id.about"};
private static int[] fragment = new int[] {R.layout.fragment_main, R.layout.fragment_morse, R.layout.fragment_about };
public static int mainPosition;
-
+
public final static String EXTRA_MESSAGE = "de.marcelkapfer.morseconverter.MESSAGE";
public String tfOutput = "";
int lastFragment = 0;
@@ -91,22 +91,22 @@ public class MainActivity extends FragmentActivity {
private class DrawerItemClickListener implements ListView.OnItemClickListener {
@Override
public void onItemClick(AdapterView> parent, View view, int position, long id) {
-
+
changeFragment(position);
mainPosition = position;
}
-
+
}
public void changeFragment(int position){
-
+
fragment_main newFragment = new fragment_main();
Bundle args = new Bundle();
args.putInt(fragments[position], position);
newFragment.setArguments(args);
-
+
// Insert the fragment by replacing any existing fragment
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
@@ -155,13 +155,13 @@ public class MainActivity extends FragmentActivity {
mDrawerToggle.onConfigurationChanged(newConfig);
}
-
+
public static class fragment_main extends Fragment {
public static final String ARG_POSITION = "menu_number";
-
+
public fragment_main() {
// Empty subclass required for fragment subclass
}
@@ -177,7 +177,7 @@ public class MainActivity extends FragmentActivity {
}
}
-
+
/*
* Code for converting latin letters into written morse
*/
@@ -226,8 +226,12 @@ public class MainActivity extends FragmentActivity {
After(view);
} else {
for (int c = input.length(); c > 0; c--) {
+
if (input.toString().startsWith(" ")) {
- output.append("+");
+ if(output.toString().endsWith("#")){
+ output.delete(output.length() -1 , output.length());
+ }
+ output.append("+");
input.delete(0, 1);
} else if (input.toString().startsWith("A")) {
output.append("01#");
@@ -401,10 +405,9 @@ public class MainActivity extends FragmentActivity {
tfOutput = "Code not listed or wrong.";
}
}
- if (output.toString().endsWith("#")
- && (output.toString().equals("#") == false)) {
- output.delete(output.length() - 1, output.length());
- }
+ if(output.toString().endsWith("#")){
+ output.delete(output.length() -1 , output.length());
+ }
tfOutput = output.toString();
lastFragment = 0;
After(view);
@@ -631,12 +634,15 @@ public class MainActivity extends FragmentActivity {
tfOutput = " ";
After(view);
} else if (input.toString().equals("WORD SPACE")) {
- tfOutput = " ";
+ tfOutput = " ";
After(view);
} else {
for (int c = input.length(); c > 0; c--) {
if (input.toString().startsWith(" ")) {
- output.append(" ");
+ if(output.toString().endsWith(" ")){
+ output.delete(output.length() - 3 , output.length());
+ }
+ output.append(" ");
input.delete(0, 1);
} else if (input.toString().startsWith("A")) {
output.append(".- ");
@@ -810,10 +816,9 @@ public class MainActivity extends FragmentActivity {
tfOutput = "Code not listed or wrong.";
}
}
- if (output.toString().endsWith(" ")
- && (output.toString().equals(" ") == false)) {
- output.delete(output.length() - 3, output.length());
- }
+ if(output.toString().endsWith(" ")){
+ output.delete(output.length() - 3 , output.length());
+ }
tfOutput = output.toString();
lastFragment = 1;
After(view);
@@ -829,33 +834,32 @@ public class MainActivity extends FragmentActivity {
if (message.toString().endsWith(" ")){
message = message.deleteCharAt(message.length() - 1);
}
- // Variables
- String input;
- StringBuffer output = new StringBuffer();
- input = message.toString().toUpperCase() + "#";
- StringBuffer inputToSign = new StringBuffer(input);
- while (inputToSign.toString().equals("#") == false) {
- int d = 0;
- boolean signFull = true;
- StringBuffer sign = new StringBuffer();
- while (signFull) {
- if (inputToSign.toString().charAt(d) == '+'
- || inputToSign.toString().charAt(d) == '#') {
- if (d == 0) {
- if (inputToSign.toString().startsWith("+")) {
- output.append(" ");
- }
- inputToSign.deleteCharAt(0);
- } else {
- sign.replace(0, sign.length(), inputToSign
- .toString().substring(0, d));
- inputToSign.delete(0, d);
- signFull = false;
- }
- } else {
- d++;
- }
- }
+ String input;
+ StringBuffer output = new StringBuffer();
+ input = message.toString().toUpperCase() + "#";
+ StringBuffer inputToSign = new StringBuffer(input);
+ while (!message.toString().equals(" ")) {
+ int d = 0;
+ boolean signFull = true;
+ StringBuffer sign = new StringBuffer();
+ while (signFull) {
+ if (inputToSign.toString().startsWith(" ")) {
+ output.append(" ");
+ inputToSign.delete(d, d + 9);
+ } else if (inputToSign.toString().substring(d, d + 3)
+ .equals(" ")) {
+ if (d == 0) {
+ inputToSign.delete(0, 3);
+ } else {
+ sign.replace(0, sign.length(), inputToSign
+ .toString().substring(0, d));
+ inputToSign.delete(0, d);
+ signFull = false;
+ }
+ } else {
+ d++;
+ }
+ }
if (sign.toString().equals(".-")) {
output.append("A");
} else if (sign.toString().equals("-...")) {
@@ -989,7 +993,7 @@ public class MainActivity extends FragmentActivity {
After(view);
}
-
+
public void After(View view){
Intent intent = new Intent(this, DisplayMessageActivity.class);
intent.putExtra(EXTRA_MESSAGE, tfOutput );