Example integration with WiFiDirect

Change-Id: Id65530c43d67894b46ce1aa0d523e6e99e621023
Refs:3939
diff --git a/app/src/main/res/drawable-hdpi/machine.png b/app/src/main/res/drawable-hdpi/machine.png
new file mode 100755
index 0000000..d61609a
--- /dev/null
+++ b/app/src/main/res/drawable-hdpi/machine.png
Binary files differ
diff --git a/app/src/main/res/layout/fragment_wifidirect.xml b/app/src/main/res/layout/fragment_wifidirect.xml
new file mode 100644
index 0000000..cb3136b
--- /dev/null
+++ b/app/src/main/res/layout/fragment_wifidirect.xml
@@ -0,0 +1,148 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    android:layout_height="wrap_content"
+    android:layout_width="match_parent"
+    android:orientation="vertical"
+    android:layout_margin="20dp"
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools">
+    <ScrollView
+        android:layout_height="wrap_content"
+        android:layout_width="match_parent">
+        <LinearLayout
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            android:orientation="vertical"
+            tools:context="net.named_data.nfd.WiFiDirectFragment">
+
+            <!-- Row with title and on/off switch -->
+            <RelativeLayout
+                android:layout_width="wrap_content"
+                android:layout_height="wrap_content"
+                android:layout_marginBottom="10dp">
+                <TextView
+                    android:text="@string/fragment_wifidirect_title"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content" />
+
+                <Switch
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/wd_switch"
+                    android:layout_alignParentRight="true" />
+            </RelativeLayout>
+
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:weightSum="1">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/fragment_wifidirect_label_me"
+                    android:layout_weight="0.10" />
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/wd_this_device_name_textview" />
+            </LinearLayout>
+
+            <View
+                android:layout_width="fill_parent"
+                android:layout_height="1dp"
+                android:gravity="center_vertical"
+                android:background="@color/android_color_gray" />
+
+            <!-- Row for Group connection status -->
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:weightSum="1">
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/fragment_wifidirect_group_conn_status"
+                    android:layout_weight="0.10" />
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/wd_group_conn_status_textview" />
+            </LinearLayout>
+
+            <!-- Row for IP address display -->
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:weightSum="1">
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/fragment_wifidirect_curr_ip"
+                    android:layout_weight="0.10"/>
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/wd_ip_address_textview" />
+            </LinearLayout>
+
+            <!-- Row for group owner indicator -->
+            <LinearLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content"
+                android:orientation="horizontal"
+                android:weightSum="1">
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:text="@string/fragment_wifidirect_is_group_own"
+                    android:layout_weight="0.10"/>
+
+                <TextView
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:id="@+id/wd_group_owner_textview" />
+            </LinearLayout>
+        </LinearLayout>
+    </ScrollView>
+
+    <!-- Column of currently connected peers -->
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/fragment_wifidirect_connected_peers"
+        android:layout_marginTop="10dp"/>
+    <View
+        android:layout_width="fill_parent"
+        android:layout_height="1dp"
+        android:gravity="center_vertical"
+        android:background="@color/android_color_gray" />
+    <ListView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/wd_connected_peers_listview"/>
+
+    <!-- Column of discovered peers -->
+    <TextView
+        android:layout_width="wrap_content"
+        android:layout_height="wrap_content"
+        android:text="@string/fragment_wifidirect_discovered_peers"
+        android:layout_marginTop="10dp"/>
+    <View
+        android:layout_width="fill_parent"
+        android:layout_height="1dp"
+        android:gravity="center_vertical"
+        android:background="@color/android_color_gray" />
+    <ListView
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:id="@+id/wd_discovered_peers_listview"/>
+
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/layout/row_devices.xml b/app/src/main/res/layout/row_devices.xml
new file mode 100755
index 0000000..baf49e3
--- /dev/null
+++ b/app/src/main/res/layout/row_devices.xml
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="utf-8"?>
+<LinearLayout
+    xmlns:android="http://schemas.android.com/apk/res/android"
+    android:layout_width="fill_parent"
+    android:layout_height="?android:attr/listPreferredItemHeight"
+    android:background="?android:attr/activatedBackgroundIndicator"
+    android:padding="6dip">
+    <ImageView
+        android:id="@+id/icon"
+        android:layout_width="wrap_content"
+        android:layout_height="fill_parent"
+        android:layout_marginRight="2dip"
+        android:src="@drawable/machine" />
+    <LinearLayout
+        android:orientation="vertical"
+        android:layout_width="0dip"
+        android:layout_weight="1"
+        android:layout_height="fill_parent">
+        <TextView
+            android:id="@+id/device_name"
+            android:layout_width="fill_parent"
+            android:layout_height="0dip"
+            android:layout_weight="1"
+            android:gravity="center_vertical" />
+        <TextView
+            android:layout_width="fill_parent"
+            android:layout_height="0dip"
+            android:layout_weight="1"
+            android:id="@+id/device_details"
+            android:ellipsize="marquee" />
+    </LinearLayout>
+</LinearLayout>
\ No newline at end of file
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index ff141d1..5aa76b3 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -2,6 +2,10 @@
     <string name="start">Start</string>
     <string name="stop">Stop</string>
     <string name="app_name">NFD</string>
+    <string name="yes">Yes</string>
+    <string name="no">No</string>
+    <string name="empty_string">""</string>
+    <string name="question_mark">\?</string>
     <string name="service_name">NFD Service</string>
     <string name="action_settings">Settings</string>
     <string name="nfd_stopped">NFD is stopped</string>
@@ -20,6 +24,32 @@
     <string name="drawer_item_ping">Ping</string>
     <string name="drawer_item_strategies">Strategies</string>
     <string name="drawer_item_logcat">Logcat</string>
+    <string name="drawer_item_wifidirect">WiFi Direct</string>
+    <string name="fragment_wifidirect_label_me">Me: </string>
+    <string name="fragment_wifidirect_title">NDN Over WiFi Direct</string>
+    <string name="fragment_wifidirect_group_conn_status">Group connection status: </string>
+    <string name="fragment_wifidirect_is_group_own">Is group owner: </string>
+    <string name="fragment_wifidirect_text_group_connected">Connected to group.</string>
+    <string name="fragment_wifidirect_text_group_scanning">Scanning...</string>
+    <string name="fragment_wifidirect_text_group_wifi_p2p_disabled">WIFI p2p is disabled</string>
+    <string name="fragment_wifidirect_curr_ip">Current WiFi Direct IP: </string>
+    <string name="fragment_wifidirect_connected_peers">Connected Peers: </string>
+    <string name="fragment_wifidirect_discovered_peers">Discovered Peers: </string>
+    <string name="fragment_wifidirect_toast_connected_to_group">Currently connected to a group, please disconnect first</string>
+    <string name="fragment_wifidirect_toast_peer_no_longer_available">The peer is no longer available</string>
+    <string name="fragment_wifidirect_toast_connection_works_well">Connection is working correctly</string>
+    <string name="fragment_wifidirect_toast_didnt_get_response">Didn\'t get responses in the last\u0020</string>
+    <string name="fragment_wifidirect_toast_seconds">\u0020seconds</string>
+    <string name="fragment_wifidirect_dialog_cancel_invitation">Cancel invitation for\u0020</string>
+    <string name="fragment_wifidirect_dialog_cancelling">Cancelling</string>
+    <string name="fragment_wifidirect_dialog_cancelling_invitation">Cancelling invitation for\u0020</string>
+    <string name="fragment_wifidirect_dialog_disconnect_from">Disconnect from\u0020</string>
+    <string name="fragment_wifidirect_dialog_disconnecting">Disconnecting</string>
+    <string name="fragment_wifidirect_dialog_disconnecting_from">Disconnecting from\u0020</string>
+    <string name="fragment_wifidirect_dialog_invite">Invite\u0020</string>
+    <string name="fragment_wifidirect_dialog_inviting">Inviting\u0020</string>
+    <string name="fragment_wifidirect_dialog_join_group">\u0020to join a group</string>
+    <string name="fragment_wifidirect_dialog_destroy_group_alter">\u0020Because you are the group owner, disconnecting from a device will also destroy the group.</string>
     <string name="menu_item_delete_setting_item">Delete</string>
     <string name="fragment_logcat_general_operations_category">General Actions</string>
     <string name="fragment_logcat_tags_n_log_levels">Tags &amp; Log Levels</string>