1
0
mirror of https://github.com/moparisthebest/Yaaic synced 2024-11-22 17:02:21 -05:00

Use an activity for the "join channel" dialog instead of a real dialog)

This commit is contained in:
Sebastian Kaspari 2010-03-17 22:43:56 +01:00
parent ca4a207b50
commit 62f5fcc074
5 changed files with 126 additions and 17 deletions

View File

@ -48,6 +48,11 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
android:name=".view.SettingsActivity"
android:label="@string/settings_label">
</activity>
<activity
android:name=".view.JoinActivity"
android:label="@string/join_label"
android:theme="@android:style/Theme.Dialog">
</activity>
<service android:name=".irc.IRCService"></service>
</application>

40
res/layout/join.xml Normal file
View File

@ -0,0 +1,40 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Yaaic - Yet Another Android IRC Client
Copyright 2009-2010 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
-->
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:padding="5px">
<EditText
android:id="@+id/channel"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:singleLine="true"
android:ems="10"
android:text="#" />
<Button
android:id="@+id/join"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Join" />
</LinearLayout>

View File

@ -37,4 +37,6 @@
</string>
<string name="settings_label">Settings</string>
<string name="join_label">Join channel</string>
</resources>

View File

@ -21,7 +21,6 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
package org.yaaic.view;
import android.app.Activity;
import android.app.Dialog;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@ -34,10 +33,8 @@ import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.View.OnKeyListener;
import android.widget.AdapterView;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Gallery;
import android.widget.ImageView;
@ -198,20 +195,7 @@ public class ConversationActivity extends Activity implements ServiceConnection,
finish();
break;
case R.id.join:
final Dialog dialog = new Dialog(this);
dialog.setContentView(R.layout.channeldialog);
dialog.setTitle(R.string.channel);
Button button = (Button) dialog.findViewById(R.id.join);
button.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
String channel = ((EditText) v.getRootView().findViewById(R.id.channel)).getText().toString();
binder.getService().getConnection(serverId).joinChannel(channel);
dialog.cancel();
}
});
dialog.show();
startActivityForResult(new Intent(this, JoinActivity.class), 0);
break;
}
@ -380,6 +364,20 @@ public class ConversationActivity extends Activity implements ServiceConnection,
}
return false;
}
/**
* On activity result
*/
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
if (resultCode == RESULT_OK) {
// currently there's only the "join channel" activity
binder.getService().getConnection(serverId).joinChannel(
data.getExtras().getString("channel")
);
}
}
/**
* On channel selected/focused

View File

@ -0,0 +1,64 @@
/*
Yaaic - Yet Another Android IRC Client
Copyright 2009-2010 Sebastian Kaspari
This file is part of Yaaic.
Yaaic is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
Yaaic is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
*/
package org.yaaic.view;
import org.yaaic.R;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
/**
* Small dialog to show an edittext for joining channels
*
* @author Sebastian Kaspari <sebastian@yaaic.org>
*
*/
public class JoinActivity extends Activity implements OnClickListener
{
/**
* On create
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.join);
((Button) findViewById(R.id.join)).setOnClickListener(this);
}
/**
* On click
*/
public void onClick(View v)
{
Intent intent = new Intent();
intent.putExtra("channel", ((EditText) findViewById(R.id.channel)).getText().toString());
setResult(RESULT_OK, intent);
finish();
}
}