|
@@ -80,7 +80,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
static final String OTHER_CHART_TITLE = "Other";
|
|
|
|
|
|
// MINIMAL 2
|
|
|
- static int MAX_NUMBER_OF_CHART_OBJECTS = 5;
|
|
|
+ static int MAX_NUMBER_OF_CHART_OBJECTS = 6;
|
|
|
|
|
|
private boolean wasBelowTimePicker;
|
|
|
|
|
@@ -102,6 +102,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
private ListView legendListView;
|
|
|
|
|
|
+
|
|
|
+
|
|
|
private String selectedCompareData = COMPARE_TITLE_AttacksPerProtocol;
|
|
|
|
|
|
public enum ChartType {
|
|
@@ -137,6 +139,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
setHasOptionsMenu(true);
|
|
|
}
|
|
|
|
|
|
+ private ImageButton getFilterButton(){
|
|
|
+ return (ImageButton) this.rootView.findViewById(R.id.FilterButton);
|
|
|
+ }
|
|
|
+
|
|
|
public int getLayoutID(){
|
|
|
return R.layout.fragment_statistics;
|
|
|
}
|
|
@@ -198,18 +204,28 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
this.actualiseCurrentPlot();
|
|
|
|
|
|
- ImageButton filterButton = (ImageButton) rootView.findViewById(R.id.plot_data_button);
|
|
|
- filterButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ ImageButton visualButton = (ImageButton) rootView.findViewById(R.id.plot_data_button);
|
|
|
+ visualButton.setOnClickListener(new View.OnClickListener() {
|
|
|
public void onClick(View v) {
|
|
|
StatisticsFragment.this.openPopupMenuOnView(v);
|
|
|
}
|
|
|
});
|
|
|
+
|
|
|
+ this.setTitle(this.selectedCompareData);
|
|
|
+
|
|
|
+ ImageButton filterButton = this.getFilterButton();
|
|
|
+ filterButton.setOnClickListener(new View.OnClickListener() {
|
|
|
+ public void onClick(View v) {
|
|
|
+ StatisticsFragment.this.openFilterMenuOnView(v);
|
|
|
+ }
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
public void setTitle(String title){
|
|
|
TextView titleView = (TextView) this.rootView.findViewById(R.id.title_text_view);
|
|
|
if (title != null && titleView != null){
|
|
|
titleView.setText(title);
|
|
|
+ titleView.invalidate();
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -245,10 +261,14 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
if (type == ChartType.BAR_CHART){
|
|
|
shouldChange = ! (this.currentPlotView instanceof BarGraph);
|
|
|
// SHOW FILTER BUTTON
|
|
|
+ ImageButton filterButton = this.getFilterButton();
|
|
|
+ if (filterButton != null) filterButton.setVisibility(View.VISIBLE);
|
|
|
} else {
|
|
|
if (this.barGraph != null)
|
|
|
this.barGraph.setVisibility(View.INVISIBLE);
|
|
|
// SET FILTER BUTTON HIDDEN
|
|
|
+ ImageButton filterButton = this.getFilterButton();
|
|
|
+ if (filterButton != null) filterButton.setVisibility(View.INVISIBLE);
|
|
|
}
|
|
|
}
|
|
|
if (shouldChange){
|
|
@@ -352,7 +372,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
ArrayList<String> titles =dialog.getSelectedItemTitles();
|
|
|
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;
|
|
@@ -369,6 +389,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
this.setChartType(chartType);
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
}
|
|
|
|
|
|
public void onDialogNegativeClick(ChecklistDialog dialog) {
|
|
@@ -404,6 +425,16 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
return selected;
|
|
|
}
|
|
|
|
|
|
+ /*
|
|
|
+ *
|
|
|
+ * FILTER BUTTON
|
|
|
+ *
|
|
|
+ * */
|
|
|
+ private void openFilterMenuOnView(View anchor){
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
/**
|
|
|
*
|
|
|
* PLOT TOUCH HANDLING
|
|
@@ -448,7 +479,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
if (this.barGraph == null) {
|
|
|
this.barGraph = new BarGraph(this.getActivity());
|
|
|
LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
|
|
|
- this.barGraph.setLayoutParams(new ViewGroup.LayoutParams(plotLayout.getWidth(), plotLayout.getHeight()));
|
|
|
+ this.barGraph.setLayoutParams(new ViewGroup.LayoutParams(plotLayout.getWidth() - plotLayout.getPaddingLeft() - plotLayout.getPaddingRight(), plotLayout.getHeight() - - plotLayout.getPaddingTop() - plotLayout.getPaddingBottom()));
|
|
|
plotLayout.addView(this.barGraph);
|
|
|
this.barGraph.setPopupImageID(R.drawable.popup_black);
|
|
|
this.barGraph.setOnBarClickedListener(new BarGraph.OnBarClickedListener() {
|
|
@@ -500,6 +531,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
p.setX(index);
|
|
|
Double value2 = (Double) item.getValue2();
|
|
|
p.setY(value2.floatValue());
|
|
|
+ p.setColor(item.getColor());
|
|
|
+ l.addPoint(p);
|
|
|
index++;
|
|
|
}
|
|
|
this.lineGraph.addLine(l);
|
|
@@ -663,7 +696,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
HashMap<Long, ArrayList<Record> > recordMap = new HashMap<Long, ArrayList<Record> >();
|
|
|
|
|
|
for (Record record : this.getFetchedRecords()){
|
|
|
- long date = this.getDateFromMilliseconds(record.getTimestamp());
|
|
|
+ long timestamp = record.getTimestamp();
|
|
|
+ long date = this.getDateFromMilliseconds(timestamp);
|
|
|
ArrayList<Record> list = recordMap.get(date);
|
|
|
if (list == null){
|
|
|
list = new ArrayList<Record>();
|
|
@@ -675,7 +709,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
for (long date : recordMap.keySet()){
|
|
|
ArrayList<Record> list = recordMap.get(date);
|
|
|
if (list.size() == 0) continue;
|
|
|
- PlotComparisonItem item = new PlotComparisonItem(this.getDateAsDayString(date), this.getColor(index), (double) date, (double)list.size());
|
|
|
+ // TODO SET CORRECT COLOR
|
|
|
+ PlotComparisonItem item = new PlotComparisonItem(this.getDateAsDayString(date), this.getColor(0), (double) date, (double)list.size());
|
|
|
plotItems.add(item);
|
|
|
index++;
|
|
|
}
|
|
@@ -692,11 +727,12 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
HashMap<Long, ArrayList<Record> > recordMap = new HashMap<Long, ArrayList<Record> >();
|
|
|
|
|
|
for (Record record : this.getFetchedRecords()){
|
|
|
- long date = this.getDayHourFromDate(record.getTimestamp());
|
|
|
- ArrayList<Record> list = recordMap.get(date);
|
|
|
+ long timestamp = record.getTimestamp();
|
|
|
+ long time = this.getDayHourFromDate(timestamp);
|
|
|
+ ArrayList<Record> list = recordMap.get(time);
|
|
|
if (list == null){
|
|
|
list = new ArrayList<Record>();
|
|
|
- recordMap.put(date, list);
|
|
|
+ recordMap.put(time, list);
|
|
|
}
|
|
|
list.add(record);
|
|
|
}
|
|
@@ -704,7 +740,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
for (long time : recordMap.keySet()){
|
|
|
ArrayList<Record> list = recordMap.get(time);
|
|
|
if (list.size() == 0) continue;
|
|
|
- PlotComparisonItem item = new PlotComparisonItem(this.getDateAsTimeString(time), this.getColor(index) , (double)time, (double) list.size());
|
|
|
+ // TODO SET CURRECT COLOR
|
|
|
+ PlotComparisonItem item = new PlotComparisonItem(this.getDateAsTimeString(time), this.getColor(0) , (double)time, (double) list.size());
|
|
|
plotItems.add(item);
|
|
|
index++;
|
|
|
}
|
|
@@ -947,15 +984,21 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
*
|
|
|
*/
|
|
|
public long getDayHourFromDate(long timeInMillis){
|
|
|
+
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
|
|
|
calendar.setTimeInMillis (timeInMillis);
|
|
|
- int hour = calendar.get(Calendar.HOUR);
|
|
|
+ int hour = calendar.get(Calendar.HOUR_OF_DAY);
|
|
|
int min = calendar.get(Calendar.MINUTE);
|
|
|
|
|
|
- return (hour*60*60)*1000;
|
|
|
+ return hour;
|
|
|
+
|
|
|
}
|
|
|
public long getDateFromMilliseconds(long timeInMillis){
|
|
|
+ long millisInDay = 60 * 60 * 24 * 1000;
|
|
|
+ return (timeInMillis / millisInDay) * millisInDay;
|
|
|
+
|
|
|
+ /*
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTimeInMillis (timeInMillis);
|
|
|
|
|
@@ -965,17 +1008,21 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
|
|
|
|
|
|
calendar.set(year, month, day, 0,0);
|
|
|
return calendar.getTimeInMillis();
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
static final DateFormat timeFormat = new SimpleDateFormat("H:mm");
|
|
|
@SuppressLint("SimpleDateFormat")
|
|
|
private String getDateAsTimeString(long timeStamp) {
|
|
|
+ return "" + timeStamp + ":00";
|
|
|
+ /*
|
|
|
try {
|
|
|
Date netDate = (new Date(timeStamp));
|
|
|
return timeFormat.format(netDate);
|
|
|
} catch (Exception ex) {
|
|
|
return "xx";
|
|
|
}
|
|
|
+ */
|
|
|
}
|
|
|
|
|
|
static final DateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy");
|