|
@@ -9,8 +9,10 @@ import android.os.Bundle;
|
|
import android.view.LayoutInflater;
|
|
import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
import android.view.ViewGroup;
|
|
import android.view.ViewGroup;
|
|
|
|
+import android.widget.AdapterView;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.LinearLayout;
|
|
import android.widget.ListView;
|
|
import android.widget.ListView;
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
import com.echo.holographlibrary.Bar;
|
|
import com.echo.holographlibrary.Bar;
|
|
import com.echo.holographlibrary.BarGraph;
|
|
import com.echo.holographlibrary.BarGraph;
|
|
@@ -139,14 +141,27 @@ public class StatisticsFragment extends Fragment {
|
|
|
|
|
|
View rootView = inflater.inflate(this.getLayoutID(), container, false);
|
|
View rootView = inflater.inflate(this.getLayoutID(), container, false);
|
|
|
|
|
|
|
|
+ LinearLayout plotLayout = (LinearLayout) rootView.findViewById(R.id.plot_layout);
|
|
|
|
+ plotLayout.setWillNotDraw(false);
|
|
|
|
+
|
|
|
|
+ container.setWillNotDraw(false);
|
|
|
|
+
|
|
this.legendListView = (ListView) rootView.findViewById(R.id.legend_list_view);
|
|
this.legendListView = (ListView) rootView.findViewById(R.id.legend_list_view);
|
|
|
|
+ this.legendListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
|
|
|
|
+ StatisticsFragment.this.userTappedOnItem(i);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
this.rootView = rootView;
|
|
this.rootView = rootView;
|
|
|
|
+ rootView.setWillNotDraw(false);
|
|
|
|
|
|
this.configureRootView(rootView);
|
|
this.configureRootView(rootView);
|
|
|
|
|
|
return rootView;
|
|
return rootView;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
private Context getBaseContext(){
|
|
private Context getBaseContext(){
|
|
return this.getActivity().getBaseContext();
|
|
return this.getActivity().getBaseContext();
|
|
}
|
|
}
|
|
@@ -156,27 +171,57 @@ public class StatisticsFragment extends Fragment {
|
|
}
|
|
}
|
|
|
|
|
|
public void configureRootView(View rootView){
|
|
public void configureRootView(View rootView){
|
|
|
|
+ LinearLayout plotLayout = (LinearLayout) rootView.findViewById(R.id.plot_layout);
|
|
|
|
+ plotLayout.setWillNotDraw(false);
|
|
|
|
+
|
|
|
|
+ plotLayout.removeAllViews();
|
|
|
|
+
|
|
this.actualiseCurrentPlot();
|
|
this.actualiseCurrentPlot();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ public void setTitle(String title){
|
|
|
|
+ TextView titleView = (TextView) this.rootView.findViewById(R.id.title_text_view);
|
|
|
|
+ if (title != null && titleView != null){
|
|
|
|
+ titleView.setText(title);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public String getTitle(){
|
|
|
|
+ TextView titleView = (TextView) this.rootView.findViewById(R.id.title_text_view);
|
|
|
|
+ if (titleView != null){
|
|
|
|
+ return "" + titleView.getText();
|
|
|
|
+ }
|
|
|
|
+ return "";
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void onStart() {
|
|
|
|
+ super.onStart();
|
|
|
|
+ this.actualiseCurrentPlot();
|
|
|
|
+ this.currentPlotView.invalidate();
|
|
|
|
+ }
|
|
|
|
+
|
|
public void setChartType(ChartType type){
|
|
public void setChartType(ChartType type){
|
|
boolean shouldChange = true;
|
|
boolean shouldChange = true;
|
|
if (this.currentPlotView != null){
|
|
if (this.currentPlotView != null){
|
|
if (type == ChartType.PIE_CHART){
|
|
if (type == ChartType.PIE_CHART){
|
|
shouldChange = ! (this.currentPlotView instanceof PieGraph);
|
|
shouldChange = ! (this.currentPlotView instanceof PieGraph);
|
|
|
|
+ } else {
|
|
|
|
+ this.pieGraph.setVisibility(View.INVISIBLE);
|
|
}
|
|
}
|
|
if (type == ChartType.LINE_CHART){
|
|
if (type == ChartType.LINE_CHART){
|
|
shouldChange = ! (this.currentPlotView instanceof LineGraph);
|
|
shouldChange = ! (this.currentPlotView instanceof LineGraph);
|
|
|
|
+ } else {
|
|
|
|
+ this.lineGraph.setVisibility(View.INVISIBLE);
|
|
}
|
|
}
|
|
if (type == ChartType.BAR_CHART){
|
|
if (type == ChartType.BAR_CHART){
|
|
shouldChange = ! (this.currentPlotView instanceof BarGraph);
|
|
shouldChange = ! (this.currentPlotView instanceof BarGraph);
|
|
|
|
+ } else {
|
|
|
|
+ this.barGraph.setVisibility(View.INVISIBLE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (shouldChange){
|
|
if (shouldChange){
|
|
- LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
|
|
|
|
- plotLayout.removeView(this.currentPlotView);
|
|
|
|
this.currentPlotView = this.getPlotViewForType(type);
|
|
this.currentPlotView = this.getPlotViewForType(type);
|
|
- plotLayout.addView(this.currentPlotView);
|
|
|
|
|
|
+ this.currentPlotView.setVisibility(View.VISIBLE);
|
|
|
|
|
|
this.actualiseCurrentPlot();
|
|
this.actualiseCurrentPlot();
|
|
}
|
|
}
|
|
@@ -204,10 +249,10 @@ public class StatisticsFragment extends Fragment {
|
|
*
|
|
*
|
|
* */
|
|
* */
|
|
public void onSliceClick(int index){
|
|
public void onSliceClick(int index){
|
|
-
|
|
|
|
|
|
+ this.userTappedOnItem(index);
|
|
}
|
|
}
|
|
public void onBarClick(int index){
|
|
public void onBarClick(int index){
|
|
-
|
|
|
|
|
|
+ this.userTappedOnItem(index);
|
|
}
|
|
}
|
|
/*
|
|
/*
|
|
*
|
|
*
|
|
@@ -216,8 +261,9 @@ public class StatisticsFragment extends Fragment {
|
|
* **/
|
|
* **/
|
|
public PieGraph getPieGraphView(){
|
|
public PieGraph getPieGraphView(){
|
|
if (this.pieGraph == null) {
|
|
if (this.pieGraph == null) {
|
|
- this.pieGraph = new PieGraph(this.getActivity());
|
|
|
|
- this.pieGraph.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.MATCH_PARENT));
|
|
|
|
|
|
+ this.pieGraph = new PieGraph(this.getApplicationContext());
|
|
|
|
+ LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
|
|
|
|
+ plotLayout.addView(this.pieGraph);
|
|
this.pieGraph.setOnSliceClickedListener(new PieGraph.OnSliceClickedListener() {
|
|
this.pieGraph.setOnSliceClickedListener(new PieGraph.OnSliceClickedListener() {
|
|
@Override
|
|
@Override
|
|
public void onClick(int index) {
|
|
public void onClick(int index) {
|
|
@@ -231,6 +277,8 @@ public class StatisticsFragment extends Fragment {
|
|
public LineGraph getLineGraphView(){
|
|
public LineGraph getLineGraphView(){
|
|
if (this.lineGraph == null) {
|
|
if (this.lineGraph == null) {
|
|
this.lineGraph = new LineGraph(this.getActivity());
|
|
this.lineGraph = new LineGraph(this.getActivity());
|
|
|
|
+ LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
|
|
|
|
+ plotLayout.addView(this.lineGraph);
|
|
}
|
|
}
|
|
return this.lineGraph;
|
|
return this.lineGraph;
|
|
}
|
|
}
|
|
@@ -238,6 +286,8 @@ public class StatisticsFragment extends Fragment {
|
|
public BarGraph getBarGraphView(){
|
|
public BarGraph getBarGraphView(){
|
|
if (this.barGraph == null) {
|
|
if (this.barGraph == null) {
|
|
this.barGraph = new BarGraph(this.getActivity());
|
|
this.barGraph = new BarGraph(this.getActivity());
|
|
|
|
+ LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
|
|
|
|
+ plotLayout.addView(this.barGraph);
|
|
this.barGraph.setPopupImageID(R.drawable.popup_black);
|
|
this.barGraph.setPopupImageID(R.drawable.popup_black);
|
|
this.barGraph.setOnBarClickedListener(new BarGraph.OnBarClickedListener() {
|
|
this.barGraph.setOnBarClickedListener(new BarGraph.OnBarClickedListener() {
|
|
@Override
|
|
@Override
|
|
@@ -264,7 +314,8 @@ public class StatisticsFragment extends Fragment {
|
|
PieSlice slice = new PieSlice();
|
|
PieSlice slice = new PieSlice();
|
|
slice.setColor(item.getColor());
|
|
slice.setColor(item.getColor());
|
|
Double value2 = (Double) item.getValue2();
|
|
Double value2 = (Double) item.getValue2();
|
|
- slice.setValue(value2.floatValue());
|
|
|
|
|
|
+ float v = value2.floatValue();
|
|
|
|
+ slice.setValue(v);
|
|
slice.setTitle(item.getTitle());
|
|
slice.setTitle(item.getTitle());
|
|
this.pieGraph.addSlice(slice);
|
|
this.pieGraph.addSlice(slice);
|
|
}
|
|
}
|
|
@@ -329,28 +380,35 @@ public class StatisticsFragment extends Fragment {
|
|
public void actualiseCurrentPlot(){
|
|
public void actualiseCurrentPlot(){
|
|
View plot = this.currentPlotView;
|
|
View plot = this.currentPlotView;
|
|
if (plot == null){
|
|
if (plot == null){
|
|
- if (this.pieGraph == null){
|
|
|
|
- this.currentPlotView = this.getPieGraphView();
|
|
|
|
- }
|
|
|
|
this.currentPlotView = this.getPieGraphView();
|
|
this.currentPlotView = this.getPieGraphView();
|
|
- LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
|
|
|
|
- plotLayout.addView(this.currentPlotView);
|
|
|
|
plot = this.currentPlotView;
|
|
plot = this.currentPlotView;
|
|
}
|
|
}
|
|
|
|
+ if (plot.getVisibility() == View.INVISIBLE) plot.setVisibility(View.VISIBLE);
|
|
|
|
+
|
|
if (plot instanceof PieGraph){
|
|
if (plot instanceof PieGraph){
|
|
PieGraph pie = (PieGraph) plot;
|
|
PieGraph pie = (PieGraph) plot;
|
|
this.setPieGraphData(pie);
|
|
this.setPieGraphData(pie);
|
|
|
|
+ } else {
|
|
|
|
+ if (this.pieGraph != null)
|
|
|
|
+ this.pieGraph.setVisibility(View.INVISIBLE);
|
|
}
|
|
}
|
|
if (plot instanceof BarGraph){
|
|
if (plot instanceof BarGraph){
|
|
BarGraph bar = (BarGraph) plot;
|
|
BarGraph bar = (BarGraph) plot;
|
|
this.setBarGraphData(bar);
|
|
this.setBarGraphData(bar);
|
|
|
|
+ } else {
|
|
|
|
+ if (this.barGraph != null)
|
|
|
|
+ this.barGraph.setVisibility(View.INVISIBLE);
|
|
}
|
|
}
|
|
if (plot instanceof LineGraph){
|
|
if (plot instanceof LineGraph){
|
|
LineGraph line = (LineGraph)plot;
|
|
LineGraph line = (LineGraph)plot;
|
|
this.setLineGraphData(line);
|
|
this.setLineGraphData(line);
|
|
|
|
+ }else {
|
|
|
|
+ if (this.lineGraph != null)
|
|
|
|
+ this.lineGraph.setVisibility(View.INVISIBLE);
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+ plot.setVisibility(View.VISIBLE);
|
|
this.actualiseLegendList();
|
|
this.actualiseLegendList();
|
|
|
|
+ this.currentPlotView.invalidate();
|
|
}
|
|
}
|
|
|
|
|
|
public ArrayList<PlotComparisonItem> getPieData(){
|
|
public ArrayList<PlotComparisonItem> getPieData(){
|
|
@@ -427,7 +485,7 @@ public class StatisticsFragment extends Fragment {
|
|
int index = 0;
|
|
int index = 0;
|
|
for (long date : recordMap.keySet()){
|
|
for (long date : recordMap.keySet()){
|
|
ArrayList<Record> list = recordMap.get(date);
|
|
ArrayList<Record> list = recordMap.get(date);
|
|
- PlotComparisonItem item = new PlotComparisonItem(this.getDateAsDayString(date),this.getColor(index), (double) date, (double)list.size());
|
|
|
|
|
|
+ PlotComparisonItem item = new PlotComparisonItem(this.getDateAsDayString(date), this.getColor(index), (double) date, (double)list.size());
|
|
plotItems.add(item);
|
|
plotItems.add(item);
|
|
index++;
|
|
index++;
|
|
}
|
|
}
|
|
@@ -538,6 +596,8 @@ public class StatisticsFragment extends Fragment {
|
|
|
|
|
|
for (int i = 0; i < plotItems.size(); i++){
|
|
for (int i = 0; i < plotItems.size(); i++){
|
|
if (i < MAX_NUMBER_OF_CHART_OBJECTS - 1){
|
|
if (i < MAX_NUMBER_OF_CHART_OBJECTS - 1){
|
|
|
|
+ PlotComparisonItem item = plotItems.get(i);
|
|
|
|
+ item.setColor(this.getColor(i));
|
|
copy.add(plotItems.get(i));
|
|
copy.add(plotItems.get(i));
|
|
} else {
|
|
} else {
|
|
PlotComparisonItem item = plotItems.get(i);
|
|
PlotComparisonItem item = plotItems.get(i);
|
|
@@ -642,23 +702,6 @@ public class StatisticsFragment extends Fragment {
|
|
return Color.argb(255,R,G,B);
|
|
return Color.argb(255,R,G,B);
|
|
}
|
|
}
|
|
|
|
|
|
- /*
|
|
|
|
- *
|
|
|
|
- * ACTUALISE PLOT VIEW
|
|
|
|
- *
|
|
|
|
- */
|
|
|
|
-
|
|
|
|
- public void setPlotView(View view){
|
|
|
|
- LinearLayout plotLayout = this.getPlotLayout();
|
|
|
|
- if (this.currentPlotView != null && plotLayout != null){
|
|
|
|
- plotLayout.removeAllViews();
|
|
|
|
- }
|
|
|
|
- if (view != null && plotLayout != null){
|
|
|
|
- this.currentPlotView = view;
|
|
|
|
- view.setLayoutParams(plotLayout.getLayoutParams());
|
|
|
|
- plotLayout.addView(view);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
|
|
public LinearLayout getPlotLayout(){
|
|
public LinearLayout getPlotLayout(){
|
|
if (this.rootView != null){
|
|
if (this.rootView != null){
|
|
@@ -744,4 +787,41 @@ public class StatisticsFragment extends Fragment {
|
|
return "xx";
|
|
return "xx";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * USERINTERACTION
|
|
|
|
+ */
|
|
|
|
+ private void userTappedOnItem(int index){
|
|
|
|
+ if (index < this.currentData.size()){
|
|
|
|
+ PlotComparisonItem item = this.currentData.get(index);
|
|
|
|
+ ArrayList<String> selectedData;
|
|
|
|
+ selectedData = new ArrayList<String>();
|
|
|
|
+
|
|
|
|
+ if (item.getOtherData() == null){
|
|
|
|
+ selectedData.add(item.getTitle());
|
|
|
|
+ } else {
|
|
|
|
+ for (PlotComparisonItem other : item.getOtherData()){
|
|
|
|
+ selectedData.add(other.getTitle());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ LogFilter filter = new LogFilter();
|
|
|
|
+ if (this.currentPlotView instanceof PieGraph){
|
|
|
|
+ filter.setProtocols(selectedData);
|
|
|
|
+ }
|
|
|
|
+ if (this.currentPlotView instanceof BarGraph){
|
|
|
|
+ // TODO set data for BSSID / ESSID
|
|
|
|
+ }
|
|
|
|
+ if (this.currentPlotView instanceof LineGraph){
|
|
|
|
+ // TODO set data for BSSID / ESSID
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void pushRecordOverviewForFilter(LogFilter filter){
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|