Quellcode durchsuchen

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

Conflicts:
	src/de/tudarmstadt/informatik/hostage/ui2/fragment/RecordOverviewFragment.java
Julien Clauter vor 11 Jahren
Ursprung
Commit
cdb2fd1b6d
26 geänderte Dateien mit 833 neuen und 267 gelöschten Zeilen
  1. 2 29
      AndroidManifest.xml
  2. 53 0
      AndroidManifest.xml~
  3. 82 0
      pom.xml~
  4. BIN
      res/drawable-hdpi/ic_action_stats.png
  5. BIN
      res/drawable-hdpi/ic_menu_allfriends.png
  6. BIN
      res/drawable-hdpi/ic_menu_stats.png
  7. BIN
      res/drawable-mdpi/ic_action_stats.png
  8. BIN
      res/drawable-mdpi/ic_menu_allfriends.png
  9. BIN
      res/drawable-mdpi/ic_menu_stats.png
  10. BIN
      res/drawable-xhdpi/ic_action_stats.png
  11. BIN
      res/drawable-xhdpi/ic_menu_allfriends.png
  12. BIN
      res/drawable-xxhdpi/ic_action_stats.png
  13. BIN
      res/drawable-xxhdpi/ic_menu_allfriends.png
  14. BIN
      res/drawable-xxhdpi/ic_menu_stats.png
  15. 59 58
      res/layout/profile_manager_list_item.xml
  16. 138 0
      src/de/tudarmstadt/informatik/hostage/dao/ProfileManager.java
  17. 50 0
      src/de/tudarmstadt/informatik/hostage/model/Profile.java
  18. 101 2
      src/de/tudarmstadt/informatik/hostage/ui2/activity/MainActivity.java
  19. 2 6
      src/de/tudarmstadt/informatik/hostage/ui2/activity/ProfileEditActivity.java
  20. 61 11
      src/de/tudarmstadt/informatik/hostage/ui2/adapter/ProfileManagerListAdapter.java
  21. 132 0
      src/de/tudarmstadt/informatik/hostage/ui2/fragment/ProfileEditFragment.java
  22. 25 32
      src/de/tudarmstadt/informatik/hostage/ui2/fragment/ProfileManagerFragment.java
  23. 78 69
      src/de/tudarmstadt/informatik/hostage/ui2/fragment/RecordOverviewFragment.java
  24. 50 16
      src/de/tudarmstadt/informatik/hostage/ui2/fragment/ThreatMapFragment.java
  25. 0 10
      src/de/tudarmstadt/informatik/hostage/ui2/model/Profile.java
  26. 0 34
      src/de/tudarmstadt/informatik/hostage/ui2/preference/ProfileEditFragment.java

+ 2 - 29
AndroidManifest.xml

@@ -40,7 +40,7 @@
 				android:value="14"/>
 		<meta-data
 				android:name="com.google.android.maps.v2.API_KEY"
-				android:value="AIzaSyDZ-Zr6u5wXwpVIQ_7-J9e82BF_lESvWes"/>
+				android:value="AIzaSyCLAiF5Dx6qkDwWUfNnteMcapILmjCbuZ0"/>
 		<activity
 				android:name="de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity"
 				android:configChanges="keyboardHidden|orientation|screenSize"
@@ -65,7 +65,7 @@
             android:label="@string/database" >
         </activity>
 	    <activity
-			    android:name="de.tudarmstadt.informatik.hostage.ui2.preference.ProfileEditActivity"
+			    android:name=".ui2.activity.ProfileEditActivity"
 			    android:label="Edit Profile" >
 	    </activity>
         <activity
@@ -103,33 +103,6 @@
 			android:label="@string/database" >
 		</activity>
 		-->
-		<activity
-				android:name="de.tudarmstadt.informatik.hostage.ui2.preference.ProfileEditActivity"
-				android:label="Edit Profile">
-		</activity>
-		<activity
-				android:name="de.tudarmstadt.informatik.hostage.ui.SettingsActivity"
-				android:label="@string/settings">
-		</activity>
-		<activity
-				android:name="de.tudarmstadt.informatik.hostage.ui.AboutActivity"
-				android:label="@string/gui_action_about">
-		</activity>
-		<activity
-				android:name="de.tudarmstadt.informatik.hostage.ui.PlayGroundActivity"
-				android:label="@string/gui_playground">
-		</activity>
-		<activity
-				android:name="de.tudarmstadt.informatik.hostage.sync.NFCSync"
-				android:label="@string/gui_playground">
-			<intent-filter>
-				<action android:name="android.nfc.action.NDEF_DISCOVERED"/>
-
-				<category android:name="android.intent.category.DEFAULT"/>
-
-				<data android:mimeType="application/de.tudarmstadt.informatik.hostage"/>
-			</intent-filter>
-		</activity>
 
 		<service android:name="de.tudarmstadt.informatik.hostage.HoneyService">
 		</service>

+ 53 - 0
AndroidManifest.xml~

@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<manifest xmlns:android="http://schemas.android.com/apk/res/android"
+    package="de.tudarmstadt.informatik.hostage"
+    android:versionCode="1"
+    android:versionName="1.0" >
+
+    <uses-sdk
+        android:minSdkVersion="8"
+        android:targetSdkVersion="19" />
+
+    <uses-permission android:name="android.permission.VIBRATE" />
+    <uses-permission android:name="android.permission.INTERNET" />
+    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
+    <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
+    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
+
+    <application
+        android:allowBackup="true"
+        android:icon="@drawable/ic_launcher"
+        android:label="@string/app_name"
+        android:theme="@style/AppTheme" >
+        <activity
+            android:name="de.tudarmstadt.informatik.hostage.ui.MainActivity"
+            android:configChanges="keyboardHidden|orientation|screenSize"
+            android:label="@string/app_name" >
+            <intent-filter>
+                <action android:name="android.intent.action.MAIN" />
+
+                <category android:name="android.intent.category.LAUNCHER" />
+            </intent-filter>
+        </activity>
+        <activity
+            android:name="de.tudarmstadt.informatik.hostage.ui.ViewLog"
+            android:label="@string/statistics" >
+        </activity>
+        <activity
+            android:name="de.tudarmstadt.informatik.hostage.ui.ViewLogTable"
+            android:label="@string/database" >
+        </activity>
+        <activity
+            android:name="de.tudarmstadt.informatik.hostage.ui.SettingsActivity"
+            android:label="@string/settings" >
+        </activity>
+        <activity
+            android:name="de.tudarmstadt.informatik.hostage.ui.AboutActivity"
+            android:label="@string/action_about" >
+        </activity>
+
+        <service android:name="de.tudarmstadt.informatik.hostage.HoneyService" >
+        </service>
+    </application>
+
+</manifest>

+ 82 - 0
pom.xml~

@@ -0,0 +1,82 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+	<modelVersion>4.0.0</modelVersion>
+	<groupId>de.tudarmstadt.informatik</groupId>
+	<artifactId>hostage</artifactId>
+	<version>2.0.0-SNAPSHOT</version>
+	<packaging>apk</packaging>
+	<name>HosTaGe</name>
+	<dependencies>
+		<dependency>
+			<groupId>android</groupId>
+			<artifactId>android</artifactId>
+			<version>4.4.2_r2</version>
+			<scope>provided</scope>
+		</dependency>
+		<dependency>
+			<groupId>android.support</groupId>
+			<artifactId>compatibility-v4</artifactId>
+			<version>19.0.1</version>
+		</dependency>
+		<dependency>
+			<groupId>org.roboguice</groupId>
+			<artifactId>roboguice</artifactId>
+			<version>2.0</version>
+		</dependency>
+	</dependencies>
+	<build>
+		<finalName>${project.artifactId}</finalName>
+		<sourceDirectory>src</sourceDirectory>
+		<pluginManagement>
+			<plugins>
+				<plugin>
+					<groupId>com.jayway.maven.plugins.android.generation2</groupId>
+					<artifactId>android-maven-plugin</artifactId>
+					<version>3.8.0</version>
+					<extensions>true</extensions>
+				</plugin>
+				<plugin>
+					<groupId>org.eclipse.m2e</groupId>
+					<artifactId>lifecycle-mapping</artifactId>
+					<version>1.0.0</version>
+					<configuration>
+						<lifecycleMappingMetadata>
+							<pluginExecutions>
+								<pluginExecution>
+									<pluginExecutionFilter>
+										<groupId>
+											com.jayway.maven.plugins.android.generation2
+										</groupId>
+										<artifactId>
+											android-maven-plugin
+										</artifactId>
+										<versionRange>
+											[3.8.0,)
+										</versionRange>
+										<goals>
+											<goal>consume-aar</goal>
+										</goals>
+									</pluginExecutionFilter>
+									<action>
+										<ignore></ignore>
+									</action>
+								</pluginExecution>
+							</pluginExecutions>
+						</lifecycleMappingMetadata>
+					</configuration>
+				</plugin>
+			</plugins>
+		</pluginManagement>
+		<plugins>
+			<plugin>
+				<groupId>com.jayway.maven.plugins.android.generation2</groupId>
+				<artifactId>android-maven-plugin</artifactId>
+				<configuration>
+					<sdk>
+						<platform>19.0.1</platform>
+					</sdk>
+				</configuration>
+			</plugin>
+		</plugins>
+	</build>
+</project>

BIN
res/drawable-hdpi/ic_action_stats.png


BIN
res/drawable-hdpi/ic_menu_allfriends.png


BIN
res/drawable-hdpi/ic_menu_stats.png


BIN
res/drawable-mdpi/ic_action_stats.png


BIN
res/drawable-mdpi/ic_menu_allfriends.png


BIN
res/drawable-mdpi/ic_menu_stats.png


BIN
res/drawable-xhdpi/ic_action_stats.png


BIN
res/drawable-xhdpi/ic_menu_allfriends.png


BIN
res/drawable-xxhdpi/ic_action_stats.png


BIN
res/drawable-xxhdpi/ic_menu_allfriends.png


BIN
res/drawable-xxhdpi/ic_menu_stats.png


+ 59 - 58
res/layout/profile_manager_list_item.xml

@@ -4,7 +4,7 @@
               android:layout_width="wrap_content"
               android:layout_height="wrap_content">
 
-    <RelativeLayout
+	<RelativeLayout
         android:id="@+id/swipelist_backview"
         android:orientation="horizontal"
         android:layout_width="match_parent"
@@ -33,7 +33,8 @@
                 android:layout_height="match_parent"
                 android:background="@color/light_grey"
                 android:layout_marginTop="10dp"
-                android:layout_marginBottom="10dp"/>
+                android:layout_marginBottom="10dp"
+		        android:id="@+id/profile_manager_item_seperator"/>
 
             <ImageButton
                 android:layout_width="0dp"
@@ -51,66 +52,66 @@
         </LinearLayout>
 
     </RelativeLayout>
-    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
-                    android:id="@+id/swipelist_frontview"
-                    android:layout_width="match_parent"
-                    android:layout_height="wrap_content"
-                    android:padding="5dp"
-                    android:baselineAligned="false"
-                    android:background="@drawable/panel_bg_selector">
+	<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
+	                android:id="@+id/swipelist_frontview"
+	                android:layout_width="match_parent"
+	                android:layout_height="wrap_content"
+	                android:padding="5dp"
+	                android:baselineAligned="false"
+	                android:background="@drawable/panel_bg_selector">
 
-        <TextView
-            android:id="@+id/profile_manager_item_label"
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:textAppearance="?android:attr/textAppearanceListItemSmall"
-            android:gravity="center_vertical"
-            android:paddingLeft="16dp"
-            android:paddingRight="16dp"
-            android:textColor="?android:attr/colorForeground"
-            android:minHeight="?android:attr/listPreferredItemHeightSmall"
-            android:text="Sample title"
-            android:layout_alignParentTop="true"
-            android:layout_toRightOf="@+id/profile_manager_item_image" />
+	    <TextView
+	        android:id="@+id/profile_manager_item_label"
+	        android:layout_width="match_parent"
+	        android:layout_height="wrap_content"
+	        android:textAppearance="?android:attr/textAppearanceListItemSmall"
+	        android:gravity="center_vertical"
+	        android:paddingLeft="16dp"
+	        android:paddingRight="16dp"
+	        android:textColor="?android:attr/colorForeground"
+	        android:minHeight="?android:attr/listPreferredItemHeightSmall"
+	        android:text="Sample title"
+	        android:layout_alignParentTop="true"
+	        android:layout_toRightOf="@+id/profile_manager_item_image" />
 
-        <TextView
-            android:layout_width="match_parent"
-            android:layout_height="wrap_content"
-            android:text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
-            android:id="@+id/profile_manager_item_text"
-            android:paddingLeft="16dp"
-            android:paddingRight="16dp"
-            android:paddingBottom="16dp"
-            android:textColor="#808080"
-            android:visibility="visible"
-            android:singleLine="false"
-            android:layout_alignParentLeft="true"
-            android:layout_alignParentStart="true"
-            android:layout_below="@+id/profile_manager_item_label"
-            android:paddingTop="10dp"
-            android:layout_toLeftOf="@+id/profile_manager_item_activated"/>
+	    <TextView
+	        android:layout_width="match_parent"
+	        android:layout_height="wrap_content"
+	        android:text="Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet."
+	        android:id="@+id/profile_manager_item_text"
+	        android:paddingLeft="16dp"
+	        android:paddingRight="16dp"
+	        android:paddingBottom="16dp"
+	        android:textColor="#808080"
+	        android:visibility="visible"
+	        android:singleLine="false"
+	        android:layout_alignParentLeft="true"
+	        android:layout_alignParentStart="true"
+	        android:layout_below="@+id/profile_manager_item_label"
+	        android:paddingTop="10dp"
+	        android:layout_toLeftOf="@+id/profile_manager_item_activated"/>
 
-        <ImageView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:id="@+id/profile_manager_item_activated"
-            android:src="@drawable/ic_action_accept"
-            android:layout_centerVertical="true"
-            android:layout_alignParentRight="true"
-            android:layout_alignParentEnd="true"
-            android:layout_marginRight="20dp"
-            android:visibility="visible"
-            android:layout_marginLeft="20dp"/>
+	    <ImageView
+	        android:layout_width="wrap_content"
+	        android:layout_height="wrap_content"
+	        android:id="@+id/profile_manager_item_activated"
+	        android:src="@drawable/ic_action_accept"
+	        android:layout_centerVertical="true"
+	        android:layout_alignParentRight="true"
+	        android:layout_alignParentEnd="true"
+	        android:layout_marginRight="20dp"
+	        android:visibility="visible"
+	        android:layout_marginLeft="20dp"/>
 
-        <ImageView
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:id="@+id/profile_manager_item_image"
-            android:src="@drawable/ic_launcher"
-            android:layout_above="@+id/profile_manager_item_text"
-            android:layout_alignParentLeft="true"
-            android:layout_alignParentStart="true" />
+	    <ImageView
+	        android:layout_width="wrap_content"
+	        android:layout_height="wrap_content"
+	        android:id="@+id/profile_manager_item_image"
+	        android:src="@drawable/ic_launcher"
+	        android:layout_above="@+id/profile_manager_item_text"
+	        android:layout_alignParentLeft="true"
+	        android:layout_alignParentStart="true" />
 
-    </RelativeLayout>
+	</RelativeLayout>
 
 </FrameLayout>

+ 138 - 0
src/de/tudarmstadt/informatik/hostage/dao/ProfileManager.java

@@ -0,0 +1,138 @@
+package de.tudarmstadt.informatik.hostage.dao;
+
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.model.Profile;
+import de.tudarmstadt.informatik.hostage.ui2.adapter.ProfileManagerListAdapter;
+import de.tudarmstadt.informatik.hostage.ui2.model.ProfileListItem;
+
+/**
+ * @author Alexander Brakowski
+ * @created 10.02.14 20:24
+ */
+public class ProfileManager {
+	private static ProfileManager INSTANCE = null;
+
+	private Map<Integer, Profile> mProfiles;
+	private ProfileManagerListAdapter mProfileListAdapter = null;
+
+	private int mProfileId = 4;
+	private Profile mCurrentActivatedProfile = null;
+
+	public static ProfileManager getInstance(){
+		if(INSTANCE == null){
+			INSTANCE = new ProfileManager();
+		}
+
+		return INSTANCE;
+	}
+
+	private ProfileManager(){
+		this.mProfiles = new HashMap<Integer, Profile>();
+		this.mProfiles.put(0, new Profile(
+				0,
+				"Windows Vista",
+				"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
+				R.drawable.ic_profile_vista,
+				false
+		));
+
+		this.mProfiles.put(1, new Profile(
+				1,
+				"Windows 7",
+				"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
+				R.drawable.ic_profile_w7,
+				false
+		));
+
+		this.mProfiles.put(2, new Profile(
+				2,
+				"Unix Distro",
+				"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
+				R.drawable.ic_profile_unix,
+				false
+		));
+
+		this.mProfiles.put(3, new Profile(
+				3,
+				"Random",
+				"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
+				R.drawable.ic_service_green,
+				false
+		));
+
+		this.mProfiles.put(4, new Profile(
+				4,
+				"Mix",
+				"Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
+				R.drawable.ic_service_green,
+				false
+		));
+	}
+
+	public List<Profile> getProfilesList(){
+		return new ArrayList<Profile>(getProfilesCollection());
+	}
+
+	public Collection<Profile> getProfilesCollection(){
+		return mProfiles.values();
+	}
+
+	public Map<Integer, Profile> getMapProfiles(){
+		return mProfiles;
+	}
+
+	public Profile getProfile(int id){
+		if(this.mProfiles.containsKey(id)){
+			return this.mProfiles.get(id);
+		}
+
+		return null;
+	}
+
+	public void addProfile(Profile profile){
+		if(profile.id == -1){
+			profile.id = mProfileId++;
+		}
+
+		this.mProfiles.put(profile.id, profile);
+		if(this.mProfileListAdapter != null){
+			this.mProfileListAdapter.add(profile);
+		}
+	}
+
+	public void deleteProfile(Profile profile){
+		if(this.mProfiles.containsKey(profile.id)){
+			this.mProfiles.remove(profile.id);
+
+			if(this.mProfileListAdapter != null){
+				this.mProfileListAdapter.remove(profile);
+			}
+		}
+	}
+
+	public void activeProfile(Profile profile){
+		if(profile.equals(this.mCurrentActivatedProfile)) return;
+
+		if(this.mCurrentActivatedProfile != null){
+			this.mCurrentActivatedProfile.activated = false;
+		}
+
+		profile.activated = true;
+		this.mCurrentActivatedProfile = profile;
+	}
+
+	public void setProfileListAdapter(ProfileManagerListAdapter profileListAdapter){
+		this.mProfileListAdapter = profileListAdapter;
+	}
+
+
+	public ProfileManagerListAdapter getProfileListAdapter(){
+		return this.mProfileListAdapter;
+	}
+}

+ 50 - 0
src/de/tudarmstadt/informatik/hostage/model/Profile.java

@@ -0,0 +1,50 @@
+package de.tudarmstadt.informatik.hostage.model;
+
+import android.graphics.Bitmap;
+import android.graphics.BitmapFactory;
+
+import de.tudarmstadt.informatik.hostage.ui2.activity.MainActivity;
+
+/**
+ * @author Alexander Brakowski
+ * @created 14.01.14 18:04
+ */
+public class Profile {
+	public String label;
+	public String text;
+	public int id;
+	public boolean activated;
+	public Bitmap icon;
+
+	public boolean isBackVisible = false;
+	public boolean editable = false;
+
+	public Profile(int id, String text, String label, Bitmap icon, boolean editable){
+		this.id = id;
+		this.text = text;
+		this.label = label;
+		this.activated = false;
+		this.icon = icon;
+		this.editable = editable;
+	}
+
+	public Profile(int id, String text, String label, int icon, boolean editable){
+		this(id, text, label, BitmapFactory.decodeResource(MainActivity.context.getResources(), icon), editable);
+	}
+
+	public void setIcon(Bitmap bitmap){
+		this.icon = bitmap;
+	}
+
+	public void setIcon(int icon){
+		this.icon = BitmapFactory.decodeResource(MainActivity.context.getResources(), icon);
+	}
+
+	public boolean isEditable(){
+		return this.editable;
+	}
+
+	public Profile cloneProfile(){
+		return new Profile(id, text, label, icon, editable);
+	}
+}

+ 101 - 2
src/de/tudarmstadt/informatik/hostage/ui2/activity/MainActivity.java

@@ -1,5 +1,7 @@
 package de.tudarmstadt.informatik.hostage.ui2.activity;
 
+import java.io.BufferedReader;
+import java.io.InputStreamReader;
 import java.util.ArrayList;
 
 import android.app.ActionBar;
@@ -7,18 +9,23 @@ import android.app.Activity;
 import android.app.Fragment;
 import android.app.FragmentManager;
 import android.app.FragmentTransaction;
+import android.content.ComponentName;
 import android.content.Context;
 import android.content.Intent;
+import android.content.ServiceConnection;
 import android.content.res.Configuration;
 import android.content.res.TypedArray;
 import android.os.Bundle;
+import android.os.IBinder;
 import android.support.v4.app.ActionBarDrawerToggle;
 import android.support.v4.widget.DrawerLayout;
+import android.util.Log;
 import android.view.MenuItem;
 import android.view.View;
 import android.widget.AdapterView;
 import android.widget.ListView;
 
+import de.tudarmstadt.informatik.hostage.HoneyService;
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.ui.LogFilter;
 import de.tudarmstadt.informatik.hostage.ui.ViewLogTable;
@@ -46,14 +53,21 @@ public class MainActivity extends Activity {
 	public Fragment displayedFragment;
 
 	private ArrayList<DrawerListItem> drawerItems;
+	private HoneyService mHoneyService;
 
 	public static volatile Context context;
 
+	public static boolean isRooted = false;
+	public static boolean porthackInstalled = false;
+
+	private boolean serviceBound;
+
 	@Override
 	protected void onCreate(Bundle savedInstanceState) {
 		super.onCreate(savedInstanceState);
 		MainActivity.context = getApplicationContext();
 
+
 		setContentView(R.layout.activity_drawer_main);
 
 		ThreatIndicatorGLRenderer.assets = getAssets();
@@ -75,9 +89,9 @@ public class MainActivity extends Activity {
 		drawerItems = new ArrayList<DrawerListItem>();
 		drawerItems.add(new DrawerListItem(R.string.drawer_overview, R.drawable.ic_menu_home));
 		drawerItems.add(new DrawerListItem(R.string.drawer_threat_map, R.drawable.ic_menu_mapmode));
-		drawerItems.add(new DrawerListItem(R.string.drawer_records, R.drawable.ic_menu_gallery));
+		drawerItems.add(new DrawerListItem(R.string.drawer_records, R.drawable.ic_action_stats));
 		drawerItems.add(new DrawerListItem(R.string.drawer_services, R.drawable.ic_menu_set_as));
-		drawerItems.add(new DrawerListItem(R.string.drawer_profile_manager, R.drawable.ic_menu_set_as));
+		drawerItems.add(new DrawerListItem(R.string.drawer_profile_manager, R.drawable.ic_menu_allfriends));
 		drawerItems.add(new DrawerListItem(R.string.drawer_settings, R.drawable.ic_menu_preferences));
 		drawerItems.add(new DrawerListItem(R.string.drawer_app_info, R.drawable.ic_menu_info_details));
 
@@ -113,6 +127,17 @@ public class MainActivity extends Activity {
 			// on first time display view for first nav item
 			displayView(0);
 		}
+		checkRootAndPorthack();
+		startAndBind();
+	}
+
+	private void startAndBind() {
+		startService(getServiceIntent());
+		bindService();
+	}
+
+	private void bindService() {
+		bindService(getServiceIntent(), mConnection, BIND_AUTO_CREATE);
 	}
 
 	@Override
@@ -192,6 +217,10 @@ public class MainActivity extends Activity {
 		}
 	}
 
+	public Intent getServiceIntent() {
+		return new Intent(this, HoneyService.class);
+	}
+
 	private class DrawerItemClickListener implements ListView.OnItemClickListener {
 		public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
 			displayView(position);
@@ -205,4 +234,74 @@ public class MainActivity extends Activity {
 	public static Context getContext(){
 		return MainActivity.context;
 	}
+
+	/**
+	 * Connection to bind the background service
+	 *
+	 * @see HoneyService
+	 */
+	private ServiceConnection mConnection = new ServiceConnection() {
+		/**
+		 * After the service is bound, check which has been clicked and start
+		 * it.
+		 *
+		 * @see android.content.ServiceConnection#onServiceConnected(android.content.ComponentName)
+		 */
+		@Override
+		public void onServiceConnected(ComponentName name, IBinder service) {
+			mHoneyService = ((HoneyService.LocalBinder) service).getService();
+			serviceBound = true;
+			updateUI();
+		}
+
+		/**
+		 * After the service is unbound, delete reference.
+		 *
+		 * @see android.content.ServiceConnection#onServiceDisconnected(android.content.ComponentName)
+		 */
+		@Override
+		public void onServiceDisconnected(ComponentName name) {
+			mHoneyService = null;
+			serviceBound = false;
+		}
+
+	};
+
+	private void updateUI() {
+
+	}
+
+	/**
+	 * Checks if the phone ist rooted and if porthack is installed. Sets flags
+	 * {@link isRooted} and {@link porthackInstalled}
+	 */
+	private void checkRootAndPorthack() {
+		isRooted = false;
+		porthackInstalled = false;
+		Process p;
+		try {
+			String found = "Found";
+			String notFound = "Not found";
+			String command = "[ -f /data/local/p ] && echo " + found
+					+ " || echo " + notFound;
+			p = Runtime.getRuntime().exec(new String[] { "su", "-c", command });
+			BufferedReader in = new BufferedReader(new InputStreamReader(
+					p.getInputStream()));
+			/*
+			 * int av = byte[] b = new byte[av]; if (av != 0) { in.read(b); }
+			 */
+			String echoResponse = in.readLine();
+			Log.i("MainAc", echoResponse);
+			if (echoResponse.equals(found)) {
+				isRooted = true;
+				porthackInstalled = true;
+			} else if (echoResponse.equals(notFound)) {
+				isRooted = true;
+			}
+		} catch (Exception e) {
+			e.printStackTrace();
+		}
+		Log.i("MainAc", "Rooted: " + isRooted + " Porthack: "
+				+ porthackInstalled);
+	}
 }

+ 2 - 6
src/de/tudarmstadt/informatik/hostage/ui2/preference/ProfileEditActivity.java → src/de/tudarmstadt/informatik/hostage/ui2/activity/ProfileEditActivity.java

@@ -1,13 +1,9 @@
-package de.tudarmstadt.informatik.hostage.ui2.preference;
+package de.tudarmstadt.informatik.hostage.ui2.activity;
 
-import android.content.Context;
 import android.os.Bundle;
 import android.preference.PreferenceActivity;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.LinearLayout;
 
-import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.ui2.fragment.ProfileEditFragment;
 
 /**
  * @author Alexander Brakowski

+ 61 - 11
src/de/tudarmstadt/informatik/hostage/ui2/adapter/ProfileManagerListAdapter.java

@@ -1,32 +1,35 @@
 package de.tudarmstadt.informatik.hostage.ui2.adapter;
 
+import android.app.AlertDialog;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.view.animation.Animation;
-import android.view.animation.AnimationUtils;
 import android.widget.ArrayAdapter;
 import android.widget.ImageButton;
 import android.widget.ImageView;
 import android.widget.RelativeLayout;
 import android.widget.TextView;
-import android.widget.ViewSwitcher;
 
 import com.fortysevendeg.android.swipelistview.SwipeListView;
 
 import java.util.List;
 
 import de.tudarmstadt.informatik.hostage.R;
+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.fragment.ProfileManagerFragment;
 import de.tudarmstadt.informatik.hostage.ui2.model.ProfileListItem;
-import de.tudarmstadt.informatik.hostage.ui2.preference.ProfileEditActivity;
+import de.tudarmstadt.informatik.hostage.ui2.activity.ProfileEditActivity;
 
 /**
  * @author Alexander Brakowski
  * @created 14.01.14 18:00
  */
-public class ProfileManagerListAdapter extends ArrayAdapter<ProfileListItem> {
+public class ProfileManagerListAdapter extends ArrayAdapter<Profile> {
 	private class ViewHolder {
 		public TextView labelView;
 		public TextView textView;
@@ -34,12 +37,13 @@ public class ProfileManagerListAdapter extends ArrayAdapter<ProfileListItem> {
 		public ImageView itemIcon;
 		public ImageButton buttonEdit;
 		public ImageButton buttonDelete;
+		public View seperator;
 	}
 
     private final Context context;
-    private final List<ProfileListItem> values;
+    private final List<Profile> values;
 
-    public ProfileManagerListAdapter(Context context, List<ProfileListItem> objects) {
+    public ProfileManagerListAdapter(Context context, List<Profile> objects) {
         super(context, R.layout.profile_manager_list_item, objects);
         this.context = context;
         this.values  = objects;
@@ -54,7 +58,7 @@ public class ProfileManagerListAdapter extends ArrayAdapter<ProfileListItem> {
         View rowView = convertView;
 	    ViewHolder holder = null;
 
-	    final ProfileListItem item = values.get(position);
+	    final Profile item = values.get(position);
 
 	    if(rowView == null){
 		    rowView = inflater.inflate(R.layout.profile_manager_list_item, parent, false);
@@ -66,6 +70,7 @@ public class ProfileManagerListAdapter extends ArrayAdapter<ProfileListItem> {
 		    holder.itemIcon = (ImageView) rowView.findViewById(R.id.profile_manager_item_image);
 		    holder.buttonEdit = (ImageButton) rowView.findViewById(R.id.profile_manager_item_button_edit);
 		    holder.buttonDelete = (ImageButton) rowView.findViewById(R.id.profile_manager_item_button_delete);
+			holder.seperator = rowView.findViewById(R.id.profile_manager_item_seperator);
 
 		    rowView.setTag(holder);
 	    } else {
@@ -83,19 +88,64 @@ public class ProfileManagerListAdapter extends ArrayAdapter<ProfileListItem> {
 			public void onClick(View v) {
 				Intent intent = new Intent(context, ProfileEditActivity.class);
 				intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
+				intent.putExtra("profile_id", item.id);
 				context.startActivity(intent);
 			}
 		});
 
+		holder.buttonDelete.setOnClickListener(new View.OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				new AlertDialog.Builder(context)
+						.setTitle("Delete profile")
+						.setMessage("Do you really want to delete this profile?")
+						.setNegativeButton("No", new DialogInterface.OnClickListener() {
+							@Override
+							public void onClick(DialogInterface dialog, int which) {
+
+							}
+						})
+						.setPositiveButton("Yes", new DialogInterface.OnClickListener() {
+							public void onClick(DialogInterface dialog, int which) {
+								ProfileManager profileManager = ProfileManager.getInstance();
+
+								profileManager.deleteProfile(item);
+								profileManager.getProfileListAdapter().notifyDataSetChanged();
+
+							}
+						})
+						.setIcon(android.R.drawable.ic_dialog_alert)
+						.show();
+			}
+		});
+
+		RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams) holder.textView.getLayoutParams();
+
         if(!item.activated){
-            RelativeLayout.LayoutParams lp = (RelativeLayout.LayoutParams )holder.textView.getLayoutParams();
-            lp.setMargins(0,0,0,0);
+            lp.setMargins(0, 0, 0, 0);
 
 	        holder.textView.setLayoutParams(lp);
 
 	        holder.imageSelected.setVisibility(View.GONE);
-        }
+        } else {
+			/*float d = context.getResources().getDisplayMetrics().density;
+			int dm = (int)(20 * d);
+
+			lp.setMargins(0,0,dm,0);
+
+			holder.textView.setLayoutParams(lp);*/
+
+			holder.imageSelected.setVisibility(View.VISIBLE);
+		}
+
 
+		if(!item.isEditable()){
+			holder.buttonDelete.setVisibility(View.GONE);
+			holder.seperator.setVisibility(View.GONE);
+		} else {
+			holder.buttonDelete.setVisibility(View.VISIBLE);
+			holder.seperator.setVisibility(View.VISIBLE);
+		}
 
         return rowView;
     }

+ 132 - 0
src/de/tudarmstadt/informatik/hostage/ui2/fragment/ProfileEditFragment.java

@@ -0,0 +1,132 @@
+package de.tudarmstadt.informatik.hostage.ui2.fragment;
+
+import android.app.ActionBar;
+import android.content.Context;
+import android.content.Intent;
+import android.content.SharedPreferences;
+import android.os.Bundle;
+import android.preference.EditTextPreference;
+import android.preference.Preference;
+import android.preference.PreferenceFragment;
+import android.preference.PreferenceManager;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.LinearLayout;
+
+import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.dao.ProfileManager;
+import de.tudarmstadt.informatik.hostage.model.Profile;
+
+/**
+ * @author Alexander Brakowski
+ * @created 08.02.14 23:39
+ */
+public class ProfileEditFragment extends PreferenceFragment implements
+		SharedPreferences.OnSharedPreferenceChangeListener {
+
+	private LayoutInflater mInflater;
+
+	@Override
+	public void onCreate(Bundle savedInstanceState){
+		getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
+		super.onCreate(savedInstanceState);
+
+		mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+		View actionBarButtons = mInflater.inflate(R.layout.actionbar_donebar, new LinearLayout(getActivity()), false);
+		getActivity().getActionBar().setCustomView(actionBarButtons);
+
+		View doneButton = actionBarButtons.findViewById(R.id.action_done);
+		View cancelButton = actionBarButtons.findViewById(R.id.action_cancel);
+
+		doneButton.setOnClickListener(new View.OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(getActivity());
+				ProfileManager pmanager = ProfileManager.getInstance();
+
+				Profile profile = getProfile();
+				boolean createNew = false;
+
+				if(!profile.isEditable()){
+					profile = profile.cloneProfile();
+					profile.editable = true;
+					createNew = true;
+				}
+
+				profile.text = prefs.getString("pref_profile_general_name", profile.text);
+
+				if(createNew){
+					profile.id = -1;
+					pmanager.addProfile(profile);
+				}
+
+				getActivity().finish();
+			}
+		});
+
+		cancelButton.setOnClickListener(new View.OnClickListener() {
+			@Override
+			public void onClick(View v) {
+				getActivity().finish();
+			}
+		});
+
+		Profile profile = getProfile();
+		SharedPreferences.Editor prefs = PreferenceManager.getDefaultSharedPreferences(getActivity()).edit();
+
+		if(profile != null){
+
+			prefs.putString("pref_profile_general_name", profile.text);
+			prefs.commit();
+		}
+
+		addPreferencesFromResource(R.xml.profile_preferences);
+
+		findPreference("pref_profile_general_name").setSummary(profile.text);
+	}
+
+	public Profile getProfile(){
+		ProfileManager pmanager = ProfileManager.getInstance();
+
+		Intent intent = getActivity().getIntent();
+		int profile_id = intent.getIntExtra("profile_id", -1);
+
+		if(profile_id != -1){
+			return pmanager.getProfile(profile_id);
+		}
+
+		return null;
+	}
+
+	@Override
+	public void onResume() {
+		super.onResume();
+		getPreferenceManager().getSharedPreferences().registerOnSharedPreferenceChangeListener(this);
+	}
+
+	@Override
+	public void onPause() {
+		getPreferenceManager().getSharedPreferences().unregisterOnSharedPreferenceChangeListener(this);
+		super.onPause();
+	}
+
+	/**
+	 * Called when a shared preference is changed, added, or removed. This
+	 * may be called even if a preference is set to its existing value.
+	 *
+	 * <p>This callback will be run on your main thread.
+	 *
+	 * @param sharedPreferences The {@link android.content.SharedPreferences} that received
+	 *                          the change.
+	 * @param key               The key of the preference that was changed, added, or
+	 */
+	@Override
+	public void onSharedPreferenceChanged(SharedPreferences sharedPreferences, String key) {
+		Preference p = findPreference(key);
+
+		if(p instanceof EditTextPreference){
+			p.setSummary(sharedPreferences.getString(key, ""));
+		}
+	}
+}

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

@@ -5,23 +5,25 @@ import android.os.Bundle;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
-import android.widget.ListView;
 
+import com.fortysevendeg.android.swipelistview.BaseSwipeListViewListener;
 import com.fortysevendeg.android.swipelistview.SwipeListView;
 
-import java.util.ArrayList;
+import java.util.List;
 
 import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.dao.ProfileManager;
+import de.tudarmstadt.informatik.hostage.model.Profile;
 import de.tudarmstadt.informatik.hostage.ui2.adapter.ProfileManagerListAdapter;
-import de.tudarmstadt.informatik.hostage.ui2.model.ProfileListItem;
 
 /**
  * @author Alexander Brakowski
  * @created 14.01.14 15:05
  */
 public class ProfileManagerFragment extends Fragment {
+	private ProfileManagerListAdapter mAdapter;
 
-    public ProfileManagerFragment(){}
+	public ProfileManagerFragment(){}
 
     @Override
     public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -30,42 +32,33 @@ public class ProfileManagerFragment extends Fragment {
 	    super.onCreateView(inflater, container, savedInstanceState);
 
         View rootView = inflater.inflate(R.layout.fragment_profile_manager, container, false);
-
 	    SwipeListView list = (SwipeListView) rootView.findViewById(R.id.profile_manager_listview);
 
-	    list.setItemsCanFocus(false);
-
-        ArrayList<ProfileListItem> strList = new ArrayList<ProfileListItem>();
-
+		final ProfileManager pmanager = ProfileManager.getInstance();
 
-        strList.add(new ProfileListItem(
-                "Windows Vista",
-		        "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
-		        R.drawable.ic_profile_vista));
+        List<Profile> strList = pmanager.getProfilesList();
 
-	    strList.add(new ProfileListItem(
-			    "Windows 7",
-			    "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
-			    R.drawable.ic_profile_w7));
+		mAdapter = new ProfileManagerListAdapter(getActivity(), strList);
+		pmanager.setProfileListAdapter(mAdapter);
 
-        strList.add(new ProfileListItem(
-                "Unix Distro",
-		        "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
-		        R.drawable.ic_profile_unix));
+        list.setAdapter(mAdapter);
 
-        strList.add(new ProfileListItem(
-                "Random",
-		        "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
-		        R.drawable.ic_service_green));
+		list.setSwipeListViewListener(new BaseSwipeListViewListener() {
+			@Override
+			public void onClickFrontView(int position) {
+				Profile profile = mAdapter.getItem(position);
+				pmanager.activeProfile(profile);
 
-	    strList.add(new ProfileListItem(
-			    "Mix",
-			    "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.",
-			    R.drawable.ic_service_green));
-
-        ProfileManagerListAdapter adapter = new ProfileManagerListAdapter(getActivity().getBaseContext(), strList);
-        list.setAdapter(adapter);
+				mAdapter.notifyDataSetChanged();
+			}
+		});
 
         return rootView;
     }
+
+	@Override
+	public void onResume() {
+		super.onResume();
+		mAdapter.notifyDataSetChanged();
+	}
 }

+ 78 - 69
src/de/tudarmstadt/informatik/hostage/ui2/fragment/RecordOverviewFragment.java

@@ -1,5 +1,7 @@
 package de.tudarmstadt.informatik.hostage.ui2.fragment;
 
+import com.google.android.gms.maps.model.LatLng;
+
 import android.annotation.SuppressLint;
 import android.app.Fragment;
 import android.content.Context;
@@ -29,6 +31,7 @@ import java.util.Collections;
 import java.util.Comparator;
 import java.util.Date;
 import java.util.HashMap;
+import java.util.Random;
 
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.logging.Record;
@@ -44,7 +47,7 @@ import de.tudarmstadt.informatik.hostage.ui2.model.ExpandableListItem;
 public class RecordOverviewFragment extends Fragment implements ChecklistDialog.ChecklistDialogListener, DateTimeDialogFragment.DateTimeDialogFragmentListener {
 	static final String SELECTED_KEY = "Selected";
 	static final String OTHERS_KEY = "Other";
-	
+
 	static final String FILTER_MENU_TITLE_BSSID = "BSSID";
 	static final String FILTER_MENU_TITLE_ESSID = "ESSID";
 	static final String FILTER_MENU_TITLE_PROTOCOLS = "Protocols";
@@ -64,20 +67,20 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
     private ExpandableListView expListView;
 
 	UglyDbHelper dbh;
-	
+
 
     public RecordOverviewFragment(){}
-    
-	
+
+
     @Override
     public void onCreate(Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
         setHasOptionsMenu(true);
     }
-    
+
 	public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
-		
+
 		dbh = new UglyDbHelper(this.getActivity().getBaseContext());
 
 	    // Get the message from the intent
@@ -97,14 +100,14 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 
 	    this.setShowFilterButton(!this.filter.isNotEditable());
 	    this.addRecordToDB();
-	    
+
 		View rootView = inflater.inflate(R.layout.fragment_record_list, container, false);
 		ExpandableListView mylist = (ExpandableListView) rootView.findViewById(R.id.loglistview);
 		this.expListView = mylist;
 		populateListViewFromDB(mylist);
-		
+
 		registerListClickCallback(mylist);
-		
+
         ImageButton filterButton = (ImageButton) rootView.findViewById(R.id.FilterButton);
         filterButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
@@ -112,7 +115,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
             }
         });
         filterButton.setVisibility(this.showFilterButton? View.VISIBLE : View.INVISIBLE);
-        
+
         ImageButton sortButton = (ImageButton) rootView.findViewById(R.id.SortButton);
         sortButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
@@ -128,7 +131,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
                 RecordOverviewFragment.this.openGroupingDialog();
             }
         });
-		
+
 		return rootView;
 	 }
 
@@ -140,13 +143,13 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 
 	public boolean onFilterMenuItemSelected(MenuItem item) {
 		String title = item.getTitle().toString();
-		
+
 		if(title.equals(FILTER_MENU_TITLE_BSSID)){
 			this.openBSSIDFilterDialog();
 		}
 		if(title.equals(FILTER_MENU_TITLE_ESSID)){
 			this.openESSIDFilterDialog();
-		}		
+		}
 		if(title.equals(FILTER_MENU_TITLE_PROTOCOLS)){
 			this.openProtocolsFilterDialog();
 		}
@@ -165,17 +168,17 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		}
 		return super.onOptionsItemSelected(item);
 	}
-	
-	
-	
+
+
+
 	/*****************************
-	 * 
+	 *
 	 *          ListView Stuff
-	 * 
+	 *
 	 * ***************************/
-	
+
 	private void populateListViewFromDB(ExpandableListView mylist) {
-		
+
 		HashMap<String, ArrayList<ExpandableListItem>> sectionData = new HashMap<String, ArrayList<ExpandableListItem>>();
 
 		ArrayList<Record> data = dbh.getRecordsForFilter(this.filter);
@@ -227,15 +230,15 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 
         mylist.setAdapter(adapter);
 	}
-	
+
 	private Context getBaseContext(){
 		return this.getActivity().getBaseContext();
 	}
-	
+
 	private Context getApplicationContext(){
 		return this.getActivity().getApplicationContext();
 	}
-	
+
 	private void registerListClickCallback(ExpandableListView mylist) {
 
 		mylist.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@@ -267,16 +270,16 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 
 		});
 	}
-	
-	
-	
+
+
+
 	/*****************************
-	 * 
+	 *
 	 *          Date Transform
-	 * 
+	 *
 	 * ***************************/
-	
-	
+
+
 	@SuppressLint("SimpleDateFormat")
 	private String getDateAsString(long timeStamp) {
 
@@ -288,12 +291,12 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 			return "xx";
 		}
 	}
-	
-	
+
+
 	/*****************************
-	 * 
+	 *
 	 *          Getter / Setter
-	 * 
+	 *
 	 * ***************************/
 
 	public boolean isShowFilterButton() {
@@ -303,50 +306,50 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	public void setShowFilterButton(boolean showFilterButton) {
 		this.showFilterButton = showFilterButton;
 	}
-	
-	
-	
+
+
+
 
 	/*****************************
-	 * 
+	 *
 	 *          Open Dialog Methods
-	 * 
+	 *
 	 * ***************************/
 
     private void openGroupingDialog(){
         ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_GROUP, this.groupingTitles(), this.selectedGroup(), false , this);
         newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_GROUP);
     }
-	
+
 	private void openBSSIDFilterDialog(){
 		ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_BSSID,this.bssids(), this.selectedBSSIDs(), true , this);
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_BSSID);
 	}
-	
+
 	private void openESSIDFilterDialog(){
 		ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_ESSID,this.essids(), this.selectedESSIDs(), true , this);
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_ESSID);
 	}
-	
+
 	private void openProtocolsFilterDialog(){
 		ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_PROTOCOLS,this.protocolTitles(), this.selectedProtocols(), true , this);
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_PROTOCOLS);
 	}
-	
+
 	private void openTimestampFromFilterDialog(){
 		this.wasBelowTimePicker = false;
 		DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
         if (this.filter.aboveTimestamp != Long.MIN_VALUE)newFragment.setDate(this.filter.aboveTimestamp);
 	}
-	
+
 	private void openTimestampToFilterDialog(){
 		this.wasBelowTimePicker = true;
 		DateTimeDialogFragment newFragment = new DateTimeDialogFragment(this.getActivity());
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
         if (this.filter.belowTimestamp != Long.MAX_VALUE) newFragment.setDate(this.filter.belowTimestamp);
     }
-	
+
 	private void openSortingDialog(){
 		ChecklistDialog newFragment = new ChecklistDialog(FILTER_MENU_TITLE_SORTING,this.sortTypeTtiles(), this.selectedSorttype(), false , this);
 	    newFragment.show(this.getActivity().getFragmentManager(), FILTER_MENU_TITLE_SORTING);
@@ -388,11 +391,11 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 
 
 	/*****************************
-	 * 
+	 *
 	 *          Filter Stuff
-	 * 
+	 *
 	 * ***************************/
-	
+
 	private void openFilterPopupMenuOnView(View v){
         // Open FilterMenu
         PopupMenu filterMenu = new PopupMenu(getBaseContext(), v);
@@ -410,8 +413,8 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
         });
 			filterMenu.show();
 	}
-	
-	
+
+
 	private void clearFilter(){
     	if(filter == null) this.filter = new LogFilter();
     	this.filter.clear();
@@ -435,7 +438,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
         }
         return selected;
     }
-	
+
 	public ArrayList<String> protocolTitles(){
 		ArrayList<String> titles = new ArrayList<String>();
 		for (String protocol : this.getResources().getStringArray(
@@ -447,7 +450,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	public boolean[] selectedProtocols(){
 		ArrayList<String> protocols = this.protocolTitles();
 		boolean[] selected = new boolean[protocols.size()];
-		
+
 		int i = 0;
 		for(String protocol : protocols){
 			selected[i] =(this.filter.protocols.contains(protocol));
@@ -470,7 +473,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	}
 	public boolean[] selectedSorttype(){
 		ArrayList<String> types = this.sortTypeTtiles();
-		boolean[] selected = new boolean[types.size()];	
+		boolean[] selected = new boolean[types.size()];
 		int i = 0;
 		for(String sorttype : types){
 			selected[i] =(this.filter.sorttype.toString() == sorttype);
@@ -478,7 +481,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		}
 		return selected;
 	}
-	
+
 	public ArrayList<String> bssids(){
 		ArrayList<String> records = dbh.getUniqueBSSIDRecords();
 		return records;
@@ -486,7 +489,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	public boolean[] selectedBSSIDs(){
 		ArrayList<String> bssids = this.bssids();
 		boolean[] selected = new boolean[bssids.size()];
-		
+
 		int i = 0;
 		for(String bssid : bssids){
 			selected[i] =(this.filter.BSSIDs.contains(bssid));
@@ -503,7 +506,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	public boolean[] selectedESSIDs(){
 		ArrayList<String> essids = this.essids();
 		boolean[] selected = new boolean[essids.size()];
-		
+
 		int i = 0;
 		for(String essid : essids){
 			selected[i] =(this.filter.ESSIDs.contains(essid));
@@ -512,7 +515,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		return selected;
 	}
 
-	
+
 	private ArrayList<String> filterMenuTitles(){
 		ArrayList<String> titles = new ArrayList<String>();
 		titles.add(FILTER_MENU_TITLE_BSSID);
@@ -524,13 +527,13 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		return titles;
 	}
 
-	
+
 	/*****************************
-	 * 
+	 *
 	 *          Listener Actions
-	 * 
+	 *
 	 * ***************************/
-	
+
 	public void onDateTimePickerPositiveClick(DateTimeDialogFragment dialog) {
 		if(this.wasBelowTimePicker){
 			this.filter.setBelowTimestamp(dialog.getDate());
@@ -547,7 +550,7 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 			this.filter.setAboveTimestamp(Long.MIN_VALUE);
 		}
 	}
-	
+
 	public void onDialogPositiveClick(ChecklistDialog dialog) {
 		String title = dialog.getTitle();
 		if(title.equals(FILTER_MENU_TITLE_BSSID)){
@@ -590,14 +593,14 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 	public void onDialogNegativeClick(ChecklistDialog dialog) {
 
 	}
-	
-	
+
+
 	/*****************************
-     *
-     *          TEST
-     *
-     * ***************************/
-	
+	 *
+	 *          TEST
+	 *
+	 * ***************************/
+
 	private void addRecordToDB() {
 
         if ((dbh.getRecordCount() > 0)) return;
@@ -607,6 +610,9 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 		int maxProtocolsIndex = this.getResources().getStringArray(
 				R.array.protocols).length;
 
+		Random random = new Random();
+
+		LatLng tudarmstadtLoc = new LatLng(49.86923, 8.6632768);
 		int numberofRecords = (int) (Math.random() * (50 - 10));
 		for (int i = 0; i < numberofRecords; i++) {
 			Record record = new Record();
@@ -626,6 +632,9 @@ public class RecordOverviewFragment extends Fragment implements ChecklistDialog.
 			record.setLocalIP("127.0.0.1");
 			record.setType(TYPE.SEND);
 
+			record.setLatitude(tudarmstadtLoc.latitude + -0.01 + 0.02 * random.nextDouble());
+			record.setLongitude(tudarmstadtLoc.longitude + -0.01 + 0.02 * random.nextDouble());
+
 			dbh.addRecord(record);
 		}
 

+ 50 - 16
src/de/tudarmstadt/informatik/hostage/ui2/fragment/ThreatMapFragment.java

@@ -7,6 +7,8 @@ import android.content.Context;
 import android.content.DialogInterface;
 import android.graphics.Color;
 import android.os.Bundle;
+import android.util.Log;
+import android.view.InflateException;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
@@ -17,17 +19,23 @@ import com.google.android.gms.maps.GoogleMap;
 import com.google.android.gms.maps.MapFragment;
 import com.google.android.gms.maps.model.CircleOptions;
 import com.google.android.gms.maps.model.LatLng;
+import com.google.android.gms.maps.model.Marker;
 import com.google.android.gms.maps.model.MarkerOptions;
 
+import java.util.ArrayList;
+
 import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.logging.Record;
+import de.tudarmstadt.informatik.hostage.logging.UglyDbHelper;
 
 import static com.google.android.gms.common.GooglePlayServicesUtil.*;
 
 /**
  * Created by fabio on 10.02.14.
  */
-public class ThreatMapFragment extends Fragment {
-	private GoogleMap map = null;
+public class ThreatMapFragment extends Fragment implements GoogleMap.OnMarkerClickListener {
+	private static GoogleMap map = null;
+	private static View view = null;
 
 	/**
 	 * if google play services aren't available an error notification will be displayed
@@ -43,26 +51,52 @@ public class ThreatMapFragment extends Fragment {
 		return result;
 	}
 
-	private void loadMapFragment() {
-		// Get a handle to the Map Fragment
-		MapFragment mapFragment = (MapFragment) getFragmentManager()
-				.findFragmentById(R.id.threatmapfragment);
-		map = mapFragment.getMap();
+	@Override
+	public boolean onMarkerClick(Marker marker) {
+		Log.i("MARKER", ""+marker.getId());
+		return false;
+	}
+
+	private void populateMap() {
+		UglyDbHelper dbh = new UglyDbHelper(getActivity());
+		ArrayList<Record> records = dbh.getAllRecords();
+
+		CircleOptions circleOptions = new CircleOptions().radius(200.0).fillColor(Color.argb(127, 240, 80, 60)).strokeWidth(0.0f);
+		for (Record record : records) {
+			LatLng location = new LatLng(record.getLatitude(), record.getLongitude());
+			map.addCircle(circleOptions.center(location));
+			map.addMarker(new MarkerOptions().title(record.getSsid()).position(location));
+		}
+
+		map.setMyLocationEnabled(true);
+		map.setOnMarkerClickListener(this);
+
+		LatLng tudarmstadt = new LatLng(49.86923, 8.6632768);
+		//LatLng mapCenter = new LatLng(41.889, -87.622);
+		map.moveCamera(CameraUpdateFactory.newLatLngZoom(tudarmstadt, 13));
 	}
 
 	@Override
 	public View onCreateView(LayoutInflater inflater, ViewGroup container,
 	                         Bundle savedInstanceState) {
-		//super.onCreateView(inflater, container, savedInstanceState);
-		View rootView = inflater.inflate(R.layout.fragment_threatmap, container, false);
-		if (isGooglePlay()) {
-			loadMapFragment();
+		super.onCreateView(inflater, container, savedInstanceState);
+
+		if (view != null) {
+			ViewGroup parent = (ViewGroup) view.getParent();
+			if (parent != null)
+				parent.removeView(view);
 		}
-		if (map != null) {
-			LatLng mapCenter = new LatLng(41.889, -87.622);
-			map.moveCamera(CameraUpdateFactory.newLatLngZoom(mapCenter, 13));
-			map.addCircle(new CircleOptions().center(mapCenter).radius(200.0).fillColor(Color.argb(127, 240, 80, 60)).strokeWidth(0.0f));
+		try {
+			view = inflater.inflate(R.layout.fragment_threatmap, container, false);
+			if (isGooglePlay()) {
+				map = ((MapFragment) getFragmentManager()
+						.findFragmentById(R.id.threatmapfragment)).getMap();
+				populateMap();
+			}
+		} catch (InflateException e) {
+        	// map already exists
 		}
-		return rootView;
+
+		return view;
 	}
 }

+ 0 - 10
src/de/tudarmstadt/informatik/hostage/ui2/model/Profile.java

@@ -1,10 +0,0 @@
-package de.tudarmstadt.informatik.hostage.ui2.model;
-
-/**
- * @author Alexander Brakowski
- * @created 08.02.14 18:33
- */
-public class Profile {
-
-
-}

+ 0 - 34
src/de/tudarmstadt/informatik/hostage/ui2/preference/ProfileEditFragment.java

@@ -1,34 +0,0 @@
-package de.tudarmstadt.informatik.hostage.ui2.preference;
-
-import android.app.ActionBar;
-import android.content.Context;
-import android.os.Bundle;
-import android.preference.PreferenceFragment;
-import android.view.LayoutInflater;
-import android.view.View;
-import android.widget.LinearLayout;
-
-import de.tudarmstadt.informatik.hostage.R;
-
-/**
- * @author Alexander Brakowski
- * @created 08.02.14 23:39
- */
-public class ProfileEditFragment extends PreferenceFragment {
-
-	private LayoutInflater mInflater;
-
-	@Override
-	public void onCreate(Bundle savedInstanceState){
-		getActivity().getActionBar().setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
-		super.onCreate(savedInstanceState);
-
-		mInflater = (LayoutInflater) getActivity().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
-
-		View actionBarButtons = mInflater.inflate(R.layout.actionbar_donebar, new LinearLayout(getActivity()), false);
-		getActivity().getActionBar().setCustomView(actionBarButtons);
-
-		addPreferencesFromResource(R.xml.profile_preferences);
-	}
-
-}