Convert project from ant to gradle

This commit is contained in:
Branden Archer
2017-09-13 10:33:55 -04:00
parent ffee8003f0
commit 3a63c45015
38 changed files with 317 additions and 130 deletions

19
app/build.gradle Normal file
View File

@@ -0,0 +1,19 @@
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "protect.babymonitor"
minSdkVersion 17
targetSdkVersion 17
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}

View File

@@ -0,0 +1,50 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="protect.babymonitor"
android:versionCode="2"
android:versionName="0.2" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="8" />
<uses-permission android:required="true" android:name="android.permission.INTERNET"/>
<uses-permission android:required="true" android:name="android.permission.RECORD_AUDIO"/>
<uses-permission android:required="true" android:name="android.permission.ACCESS_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@android:style/Theme.Holo" >
<activity
android:name="protect.babymonitor.StartActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="protect.babymonitor.MonitorActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize"
android:parentActivityName="protect.babymonitor.StartActivity"
/>
<activity
android:name="protect.babymonitor.DiscoverActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize"
android:windowSoftInputMode="adjustPan"
android:parentActivityName="protect.babymonitor.StartActivity"
/>
<activity
android:name="protect.babymonitor.ListenActivity"
android:label="@string/app_name"
android:configChanges="orientation|screenSize"
android:parentActivityName="protect.babymonitor.DiscoverActivity"
/>
</application>
</manifest>

View File

@@ -0,0 +1,303 @@
/**
* This file is part of the Protect Baby Monitor.
*
* Protect Baby Monitor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Protect Baby Monitor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Protect Baby Monitor. If not, see <http://www.gnu.org/licenses/>.
*/
package protect.babymonitor;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.net.nsd.NsdManager;
import android.net.nsd.NsdServiceInfo;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Toast;
public class DiscoverActivity extends Activity
{
final String TAG = "BabyMonitor";
NsdManager _nsdManager;
NsdManager.DiscoveryListener _discoveryListener;
@Override
protected void onCreate(Bundle savedInstanceState)
{
Log.i(TAG, "Baby monitor start");
_nsdManager = (NsdManager)this.getSystemService(Context.NSD_SERVICE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_discover);
final Button discoverChildButton = (Button) findViewById(R.id.discoverChildButton);
discoverChildButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
loadDiscoveryViaMdns();
}
});
final Button enterChildAddressButton = (Button) findViewById(R.id.enterChildAddressButton);
enterChildAddressButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
loadDiscoveryViaAddress();
}
});
}
private void loadDiscoveryViaMdns()
{
setContentView(R.layout.activity_discover_mdns);
startServiceDiscovery("_babymonitor._tcp.");
}
private void loadDiscoveryViaAddress()
{
setContentView(R.layout.activity_discover_address);
final Button connectButton = (Button) findViewById(R.id.connectViaAddressButton);
connectButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Log.i(TAG, "Connecting to child device via address");
final EditText addressField = (EditText) findViewById(R.id.ipAddressField);
final EditText portField = (EditText) findViewById(R.id.portField);
final String addressString = addressField.getText().toString();
final String portString = portField.getText().toString();
if(addressString.length() == 0)
{
Toast.makeText(DiscoverActivity.this, R.string.invalidAddress, Toast.LENGTH_LONG).show();
return;
}
int port = 0;
try
{
port = Integer.parseInt(portString);
}
catch(NumberFormatException e)
{
Toast.makeText(DiscoverActivity.this, R.string.invalidPort, Toast.LENGTH_LONG).show();
return;
}
connectToChild(addressString, port, addressString);
}
});
}
@Override
protected void onDestroy()
{
Log.i(TAG, "Baby monitoring stop");
if(_discoveryListener != null)
{
Log.i(TAG, "Unregistering monitoring service");
_nsdManager.stopServiceDiscovery(_discoveryListener);
_discoveryListener = null;
}
super.onDestroy();
}
public void startServiceDiscovery(final String serviceType)
{
final NsdManager nsdManager = (NsdManager)this.getSystemService(Context.NSD_SERVICE);
final ListView serviceTable = (ListView) findViewById(R.id.ServiceTable);
final ArrayAdapter<ServiceInfoWrapper> availableServicesAdapter = new ArrayAdapter<ServiceInfoWrapper>(this,
R.layout.available_children_list);
serviceTable.setAdapter(availableServicesAdapter);
serviceTable.setOnItemClickListener(new OnItemClickListener()
{
@Override
public void onItemClick(AdapterView<?> parent, View view,
int position, long id)
{
final ServiceInfoWrapper info = (ServiceInfoWrapper) parent.getItemAtPosition(position);
connectToChild(info.getAddress(), info.getPort(), info.getName());
}
});
// Instantiate a new DiscoveryListener
_discoveryListener = new NsdManager.DiscoveryListener()
{
// Called as soon as service discovery begins.
@Override
public void onDiscoveryStarted(String regType)
{
Log.d(TAG, "Service discovery started");
}
@Override
public void onServiceFound(NsdServiceInfo service) {
// A service was found! Do something with it.
Log.d(TAG, "Service discovery success: " + service);
if (!service.getServiceType().equals(serviceType))
{
// Service type is the string containing the protocol and
// transport layer for this service.
Log.d(TAG, "Unknown Service Type: " + service.getServiceType());
}
else if (service.getServiceName().contains("ProtectBabyMonitor"))
{
NsdManager.ResolveListener resolver = new NsdManager.ResolveListener()
{
@Override
public void onResolveFailed(NsdServiceInfo serviceInfo, int errorCode)
{
// Called when the resolve fails. Use the error code to debug.
Log.e(TAG, "Resolve failed: error " + errorCode + " for service: " + serviceInfo);
}
@Override
public void onServiceResolved(final NsdServiceInfo serviceInfo)
{
Log.i(TAG, "Resolve Succeeded: " + serviceInfo);
DiscoverActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
availableServicesAdapter.add(new ServiceInfoWrapper(serviceInfo));
}
});
}
};
_nsdManager.resolveService(service, resolver);
}
else
{
Log.d(TAG, "Unknown Service name: " + service.getServiceName());
}
}
@Override
public void onServiceLost(NsdServiceInfo service)
{
// When the network service is no longer available.
// Internal bookkeeping code goes here.
Log.e(TAG, "Service lost: " + service);
}
@Override
public void onDiscoveryStopped(String serviceType)
{
Log.i(TAG, "Discovery stopped: " + serviceType);
}
@Override
public void onStartDiscoveryFailed(String serviceType, int errorCode)
{
Log.e(TAG, "Discovery failed: Error code: " + errorCode);
nsdManager.stopServiceDiscovery(this);
}
@Override
public void onStopDiscoveryFailed(String serviceType, int errorCode)
{
Log.e(TAG, "Discovery failed: Error code: " + errorCode);
nsdManager.stopServiceDiscovery(this);
}
};
nsdManager.discoverServices(
serviceType, NsdManager.PROTOCOL_DNS_SD, _discoveryListener);
}
/**
* Launch the ListenActivity to connect to the given child device
*
* @param address
* @param port
* @param name
*/
private void connectToChild(final String address, final int port, final String name)
{
final Intent i = new Intent(getApplicationContext(), ListenActivity.class);
final Bundle b = new Bundle();
b.putString("address", address);
b.putInt("port", port);
b.putString("name", name);
i.putExtras(b);
startActivity(i);
}
}
class ServiceInfoWrapper
{
private NsdServiceInfo _info;
public ServiceInfoWrapper(NsdServiceInfo info)
{
_info = info;
}
public String getAddress()
{
return _info.getHost().getHostAddress();
}
public int getPort()
{
return _info.getPort();
}
public String getName()
{
// If there is more than one service on the network, it will
// have a number at the end, but will appear as the following:
// "ProtectBabyMonitor\\032(number)
// or
// "ProtectBabyMonitor\032(number)
// Replace \\032 and \032 with a " "
String serviceName = _info.getServiceName();
serviceName = serviceName.replace("\\\\032", " ");
serviceName = serviceName.replace("\\032", " ");
return serviceName;
}
@Override
public String toString()
{
return getName();
}
}

View File

@@ -0,0 +1,188 @@
/**
* This file is part of the Protect Baby Monitor.
*
* Protect Baby Monitor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Protect Baby Monitor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Protect Baby Monitor. If not, see <http://www.gnu.org/licenses/>.
*/
package protect.babymonitor;
import java.io.IOException;
import java.io.InputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import android.app.Activity;
import android.media.AudioFormat;
import android.media.AudioManager;
import android.media.AudioTrack;
import android.media.MediaPlayer;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
public class ListenActivity extends Activity
{
final String TAG = "BabyMonitor";
String _address;
int _port;
String _name;
Thread _listenThread;
private void streamAudio(final Socket socket) throws IllegalArgumentException, IllegalStateException, IOException
{
Log.i(TAG, "Setting up stream");
final int frequency = 11025;
final int channelConfiguration = AudioFormat.CHANNEL_OUT_MONO;
final int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
final int bufferSize = AudioTrack.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
final int byteBufferSize = bufferSize*2;
final AudioTrack audioTrack = new AudioTrack(AudioManager.STREAM_MUSIC,
frequency,
channelConfiguration,
audioEncoding,
bufferSize,
AudioTrack.MODE_STREAM);
setVolumeControlStream(AudioManager.STREAM_MUSIC);
final InputStream is = socket.getInputStream();
int read = 0;
audioTrack.play();
try
{
final byte [] buffer = new byte[byteBufferSize];
while(socket.isConnected() && read != -1 && Thread.currentThread().isInterrupted() == false)
{
read = is.read(buffer);
if(read > 0)
{
audioTrack.write(buffer, 0, read);
}
}
}
finally
{
audioTrack.stop();
socket.close();
}
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
final Bundle b = getIntent().getExtras();
_address = b.getString("address");
_port = b.getInt("port");
_name = b.getString("name");
setContentView(R.layout.activity_listen);
ListenActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
final TextView connectedText = (TextView) findViewById(R.id.connectedTo);
connectedText.setText(_name);
final TextView statusText = (TextView) findViewById(R.id.textStatus);
statusText.setText(R.string.listening);
}
});
_listenThread = new Thread(new Runnable()
{
@Override
public void run()
{
try
{
final Socket socket = new Socket(_address, _port);
streamAudio(socket);
}
catch (UnknownHostException e)
{
Log.e(TAG, "Failed to stream audio", e);
}
catch (IOException e)
{
Log.e(TAG, "Failed to stream audio", e);
}
if(Thread.currentThread().isInterrupted() == false)
{
// If this thread has not been interrupted, likely something
// bad happened with the connection to the child device. Play
// an alert to notify the user that the connection has been
// interrupted.
playAlert();
ListenActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
final TextView connectedText = (TextView) findViewById(R.id.connectedTo);
connectedText.setText("");
final TextView statusText = (TextView) findViewById(R.id.textStatus);
statusText.setText(R.string.disconnected);
}
});
}
}
});
_listenThread.start();
}
@Override
public void onDestroy()
{
_listenThread.interrupt();
_listenThread = null;
super.onDestroy();
}
private void playAlert()
{
final MediaPlayer mp = MediaPlayer.create(this, R.raw.upward_beep_chromatic_fifths);
if(mp != null)
{
Log.i(TAG, "Playing alert");
mp.setOnCompletionListener(new MediaPlayer.OnCompletionListener()
{
@Override
public void onCompletion(MediaPlayer mp)
{
mp.release();
}
});
mp.start();
}
else
{
Log.e(TAG, "Failed to play alert");
}
}
}

View File

@@ -0,0 +1,308 @@
/**
* This file is part of the Protect Baby Monitor.
*
* Protect Baby Monitor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Protect Baby Monitor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Protect Baby Monitor. If not, see <http://www.gnu.org/licenses/>.
*/
package protect.babymonitor;
import java.io.IOException;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;
import android.app.Activity;
import android.content.Context;
import android.media.AudioFormat;
import android.media.AudioRecord;
import android.media.MediaRecorder;
import android.net.nsd.NsdManager;
import android.net.nsd.NsdServiceInfo;
import android.net.wifi.WifiInfo;
import android.net.wifi.WifiManager;
import android.os.Bundle;
import android.text.format.Formatter;
import android.util.Log;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.TextView;
public class MonitorActivity extends Activity
{
final String TAG = "BabyMonitor";
NsdManager _nsdManager;
NsdManager.RegistrationListener _registrationListener;
Thread _serviceThread;
private void serviceConnection(Socket socket) throws IOException
{
MonitorActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
final TextView statusText = (TextView) findViewById(R.id.textStatus);
statusText.setText(R.string.streaming);
}
});
final int frequency = 11025;
final int channelConfiguration = AudioFormat.CHANNEL_IN_MONO;
final int audioEncoding = AudioFormat.ENCODING_PCM_16BIT;
final int bufferSize = AudioRecord.getMinBufferSize(frequency, channelConfiguration, audioEncoding);
final AudioRecord audioRecord = new AudioRecord(MediaRecorder.AudioSource.MIC,
frequency, channelConfiguration,
audioEncoding, bufferSize);
final int byteBufferSize = bufferSize*2;
final byte[] buffer = new byte[byteBufferSize];
try
{
audioRecord.startRecording();
final OutputStream out = socket.getOutputStream();
socket.setSendBufferSize(byteBufferSize);
Log.d(TAG, "Socket send buffer size: " + socket.getSendBufferSize());
while (socket.isConnected() && Thread.currentThread().isInterrupted() == false)
{
final int read = audioRecord.read(buffer, 0, bufferSize);
out.write(buffer, 0, read);
}
}
finally
{
audioRecord.stop();
}
}
@Override
protected void onCreate(Bundle savedInstanceState)
{
Log.i(TAG, "Baby monitor start");
_nsdManager = (NsdManager)this.getSystemService(Context.NSD_SERVICE);
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_monitor);
_serviceThread = new Thread(new Runnable()
{
@Override
public void run()
{
while(Thread.currentThread().isInterrupted() == false)
{
ServerSocket serverSocket = null;
try
{
// Initialize a server socket on the next available port.
serverSocket = new ServerSocket(0);
// Store the chosen port.
final int localPort = serverSocket.getLocalPort();
// Register the service so that parent devices can
// locate the child device
registerService(localPort);
// Wait for a parent to find us and connect
Socket socket = serverSocket.accept();
Log.i(TAG, "Connection from parent device received");
// We now have a client connection.
// Unregister so no other clients will
// attempt to connect
serverSocket.close();
serverSocket = null;
unregisterService();
try
{
serviceConnection(socket);
}
finally
{
socket.close();
}
}
catch(IOException e)
{
Log.e(TAG, "Connection failed", e);
}
// If an exception was thrown before the connection
// could be closed, clean it up
if(serverSocket != null)
{
try
{
serverSocket.close();
}
catch (IOException e)
{
Log.e(TAG, "Failed to close stray connection", e);
}
serverSocket = null;
}
}
}
});
_serviceThread.start();
MonitorActivity.this.runOnUiThread(new Runnable()
{
@Override
public void run()
{
final TextView addressText = (TextView) findViewById(R.id.address);
final WifiManager wifiManager = (WifiManager) getSystemService(WIFI_SERVICE);
final WifiInfo info = wifiManager.getConnectionInfo();
final int address = info.getIpAddress();
if(address != 0)
{
@SuppressWarnings("deprecation")
final String ipAddress = Formatter.formatIpAddress(address);
addressText.setText(ipAddress);
}
else
{
addressText.setText(R.string.wifiNotConnected);
}
}
});
}
@Override
protected void onDestroy()
{
Log.i(TAG, "Baby monitor stop");
unregisterService();
if(_serviceThread != null)
{
_serviceThread.interrupt();
_serviceThread = null;
}
super.onDestroy();
}
@Override
public boolean onCreateOptionsMenu(Menu menu)
{
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.start, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item)
{
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}
private void registerService(final int port)
{
final NsdServiceInfo serviceInfo = new NsdServiceInfo();
serviceInfo.setServiceName("ProtectBabyMonitor");
serviceInfo.setServiceType("_babymonitor._tcp.");
serviceInfo.setPort(port);
_registrationListener = new NsdManager.RegistrationListener()
{
@Override
public void onServiceRegistered(NsdServiceInfo nsdServiceInfo) {
// Save the service name. Android may have changed it in order to
// resolve a conflict, so update the name you initially requested
// with the name Android actually used.
final String serviceName = nsdServiceInfo.getServiceName();
Log.i(TAG, "Service name: " + serviceName);
MonitorActivity.this.runOnUiThread(new Runnable() {
@Override
public void run()
{
final TextView statusText = (TextView) findViewById(R.id.textStatus);
statusText.setText(R.string.waitingForParent);
final TextView serviceText = (TextView) findViewById(R.id.textService);
serviceText.setText(serviceName);
final TextView portText = (TextView) findViewById(R.id.port);
portText.setText(Integer.toString(port));
}
});
}
@Override
public void onRegistrationFailed(NsdServiceInfo serviceInfo, int errorCode)
{
// Registration failed! Put debugging code here to determine why.
Log.e(TAG, "Registration failed: " + errorCode);
}
@Override
public void onServiceUnregistered(NsdServiceInfo arg0)
{
// Service has been unregistered. This only happens when you call
// NsdManager.unregisterService() and pass in this listener.
Log.i(TAG, "Unregistering service");
}
@Override
public void onUnregistrationFailed(NsdServiceInfo serviceInfo, int errorCode)
{
// Unregistration failed. Put debugging code here to determine why.
Log.e(TAG, "Unregistration failed: " + errorCode);
}
};
_nsdManager.registerService(
serviceInfo, NsdManager.PROTOCOL_DNS_SD, _registrationListener);
}
/**
* Uhregistered the service and assigns the listener
* to null.
*/
private void unregisterService()
{
if(_registrationListener != null)
{
Log.i(TAG, "Unregistering monitoring service");
_nsdManager.unregisterService(_registrationListener);
_registrationListener = null;
}
}
}

View File

@@ -0,0 +1,64 @@
/**
* This file is part of the Protect Baby Monitor.
*
* Protect Baby Monitor is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Protect Baby Monitor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Protect Baby Monitor. If not, see <http://www.gnu.org/licenses/>.
*/
package protect.babymonitor;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
public class StartActivity extends Activity
{
final String TAG = "BabyMonitor";
@Override
protected void onCreate(Bundle savedInstanceState)
{
Log.i(TAG, "Baby monitor launched");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start);
final Button monitorButton = (Button) findViewById(R.id.useChildDevice);
monitorButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Log.i(TAG, "Starting up monitor");
Intent i = new Intent(getApplicationContext(), MonitorActivity.class);
startActivity(i);
}
});
final Button connectButton = (Button) findViewById(R.id.useParentDevice);
connectButton.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
Log.i(TAG, "Starting connection activity");
Intent i = new Intent(getApplicationContext(), DiscoverActivity.class);
startActivity(i);
}
});
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

View File

@@ -0,0 +1,59 @@
<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" />
<Button
android:id="@+id/discoverChildButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
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" />
<Button
android:id="@+id/enterChildAddressButton"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/enterChildAddress"
android:textSize="17sp" />
<TextView
android:id="@+id/enterChildAddressDescription"
android:layout_width="match_parent"
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

@@ -0,0 +1,58 @@
<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:keepScreenOn="true"
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/connectedToTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/connectedTo"
android:textSize="20sp" />
<TextView
android:id="@+id/connectedTo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="20sp" />
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/status"
android:textSize="20sp" />
<TextView
android:id="@+id/textStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="20sp" />
</LinearLayout>

View File

@@ -0,0 +1,95 @@
<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"
android:keepScreenOn="true"
tools:context="protect.babymonitor.MonitorActivity" >
<TextView
android:id="@+id/childDeviceTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/childDevice"
android:textSize="25sp" />
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<TextView
android:id="@+id/serviceTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/serviceTitle"
android:textSize="20sp" />
<TextView
android:id="@+id/textService"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/loading"
android:textSize="20sp" />
<TextView
android:id="@+id/serviceDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/serviceDescription" />
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<TextView
android:id="@+id/addressTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/addressTitle"
android:textSize="20sp" />
<TextView
android:id="@+id/address"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="20sp"/>
<TextView
android:id="@+id/portTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/portTitle"
android:textSize="20sp" />
<TextView
android:id="@+id/port"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/loading"
android:textSize="20sp"/>
<TextView
android:id="@+id/addressDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/addressDescription" />
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<TextView
android:id="@+id/textStatus"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="20sp" />
</LinearLayout>

View File

@@ -0,0 +1,46 @@
<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.StartActivity" >
<Button
android:id="@+id/useChildDevice"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/useAsChildDevice"
android:textSize="17sp" />
<TextView
android:id="@+id/childDescription"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/childDescription"
android:textSize="14sp" />
<Space
android:layout_width="match_parent"
android:layout_height="15dip" />
<Button
android:id="@+id/useParentDevice"
style="?android:attr/buttonStyleSmall"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/useAsParentDevice"
android:textSize="17sp" />
<TextView
android:id="@+id/parentDescription"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/parentDescription" />
</LinearLayout>

View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/availableChildrenList"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceListItemSmall"
android:gravity="center_vertical"
android:paddingStart="?android:attr/listPreferredItemPaddingStart"
android:paddingEnd="?android:attr/listPreferredItemPaddingEnd"
android:minHeight="?android:attr/listPreferredItemHeightSmall" />

View File

@@ -0,0 +1,11 @@
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="gpl.babymonitor.StartActivity" >
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
</menu>

Binary file not shown.

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">安全ベビー モニター</string>
<string name="action_settings">設定</string>
<string name="useAsParentDevice">親機として使用する</string>
<string name="useAsChildDevice">子機として使用する</string>
<string name="childDescription">端末をベビーの横に置くと、音声が親機に送られます</string>
<string name="parentDescription">子機とペアにして、受信した音声を再生します</string>
<string name="childDevice">子機</string>
<string name="serviceTitle">サービス:</string>
<string name="serviceDescription">親機がペアにするサービスの名前</string>
<string name="loading">読み込み中...</string>
<string name="stopped">停止しました</string>
<string name="streaming">ストリーム中...</string>
<string name="waitingForParent">親機を待機中...</string>
<string name="parentDevice">親機</string>
<string name="selectChildDevice">子機を選択:</string>
<string name="status">ステータス:</string>
<string name="connectedTo">接続しました:</string>
<string name="disconnected">切断しました</string>
<string name="listening">リスニング中...</string>
<string name="addressTitle">アドレス:</string>
<string name="portTitle">ポート:</string>
<string name="addressDescription">親機がペアにする先のアドレスとポート</string>
<string name="wifiNotConnected">Wi-Fi ネットワークに接続されていません</string>
<string name="enterAddressInstructions">子機の IP アドレスとポートを入力して、接続をクリックしてください</string>
<string name="connect">接続</string>
<string name="exampleAddress">192.168.1.2</string>
<string name="examplePort">10000</string>
<string name="invalidPort">ポートが入力されていないか正しくありません</string>
<string name="invalidAddress">アドレスフィールドを入力してください</string>
<string name="discoverChild">ネットワークで子機を探索</string>
<string name="discoverChildDescription">ネットワークで検出した子機を選択します</string>
<string name="enterChildAddress">子機をアドレスで選択</string>
<string name="enterChildAddressDescription">子機のアドレスとポートを入力します</string>
</resources>

View File

@@ -0,0 +1,11 @@
<resources>
<!--
Base application theme for API 11+. This theme completely replaces
AppBaseTheme from res/values/styles.xml on API 11+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light">
<!-- API 11 theme customizations can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,12 @@
<resources>
<!--
Base application theme for API 14+. This theme completely replaces
AppBaseTheme from BOTH res/values/styles.xml and
res/values-v11/styles.xml on API 14+ devices.
-->
<style name="AppBaseTheme" parent="android:Theme.Holo.Light.DarkActionBar">
<!-- API 14 theme customizations can go here. -->
</style>
</resources>

View File

@@ -0,0 +1,10 @@
<resources>
<!--
Example customization of dimensions originally defined in res/values/dimens.xml
(such as screen margins) for screens with more than 820dp of available width. This
would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively).
-->
<dimen name="activity_horizontal_margin">64dp</dimen>
</resources>

View File

@@ -0,0 +1,7 @@
<resources>
<!-- Default screen margins, per the Android Design guidelines. -->
<dimen name="activity_horizontal_margin">16dp</dimen>
<dimen name="activity_vertical_margin">16dp</dimen>
</resources>

View File

@@ -0,0 +1,37 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">Protect Baby Monitor</string>
<string name="action_settings">Settings</string>
<string name="useAsParentDevice">Use as Parent Device</string>
<string name="useAsChildDevice">Use as Child Device</string>
<string name="childDescription">Device is placed with baby, and sends audio to a paired parent device</string>
<string name="parentDescription">Pairs with child device and plays received audio</string>
<string name="childDevice">Child Device</string>
<string name="serviceTitle">Service:</string>
<string name="serviceDescription">Name of the service that parent must pair to</string>
<string name="loading">Loading...</string>
<string name="stopped">Stopped</string>
<string name="streaming">Streaming...</string>
<string name="waitingForParent">Waiting for Parent...</string>
<string name="parentDevice">Parent Device</string>
<string name="selectChildDevice">Select Child Device:</string>
<string name="status">Status:</string>
<string name="connectedTo">Connected To:</string>
<string name="disconnected">Disconnected</string>
<string name="listening">Listening...</string>
<string name="addressTitle">Address:</string>
<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="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>

View File

@@ -0,0 +1,10 @@
<resources>
<!--
Base application theme, dependent on API level. This theme is replaced
by AppBaseTheme from res/values-vXX/styles.xml on newer devices.
-->
<!-- Application theme. -->
</resources>