Remove content-type and parentId from private messages

and turn them into a regular string.
This commit is contained in:
Torsten Grote
2016-10-27 13:30:34 -02:00
parent a18317e912
commit 78740a6942
18 changed files with 81 additions and 112 deletions

View File

@@ -450,11 +450,11 @@ public class ConversationActivity extends BriarActivity
public void run() {
try {
long now = System.currentTimeMillis();
byte[] body = messagingManager.getMessageBody(m);
String body = messagingManager.getMessageBody(m);
long duration = System.currentTimeMillis() - now;
if (LOG.isLoggable(INFO))
LOG.info("Loading body took " + duration + " ms");
displayMessageBody(m, StringUtils.fromUtf8(body));
displayMessageBody(m, body);
} catch (DbException e) {
if (LOG.isLoggable(WARNING))
LOG.log(WARNING, e.toString(), e);
@@ -656,8 +656,7 @@ public class ConversationActivity extends BriarActivity
public void run() {
try {
storeMessage(privateMessageFactory.createPrivateMessage(
groupId, timestamp, null, "text/plain",
StringUtils.toUtf8(body)), body);
groupId, timestamp, body), body);
} catch (FormatException e) {
throw new RuntimeException(e);
}
@@ -676,9 +675,10 @@ public class ConversationActivity extends BriarActivity
if (LOG.isLoggable(INFO))
LOG.info("Storing message took " + duration + " ms");
MessageId id = m.getMessage().getId();
PrivateMessageHeader h = new PrivateMessageHeader(id,
groupId, m.getMessage().getTimestamp(),
m.getContentType(), true, false, false, false);
PrivateMessageHeader h =
new PrivateMessageHeader(id, groupId,
m.getMessage().getTimestamp(), true, false,
false, false);
ConversationItem item = ConversationItem.from(h);
item.setBody(body);
bodyCache.put(id, body);

View File

@@ -64,7 +64,7 @@ public abstract class BaseMessageFragment extends BaseFragment
@Override
public void onSendClick(String msg) {
if (StringUtils.isTooLong(msg, listener.getMaximumMessageLength())) {
if (StringUtils.utf8IsTooLong(msg, listener.getMaximumMessageLength())) {
Snackbar.make(message, R.string.text_too_long, LENGTH_SHORT).show();
return;
}

View File

@@ -232,7 +232,7 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
public void onSendClick(String text) {
if (text.trim().length() == 0)
return;
if (StringUtils.isTooLong(text, getMaxBodyLength())) {
if (StringUtils.utf8IsTooLong(text, getMaxBodyLength())) {
displaySnackbarShort(R.string.text_too_long);
return;
}

View File

@@ -6,7 +6,7 @@ import android.support.annotation.CallSuper;
import org.briarproject.android.api.AndroidNotificationManager;
import org.briarproject.android.controller.DbControllerImpl;
import org.briarproject.android.controller.handler.ResultExceptionHandler;
import org.briarproject.api.clients.BaseMessage;
import org.briarproject.api.clients.ThreadedMessage;
import org.briarproject.api.clients.NamedGroup;
import org.briarproject.api.clients.PostHeader;
import org.briarproject.api.crypto.CryptoExecutor;
@@ -34,7 +34,7 @@ import java.util.logging.Logger;
import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends ThreadItem, H extends PostHeader, M extends BaseMessage>
public abstract class ThreadListControllerImpl<G extends NamedGroup, I extends ThreadItem, H extends PostHeader, M extends ThreadedMessage>
extends DbControllerImpl
implements ThreadListController<G, I, H>, EventListener {