diff options
author | Nathan Lasseter <nathan@4574.co.uk> | 2013-05-25 11:06:51 +0100 |
---|---|---|
committer | Nathan Lasseter <nathan@4574.co.uk> | 2013-05-25 11:06:51 +0100 |
commit | c64b98512ebccec28063b8da387e9ac4051f9878 (patch) | |
tree | 9e248de908adcc1804858adeb1e83ff21e1bb73d | |
parent | dd525d0d032ef28e1eab0a8d89e32eb5e72654bb (diff) |
-rw-r--r-- | res/layout/start.xml | 5 | ||||
-rw-r--r-- | src/user4574/texttransport/Start.java | 24 |
2 files changed, 24 insertions, 5 deletions
diff --git a/res/layout/start.xml b/res/layout/start.xml index 0168774..47305f3 100644 --- a/res/layout/start.xml +++ b/res/layout/start.xml @@ -57,11 +57,12 @@ <Button android:id="@+id/connectbutton" - android:layout_width="wrap_content" + android:layout_width="fill_parent" android:layout_height="wrap_content" android:layout_alignParentLeft="true" android:layout_below="@+id/port" - android:text="@string/connect" /> + android:text="@string/connect" + android:textSize="24sp" /> <EditText android:id="@+id/username" diff --git a/src/user4574/texttransport/Start.java b/src/user4574/texttransport/Start.java index 8f93bd9..ec06f98 100644 --- a/src/user4574/texttransport/Start.java +++ b/src/user4574/texttransport/Start.java @@ -1,5 +1,7 @@ package user4574.texttransport; +import java.util.ArrayList; + import org.eclipse.paho.client.mqttv3.MqttClient; import org.eclipse.paho.client.mqttv3.MqttConnectOptions; import org.eclipse.paho.client.mqttv3.MqttException; @@ -21,6 +23,8 @@ public class Start extends Activity { private MqttConnectOptions opts; private SmsManager sms = SmsManager.getDefault(); + private ArrayList<View> inputs; + private Button conn; private EditText ent; private EditText port; @@ -33,6 +37,8 @@ public class Start extends Activity { super.onCreate(savedInstanceState); setContentView(R.layout.start); + inputs = new ArrayList<View>(); + conn = (Button) findViewById(R.id.connectbutton); conn.setEnabled(false); conn.setOnClickListener(new ConnectListener()); @@ -46,12 +52,24 @@ public class Start extends Activity { un = (EditText) findViewById(R.id.username); pw = (EditText) findViewById(R.id.password); + + inputs.add(findViewById(R.id.uri)); + inputs.add(findViewById(R.id.port)); + inputs.add(findViewById(R.id.tcp)); + inputs.add(findViewById(R.id.ssl)); + inputs.add(findViewById(R.id.username)); + inputs.add(findViewById(R.id.password)); + } + + private void setInputsEnabled(boolean enabled) { + for (View v : inputs) + v.setEnabled(enabled); } protected void onResume() { super.onResume(); if (client == null || !client.isConnected()) { - ent.setEnabled(true); + setInputsEnabled(true); ent.setText(""); } } @@ -61,7 +79,7 @@ public class Start extends Activity { if (client != null && client.isConnected()) { try { client.disconnect(); - ent.setEnabled(true); + setInputsEnabled(true); conn.setText(R.string.connect); } catch (MqttException e) { e.printStackTrace(); @@ -83,7 +101,7 @@ public class Start extends Activity { } else client.connect(); client.subscribe("/texttransport/+/send"); - ent.setEnabled(false); + setInputsEnabled(false); conn.setText(R.string.disconnect); } catch (MqttException e) { e.printStackTrace(); |