|
@@ -19,6 +19,7 @@ import android.widget.ListView;
|
|
|
import android.widget.ProgressBar;
|
|
|
import android.widget.RelativeLayout;
|
|
|
import android.widget.TextView;
|
|
|
+import android.widget.Toast;
|
|
|
|
|
|
import com.echo.holographlibrary.Bar;
|
|
|
import com.echo.holographlibrary.BarGraph;
|
|
@@ -128,6 +129,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
private ListView legendListView;
|
|
|
|
|
|
+ private Toast noDataNotificationToast;
|
|
|
+
|
|
|
|
|
|
private String selectedCompareData = COMPARE_TITLE_AttacksPerProtocol;
|
|
|
|
|
@@ -244,7 +247,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
/**Configures the given rootview.
|
|
|
* Sets the Spinner, the list and all requiered buttons.
|
|
|
* It also actualises the current plot type.
|
|
|
- * @param View rootView
|
|
|
+ * @param rootView View
|
|
|
* */
|
|
|
public void configureRootView(View rootView){
|
|
|
LinearLayout plotLayout = (LinearLayout) rootView.findViewById(R.id.plot_layout);
|
|
@@ -298,7 +301,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
|
|
|
/**Sets the title over the plot view.
|
|
|
- * @param String title
|
|
|
+ * @param title String
|
|
|
* */
|
|
|
public void setTitle(String title){
|
|
|
TextView titleView = (TextView) this.rootView.findViewById(R.id.title_text_view);
|
|
@@ -333,7 +336,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
|
|
|
/**Sets the current chart to the given type and acualises it.
|
|
|
- * @param ChartType type
|
|
|
+ * @param type {@link de.tudarmstadt.informatik.hostage.ui2.fragment.StatisticsFragment.ChartType ChartType}
|
|
|
* */
|
|
|
public void setChartType(ChartType type){
|
|
|
boolean shouldChange = true;
|
|
@@ -376,7 +379,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
|
|
|
/**Returns the plot view for a given type.
|
|
|
- * @param ChartType type.
|
|
|
+ * @param type {@link de.tudarmstadt.informatik.hostage.ui2.fragment.StatisticsFragment.ChartType ChartType}
|
|
|
* */
|
|
|
public View getPlotViewForType(ChartType type){
|
|
|
switch (type){
|
|
@@ -430,13 +433,17 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
tableHeaderTitleView.setText(FILTER_MENU_TITLE_ESSID);
|
|
|
}
|
|
|
}
|
|
|
+ if (this.currentData == null || this.currentData.isEmpty()){
|
|
|
+ tableHeaderTitleView.setText("");
|
|
|
+ tableHeaderValueView.setText("");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
/*
|
|
|
* MENU
|
|
|
* */
|
|
|
/**Opens the Bar Option Menu above the given anchor view.
|
|
|
- * @param View the anchor view*/
|
|
|
+ * @param anchorView View*/
|
|
|
private void openBarSelectionMenuOnView(View anchorView){
|
|
|
SimplePopupTable visualiseMenu = new SimplePopupTable(this.getActivity(), new AbstractPopup.OnPopupItemClickListener() {
|
|
|
public void onItemClick(Object ob) {
|
|
@@ -516,7 +523,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* */
|
|
|
/**
|
|
|
* Will be called if the user selects the positiv button on an checklist dialog.
|
|
|
- * @param ChecklistDialog dialog
|
|
|
+ * @param dialog {@link ChecklistDialog ChecklistDialog}
|
|
|
* */
|
|
|
public void onDialogPositiveClick(ChecklistDialog dialog) {
|
|
|
String title = dialog.getTitle();
|
|
@@ -581,7 +588,7 @@ 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
|
|
|
+ * @param dialog {@link ChecklistDialog ChecklistDialog}
|
|
|
* */
|
|
|
public void onDialogNegativeClick(ChecklistDialog dialog) {
|
|
|
|
|
@@ -656,7 +663,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
/**
|
|
|
* Opens the filter menu above an given anchor view.
|
|
|
- * @param View anchor view
|
|
|
+ * @param anchor View
|
|
|
*/
|
|
|
private void openFilterMenuOnView(View anchor){
|
|
|
SimplePopupTable filterMenu = new SimplePopupTable(this.getActivity(), new AbstractPopup.OnPopupItemClickListener() {
|
|
@@ -695,7 +702,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
/**
|
|
|
* Will be called if the user selected an filter item.
|
|
|
- * @param AbstractPopupItem item
|
|
|
+ * @param item {@link AbstractPopupItem AbstractPopupItem}
|
|
|
*/
|
|
|
private void onFilterMenuItemSelected(AbstractPopupItem item){
|
|
|
if (item instanceof SplitPopupItem){
|
|
@@ -919,7 +926,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Returns the current line graph.
|
|
|
+ * Returns the current {@link com.echo.holographlibrary.LineGraph Linegraph} .
|
|
|
* @return LineGraph current line graph
|
|
|
*/
|
|
|
public LineGraph getLineGraphView(){
|
|
@@ -933,7 +940,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * Returns the current BarGraph.
|
|
|
+ * Returns the current {@link com.echo.holographlibrary.BarGraph BarGraph} .
|
|
|
* @return BarGraph the current bar graph
|
|
|
*/
|
|
|
public BarGraph getBarGraphView(){
|
|
@@ -960,7 +967,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
/**
|
|
|
* Sets the data for the given PieGraph
|
|
|
- * @param PieGraph piegraph
|
|
|
+ * @param piegraph {@link com.echo.holographlibrary.PieGraph PieGraph}
|
|
|
*/
|
|
|
public void setPieGraphData(PieGraph piegraph){
|
|
|
this.currentData = this.getPieData();
|
|
@@ -985,7 +992,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
/**
|
|
|
* Sets the data for the given LineGraph
|
|
|
- * @param LineGraph linegraph
|
|
|
+ * @param linegraph {@link LineGraph Linegraph}
|
|
|
*/
|
|
|
public void setLineGraphData(LineGraph linegraph){
|
|
|
this.currentData = this.getLineData();
|
|
@@ -1085,7 +1092,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
/**
|
|
|
* Set the graph data to the given graph
|
|
|
- * @param BarGraph bargraph
|
|
|
+ * @param bargraph {@link BarGraph BarGraph}
|
|
|
* */
|
|
|
public void setBarGraphData(BarGraph bargraph){
|
|
|
this.currentData = this.getBarData();
|
|
@@ -1114,7 +1121,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* */
|
|
|
/**
|
|
|
* Returns the DataBaseHandler result for the current filter.
|
|
|
- * @param ArrayList<Record> records
|
|
|
+ * @return records {@link java.util.ArrayList}, {@link Record Record}
|
|
|
*/
|
|
|
public ArrayList<Record> getFetchedRecords(){
|
|
|
if (this.filter == null) this.clearFilter();
|
|
@@ -1232,6 +1239,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
StatisticsFragment.this.currentPlotView.invalidate();
|
|
|
|
|
|
StatisticsFragment.this.spinner.setVisibility(View.GONE);
|
|
|
+
|
|
|
+ StatisticsFragment.this.showEmptyDataNotification();
|
|
|
}
|
|
|
});
|
|
|
}
|
|
@@ -1241,6 +1250,24 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
this.loader.start();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * Shows a small toast if the data to show is empty (no records).
|
|
|
+ */
|
|
|
+ private void showEmptyDataNotification(){
|
|
|
+ if (this.noDataNotificationToast == null){
|
|
|
+ this.noDataNotificationToast = Toast.makeText(getApplicationContext(), R.string.no_data_notification, Toast.LENGTH_SHORT);
|
|
|
+ }
|
|
|
+ if (this.getFilterButton().getVisibility() == View.VISIBLE){
|
|
|
+ this.noDataNotificationToast.setText(R.string.no_data_notification);
|
|
|
+ } else {
|
|
|
+ this.noDataNotificationToast.setText(R.string.no_data_notification_no_filter);
|
|
|
+ }
|
|
|
+ if (this.currentData == null || this.currentData.isEmpty()){
|
|
|
+ this.noDataNotificationToast.show();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/** Calculates and returns the data for the piegraph
|
|
|
* @return ArrayList<PlotComparisonItem> data */
|
|
|
public ArrayList<PlotComparisonItem> getPieData(){
|
|
@@ -1303,9 +1330,11 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* LINE PLOT DATA
|
|
|
*/
|
|
|
|
|
|
- /**Returns the line graph data responding to the selectedCompareData key.
|
|
|
+ /**
|
|
|
+ * 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*/
|
|
|
+ * @return plotItems {@link PlotComparisonItem PlotComparisonItems}
|
|
|
+ */
|
|
|
public ArrayList<PlotComparisonItem> attacksPerTime(){
|
|
|
HashMap<String,HashMap<Long, ArrayList<Record> > > lineMap = new HashMap<String, HashMap<Long, ArrayList<Record>>>();
|
|
|
|
|
@@ -1385,7 +1414,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
*/
|
|
|
/**Returns plotitems for the comparison "attacks per bssid"
|
|
|
* The returned data is resized to the specified limit.
|
|
|
- * @return ArrayList<PlotComparisonItem> the data
|
|
|
+ * @return ArrayList of {@link PlotComparisonItem PlotComparisonItems}
|
|
|
*/
|
|
|
public ArrayList<PlotComparisonItem> attacksPerBSSID(String protocol){
|
|
|
LogFilter filter = new LogFilter();
|
|
@@ -1425,7 +1454,7 @@ 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
|
|
|
+ * @return ArrayList of {@link PlotComparisonItem PlotComparisonItems}
|
|
|
*/
|
|
|
public ArrayList<PlotComparisonItem> attacksPerESSID(String protocol){
|
|
|
LogFilter filter = new LogFilter();
|
|
@@ -1471,8 +1500,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* 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
|
|
|
+ * @param plotItems to normalize {@link PlotComparisonItem PlotComparisonItems}
|
|
|
+ * @return the normalized ArrayList of {@link PlotComparisonItem PlotComparisonItems}
|
|
|
*/
|
|
|
private ArrayList<PlotComparisonItem> resizeData(ArrayList<PlotComparisonItem> plotItems){
|
|
|
if (plotItems != null){
|
|
@@ -1607,7 +1636,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
* */
|
|
|
/**
|
|
|
* Returns true if the current filter is set for a given filter menu title.
|
|
|
- * @param String filter menu title
|
|
|
+ * @param title of the filter menu item {@link String String}
|
|
|
* @return boolean b
|
|
|
*/
|
|
|
private boolean isFilterSetForTitle(String title){
|
|
@@ -1645,8 +1674,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
/**
|
|
|
* Returns the current hour from a date.
|
|
|
- * @param timeInMillis
|
|
|
- * @return
|
|
|
+ * @param timeInMillis long
|
|
|
+ * @return milliseconds in long
|
|
|
*/
|
|
|
public long getDayHourFromDate(long timeInMillis){
|
|
|
|
|
@@ -1661,7 +1690,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
/**
|
|
|
* Returns the current date without the seconds, minutes, hours.
|
|
|
- * @param long date
|
|
|
+ * @param timeInMillis long
|
|
|
* @return long date with time 00:00:00
|
|
|
* */
|
|
|
public long getDateFromMilliseconds(long timeInMillis){
|
|
@@ -1681,7 +1710,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
static final DateFormat dateFormat = new SimpleDateFormat("d.M.yy");
|
|
|
|
|
|
/**Returns a date as a formated string
|
|
|
- * @param long date
|
|
|
+ * @param timeStamp date
|
|
|
* @return String date format (d.M.yy)*/
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
private String getDateAsDayString(long timeStamp) {
|
|
@@ -1715,7 +1744,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
*/
|
|
|
/**
|
|
|
* Will be called if the users taps on a list row.
|
|
|
- * @param int index
|
|
|
+ * @param index int
|
|
|
*/
|
|
|
private void userTappedOnLegendItem(int index){
|
|
|
if (index < this.currentData.size()){
|
|
@@ -1766,19 +1795,19 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
}
|
|
|
|
|
|
/**Will be called if the user clicked on a slice
|
|
|
- * @param int slice index*/
|
|
|
+ * @param index of the slice (int)*/
|
|
|
public void onSliceClick(int index){
|
|
|
}
|
|
|
/**Will be called if the user clicked on a bar
|
|
|
- * @param int bar index*/
|
|
|
+ * @param index of the bar (int)*/
|
|
|
public void onBarClick(int index){
|
|
|
this.userTappedOnLegendItem(index);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Displays a record over view fragment.
|
|
|
- * @param LogFilter filter
|
|
|
- * @param String sortKey
|
|
|
+ * @param filter {@link de.tudarmstadt.informatik.hostage.ui.LogFilter LogFilter}
|
|
|
+ * @param sortKey String
|
|
|
*/
|
|
|
private void pushRecordOverviewForFilter(LogFilter filter, String sortKey){
|
|
|
|