mirror of
https://github.com/moparisthebest/Yaaic
synced 2025-01-08 12:18:07 -05:00
Include channel topic in the displayed conversation title
This commit is contained in:
parent
9a8bf44d63
commit
09fedc6975
@ -42,6 +42,7 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
android:paddingLeft="3dp"
|
android:paddingLeft="3dp"
|
||||||
android:textSize="12sp"
|
android:textSize="12sp"
|
||||||
android:text="Server"
|
android:text="Server"
|
||||||
|
android:maxLines="1"
|
||||||
android:layout_weight="1" />
|
android:layout_weight="1" />
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
<ViewSwitcher
|
<ViewSwitcher
|
||||||
|
@ -39,6 +39,7 @@ import org.yaaic.listener.ConversationSelectedListener;
|
|||||||
import org.yaaic.listener.ServerListener;
|
import org.yaaic.listener.ServerListener;
|
||||||
import org.yaaic.listener.SpeechClickListener;
|
import org.yaaic.listener.SpeechClickListener;
|
||||||
import org.yaaic.model.Broadcast;
|
import org.yaaic.model.Broadcast;
|
||||||
|
import org.yaaic.model.Channel;
|
||||||
import org.yaaic.model.Conversation;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Extra;
|
import org.yaaic.model.Extra;
|
||||||
import org.yaaic.model.Message;
|
import org.yaaic.model.Message;
|
||||||
@ -198,6 +199,7 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_MESSAGE));
|
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_MESSAGE));
|
||||||
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_NEW));
|
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_NEW));
|
||||||
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_REMOVE));
|
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_REMOVE));
|
||||||
|
registerReceiver(channelReceiver, new IntentFilter(Broadcast.CONVERSATION_TOPIC));
|
||||||
|
|
||||||
serverReceiver = new ServerReceiver(this);
|
serverReceiver = new ServerReceiver(this);
|
||||||
registerReceiver(serverReceiver, new IntentFilter(Broadcast.SERVER_UPDATE));
|
registerReceiver(serverReceiver, new IntentFilter(Broadcast.SERVER_UPDATE));
|
||||||
@ -490,6 +492,23 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On topic change
|
||||||
|
*/
|
||||||
|
public void onTopicChanged(String target)
|
||||||
|
{
|
||||||
|
String selected = server.getSelectedConversation();
|
||||||
|
if (selected.equals(target)) {
|
||||||
|
// onTopicChanged is only called for channels
|
||||||
|
Channel channel = (Channel) server.getConversation(selected);
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(server.getTitle() + " - " + channel.getName());
|
||||||
|
if (!(channel.getTopic()).equals(""))
|
||||||
|
sb.append(" - " + channel.getTopic());
|
||||||
|
((TextView) findViewById(R.id.title)).setText(sb.toString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On server status update
|
* On server status update
|
||||||
*/
|
*/
|
||||||
|
@ -738,6 +738,14 @@ public class IRCConnection extends PircBot
|
|||||||
target
|
target
|
||||||
);
|
);
|
||||||
service.sendBroadcast(intent);
|
service.sendBroadcast(intent);
|
||||||
|
|
||||||
|
// update the displayed conversation title if necessary
|
||||||
|
intent = Broadcast.createConversationIntent(
|
||||||
|
Broadcast.CONVERSATION_TOPIC,
|
||||||
|
server.getId(),
|
||||||
|
target
|
||||||
|
);
|
||||||
|
service.sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,4 +47,11 @@ public interface ConversationListener
|
|||||||
* @param target
|
* @param target
|
||||||
*/
|
*/
|
||||||
public void onRemoveConversation(String target);
|
public void onRemoveConversation(String target);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* On topic changed (for given target)
|
||||||
|
*
|
||||||
|
* @param target
|
||||||
|
*/
|
||||||
|
public void onTopicChanged(String target);
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@ along with Yaaic. If not, see <http://www.gnu.org/licenses/>.
|
|||||||
*/
|
*/
|
||||||
package org.yaaic.listener;
|
package org.yaaic.listener;
|
||||||
|
|
||||||
|
import org.yaaic.model.Channel;
|
||||||
import org.yaaic.model.Conversation;
|
import org.yaaic.model.Conversation;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
import org.yaaic.view.ConversationSwitcher;
|
import org.yaaic.view.ConversationSwitcher;
|
||||||
@ -62,7 +63,11 @@ public class ConversationSelectedListener implements OnItemSelectedListener
|
|||||||
Conversation conversation = (Conversation) deck.getItemAtPosition(position);
|
Conversation conversation = (Conversation) deck.getItemAtPosition(position);
|
||||||
|
|
||||||
if (conversation != null && conversation.getType() != Conversation.TYPE_SERVER) {
|
if (conversation != null && conversation.getType() != Conversation.TYPE_SERVER) {
|
||||||
titleView.setText(server.getTitle() + " - " + conversation.getName());
|
StringBuilder sb = new StringBuilder();
|
||||||
|
sb.append(server.getTitle() + " - " + conversation.getName());
|
||||||
|
if (conversation.getType() == Conversation.TYPE_CHANNEL && !((Channel)conversation).getTopic().equals(""))
|
||||||
|
sb.append(" - " + ((Channel)conversation).getTopic());
|
||||||
|
titleView.setText(sb.toString());
|
||||||
} else {
|
} else {
|
||||||
onNothingSelected(deck);
|
onNothingSelected(deck);
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,7 @@ public abstract class Broadcast
|
|||||||
public static final String CONVERSATION_MESSAGE = "org.yaaic.conversation.message";
|
public static final String CONVERSATION_MESSAGE = "org.yaaic.conversation.message";
|
||||||
public static final String CONVERSATION_NEW = "org.yaaic.conversation.new";
|
public static final String CONVERSATION_NEW = "org.yaaic.conversation.new";
|
||||||
public static final String CONVERSATION_REMOVE = "org.yaaic.conversation.remove";
|
public static final String CONVERSATION_REMOVE = "org.yaaic.conversation.remove";
|
||||||
|
public static final String CONVERSATION_TOPIC = "org.yaaic.conversation.topic";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create an Intent for conversation broadcasting
|
* Create an Intent for conversation broadcasting
|
||||||
|
@ -72,6 +72,8 @@ public class ConversationReceiver extends BroadcastReceiver
|
|||||||
listener.onNewConversation(intent.getExtras().getString(Extra.CONVERSATION));
|
listener.onNewConversation(intent.getExtras().getString(Extra.CONVERSATION));
|
||||||
} else if (action.equals(Broadcast.CONVERSATION_REMOVE)) {
|
} else if (action.equals(Broadcast.CONVERSATION_REMOVE)) {
|
||||||
listener.onRemoveConversation(intent.getExtras().getString(Extra.CONVERSATION));
|
listener.onRemoveConversation(intent.getExtras().getString(Extra.CONVERSATION));
|
||||||
|
} else if (action.equals(Broadcast.CONVERSATION_TOPIC)) {
|
||||||
|
listener.onTopicChanged(intent.getExtras().getString(Extra.CONVERSATION));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user