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