mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 18:59:06 +01:00
Pre-address potential review issues
This commit is contained in:
@@ -623,6 +623,7 @@ public class ConversationActivity extends BriarActivity
|
||||
long timestamp = System.currentTimeMillis();
|
||||
timestamp = Math.max(timestamp, getMinTimestampForNewMessage());
|
||||
createMessage(StringUtils.toUtf8(text), timestamp);
|
||||
textInputView.setText("");
|
||||
}
|
||||
|
||||
private long getMinTimestampForNewMessage() {
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.briarproject.R;
|
||||
import org.briarproject.android.ActivityComponent;
|
||||
import org.briarproject.android.fragment.BaseFragment;
|
||||
import org.briarproject.android.view.TextInputView;
|
||||
import org.briarproject.android.view.TextInputView.TextInputListener;
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
@@ -37,7 +38,7 @@ 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 {
|
||||
implements TextInputListener {
|
||||
|
||||
public static final String TAG =
|
||||
IntroductionMessageFragment.class.getName();
|
||||
@@ -56,7 +57,8 @@ public class IntroductionMessageFragment extends BaseFragment
|
||||
@Inject
|
||||
protected volatile IntroductionManager introductionManager;
|
||||
|
||||
public static IntroductionMessageFragment newInstance(int contactId1, int contactId2) {
|
||||
public static IntroductionMessageFragment newInstance(int contactId1,
|
||||
int contactId2) {
|
||||
Bundle args = new Bundle();
|
||||
args.putInt(CONTACT_ID_1, contactId1);
|
||||
args.putInt(CONTACT_ID_2, contactId2);
|
||||
|
||||
@@ -24,12 +24,13 @@ import javax.inject.Inject;
|
||||
|
||||
import static android.support.v4.app.ActivityOptionsCompat.makeCustomAnimation;
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||
|
||||
public class CreateGroupActivity extends ContactSelectorActivity implements
|
||||
CreateGroupListener, MessageFragmentListener {
|
||||
|
||||
@Inject
|
||||
protected CreateGroupController controller;
|
||||
CreateGroupController controller;
|
||||
|
||||
@Override
|
||||
public void injectActivity(ActivityComponent component) {
|
||||
@@ -144,6 +145,11 @@ public class CreateGroupActivity extends ContactSelectorActivity implements
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumMessageLength() {
|
||||
return MAX_MESSAGE_BODY_LENGTH;
|
||||
}
|
||||
|
||||
private void openNewGroup() {
|
||||
Intent i = new Intent(this, GroupActivity.class);
|
||||
i.putExtra(GROUP_ID, groupId.getBytes());
|
||||
|
||||
@@ -1,21 +1,24 @@
|
||||
package org.briarproject.android.privategroup.creation;
|
||||
|
||||
import android.support.annotation.StringRes;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.ActivityComponent;
|
||||
import org.briarproject.android.sharing.BaseMessageFragment;
|
||||
|
||||
|
||||
public class CreateGroupMessageFragment extends BaseMessageFragment {
|
||||
|
||||
private final static String TAG =
|
||||
CreateGroupMessageFragment.class.getName();
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getButtonText() {
|
||||
return R.string.groups_create_group_invitation_button;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getHintText() {
|
||||
return R.string.forum_share_message;
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.briarproject.android.sharing;
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -11,6 +12,9 @@ import org.briarproject.R;
|
||||
import org.briarproject.android.fragment.BaseFragment;
|
||||
import org.briarproject.android.view.LargeTextInputView;
|
||||
import org.briarproject.android.view.TextInputView.TextInputListener;
|
||||
import org.briarproject.util.StringUtils;
|
||||
|
||||
import static android.support.design.widget.Snackbar.LENGTH_SHORT;
|
||||
|
||||
import static org.briarproject.api.sharing.SharingConstants.MAX_INVITATION_MESSAGE_LENGTH;
|
||||
import static org.briarproject.util.StringUtils.truncateUtf8;
|
||||
@@ -46,8 +50,10 @@ public abstract class BaseMessageFragment extends BaseFragment
|
||||
listener.setTitle(res);
|
||||
}
|
||||
|
||||
protected abstract @StringRes int getButtonText();
|
||||
protected abstract @StringRes int getHintText();
|
||||
@StringRes
|
||||
protected abstract int getButtonText();
|
||||
@StringRes
|
||||
protected abstract int getHintText();
|
||||
|
||||
@Override
|
||||
public void onStart() {
|
||||
@@ -57,6 +63,11 @@ public abstract class BaseMessageFragment extends BaseFragment
|
||||
|
||||
@Override
|
||||
public void onSendClick(String msg) {
|
||||
if (StringUtils.isTooLong(msg, listener.getMaximumMessageLength())) {
|
||||
Snackbar.make(message, R.string.text_too_long, LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
// disable button to prevent accidental double actions
|
||||
message.setSendButtonEnabled(false);
|
||||
message.hideSoftKeyboard();
|
||||
@@ -77,6 +88,8 @@ public abstract class BaseMessageFragment extends BaseFragment
|
||||
/** Returns true when the button click has been consumed. */
|
||||
boolean onButtonClick(String message);
|
||||
|
||||
int getMaximumMessageLength();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,11 +10,13 @@ import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||
|
||||
public class ShareBlogActivity extends ShareActivity {
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject
|
||||
protected volatile BlogSharingManager blogSharingManager;
|
||||
volatile BlogSharingManager blogSharingManager;
|
||||
|
||||
@Override
|
||||
BaseMessageFragment getMessageFragment() {
|
||||
@@ -42,4 +44,8 @@ public class ShareBlogActivity extends ShareActivity {
|
||||
return R.string.blogs_sharing_error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumMessageLength() {
|
||||
return MAX_MESSAGE_BODY_LENGTH;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.android.sharing;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -25,11 +26,13 @@ public class ShareBlogMessageFragment extends BaseMessageFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getButtonText() {
|
||||
return R.string.blogs_sharing_button;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getHintText() {
|
||||
return R.string.forum_share_message;
|
||||
}
|
||||
|
||||
@@ -10,11 +10,13 @@ import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||
|
||||
public class ShareForumActivity extends ShareActivity {
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject
|
||||
protected volatile ForumSharingManager forumSharingManager;
|
||||
volatile ForumSharingManager forumSharingManager;
|
||||
|
||||
@Override
|
||||
BaseMessageFragment getMessageFragment() {
|
||||
@@ -42,4 +44,8 @@ public class ShareForumActivity extends ShareActivity {
|
||||
return R.string.forum_share_error;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumMessageLength() {
|
||||
return MAX_MESSAGE_BODY_LENGTH;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package org.briarproject.android.sharing;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.StringRes;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -25,11 +26,13 @@ public class ShareForumMessageFragment extends BaseMessageFragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getButtonText() {
|
||||
return R.string.forum_share_button;
|
||||
}
|
||||
|
||||
@Override
|
||||
@StringRes
|
||||
protected int getHintText() {
|
||||
return R.string.forum_share_message;
|
||||
}
|
||||
|
||||
@@ -253,6 +253,7 @@ public abstract class ThreadListActivity<G extends NamedGroup, I extends ThreadI
|
||||
replyItem != null ? replyItem.getId() : null, handler);
|
||||
textInput.hideSoftKeyboard();
|
||||
textInput.setVisibility(GONE);
|
||||
textInput.setText("");
|
||||
adapter.setReplyItem(null);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,6 @@ public class TextInputView extends KeyboardAwareLinearLayout
|
||||
public void onClick(View v) {
|
||||
if (listener != null) {
|
||||
listener.onSendClick(ui.editText.getText().toString());
|
||||
ui.editText.setText("");
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user