Explorar el Código

improved look and feel of abstract popups a bit. added link from attacks display on home to the records view

Alexander Brakowski hace 10 años
padre
commit
7652b80650

+ 1 - 0
res/layout/simple_popup_item.xml

@@ -37,6 +37,7 @@
 			android:layout_width="fill_parent"
 			android:layout_height="1dp"
 			android:background="@android:color/darker_gray"
+	        android:id="@+id/bottom_seperator"
 			/>
 
 </LinearLayout>

+ 2 - 1
res/layout/split_popup_item.xml

@@ -92,5 +92,6 @@
 	<View
 			android:layout_width="fill_parent"
 			android:layout_height="1dp"
-			android:background="@android:color/darker_gray"/>
+			android:background="@android:color/darker_gray"
+			android:id="@+id/bottom_seperator"/>
 </LinearLayout>

+ 28 - 1
src/de/tudarmstadt/informatik/hostage/ui2/fragment/HomeFragment.java

@@ -19,11 +19,14 @@ import android.widget.ImageView;
 import android.widget.Switch;
 import android.widget.TextView;
 
+import java.util.ArrayList;
+
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
 import de.tudarmstadt.informatik.hostage.dao.ProfileManager;
 import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
 import de.tudarmstadt.informatik.hostage.model.Profile;
+import de.tudarmstadt.informatik.hostage.ui.LogFilter;
 import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
 import de.tudarmstadt.informatik.hostage.ui2.fragment.opengl.ThreatIndicatorGLRenderer;
 
@@ -242,7 +245,7 @@ public class HomeFragment extends Fragment {
 	    mReceiver = new BroadcastReceiver() {
 		    @Override
 		    public void onReceive(Context context, Intent intent) {
-			    updateUI();
+			    if(getUserVisibleHint()) updateUI();
 		    }
 	    };
 	    registerBroadcastReceiver();
@@ -342,6 +345,30 @@ public class HomeFragment extends Fragment {
 			    }
 		    }
 	    );
+
+	    View.OnClickListener attackClickListener = new View.OnClickListener() {
+		    @Override
+		    public void onClick(View v) {
+			    String ssid = mConnectionInfo.getString(getString(R.string.connection_info_ssid), "");
+			    if(!ssid.isEmpty()){
+				    ArrayList<String> ssids = new ArrayList<String>();
+				    ssids.add(ssid);
+
+				    LogFilter filter = new LogFilter();
+				    filter.setESSIDs(ssids);
+
+				    RecordOverviewFragment recordOverviewFragment = new RecordOverviewFragment();
+				    recordOverviewFragment.setFilter(filter);
+				    recordOverviewFragment.setGroupKey("ESSID");
+
+				    MainActivity.getInstance().injectFragment(recordOverviewFragment);
+			    }
+		    }
+	    };
+
+	    mHomeTextAttacks.setOnClickListener(attackClickListener);
+	    mHomeTextSecurity.setOnClickListener(attackClickListener);
+
         return rootView;
     }
 

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

@@ -118,7 +118,7 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
         if (this.groupingKey == null) this.groupingKey = this.groupingTitles().get(0);
 
 	    this.setShowFilterButton(!this.filter.isNotEditable());
-	    this.addRecordToDB();
+	    //this.addRecordToDB();
 
 		View rootView = inflater.inflate(this.getLayoutId(), container, false);
 		ExpandableListView mylist = (ExpandableListView) rootView.findViewById(R.id.loglistview);
@@ -745,7 +745,6 @@ public class RecordOverviewFragment extends UpNavigatibleFragment implements Che
 	 * ***************************/
 
 	private void addRecordToDB() {
-
         if ((dbh.getRecordCount() > 0)) return;
 
 		Calendar cal = Calendar.getInstance();

+ 15 - 1
src/de/tudarmstadt/informatik/hostage/ui2/popup/AbstractPopup.java

@@ -12,6 +12,8 @@ import android.view.WindowManager;
 import android.widget.LinearLayout;
 import android.widget.PopupWindow;
 
+import de.tudarmstadt.informatik.hostage.R;
+
 /**
  * Created by Julien on 13.02.14.
  */
@@ -28,6 +30,7 @@ public abstract class AbstractPopup {
     private OnPopupItemClickListener onPopupItemClickListener;
     private LinearLayout rootView;
     private LayoutInflater lInf;
+	private View lastItemView;
 
     abstract public int getLayoutId();
     abstract void configureView(View view);
@@ -58,6 +61,8 @@ public abstract class AbstractPopup {
         }
         if (this.rootView != null){
             this.getScrollableItemLayout().addView(view);
+	        lastItemView = view;
+
             //this.rootView.addView(view);
             view.setOnTouchListener(new View.OnTouchListener() {
                 @Override
@@ -124,7 +129,7 @@ public abstract class AbstractPopup {
             x = Math.max(0, x);
             x = Math.min(windowWidth - width, x);
 
-            height = windowHeight < height ? windowHeight : height;
+            height = (windowHeight < height ? windowHeight : height) - 10;
 
             y = Math.max(0, y);
             y = Math.min(windowHeight - height, y);
@@ -134,6 +139,15 @@ public abstract class AbstractPopup {
             int smallBottomOffset = 45;
             this.popupWindow.setWidth(width);
             this.popupWindow.setHeight(height);
+
+	        if(lastItemView != null){
+		        View v = lastItemView.findViewById(R.id.bottom_seperator);
+
+		        if(v != null){
+			        v.setVisibility(View.GONE);
+		        }
+	        }
+
             this.popupWindow.showAtLocation(anchorView, Gravity.NO_GRAVITY, x, y-smallBottomOffset);
 
         }