mirror of
https://github.com/moparisthebest/Yaaic
synced 2024-08-13 16:53:50 -04:00
Implemented simple UsersActivity to show list of users currently in a channel
This commit is contained in:
parent
6e735f17b8
commit
340049f44c
28
res/layout/useritem.xml
Normal file
28
res/layout/useritem.xml
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<?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/>.
|
||||||
|
-->
|
||||||
|
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
android:id="@+id/host"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
android:padding="7px"
|
||||||
|
android:text=""
|
||||||
|
android:textSize="12px" />
|
30
res/layout/users.xml
Normal file
30
res/layout/users.xml
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
<?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">
|
||||||
|
<ListView
|
||||||
|
android:id="@android:id/list"
|
||||||
|
android:layout_width="fill_parent"
|
||||||
|
android:layout_height="fill_parent" />
|
||||||
|
</LinearLayout>
|
@ -59,6 +59,7 @@ import org.yaaic.listener.ConversationListener;
|
|||||||
import org.yaaic.listener.ServerListener;
|
import org.yaaic.listener.ServerListener;
|
||||||
import org.yaaic.model.Broadcast;
|
import org.yaaic.model.Broadcast;
|
||||||
import org.yaaic.model.Conversation;
|
import org.yaaic.model.Conversation;
|
||||||
|
import org.yaaic.model.Extra;
|
||||||
import org.yaaic.model.Message;
|
import org.yaaic.model.Message;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
import org.yaaic.model.Status;
|
import org.yaaic.model.Status;
|
||||||
@ -250,7 +251,14 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
case R.id.users:
|
case R.id.users:
|
||||||
Conversation conversationForUserList = deckAdapter.getItem(deck.getSelectedItemPosition());
|
Conversation conversationForUserList = deckAdapter.getItem(deck.getSelectedItemPosition());
|
||||||
if (conversationForUserList.getType() == Conversation.TYPE_CHANNEL) {
|
if (conversationForUserList.getType() == Conversation.TYPE_CHANNEL) {
|
||||||
startActivity(new Intent(this, UsersActivity.class));
|
Intent intent = new Intent(this, UsersActivity.class);
|
||||||
|
intent.putExtra(
|
||||||
|
Extra.USERS,
|
||||||
|
binder.getService().getConnection(server.getId()).getUsersAsStringArray(
|
||||||
|
conversationForUserList.getName()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
startActivity(intent);
|
||||||
} else {
|
} else {
|
||||||
Toast.makeText(this, "Only usable from within a channel", Toast.LENGTH_SHORT).show();
|
Toast.makeText(this, "Only usable from within a channel", Toast.LENGTH_SHORT).show();
|
||||||
}
|
}
|
||||||
|
@ -20,14 +20,34 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package org.yaaic.activity;
|
package org.yaaic.activity;
|
||||||
|
|
||||||
import android.app.Activity;
|
import org.yaaic.R;
|
||||||
|
import org.yaaic.model.Extra;
|
||||||
|
|
||||||
|
import android.app.ListActivity;
|
||||||
|
import android.os.Bundle;
|
||||||
|
import android.view.Window;
|
||||||
|
import android.widget.ArrayAdapter;
|
||||||
|
import android.widget.ListView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User Activity - Shows a list of users in the current channel
|
* User Activity - Shows a list of users in the current channel
|
||||||
*
|
*
|
||||||
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
* @author Sebastian Kaspari <sebastian@yaaic.org>
|
||||||
*/
|
*/
|
||||||
public class UsersActivity extends Activity
|
public class UsersActivity extends ListActivity
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* On create
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void onCreate(Bundle savedInstanceState)
|
||||||
|
{
|
||||||
|
super.onCreate(savedInstanceState);
|
||||||
|
requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||||
|
|
||||||
|
setContentView(R.layout.users);
|
||||||
|
|
||||||
|
String[] users = getIntent().getExtras().getStringArray(Extra.USERS);
|
||||||
|
getListView().setAdapter(new ArrayAdapter<String>(this, R.layout.useritem, users));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -996,6 +996,24 @@ public class IRCConnection extends PircBot
|
|||||||
return channels;
|
return channels;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get list of users in a channel as array of strings
|
||||||
|
*
|
||||||
|
* @param channel Name of the channel
|
||||||
|
*/
|
||||||
|
public String[] getUsersAsStringArray(String channel)
|
||||||
|
{
|
||||||
|
User[] userArray = getUsers(channel);
|
||||||
|
int mLength = userArray.length;
|
||||||
|
String[] users = new String[mLength];
|
||||||
|
|
||||||
|
for (int i = 0; i < mLength; i++) {
|
||||||
|
users[i] = userArray[i].getPrefix() + userArray[i].getNick();
|
||||||
|
}
|
||||||
|
|
||||||
|
return users;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Quits from the IRC server with default reason.
|
* Quits from the IRC server with default reason.
|
||||||
*/
|
*/
|
||||||
|
@ -29,4 +29,5 @@ public class Extra
|
|||||||
{
|
{
|
||||||
public static final String SERVER = "server";
|
public static final String SERVER = "server";
|
||||||
public static final String CONVERSATION = "conversation";
|
public static final String CONVERSATION = "conversation";
|
||||||
|
public static final String USERS = "users";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user