Browse Source

filter highlighting in statistics and record over view

Julien Clauter 10 years ago
parent
commit
6400f7e843

BIN
res/drawable-hdpi/ic_filter_pressed.png


+ 35 - 2
src/de/tudarmstadt/informatik/hostage/ui2/fragment/RecordOverviewFragment.java

@@ -5,6 +5,9 @@ import android.app.Activity;
 import android.app.FragmentManager;
 import android.content.Context;
 import android.content.Intent;
+import android.graphics.Color;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.util.Log;
 import android.view.LayoutInflater;
@@ -66,6 +69,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 
     private LogFilter filter;
     private boolean showFilterButton;
+    private View rootView;
 
     private int mListPosition = -1;
     private int mItemPosition = -1;
@@ -129,6 +133,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 	    this.setShowFilterButton(!this.filter.isNotEditable());
 
 		View rootView = inflater.inflate(this.getLayoutId(), container, false);
+        this.rootView = rootView;
 		ExpandableListView mylist = (ExpandableListView) rootView.findViewById(R.id.loglistview);
 
         this.spinner =(ProgressBar) rootView.findViewById(R.id.progressBar1);
@@ -432,6 +437,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         loader = null;
 
         this.spinner.setVisibility(View.VISIBLE);
+        this.actualiseFilterButton();
 
         loader = new Thread(new Runnable() {
             @Override
@@ -669,6 +675,12 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 	 *
 	 * ***************************/
 
+    /**Returns the FilterButton.
+     * @return ImageButton filterButton*/
+    private ImageButton getFilterButton(){
+        return (ImageButton) this.rootView.findViewById(R.id.FilterButton);
+    }
+
     /**Opens the filter menu on a anchor view. The filter menu will always be on top of the anchor.
     * @param View anchorView*/
 	private void openFilterPopupMenuOnView(View v){
@@ -910,7 +922,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 			this.filter.setAboveTimestamp(dialog.getDate());
 		}
         this.actualiseListViewInBackground();
-	}
+        this.actualiseFilterButton();
+    }
     /**
      * Will be called if the users cancels a timestamp selection.
      * @param DateTimeDialogFragment dialog
@@ -921,7 +934,8 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 		} else {
 			this.filter.setAboveTimestamp(Long.MIN_VALUE);
 		}
-	}
+        this.actualiseFilterButton();
+    }
 
     /**
      * Will be called if the users clicks the positiv button on a ChechlistDialog.
@@ -966,8 +980,27 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
             this.groupingKey =  titles.get(0);
         }
         this.actualiseListViewInBackground();
+
+        this.actualiseFilterButton();
 	}
 
+    /**Paints the filter button if the current filter object is set.*/
+    private void actualiseFilterButton(){
+        if (this.filter.isSet() ){
+            ImageButton filterButton = this.getFilterButton();
+            if (filterButton != null){
+                filterButton.setImageResource(R.drawable.ic_filter_pressed);
+                filterButton.invalidate();
+            }
+        } else {
+            ImageButton filterButton = this.getFilterButton();
+            if (filterButton != null){
+                filterButton.setImageResource(R.drawable.ic_filter);
+                filterButton.invalidate();
+            }
+        }
+    }
+
     /**
      * Will be called if the users clicks the negativ button on a ChechlistDialog.
      * @param ChecklistDialog dialog

+ 26 - 0
src/de/tudarmstadt/informatik/hostage/ui2/fragment/StatisticsFragment.java

@@ -8,6 +8,8 @@ import android.content.Context;
 import android.content.Intent;
 import android.content.res.Configuration;
 import android.graphics.Color;
+import android.graphics.PorterDuff;
+import android.graphics.drawable.Drawable;
 import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
@@ -532,16 +534,19 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
             this.actualiseCurrentPlot();
             String fragTitle = "" + this.getCurrentSelectedProtocol() + ": " + this.selectedCompareData;
             this.setTitle(fragTitle);
+
             return;
         }
         if (title.equals(FILTER_MENU_TITLE_ESSID)){
             this.filter.setESSIDs(titles);
             this.actualiseCurrentPlot();
+
             return;
         }
         if (title.equals(FILTER_MENU_TITLE_BSSID)){
             this.filter.setBSSIDs(titles);
             this.actualiseCurrentPlot();
+
             return;
         }
 
@@ -549,6 +554,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
             String data = titles.get(0);
             this.setTitle(data);
 
+            this.actualiseFilterButton();
+
             if (data.equals(COMPARE_TITLE_AttacksPerTime) || data.equals(COMPARE_TITLE_AttacksPerDate)){
                 ChartType chartType = ChartType.LINE_CHART;
                 this.selectedCompareData = data;
@@ -626,6 +633,23 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
     *
     * */
 
+    /**Paints the filter button if the current filter object is set.*/
+    private void actualiseFilterButton(){
+        if (this.filter.isSet() ){
+            ImageButton filterButton = this.getFilterButton();
+            if (filterButton != null){
+                filterButton.setImageResource(R.drawable.ic_filter_pressed);
+                filterButton.invalidate();
+            }
+        } else {
+            ImageButton filterButton = this.getFilterButton();
+            if (filterButton != null){
+                filterButton.setImageResource(R.drawable.ic_filter);
+                filterButton.invalidate();
+            }
+        }
+    }
+
     /**
      * Opens the filter menu above an given anchor view.
      * @param View anchor view
@@ -1100,6 +1124,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
      public void actualiseCurrentPlot(){
          this.spinner.setVisibility(View.VISIBLE);
 
+         this.actualiseFilterButton();
+
          LinearLayout plotLayout = (LinearLayout) this.rootView.findViewById(R.id.plot_layout);
 
          if (this.barGraph != null)