diff --git a/app/app.iml b/app/app.iml
index 84fb8dd..939c9cf 100644
--- a/app/app.iml
+++ b/app/app.iml
@@ -52,6 +52,7 @@
+
diff --git a/app/build.gradle b/app/build.gradle
index 60dc879..85d73ea 100644
--- a/app/build.gradle
+++ b/app/build.gradle
@@ -17,6 +17,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
+ sourceSets { main { java.srcDirs = ['src/main/java', 'src/main/java/engine'] } }
}
repositories {
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java b/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java
index f7c214c..efa2bc4 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/MainActivity.java
@@ -21,7 +21,6 @@ package de.marcelkapfer.morseconverter;
*/
-import android.app.Notification;
import android.content.ClipData;
import android.content.ClipboardManager;
import android.content.Context;
@@ -29,20 +28,25 @@ import android.content.Intent;
import android.content.res.Resources;
import android.net.Uri;
import android.os.Bundle;
-import android.support.v4.widget.DrawerLayout;
-import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.CardView;
import android.view.View;
import android.view.inputmethod.InputMethodManager;
import android.widget.EditText;
import android.widget.TextView;
+import de.marcelkapfer.morseconverter.engine.DecodeNormalMorseManager;
+import de.marcelkapfer.morseconverter.engine.DecodeWrittenMorseManager;
+import de.marcelkapfer.morseconverter.engine.EncodeNormalMorseManager;
+import de.marcelkapfer.morseconverter.engine.EncodeWrittenMorseManager;
+import de.marcelkapfer.morseconverter.fragments.AboutFragment;
+import de.marcelkapfer.morseconverter.fragments.MainFragment;
+import de.marcelkapfer.morseconverter.fragments.MorseFragment;
+import de.marcelkapfer.morseconverter.fragments.writtenMorseListFragment;
+
import it.neokree.materialnavigationdrawer.MaterialNavigationDrawer;
import it.neokree.materialnavigationdrawer.elements.MaterialSection;
import it.neokree.materialnavigationdrawer.util.MaterialActionBarDrawerToggle;
-import static android.view.inputmethod.InputMethodManager.*;
-
public class MainActivity extends MaterialNavigationDrawer {
@@ -79,6 +83,7 @@ public class MainActivity extends MaterialNavigationDrawer {
public void onDrawerOpened(View view){
super.onDrawerOpened(view);
+ // This closes the soft keyboard, when the drawer is opened
try {
InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE);
@@ -108,8 +113,7 @@ public class MainActivity extends MaterialNavigationDrawer {
if(cardView.getVisibility() == View.INVISIBLE){
cardView.setVisibility(View.VISIBLE);
}
- EncodeNormalMorseManager message = new EncodeNormalMorseManager(input.getText().toString());
- output.setText(message.getEncodedString());
+ output.setText(EncodeNormalMorseManager.getEncodedString(input.getText().toString()));
} catch (Exception e){
e.printStackTrace();
}
@@ -123,8 +127,8 @@ public class MainActivity extends MaterialNavigationDrawer {
if(cardView.getVisibility() == View.INVISIBLE){
cardView.setVisibility(View.VISIBLE);
}
- DecodeNormalMorseManager message = new DecodeNormalMorseManager(input.getText().toString());
- output.setText(message.getDecodedString());
+ output.setText(DecodeNormalMorseManager.getDecodedString(input.getText().toString()));
+
} catch (Exception e){
e.printStackTrace();
}
@@ -138,8 +142,7 @@ public class MainActivity extends MaterialNavigationDrawer {
if(cardView.getVisibility() == View.INVISIBLE){
cardView.setVisibility(View.VISIBLE);
}
- EncodeWrittenMorseManager message = new EncodeWrittenMorseManager(input.getText().toString());
- output.setText(message.getEncodedString());
+ output.setText(EncodeWrittenMorseManager.getEncodedString(input.getText().toString()));
} catch (Exception e){
e.printStackTrace();
}
@@ -153,13 +156,13 @@ public class MainActivity extends MaterialNavigationDrawer {
if(cardView.getVisibility() == View.INVISIBLE){
cardView.setVisibility(View.VISIBLE);
}
- DecodeWrittenMorseManager message = new DecodeWrittenMorseManager(input.getText().toString());
- output.setText(message.getDecodedString());
+ output.setText(DecodeWrittenMorseManager.getDecodedString(input.getText().toString()));
} catch (Exception e){
e.printStackTrace();
}
}
+
//called when clicking on the version entry in the about fragment
//opens the app page (de.marcelkapfer.morseconverter)
public void versionEntry(View view){
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/MyAdapter.java b/app/src/main/java/de/marcelkapfer/morseconverter/adapter/WrittenMorseCodeAdapter.java
similarity index 80%
rename from app/src/main/java/de/marcelkapfer/morseconverter/MyAdapter.java
rename to app/src/main/java/de/marcelkapfer/morseconverter/adapter/WrittenMorseCodeAdapter.java
index f637714..8d6f233 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/MyAdapter.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/adapter/WrittenMorseCodeAdapter.java
@@ -1,4 +1,4 @@
-package de.marcelkapfer.morseconverter;
+package de.marcelkapfer.morseconverter.adapter;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
@@ -6,10 +6,12 @@ import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
+import de.marcelkapfer.morseconverter.R;
+
/**
* Created by mmk on 3/30/15.
*/
-public class MyAdapter extends RecyclerView.Adapter {
+public class WrittenMorseCodeAdapter extends RecyclerView.Adapter {
private String[] mLetter;
private String[] mCode;
private static String mType = "LETTER";
@@ -26,13 +28,13 @@ public class MyAdapter extends RecyclerView.Adapter {
}
- public MyAdapter(String[] myLetter, String[] myCode) {
+ public WrittenMorseCodeAdapter(String[] myLetter, String[] myCode) {
mLetter = myLetter;
mCode = myCode;
}
@Override
- public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
+ public WrittenMorseCodeAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) {
// create a new view
View v = LayoutInflater.from(parent.getContext())
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/DecodeNormalMorseManager.java b/app/src/main/java/de/marcelkapfer/morseconverter/engine/DecodeNormalMorseManager.java
similarity index 96%
rename from app/src/main/java/de/marcelkapfer/morseconverter/DecodeNormalMorseManager.java
rename to app/src/main/java/de/marcelkapfer/morseconverter/engine/DecodeNormalMorseManager.java
index 4b5233e..a92116a 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/DecodeNormalMorseManager.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/engine/DecodeNormalMorseManager.java
@@ -1,4 +1,4 @@
-package de.marcelkapfer.morseconverter;
+package de.marcelkapfer.morseconverter.engine;
/*
This is a Android application for converting writtenMorse and normal morse code.
@@ -23,31 +23,12 @@ package de.marcelkapfer.morseconverter;
public class DecodeNormalMorseManager {
- private String inputMessage;
-
- DecodeNormalMorseManager(String string) {
- inputMessage = string;
- }
-
- public void setString(String string) {
- inputMessage = string;
- }
-
- public String getString() {
- return inputMessage;
- }
-
- /*
- * Code for converting normal letters into morse code
- */
-
- public String getDecodedString() {
+ public static String getDecodedString(String inputMessage) {
StringBuffer message = new StringBuffer(inputMessage);
if (message.toString().endsWith(" ")) {
message = message.deleteCharAt(message.length() - 1);
}
// Variables
- // Variables
StringBuffer input = new StringBuffer();
input = input.replace(0, input.length(), message.toString().toUpperCase());
StringBuffer output = new StringBuffer();
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/DecodeWrittenMorseManager.java b/app/src/main/java/de/marcelkapfer/morseconverter/engine/DecodeWrittenMorseManager.java
similarity index 96%
rename from app/src/main/java/de/marcelkapfer/morseconverter/DecodeWrittenMorseManager.java
rename to app/src/main/java/de/marcelkapfer/morseconverter/engine/DecodeWrittenMorseManager.java
index 6347f24..fec2983 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/DecodeWrittenMorseManager.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/engine/DecodeWrittenMorseManager.java
@@ -1,4 +1,4 @@
-package de.marcelkapfer.morseconverter;
+package de.marcelkapfer.morseconverter.engine;
/*
This is a Android application for converting writtenMorse and normal morse code.
@@ -23,24 +23,7 @@ package de.marcelkapfer.morseconverter;
public class DecodeWrittenMorseManager {
- private String inputMessage;
-
- DecodeWrittenMorseManager(String string) {
- inputMessage = string;
- }
-
- public void setString(String string) {
- inputMessage = string;
- }
-
- public String getString() {
- return inputMessage;
- }
-
- /*
- * Code for converting latin letters into written morse
- */
- public String getDecodedString() {
+ public static String getDecodedString(String inputMessage) {
StringBuffer message = new StringBuffer(inputMessage);
if (message.toString().endsWith(" ")) {
message = message.deleteCharAt(message.length() - 1);
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/EncodeNormalMorseManager.java b/app/src/main/java/de/marcelkapfer/morseconverter/engine/EncodeNormalMorseManager.java
similarity index 96%
rename from app/src/main/java/de/marcelkapfer/morseconverter/EncodeNormalMorseManager.java
rename to app/src/main/java/de/marcelkapfer/morseconverter/engine/EncodeNormalMorseManager.java
index 9de31c3..fea22da 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/EncodeNormalMorseManager.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/engine/EncodeNormalMorseManager.java
@@ -1,4 +1,4 @@
-package de.marcelkapfer.morseconverter;
+package de.marcelkapfer.morseconverter.engine;
/*
This is a Android application for converting writtenMorse and normal morse code.
@@ -26,22 +26,7 @@ package de.marcelkapfer.morseconverter;
*/
public class EncodeNormalMorseManager {
- private String inputMessage;
-
- EncodeNormalMorseManager(String string) {
- inputMessage = string;
- }
-
- public void setString(String string){
- inputMessage = string;
- }
-
- public String getString(){
- return inputMessage;
- }
-
-
- public String getEncodedString() {
+ public static String getEncodedString(String inputMessage) {
// Converts the input string into a StringBuffer
StringBuffer message = new StringBuffer(inputMessage);
// Delete the space at the end which is automatically set through some keyboards
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/EncodeWrittenMorseManager.java b/app/src/main/java/de/marcelkapfer/morseconverter/engine/EncodeWrittenMorseManager.java
similarity index 96%
rename from app/src/main/java/de/marcelkapfer/morseconverter/EncodeWrittenMorseManager.java
rename to app/src/main/java/de/marcelkapfer/morseconverter/engine/EncodeWrittenMorseManager.java
index de027a8..db00874 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/EncodeWrittenMorseManager.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/engine/EncodeWrittenMorseManager.java
@@ -1,4 +1,4 @@
-package de.marcelkapfer.morseconverter;
+package de.marcelkapfer.morseconverter.engine;
/*
This is a Android application for converting writtenMorse and normal morse code.
@@ -27,21 +27,7 @@ package de.marcelkapfer.morseconverter;
public class EncodeWrittenMorseManager {
- private String inputMessage;
-
- EncodeWrittenMorseManager(String string){
- inputMessage = string;
- }
-
- public String getString(){
- return inputMessage;
- }
-
- public void setString(String string){
- inputMessage = string;
- }
-
- public String getEncodedString() {
+ public static String getEncodedString(String inputMessage) {
StringBuffer message = new StringBuffer(inputMessage);
if (message.toString().endsWith(" ")) {
message = message.deleteCharAt(message.length() - 1);
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/AboutFragment.java b/app/src/main/java/de/marcelkapfer/morseconverter/fragments/AboutFragment.java
similarity index 93%
rename from app/src/main/java/de/marcelkapfer/morseconverter/AboutFragment.java
rename to app/src/main/java/de/marcelkapfer/morseconverter/fragments/AboutFragment.java
index 2865029..16830f0 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/AboutFragment.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/fragments/AboutFragment.java
@@ -1,4 +1,4 @@
-package de.marcelkapfer.morseconverter;
+package de.marcelkapfer.morseconverter.fragments;
/*
This is a Android application for converting writtenMorse and normal morse code.
@@ -27,6 +27,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import de.marcelkapfer.morseconverter.R;
+
/**
* Created by mmk on 2/14/15.
*/
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/MainFragment.java b/app/src/main/java/de/marcelkapfer/morseconverter/fragments/MainFragment.java
similarity index 93%
rename from app/src/main/java/de/marcelkapfer/morseconverter/MainFragment.java
rename to app/src/main/java/de/marcelkapfer/morseconverter/fragments/MainFragment.java
index cec167a..4b49a4b 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/MainFragment.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/fragments/MainFragment.java
@@ -1,4 +1,4 @@
-package de.marcelkapfer.morseconverter;
+package de.marcelkapfer.morseconverter.fragments;
/*
This is a Android application for converting writtenMorse and normal morse code.
@@ -27,6 +27,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import de.marcelkapfer.morseconverter.R;
+
/**
* Created by mmk on 2/14/15.
*/
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/MorseFragment.java b/app/src/main/java/de/marcelkapfer/morseconverter/fragments/MorseFragment.java
similarity index 93%
rename from app/src/main/java/de/marcelkapfer/morseconverter/MorseFragment.java
rename to app/src/main/java/de/marcelkapfer/morseconverter/fragments/MorseFragment.java
index a1930c1..26b64a8 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/MorseFragment.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/fragments/MorseFragment.java
@@ -1,4 +1,4 @@
-package de.marcelkapfer.morseconverter;
+package de.marcelkapfer.morseconverter.fragments;
/*
This is a Android application for converting writtenMorse and normal morse code.
@@ -27,6 +27,8 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
+import de.marcelkapfer.morseconverter.R;
+
/**
* Created by mmk on 2/14/15.
*/
diff --git a/app/src/main/java/de/marcelkapfer/morseconverter/writtenMorseListFragment.java b/app/src/main/java/de/marcelkapfer/morseconverter/fragments/writtenMorseListFragment.java
similarity index 92%
rename from app/src/main/java/de/marcelkapfer/morseconverter/writtenMorseListFragment.java
rename to app/src/main/java/de/marcelkapfer/morseconverter/fragments/writtenMorseListFragment.java
index 1f5f927..1e6e8ca 100644
--- a/app/src/main/java/de/marcelkapfer/morseconverter/writtenMorseListFragment.java
+++ b/app/src/main/java/de/marcelkapfer/morseconverter/fragments/writtenMorseListFragment.java
@@ -1,4 +1,4 @@
-package de.marcelkapfer.morseconverter;
+package de.marcelkapfer.morseconverter.fragments;
import android.content.res.AssetManager;
import android.os.Bundle;
@@ -14,7 +14,9 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
-import java.util.StringTokenizer;
+
+import de.marcelkapfer.morseconverter.adapter.WrittenMorseCodeAdapter;
+import de.marcelkapfer.morseconverter.R;
public class writtenMorseListFragment extends Fragment {
@@ -40,7 +42,7 @@ public class writtenMorseListFragment extends Fragment {
mLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLayoutManager);
getDataset();
- mAdapter = new MyAdapter(myLetter, myCode);
+ mAdapter = new WrittenMorseCodeAdapter(myLetter, myCode);
mRecyclerView.setAdapter(mAdapter);
return rootView;
}
diff --git a/app/src/main/res/values-v19/styles.xml b/app/src/main/res/values-v19/styles.xml
index 5bc185f..0bcdca5 100644
--- a/app/src/main/res/values-v19/styles.xml
+++ b/app/src/main/res/values-v19/styles.xml
@@ -27,7 +27,7 @@
- @color/colorPrimary
- @color/colorPrimaryDark
- - @color/white
+ - @color/colorPrimary
- @integer/DRAWERTYPE_IMAGE
- true
- true
diff --git a/app/src/main/res/values/styles.xml b/app/src/main/res/values/styles.xml
index 81a6944..e29b1b1 100644
--- a/app/src/main/res/values/styles.xml
+++ b/app/src/main/res/values/styles.xml
@@ -27,7 +27,7 @@
- @color/colorPrimary
- @color/colorPrimaryDark
- - @color/white
+ - @color/colorPrimary
- @integer/DRAWERTYPE_IMAGE
- true
- true