mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 19:59:05 +01:00
Truncate all messages to valid length before sending.
This commit is contained in:
@@ -128,12 +128,7 @@ public class WriteBlogPostActivity extends BriarActivity
|
||||
}
|
||||
|
||||
private void enableOrDisablePublishButton() {
|
||||
int bodyLength =
|
||||
StringUtils.toUtf8(input.getText().toString()).length;
|
||||
if (bodyLength > 0 && bodyLength <= MAX_BLOG_POST_BODY_LENGTH)
|
||||
input.setSendButtonEnabled(true);
|
||||
else
|
||||
input.setSendButtonEnabled(false);
|
||||
input.setSendButtonEnabled(input.getText().length() > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -142,6 +137,7 @@ public class WriteBlogPostActivity extends BriarActivity
|
||||
input.setVisibility(GONE);
|
||||
progressBar.setVisibility(VISIBLE);
|
||||
|
||||
body = StringUtils.truncateUtf8(body, MAX_BLOG_POST_BODY_LENGTH);
|
||||
storePost(body);
|
||||
}
|
||||
|
||||
|
||||
@@ -100,6 +100,7 @@ import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.android.contact.ConversationItem.IncomingItem;
|
||||
import static org.briarproject.android.contact.ConversationItem.OutgoingItem;
|
||||
import static org.briarproject.android.fragment.SettingsFragment.SETTINGS_NAMESPACE;
|
||||
import static org.briarproject.api.messaging.MessagingConstants.MAX_PRIVATE_MESSAGE_BODY_LENGTH;
|
||||
|
||||
public class ConversationActivity extends BriarActivity
|
||||
implements EventListener, IntroductionHandler, TextInputListener {
|
||||
@@ -656,6 +657,7 @@ public class ConversationActivity extends BriarActivity
|
||||
public void onSendClick(String text) {
|
||||
markMessagesRead();
|
||||
if (text.equals("")) return;
|
||||
text = StringUtils.truncateUtf8(text, MAX_PRIVATE_MESSAGE_BODY_LENGTH);
|
||||
long timestamp = System.currentTimeMillis();
|
||||
timestamp = Math.max(timestamp, getMinTimestampForNewMessage());
|
||||
createMessage(StringUtils.toUtf8(text), timestamp);
|
||||
|
||||
@@ -20,6 +20,7 @@ import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.introduction.IntroductionManager;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@@ -33,6 +34,7 @@ import static android.view.View.GONE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.api.introduction.IntroductionConstants.MAX_INTRODUCTION_MESSAGE_LENGTH;
|
||||
|
||||
public class IntroductionMessageFragment extends BaseFragment
|
||||
implements TextInputView.TextInputListener {
|
||||
@@ -176,6 +178,7 @@ public class IntroductionMessageFragment extends BaseFragment
|
||||
ui.message.setSendButtonEnabled(false);
|
||||
|
||||
String msg = ui.message.getText().toString();
|
||||
msg = StringUtils.truncateUtf8(msg, MAX_INTRODUCTION_MESSAGE_LENGTH);
|
||||
makeIntroduction(contact1, contact2, msg);
|
||||
|
||||
// don't wait for the introduction to be made before finishing activity
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.briarproject.api.blogs.BlogSharingManager;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.forum.ForumSharingManager;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -24,6 +25,7 @@ import javax.inject.Inject;
|
||||
import static org.briarproject.android.sharing.ShareActivity.CONTACTS;
|
||||
import static org.briarproject.android.sharing.ShareActivity.getContactsFromIds;
|
||||
import static org.briarproject.api.sharing.SharingConstants.GROUP_ID;
|
||||
import static org.briarproject.api.sharing.SharingConstants.MAX_INVITATION_MESSAGE_LENGTH;
|
||||
|
||||
abstract class ShareMessageFragment extends BaseFragment
|
||||
implements TextInputListener {
|
||||
@@ -103,6 +105,7 @@ abstract class ShareMessageFragment extends BaseFragment
|
||||
// disable button to prevent accidental double invitations
|
||||
ui.message.setSendButtonEnabled(false);
|
||||
|
||||
msg = StringUtils.truncateUtf8(msg, MAX_INVITATION_MESSAGE_LENGTH);
|
||||
share(msg);
|
||||
|
||||
// don't wait for the invitation to be made before finishing activity
|
||||
|
||||
Reference in New Issue
Block a user