|
@@ -87,6 +87,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
static final String COMPARE_TITLE_AttacksPerESSID = "Attacks per ESSID";
|
|
static final String COMPARE_TITLE_AttacksPerESSID = "Attacks per ESSID";
|
|
static final String FILTER_MENU_PROTOCOL_SINGLE_CHOICE_TITLE = "Select Protocol";
|
|
static final String FILTER_MENU_PROTOCOL_SINGLE_CHOICE_TITLE = "Select Protocol";
|
|
|
|
|
|
|
|
+ static final String TABLE_HEADER_VALUE_TITLE_ATTACKS_COUNT = "Attacks count";
|
|
|
|
+ static final String TABLE_HEADER_VALUE_TITLE_ATTACKS_PERCENTAGE = "% of all";
|
|
|
|
+
|
|
|
|
|
|
static final String OTHER_CHART_TITLE = "Other";
|
|
static final String OTHER_CHART_TITLE = "Other";
|
|
|
|
|
|
@@ -322,7 +325,44 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
public void actualiseLegendList(){
|
|
public void actualiseLegendList(){
|
|
StatisticListAdapter adapter = new StatisticListAdapter(this.getApplicationContext(), this.currentData);
|
|
StatisticListAdapter adapter = new StatisticListAdapter(this.getApplicationContext(), this.currentData);
|
|
|
|
+ if (this.currentPlotView instanceof LineGraph){
|
|
|
|
+ adapter.setValueFormatter(new StatisticListAdapter.ValueFormatter() {
|
|
|
|
+ @Override
|
|
|
|
+ public String convertValueToString(double value) {
|
|
|
|
+ return String.format("%.02f", value) + " %";
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ } else {
|
|
|
|
+
|
|
|
|
+ adapter.setValueFormatter(new StatisticListAdapter.ValueFormatter() {
|
|
|
|
+ @Override
|
|
|
|
+ public String convertValueToString(double value) {
|
|
|
|
+ int v = (int) value;
|
|
|
|
+ return "" + v;
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ }
|
|
this.legendListView.setAdapter(adapter);
|
|
this.legendListView.setAdapter(adapter);
|
|
|
|
+
|
|
|
|
+ TextView tableHeaderTitleView = (TextView) this.rootView.findViewById(R.id.table_header_title_textview);
|
|
|
|
+ TextView tableHeaderValueView = (TextView) this.rootView.findViewById(R.id.table_header_value_textview);
|
|
|
|
+ if (this.currentPlotView instanceof LineGraph){
|
|
|
|
+ tableHeaderTitleView.setText(FILTER_MENU_TITLE_ESSID);
|
|
|
|
+ tableHeaderValueView.setText(TABLE_HEADER_VALUE_TITLE_ATTACKS_PERCENTAGE);
|
|
|
|
+ }
|
|
|
|
+ if (this.currentPlotView instanceof PieGraph){
|
|
|
|
+ tableHeaderTitleView.setText(FILTER_MENU_TITLE_PROTOCOL);
|
|
|
|
+ tableHeaderValueView.setText(TABLE_HEADER_VALUE_TITLE_ATTACKS_COUNT);
|
|
|
|
+ }
|
|
|
|
+ if (this.currentPlotView instanceof BarGraph){
|
|
|
|
+ tableHeaderValueView.setText(TABLE_HEADER_VALUE_TITLE_ATTACKS_COUNT);
|
|
|
|
+ if (this.selectedCompareData.equals(COMPARE_TITLE_AttacksPerBSSID)){
|
|
|
|
+ tableHeaderTitleView.setText(FILTER_MENU_TITLE_BSSID);
|
|
|
|
+ } else {
|
|
|
|
+ tableHeaderTitleView.setText(FILTER_MENU_TITLE_ESSID);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -520,11 +560,6 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
filterMenu.addItem(item);
|
|
filterMenu.addItem(item);
|
|
}
|
|
}
|
|
- if (this.filter.isSet()){
|
|
|
|
- AbstractPopupItem item = new SimplePopupItem(this.getActivity());
|
|
|
|
- item.setTitle(FILTER_MENU_TITLE_REMOVE);
|
|
|
|
- filterMenu.addItem(item);
|
|
|
|
- }
|
|
|
|
filterMenu.showOnView(anchor);
|
|
filterMenu.showOnView(anchor);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -578,7 +613,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
titles.add(FILTER_MENU_TITLE_ESSID);
|
|
titles.add(FILTER_MENU_TITLE_ESSID);
|
|
}
|
|
}
|
|
titles.add(FILTER_MENU_TITLE_TIMESTAMP_ABOVE);
|
|
titles.add(FILTER_MENU_TITLE_TIMESTAMP_ABOVE);
|
|
- if (this.filter.hasProtocols() || this.filter.hasATimestamp() || this.filter.hasESSIDs() || this.filter.hasBSSIDs()){
|
|
|
|
|
|
+ if (this.filter.hasATimestamp() || this.filter.hasESSIDs() || this.filter.hasBSSIDs()
|
|
|
|
+ || (this.currentPlotView instanceof LineGraph && this.filter.hasProtocols())){
|
|
titles.add(FILTER_MENU_TITLE_REMOVE);
|
|
titles.add(FILTER_MENU_TITLE_REMOVE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -586,7 +622,11 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
}
|
|
}
|
|
|
|
|
|
private void openProtocolsFilterDialog(){
|
|
private void openProtocolsFilterDialog(){
|
|
- ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_PROTOCOLS,this.protocolTitles(), this.selectedProtocols(), true , this);
|
|
|
|
|
|
+ ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_PROTOCOLS,
|
|
|
|
+ this.protocolTitles(),
|
|
|
|
+ this.selectedProtocols(),
|
|
|
|
+ true ,
|
|
|
|
+ this);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_PROTOCOLS);
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_PROTOCOLS);
|
|
}
|
|
}
|
|
private void openFilterDialogSelectProtocol(){
|
|
private void openFilterDialogSelectProtocol(){
|
|
@@ -840,7 +880,11 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
this.lineGraph.setConverter(null);
|
|
this.lineGraph.setConverter(null);
|
|
}
|
|
}
|
|
|
|
|
|
- this.lineGraph.setRangeY(rangeMin_Y, rangeMax_Y);
|
|
|
|
|
|
+ int maxY = (int)(rangeMax_Y - rangeMin_Y);
|
|
|
|
+ this.lineGraph.setYAxisStep(Math.min(maxY, 5));
|
|
|
|
+ int yStep = (int)this.lineGraph.getyAxisStep();
|
|
|
|
+ maxY = maxY + (maxY % yStep);
|
|
|
|
+ this.lineGraph.setRangeY(rangeMin_Y, rangeMin_Y + maxY);
|
|
this.lineGraph.setLineToFill(0);
|
|
this.lineGraph.setLineToFill(0);
|
|
this.lineGraph.invalidate();
|
|
this.lineGraph.invalidate();
|
|
}
|
|
}
|
|
@@ -991,7 +1035,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
boolean shouldUseDate = this.selectedCompareData.equals(COMPARE_TITLE_AttacksPerDate);
|
|
boolean shouldUseDate = this.selectedCompareData.equals(COMPARE_TITLE_AttacksPerDate);
|
|
|
|
|
|
- for (Record record : this.getFetchedRecords()){
|
|
|
|
|
|
+ ArrayList<Record> records = this.getFetchedRecords();
|
|
|
|
+ for (Record record : records){
|
|
long timestamp = record.getTimestamp();
|
|
long timestamp = record.getTimestamp();
|
|
long time = 0;
|
|
long time = 0;
|
|
if (shouldUseDate){
|
|
if (shouldUseDate){
|
|
@@ -1028,11 +1073,13 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
HashMap<Long, ArrayList<Record> > recordMap = lineMap.get(groupKey);
|
|
HashMap<Long, ArrayList<Record> > recordMap = lineMap.get(groupKey);
|
|
ArrayList<PlotComparisonItem> singleLineItems = new ArrayList<PlotComparisonItem>();
|
|
ArrayList<PlotComparisonItem> singleLineItems = new ArrayList<PlotComparisonItem>();
|
|
|
|
|
|
|
|
+ int numbOfAttacks = 0;
|
|
for (long time : recordMap.keySet()){
|
|
for (long time : recordMap.keySet()){
|
|
ArrayList<Record>list = recordMap.get(time);
|
|
ArrayList<Record>list = recordMap.get(time);
|
|
if (list.size() == 0) continue;
|
|
if (list.size() == 0) continue;
|
|
PlotComparisonItem item = new PlotComparisonItem(this.getHourAsTimeString(time), 0 , (double)time, (double) list.size());
|
|
PlotComparisonItem item = new PlotComparisonItem(this.getHourAsTimeString(time), 0 , (double)time, (double) list.size());
|
|
singleLineItems.add(item);
|
|
singleLineItems.add(item);
|
|
|
|
+ numbOfAttacks +=list.size();
|
|
}
|
|
}
|
|
|
|
|
|
Collections.sort(singleLineItems, new Comparator<PlotComparisonItem>() {
|
|
Collections.sort(singleLineItems, new Comparator<PlotComparisonItem>() {
|
|
@@ -1042,8 +1089,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
-
|
|
|
|
- PlotComparisonItem item = new PlotComparisonItem(groupKey, this.getColor(index), 0., (double) singleLineItems.size());
|
|
|
|
|
|
+ double itemValue = (((double)numbOfAttacks / (double)records.size())*100.);
|
|
|
|
+ PlotComparisonItem item = new PlotComparisonItem(groupKey, this.getColor(index), 0., itemValue);
|
|
item.setOtherData(singleLineItems);
|
|
item.setOtherData(singleLineItems);
|
|
plotItems.add(item);
|
|
plotItems.add(item);
|
|
index++;
|
|
index++;
|
|
@@ -1168,9 +1215,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
private String getCurrentSelectedProtocol(){
|
|
private String getCurrentSelectedProtocol(){
|
|
ArrayList<String> protocolTitles = this.getSelectedProtocolTitles();
|
|
ArrayList<String> protocolTitles = this.getSelectedProtocolTitles();
|
|
if (protocolTitles != null && protocolTitles.size() != 0){
|
|
if (protocolTitles != null && protocolTitles.size() != 0){
|
|
- return this.getSelectedProtocolTitles().get(0);
|
|
|
|
|
|
+ return protocolTitles.get(0);
|
|
}
|
|
}
|
|
- return "";
|
|
|
|
|
|
+ return this.protocolTitles().get(0);
|
|
}
|
|
}
|
|
|
|
|
|
public ArrayList<String> protocolTitles(){
|
|
public ArrayList<String> protocolTitles(){
|