Browse Source

changed services fragment to listView

Daniel Lazar 10 years ago
parent
commit
d31c89cf44

+ 4 - 572
res/layout/fragment_services.xml

@@ -106,580 +106,12 @@
             android:layout_marginRight="15dp"
             android:background="@android:color/darker_gray" />
 
-    <ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
-                android:layout_width="fill_parent"
-                android:layout_height="fill_parent"
+    <ListView android:layout_width="fill_parent"
+              android:layout_height="wrap_content"
+              android:id="@+id/services_list_view"
             >
-        <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="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-        <TextView
-                android:id="@+id/textViewSSH"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="5dp"
-                android:layout_weight="1"
-                android:text="SSH"
-                android:textStyle="bold"
-                android:textSize="16dp"/>
-        <TextView
-                android:id="@+id/textViewSSHAttacks"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="25dp"
-                android:layout_weight="1"
-                android:text="recorded attacks: 20"
-                android:textStyle="bold"
-                android:textSize="12dp"/>
-        <Switch
-                android:id="@+id/ssh_switch"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="false"
-                android:layout_alignParentEnd="false"
-                android:layout_alignParentLeft="false"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentTop="false"
-                android:layout_gravity="right"
-                android:layout_marginLeft="0dp"
-                android:layout_marginRight="15dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="0dp"
-                android:layout_weight="1"
-                android:checked="false"
-                android:textSize="10dp" />
-    </RelativeLayout>
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
-
-    <RelativeLayout android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-    <TextView
-            android:id="@+id/textViewFTP"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentEnd="true"
-            android:layout_alignParentLeft="true"
-            android:layout_alignParentRight="false"
-            android:layout_marginLeft="50dp"
-            android:layout_marginTop="5dp"
-            android:layout_weight="1"
-            android:text="FTP"
-            android:textStyle="bold"
-            android:textSize="16dp"/>
-    <TextView
-            android:id="@+id/textViewFTPAttacks"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentEnd="true"
-            android:layout_alignParentLeft="true"
-            android:layout_alignParentRight="false"
-            android:layout_marginLeft="50dp"
-            android:layout_marginTop="25dp"
-            android:layout_weight="1"
-            android:text="recorded attacks: 2"
-            android:textStyle="bold"
-            android:textSize="12dp"/>
-    <Switch
-            android:id="@+id/ftp_switch"
-            android:layout_width="wrap_content"
-            android:layout_height="wrap_content"
-            android:layout_alignParentBottom="false"
-            android:layout_alignParentEnd="false"
-            android:layout_alignParentLeft="false"
-            android:layout_alignParentRight="true"
-            android:layout_alignParentTop="false"
-            android:layout_gravity="right"
-            android:layout_marginLeft="0dp"
-            android:layout_marginRight="15dp"
-            android:layout_marginTop="10dp"
-            android:layout_marginBottom="0dp"
-            android:layout_weight="1"
-            android:checked="false"
-            android:textSize="10dp" />
-</RelativeLayout>
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
-
-    <RelativeLayout android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-        <TextView
-                android:id="@+id/textViewHTTP"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="5dp"
-                android:layout_weight="1"
-                android:text="HTTP"
-                android:textStyle="bold"
-                android:textSize="16dp"/>
-        <TextView
-                android:id="@+id/textViewHTTPAttacks"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="25dp"
-                android:layout_weight="1"
-                android:text="recorded attacks: 13"
-                android:textStyle="bold"
-                android:textSize="12dp"/>
-        <Switch
-                android:id="@+id/http_switch"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="false"
-                android:layout_alignParentEnd="false"
-                android:layout_alignParentLeft="false"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentTop="false"
-                android:layout_gravity="right"
-                android:layout_marginLeft="0dp"
-                android:layout_marginRight="15dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="0dp"
-                android:layout_weight="1"
-                android:checked="false"
-                android:textSize="10dp" />
-    </RelativeLayout>
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
-
-    <RelativeLayout android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-        <TextView
-                android:id="@+id/textViewHTTPS"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="5dp"
-                android:layout_weight="1"
-                android:text="HTTPS"
-                android:textStyle="bold"
-                android:textSize="16dp"/>
-        <TextView
-                android:id="@+id/textViewHTTPSAttacks"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="25dp"
-                android:layout_weight="1"
-                android:text="recorded attacks: 20"
-                android:textStyle="bold"
-                android:textSize="12dp"/>
-        <Switch
-                android:id="@+id/https_switch"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="false"
-                android:layout_alignParentEnd="false"
-                android:layout_alignParentLeft="false"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentTop="false"
-                android:layout_gravity="right"
-                android:layout_marginLeft="0dp"
-                android:layout_marginRight="15dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="0dp"
-                android:layout_weight="1"
-                android:checked="false"
-                android:textSize="10dp" />
-    </RelativeLayout>
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
-
-    <RelativeLayout android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-        <TextView
-                android:id="@+id/textViewSAMBA"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="5dp"
-                android:layout_weight="1"
-                android:text="SAMBA"
-                android:textStyle="bold"
-                android:textSize="16dp"/>
-        <TextView
-                android:id="@+id/textViewSAMBAAttacks"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="25dp"
-                android:layout_weight="1"
-                android:text="recorded attacks: 0"
-                android:textStyle="bold"
-                android:textSize="12dp"/>
-        <Switch
-                android:id="@+id/samba_switch"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="false"
-                android:layout_alignParentEnd="false"
-                android:layout_alignParentLeft="false"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentTop="false"
-                android:layout_gravity="right"
-                android:layout_marginLeft="0dp"
-                android:layout_marginRight="15dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="0dp"
-                android:layout_weight="1"
-                android:checked="false"
-                android:textSize="10dp" />
-    </RelativeLayout>
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
-
-    <RelativeLayout android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-        <TextView
-                android:id="@+id/textViewTELNET"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="5dp"
-                android:layout_weight="1"
-                android:text="TELNET"
-                android:textStyle="bold"
-                android:textSize="16dp"/>
-        <TextView
-                android:id="@+id/textViewTELNETAttacks"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="25dp"
-                android:layout_weight="1"
-                android:text="recorded attacks: 20"
-                android:textStyle="bold"
-                android:textSize="12dp"/>
-        <Switch
-                android:id="@+id/telnet_switch"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="false"
-                android:layout_alignParentEnd="false"
-                android:layout_alignParentLeft="false"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentTop="false"
-                android:layout_gravity="right"
-                android:layout_marginLeft="0dp"
-                android:layout_marginRight="15dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="0dp"
-                android:layout_weight="1"
-                android:checked="false"
-                android:textSize="10dp" />
-    </RelativeLayout>
 
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
 
-    <RelativeLayout android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-        <TextView
-                android:id="@+id/textViewSSH"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="5dp"
-                android:layout_weight="1"
-                android:text="SSH"
-                android:textStyle="bold"
-                android:textSize="16dp"/>
-        <TextView
-                android:id="@+id/textViewSSHAttacks"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="25dp"
-                android:layout_weight="1"
-                android:text="recorded attacks: 20"
-                android:textStyle="bold"
-                android:textSize="12dp"/>
-        <Switch
-                android:id="@+id/home_switch_connection"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="false"
-                android:layout_alignParentEnd="false"
-                android:layout_alignParentLeft="false"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentTop="false"
-                android:layout_gravity="right"
-                android:layout_marginLeft="0dp"
-                android:layout_marginRight="15dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="0dp"
-                android:layout_weight="1"
-                android:checked="false"
-                android:textSize="10dp" />
-    </RelativeLayout>
+    </ListView>
 
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
-    <RelativeLayout android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-        <TextView
-                android:id="@+id/textViewSSH"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="5dp"
-                android:layout_weight="1"
-                android:text="SSH"
-                android:textStyle="bold"
-                android:textSize="16dp"/>
-        <TextView
-                android:id="@+id/textViewSSHAttacks"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="25dp"
-                android:layout_weight="1"
-                android:text="recorded attacks: 20"
-                android:textStyle="bold"
-                android:textSize="12dp"/>
-        <Switch
-                android:id="@+id/home_switch_connection"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="false"
-                android:layout_alignParentEnd="false"
-                android:layout_alignParentLeft="false"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentTop="false"
-                android:layout_gravity="right"
-                android:layout_marginLeft="0dp"
-                android:layout_marginRight="15dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="0dp"
-                android:layout_weight="1"
-                android:checked="false"
-                android:textSize="10dp" />
-    </RelativeLayout>
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
-    <RelativeLayout android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-        <TextView
-                android:id="@+id/textViewSSH"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="5dp"
-                android:layout_weight="1"
-                android:text="SSH"
-                android:textStyle="bold"
-                android:textSize="16dp"/>
-        <TextView
-                android:id="@+id/textViewSSHAttacks"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="25dp"
-                android:layout_weight="1"
-                android:text="recorded attacks: 20"
-                android:textStyle="bold"
-                android:textSize="12dp"/>
-        <Switch
-                android:id="@+id/home_switch_connection"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="false"
-                android:layout_alignParentEnd="false"
-                android:layout_alignParentLeft="false"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentTop="false"
-                android:layout_gravity="right"
-                android:layout_marginLeft="0dp"
-                android:layout_marginRight="15dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="0dp"
-                android:layout_weight="1"
-                android:checked="false"
-                android:textSize="10dp" />
-    </RelativeLayout>
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
-    <RelativeLayout android:layout_width="fill_parent"
-                    android:layout_height="wrap_content"
-                    android:baselineAligned="false"
-                    android:orientation="horizontal"
-                    android:weightSum="1" >
-        <TextView
-                android:id="@+id/textViewSSH"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="5dp"
-                android:layout_weight="1"
-                android:text="SSH"
-                android:textStyle="bold"
-                android:textSize="16dp"/>
-        <TextView
-                android:id="@+id/textViewSSHAttacks"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentEnd="true"
-                android:layout_alignParentLeft="true"
-                android:layout_alignParentRight="false"
-                android:layout_marginLeft="50dp"
-                android:layout_marginTop="25dp"
-                android:layout_weight="1"
-                android:text="recorded attacks: 20"
-                android:textStyle="bold"
-                android:textSize="12dp"/>
-        <Switch
-                android:id="@+id/home_switch_connection"
-                android:layout_width="wrap_content"
-                android:layout_height="wrap_content"
-                android:layout_alignParentBottom="false"
-                android:layout_alignParentEnd="false"
-                android:layout_alignParentLeft="false"
-                android:layout_alignParentRight="true"
-                android:layout_alignParentTop="false"
-                android:layout_gravity="right"
-                android:layout_marginLeft="0dp"
-                android:layout_marginRight="15dp"
-                android:layout_marginTop="10dp"
-                android:layout_marginBottom="0dp"
-                android:layout_weight="1"
-                android:checked="false"
-                android:textSize="10dp" />
-    </RelativeLayout>
-
-    <View
-            android:layout_width="fill_parent"
-            android:layout_height="1dp"
-            android:layout_marginLeft="15dp"
-            android:layout_marginRight="15dp"
-            android:background="@android:color/darker_gray" />
-    </LinearLayout>
-    </ScrollView>
 </LinearLayout>

+ 66 - 0
res/layout/services_list_item.xml

@@ -0,0 +1,66 @@
+<?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="fill_parent"
+                    android:layout_height="wrap_content"
+                    android:baselineAligned="false"
+                    android:orientation="horizontal"
+                    android:weightSum="1" >
+        <TextView
+                android:id="@+id/services_item_name"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentEnd="true"
+                android:layout_alignParentLeft="true"
+                android:layout_alignParentRight="false"
+                android:layout_marginLeft="50dp"
+                android:layout_marginTop="5dp"
+                android:layout_weight="1"
+                android:text="SSH"
+                android:textStyle="bold"
+                android:textSize="16dp"/>
+        <TextView
+                android:id="@+id/services_item_rec_attacks"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentEnd="true"
+                android:layout_alignParentLeft="true"
+                android:layout_alignParentRight="false"
+                android:layout_marginLeft="50dp"
+                android:layout_marginTop="25dp"
+                android:layout_weight="1"
+                android:text="recorded attacks: 20"
+                android:textStyle="bold"
+                android:textSize="12dp"/>
+        <Switch
+                android:id="@+id/services_item_switch"
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_alignParentBottom="false"
+                android:layout_alignParentEnd="false"
+                android:layout_alignParentLeft="false"
+                android:layout_alignParentRight="true"
+                android:layout_alignParentTop="false"
+                android:layout_gravity="right"
+                android:layout_marginLeft="0dp"
+                android:layout_marginRight="15dp"
+                android:layout_marginTop="10dp"
+                android:layout_marginBottom="0dp"
+                android:layout_weight="1"
+                android:checked="false"
+                android:textSize="10dp" />
+    </RelativeLayout>
+
+    <View
+            android:layout_width="fill_parent"
+            android:layout_height="1dp"
+            android:layout_marginLeft="15dp"
+            android:layout_marginRight="15dp"
+            android:background="@android:color/darker_gray" />
+
+
+</LinearLayout>

+ 70 - 0
src/de/tudarmstadt/informatik/hostage/ui2/adapter/ServicesListAdapter.java

@@ -0,0 +1,70 @@
+package de.tudarmstadt.informatik.hostage.ui2.adapter;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.ArrayAdapter;
+import android.widget.ImageButton;
+import android.widget.ImageView;
+import android.widget.ListView;
+import android.widget.Switch;
+import android.widget.TextView;
+import android.widget.ViewSwitcher;
+
+import java.util.List;
+
+import de.tudarmstadt.informatik.hostage.R;
+import de.tudarmstadt.informatik.hostage.ui2.model.ServicesListItem;
+
+/**
+ * Created by Daniel Lazar on 06.02.14.
+ */
+public class ServicesListAdapter extends ArrayAdapter<ServicesListItem> {
+		private class ViewHolder {
+			public TextView protocolName;
+			public TextView recordedAttacks;
+			public Switch activated;
+		}
+
+	private final Context context;
+	private final List<ServicesListItem> values;
+
+	public ServicesListAdapter(Context context, List<ServicesListItem> objects){
+		super(context, R.layout.services_list_item, objects);
+
+		this.context = context;
+		this.values = objects;
+	}
+
+	@Override
+	public View getView(final int position, View convertView, ViewGroup parent) {
+		LayoutInflater inflater = (LayoutInflater) context
+				.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
+
+		View rowView = convertView;
+		ViewHolder holder = null;
+
+		final ServicesListItem item = values.get(position);
+
+		if(rowView == null){
+			rowView = inflater.inflate(R.layout.services_list_item, parent, false);
+
+			holder = new ViewHolder();
+			holder.protocolName = (TextView) rowView.findViewById(R.id.services_item_name);
+			holder.recordedAttacks = (TextView) rowView.findViewById(R.id.services_item_rec_attacks);
+			holder.activated = (Switch) rowView.findViewById(R.id.services_item_switch);
+
+			rowView.setTag(holder);
+		} else {
+			holder = (ViewHolder) rowView.getTag();
+		}
+
+		holder.protocolName.setText(item.protocol);
+		holder.recordedAttacks.setText(item.attacks);
+
+
+		return rowView;
+	}
+
+}

+ 66 - 47
src/de/tudarmstadt/informatik/hostage/ui2/fragment/ServicesFragment.java

@@ -1,18 +1,28 @@
 package de.tudarmstadt.informatik.hostage.ui2.fragment;
 
 
+import android.app.AlertDialog;
+import android.content.DialogInterface;
 import android.os.Bundle;
 import android.app.Fragment;
 import android.view.LayoutInflater;
 import android.view.View;
 import android.view.ViewGroup;
 import android.widget.CompoundButton;
+import android.widget.ListView;
 import android.widget.Switch;
 import android.widget.TextView;
 
+import java.util.ArrayList;
+
 import de.tudarmstadt.informatik.hostage.HoneyService;
 import de.tudarmstadt.informatik.hostage.R;
 import de.tudarmstadt.informatik.hostage.commons.HelperUtils;
+import de.tudarmstadt.informatik.hostage.protocol.FTP;
+import de.tudarmstadt.informatik.hostage.ui2.adapter.ServicesListAdapter;
+import de.tudarmstadt.informatik.hostage.ui2.model.ServicesListItem;
+
+import static de.tudarmstadt.informatik.hostage.HoneyService.*;
 
 /**
  * Created by Daniel Lazar on 05.02.14.
@@ -22,27 +32,6 @@ public class ServicesFragment extends Fragment{
 	private Switch mServicesSwitchService;
 	private TextView mServicesTextName;
 
-	private TextView mServicesTextSSH;
-	private TextView mServicesTextFTP;
-	private TextView mServicesTextTELNET;
-	private TextView mServicesTextHTTP;
-	private TextView mServicesTextHTTPS;
-	private TextView mServicesTextSAMBA;
-
-	private TextView mServicesTextSSHAttacks;
-	private TextView mServicesTextFTPAttacks;
-	private TextView mServicesTextTELNETAttacks;
-	private TextView mServicesTextHTTPAttacks;
-	private TextView mServicesTextHTTPSAttacks;
-	private TextView mServicesTextSAMBAAttacks;
-
-	private Switch mServicesSwitchSSH;
-	private Switch mServicesSwitchFTP;
-	private Switch mServicesSwitchTELNET;
-	private Switch mServicesSwitchHTTP;
-	private Switch mServicesSwitchHTTPS;
-	private Switch mServicesSwitchSAMBA;
-
 	private View rootView;
 
 	private CompoundButton.OnCheckedChangeListener switchChangeListener = null;
@@ -51,48 +40,26 @@ public class ServicesFragment extends Fragment{
 	private void assignViews(){
 		mServicesSwitchService = (Switch) rootView.findViewById(R.id.service_switch_connection);
 		mServicesTextName = (TextView) rootView.findViewById(R.id.services_text_name);
-
-		mServicesTextSSH = (TextView) rootView.findViewById(R.id.textViewSSH);
-		mServicesTextFTP = (TextView) rootView.findViewById(R.id.textViewFTP);
-		mServicesTextTELNET = (TextView) rootView.findViewById(R.id.textViewTELNET);
-		mServicesTextHTTP = (TextView) rootView.findViewById(R.id.textViewHTTP);
-		mServicesTextHTTPS = (TextView) rootView.findViewById(R.id.textViewHTTPS);
-		mServicesTextSAMBA = (TextView) rootView.findViewById(R.id.textViewSAMBA);
-
-		mServicesTextSSHAttacks = (TextView) rootView.findViewById(R.id.textViewSSHAttacks);
-		mServicesTextFTPAttacks = (TextView) rootView.findViewById(R.id.textViewFTPAttacks);
-		mServicesTextTELNETAttacks = (TextView) rootView.findViewById(R.id.textViewTELNETAttacks);
-		mServicesTextHTTPAttacks = (TextView) rootView.findViewById(R.id.textViewHTTPAttacks);
-		mServicesTextHTTPSAttacks = (TextView) rootView.findViewById(R.id.textViewHTTPSAttacks);
-		mServicesTextSAMBAAttacks = (TextView) rootView.findViewById(R.id.textViewSAMBAAttacks);
-
-		mServicesSwitchSSH = (Switch) rootView.findViewById(R.id.ssh_switch);
-		mServicesSwitchFTP = (Switch) rootView.findViewById(R.id.ftp_switch);
-		mServicesSwitchTELNET = (Switch) rootView.findViewById(R.id.telnet_switch);
-		mServicesSwitchHTTP = (Switch) rootView.findViewById(R.id.http_switch);
-		mServicesSwitchHTTPS = (Switch) rootView.findViewById(R.id.https_switch);
-		mServicesSwitchSAMBA = (Switch) rootView.findViewById(R.id.samba_switch);
-
 	}
 
 	public void updateUI(){
 		if(!HelperUtils.isWifiConnected(getActivity())){
 			mServicesSwitchService.setOnCheckedChangeListener(null);
+			setStateNotConnected();
+			setStateNotActive();
 			mServicesSwitchService.setOnCheckedChangeListener(switchChangeListener);
 		}
 		else {
 			mServicesTextName.setText(HelperUtils.getSSID(getActivity()));
 		}
 
-
 /*		//check if ftp monitoring is running
-		if(!HoneyService.isRunning("ftp")){
+		if(!HoneyService.isRunning(protocols[1])){
 			mServicesSwitchFTP.setOnCheckedChangeListener(null);
 		}
 		else {
 			mServicesSwitchFTP.setChecked(true);
-		}
-*/
+		}*/
 	}
 	public ServicesFragment(){}
 
@@ -105,8 +72,60 @@ public class ServicesFragment extends Fragment{
 		assignViews();
 
 		updateUI();
+
+		ListView list = (ListView) rootView.findViewById(R.id.services_list_view);
+		String[] protocols = getResources().getStringArray(R.array.protocols);
+		ArrayList<ServicesListItem> protocolList= new ArrayList<ServicesListItem>();
+
+		for(String protocol: protocols){
+			protocolList.add(new ServicesListItem(protocol));
+		}
+
+		ServicesListAdapter adapter = new ServicesListAdapter(getActivity().getBaseContext(), protocolList);
+		list.setAdapter(adapter);
+
+		if(switchChangeListener == null){
+			switchChangeListener = new CompoundButton.OnCheckedChangeListener() {
+				public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
+					if(!HelperUtils.isWifiConnected(getActivity())){
+						new AlertDialog.Builder(getActivity())
+								.setTitle("Information")
+								.setMessage("You are not connected to a WiFi network. \n\nPlease connect to one, before trying to activate HosTaGe.")
+								.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
+									public void onClick(DialogInterface dialog, int which) {
+
+									}
+								})
+								.setIcon(android.R.drawable.ic_dialog_info)
+								.show();
+
+
+						setStateNotActive();
+						setStateNotConnected();
+					} else {
+						if(isChecked){
+							setStateActive();
+						} else {
+							setStateNotActive();
+						}
+					}
+				}
+			};
+		}
 		return rootView;
 
 	}
 
+	private void setStateActive() {
+
+	}
+
+	private void setStateNotConnected() {
+		mServicesTextName.setText("Not connected");
+	}
+
+	private void setStateNotActive() {
+
+	}
+
 }

+ 16 - 0
src/de/tudarmstadt/informatik/hostage/ui2/model/ServicesListItem.java

@@ -0,0 +1,16 @@
+package de.tudarmstadt.informatik.hostage.ui2.model;
+
+/**
+ * Created by Daniel Lazar on 06.02.14.
+ */
+public class ServicesListItem {
+	public String protocol;
+	public String attacks;
+
+	public boolean activated;
+
+	public ServicesListItem(String protocol){
+		this.protocol = protocol;
+		this.activated = false;
+	}
+}