Browse Source

bug fixes and comments

Julien Clauter 10 years ago
parent
commit
9ffd245e7b

+ 2 - 0
res/values-de/strings.xml

@@ -103,6 +103,8 @@
     <string name="discard">Verwerfen</string>
     <string name="save">Speichern</string>
     <string name="rec_protocol">Protokol</string>
+    <string name="ESSID">ESSID</string>
+    <string name="BSSID">BSSID</string>
     <string name="rec_sortby">Sortieren</string>
     <string name="rec_latest">Bis</string>
     <string name="rec_earliest">Von</string>

+ 2 - 0
res/values/strings.xml

@@ -103,6 +103,8 @@
     <string name="save">Save</string>
 	<string name="really_want_delete_profiel">Do you really want to delete this profile?</string>
     <string name="rec_protocol">Protocol</string>
+    <string name="ESSID">ESSID</string>
+    <string name="BSSID">BSSID</string>
     <string name="rec_sortby">Sort by</string>
     <string name="rec_latest">Latest</string>
     <string name="rec_earliest">Earliest</string>

+ 6 - 7
src/com/echo/holographlibrary/LineGraph.java

@@ -64,9 +64,8 @@ public class LineGraph extends View {
 	private Bitmap fullImage;
 	private boolean shouldUpdate = false;
 
-    static final float bottomPadding = 40, topPadding = 10;
-    static final float rightPadding = 10;
-    static final float leftPadding = 50;
+    static final float bottomPadding = 50, topPadding = 10;
+    static final float leftPadding = 50, rightPadding = 10;
     static final float sidePadding = rightPadding + leftPadding;
 
     private float xAxisStep = 4;
@@ -459,7 +458,7 @@ public class LineGraph extends View {
         float usableWidth = getWidth() - 2*sidePadding;
         float usableHeight = getHeight() - bottomPadding - topPadding;
 
-        float yPixels = getHeight() - (bottomPadding*3/5);
+        float yPixels = getHeight() - (bottomPadding*(4.f/5.f));
 
         // DRAW SEPERATOR
         paint.setColor(Color.BLACK);
@@ -474,18 +473,18 @@ public class LineGraph extends View {
         this.paint.setTextSize(AXIS_LABEL_FONT_SIZE * mContext.getResources().getDisplayMetrics().scaledDensity);
 
         // Draw y-axis label text
-        //double skippedValue = (maxY - minY ) / (Math.max(1., yAxisStep));
         double step = Math.max(1., (maxY - minY) / (Math.max(1., yAxisStep)));
-
+        double v = 0;
         for (double y = minY; y <= maxY; y+=step){
             double yPercent = (y-minY)/(maxY - minY);
 
             double newYPixels = topPadding + (yPercent*usableHeight);
             canvas.drawLine((float)leftPadding,(float)newYPixels,(float)leftPadding-5.f,(float)newYPixels, paint);
-            String title = this.getY_AxisTitle(maxY - y);
+            String title = this.getY_AxisTitle(maxY - v);
             float textwidth = (this.paint.measureText(title));
             canvas.drawText(title, 5.f ,(float)newYPixels + (textwidth/2), this.paint);
 
+            v+=step;
             //value+=skippedValue;
         }
 

+ 158 - 56
src/de/tudarmstadt/informatik/hostage/ui2/fragment/RecordOverviewFragment.java

@@ -1,15 +1,12 @@
 package de.tudarmstadt.informatik.hostage.ui2.fragment;
 
 import android.annotation.SuppressLint;
-import android.app.Fragment;
 import android.app.FragmentManager;
 import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.LayoutInflater;
-import android.view.Menu;
-import android.view.MenuInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.ExpandableListView;
@@ -29,7 +26,6 @@ import java.util.Random;
 
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.logging.Record;
-import de.tudarmstadt.informatik.hostage.logging.Record.TYPE;
 import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
 import de.tudarmstadt.informatik.hostage.ui.LogFilter;
 import de.tudarmstadt.informatik.hostage.ui.LogFilter.SortType;
@@ -102,6 +98,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 
 		dbh = new UglyDbHelper(this.getActivity().getBaseContext());
 
+        //this.addRecordToDB(5, 2);
+
 	    // Get the message from the intent
 
         if (this.filter == null){
@@ -170,16 +168,19 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		return rootView;
 	 }
 
+    /*
+    *  Returns the Fragment layout ID
+    *  @return int The fragment layout ID
+    * */
     public int getLayoutId(){
         return R.layout.fragment_record_list;
     }
 
-
-
-	public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
-		super.onCreateOptionsMenu(menu, inflater);
-	}
-
+    /*
+    * Gets called if the user clicks on item in the filter menu.
+    *
+    * @param AbstractPopupItem item
+    * */
 	public void onFilterMenuItemSelected(AbstractPopupItem item) {
 		String title = item.getTitle();
 
@@ -260,6 +261,10 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 	 *
 	 * ***************************/
 
+    /*
+    *  Reloads the data in the ExpandableListView for the given filter object.
+    *  @param ExpandableListView  listview
+    * */
 	private void populateListViewFromDB(ExpandableListView mylist) {
 
 		HashMap<String, ArrayList<ExpandableListItem>> sectionData = new HashMap<String, ArrayList<ExpandableListItem>>();
@@ -320,25 +325,41 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         mylist.setAdapter(adapter);
 	}
 
+    /*Thsi will open a section in the ExpandableListView with the same title as the parameter s.
+    *
+    * @param String s (the section title to open)
+    *
+    * */
     private void setSectionToOpen(String s){
         this.sectionToOpen = s;
         if (this.sectionToOpen != null && this.sectionToOpen.length() != 0){
-            if (this.getGroupTitle().contains(this.sectionToOpen)){
-                int section = this.getGroupTitle().indexOf(this.sectionToOpen);
+            if (this.getGroupTitles().contains(this.sectionToOpen)){
+                int section = this.getGroupTitles().indexOf(this.sectionToOpen);
                 this.expListView.expandGroup(section);
                 this.sectionToOpen = "";
             }
         }
     }
 
+    /*
+    * Returns the base context.
+    * @return Context baseContext
+    * */
 	private Context getBaseContext(){
 		return this.getActivity().getBaseContext();
 	}
 
+    /*Returns the application context.
+    * @return Context application context
+    * */
 	private Context getApplicationContext(){
 		return this.getActivity().getApplicationContext();
 	}
 
+    /*Sets the list view listener on the given ExpandableListView.
+    *
+    * @param ExpandableListView listview
+    * */
 	private void registerListClickCallback(ExpandableListView mylist) {
         mylist.setOnChildClickListener(new ExpandableListView.OnChildClickListener() {
             @Override
@@ -378,6 +399,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 	 * ***************************/
 
 
+    /*Returns the date format "H:mm d.M.yy" for the given timestamp (long)
+    * @param Long timestamp*/
 	@SuppressLint("SimpleDateFormat")
 	private String getDateAsString(long timeStamp) {
 
@@ -414,26 +437,31 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 	 *
 	 * ***************************/
 
+    /*Opens the grouping dialog*/
     private void openGroupingDialog(){
         ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_GROUP, this.groupingTitles(), this.selectedGroup(), false , this);
         newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_GROUP);
     }
 
+    /*opens the bssid filter dialog*/
 	private void openBSSIDFilterDialog(){
 		ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_BSSID,this.bssids(), this.selectedBSSIDs(), true , this);
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_BSSID);
 	}
 
+    /*opens the essid filter dialog*/
 	private void openESSIDFilterDialog(){
 		ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_ESSID,this.essids(), this.selectedESSIDs(), true , this);
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_ESSID);
 	}
 
+    /*opens the protocol filter dialog*/
 	private void openProtocolsFilterDialog(){
 		ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_PROTOCOLS,this.protocolTitles(), this.selectedProtocols(), true , this);
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_PROTOCOLS);
 	}
 
+    /*opens the timestamp filter dialog (minimal timestamp required)*/
 	private void openTimestampFromFilterDialog(){
 		this.wasBelowTimePicker = false;
 		DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
@@ -441,6 +469,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         if (this.filter.aboveTimestamp != Long.MIN_VALUE)newFragment.setDate(this.filter.aboveTimestamp);
 	}
 
+    /*opens time timestamp filter dialog (maximal timestamp required)*/
 	private void openTimestampToFilterDialog(){
 		this.wasBelowTimePicker = true;
 		DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
@@ -448,6 +477,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         if (this.filter.belowTimestamp != Long.MAX_VALUE) newFragment.setDate(this.filter.belowTimestamp);
     }
 
+    /*opens the sorting dialog*/
 	private void openSortingDialog(){
 		ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_SORTING,this.sortTypeTiles(), this.selectedSorttype(), false , this);
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
@@ -459,6 +489,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
      *
      * ***************************/
 
+    /*returns the group title for the given record. Uses the groupingKey to decied which value of the record should be used.
+    * @param Record rec
+    * @return String grouptitle*/
     public String getGroupValue(Record rec){
         int index = this.groupingTitles().indexOf(this.groupingKey);
         switch (index){
@@ -473,7 +506,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         }
     }
 
-    public ArrayList<String> getGroupTitle(){
+    /*Returns the Group titles for the specified grouping key. e.g. groupingKey is "ESSID" it returns all available essids.
+    * @return ArrayList<String> grouptitles*/
+    public ArrayList<String> getGroupTitles(){
         int index = this.groupingTitles().indexOf(this.groupingKey);
         switch (index){
             case 0:
@@ -494,6 +529,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 	 *
 	 * ***************************/
 
+    /*Opens the filter menu on a anchor view. The filter menu will always be on top of the anchor.
+    * @param View anchorView*/
 	private void openFilterPopupMenuOnView(View v){
 
         SimplePopupTable filterMenu = new SimplePopupTable(this.getActivity(), new AbstractPopup.OnPopupItemClickListener() {
@@ -529,6 +566,11 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		filterMenu.showOnView(v);
 	}
 
+    /*Returns true  if the filter object is set for the given title otherwise false. e.g. the filter object has protocols,
+    * so the method will return for the title FILTER_MENU_TITLE_PROTOCOLS TRUE.
+    * @param String title
+    * @return boolean value
+    * */
     private boolean isFilterSetForTitle(String title){
         if (title.equals(FILTER_MENU_TITLE_BSSID)){
             return this.filter.hasBSSIDs();
@@ -548,11 +590,15 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         return false;
     }
 
+    /*clears the filter. Does not invoke populatelistview!*/
 	private void clearFilter(){
     	if(filter == null) this.filter = new LogFilter();
     	this.filter.clear();
 	}
 
+    /*Returns all grouping titles
+    * @param Context context
+    * @return ArrayList<String> titles*/
     public ArrayList<String> groupingTitles(Context context){
         ArrayList<String> titles = new ArrayList<String>();
         for (String groupTitle : context.getResources().getStringArray(
@@ -561,6 +607,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         }
         return titles;
     }
+    /*Returns all grouping titles.
+    * @return ArrayList<String> tiles*/
     public ArrayList<String> groupingTitles(){
         ArrayList<String> titles = new ArrayList<String>();
         for (String groupTitle : this.getResources().getStringArray(
@@ -569,6 +617,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         }
         return titles;
     }
+    /*Returns a bool array. This array is true at the index of the groupingKey in groupingTitles(), otherwise false.
+    * @return boolean[] selection
+    * */
     public boolean[] selectedGroup(){
         ArrayList<String> groups = this.groupingTitles();
         boolean[] selected = new boolean[groups.size()];
@@ -580,6 +631,9 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         return selected;
     }
 
+    /*Returns all protocol titles / names.
+    * @return ArrayList<String> protocolTitles
+    * */
 	public ArrayList<String> protocolTitles(){
 		ArrayList<String> titles = new ArrayList<String>();
 		for (String protocol : this.getResources().getStringArray(
@@ -588,6 +642,10 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		}
 		return titles;
 	}
+    /*Return a boolean array of the selected / filtered protocols. If the filter object has
+    * an protocol from the protocolTitles() array, the index of it will be true, otherwise false.
+    * @return boolean[] protocol selection
+    * */
 	public boolean[] selectedProtocols(){
 		ArrayList<String> protocols = this.protocolTitles();
 		boolean[] selected = new boolean[protocols.size()];
@@ -600,18 +658,23 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		return selected;
 	}
 
+    /*
+    * Returns the Sorttype Titles
+    * @return ArayList<String> Sort type titles
+    * */
 	public ArrayList<String> sortTypeTiles(){
 		ArrayList<String> titles = new ArrayList<String>();
 		titles.add(MainActivity.getContext().getString(R.string.rec_time));
 		titles.add(MainActivity.getContext().getString(R.string.rec_protocol));
-		titles.add("BSSID");
-		titles.add("ESSID");
-		//titles.add("Remote Host Name");
-		//titles.add("Local Host Name");
-		//titles.add("Attack ID");
-		//titles.add("ID");
+		titles.add(MainActivity.getContext().getString(R.string.BSSID));
+		titles.add(MainActivity.getContext().getString(R.string.ESSID));
 		return titles;
 	}
+    /*
+    * Returns an boolean array. The array is true at the index of the selected sort type..
+    * The index of the selected sort type is the same index in the sortTypeTiles array.
+    * @return boolean array, length == sortTypeTiles().length
+    * */
 	public boolean[] selectedSorttype(){
 		ArrayList<String> types = this.sortTypeTiles();
 		boolean[] selected = new boolean[types.size()];
@@ -623,10 +686,19 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		return selected;
 	}
 
+    /*
+    * Returns all unique bssids.
+    * @return ArrayList<String>
+    * */
 	public ArrayList<String> bssids(){
 		ArrayList<String> records = dbh.getUniqueBSSIDRecords();
 		return records;
 	}
+    /*
+    * Returns an boolean array. The array is true at the indices of the selected bssids.
+    * The index of the selected bssid is the same index in the bssids() array.
+    * @return boolean array, length == bssids().length
+    * */
 	public boolean[] selectedBSSIDs(){
 		ArrayList<String> bssids = this.bssids();
 		boolean[] selected = new boolean[bssids.size()];
@@ -639,11 +711,19 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		return selected;
 	}
 
-
+    /*
+    * Returns all unique essids.
+    * @return ArrayList<String>
+    * */
 	public ArrayList<String> essids(){
 		ArrayList<String> records = dbh.getUniqueESSIDRecords();
 		return records;
 	}
+    /*
+    * Returns an boolean array. The array is true at the indices of the selected essids.
+    * The index of the selected essid is the same index in the essids() array.
+    * @return boolean array, length == essids().length
+    * */
 	public boolean[] selectedESSIDs(){
 		ArrayList<String> essids = this.essids();
 		boolean[] selected = new boolean[essids.size()];
@@ -656,7 +736,10 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		return selected;
 	}
 
-
+    /*
+     * Returns all filter menu titles.
+     * @return ArrayList<String>
+     * */
 	private ArrayList<String> filterMenuTitles(){
 		ArrayList<String> titles = new ArrayList<String>();
 		titles.add(FILTER_MENU_TITLE_BSSID);
@@ -733,9 +816,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		this.populateListViewFromDB(this.expListView);
 	}
 
-	public void onDialogNegativeClick(ChecklistDialog dialog) {
-
-	}
+	public void onDialogNegativeClick(ChecklistDialog dialog) {}
 
 
 	/*****************************
@@ -744,8 +825,13 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 	 *
 	 * ***************************/
 
-	private void addRecordToDB() {
-        if ((dbh.getRecordCount() > 0)) return;
+    /*
+    * This will clear the database at first and than add new attacks.
+    * @param int number of networks to create
+    * @param int maximal number of attack per network
+    * */
+	private void addRecordToDB( int createNetworks, int attacksPerNetwork) {
+        if ((dbh.getRecordCount() > 0)) dbh.clearData();
 
 		Calendar cal = Calendar.getInstance();
 
@@ -756,44 +842,59 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 
 		LatLng tudarmstadtLoc = new LatLng(49.86923, 8.6632768);
 
-		final int numSSIDs = 10;
-		final int numUniqueSSIDs = 6;
+
 		final double ssidRadius = 0.1;
 		final double bssidRadius = 0.004;
-		int id = 0; // global id
-		for (int ssid = 0; ssid < numSSIDs; ssid++) {
-			LatLng ssidLocation = new LatLng(tudarmstadtLoc.latitude - ssidRadius + 2.0 * ssidRadius * Math.random(), tudarmstadtLoc.longitude - ssidRadius + 2.0 * ssidRadius * Math.random());
 
-			String ssidName = "WiFi" + ((ssid % numUniqueSSIDs) + 1);
+        int id = 0;
 
-			int numBSSIDs = (Math.abs(random.nextInt()) % 20) + 1;
-			for (int bssid = 0; bssid < numBSSIDs; bssid++) {
-				Record record = new Record();
-				record.setId(id);
-				record.setAttack_id(id);
-				record.setBssid("BSSID" + id);
-				id++;
+        for (int numOfNetworks = 0; numOfNetworks < createNetworks; numOfNetworks++){
+            String ssidName = "WiFi" + ((numOfNetworks) + 1);
+            String bssidName = "127.0.0." + ((numOfNetworks) + 1);
 
-				record.setSsid(ssidName);
-				record.setTimestamp(cal.getTimeInMillis()
-						+ ((id * 60 * 60 * 60 * 24) * 1000));
+            int protocolIndex = numOfNetworks % maxProtocolsIndex;
+            String protocolName = this.getResources().getStringArray(
+                    R.array.protocols)[protocolIndex];
 
-				int index = id % maxProtocolsIndex;
-				String protocolName = this.getResources().getStringArray(
-						R.array.protocols)[index];
+            int numOfAttackPerNetwork = (Math.abs(random.nextInt()) % attacksPerNetwork) + 1;
 
-				record.setProtocol(protocolName);
+            // ATTACKS PER NETWORK
+            for (int attack = 0; attack < numOfAttackPerNetwork; attack++) {
+                LatLng ssidLocation = new LatLng(tudarmstadtLoc.latitude - ssidRadius + 2.0 * ssidRadius * Math.random(), tudarmstadtLoc.longitude - ssidRadius + 2.0 * ssidRadius * Math.random());
 
-				record.setLocalIP("127.0.0.1");
-				record.setType(TYPE.SEND);
+                int numRecordsPerAttack = (Math.abs(random.nextInt()) % 5) + 1;
 
-				record.setLatitude(
-						ssidLocation.latitude - bssidRadius + 2.0 * bssidRadius * Math.random());
-				record.setLongitude(ssidLocation.longitude - bssidRadius + 2.0 * bssidRadius * Math.random());
+                double latitude = ssidLocation.latitude - bssidRadius + 2.0 * bssidRadius * Math.random();
+                double longitude = ssidLocation.longitude - bssidRadius + 2.0 * bssidRadius * Math.random();
 
-				dbh.addRecord(record);
-			}
-		}
+
+                // RECORDS PER ATTACK
+                for (int recC = id; recC < id + numRecordsPerAttack; recC++) {
+                    Record record = new Record();
+                    record.setId(recC);
+                    record.setAttack_id(id);
+
+                    record.setSsid(ssidName);
+                    record.setBssid(bssidName);
+
+                    // GO BACK IN TIME
+                    record.setTimestamp(cal.getTimeInMillis()
+                            - ((recC * 60 * 60 * 24) * 1000) + (1000 * ((recC - id) + 1)));
+
+                    record.setProtocol(protocolName);
+                    record.setLocalIP(bssidName);
+                    record.setType(Record.TYPE.SEND);
+
+                    record.setLatitude(latitude);
+                    record.setLongitude(longitude);
+
+                    dbh.addRecord(record);
+                }
+
+                id+=numRecordsPerAttack;
+            }
+
+        }
 
         int countAllLogs = dbh.getAllRecords().size();
         int countRecords = dbh.getRecordCount();
@@ -803,14 +904,15 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
             Record rec = dbh.getRecordOfAttackId(0);
             Record rec2 = dbh.getRecord(0);
 
-
             System.out.println("" + "Could not create logs!");
         }
 
     }
 
 
-    /*Navigation*/
+    /*Navigation. Shows the record detail view for the given record
+    * @param Record record to show
+    * */
     private void pushRecordDetailViewForRecord(Record record){
 
         FragmentManager fm = this.getActivity().getFragmentManager();

+ 79 - 32
src/de/tudarmstadt/informatik/hostage/ui2/fragment/StatisticsFragment.java

@@ -487,23 +487,21 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
         if (titles.size() != 0){
             String data = titles.get(0);
             this.setTitle(data);
-            if (title.equals(DIALOG_PROTOCOLS_TITLE)){
-                ChartType chartType = ChartType.PIE_CHART;
-                this.selectedCompareData = data;
-                this.setChartType(chartType);
-            }
-            if (title.equals(DIALOG_ATTACK_TITLE)){
+
+            if (data.equals(COMPARE_TITLE_AttacksPerTime) || data.equals(COMPARE_TITLE_AttacksPerDate)){
                 ChartType chartType = ChartType.LINE_CHART;
                 this.selectedCompareData = data;
                 this.setChartType(chartType);
+                return;
             }
-            if (title.equals(DIALOG_NETWORK_TITLE)){
+            if (data.equals(COMPARE_TITLE_AttacksPerBSSID) || data.equals(COMPARE_TITLE_AttacksPerESSID)){
                 ChartType chartType = ChartType.BAR_CHART;
                 this.selectedCompareData = data;
                 this.setChartType(chartType);
 
                 String fragTitle = "" + this.getCurrentSelectedProtocol() + ": " + this.selectedCompareData;
                 this.setTitle(fragTitle);
+                return;
             }
         }
 
@@ -775,7 +773,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
             this.lineGraph = new LineGraph(this.getActivity());
             LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
             plotLayout.addView(this.lineGraph);
-            this.lineGraph.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT,LinearLayout.LayoutParams.MATCH_PARENT ));
+            this.lineGraph.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
         }
         return this.lineGraph;
     }
@@ -807,7 +805,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
             this.currentData = new ArrayList<PlotComparisonItem>();
         }
 
-        this.pieGraph.removeSlices();
+        piegraph.removeSlices();
 
         for (PlotComparisonItem item : this.currentData){
             PieSlice slice = new PieSlice();
@@ -816,9 +814,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
             float v = value2.floatValue();
             slice.setValue(v);
             slice.setTitle(item.getTitle());
-            this.pieGraph.addSlice(slice);
+            piegraph.addSlice(slice);
         }
-        this.pieGraph.invalidate();
+        piegraph.invalidate();
 
     }
 
@@ -828,7 +826,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
             this.currentData = new ArrayList<PlotComparisonItem>();
         }
 
-        this.lineGraph.removeAllLines();
+        linegraph.removeAllLines();
         double rangeMax_Y = 0;
         double rangeMin_Y = 0;
 
@@ -863,7 +861,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
                 index++;
                 count++;
             }
-            this.lineGraph.addLine(l);
+            linegraph.addLine(l);
         }
         // add a bit more space
         rangeMax_Y++;
@@ -871,7 +869,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
 
         boolean shouldUseDate = this.selectedCompareData.equals(COMPARE_TITLE_AttacksPerDate);
         if (shouldUseDate){
-            this.lineGraph.resetXLimits();
+            linegraph.resetXLimits();
 
             if (this.filter.hasBelowTimestamp()){
                 rangeMax_X = Math.max(this.filter.belowTimestamp, rangeMax_X);
@@ -880,12 +878,18 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
                 rangeMin_X = Math.min(this.filter.aboveTimestamp, rangeMin_X);
             }
 
+            if (rangeMax_X == rangeMin_X){
+                double aDay = 60*60*24*1000;
+                rangeMax_X+= aDay;
+                rangeMin_X-= aDay;
+            }
+
             double stepRange = (rangeMax_X - rangeMin_X)/(60*60*24*1000);
-            this.lineGraph.setxAxisStep(Math.max(1, (float) Math.min(stepRange, 4)));
+            linegraph.setxAxisStep(Math.max(1, (float) Math.min(stepRange, 4)));
 
-            this.lineGraph.setRangeX(rangeMin_X  , rangeMax_X);
+            linegraph.setRangeX(rangeMin_X  , rangeMax_X);
 
-            this.lineGraph.setConverter(new LineGraph.AxisDataConverter() {
+            linegraph.setConverter(new LineGraph.AxisDataConverter() {
                 @Override
                 public String convertDataForX_Position(double x) {
                     return StatisticsFragment.this.getDateAsDayString((long)x);
@@ -896,22 +900,27 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
                 }
             });
         } else {
-            this.lineGraph.setxAxisStep(12.f);
-            this.lineGraph.setRangeX(0, 24);
-            this.lineGraph.setConverter(null);
+            linegraph.setxAxisStep(12.f);
+            linegraph.setRangeX(0, 24);
+            linegraph.setConverter(null);
         }
 
         int maxY = (int)(rangeMax_Y - rangeMin_Y);
-        this.lineGraph.setYAxisStep(Math.min(maxY, 5));
-        int yStep = (int)this.lineGraph.getyAxisStep();
+        linegraph.setYAxisStep(Math.min(maxY, 5));
+        int yStep = (int)linegraph.getyAxisStep();
         if ((maxY % yStep) != 0) {
             maxY = maxY + (yStep - (maxY % yStep));
         }
-        this.lineGraph.setRangeY(rangeMin_Y, rangeMin_Y + maxY);
-        this.lineGraph.setLineToFill(0);
-        this.lineGraph.invalidate();
+        rangeMax_Y = rangeMin_Y + maxY;
+        linegraph.setRangeY(rangeMin_Y, rangeMax_Y);
+        linegraph.setLineToFill(0);
+        linegraph.invalidate();
     }
 
+    /*
+    * Set the graph data to the given graph
+    * @param BarGraph bargraph
+    * */
     public void setBarGraphData(BarGraph bargraph){
         this.currentData = this.getBarData();
         if (this.currentData == null){
@@ -924,13 +933,13 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
             Bar d = new Bar();
             d.setColor(item.getColor());
             Long value2 =  item.getValue2().longValue();
-            d.setName("" + value2);
+            d.setName("");
             d.setValue(value2.floatValue());
             bars.add(d);
         }
 
-        this.barGraph.setBars(bars);
-        this.barGraph.invalidate();
+        barGraph.setBars(bars);
+        barGraph.invalidate();
     }
 
     /*
@@ -943,6 +952,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
         return this.dbh.getRecordsForFilter(this.filter);
     }
 
+    /*Actualises the current plot.*/
      public void actualiseCurrentPlot(){
          LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
         View plot = this.currentPlotView;
@@ -1051,8 +1061,14 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
          });
          return this.resizeData(plotItems);
     }
-    /*LINE PLOT DATA*/
 
+
+    /*
+    *  LINE PLOT DATA
+    */
+
+    /*Returns the line graph data responding to the selectedCompareData key.
+    * @return ArrayList<PlotComparisonItem attacksPerTime or attacksPerDate*/
     public ArrayList<PlotComparisonItem> attacksPerTime(){
         HashMap<String,HashMap<Long, ArrayList<Record> > > lineMap = new HashMap<String, HashMap<Long, ArrayList<Record>>>();
 
@@ -1126,7 +1142,13 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
         });
         return plotItems;
     }
-    // BAR PLOT DATA
+
+    /*
+    *  BAR PLOT DATA
+    */
+    /*Returns plotitems for the comparison "attacks per bssid"
+    * @return ArrayList<PlotComparisonItem> the data
+    */
     public ArrayList<PlotComparisonItem> attacksPerBSSID(String protocol){
         LogFilter filter = new LogFilter();
         ArrayList<String> protocollist = new ArrayList<String>();
@@ -1164,6 +1186,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
         });
         return this.resizeData(plotItems);
     }
+    /*Returns plotitems for the comparison "attacks per essid"
+    * @return ArrayList<PlotComparisonItem> the data
+    */
     public ArrayList<PlotComparisonItem> attacksPerESSID(String protocol){
         LogFilter filter = new LogFilter();
         filter.setAboveTimestamp(this.filter.getAboveTimestamp());
@@ -1203,7 +1228,14 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
         return this.resizeData(plotItems);
     }
 
-
+    /*
+    * This will normalize the given list of plot items to the specified length of MAX_NUMBER_OF_CHART_OBJECTS.
+    * Creates an "others" group, containing all objects after the (MAX_NUMBER_OF_CHART_OBJECTS - 1)th object from the given list.
+    * If the given list does contain MAX_NUMBER_OF_CHART_OBJECTS+1 or more objects, nothing will change.
+    *
+    * @param AtrrayList<PlotComparisonItem> the list to normalize
+    * @return ArrayList<PlotComparisonItem> the normalized data
+    */
     private ArrayList<PlotComparisonItem> resizeData(ArrayList<PlotComparisonItem> plotItems){
         if (plotItems != null){
             if (plotItems.size() > MAX_NUMBER_OF_CHART_OBJECTS && MAX_NUMBER_OF_CHART_OBJECTS > 1){
@@ -1242,7 +1274,13 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
     /*
     * FILTER STUFF
     * */
-     private String getCurrentSelectedProtocol(){
+
+    /*
+    * Returns the first selected protocol from all selected protocols.
+    * If no protocol is selected, it return the first protocol in the protocolTitles() list.
+    * @return String protocolName
+    * */
+    private String getCurrentSelectedProtocol(){
          ArrayList<String> protocolTitles = this.getSelectedProtocolTitles();
          if (protocolTitles != null && protocolTitles.size() != 0){
              return  protocolTitles.get(0);
@@ -1250,6 +1288,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
          return this.protocolTitles().get(0);
      }
 
+    /*Return all Protocols
+    *
+    * @return ArrayList<String> protocolNames
+    * */
      public ArrayList<String> protocolTitles(){
         ArrayList<String> titles = new ArrayList<String>();
         for (String protocol : this.getResources().getStringArray(
@@ -1258,6 +1300,11 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
         }
         return titles;
     }
+    /*
+    * Returns a boolean array containing a bool value for each protocol. If the value is true, the filter object contains the protocol.
+    * The array sequence equates to the protocolTitles() list.
+    * @return boolean[] selection array
+    * */
     public boolean[] selectedProtocols(){
         ArrayList<String> protocols = this.protocolTitles();
         boolean[] selected = new boolean[protocols.size()];