From 367fe94dc6d4cae7d9b8e2239ebfc04ad23484b8 Mon Sep 17 00:00:00 2001 From: Brion Vibber Date: Mon, 2 Aug 2010 12:30:53 -0700 Subject: [PATCH] Disable "Ok" button on Add Channel, Add Command dialogs until something's actually been added or removed. I found myself hitting "ok" *before* "add" about four times before I figured out why it never worked. :) --- src/org/yaaic/activity/AddChannelActivity.java | 10 ++++++++-- src/org/yaaic/activity/AddCommandsActivity.java | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/org/yaaic/activity/AddChannelActivity.java b/src/org/yaaic/activity/AddChannelActivity.java index 8ad50a3..975d878 100644 --- a/src/org/yaaic/activity/AddChannelActivity.java +++ b/src/org/yaaic/activity/AddChannelActivity.java @@ -50,6 +50,7 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI private EditText channelInput; private ArrayAdapter adapter; private ArrayList channels; + private Button okButton; /** * On create @@ -71,9 +72,12 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI list.setOnItemClickListener(this); ((Button) findViewById(R.id.add)).setOnClickListener(this); - ((Button) findViewById(R.id.ok)).setOnClickListener(this); ((Button) findViewById(R.id.cancel)).setOnClickListener(this); - + + okButton = (Button) findViewById(R.id.ok); + okButton.setOnClickListener(this); + okButton.setEnabled(false); + channels = getIntent().getExtras().getStringArrayList(Extra.CHANNELS); for (String channel : channels) { @@ -92,6 +96,7 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI channels.add(channel); adapter.add(channel); channelInput.setText("#"); + okButton.setEnabled(true); break; case R.id.cancel: setResult(RESULT_CANCELED); @@ -124,6 +129,7 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI case 0: // Remove adapter.remove(channel); channels.remove(channel); + okButton.setEnabled(true); break; } } diff --git a/src/org/yaaic/activity/AddCommandsActivity.java b/src/org/yaaic/activity/AddCommandsActivity.java index aabf344..c497a80 100644 --- a/src/org/yaaic/activity/AddCommandsActivity.java +++ b/src/org/yaaic/activity/AddCommandsActivity.java @@ -52,6 +52,7 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On private EditText commandInput; private ArrayAdapter adapter; private ArrayList commands; + private Button okButton; /** * On create @@ -75,6 +76,10 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On ((Button) findViewById(R.id.add)).setOnClickListener(this); ((Button) findViewById(R.id.ok)).setOnClickListener(this); ((Button) findViewById(R.id.cancel)).setOnClickListener(this); + + okButton = (Button) findViewById(R.id.ok); + okButton.setOnClickListener(this); + okButton.setEnabled(false); commands = getIntent().getExtras().getStringArrayList(Extra.COMMANDS); @@ -106,6 +111,7 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On commands.add("/" + command); adapter.add("/" + command); commandInput.setText("/"); + okButton.setEnabled(true); break; case R.id.cancel: setResult(RESULT_CANCELED); @@ -138,6 +144,7 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On case 0: // Remove adapter.remove(command); commands.remove(command); + okButton.setEnabled(true); break; } }