Kaydet (Commit) 9f8cd15b authored tarafından Andrzej J.R. Hunt's avatar Andrzej J.R. Hunt

Add icons + device name display to pairing activity.

Change-Id: If27119e3e62bac8046fcc33cb12767b116bcc991
üst 9b0b15ee
...@@ -26,12 +26,14 @@ ...@@ -26,12 +26,14 @@
<category android:name="android.intent.category.LAUNCHER" /> <category android:name="android.intent.category.LAUNCHER" />
</intent-filter> </intent-filter>
</activity> </activity>
<activity
android:name=".PairingActivity"
android:icon="@drawable/actionbar_icon_computer" >
</activity>
<service android:name=".communication.CommunicationService" > <service android:name=".communication.CommunicationService" >
</service> </service>
<activity android:name=".PairingActivity" >
</activity>
<activity android:name=".StartPresentationActivity" > <activity android:name=".StartPresentationActivity" >
</activity> </activity>
<activity <activity
......
...@@ -44,6 +44,8 @@ public class PairingActivity extends SherlockActivity { ...@@ -44,6 +44,8 @@ public class PairingActivity extends SherlockActivity {
LocalBroadcastManager.getInstance(this).registerReceiver(mListener, LocalBroadcastManager.getInstance(this).registerReceiver(mListener,
aFilter); aFilter);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
} }
@Override @Override
...@@ -69,6 +71,8 @@ public class PairingActivity extends SherlockActivity { ...@@ -69,6 +71,8 @@ public class PairingActivity extends SherlockActivity {
if (mCommunicationService.getState() == State.CONNECTING) { if (mCommunicationService.getState() == State.CONNECTING) {
mPinText.setText(mCommunicationService.getPairingPin()); mPinText.setText(mCommunicationService.getPairingPin());
getSupportActionBar().setTitle(
mCommunicationService.getPairingDeviceName());
} }
} }
...@@ -91,6 +95,10 @@ public class PairingActivity extends SherlockActivity { ...@@ -91,6 +95,10 @@ public class PairingActivity extends SherlockActivity {
String aPin = aIntent.getStringExtra("PIN"); String aPin = aIntent.getStringExtra("PIN");
mPinText.setText(aPin); mPinText.setText(aPin);
if (mCommunicationService != null)
getSupportActionBar().setTitle(
mCommunicationService
.getPairingDeviceName());
// refreshLists(); // refreshLists();
} else if (aIntent.getAction().equals( } else if (aIntent.getAction().equals(
CommunicationService.MSG_PAIRING_SUCCESSFUL)) { CommunicationService.MSG_PAIRING_SUCCESSFUL)) {
......
...@@ -33,6 +33,7 @@ public abstract class Client { ...@@ -33,6 +33,7 @@ public abstract class Client {
protected BufferedReader mReader; protected BufferedReader mReader;
protected OutputStream mOutputStream; protected OutputStream mOutputStream;
protected String mPin = ""; protected String mPin = "";
protected String mName = "";
private static Client latestInstance = null; private static Client latestInstance = null;
...@@ -108,6 +109,14 @@ public abstract class Client { ...@@ -108,6 +109,14 @@ public abstract class Client {
} }
} }
public static String getName() {
if (latestInstance != null) {
return latestInstance.mName;
} else {
return "";
}
}
/** /**
* Send a valid command to the Server. * Send a valid command to the Server.
*/ */
......
...@@ -59,6 +59,10 @@ public class CommunicationService extends Service implements Runnable { ...@@ -59,6 +59,10 @@ public class CommunicationService extends Service implements Runnable {
return Client.getPin(); return Client.getPin();
} }
public String getPairingDeviceName() {
return Client.getName();
}
private State mStateDesired = State.DISCONNECTED; private State mStateDesired = State.DISCONNECTED;
private Server mServerDesired = null; private Server mServerDesired = null;
......
...@@ -35,6 +35,7 @@ public class NetworkClient extends Client { ...@@ -35,6 +35,7 @@ public class NetworkClient extends Client {
CommunicationService aCommunicationService) { CommunicationService aCommunicationService) {
super(aServer, aCommunicationService); super(aServer, aCommunicationService);
try { try {
mName = aServer.getName();
mSocket = new Socket(aServer.getAddress(), PORT); mSocket = new Socket(aServer.getAddress(), PORT);
mInputStream = mSocket.getInputStream(); mInputStream = mSocket.getInputStream();
mReader = new BufferedReader(new InputStreamReader(mInputStream, mReader = new BufferedReader(new InputStreamReader(mInputStream,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment