1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-08-13 16:53:50 -04:00

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. :)

This commit is contained in:
Brion Vibber 2010-08-02 12:30:53 -07:00
parent 4f7bdfe9bc
commit 367fe94dc6
2 changed files with 15 additions and 2 deletions

View File

@ -50,6 +50,7 @@ public class AddChannelActivity extends Activity implements OnClickListener, OnI
private EditText channelInput;
private ArrayAdapter<String> adapter;
private ArrayList<String> 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;
}
}

View File

@ -52,6 +52,7 @@ public class AddCommandsActivity extends Activity implements OnClickListener, On
private EditText commandInput;
private ArrayAdapter<String> adapter;
private ArrayList<String> 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;
}
}