use of de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage in project TumCampusApp by TCA-Team.
the class RSASignerTestCase method testAsciiMessageSigning.
/**
* Tests that a valid ASCII-based message is correctly signed.
*/
@Test
public void testAsciiMessageSigning() {
signer = new RSASigner(privateKeyFixture);
ChatMessage message = messageFixtures.get(0);
assertThat(signer.sign(message.getText())).isEqualTo(message.getSignature());
}
use of de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage in project TumCampusApp by TCA-Team.
the class RSASignerTestCase method buildChatMessage.
private ChatMessage buildChatMessage(String text, String signature) {
ChatMessage message = new ChatMessage(text);
message.setSignature(signature);
return message;
}
use of de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage in project TumCampusApp by TCA-Team.
the class RSASignerTestCase method testUnicodeMessageSigning.
/**
* Tests that a unicode (european) message is correctly signed.
*/
@Test
public void testUnicodeMessageSigning() {
signer = new RSASigner(privateKeyFixture);
ChatMessage message = messageFixtures.get(1);
assertThat(signer.sign(message.getText())).isEqualTo(message.getSignature());
}
use of de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage in project TumCampusApp by TCA-Team.
the class ChatNotification method onDataLoaded.
public void onDataLoaded() {
List<ChatMessage> messages = Lists.reverse(chatMessageDao.getLastUnread(chatRoom.getId()));
Intent intent = new Intent(Const.CHAT_BROADCAST_NAME);
intent.putExtra("GCMChat", this.extras);
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
notificationText = null;
if (messages != null) {
for (ChatMessage msg : messages) {
if (notificationText == null) {
notificationText = msg.getText();
} else {
notificationText += "\n" + msg.getText();
}
}
}
// Put the data into the intent
Intent notificationIntent = new Intent(context, ChatActivity.class);
notificationIntent.putExtra(Const.CURRENT_CHAT_ROOM, new Gson().toJson(chatRoom));
sBuilder = TaskStackBuilder.create(context);
sBuilder.addNextIntent(new Intent(context, MainActivity.class));
sBuilder.addNextIntent(new Intent(context, ChatRoomsActivity.class));
sBuilder.addNextIntent(notificationIntent);
showNotification();
}
use of de.tum.in.tumcampusapp.component.ui.chat.model.ChatMessage in project TumCampusApp by TCA-Team.
the class ChatActivity method sendMessage.
private void sendMessage(String text) {
if (chatHistoryAdapter.mEditedItem == null) {
final ChatMessage message = new ChatMessage(text, currentChatMember);
message.setRoom(currentChatRoom.getId());
chatHistoryAdapter.add(message);
chatMessageViewModel.addToUnsent(message);
} else {
chatHistoryAdapter.mEditedItem.setText(etMessage.getText().toString());
chatHistoryAdapter.mEditedItem.setRoom(currentChatRoom.getId());
chatHistoryAdapter.mEditedItem.setSendingStatus(ChatMessage.STATUS_SENDING);
chatHistoryAdapter.mEditedItem.setMember(currentChatMember);
chatMessageViewModel.addToUnsent(chatHistoryAdapter.mEditedItem);
chatHistoryAdapter.mEditedItem = null;
chatMessageViewModel.markAsRead(currentChatRoom.getId());
chatHistoryAdapter.updateHistory(chatMessageViewModel.getAll(currentChatRoom.getId()));
}
// let the service handle the actual sending of the message
SendMessageService.enqueueWork(this, new Intent());
}
Aggregations