mirror of
https://github.com/moparisthebest/Yaaic
synced 2025-01-10 05:08:18 -05:00
ConversationActivity: Use scrollback class
This commit is contained in:
parent
420d7df0b1
commit
9ddd45ed92
@ -62,6 +62,7 @@ import org.yaaic.model.Broadcast;
|
|||||||
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;
|
||||||
|
import org.yaaic.model.Scrollback;
|
||||||
import org.yaaic.model.Server;
|
import org.yaaic.model.Server;
|
||||||
import org.yaaic.model.Status;
|
import org.yaaic.model.Status;
|
||||||
import org.yaaic.receiver.ConversationReceiver;
|
import org.yaaic.receiver.ConversationReceiver;
|
||||||
@ -84,6 +85,7 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
private ViewSwitcher switcher;
|
private ViewSwitcher switcher;
|
||||||
private Gallery deck;
|
private Gallery deck;
|
||||||
private DeckAdapter deckAdapter;
|
private DeckAdapter deckAdapter;
|
||||||
|
private Scrollback scrollback;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* On create
|
* On create
|
||||||
@ -118,6 +120,9 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
for (Conversation conversation : mConversations) {
|
for (Conversation conversation : mConversations) {
|
||||||
onNewConversation(conversation.getName());
|
onNewConversation(conversation.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Create a new scrollback history
|
||||||
|
scrollback = new Scrollback();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -400,13 +405,21 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
*/
|
*/
|
||||||
public boolean onKey(View view, int keyCode, KeyEvent event)
|
public boolean onKey(View view, int keyCode, KeyEvent event)
|
||||||
{
|
{
|
||||||
if (keyCode == KeyEvent.KEYCODE_DPAD_UP && event.getAction() == KeyEvent.ACTION_UP) {
|
EditText input = (EditText) view;
|
||||||
// XXX: History up (Implement me..)
|
|
||||||
|
if (keyCode == KeyEvent.KEYCODE_DPAD_UP && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
|
String message = scrollback.goBack();
|
||||||
|
if (message != null) {
|
||||||
|
input.setText(message);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && event.getAction() == KeyEvent.ACTION_UP) {
|
if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN && event.getAction() == KeyEvent.ACTION_DOWN) {
|
||||||
// XXX: History down (Implement me..)
|
String message = scrollback.goForward();
|
||||||
|
if (message != null) {
|
||||||
|
input.setText(message);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -419,7 +432,6 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
onConversationMessage(server.getSelectedConversation());
|
onConversationMessage(server.getSelectedConversation());
|
||||||
}
|
}
|
||||||
|
|
||||||
EditText input = (EditText) view;
|
|
||||||
String text = input.getText().toString();
|
String text = input.getText().toString();
|
||||||
input.setText("");
|
input.setText("");
|
||||||
|
|
||||||
@ -428,6 +440,8 @@ public class ConversationActivity extends Activity implements ServiceConnection,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
scrollback.addMessage(text);
|
||||||
|
|
||||||
Conversation conversation = deckAdapter.getItem(deck.getSelectedItemPosition());
|
Conversation conversation = deckAdapter.getItem(deck.getSelectedItemPosition());
|
||||||
|
|
||||||
if (conversation != null) {
|
if (conversation != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user