Skip to content
This repository has been archived by the owner on Aug 11, 2024. It is now read-only.

Commit

Permalink
3609874 - Added a new server port input field so that different port …
Browse files Browse the repository at this point in the history
…numbers can be specified rather than just the default of port 24800
  • Loading branch information
mcombell committed Apr 3, 2013
1 parent cdd1758 commit a65ad65
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 13 deletions.
10 changes: 6 additions & 4 deletions gen/org/synergy/R.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,14 @@ public static final class drawable {
public static final class id {
public static final int clientNameEditText=0x7f050001;
public static final int clientNameTextView=0x7f050000;
public static final int connectButton=0x7f050006;
public static final int inputDeviceEditText=0x7f050005;
public static final int inputDeviceTextView=0x7f050004;
public static final int outputEditText=0x7f050007;
public static final int connectButton=0x7f050008;
public static final int inputDeviceEditText=0x7f050007;
public static final int inputDeviceTextView=0x7f050006;
public static final int outputEditText=0x7f050009;
public static final int serverHostEditText=0x7f050003;
public static final int serverHostTextView=0x7f050002;
public static final int serverPortEditText=0x7f050005;
public static final int serverPortTextView=0x7f050004;
}
public static final class layout {
public static final int main=0x7f030000;
Expand Down
19 changes: 16 additions & 3 deletions res/layout/main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,24 @@
android:layout_below="@id/serverHostTextView"
android:id="@+id/serverHostEditText"/>

<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Server Port:"
android:layout_below="@id/serverHostEditText"
android:id="@+id/serverPortTextView"/>

<EditText android:id="@+id/serverPortEditText"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="@id/serverPortTextView"
android:background="@android:drawable/editbox_background"
android:inputType="number"
android:text="24800" />

<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Input device name:"
android:layout_below="@+id/serverHostEditText"
android:layout_below="@+id/serverPortEditText"
android:id="@+id/inputDeviceTextView"/>

<EditText android:layout_width="fill_parent"
Expand Down Expand Up @@ -70,8 +84,7 @@
<!-- </LinearLayout>-->
<!--</TabHost>-->
<!-- -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@id/connectButton">

Expand Down
4 changes: 3 additions & 1 deletion src/org/synergy/Synergy.java
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,8 @@ private void connect () {

String clientName = ((EditText) findViewById (R.id.clientNameEditText)).getText().toString();
String ipAddress = ((EditText) findViewById (R.id.serverHostEditText)).getText().toString();
String portStr = ((EditText) findViewById(R.id.serverPortEditText)).getText().toString();
int port = Integer.parseInt(portStr);
String deviceName = ((EditText) findViewById(R.id.inputDeviceEditText)).getText().toString();

SharedPreferences preferences = getPreferences(MODE_PRIVATE);
Expand All @@ -124,7 +126,7 @@ private void connect () {

try {
SocketFactoryInterface socketFactory = new TCPSocketFactory();
NetworkAddress serverAddress = new NetworkAddress (ipAddress, 24800);
NetworkAddress serverAddress = new NetworkAddress (ipAddress, port);
serverAddress.resolve ();

Injection.startInjection(deviceName);
Expand Down
11 changes: 6 additions & 5 deletions src/org/synergy/client/Client.java
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,14 @@ public void connect () {

socket.connect (serverAddress);

final Toast toast = Toast.makeText(context, "Connected to " + serverAddress.getHostname(),
Toast.LENGTH_SHORT);
final Toast toast = Toast.makeText(context, "Connected to " + serverAddress.getHostname()
+ ":" + serverAddress.getPort(), Toast.LENGTH_SHORT);
toast.show();
} catch (IOException e) {
Log.error("Failed to connect to " + serverAddress.getHostname());
final Toast toast = Toast.makeText(context, "Failed to connect to " + serverAddress.getHostname(),
Toast.LENGTH_SHORT);
final String errorMessage = "Failed to connect to " + serverAddress.getHostname()
+ ":" + serverAddress.getPort();
Log.error(errorMessage);
final Toast toast = Toast.makeText(context, errorMessage, Toast.LENGTH_SHORT);
toast.show();
}
}
Expand Down

0 comments on commit a65ad65

Please sign in to comment.