mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Address actual review issues
This commit is contained in:
@@ -17,6 +17,7 @@ import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
@@ -24,7 +25,7 @@ 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;
|
||||
import static org.briarproject.api.privategroup.PrivateGroupConstants.MAX_GROUP_POST_BODY_LENGTH;
|
||||
|
||||
public class CreateGroupActivity extends ContactSelectorActivity implements
|
||||
CreateGroupListener, MessageFragmentListener {
|
||||
@@ -125,7 +126,7 @@ public class CreateGroupActivity extends ContactSelectorActivity implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onButtonClick(String message) {
|
||||
public boolean onButtonClick(@NotNull String message) {
|
||||
controller.sendInvitation(groupId, contacts, message,
|
||||
new UiResultExceptionHandler<Void, DbException>(this) {
|
||||
@Override
|
||||
@@ -147,7 +148,7 @@ public class CreateGroupActivity extends ContactSelectorActivity implements
|
||||
|
||||
@Override
|
||||
public int getMaximumMessageLength() {
|
||||
return MAX_MESSAGE_BODY_LENGTH;
|
||||
return MAX_GROUP_POST_BODY_LENGTH;
|
||||
}
|
||||
|
||||
private void openNewGroup() {
|
||||
|
||||
@@ -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.annotation.UiThread;
|
||||
import android.support.design.widget.Snackbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@@ -12,10 +13,10 @@ 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.api.nullsafety.NotNullByDefault;
|
||||
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;
|
||||
|
||||
@@ -79,6 +80,8 @@ public abstract class BaseMessageFragment extends BaseFragment
|
||||
}
|
||||
}
|
||||
|
||||
@UiThread
|
||||
@NotNullByDefault
|
||||
public interface MessageFragmentListener {
|
||||
|
||||
void onBackPressed();
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.android.sharing;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.CallSuper;
|
||||
import android.support.annotation.UiThread;
|
||||
@@ -10,6 +9,7 @@ import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.fragment.BaseFragment.BaseFragmentListener;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DatabaseExecutor;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
@@ -22,8 +22,8 @@ public abstract class ContactSelectorActivity extends BriarActivity implements
|
||||
|
||||
final static String CONTACTS = "contacts";
|
||||
|
||||
protected volatile GroupId groupId;
|
||||
protected volatile Collection<ContactId> contacts;
|
||||
protected GroupId groupId;
|
||||
protected Collection<ContactId> contacts;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle bundle) {
|
||||
@@ -58,9 +58,7 @@ public abstract class ContactSelectorActivity extends BriarActivity implements
|
||||
this.contacts = contacts;
|
||||
}
|
||||
|
||||
/**
|
||||
* This must only be called from a DbThread
|
||||
*/
|
||||
@DatabaseExecutor
|
||||
public abstract boolean isDisabled(GroupId groupId, Contact c)
|
||||
throws DbException;
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ import android.support.annotation.UiThread;
|
||||
import org.briarproject.android.DestroyableContext;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DatabaseExecutor;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
@@ -12,8 +13,10 @@ import java.util.Collection;
|
||||
|
||||
public interface ContactSelectorListener extends DestroyableContext {
|
||||
|
||||
@Deprecated
|
||||
void runOnDbThread(Runnable runnable);
|
||||
|
||||
@DatabaseExecutor
|
||||
boolean isDisabled(GroupId groupId, Contact c) throws DbException;
|
||||
|
||||
@UiThread
|
||||
|
||||
@@ -9,8 +9,10 @@ import android.widget.Toast;
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.sharing.BaseMessageFragment.MessageFragmentListener;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DatabaseExecutor;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
@@ -64,20 +66,21 @@ public abstract class ShareActivity extends ContactSelectorActivity implements
|
||||
|
||||
@UiThread
|
||||
@Override
|
||||
public boolean onButtonClick(String message) {
|
||||
share(message);
|
||||
public boolean onButtonClick(@NotNull String message) {
|
||||
share(groupId, contacts, message);
|
||||
setResult(RESULT_OK);
|
||||
supportFinishAfterTransition();
|
||||
return true;
|
||||
}
|
||||
|
||||
private void share(final String msg) {
|
||||
private void share(final GroupId g, final Collection<ContactId> contacts,
|
||||
final String msg) {
|
||||
runOnDbThread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
for (ContactId c : contacts) {
|
||||
share(groupId, c, msg);
|
||||
share(g, c, msg);
|
||||
}
|
||||
} catch (DbException e) {
|
||||
// TODO proper error handling
|
||||
@@ -89,9 +92,7 @@ public abstract class ShareActivity extends ContactSelectorActivity implements
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* This method must be run from the DbThread.
|
||||
*/
|
||||
@DatabaseExecutor
|
||||
protected abstract void share(GroupId g, ContactId c, String msg)
|
||||
throws DbException;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user