mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Add a controller for contact selection lists
This commit is contained in:
@@ -1,22 +1,27 @@
|
||||
package org.briarproject.android.sharing;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.ActivityComponent;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.android.contactselection.ContactSelectorController;
|
||||
import org.briarproject.android.contactselection.SelectableContactItem;
|
||||
import org.briarproject.android.controller.handler.UiResultExceptionHandler;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.forum.ForumSharingManager;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.widget.Toast.LENGTH_SHORT;
|
||||
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
|
||||
volatile ForumSharingManager forumSharingManager;
|
||||
ShareForumController controller;
|
||||
|
||||
@Override
|
||||
BaseMessageFragment getMessageFragment() {
|
||||
@@ -29,23 +34,37 @@ public class ShareForumActivity extends ShareActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDisabled(GroupId groupId, Contact c) throws DbException {
|
||||
return !forumSharingManager.canBeShared(groupId, c);
|
||||
public ContactSelectorController<SelectableContactItem> getController() {
|
||||
return controller;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void share(GroupId g, ContactId c, String msg)
|
||||
throws DbException {
|
||||
forumSharingManager.sendInvitation(g, c, msg);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getSharingError() {
|
||||
return R.string.forum_share_error;
|
||||
public void onCreate(Bundle bundle) {
|
||||
super.onCreate(bundle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumMessageLength() {
|
||||
return MAX_MESSAGE_BODY_LENGTH;
|
||||
}
|
||||
|
||||
@Override
|
||||
void share(Collection<ContactId> contacts, String msg) {
|
||||
controller.share(groupId, contacts, msg,
|
||||
new UiResultExceptionHandler<Void, DbException>(this) {
|
||||
@Override
|
||||
public void onResultUi(Void result) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExceptionUi(DbException exception) {
|
||||
// TODO proper error handling
|
||||
Toast.makeText(ShareForumActivity.this,
|
||||
R.string.forum_share_error, LENGTH_SHORT)
|
||||
.show();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user