mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-12-02 05:42:17 -05:00
AddServerActivity: Added "Commands" button -> Launch AddCommandsActivity
This commit is contained in:
parent
80262d93e7
commit
39824aeb00
@ -143,6 +143,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:layout_width="fill_parent"
|
android:layout_width="fill_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:text="Channels" />
|
android:text="Channels" />
|
||||||
|
<Button
|
||||||
|
android:id="@+id/commands"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:text="Commands" />
|
||||||
<!-- ############################################################################ -->
|
<!-- ############################################################################ -->
|
||||||
<TextView
|
<TextView
|
||||||
android:text="Preferences"
|
android:text="Preferences"
|
||||||
|
@ -53,8 +53,12 @@ import org.yaaic.model.Status;
|
|||||||
*/
|
*/
|
||||||
public class AddServerActivity extends Activity implements OnClickListener
|
public class AddServerActivity extends Activity implements OnClickListener
|
||||||
{
|
{
|
||||||
|
private static final int REQUEST_CODE_CHANNELS = 1;
|
||||||
|
private static final int REQUEST_CODE_COMMANDS = 2;
|
||||||
|
|
||||||
private Server server;
|
private Server server;
|
||||||
private ArrayList<String> channels;
|
private ArrayList<String> channels;
|
||||||
|
private ArrayList<String> commands;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
@ -66,9 +70,12 @@ public class AddServerActivity extends Activity implements OnClickListener
|
|||||||
|
|
||||||
setContentView(R.layout.serveradd);
|
setContentView(R.layout.serveradd);
|
||||||
channels = new ArrayList<String>();
|
channels = new ArrayList<String>();
|
||||||
|
commands = new ArrayList<String>();
|
||||||
|
|
||||||
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
((Button) findViewById(R.id.add)).setOnClickListener(this);
|
||||||
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
((Button) findViewById(R.id.cancel)).setOnClickListener(this);
|
||||||
|
((Button) findViewById(R.id.channels)).setOnClickListener(this);
|
||||||
|
((Button) findViewById(R.id.commands)).setOnClickListener(this);
|
||||||
|
|
||||||
Spinner spinner = (Spinner) findViewById(R.id.charset);
|
Spinner spinner = (Spinner) findViewById(R.id.charset);
|
||||||
String[] charsets = getResources().getStringArray(R.array.charsets);
|
String[] charsets = getResources().getStringArray(R.array.charsets);
|
||||||
@ -76,14 +83,13 @@ public class AddServerActivity extends Activity implements OnClickListener
|
|||||||
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
||||||
spinner.setAdapter(adapter);
|
spinner.setAdapter(adapter);
|
||||||
|
|
||||||
((Button) findViewById(R.id.channels)).setOnClickListener(this);
|
|
||||||
|
|
||||||
Bundle extras = getIntent().getExtras();
|
Bundle extras = getIntent().getExtras();
|
||||||
if (extras != null && extras.containsKey(Extra.SERVER)) {
|
if (extras != null && extras.containsKey(Extra.SERVER)) {
|
||||||
// Request to edit an existing server
|
// Request to edit an existing server
|
||||||
Database db = new Database(this);
|
Database db = new Database(this);
|
||||||
this.server = db.getServerById(extras.getInt(Extra.SERVER));
|
this.server = db.getServerById(extras.getInt(Extra.SERVER));
|
||||||
this.channels = db.getChannelsByServerId(server.getId());
|
this.channels = db.getChannelsByServerId(server.getId());
|
||||||
|
this.commands = db.getCommandsByServerId(server.getId());
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
// Set server values
|
// Set server values
|
||||||
@ -127,8 +133,17 @@ public class AddServerActivity extends Activity implements OnClickListener
|
|||||||
@Override
|
@Override
|
||||||
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
protected void onActivityResult(int requestCode, int resultCode, Intent data)
|
||||||
{
|
{
|
||||||
if (resultCode == RESULT_OK) {
|
if (resultCode != RESULT_OK) {
|
||||||
|
return; // ignore everything else
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (requestCode) {
|
||||||
|
case REQUEST_CODE_CHANNELS:
|
||||||
channels = data.getExtras().getStringArrayList(Extra.CHANNELS);
|
channels = data.getExtras().getStringArrayList(Extra.CHANNELS);
|
||||||
|
break;
|
||||||
|
case REQUEST_CODE_COMMANDS:
|
||||||
|
commands = data.getExtras().getStringArrayList(Extra.COMMANDS);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,9 +154,14 @@ public class AddServerActivity extends Activity implements OnClickListener
|
|||||||
{
|
{
|
||||||
switch (v.getId()) {
|
switch (v.getId()) {
|
||||||
case R.id.channels:
|
case R.id.channels:
|
||||||
Intent intent = new Intent(this, AddChannelActivity.class);
|
Intent channelIntent = new Intent(this, AddChannelActivity.class);
|
||||||
intent.putExtra(Extra.CHANNELS, channels);
|
channelIntent.putExtra(Extra.CHANNELS, channels);
|
||||||
startActivityForResult(intent, 0);
|
startActivityForResult(channelIntent, REQUEST_CODE_CHANNELS);
|
||||||
|
break;
|
||||||
|
case R.id.commands:
|
||||||
|
Intent commandsIntent = new Intent(this, AddCommandsActivity.class);
|
||||||
|
commandsIntent.putExtra(Extra.COMMANDS, commands);
|
||||||
|
startActivityForResult(commandsIntent, REQUEST_CODE_COMMANDS);
|
||||||
break;
|
break;
|
||||||
case R.id.add:
|
case R.id.add:
|
||||||
try {
|
try {
|
||||||
@ -192,6 +212,7 @@ public class AddServerActivity extends Activity implements OnClickListener
|
|||||||
);
|
);
|
||||||
|
|
||||||
db.setChannels((int) serverId, channels);
|
db.setChannels((int) serverId, channels);
|
||||||
|
db.setCommands((int) serverId, commands);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
@ -234,6 +255,7 @@ public class AddServerActivity extends Activity implements OnClickListener
|
|||||||
);
|
);
|
||||||
|
|
||||||
db.setChannels(serverId, channels);
|
db.setChannels(serverId, channels);
|
||||||
|
db.setCommands(serverId, commands);
|
||||||
|
|
||||||
db.close();
|
db.close();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user