Browse Source

fixed home orientation, and some other bugs

Alexander Brakowski 10 years ago
parent
commit
b3763c1899

+ 2 - 1
.gitignore

@@ -29,4 +29,5 @@ target/
 build/
 .gradle/
 gen-external-apklibs/
-
+native/p
+native/p.o

+ 94 - 44
res/layout/fragment_about.xml

@@ -9,52 +9,102 @@
 			android:layout_width="match_parent"
 			android:layout_height="match_parent"
 			android:id="@+id/imageView" android:src="@drawable/hostage_logo_tilted"
-			android:layout_weight="0.4" android:layout_margin="24dp"/>
+			android:layout_weight="0.6" android:layout_margin="24dp"/>
 
-	<LinearLayout
-			android:orientation="vertical"
-			android:layout_width="match_parent"
-			android:layout_height="match_parent"
-			android:layout_weight="0.6">
-		<TextView
+	<TextView
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:textAppearance="?android:attr/textAppearanceLarge"
+			android:text="HosTaGe"
+			android:id="@+id/textView" android:layout_gravity="center_horizontal"
+			android:textStyle="bold"/>
+	<TextView
+			android:layout_width="wrap_content"
+			android:layout_height="wrap_content"
+			android:textAppearance="?android:attr/textAppearanceSmall"
+			android:text="Honeypot To Go"
+			android:id="@+id/textView7" android:layout_gravity="center_horizontal"
+			/>
+	<RelativeLayout
+			android:orientation="horizontal"
+			android:layout_width="fill_parent"
+			android:layout_height="fill_parent" android:layout_weight="0.7"
+			android:paddingTop="20dp">
+		<LinearLayout
+				android:orientation="vertical"
 				android:layout_width="wrap_content"
 				android:layout_height="wrap_content"
-				android:textAppearance="?android:attr/textAppearanceLarge"
-				android:text="HosTaGe"
-				android:id="@+id/textView" android:layout_gravity="center_horizontal"
-				android:textStyle="bold"/>
-		<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
-				  android:textAppearance="?android:attr/textAppearanceMedium"
-				  android:text="UI designed by:"
-				  android:id="@+id/textView4" android:layout_gravity="center_horizontal"
-				  android:singleLine="false" android:autoText="false"
-				  android:layout_marginTop="8dp"/>
-		<TextView
+				android:layout_weight="0.5"
+				android:layout_alignTop="@+id/linearLayout" android:layout_alignParentLeft="true"
+				android:layout_alignParentStart="true" android:id="@+id/linearLayout2"
+				android:layout_marginLeft="10dp">
+			<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+					  android:textAppearance="?android:attr/textAppearanceMedium"
+					  android:text="UI developed by"
+					  android:id="@+id/textView4" android:layout_gravity="center_horizontal|left"
+					  android:singleLine="false" android:autoText="false"
+					  android:layout_marginTop="8dp" android:textStyle="bold"
+					  android:textColor="@android:color/holo_blue_dark"/>
+			<TextView
+					android:layout_width="wrap_content"
+					android:layout_height="wrap_content"
+					android:textAppearance="?android:attr/textAppearanceMedium"
+					android:text="Fabio Arnold"
+					android:id="@+id/textView2"
+					android:layout_gravity="center_horizontal|left"
+					android:singleLine="false" android:autoText="false" android:layout_marginTop="4dp"
+					android:textAlignment="center"/>
+			<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+			          android:textAppearance="?android:attr/textAppearanceMedium"
+			          android:text="Alexander Brakowski"
+			          android:id="@+id/textView3" android:layout_gravity="center_horizontal|left"
+			          android:singleLine="false" android:autoText="false" android:layout_marginTop="4dp"
+			          android:textAlignment="center"/>
+			<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+			          android:textAppearance="?android:attr/textAppearanceMedium"
+			          android:text="Julien Clauter" android:id="@+id/textView5"
+			          android:layout_gravity="center_horizontal|left" android:singleLine="false"
+			          android:autoText="false" android:layout_marginTop="4dp"
+			          android:textAlignment="center"/>
+			<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+			          android:textAppearance="?android:attr/textAppearanceMedium"
+			          android:text="Daniel Lazar" android:id="@+id/textView6"
+			          android:layout_gravity="center_horizontal|left" android:singleLine="false"
+			          android:autoText="false" android:layout_marginTop="4dp"
+			          android:textAlignment="center"/>
+		</LinearLayout>
+		<LinearLayout
+				android:orientation="vertical"
 				android:layout_width="wrap_content"
-				android:layout_height="wrap_content"
-				android:textAppearance="?android:attr/textAppearanceMedium"
-				android:text="Fabio Arnold"
-				android:id="@+id/textView2"
-				android:layout_gravity="center_horizontal"
-				android:singleLine="false" android:autoText="false" android:layout_marginTop="4dp"
-				android:textAlignment="center"/>
-		<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
-		          android:textAppearance="?android:attr/textAppearanceMedium"
-		          android:text="Alexander Brakowski"
-		          android:id="@+id/textView3" android:layout_gravity="center_horizontal"
-		          android:singleLine="false" android:autoText="false" android:layout_marginTop="4dp"
-		          android:textAlignment="center"/>
-		<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
-		          android:textAppearance="?android:attr/textAppearanceMedium"
-		          android:text="Julien Clauter" android:id="@+id/textView5"
-		          android:layout_gravity="center_horizontal" android:singleLine="false"
-		          android:autoText="false" android:layout_marginTop="4dp"
-		          android:textAlignment="center"/>
-		<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
-		          android:textAppearance="?android:attr/textAppearanceMedium"
-		          android:text="Daniel Lazar" android:id="@+id/textView6"
-		          android:layout_gravity="center_horizontal" android:singleLine="false"
-		          android:autoText="false" android:layout_marginTop="4dp"
-		          android:textAlignment="center"/>
-	</LinearLayout>
+				android:layout_height="wrap_content" android:layout_weight="0.5"
+				android:id="@+id/linearLayout"
+				android:layout_alignParentTop="true" android:layout_alignParentRight="true"
+				android:layout_alignParentEnd="true" android:layout_marginRight="10dp">
+			<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+			          android:textAppearance="?android:attr/textAppearanceMedium"
+			          android:text="Core developed by" android:id="@+id/textView8"
+			          android:singleLine="false"
+			          android:autoText="false" android:layout_marginTop="8dp"
+			          android:textStyle="bold" android:textColor="@android:color/holo_blue_dark"
+			          android:layout_gravity="right"/>
+			<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+			          android:textAppearance="?android:attr/textAppearanceMedium"
+			          android:text="Lars Pandikow" android:id="@+id/textView9"
+			          android:singleLine="false"
+			          android:autoText="false" android:layout_marginTop="4dp"
+			          android:textAlignment="center" android:layout_gravity="right"/>
+			<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+			          android:textAppearance="?android:attr/textAppearanceMedium"
+			          android:text="Wulf Pfeiffer" android:id="@+id/textView10"
+			          android:singleLine="false"
+			          android:autoText="false" android:layout_marginTop="4dp"
+			          android:textAlignment="center" android:layout_gravity="right"/>
+			<TextView android:layout_width="wrap_content" android:layout_height="wrap_content"
+			          android:textAppearance="?android:attr/textAppearanceMedium"
+			          android:text="Mihai Plasoianu " android:id="@+id/textView12"
+			          android:singleLine="false"
+			          android:autoText="false" android:layout_marginTop="4dp"
+			          android:textAlignment="center" android:layout_gravity="right"/>
+		</LinearLayout>
+	</RelativeLayout>
 </LinearLayout>

+ 11 - 1
res/layout/fragment_home.xml

@@ -119,7 +119,8 @@
 
         <RelativeLayout
             android:layout_width="fill_parent"
-            android:layout_height="match_parent" >
+            android:layout_height="match_parent" android:id="@+id/home_profile_details"
+		        >
 
             <TextView
                 android:id="@+id/home_text_profile_header"
@@ -140,6 +141,15 @@
                 android:layout_centerHorizontal="true"
                 android:text="Windows 7"
                 android:textSize="11sp" />
+	        <ImageView
+			        android:layout_width="wrap_content"
+			        android:layout_height="wrap_content"
+			        android:id="@+id/home_image_profile"
+			        android:src="@drawable/ic_launcher"
+			        android:scaleType="fitCenter"
+			        android:layout_alignBottom="@+id/home_text_profile"
+			        android:layout_toLeftOf="@+id/home_text_profile_header"
+			        android:layout_alignTop="@+id/home_text_profile_header"/>
         </RelativeLayout>
     </LinearLayout>
 

+ 1 - 1
res/layout/fragment_profile_manager.xml

@@ -7,7 +7,7 @@
     android:layout_height="fill_parent"
     android:id="@+id/profile_manager_root_view">
 
-    <com.fortysevendeg.android.swipelistview.SwipeListView
+    <de.tudarmstadt.informatik.hostage.ui2.swipelist.SwipeListView
         android:layout_width="match_parent"
         android:layout_height="match_parent"
         xmlns:swipe="http://schemas.android.com/apk/res-auto"

+ 45 - 0
res/layout/fragment_settings.xml

@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="utf-8"?>
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+              android:orientation="vertical"
+              android:layout_width="match_parent"
+              android:layout_height="match_parent">
+
+	<RelativeLayout
+			android:layout_width="match_parent"
+			android:layout_height="wrap_content" android:padding="16dp">
+		<TextView
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
+				android:textAppearance="?android:attr/textAppearanceMedium"
+				android:text="Device rooted"
+				android:id="@+id/textView" android:textStyle="bold"/>
+		<TextView
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
+				android:textAppearance="?android:attr/textAppearanceMedium"
+				android:text="Porthack installed"
+				android:id="@+id/textView2"
+				android:layout_below="@+id/textView" android:layout_alignParentLeft="true"
+				android:layout_alignParentStart="true" android:textStyle="bold"/>
+		<TextView
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
+				android:textAppearance="?android:attr/textAppearanceMedium"
+				android:text="Yes"
+				android:id="@+id/textView3" android:layout_above="@+id/textView2"
+				android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/>
+		<TextView
+				android:layout_width="wrap_content"
+				android:layout_height="wrap_content"
+				android:textAppearance="?android:attr/textAppearanceMedium"
+				android:text="Yes"
+				android:id="@+id/textView4" android:layout_below="@+id/textView3"
+				android:layout_alignParentRight="true" android:layout_alignParentEnd="true"/>
+	</RelativeLayout>
+	<FrameLayout
+			android:layout_width="fill_parent"
+			android:layout_height="fill_parent"
+			android:id="@+id/settings_fragment_container">
+	</FrameLayout>
+</LinearLayout>

+ 16 - 13
res/layout/split_popup_item.xml

@@ -8,14 +8,15 @@
 	    android:layout_width="match_parent"
 	    android:layout_height="wrap_content"
 	    android:gravity="top|center"
-	    android:weightSum="1">
+			>
 
 	    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 	        android:orientation="vertical"
 	        android:layout_width="wrap_content"
 	        android:layout_height="85dp"
-	        android:layout_weight="0.5"
-	        android:padding="2dp" android:id="@+id/popup_left_container">
+	        android:layout_weight="1"
+	        android:padding="2dp" android:id="@+id/popup_left_container"
+	        android:layout_gravity="left">
 		    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 		        android:orientation="vertical"
 		        android:layout_width="match_parent"
@@ -26,19 +27,19 @@
 		            android:layout_width="wrap_content"
 		            android:layout_height="wrap_content"
 		            android:textAppearance="?android:attr/textAppearanceMedium"
-		            android:text="Title"
+		            android:text="Earliest"
 		            android:id="@+id/left_title_text_view"
 		            android:textColor="#ffffff"
 		            android:layout_alignParentStart="true"
 		            android:textAlignment="textStart"
 		            android:textStyle="bold"/>
 		        <TextView
-		            android:layout_width="match_parent"
-		            android:layout_height="match_parent"
+		            android:layout_width="wrap_content"
+		            android:layout_height="wrap_content"
 		            android:textAppearance="?android:attr/textAppearanceSmall"
 		            android:text="Subtitle"
 		            android:id="@+id/left_subtitle_text_view"
-		            android:textColor="#ffffff"
+		            android:textColor="@color/light_grey"
 		            android:layout_alignParentStart="true"
 		            android:textAlignment="center"
 		            android:textIsSelectable="false"/>
@@ -48,15 +49,17 @@
 		<View
 				android:layout_height="fill_parent"
 				android:layout_width="1dp"
-				android:background="@android:color/darker_gray" android:layout_weight="0"/>
+				android:background="@android:color/darker_gray"
+				android:layout_marginTop="5dp" android:layout_marginBottom="5dp"
+				android:layout_weight="0"/>
 
 	    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 	        android:orientation="vertical"
 	        android:layout_width="wrap_content"
 	        android:layout_height="85dp"
-	        android:layout_weight="0.5"
+	        android:layout_weight="1"
 	        android:id="@+id/popup_right_container"
-	        android:padding="2dp">
+	        android:padding="2dp" android:layout_gravity="right">
 	    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 	        android:orientation="vertical"
 	        android:layout_width="match_parent"
@@ -74,12 +77,12 @@
 	            android:textAlignment="textStart"
 	            android:textStyle="bold"/>
 	        <TextView
-	            android:layout_width="match_parent"
-	            android:layout_height="match_parent"
+	            android:layout_width="wrap_content"
+	            android:layout_height="wrap_content"
 	            android:textAppearance="?android:attr/textAppearanceSmall"
 	            android:text="Subtitle"
 	            android:id="@+id/right_subtitle_text_view"
-	            android:textColor="#ffffff"
+	            android:textColor="@color/light_grey"
 	            android:layout_alignParentStart="true"
 	            android:textAlignment="center"
 	            android:paddingLeft="3dp" android:paddingRight="3dp"/>

+ 1 - 0
res/values/colors.xml

@@ -4,6 +4,7 @@
         <color name="dark_grey">#FF808080</color>
         <color name="holo_red">#FFF44444</color>
         <color name="holo_dark_green">#ff669900</color>
+		<color name="holo_yellow">#FFFFBB33</color>
         <color name="apptheme_color">#33b5e5</color>
 
 </resources>

+ 0 - 8
res/xml/settings_preferences.xml

@@ -1,13 +1,5 @@
 <?xml version="1.0" encoding="utf-8"?>
 <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >
-
-	<CheckBoxPreference
-		android:defaultValue="false"
-	    android:key="pref_general_expert"
-	    android:summary="This will activate expert functionalities"
-	    android:title="Expert Mode"/>
-
-
 	<PreferenceCategory android:title="@string/pref_notification" >
 		<CheckBoxPreference
 				android:defaultValue="true"

+ 1 - 0
src/de/tudarmstadt/informatik/hostage/HoneyListener.java

@@ -175,6 +175,7 @@ public class HoneyListener implements Runnable {
 					startHandler(client);
 				}
 			} catch (Exception e) {
+				if(server.isClosed()) return;
 				e.printStackTrace();
 			}
 		}

+ 4 - 1
src/de/tudarmstadt/informatik/hostage/dao/ProfileManager.java

@@ -131,10 +131,13 @@ public class ProfileManager {
 
 		profile.mActivated = true;
 		this.mCurrentActivatedProfile = profile;
-
 		this.dbh.persistProfile(profile);
 	}
 
+	public Profile getCurrentActivatedProfile(){
+		return mCurrentActivatedProfile;
+	}
+
 	public void setProfileListAdapter(ProfileManagerListAdapter profileListAdapter){
 		this.mProfileListAdapter = profileListAdapter;
 	}

+ 13 - 0
src/de/tudarmstadt/informatik/hostage/logging/UglyDbHelper.java

@@ -304,6 +304,19 @@ public class UglyDbHelper extends SQLiteOpenHelper {
 		return result > 0;
 	}
 
+	public int numBssidSeen(String protocol, String BSSID) {
+		String countQuery = "SELECT  * FROM " + TABLE_ATTACK_INFO
+				+ " JOIN " + TABLE_BSSIDS + " USING " + "(" + KEY_BSSID + ")" + " WHERE " + TABLE_ATTACK_INFO + "." +  KEY_PROTOCOL
+				+ " = " + "'" + protocol + "'" + " AND " + TABLE_BSSIDS+ "."+ KEY_BSSID + " = "
+				+ "'" + BSSID + "'";
+		SQLiteDatabase db = this.getReadableDatabase();
+		Cursor cursor = db.rawQuery(countQuery, null);
+		int result = cursor.getCount();
+		cursor.close();
+		db.close();
+		return result;
+	}
+
 	/**
 	 * Determines if an attack has been recorded on a specific protocol in a
 	 * network with a given BSSID.

+ 11 - 3
src/de/tudarmstadt/informatik/hostage/ui2/activity/MainActivity.java

@@ -10,6 +10,7 @@ import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
 import android.content.ServiceConnection;
+import android.content.pm.ActivityInfo;
 import android.content.res.Configuration;
 import android.content.res.TypedArray;
 import android.os.Bundle;
@@ -73,7 +74,7 @@ public class MainActivity extends Activity {
 
 	private ArrayList<DrawerListItem> mDrawerItems;
 
-	private boolean mServiceBound;
+	private boolean mServiceBound = false;
 
 	/**
 	 * Connection to bind the background service
@@ -222,12 +223,12 @@ public class MainActivity extends Activity {
 
 	public void unbindService() {
 		unbindService(mConnection);
-		mServiceBound = false;
+		//mServiceBound = false;
 	}
 
 	public void bindService() {
 		bindService(getServiceIntent(), mConnection, BIND_AUTO_CREATE);
-		mServiceBound = true;
+		//mServiceBound = true;
 	}
 
 	@Override
@@ -289,6 +290,13 @@ public class MainActivity extends Activity {
 
         Fragment fragment = null;
 
+		// set orientation fixed to portrait in home fragment
+		if(menuItemPosition == MainMenuItem.HOME){
+			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT | ActivityInfo.SCREEN_ORIENTATION_NOSENSOR);
+		} else {
+			setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
+		}
+
         // update the main content by replacing fragments
 		switch (menuItemPosition) {
 			case HOME:

+ 1 - 2
src/de/tudarmstadt/informatik/hostage/ui2/adapter/ProfileManagerListAdapter.java

@@ -14,8 +14,6 @@ import android.widget.ImageView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
 
-import com.fortysevendeg.android.swipelistview.SwipeListView;
-
 import java.util.List;
 
 import de.tudarmstadt.informatik.hostage.R;
@@ -23,6 +21,7 @@ import de.tudarmstadt.informatik.hostage.dao.ProfileManager;
 import de.tudarmstadt.informatik.hostage.model.Profile;
 import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
 import de.tudarmstadt.informatik.hostage.ui2.activity.ProfileEditActivity;
+import de.tudarmstadt.informatik.hostage.ui2.swipelist.SwipeListView;
 
 /**
  * @author Alexander Brakowski

+ 102 - 34
src/de/tudarmstadt/informatik/hostage/ui2/fragment/HomeFragment.java

@@ -6,6 +6,7 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.IntentFilter;
+import android.content.SharedPreferences;
 import android.net.wifi.WifiManager;
 import android.os.Bundle;
 import android.support.v4.content.LocalBroadcastManager;
@@ -13,11 +14,15 @@ import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.CompoundButton;
+import android.widget.ImageView;
 import android.widget.Switch;
 import android.widget.TextView;
 
 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.ui2.activity.MainActivity;
 import de.tudarmstadt.informatik.hostage.ui2.fragment.opengl.ThreatIndicatorGLRenderer;
 
@@ -34,6 +39,7 @@ public class HomeFragment extends Fragment {
 	private TextView mHomeTextAttacks;
 	private TextView mHomeTextProfile;
 	private TextView mHomeTextProfileHeader;
+	private ImageView mHomeProfileImage;
 
 	private View rootView;
 	private BroadcastReceiver mReceiver;
@@ -41,6 +47,12 @@ public class HomeFragment extends Fragment {
 	private CompoundButton.OnCheckedChangeListener switchChangeListener = null;
 
 	private int defaultTextColor;
+	private ProfileManager mProfileManager;
+
+	private SharedPreferences mConnectionInfo;
+	private UglyDbHelper dbh;
+
+	private static int DANGER_LEVEL= 0;
 
 	private void assignViews() {
 		mHomeSwitchConnection = (Switch) rootView.findViewById(R.id.home_switch_connection);
@@ -49,6 +61,7 @@ public class HomeFragment extends Fragment {
 		mHomeTextAttacks = (TextView) rootView.findViewById(R.id.home_text_attacks);
 		mHomeTextProfile = (TextView) rootView.findViewById(R.id.home_text_profile);
 		mHomeTextProfileHeader = (TextView) rootView.findViewById(R.id.home_text_profile_header);
+		mHomeProfileImage = (ImageView) rootView.findViewById(R.id.home_image_profile);
 	}
 
 	private void registerBroadcastReceiver(){
@@ -66,45 +79,44 @@ public class HomeFragment extends Fragment {
 				//}
 			}
 		};
-
-		/*IntentFilter intentFilter = new IntentFilter();
-		intentFilter.addAction(WifiManager.SUPPLICANT_CONNECTION_CHANGE_ACTION);
-		intentFilter.addAction(WifiManager.SUPPLICANT_STATE_CHANGED_ACTION);
-		intentFilter.addAction(WifiManager.WIFI_STATE_CHANGED_ACTION);
-		intentFilter.addAction(WifiManager.NETWORK_STATE_CHANGED_ACTION);*/
-
 		LocalBroadcastManager.getInstance(getActivity()).registerReceiver(mReceiver, new IntentFilter(getString(R.string.broadcast)));
-		//getActivity().registerReceiver(mReceiver, intentFilter);
 	}
 
 	public HomeFragment(){}
 
-	public void setStateNotActive(){
+	public void setStateNotActive(boolean initial){
 		mHomeTextName.setTextColor(getResources().getColor(R.color.light_grey));
 		mHomeTextSecurity.setTextColor(getResources().getColor(R.color.light_grey));
 		mHomeTextAttacks.setTextColor(getResources().getColor(R.color.light_grey));
 		mHomeTextProfile.setTextColor(getResources().getColor(R.color.light_grey));
 		mHomeTextProfileHeader.setTextColor(getResources().getColor(R.color.light_grey));
-		
-	    ThreatIndicatorGLRenderer.setThreatLevel(ThreatIndicatorGLRenderer.kThreatLevelNotMonitoring);
+
+		if(!initial){
+	        ThreatIndicatorGLRenderer.setThreatLevel(ThreatIndicatorGLRenderer.kThreatLevelNotMonitoring);
+		}
 
 		mHomeSwitchConnection.setChecked(false);
 	}
 
+	public void setStateNotActive(){
+		setStateNotActive(false);
+	}
+
 	public void setStateActive(){
-		mHomeTextAttacks.setText("0 attacks recorded");
-		mHomeTextSecurity.setText("Secure");
-		mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_dark_green));
-		mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_dark_green));
+		setStateActive(false);
+	}
 
+	public void setStateActive(boolean initial){
 		mHomeTextAttacks.setVisibility(View.VISIBLE);
 		mHomeTextSecurity.setVisibility(View.VISIBLE);
 
 		mHomeTextName.setTextColor(defaultTextColor);
 		mHomeTextProfile.setTextColor(defaultTextColor);
 		mHomeTextProfileHeader.setTextColor(defaultTextColor);
-		
-	    ThreatIndicatorGLRenderer.setThreatLevel(ThreatIndicatorGLRenderer.kThreatLevelNoThreat);
+
+		if(!initial){
+	        ThreatIndicatorGLRenderer.setThreatLevel(ThreatIndicatorGLRenderer.kThreatLevelNoThreat);
+		}
 
 		mHomeSwitchConnection.setChecked(true);
 	}
@@ -124,14 +136,76 @@ public class HomeFragment extends Fragment {
 	}
 
 	public void updateUI(){
-		if(!HelperUtils.isWifiConnected(getActivity())){
+		Profile profile = mProfileManager.getCurrentActivatedProfile();
+		if(profile != null){
+			mHomeTextProfile.setText(profile.mLabel);
+			mHomeProfileImage.setImageBitmap(profile.getIconBitmap());
+		}
+
+		if(HelperUtils.isWifiConnected(getActivity())){
+			setStateConnected();
+			mHomeTextName.setText(mConnectionInfo.getString(getString(R.string.connection_info_ssid), ""));
+		}
+
+		int dangerLevel = 0;
+		boolean hasActiveListeners = false;
+		int totalAttacks = 0;
+		int totalLogged = 0;
+
+		if(MainActivity.getInstance().isServiceBound()){
+			for(String protocol: getResources().getStringArray(R.array.protocols)){
+				if(MainActivity.getInstance().getHoneyService().isRunning(protocol)){
+					hasActiveListeners = true;
+					int attacks = MainActivity.getInstance().getHoneyService().getNumberOfActiveConnections(protocol);
+
+					if(attacks == 0){
+						int log_attacks = dbh.numBssidSeen(protocol, mConnectionInfo.getString(getString(R.string.connection_info_bssid), null));
+						totalLogged += log_attacks;
+
+						if(log_attacks > 0){
+							DANGER_LEVEL = Math.max(1, DANGER_LEVEL);
+						} else {
+							DANGER_LEVEL = Math.max(0, DANGER_LEVEL);
+						}
+					} else {
+						totalAttacks += attacks;
+						DANGER_LEVEL = Math.max(2, DANGER_LEVEL);
+					}
+				}
+			}
+		}
+
+		if(hasActiveListeners){
+			setStateActive(true);
+
+			if(DANGER_LEVEL == 0){
+				mHomeTextAttacks.setText("0 attacks recorded");
+				mHomeTextSecurity.setText("Secure");
+				mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_dark_green));
+				mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_dark_green));
+			} else if(DANGER_LEVEL == 1){
+				mHomeTextAttacks.setText(totalLogged + (totalLogged == 1 ? " attack" : " attacks") +  " logged");
+				mHomeTextSecurity.setText("Insecure");
+				mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_yellow));
+				mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_yellow));
+			} else if(DANGER_LEVEL == 2){
+				mHomeTextAttacks.setText(totalAttacks + (totalAttacks == 1 ? " attack" : " attacks") +  " recorded");
+				mHomeTextSecurity.setText("Insecure");
+				mHomeTextAttacks.setTextColor(getResources().getColor(R.color.holo_red));
+				mHomeTextSecurity.setTextColor(getResources().getColor(R.color.holo_red));
+			}
+
+			ThreatIndicatorGLRenderer.setThreatLevel(DANGER_LEVEL + 1);
+		} else {
 			mHomeSwitchConnection.setOnCheckedChangeListener(null);
-			setStateNotConnected();
 			setStateNotActive();
+			DANGER_LEVEL = 0;
+
+			if(!HelperUtils.isWifiConnected(getActivity())){
+				setStateNotConnected();
+			}
+
 			mHomeSwitchConnection.setOnCheckedChangeListener(switchChangeListener);
-		} else {
-			setStateConnected();
-			mHomeTextName.setText(HelperUtils.getSSID(getActivity()));
 		}
 	}
 
@@ -141,12 +215,17 @@ public class HomeFragment extends Fragment {
 
 	    super.onCreateView(inflater, container, savedInstanceState);
 
+	    dbh = new UglyDbHelper(getActivity());
+
+	    mProfileManager = ProfileManager.getInstance();
+		mConnectionInfo = getActivity().getSharedPreferences(getString(R.string.connection_info), Context.MODE_PRIVATE);
+
         rootView = inflater.inflate(R.layout.fragment_home, container, false);
 	    assignViews();
 
 	    defaultTextColor = mHomeTextName.getCurrentTextColor();
 
-	    setStateNotActive();
+	    setStateNotActive(true);
 	    setStateNotConnected();
 
 	    registerBroadcastReceiver();
@@ -155,17 +234,6 @@ public class HomeFragment extends Fragment {
 
 		final String[] protocols = getResources().getStringArray(R.array.protocols);
 
-		if(MainActivity.getInstance().getHoneyService() == null){
-			// do nothing
-		}
-		else {
-			for(String protocol: protocols){
-				if (MainActivity.getInstance().getHoneyService().isRunning(protocol)) {
-					setStateActive();
-				}
-			}
-		}
-
 	    mHomeSwitchConnection = (Switch) rootView.findViewById(R.id.home_switch_connection);
 
 	    if(switchChangeListener == null){

+ 19 - 0
src/de/tudarmstadt/informatik/hostage/ui2/fragment/PreferenceHostageFrament.java

@@ -0,0 +1,19 @@
+package de.tudarmstadt.informatik.hostage.ui2.fragment;
+
+import android.os.Bundle;
+import android.preference.PreferenceFragment;
+
+import de.tudarmstadt.informatik.hostage.R;
+
+/**
+ * @author Alexander Brakowski
+ * @created 02.03.14 21:03
+ */
+public class PreferenceHostageFrament extends PreferenceFragment {
+	@Override
+	public void onCreate(Bundle savedInstanceState){
+		super.onCreate(savedInstanceState);
+
+		addPreferencesFromResource(R.xml.settings_preferences);
+	}
+}

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

@@ -11,7 +11,6 @@ import android.view.View;
 import android.view.ViewGroup;
 
 import com.fortysevendeg.android.swipelistview.BaseSwipeListViewListener;
-import com.fortysevendeg.android.swipelistview.SwipeListView;
 
 import java.util.List;
 
@@ -20,6 +19,7 @@ import de.tudarmstadt.informatik.hostage.dao.ProfileManager;
 import de.tudarmstadt.informatik.hostage.model.Profile;
 import de.tudarmstadt.informatik.hostage.ui2.activity.ProfileEditActivity;
 import de.tudarmstadt.informatik.hostage.ui2.adapter.ProfileManagerListAdapter;
+import de.tudarmstadt.informatik.hostage.ui2.swipelist.SwipeListView;
 
 /**
  * @author Alexander Brakowski

+ 14 - 5
src/de/tudarmstadt/informatik/hostage/ui2/fragment/SettingsFragment.java

@@ -1,7 +1,12 @@
 package de.tudarmstadt.informatik.hostage.ui2.fragment;
 
+import android.app.Fragment;
+import android.app.FragmentManager;
 import android.os.Bundle;
 import android.preference.PreferenceFragment;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
 
 import de.tudarmstadt.informatik.hostage.R;
 
@@ -9,12 +14,16 @@ import de.tudarmstadt.informatik.hostage.R;
  * @author Alexander Brakowski
  * @created 24.02.14 23:37
  */
-public class SettingsFragment extends PreferenceFragment {
+public class SettingsFragment extends Fragment {
+	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState){
+		super.onCreateView(inflater, container, savedInstanceState);
+		return inflater.inflate(R.layout.fragment_settings, container, false);
+	}
 
-	@Override
-	public void onCreate(Bundle savedInstanceState){
-		super.onCreate(savedInstanceState);
+	public void onViewCreated(View view, Bundle savedInstanceState) {
+		super.onViewCreated(view, savedInstanceState);
 
-		addPreferencesFromResource(R.xml.settings_preferences);
+		FragmentManager manager = this.getFragmentManager();
+		manager.beginTransaction().replace(R.id.settings_fragment_container, new PreferenceHostageFrament()).commit();
 	}
 }

+ 37 - 0
src/de/tudarmstadt/informatik/hostage/ui2/swipelist/SwipeListView.java

@@ -0,0 +1,37 @@
+package de.tudarmstadt.informatik.hostage.ui2.swipelist;
+
+import android.content.Context;
+import android.util.AttributeSet;
+
+/**
+ * @author Alexander Brakowski
+ * @created 28.02.14 22:05
+ */
+public class SwipeListView extends com.fortysevendeg.android.swipelistview.SwipeListView {
+
+
+	public SwipeListView(Context context, int swipeBackView, int swipeFrontView) {
+		super(context, swipeBackView, swipeFrontView);
+	}
+
+	public SwipeListView(Context context, AttributeSet attrs) {
+		super(context, attrs);
+	}
+
+	public SwipeListView(Context context, AttributeSet attrs, int defStyle) {
+		super(context, attrs, defStyle);
+	}
+
+	protected void onOpened(int position, boolean toRight) {
+		super.onOpened(position, toRight);
+
+		int start = getFirstVisiblePosition();
+		int end = getLastVisiblePosition();
+
+		for(int i=start; i<=end; i++){
+			if(i != position){
+				closeAnimate(i);
+			}
+		}
+	}
+}