Allow parent device to pair to child via IP Address and port

If mDNS fails to locate the child device, allow the parent device
to enter an IP address and port to connect.
This commit is contained in:
Branden Archer
2016-01-01 16:58:53 -05:00
parent 562a2bb164
commit c032e9f642
6 changed files with 200 additions and 69 deletions

View File

@@ -22,78 +22,38 @@
android:layout_width="match_parent"
android:layout_height="15dip" />
<TextView
android:id="@+id/parentPairInstructions"
android:layout_width="wrap_content"
<Button
android:id="@+id/discoverChildButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/parentPairInstructions" />
android:text="@string/discoverChild"
android:textSize="17sp" />
<TextView
android:id="@+id/discoverChildDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/discoverChildDescription"
android:textSize="14sp" />
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<TextView
android:id="@+id/ipAddressTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/addressTitle" />
<EditText
android:id="@+id/ipAddressField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/exampleAddress"
android:inputType="textUri"
android:textSize="20sp"
android:nextFocusForward="@+id/portField" >
</EditText>
<TextView
android:id="@+id/portTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/portTitle" />
<EditText
android:id="@+id/portField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:ems="10"
android:inputType="number"
android:maxLength="5"
android:hint="@string/examplePort"
android:nextFocusForward="@+id/connectViaAddressButton"/>
android:layout_width="match_parent"
android:layout_height="15dip" />
<Button
android:id="@+id/connectViaAddressButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/connect" />
<Space
android:id="@+id/enterChildAddressButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="15dip" />
android:layout_height="wrap_content"
android:text="@string/enterChildAddress"
android:textSize="17sp" />
<TextView
android:id="@+id/selectChildDeviceTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/selectChildDevice"
android:textSize="20sp" />
<ListView
android:id="@+id/ServiceTable"
android:scrollbars="vertical"
android:id="@+id/enterChildAddressDescription"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.32"
android:padding="10dp" >
</ListView>
android:layout_height="wrap_content"
android:text="@string/enterChildAddressDescription"
android:textSize="14sp" />
</LinearLayout>

View File

@@ -0,0 +1,83 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="protect.babymonitor.MonitorActivity" >
<TextView
android:id="@+id/parentDeviceTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/parentDevice"
android:textSize="25sp" />
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<TextView
android:id="@+id/enterAddressInstructions"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/enterAddressInstructions" />
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<TextView
android:id="@+id/ipAddressTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/addressTitle" />
<EditText
android:id="@+id/ipAddressField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="@string/exampleAddress"
android:inputType="textUri"
android:textSize="20sp"
android:nextFocusForward="@+id/portField" >
</EditText>
<TextView
android:id="@+id/portTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp"
android:text="@string/portTitle" />
<EditText
android:id="@+id/portField"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="20sp"
android:ems="10"
android:inputType="number"
android:maxLength="5"
android:hint="@string/examplePort"
android:nextFocusForward="@+id/connectViaAddressButton"/>
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<Button
android:id="@+id/connectViaAddressButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="@string/connect" />
</LinearLayout>

View File

@@ -0,0 +1,41 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="protect.babymonitor.MonitorActivity" >
<TextView
android:id="@+id/parentDeviceTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/parentDevice"
android:textSize="25sp" />
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<TextView
android:id="@+id/selectChildDeviceTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/selectChildDevice"
android:textSize="20sp" />
<ListView
android:id="@+id/ServiceTable"
android:scrollbars="vertical"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="0.32"
android:padding="10dp" >
</ListView>
</LinearLayout>

View File

@@ -24,9 +24,14 @@
<string name="portTitle">Port:</string>
<string name="addressDescription">Address and port that parent must pair to</string>
<string name="wifiNotConnected">Not connected to a Wi-Fi network</string>
<string name="parentPairInstructions">Enter the IP Address and port of a child and click Connect, or choose a child from the list below</string>
<string name="enterAddressInstructions">Enter the IP Address and port of a child and click Connect</string>
<string name="connect">Connect</string>
<string name="exampleAddress">192.168.1.2</string>
<string name="examplePort">10000</string>
<string name="invalidPort">Either no port was entered or it is invalid</string>
<string name="invalidAddress">The address field needs to be filled out</string>
<string name="discoverChild">Discover Child on Network</string>
<string name="discoverChildDescription">Select child from a list of discovered children on the network</string>
<string name="enterChildAddress">Select Child by Address</string>
<string name="enterChildAddressDescription">Enter the address and port of the child</string>
</resources>