Bladeren bron

Merge branch 'master' of https://git.tk.informatik.tu-darmstadt.de/scm-ssi-student-hostagev2

Fabio Arnold 10 jaren geleden
bovenliggende
commit
5e103a841d

+ 22 - 0
res/layout-land/date_time_dialog.xml

@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    android:id="@+id/DateTimePicker"
+    android:layout_width="wrap_content"
+    android:layout_height="fill_parent"
+    android:gravity="center"
+    android:orientation="horizontal"
+    android:padding="5dip" >
+
+    <DatePicker
+        android:id="@+id/DatePicker"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+         />
+
+    <TimePicker
+        android:id="@+id/TimePicker"
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+         />
+
+</LinearLayout>

+ 16 - 0
res/layout/simple_popup_table.xml

@@ -23,4 +23,20 @@
 			android:layout_height="2dp"
 			android:background="@android:color/holo_blue_bright"
 			/>
+
+    <ScrollView
+        android:layout_width="fill_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/item_scrollview">
+
+        <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+            android:orientation="vertical"
+            android:layout_width="fill_parent"
+            android:layout_height="wrap_content"
+            android:id="@+id/item_scroll_layout"
+            >
+
+        </LinearLayout>
+        </ScrollView>
+
 </LinearLayout>

+ 30 - 9
src/de/tudarmstadt/informatik/hostage/ui2/dialog/DateTimeDialogFragment.java

@@ -7,9 +7,11 @@ import android.app.AlertDialog.Builder;
 import android.app.Dialog;
 import android.app.DialogFragment;
 import android.content.DialogInterface;
+import android.content.res.Configuration;
 import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
+import android.view.ViewGroup;
 import android.widget.DatePicker;
 import android.widget.DatePicker.OnDateChangedListener;
 import android.widget.TimePicker;
@@ -53,14 +55,33 @@ public class DateTimeDialogFragment extends DialogFragment implements OnDateChan
     }
 
     public DateTimeDialogFragment(Activity activity, int DialogType) {
+
         this.activity = activity;
         this.DialogType = DialogType;
 
-        // Inflate layout for the view
-        // Pass null as the parent view because its going in the dialog layout
         LayoutInflater inflater = activity.getLayoutInflater();
-        mView = inflater.inflate(R.layout.date_time_dialog, null);  
+        mView = inflater.inflate(R.layout.date_time_dialog, null);
+
+        this.setupRootView(mView);
+
+    }
+
+
+    @Override
+    public void onConfigurationChanged(Configuration newConfig){
+        super.onConfigurationChanged(newConfig);
+        LayoutInflater inflater = LayoutInflater.from(this.activity);
+
+        ViewGroup container = (ViewGroup) this.mView.getParent();
+
+        container.removeView(this.mView);
+
+        mView = inflater.inflate(R.layout.date_time_dialog, null);
+        container.addView(mView);
+        this.setupRootView(mView);
+    }
 
+    private void setupRootView(View mView){
         // Grab a Calendar instance
         mCalendar = Calendar.getInstance();
 
@@ -76,12 +97,12 @@ public class DateTimeDialogFragment extends DialogFragment implements OnDateChan
         setCalendarViewShown(false);
 
         switch (DialogType) {
-        case DATE_PICKER:
-            timePicker.setVisibility(View.GONE);
-            break;
-        case TIME_PICKER:
-            datePicker.setVisibility(View.GONE);
-            break;
+            case DATE_PICKER:
+                timePicker.setVisibility(View.GONE);
+                break;
+            case TIME_PICKER:
+                datePicker.setVisibility(View.GONE);
+                break;
         }
     }
 

+ 15 - 11
src/de/tudarmstadt/informatik/hostage/ui2/fragment/StatisticsFragment.java

@@ -3,7 +3,6 @@ package de.tudarmstadt.informatik.hostage.ui2.fragment;
 import android.annotation.SuppressLint;
 import android.app.Fragment;
 import android.app.FragmentManager;
-import android.app.FragmentTransaction;
 import android.content.Context;
 import android.content.Intent;
 import android.content.res.Configuration;
@@ -39,6 +38,7 @@ import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.logging.Record;
 import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
 import de.tudarmstadt.informatik.hostage.ui.LogFilter;
+import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
 import de.tudarmstadt.informatik.hostage.ui2.adapter.StatisticListAdapter;
 import de.tudarmstadt.informatik.hostage.ui2.dialog.ChecklistDialog;
 import de.tudarmstadt.informatik.hostage.ui2.dialog.DateTimeDialogFragment;
@@ -622,9 +622,10 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
             if (protocol.length() > 0){
                 if (this.selectedCompareData.equals(COMPARE_TITLE_AttacksPerBSSID)){
                     titles.add(FILTER_MENU_TITLE_BSSID);
+                } else {
+                    // DEFAULT
+                    titles.add(FILTER_MENU_TITLE_ESSID);
                 }
-                // DEFAULT
-                titles.add(FILTER_MENU_TITLE_ESSID);
             }
             titles.add(FILTER_MENU_TITLE_TIMESTAMP_ABOVE);
             if (this.filter.hasATimestamp() || this.filter.hasESSIDs() || this.filter.hasBSSIDs()
@@ -1040,7 +1041,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
          Collections.sort(plotItems, new Comparator<PlotComparisonItem>() {
              @Override
              public int compare(PlotComparisonItem s1, PlotComparisonItem s2) {
-                 return s1.getValue2().compareTo(s2.getValue2());
+                 return s2.getValue2().compareTo(s1.getValue2());
              }
          });
          return this.resizeData(plotItems);
@@ -1153,7 +1154,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
         Collections.sort(plotItems, new Comparator<PlotComparisonItem>() {
             @Override
             public int compare(PlotComparisonItem s1, PlotComparisonItem s2) {
-                return s1.getValue2().compareTo(s2.getValue2());
+                return s2.getValue2().compareTo(s1.getValue2());
             }
         });
         return this.resizeData(plotItems);
@@ -1190,7 +1191,7 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
         Collections.sort(plotItems, new Comparator<PlotComparisonItem>() {
             @Override
             public int compare(PlotComparisonItem s1, PlotComparisonItem s2) {
-                return s1.getValue2().compareTo(s2.getValue2());
+                return s2.getValue2().compareTo(s1.getValue2());
             }
         });
 
@@ -1220,6 +1221,13 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
                 otherItem.setOtherData(others);
                 copy.add(otherItem);
 
+                Collections.sort(copy, new Comparator<PlotComparisonItem>() {
+                    @Override
+                    public int compare(PlotComparisonItem s1, PlotComparisonItem s2) {
+                        return s2.getValue2().compareTo(s1.getValue2());
+                    }
+                });
+
                 return copy;
             }
         }
@@ -1446,12 +1454,8 @@ public class StatisticsFragment extends Fragment implements ChecklistDialog.Chec
 
             if (sortKey != null && sortKey.length() != 0) newFragment.setGroupKey(sortKey);
 
-            FragmentTransaction transaction = fm.beginTransaction();
-            transaction.replace(R.id.content_frame, newFragment, newFragment.getTag());
-            transaction.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
-            transaction.addToBackStack(null);
+            MainActivity.getInstance().injectFragment(newFragment, true, MainActivity.MainMenuItem.RECORDS);
 
-            transaction.commit();
         }
 
     }

+ 26 - 49
src/de/tudarmstadt/informatik/hostage/ui2/popup/AbstractPopup.java

@@ -43,6 +43,12 @@ public abstract class AbstractPopup {
 
     }
 
+    public abstract LinearLayout getScrollableItemLayout();
+
+    public View getRootView(){
+        return this.rootView;
+    }
+
     public void addItem(final AbstractPopupItem item)	{
         View view = item.getItemView();
 
@@ -51,15 +57,17 @@ public abstract class AbstractPopup {
             this.configureView(this.rootView);
         }
         if (this.rootView != null){
-            this.rootView.addView(view);
+            this.getScrollableItemLayout().addView(view);
+            //this.rootView.addView(view);
             view.setOnTouchListener(new View.OnTouchListener() {
                 @Override
                 public boolean onTouch(View view, MotionEvent event) {
 	                if(event.getAction() == MotionEvent.ACTION_DOWN){
-						item.onItemDown(event);
-	                } else if (event.getAction() == MotionEvent.ACTION_UP){
-	                    item.onItemUp(event);
-
+						item.onItemSelect(event);
+	                } else if (event.getAction() == MotionEvent.ACTION_CANCEL || event.getAction() == MotionEvent.ACTION_MOVE){
+                        item.onItemDeselect(event);
+                    } else if (event.getAction() == MotionEvent.ACTION_UP){
+                        item.onItemDeselect(event);
                         AbstractPopup.this.onPopupItemClickListener.onItemClick(item.onClickedResult(event));
                         AbstractPopup.this.popupWindow.dismiss();
                     }
@@ -90,9 +98,9 @@ public abstract class AbstractPopup {
 
             Window window = this.context.getWindow();
             window.getDecorView().getWindowVisibleDisplayFrame(windowFrame);
-            int orientation = 1; //this.context.getResources().getConfiguration().orientation;
-            int windowWidth = orientation == ORIENTATION_LANDSCAPE ? windowFrame.height() : windowFrame.width();
-            int windowHeight = orientation == ORIENTATION_LANDSCAPE ? windowFrame.width() : windowFrame.height();
+            int orientation = this.context.getResources().getConfiguration().orientation;
+            int windowWidth = windowFrame.width();
+            int windowHeight = windowFrame.height();
 
             final int[] position = new int[2];
             anchorView.getLocationOnScreen(position);
@@ -104,15 +112,22 @@ public abstract class AbstractPopup {
 
             //int alh = (position[0] + width) - windowFrame.width();
             //if (alh < 0) alh = 0;
+            int offset = windowFrame.top;
 
             int x = position[0] + (anchorWidth / 2) - (width / 2);
-            int y = position[1] - height;
+            int y = (position[1] - height) + offset;
+
+            height+=(offset/2);
+
+            width = windowWidth < width ? windowWidth : width;
 
             x = Math.max(0, x);
             x = Math.min(windowWidth - width, x);
 
-            y = Math.min(0,y);
-            y = Math.max(windowHeight - height, y);
+            height = windowHeight < height ? windowHeight : height;
+
+            y = Math.max(0, y);
+            y = Math.min(windowHeight - height, y);
 
             AbstractPopup.this.configureView(this.rootView);
 
@@ -121,44 +136,6 @@ public abstract class AbstractPopup {
             this.popupWindow.setHeight(height);
             this.popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, x, y-smallBottomOffset);
 
-
-
-            /*
-            // TO SET THE REAL SIZE
-            ViewTreeObserver viewTreeObserver = this.rootView.getViewTreeObserver();
-            if (viewTreeObserver != null &&  viewTreeObserver.isAlive()) {
-                viewTreeObserver.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
-                    @Override
-                    public void onGlobalLayout() {
-                        ViewTreeObserver observer= AbstractPopup.this.rootView.getViewTreeObserver();
-                        if (observer != null)observer.removeOnGlobalLayoutListener(this);
-
-                        View rootView = AbstractPopup.this.rootView;
-
-                        int width = rootView.getWidth();
-                        int height = rootView.getHeight();
-
-                        int x = position[0] + (anchorWidth / 2) - (width / 2);
-                        int y = position[1] - height;
-
-                        x = Math.min(0,x);
-                        x = Math.max(windowFrame.width() - width, x);
-
-                        y = Math.min(0,y);
-                        y = Math.max(windowFrame.height() - height, y);
-
-                        AbstractPopup.this.configureView(rootView);
-
-                        int smallBottomOffset = 10;
-                        AbstractPopup.this.popupWindow.dismiss();
-                        AbstractPopup.this.popupWindow.setWidth(width);
-                        AbstractPopup.this.popupWindow.setHeight(height + smallBottomOffset);
-                        AbstractPopup.this.popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, x, y-smallBottomOffset);
-
-                    }
-                });
-            }
-            */
         }
     }
 

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/ui2/popup/AbstractPopupItem.java

@@ -75,10 +75,10 @@ public abstract class AbstractPopupItem {
         return this;
     }
 
-	public void onItemDown(MotionEvent event){
+	public void onItemSelect(MotionEvent event){
 	}
 
-	public void onItemUp(MotionEvent event){
+	public void onItemDeselect(MotionEvent event){
 
 	}
 }

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/ui2/popup/SimplePopupItem.java

@@ -56,12 +56,12 @@ public class SimplePopupItem extends AbstractPopupItem {
         return this.selected;
     }
 
-	public void onItemDown(MotionEvent event){
+	public void onItemSelect(MotionEvent event){
 		getContainer().setBackgroundColor(
 				context.getResources().getColor(android.R.color.holo_blue_light));
 	}
 
-	public void onItemUp(MotionEvent event){
+	public void onItemDeselect(MotionEvent event){
 		getContainer().setBackgroundColor(context.getResources().getColor(android.R.color.transparent));
 	}
 }

+ 6 - 0
src/de/tudarmstadt/informatik/hostage/ui2/popup/SimplePopupTable.java

@@ -2,6 +2,7 @@ package de.tudarmstadt.informatik.hostage.ui2.popup;
 
 import android.content.Context;
 import android.view.View;
+import android.widget.LinearLayout;
 import android.widget.TextView;
 
 import de.tudarmstadt.informatik.hostage.R;
@@ -25,6 +26,11 @@ public class SimplePopupTable extends AbstractPopup {
         super(context, listener);
     }
 
+    @Override
+    public LinearLayout getScrollableItemLayout() {
+        return (LinearLayout) this.getRootView().findViewById(R.id.item_scroll_layout);
+    }
+
     public int getLayoutId(){
         return R.layout.simple_popup_table;
     }

+ 2 - 2
src/de/tudarmstadt/informatik/hostage/ui2/popup/SplitPopupItem.java

@@ -85,7 +85,7 @@ public class SplitPopupItem extends AbstractPopupItem {
 		return right_container;
 	}
 
-	public void onItemDown(MotionEvent event){
+	public void onItemSelect(MotionEvent event){
 		int blue_color = context.getResources().getColor(android.R.color.holo_blue_light);
 		int trans_color = context.getResources().getColor(android.R.color.transparent);
 
@@ -98,7 +98,7 @@ public class SplitPopupItem extends AbstractPopupItem {
 		}
 	}
 
-	public void onItemUp(MotionEvent event){
+	public void onItemDeselect(MotionEvent event){
 		int trans_color = context.getResources().getColor(android.R.color.transparent);
 
 		getLeftContainer().setBackgroundColor(trans_color);