|
@@ -128,9 +128,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
private ListView legendListView;
|
|
|
|
|
|
|
|
|
-
|
|
|
private String selectedCompareData = COMPARE_TITLE_AttacksPerProtocol;
|
|
|
|
|
|
+
|
|
|
public enum ChartType {
|
|
|
PIE_CHART(0),
|
|
|
BAR_CHART(1),
|
|
@@ -158,14 +158,21 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**Returns the FilterButton.
|
|
|
+ * @return ImageButton filterButton*/
|
|
|
private ImageButton getFilterButton(){
|
|
|
return (ImageButton) this.rootView.findViewById(R.id.FilterButton);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the layout ID
|
|
|
+ * @Return int layoutID
|
|
|
+ * */
|
|
|
public int getLayoutID(){
|
|
|
return R.layout.fragment_statistics;
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
|
Bundle savedInstanceState) {
|
|
|
|
|
@@ -215,14 +222,24 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**Returns the base context.
|
|
|
+ * @return Context the base context
|
|
|
+ * */
|
|
|
private Context getBaseContext(){
|
|
|
return this.getActivity().getBaseContext();
|
|
|
}
|
|
|
|
|
|
+ /**Returns the application context.
|
|
|
+ * @return Context the application context*/
|
|
|
private Context getApplicationContext(){
|
|
|
return this.getActivity().getApplicationContext();
|
|
|
}
|
|
|
|
|
|
+ /**Configures the given rootview.
|
|
|
+ * Sets the Spinner, the list and all requiered buttons.
|
|
|
+ * It also actualises the current plot type.
|
|
|
+ * @param View rootView
|
|
|
+ * */
|
|
|
public void configureRootView(View rootView){
|
|
|
LinearLayout plotLayout = (LinearLayout) rootView.findViewById(R.id.plot_layout);
|
|
|
plotLayout.removeAllViews();
|
|
@@ -274,6 +291,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**Sets the title over the plot view.
|
|
|
+ * @param String title
|
|
|
+ * */
|
|
|
public void setTitle(String title){
|
|
|
TextView titleView = (TextView) this.rootView.findViewById(R.id.title_text_view);
|
|
|
if (title != null && titleView != null){
|
|
@@ -282,6 +302,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**Returns the title over the plot view.
|
|
|
+ * @return String title
|
|
|
+ * */
|
|
|
public String getTitle(){
|
|
|
TextView titleView = (TextView) this.rootView.findViewById(R.id.title_text_view);
|
|
|
if (titleView != null){
|
|
@@ -290,6 +313,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return "";
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
public void onStart() {
|
|
|
super.onStart();
|
|
|
this.actualiseCurrentPlot();
|
|
@@ -302,6 +326,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**Sets the current chart to the given type and acualises it.
|
|
|
+ * @param ChartType type
|
|
|
+ * */
|
|
|
public void setChartType(ChartType type){
|
|
|
boolean shouldChange = true;
|
|
|
this.clearFilter();
|
|
@@ -342,6 +369,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**Returns the plot view for a given type.
|
|
|
+ * @param ChartType type.
|
|
|
+ * */
|
|
|
public View getPlotViewForType(ChartType type){
|
|
|
switch (type){
|
|
|
case PIE_CHART:
|
|
@@ -353,6 +383,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**Actualises the list view. Therefore it requiers the "currentData".*/
|
|
|
public void actualiseLegendList(){
|
|
|
StatisticListAdapter adapter = new StatisticListAdapter(this.getApplicationContext(), this.currentData);
|
|
|
if (this.currentPlotView instanceof LineGraph){
|
|
@@ -398,7 +429,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
/*
|
|
|
* MENU
|
|
|
* */
|
|
|
- private void openBarSelectionMenuOnView(View anchorView){
|
|
|
+ /**Opens the Bar Option Menu above the given anchor view.
|
|
|
+ * @param View the anchor view*/
|
|
|
+ private void openBarSelectionMenuOnView(View anchorView){
|
|
|
SimplePopupTable visualiseMenu = new SimplePopupTable(this.getActivity(), new AbstractPopup.OnPopupItemClickListener() {
|
|
|
public void onItemClick(Object ob) {
|
|
|
if (ob instanceof AbstractPopupItem){
|
|
@@ -420,6 +453,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
visualiseMenu.showOnView(anchorView);
|
|
|
}
|
|
|
|
|
|
+ /**Will be called when the users selected an menu item (visualise menu / plot menu).
|
|
|
+ * If the user selected "Protocols" this method sets the current plot type to piegraph.
|
|
|
+ * Otherwise it will open a new dialog to select the comparison type.
|
|
|
+ * */
|
|
|
private void userSelectMenuItem(AbstractPopupItem item){
|
|
|
// OPEN A DIALOG TO SPECIFY THE VISUALISE DATA
|
|
|
if (item.getTitle().equals(MENU_TITLE_PROTOCOLS)){
|
|
@@ -436,6 +473,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**Returns the menu titles (visualise menu / plot menu)*/
|
|
|
private ArrayList<String> getMenuTitles(){
|
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
|
titles.add(MENU_TITLE_PROTOCOLS);
|
|
@@ -447,16 +485,18 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
/*
|
|
|
* PLOT DATA DIALOGS
|
|
|
* */
|
|
|
- private void openProtocolDataDialog(){
|
|
|
- ArrayList<String> titles = this.getDialogProtocolDataTitle();
|
|
|
- ChecklistDialog newFragment = new ChecklistDialog(DIALOG_PROTOCOLS_TITLE, titles, this.selectedData(titles), false , this);
|
|
|
- newFragment.show(this.getActivity().getFragmentManager(), DIALOG_PROTOCOLS_TITLE);
|
|
|
- }
|
|
|
+// private void openProtocolDataDialog(){
|
|
|
+// ArrayList<String> titles = this.getDialogProtocolDataTitle();
|
|
|
+// ChecklistDialog newFragment = new ChecklistDialog(DIALOG_PROTOCOLS_TITLE, titles, this.selectedData(titles), false , this);
|
|
|
+// newFragment.show(this.getActivity().getFragmentManager(), DIALOG_PROTOCOLS_TITLE);
|
|
|
+// }
|
|
|
+ /**Opens the network comparison dialog*/
|
|
|
private void openNetworkDataDialog(){
|
|
|
ArrayList<String> titles = this.getDialogNetworkDataTitle();
|
|
|
ChecklistDialog newFragment = new ChecklistDialog(DIALOG_NETWORK_TITLE, titles, this.selectedData(titles), false , this);
|
|
|
newFragment.show(this.getActivity().getFragmentManager(), DIALOG_NETWORK_TITLE);
|
|
|
}
|
|
|
+ /**Opens the attack comparison dialog*/
|
|
|
private void openAttackDataDialog(){
|
|
|
ArrayList<String> titles = this.getDialogAttackDataTitle();
|
|
|
ChecklistDialog newFragment = new ChecklistDialog(DIALOG_ATTACK_TITLE, titles, this.selectedData(titles), false , this);
|
|
@@ -468,7 +508,11 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* DIALOG ACTION METHODS
|
|
|
*
|
|
|
* */
|
|
|
- public void onDialogPositiveClick(ChecklistDialog dialog) {
|
|
|
+ /**
|
|
|
+ * Will be called if the user selects the positiv button on an checklist dialog.
|
|
|
+ * @param ChecklistDialog dialog
|
|
|
+ * */
|
|
|
+ public void onDialogPositiveClick(ChecklistDialog dialog) {
|
|
|
String title = dialog.getTitle();
|
|
|
ArrayList<String> titles =dialog.getSelectedItemTitles();
|
|
|
|
|
@@ -524,6 +568,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Will be called if the user selects the negativ button on an checklist dialog.
|
|
|
+ * @param ChecklistDialog dialog
|
|
|
+ * */
|
|
|
public void onDialogNegativeClick(ChecklistDialog dialog) {
|
|
|
|
|
|
}
|
|
@@ -532,24 +580,39 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* DIALOG DATA
|
|
|
*
|
|
|
* */
|
|
|
- private ArrayList<String> getDialogProtocolDataTitle(){
|
|
|
- ArrayList<String> data = new ArrayList<String>();
|
|
|
- data.add(COMPARE_TITLE_AttacksPerProtocol);
|
|
|
- data.add(COMPARE_TITLE_UsesPerProtocol);
|
|
|
- return data;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+// private ArrayList<String> getDialogProtocolDataTitle(){
|
|
|
+// ArrayList<String> data = new ArrayList<String>();
|
|
|
+// data.add(COMPARE_TITLE_AttacksPerProtocol);
|
|
|
+// data.add(COMPARE_TITLE_UsesPerProtocol);
|
|
|
+// return data;
|
|
|
+// }
|
|
|
+ /**
|
|
|
+ * Returns the Attacks comparison titles.
|
|
|
+ * @return ArrayList<String> the titles
|
|
|
+ */
|
|
|
private ArrayList<String> getDialogAttackDataTitle(){
|
|
|
ArrayList<String> data = new ArrayList<String>();
|
|
|
data.add(COMPARE_TITLE_AttacksPerDate);
|
|
|
data.add(COMPARE_TITLE_AttacksPerTime);
|
|
|
return data;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Returns the network comparison titles.
|
|
|
+ * @return ArrayList<String> the titles
|
|
|
+ */
|
|
|
private ArrayList<String> getDialogNetworkDataTitle(){
|
|
|
ArrayList<String> data = new ArrayList<String>();
|
|
|
data.add(COMPARE_TITLE_AttacksPerESSID);
|
|
|
data.add(COMPARE_TITLE_AttacksPerBSSID);
|
|
|
return data;
|
|
|
}
|
|
|
+ /**
|
|
|
+ * DEFAULT
|
|
|
+ * Returns an boolean array with a default selection. Just the first object is true.
|
|
|
+ * @return boolean[] selected array
|
|
|
+ */
|
|
|
private boolean[] selectedData(ArrayList<String> data){
|
|
|
boolean[] selected = new boolean[data.size()];
|
|
|
// SET DEFAULT
|
|
@@ -562,7 +625,12 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* FILTER BUTTON
|
|
|
*
|
|
|
* */
|
|
|
- private void openFilterMenuOnView(View anchor){
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Opens the filter menu above an given anchor view.
|
|
|
+ * @param View anchor view
|
|
|
+ */
|
|
|
+ private void openFilterMenuOnView(View anchor){
|
|
|
SimplePopupTable filterMenu = new SimplePopupTable(this.getActivity(), new AbstractPopup.OnPopupItemClickListener() {
|
|
|
public void onItemClick(Object ob) {
|
|
|
if (ob instanceof AbstractPopupItem){
|
|
@@ -597,6 +665,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
filterMenu.showOnView(anchor);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Will be called if the user selected an filter item.
|
|
|
+ * @param AbstractPopupItem item
|
|
|
+ */
|
|
|
private void onFilterMenuItemSelected(AbstractPopupItem item){
|
|
|
if (item instanceof SplitPopupItem){
|
|
|
SplitPopupItem sItem = (SplitPopupItem) item;
|
|
@@ -627,6 +699,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Return the menu titles of the filter menu.
|
|
|
+ * @return ArrayList<String> filter menu title
|
|
|
+ * */
|
|
|
private ArrayList<String> filterMenuTitles(){
|
|
|
ArrayList<String> titles = new ArrayList<String>();
|
|
|
if (this.currentPlotView instanceof LineGraph){
|
|
@@ -656,6 +732,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return titles;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Opens a multiple protocol checklist dialog
|
|
|
+ */
|
|
|
private void openProtocolsFilterDialog(){
|
|
|
ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_PROTOCOLS,
|
|
|
this.protocolTitles(),
|
|
@@ -664,6 +743,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
this);
|
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_PROTOCOLS);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Opens a single protocol checklist dialog
|
|
|
+ */
|
|
|
private void openFilterDialogSelectProtocol(){
|
|
|
ArrayList<String> titles = this.protocolTitles();
|
|
|
boolean[] selected = new boolean[titles.size()];
|
|
@@ -676,16 +759,21 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_PROTOCOL_SINGLE_CHOICE_TITLE);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Opens a multiple essid checklist 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 a multiple bssid checlist 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 a minimal timestamp dialog.**/
|
|
|
private void openTimestampFromFilterDialog(){
|
|
|
this.wasBelowTimePicker = false;
|
|
|
DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
|
|
@@ -695,6 +783,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
if (this.filter.aboveTimestamp != Long.MIN_VALUE)newFragment.setDate(this.filter.aboveTimestamp);
|
|
|
}
|
|
|
|
|
|
+ /** Opens the maximal timestamp dialog.*/
|
|
|
private void openTimestampToFilterDialog(){
|
|
|
this.wasBelowTimePicker = true;
|
|
|
DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
|
|
@@ -703,6 +792,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
if (this.filter.belowTimestamp != Long.MAX_VALUE) newFragment.setDate(this.filter.belowTimestamp);
|
|
|
}
|
|
|
|
|
|
+ /** Returns all essids
|
|
|
+ * If the current plot is a bar graph, it just return all possible essids for the selected protocol
|
|
|
+ * @return ArrayList<String> essids
|
|
|
+ * */
|
|
|
public ArrayList<String> essids(){
|
|
|
ArrayList<String> records;
|
|
|
if (this.currentPlotView instanceof BarGraph){
|
|
@@ -712,6 +805,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
return records;
|
|
|
}
|
|
|
+ /** Returns a boolean array. The position in the array will be true, if the essid is selected in the filter.
|
|
|
+ * @return boolean[] selected essids*/
|
|
|
public boolean[] selectedESSIDs(){
|
|
|
ArrayList<String> essids = this.essids();
|
|
|
boolean[] selected = new boolean[essids.size()];
|
|
@@ -724,6 +819,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return selected;
|
|
|
}
|
|
|
|
|
|
+ /** Returns all bssids
|
|
|
+ * If the current plot is a bar graph, it just return all possible bssids for the selected protocol
|
|
|
+ * @return ArrayList<String> bssids
|
|
|
+ * */
|
|
|
public ArrayList<String> bssids(){
|
|
|
ArrayList<String> records ;
|
|
|
if (this.currentPlotView instanceof BarGraph){
|
|
@@ -733,6 +832,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
return records;
|
|
|
}
|
|
|
+ /** Returns a boolean array. The position in the array will be true, if the bssid is selected in the filter.
|
|
|
+ * @return boolean[] selected bssids*/
|
|
|
public boolean[] selectedBSSIDs(){
|
|
|
ArrayList<String> bssids = this.bssids();
|
|
|
|
|
@@ -746,6 +847,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return selected;
|
|
|
}
|
|
|
|
|
|
+ /**Will be called if the user selects an date on the timestamp dialog*/
|
|
|
public void onDateTimePickerPositiveClick(DateTimeDialogFragment dialog) {
|
|
|
if(this.wasBelowTimePicker){
|
|
|
this.filter.setBelowTimestamp(dialog.getDate());
|
|
@@ -755,6 +857,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
this.actualiseCurrentPlot();
|
|
|
}
|
|
|
|
|
|
+ /**Will be called if the user cancels an date selection on the timestamp dialog*/
|
|
|
public void onDateTimePickerNegativeClick(DateTimeDialogFragment dialog) {
|
|
|
if(this.wasBelowTimePicker){
|
|
|
this.filter.setBelowTimestamp(Long.MAX_VALUE);
|
|
@@ -770,7 +873,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* PLOT TYPES
|
|
|
*
|
|
|
* **/
|
|
|
- public PieGraph getPieGraphView(){
|
|
|
+ /**Returns the current pie graph.
|
|
|
+ * @return PieGraph current piegraph*/
|
|
|
+ public PieGraph getPieGraphView(){
|
|
|
if (this.pieGraph == null) {
|
|
|
this.pieGraph = new PieGraph(this.getApplicationContext());
|
|
|
LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
|
|
@@ -785,6 +890,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return this.pieGraph;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the current line graph.
|
|
|
+ * @return LineGraph current line graph
|
|
|
+ */
|
|
|
public LineGraph getLineGraphView(){
|
|
|
if (this.lineGraph == null) {
|
|
|
this.lineGraph = new LineGraph(this.getActivity());
|
|
@@ -795,6 +904,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return this.lineGraph;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Returns the current BarGraph.
|
|
|
+ * @return BarGraph the current bar graph
|
|
|
+ */
|
|
|
public BarGraph getBarGraphView(){
|
|
|
if (this.barGraph == null) {
|
|
|
this.barGraph = new BarGraph(this.getActivity());
|
|
@@ -816,7 +929,12 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
/*
|
|
|
* FEED PLOTS WITH DATA
|
|
|
* */
|
|
|
- public void setPieGraphData(PieGraph piegraph){
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets the data for the given PieGraph
|
|
|
+ * @param PieGraph piegraph
|
|
|
+ */
|
|
|
+ public void setPieGraphData(PieGraph piegraph){
|
|
|
this.currentData = this.getPieData();
|
|
|
if (this.currentData == null){
|
|
|
this.currentData = new ArrayList<PlotComparisonItem>();
|
|
@@ -837,6 +955,11 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Sets the data for the given LineGraph
|
|
|
+ * @param LineGraph linegraph
|
|
|
+ */
|
|
|
public void setLineGraphData(LineGraph linegraph){
|
|
|
this.currentData = this.getLineData();
|
|
|
if (this.currentData == null){
|
|
@@ -934,7 +1057,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
linegraph.invalidate();
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
+ /**
|
|
|
* Set the graph data to the given graph
|
|
|
* @param BarGraph bargraph
|
|
|
* */
|
|
@@ -964,12 +1087,16 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* FETCH & ACTUALISE RECORD DATA
|
|
|
*
|
|
|
* */
|
|
|
- public ArrayList<Record> getFetchedRecords(){
|
|
|
+ /**
|
|
|
+ * Returns the DataBaseHandler result for the current filter.
|
|
|
+ * @param ArrayList<Record> records
|
|
|
+ */
|
|
|
+ public ArrayList<Record> getFetchedRecords(){
|
|
|
if (this.filter == null) this.clearFilter();
|
|
|
return this.dbh.getRecordsForFilter(this.filter);
|
|
|
}
|
|
|
|
|
|
- /*Actualises the current plot.*/
|
|
|
+ /**Actualises the current plot in a background thread.*/
|
|
|
public void actualiseCurrentPlot(){
|
|
|
this.spinner.setVisibility(View.VISIBLE);
|
|
|
|
|
@@ -1087,10 +1214,14 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
this.loader.start();
|
|
|
}
|
|
|
|
|
|
+ /** Calculates and returns the data for the piegraph
|
|
|
+ * @return ArrayList<PlotComparisonItem> data */
|
|
|
public ArrayList<PlotComparisonItem> getPieData(){
|
|
|
// DEFAULT
|
|
|
return this.attacksPerProtocols();
|
|
|
}
|
|
|
+ /** Calculates and returns the data for the bargraph.
|
|
|
+ * @return ArrayList<PlotComparisonItem> data */
|
|
|
public ArrayList<PlotComparisonItem> getBarData(){
|
|
|
String protocol = this.getCurrentSelectedProtocol();
|
|
|
|
|
@@ -1104,6 +1235,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
// Nothing available
|
|
|
return new ArrayList<PlotComparisonItem>();
|
|
|
}
|
|
|
+ /** Calculates and returns the data for the linegraph
|
|
|
+ * @return ArrayList<PlotComparisonItem> data */
|
|
|
public ArrayList<PlotComparisonItem> getLineData(){
|
|
|
return this.attacksPerTime();
|
|
|
}
|
|
@@ -1113,6 +1246,12 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* */
|
|
|
|
|
|
/*PROTOCOLS OVERVIEW*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns the attacks per protocols comparison result.
|
|
|
+ * The returned data is resized to the specified limit.
|
|
|
+ * @return ArrayList<PlotComparisonItem>
|
|
|
+ */
|
|
|
public ArrayList<PlotComparisonItem> attacksPerProtocols(){
|
|
|
ArrayList<PlotComparisonItem> plotItems = new ArrayList<PlotComparisonItem>();
|
|
|
int index = 0;
|
|
@@ -1137,8 +1276,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* LINE PLOT DATA
|
|
|
*/
|
|
|
|
|
|
- /*Returns the line graph data responding to the selectedCompareData key.
|
|
|
- * @return ArrayList<PlotComparisonItem attacksPerTime or attacksPerDate*/
|
|
|
+ /**Returns the line graph data responding to the selectedCompareData key.
|
|
|
+ * The returned data is resized to the specified limit.
|
|
|
+ * @return ArrayList<PlotComparisonItem attacksPerTime or attacksPerDate*/
|
|
|
public ArrayList<PlotComparisonItem> attacksPerTime(){
|
|
|
HashMap<String,HashMap<Long, ArrayList<Record> > > lineMap = new HashMap<String, HashMap<Long, ArrayList<Record>>>();
|
|
|
|
|
@@ -1216,8 +1356,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
/*
|
|
|
* BAR PLOT DATA
|
|
|
*/
|
|
|
- /*Returns plotitems for the comparison "attacks per bssid"
|
|
|
- * @return ArrayList<PlotComparisonItem> the data
|
|
|
+ /**Returns plotitems for the comparison "attacks per bssid"
|
|
|
+ * The returned data is resized to the specified limit.
|
|
|
+ * @return ArrayList<PlotComparisonItem> the data
|
|
|
*/
|
|
|
public ArrayList<PlotComparisonItem> attacksPerBSSID(String protocol){
|
|
|
LogFilter filter = new LogFilter();
|
|
@@ -1256,7 +1397,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
});
|
|
|
return this.resizeData(plotItems);
|
|
|
}
|
|
|
- /*Returns plotitems for the comparison "attacks per essid"
|
|
|
+ /**Returns plotitems for the comparison "attacks per essid"
|
|
|
* @return ArrayList<PlotComparisonItem> the data
|
|
|
*/
|
|
|
public ArrayList<PlotComparisonItem> attacksPerESSID(String protocol){
|
|
@@ -1298,7 +1439,7 @@ 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.
|
|
@@ -1345,7 +1486,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* FILTER STUFF
|
|
|
* */
|
|
|
|
|
|
- /*
|
|
|
+ /**
|
|
|
* 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
|
|
@@ -1358,7 +1499,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return this.protocolTitles().get(0);
|
|
|
}
|
|
|
|
|
|
- /*Return all Protocols
|
|
|
+ /**
|
|
|
+ * Return all Protocols
|
|
|
*
|
|
|
* @return ArrayList<String> protocolNames
|
|
|
* */
|
|
@@ -1370,7 +1512,7 @@ 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
|
|
@@ -1408,16 +1550,21 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
*
|
|
|
* */
|
|
|
|
|
|
-
|
|
|
+ /** Returns the color for the other group
|
|
|
+ * @return int color*/
|
|
|
public int getOtherColor(){
|
|
|
return Color.argb(255, 80, 80, 80); // grey
|
|
|
}
|
|
|
-
|
|
|
+ /** Returns the color for the given index
|
|
|
+ * @return int color*/
|
|
|
public Integer getColor(int index) {
|
|
|
return ColorSequenceGenerator.getColorForIndex(index);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ /** Returns the Plot layout.
|
|
|
+ *
|
|
|
+ * @return LinearLayout plot layout
|
|
|
+ */
|
|
|
public LinearLayout getPlotLayout(){
|
|
|
if (this.rootView != null){
|
|
|
return (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
|
|
@@ -1426,12 +1573,17 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
+ /*
|
|
|
*
|
|
|
* FILTER STUFF
|
|
|
*
|
|
|
* */
|
|
|
- private boolean isFilterSetForTitle(String title){
|
|
|
+ /**
|
|
|
+ * Returns true if the current filter is set for a given filter menu title.
|
|
|
+ * @param String filter menu title
|
|
|
+ * @return boolean b
|
|
|
+ */
|
|
|
+ private boolean isFilterSetForTitle(String title){
|
|
|
if (title.equals(FILTER_MENU_TITLE_BSSID)){
|
|
|
return this.filter.hasBSSIDs();
|
|
|
}
|
|
@@ -1450,6 +1602,9 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Clears the current filter.
|
|
|
+ */
|
|
|
private void clearFilter(){
|
|
|
if(filter == null) this.filter = new LogFilter();
|
|
|
this.filter.clear();
|
|
@@ -1460,6 +1615,12 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* DATE TRANSFORMATION
|
|
|
*
|
|
|
*/
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Returns the current hour from a date.
|
|
|
+ * @param timeInMillis
|
|
|
+ * @return
|
|
|
+ */
|
|
|
public long getDayHourFromDate(long timeInMillis){
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
@@ -1471,20 +1632,30 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return hour;
|
|
|
|
|
|
}
|
|
|
+ /**
|
|
|
+ * Returns the current date without the seconds, minutes, hours.
|
|
|
+ * @param long date
|
|
|
+ * @return long date with time 00:00:00
|
|
|
+ * */
|
|
|
public long getDateFromMilliseconds(long timeInMillis){
|
|
|
long millisInDay = 60 * 60 * 24 * 1000;
|
|
|
return (timeInMillis / millisInDay) * millisInDay;
|
|
|
|
|
|
}
|
|
|
|
|
|
- /*
|
|
|
- *
|
|
|
+ /**
|
|
|
+ * Returns the given hour as a formated string.
|
|
|
+ *
|
|
|
* */
|
|
|
private String getHourAsTimeString(long hour) {
|
|
|
return "" + hour + ":00";
|
|
|
}
|
|
|
|
|
|
static final DateFormat dateFormat = new SimpleDateFormat("d.M.yy");
|
|
|
+
|
|
|
+ /**Returns a date as a formated string
|
|
|
+ * @param long date
|
|
|
+ * @return String date format (d.M.yy)*/
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
private String getDateAsDayString(long timeStamp) {
|
|
|
try {
|
|
@@ -1496,8 +1667,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
+ /**Returns a date as a formated string
|
|
|
+ * @param long date
|
|
|
+ * @return String date format (H:mm dd/MM/yyyy)*/
|
|
|
private String getDateAsString(long timeStamp) {
|
|
|
-
|
|
|
try {
|
|
|
DateFormat sdf = new SimpleDateFormat("H:mm dd/MM/yyyy");
|
|
|
Date netDate = (new Date(timeStamp));
|
|
@@ -1511,6 +1684,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
/**
|
|
|
* USERINTERACTION
|
|
|
*/
|
|
|
+ /**
|
|
|
+ * Will be called if the users taps on a list row.
|
|
|
+ * @param int index
|
|
|
+ */
|
|
|
private void userTappedOnLegendItem(int index){
|
|
|
if (index < this.currentData.size()){
|
|
|
PlotComparisonItem item = this.currentData.get(index);
|
|
@@ -1559,13 +1736,21 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /**Will be called if the user clicked on a slice
|
|
|
+ * @param int slice index*/
|
|
|
public void onSliceClick(int index){
|
|
|
-
|
|
|
}
|
|
|
+ /**Will be called if the user clicked on a bar
|
|
|
+ * @param int bar index*/
|
|
|
public void onBarClick(int index){
|
|
|
this.userTappedOnLegendItem(index);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Displays a record over view fragment.
|
|
|
+ * @param LogFilter filter
|
|
|
+ * @param String sortKey
|
|
|
+ */
|
|
|
private void pushRecordOverviewForFilter(LogFilter filter, String sortKey){
|
|
|
|
|
|
FragmentManager fm = this.getActivity().getFragmentManager();
|