Better Folder & File Structure

This commit is contained in:
mmk2410 2015-04-01 01:12:08 +02:00
parent cf18cbf7b4
commit 93bf3f101c
14 changed files with 48 additions and 98 deletions

View file

@ -52,6 +52,7 @@
<sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/main/assets" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/aidl" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java/engine" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/jni" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" /> <sourceFolder url="file://$MODULE_DIR$/src/main/rs" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" /> <sourceFolder url="file://$MODULE_DIR$/src/androidTest/res" type="java-test-resource" />

View file

@ -17,6 +17,7 @@ android {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
sourceSets { main { java.srcDirs = ['src/main/java', 'src/main/java/engine'] } }
} }
repositories { repositories {

View file

@ -21,7 +21,6 @@ package de.marcelkapfer.morseconverter;
*/ */
import android.app.Notification;
import android.content.ClipData; import android.content.ClipData;
import android.content.ClipboardManager; import android.content.ClipboardManager;
import android.content.Context; import android.content.Context;
@ -29,20 +28,25 @@ import android.content.Intent;
import android.content.res.Resources; import android.content.res.Resources;
import android.net.Uri; import android.net.Uri;
import android.os.Bundle; import android.os.Bundle;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.ActionBarDrawerToggle;
import android.support.v7.widget.CardView; import android.support.v7.widget.CardView;
import android.view.View; import android.view.View;
import android.view.inputmethod.InputMethodManager; import android.view.inputmethod.InputMethodManager;
import android.widget.EditText; import android.widget.EditText;
import android.widget.TextView; 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.MaterialNavigationDrawer;
import it.neokree.materialnavigationdrawer.elements.MaterialSection; import it.neokree.materialnavigationdrawer.elements.MaterialSection;
import it.neokree.materialnavigationdrawer.util.MaterialActionBarDrawerToggle; import it.neokree.materialnavigationdrawer.util.MaterialActionBarDrawerToggle;
import static android.view.inputmethod.InputMethodManager.*;
public class MainActivity extends MaterialNavigationDrawer { public class MainActivity extends MaterialNavigationDrawer {
@ -79,6 +83,7 @@ public class MainActivity extends MaterialNavigationDrawer {
public void onDrawerOpened(View view){ public void onDrawerOpened(View view){
super.onDrawerOpened(view); super.onDrawerOpened(view);
// This closes the soft keyboard, when the drawer is opened
try { try {
InputMethodManager imm = (InputMethodManager) getSystemService( InputMethodManager imm = (InputMethodManager) getSystemService(
Context.INPUT_METHOD_SERVICE); Context.INPUT_METHOD_SERVICE);
@ -108,8 +113,7 @@ public class MainActivity extends MaterialNavigationDrawer {
if(cardView.getVisibility() == View.INVISIBLE){ if(cardView.getVisibility() == View.INVISIBLE){
cardView.setVisibility(View.VISIBLE); cardView.setVisibility(View.VISIBLE);
} }
EncodeNormalMorseManager message = new EncodeNormalMorseManager(input.getText().toString()); output.setText(EncodeNormalMorseManager.getEncodedString(input.getText().toString()));
output.setText(message.getEncodedString());
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -123,8 +127,8 @@ public class MainActivity extends MaterialNavigationDrawer {
if(cardView.getVisibility() == View.INVISIBLE){ if(cardView.getVisibility() == View.INVISIBLE){
cardView.setVisibility(View.VISIBLE); cardView.setVisibility(View.VISIBLE);
} }
DecodeNormalMorseManager message = new DecodeNormalMorseManager(input.getText().toString()); output.setText(DecodeNormalMorseManager.getDecodedString(input.getText().toString()));
output.setText(message.getDecodedString());
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -138,8 +142,7 @@ public class MainActivity extends MaterialNavigationDrawer {
if(cardView.getVisibility() == View.INVISIBLE){ if(cardView.getVisibility() == View.INVISIBLE){
cardView.setVisibility(View.VISIBLE); cardView.setVisibility(View.VISIBLE);
} }
EncodeWrittenMorseManager message = new EncodeWrittenMorseManager(input.getText().toString()); output.setText(EncodeWrittenMorseManager.getEncodedString(input.getText().toString()));
output.setText(message.getEncodedString());
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
@ -153,13 +156,13 @@ public class MainActivity extends MaterialNavigationDrawer {
if(cardView.getVisibility() == View.INVISIBLE){ if(cardView.getVisibility() == View.INVISIBLE){
cardView.setVisibility(View.VISIBLE); cardView.setVisibility(View.VISIBLE);
} }
DecodeWrittenMorseManager message = new DecodeWrittenMorseManager(input.getText().toString()); output.setText(DecodeWrittenMorseManager.getDecodedString(input.getText().toString()));
output.setText(message.getDecodedString());
} catch (Exception e){ } catch (Exception e){
e.printStackTrace(); e.printStackTrace();
} }
} }
//called when clicking on the version entry in the about fragment //called when clicking on the version entry in the about fragment
//opens the app page (de.marcelkapfer.morseconverter) //opens the app page (de.marcelkapfer.morseconverter)
public void versionEntry(View view){ public void versionEntry(View view){

View file

@ -1,4 +1,4 @@
package de.marcelkapfer.morseconverter; package de.marcelkapfer.morseconverter.adapter;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater; import android.view.LayoutInflater;
@ -6,10 +6,12 @@ import android.view.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import android.widget.TextView; import android.widget.TextView;
import de.marcelkapfer.morseconverter.R;
/** /**
* Created by mmk on 3/30/15. * Created by mmk on 3/30/15.
*/ */
public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> { public class WrittenMorseCodeAdapter extends RecyclerView.Adapter<WrittenMorseCodeAdapter.ViewHolder> {
private String[] mLetter; private String[] mLetter;
private String[] mCode; private String[] mCode;
private static String mType = "LETTER"; private static String mType = "LETTER";
@ -26,13 +28,13 @@ public class MyAdapter extends RecyclerView.Adapter<MyAdapter.ViewHolder> {
} }
public MyAdapter(String[] myLetter, String[] myCode) { public WrittenMorseCodeAdapter(String[] myLetter, String[] myCode) {
mLetter = myLetter; mLetter = myLetter;
mCode = myCode; mCode = myCode;
} }
@Override @Override
public MyAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, public WrittenMorseCodeAdapter.ViewHolder onCreateViewHolder(ViewGroup parent,
int viewType) { int viewType) {
// create a new view // create a new view
View v = LayoutInflater.from(parent.getContext()) View v = LayoutInflater.from(parent.getContext())

View file

@ -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. This is a Android application for converting writtenMorse and normal morse code.
@ -23,31 +23,12 @@ package de.marcelkapfer.morseconverter;
public class DecodeNormalMorseManager { public class DecodeNormalMorseManager {
private String inputMessage; public static String getDecodedString(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() {
StringBuffer message = new StringBuffer(inputMessage); StringBuffer message = new StringBuffer(inputMessage);
if (message.toString().endsWith(" ")) { if (message.toString().endsWith(" ")) {
message = message.deleteCharAt(message.length() - 1); message = message.deleteCharAt(message.length() - 1);
} }
// Variables // Variables
// Variables
StringBuffer input = new StringBuffer(); StringBuffer input = new StringBuffer();
input = input.replace(0, input.length(), message.toString().toUpperCase()); input = input.replace(0, input.length(), message.toString().toUpperCase());
StringBuffer output = new StringBuffer(); StringBuffer output = new StringBuffer();

View file

@ -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. This is a Android application for converting writtenMorse and normal morse code.
@ -23,24 +23,7 @@ package de.marcelkapfer.morseconverter;
public class DecodeWrittenMorseManager { public class DecodeWrittenMorseManager {
private String inputMessage; public static String getDecodedString(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() {
StringBuffer message = new StringBuffer(inputMessage); StringBuffer message = new StringBuffer(inputMessage);
if (message.toString().endsWith(" ")) { if (message.toString().endsWith(" ")) {
message = message.deleteCharAt(message.length() - 1); message = message.deleteCharAt(message.length() - 1);

View file

@ -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. This is a Android application for converting writtenMorse and normal morse code.
@ -26,22 +26,7 @@ package de.marcelkapfer.morseconverter;
*/ */
public class EncodeNormalMorseManager { public class EncodeNormalMorseManager {
private String inputMessage; public static String getEncodedString(String inputMessage) {
EncodeNormalMorseManager(String string) {
inputMessage = string;
}
public void setString(String string){
inputMessage = string;
}
public String getString(){
return inputMessage;
}
public String getEncodedString() {
// Converts the input string into a StringBuffer // Converts the input string into a StringBuffer
StringBuffer message = new StringBuffer(inputMessage); StringBuffer message = new StringBuffer(inputMessage);
// Delete the space at the end which is automatically set through some keyboards // Delete the space at the end which is automatically set through some keyboards

View file

@ -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. This is a Android application for converting writtenMorse and normal morse code.
@ -27,21 +27,7 @@ package de.marcelkapfer.morseconverter;
public class EncodeWrittenMorseManager { public class EncodeWrittenMorseManager {
private String inputMessage; public static String getEncodedString(String inputMessage) {
EncodeWrittenMorseManager(String string){
inputMessage = string;
}
public String getString(){
return inputMessage;
}
public void setString(String string){
inputMessage = string;
}
public String getEncodedString() {
StringBuffer message = new StringBuffer(inputMessage); StringBuffer message = new StringBuffer(inputMessage);
if (message.toString().endsWith(" ")) { if (message.toString().endsWith(" ")) {
message = message.deleteCharAt(message.length() - 1); message = message.deleteCharAt(message.length() - 1);

View file

@ -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. 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.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import de.marcelkapfer.morseconverter.R;
/** /**
* Created by mmk on 2/14/15. * Created by mmk on 2/14/15.
*/ */

View file

@ -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. 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.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import de.marcelkapfer.morseconverter.R;
/** /**
* Created by mmk on 2/14/15. * Created by mmk on 2/14/15.
*/ */

View file

@ -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. 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.View;
import android.view.ViewGroup; import android.view.ViewGroup;
import de.marcelkapfer.morseconverter.R;
/** /**
* Created by mmk on 2/14/15. * Created by mmk on 2/14/15.
*/ */

View file

@ -1,4 +1,4 @@
package de.marcelkapfer.morseconverter; package de.marcelkapfer.morseconverter.fragments;
import android.content.res.AssetManager; import android.content.res.AssetManager;
import android.os.Bundle; import android.os.Bundle;
@ -14,7 +14,9 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.StringTokenizer;
import de.marcelkapfer.morseconverter.adapter.WrittenMorseCodeAdapter;
import de.marcelkapfer.morseconverter.R;
public class writtenMorseListFragment extends Fragment { public class writtenMorseListFragment extends Fragment {
@ -40,7 +42,7 @@ public class writtenMorseListFragment extends Fragment {
mLayoutManager = new LinearLayoutManager(getActivity()); mLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setLayoutManager(mLayoutManager);
getDataset(); getDataset();
mAdapter = new MyAdapter(myLetter, myCode); mAdapter = new WrittenMorseCodeAdapter(myLetter, myCode);
mRecyclerView.setAdapter(mAdapter); mRecyclerView.setAdapter(mAdapter);
return rootView; return rootView;
} }

View file

@ -27,7 +27,7 @@
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/white</item> <item name="colorAccent">@color/colorPrimary</item>
<item name="drawerType">@integer/DRAWERTYPE_IMAGE</item> <item name="drawerType">@integer/DRAWERTYPE_IMAGE</item>
<item name="rippleBackport">true</item> <item name="rippleBackport">true</item>
<item name="toolbarElevation">true</item> <item name="toolbarElevation">true</item>

View file

@ -27,7 +27,7 @@
<!-- Customize your theme here. --> <!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item> <item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item> <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/white</item> <item name="colorAccent">@color/colorPrimary</item>
<item name="drawerType">@integer/DRAWERTYPE_IMAGE</item> <item name="drawerType">@integer/DRAWERTYPE_IMAGE</item>
<item name="rippleBackport">true</item> <item name="rippleBackport">true</item>
<item name="toolbarElevation">true</item> <item name="toolbarElevation">true</item>