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