mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Pre-address potential review issues
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user