Commits

Thomas Amberg committed d71384b Merge

Merged

Comments (0)

Files changed (3)

2011/SmsService/res/layout/main.xml

                 
                 <!-- android:contentDescription="Host for the yaler" -->
                 <EditText
-                    android:id="@+id/editTextHost"
+                    android:id="@+id/editTextRelayHost"
                     android:hint="try.yaler.net"
                     android:layout_width="139dp"
                     android:layout_height="wrap_content"
                     android:textAppearance="?android:attr/textAppearanceMedium" />
 
                 <EditText
-                    android:id="@+id/editTextPort"
+                    android:id="@+id/editTextRelayPort"
                     android:layout_width="112dp"
                     android:layout_height="wrap_content"
                     android:layout_weight="50.18"

2011/SmsService/src/org/rhok/zurich/smsservice/SmsMessaging.java

 import android.util.Log;
 import android.view.View;
 import android.widget.Button;
+import android.widget.TextView;
 import android.widget.Toast;
 
 public class SmsMessaging extends Activity {
+	private static final String PACKAGE = "org.rhok.zurich.smsservice.";
 	private Button btnSendSMS;
 	private View startSmsServiceButton;
 
 	private void startSmsService() {
 		Log.v("SmsService", "starting sms service");
 		Intent smsServiceIntent = new Intent(this, SmsService.class);
+
+		TextView editTextRelayHost = (TextView) findViewById(R.id.editTextRelayHost);
+		String relayHost = editTextRelayHost.getText().toString();
+		TextView editTextRelayPort = (TextView) findViewById(R.id.editTextRelayPort);
+		String relayPort = editTextRelayPort.getText().toString();
+		TextView editTextRelayDomain = (TextView) findViewById(R.id.editTextRelayDomain);
+		String relayDomain = editTextRelayDomain.getText().toString();
+
+		smsServiceIntent.putExtra(PACKAGE + "RelayHost", relayHost);
+		smsServiceIntent.putExtra(PACKAGE + "RelayPort", relayPort);
+		smsServiceIntent.putExtra(PACKAGE + "RelayDomain", relayDomain);
+
 		startService(smsServiceIntent);
 	}
 

2011/SmsService/src/org/rhok/zurich/smsservice/SmsService.java

 	public int onStartCommand(Intent i, int flags, int startId) {
 		Log.v("SmsService", "onStartCommand");
 		final boolean relay = true;
-		final String YALER_HOST = "try.yaler.net";
-		final String RELAY_DOMAIN = "sms-service";
+		final String YALER_HOST_DEFAULT = "try.yaler.net";
+		final String RELAY_DOMAIN_DEFAULT = "sms-service";
+
+		// TextView editText = (TextView) findViewById(R.id.editTextRelayHost);
+		// String relayHost = editText.getText().toString();
+
 		new Thread(new Runnable() {
 			public void run() {
 				try {
 					}
 					while (true) {
 						try {
-							Socket s = relay ? accept(YALER_HOST, 8081, RELAY_DOMAIN) : listener.accept();
+							Socket s = relay ? accept(YALER_HOST_DEFAULT, 8081, RELAY_DOMAIN_DEFAULT)
+									: listener.accept();
 							InputStream is = s.getInputStream();
 							OutputStream os = s.getOutputStream();
 							handleRequest(is, os);