Skip to content

Commit

Permalink
add code for sending a MeshMS to Serval Mesh for processing
Browse files Browse the repository at this point in the history
  • Loading branch information
techxplorer committed May 11, 2012
1 parent 01aaf85 commit 52bdb06
Show file tree
Hide file tree
Showing 8 changed files with 549 additions and 1 deletion.
6 changes: 6 additions & 0 deletions AndroidManifest.xml
Expand Up @@ -26,7 +26,12 @@
android:versionName="1.0" >

<uses-sdk android:minSdkVersion="8" android:targetSdkVersion="8" />

<!-- permission required to start and stop the Serval Mesh software -->
<uses-permission android:name="org.servalproject.START_STOP"/>

<!-- permission required to send a MeshMS message -->
<uses-permission android:name="org.servalproject.meshms.SEND_MESHMS"/>

<application
android:icon="@drawable/ic_launcher"
Expand All @@ -45,6 +50,7 @@
<activity android:name=".StateChangedActivity" android:label="@string/state_changed_ui_lbl_title" android:launchMode="singleTop"></activity>
<activity android:name=".StateCheckActivity" android:label="@string/state_check_ui_lbl_title" android:launchMode="singleTop"></activity>
<activity android:name=".StartStopActivity" android:label="@string/start_stop_ui_lbl_title"></activity>
<activity android:name=".SendMeshMS" android:label="@string/send_meshms_ui_lbl_title"></activity>
</application>

</manifest>
25 changes: 25 additions & 0 deletions res/layout/main.xml
Expand Up @@ -181,6 +181,31 @@

</TableRow>

<TableRow
android:id="@+id/main_ui_tbl_row_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >

<TextView
android:id="@+id/main_ui_lbl_send_meshms"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/ui_elem_margin_bottom"
android:layout_marginLeft="@dimen/ui_elem_margin_left"
android:layout_marginRight="@dimen/ui_elem_margin_right"
android:text="@string/main_ui_lbl_send_meshms" />

<Button
android:id="@+id/main_ui_btn_send_meshms"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/ui_elem_margin_bottom"
android:layout_marginLeft="@dimen/ui_elem_margin_left"
android:layout_marginRight="@dimen/ui_elem_margin_right"
android:text="@string/main_ui_btn_try_it" />

</TableRow>

</TableLayout>

</ScrollView>
Expand Down
84 changes: 84 additions & 0 deletions res/layout/send_meshms.xml
@@ -0,0 +1,84 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="#000000">

<TextView android:id="@+id/send_meshms_ui_lbl_title"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/send_meshms_ui_lbl_title"
android:layout_marginBottom="@dimen/ui_elem_margin_bottom"
android:layout_marginLeft="@dimen/ui_elem_margin_left"
android:layout_marginRight="@dimen/ui_elem_margin_right"
android:gravity="center_vertical|center_horizontal"
android:textAppearance="?android:attr/textAppearanceLarge" />

<TextView android:id="@+id/send_meshms_ui_lbl_subtitle"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/send_meshms_ui_lbl_subtitle"
android:layout_marginBottom="@dimen/ui_elem_margin_bottom"
android:layout_marginLeft="@dimen/ui_elem_margin_left"
android:layout_marginRight="@dimen/ui_elem_margin_right"
android:gravity="center_vertical|center_horizontal" />

<TableLayout android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="1">

<TableRow android:id="@+id/send_meshms_ui_tbl_row_1"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<TextView android:id="@+id/send_meshms_ui_lbl_phone_no"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/send_meshms_ui_lbl_phone_no"
android:layout_marginBottom="@dimen/ui_elem_margin_bottom"
android:layout_marginLeft="@dimen/ui_elem_margin_left"
android:layout_marginRight="@dimen/ui_elem_margin_right" />

<EditText android:id="@+id/send_meshms_ui_txt_phone_no"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="phone"
android:layout_marginBottom="@dimen/ui_elem_margin_bottom"
android:layout_marginLeft="@dimen/ui_elem_margin_left"
android:layout_marginRight="@dimen/ui_elem_margin_right" />

</TableRow>

<TableRow android:id="@+id/send_meshms_ui_tbl_row_2"
android:layout_width="fill_parent"
android:layout_height="wrap_content">

<TextView android:id="@+id/send_meshms_ui_lbl_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/send_meshms_ui_lbl_content"
android:layout_marginBottom="@dimen/ui_elem_margin_bottom"
android:layout_marginLeft="@dimen/ui_elem_margin_left"
android:layout_marginRight="@dimen/ui_elem_margin_right" />

<EditText android:id="@+id/send_meshms_ui_txt_content"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textCapSentences|textMultiLine"
android:lines="5"
android:layout_marginBottom="@dimen/ui_elem_margin_bottom"
android:layout_marginLeft="@dimen/ui_elem_margin_left"
android:layout_marginRight="@dimen/ui_elem_margin_right" />
</TableRow>
</TableLayout>

<Button android:id="@+id/send_meshms_ui_btn_send"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="@dimen/ui_elem_margin_bottom"
android:layout_marginLeft="@dimen/ui_elem_margin_left"
android:layout_marginRight="@dimen/ui_elem_margin_right"
android:text="@string/send_meshms_ui_btn_send" />

</LinearLayout>
23 changes: 22 additions & 1 deletion res/values/strings.xml
Expand Up @@ -24,13 +24,14 @@

<!-- main activity strings -->
<string name="main_ui_lbl_title">Serval Mesh Sampler</string>
<string name="main_ui_lbl_subtitle">Use the buttons below to explore the functionality of the Serval Mesh APIs</string>
<string name="main_ui_lbl_subtitle">Use the buttons below to explore the functionality of the Serval Mesh APIs.\n\nScroll down to see all of the buttons</string>

<string name="main_ui_lbl_mesh_installed">Serval Mesh Installed?</string>
<string name="main_ui_lbl_sid_did">Get Serval DID &amp; SID</string>
<string name="main_ui_lbl_state_change">Listen for State Changes</string>
<string name="main_ui_lbl_state_check">Check Serval Mesh State</string>
<string name="main_ui_lbl_start_stop">Start / Stop Serval Mesh</string>
<string name="main_ui_lbl_send_meshms">Send a MeshMS</string>

<string name="main_ui_btn_try_it">Try It</string>

Expand Down Expand Up @@ -90,6 +91,23 @@
<string name="start_stop_ui_lbl_stop">Stop Serval</string>
<string name="start_stop_ui_btn_stop">Strop</string>

<!-- send serval meshms activity strings -->
<string name="send_meshms_ui_lbl_title">Send a Serval MeshMS</string>
<string name="send_meshms_ui_lbl_subtitle">Sending a Serval MeshMS requires that an application uses the "org.servalproject.meshms.SEND_MESHMS" permission.</string>

<string name="send_meshms_ui_lbl_phone_no">Phone Number: </string>
<string name="send_meshms_ui_lbl_content">Content: </string>

<string name="send_meshms_ui_btn_send">Send Message</string>

<string name="send_meshms_toast_no_phone">The phone number is missing</string>
<string name="send_meshms_toast_phone_not_digits">The phone number must contain only digits</string>

<string name="send_meshms_toast_no_content">The content of the message is missing</string>
<string name="send_meshms_toast_content_length">The content of the message must be below %1$s characters</string>

<string name="send_meshms_toast_sent">Message has been sent to Serval Mesh for processing</string>

<!--
start slightly modified list of state strings
as sourced from the Serval Mesh strings file
Expand Down Expand Up @@ -121,4 +139,7 @@

<string name="system_serval_mesh_start_action">org.servalproject.ACTION_START_SERVAL</string>
<string name="system_serval_mesh_stop_action">org.servalproject.ACTION_STOP_SERVAL</string>

<string name="system_serval_meshms_send_action">org.servalproject.meshms.SEND_MESHMS</string>
<string name="system_serval_meshms_extra_name">simple</string>
</resources>

0 comments on commit 52bdb06

Please sign in to comment.