use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method attachFileToConversation.
private void attachFileToConversation(Conversation conversation, Uri uri, String type) {
if (conversation == null) {
return;
}
final Toast prepareFileToast = Toast.makeText(getActivity(), getText(R.string.preparing_file), Toast.LENGTH_LONG);
prepareFileToast.show();
activity.delegateUriPermissionsToService(uri);
activity.xmppConnectionService.attachFileToConversation(conversation, uri, type, new UiInformableCallback<Message>() {
@Override
public void inform(final String text) {
hidePrepareFileToast(prepareFileToast);
runOnUiThread(() -> activity.replaceToast(text));
}
@Override
public void success(Message message) {
runOnUiThread(() -> activity.hideToast());
hidePrepareFileToast(prepareFileToast);
}
@Override
public void error(final int errorCode, Message message) {
hidePrepareFileToast(prepareFileToast);
runOnUiThread(() -> activity.replaceToast(getString(errorCode)));
}
@Override
public void userInputRequried(PendingIntent pi, Message message) {
hidePrepareFileToast(prepareFileToast);
}
});
}
use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method attachImagesToConversation.
private void attachImagesToConversation(Conversation conversation, Uri uri) {
if (conversation == null) {
return;
}
final Toast prepareFileToast = Toast.makeText(getActivity(), getText(R.string.preparing_image), Toast.LENGTH_LONG);
prepareFileToast.show();
activity.delegateUriPermissionsToService(uri);
activity.xmppConnectionService.attachImageToConversation(conversation, uri, new UiCallback<Message>() {
@Override
public void userInputRequried(PendingIntent pi, Message object) {
hidePrepareFileToast(prepareFileToast);
}
@Override
public void success(Message message) {
hidePrepareFileToast(prepareFileToast);
}
@Override
public void error(final int error, Message message) {
hidePrepareFileToast(prepareFileToast);
activity.runOnUiThread(() -> activity.replaceToast(getString(error)));
}
});
}
use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.
the class ConversationFragment method sendMessage.
private void sendMessage() {
final String body = binding.textinput.getText().toString();
final Conversation conversation = this.conversation;
if (body.length() == 0 || conversation == null) {
return;
}
final Message message;
if (conversation.getCorrectingMessage() == null) {
message = new Message(conversation, body, conversation.getNextEncryption());
if (conversation.getMode() == Conversation.MODE_MULTI) {
final Jid nextCounterpart = conversation.getNextCounterpart();
if (nextCounterpart != null) {
message.setCounterpart(nextCounterpart);
message.setTrueCounterpart(conversation.getMucOptions().getTrueCounterpart(nextCounterpart));
message.setType(Message.TYPE_PRIVATE);
}
}
} else {
message = conversation.getCorrectingMessage();
message.setBody(body);
message.setEdited(message.getUuid());
message.setUuid(UUID.randomUUID().toString());
}
switch(message.getConversation().getNextEncryption()) {
case Message.ENCRYPTION_OTR:
sendOtrMessage(message);
break;
case Message.ENCRYPTION_PGP:
sendPgpMessage(message);
break;
case Message.ENCRYPTION_AXOLOTL:
if (!trustKeysIfNeeded(REQUEST_TRUST_KEYS_TEXT)) {
sendAxolotlMessage(message);
}
break;
default:
sendPlainTextMessage(message);
}
}
use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.
the class ExportLogsService method writeToFile.
private void writeToFile(Conversation conversation) {
Jid accountJid = resolveAccountUuid(conversation.getAccountUuid());
Jid contactJid = conversation.getJid();
File dir = new File(String.format(DIRECTORY_STRING_FORMAT, accountJid.toBareJid().toString()));
dir.mkdirs();
BufferedWriter bw = null;
try {
for (Message message : mDatabaseBackend.getMessagesIterable(conversation)) {
if (message == null)
continue;
if (message.getType() == Message.TYPE_TEXT || message.hasFileOnRemoteHost()) {
String date = simpleDateFormat.format(new Date(message.getTimeSent()));
if (bw == null) {
bw = new BufferedWriter(new FileWriter(new File(dir, contactJid.toBareJid().toString() + ".txt")));
}
String jid = null;
switch(message.getStatus()) {
case Message.STATUS_RECEIVED:
jid = getMessageCounterpart(message);
break;
case Message.STATUS_SEND:
case Message.STATUS_SEND_RECEIVED:
case Message.STATUS_SEND_DISPLAYED:
jid = accountJid.toBareJid().toString();
break;
}
if (jid != null) {
String body = message.hasFileOnRemoteHost() ? message.getFileParams().url.toString() : message.getBody();
bw.write(String.format(MESSAGE_STRING_FORMAT, date, jid, body.replace("\\\n", "\\ \n").replace("\n", "\\ \n")));
}
}
}
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
if (bw != null) {
bw.close();
}
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
use of de.pixart.messenger.entities.Message in project Pix-Art-Messenger by kriztan.
the class AudioPlayer method resetPlayerUi.
private void resetPlayerUi(RelativeLayout audioPlayer) {
if (audioPlayer == null) {
return;
}
final ViewHolder viewHolder = ViewHolder.get(audioPlayer);
final Message message = (Message) audioPlayer.getTag();
viewHolder.playPause.setImageResource(viewHolder.darkBackground ? R.drawable.ic_play_arrow_white_36dp : R.drawable.ic_play_arrow_black_36dp);
if (message != null) {
viewHolder.runtime.setText(formatTime(message.getFileParams().runtime));
}
viewHolder.progress.setProgress(0);
viewHolder.progress.setEnabled(false);
}
Aggregations